From d2e28542b87e47ec47308c9fbe301b8286c91d28 Mon Sep 17 00:00:00 2001 From: Oliver Lehmann Date: Wed, 21 Mar 1990 22:23:09 +0000 Subject: [PATCH] add LCC - a better C-Compiler for WEGA --- WEGA/contrib/lcc/lib/libc/port/gen/mktemp.c | 36 +++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 WEGA/contrib/lcc/lib/libc/port/gen/mktemp.c diff --git a/WEGA/contrib/lcc/lib/libc/port/gen/mktemp.c b/WEGA/contrib/lcc/lib/libc/port/gen/mktemp.c new file mode 100644 index 0000000..f692c25 --- /dev/null +++ b/WEGA/contrib/lcc/lib/libc/port/gen/mktemp.c @@ -0,0 +1,36 @@ +/**************************************************************** + * Routine expects a string of length at least 6, with + * six trailing 'X's. These will be overlaid with a + * letter and the last (5) digigts of the proccess ID. + * If every letter (a thru z) thus inserted leads to + * an existing file name, your string is shortened to + * length zero upon return (first character set to '\0'). + ***************************************************************/ +extern int strlen(), access(), getpid(); + +char * +mktemp(as) +char *as; +{ + register char *s=as; + register unsigned pid; + + pid = getpid(); + s += strlen(as); /* point at the terminal null */ + while(*--s == 'X') { + *s = (pid%10) + '0'; + pid /= 10; + } + if(*++s) { /* maybe there were no 'X's */ + *s = 'a'; + while(access(as, 0) == 0) { + if(++*s > 'z') { + *as = '\0'; + break; + } + } + } else + if(access(as, 0) == 0) + *as = '\0'; + return(as); +}