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: */
6:
7: #if defined(LIBC_SCCS) && !defined(lint)
8: static char sccsid[] = "@(#)mkstemp.c 5.2 (Berkeley) 3/9/86";
9: #endif LIBC_SCCS and not lint
10:
11: #include <sys/file.h>
12:
13: mkstemp(as)
14: char *as;
15: {
16: register char *s;
17: register unsigned int pid;
18: register int fd, i;
19:
20: pid = getpid();
21: s = as;
22: while (*s++)
23: /* void */;
24: s--;
25: while (*--s == 'X') {
26: *s = (pid % 10) + '0';
27: pid /= 10;
28: }
29: s++;
30: i = 'a';
31: while ((fd = open(as, O_CREAT|O_EXCL|O_RDWR, 0600)) == -1) {
32: if (i == 'z')
33: return(-1);
34: *s = i++;
35: }
36: return(fd);
37: }
Defined functions
Defined variables
sccsid
defined in line
8;
never used