1#include <sys.h>23#include <stdio.h>4#include <string.h>56#include "../syscall.h"78#undef tmpnam910char *11tmpnam(char *s)12{13 static char tmpl[] = _TMPNAME;14 char *p, *beg;151617 for (beg = tmpl; *beg < '0' || *beg > '9'; ++beg)18 ;1920 do {21 for (p = beg; *p == '9'; *p++ = '0')22 ;23 if (*p == '\0')24 return NULL;25 ++*p;26 } while (_access(tmpl, F_OK) == 0);2728 if (s)29 strcpy(s, tmpl);30 return tmpl;31}