xref: /csrg-svn/lib/libc/stdio/mktemp.c (revision 26570)
1*26570Sdonn #if defined(LIBC_SCCS) && !defined(lint)
2*26570Sdonn static char sccsid[] = "@(#)mktemp.c	5.2 (Berkeley) 03/09/86";
3*26570Sdonn #endif LIBC_SCCS and not lint
413260Sroot 
513260Sroot char *
613260Sroot mktemp(as)
713260Sroot char *as;
813260Sroot {
913260Sroot 	register char *s;
1013260Sroot 	register unsigned pid;
1113260Sroot 	register i;
1213260Sroot 
1313260Sroot 	pid = getpid();
1413260Sroot 	s = as;
1513260Sroot 	while (*s++)
1613260Sroot 		;
1713260Sroot 	s--;
1813260Sroot 	while (*--s == 'X') {
1913260Sroot 		*s = (pid%10) + '0';
2013260Sroot 		pid /= 10;
2113260Sroot 	}
2213260Sroot 	s++;
2313260Sroot 	i = 'a';
2413260Sroot 	while (access(as, 0) != -1) {
2513260Sroot 		if (i=='z')
2613260Sroot 			return("/");
2713260Sroot 		*s = i++;
2813260Sroot 	}
2913260Sroot 	return(as);
3013260Sroot }
31