8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libbc / libc / gen / common / mkstemp.c
blob579044ff809d07f771960f5427b39512f85e9b78
1 /*
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
7 #pragma ident "%Z%%M% %I% %E% SMI"
9 #include <sys/file.h>
11 int
12 mkstemp(char *as)
14 char *s;
15 unsigned int pid;
16 int fd, i;
18 pid = getpid();
19 s = as;
20 while (*s++)
21 /* void */;
22 s--;
23 while (*--s == 'X') {
24 *s = (pid % 10) + '0';
25 pid /= 10;
27 s++;
28 i = 'a';
29 while ((fd = open(as, O_CREAT|O_EXCL|O_RDWR, 0600)) == -1) {
30 if (i == 'z')
31 return (-1);
32 *s = i++;
34 return (fd);