diff options
| author | rsc <devnull@localhost> | 2004-05-15 23:55:53 +0000 |
|---|---|---|
| committer | rsc <devnull@localhost> | 2004-05-15 23:55:53 +0000 |
| commit | 61f5c35c9465f0702739b41249a664d409f0482c (patch) | |
| tree | 17546b7dcc76abd9ee74dc7543cc77121acfe39a /src/cmd/postscript/common/tempnam.c | |
| parent | 173302913ebce353eadcbb12d71c3759cbe79e34 (diff) | |
| download | plan9port-61f5c35c9465f0702739b41249a664d409f0482c.tar.gz plan9port-61f5c35c9465f0702739b41249a664d409f0482c.zip | |
more files
Diffstat (limited to 'src/cmd/postscript/common/tempnam.c')
| -rw-r--r-- | src/cmd/postscript/common/tempnam.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/cmd/postscript/common/tempnam.c b/src/cmd/postscript/common/tempnam.c new file mode 100644 index 00000000..529025ed --- /dev/null +++ b/src/cmd/postscript/common/tempnam.c @@ -0,0 +1,27 @@ +#include <stdio.h> +#include <errno.h> + +#if defined(V9) || defined(BSD4_2) || defined(plan9) +char *tempnam(char *dir, char *pfx) { + int pid; + unsigned int len; + char *tnm, *malloc(); + static int seq = 0; + + pid = getpid(); + len = strlen(dir) + strlen(pfx) + 10; + if ((tnm = malloc(len)) != NULL) { + sprintf(tnm, "%s", dir); + if (access(tnm, 7) == -1) + return(NULL); + do { + sprintf(tnm, "%s/%s%d%d", dir, pfx, pid, seq++); + errno = 0; + if (access(tnm, 7) == -1) + if (errno == ENOENT) + return(tnm); + } while (1); + } + return(tnm); +} +#endif |
