2 * tmpnam.c - create a unique filename
6 #if defined(_POSIX_SOURCE)
17 static char name_buffer
[L_tmpnam
] = "/tmp/tmp.";
18 static unsigned long count
= 0;
19 static char *name
= NULL
;
22 name
= name_buffer
+ strlen(name_buffer
);
23 name
= _i_compute((unsigned long)_getpid(), 10, name
, 5);
27 if (++count
> TMP_MAX
) count
= 1; /* wrap-around */
28 *_i_compute(count
, 10, name
, 3) = '\0';
29 if (s
) return strcpy(s
, name_buffer
);
30 else return name_buffer
;