123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #include <stdio.h>
- #include <string.h>
- extern int __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,
- int try_tmpdir);
- extern int __gen_tempname (char *tmpl, int openit);
- static char tmpnam_buffer[L_tmpnam];
- char * tmpnam (char *s)
- {
-
- char tmpbuf[L_tmpnam];
-
- if (__path_search (s ? : tmpbuf, L_tmpnam, NULL, NULL, 0))
- return NULL;
- if (__gen_tempname (s ? : tmpbuf, 0))
- return NULL;
- if (s == NULL)
- return (char *) memcpy (tmpnam_buffer, tmpbuf, L_tmpnam);
- return s;
- }
|