Last change
on this file since 387 was 337, checked in by coas-nagasima, 6 years ago |
ASP3版ECNLを追加
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
539 bytes
|
Rev | Line | |
---|
[337] | 1 | #define _GNU_SOURCE
|
---|
| 2 | #include <string.h>
|
---|
| 3 | #include <stdlib.h>
|
---|
| 4 | #include <errno.h>
|
---|
| 5 | #include <sys/stat.h>
|
---|
| 6 |
|
---|
| 7 | char *__randname(char *);
|
---|
| 8 |
|
---|
| 9 | char *mktemp(char *template)
|
---|
| 10 | {
|
---|
| 11 | size_t l = strlen(template);
|
---|
| 12 | int retries = 100;
|
---|
| 13 | struct stat st;
|
---|
| 14 |
|
---|
| 15 | if (l < 6 || memcmp(template+l-6, "XXXXXX", 6)) {
|
---|
| 16 | errno = EINVAL;
|
---|
| 17 | *template = 0;
|
---|
| 18 | return template;
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | do {
|
---|
| 22 | __randname(template+l-6);
|
---|
| 23 | if (stat(template, &st)) {
|
---|
| 24 | if (errno != ENOENT) *template = 0;
|
---|
| 25 | return template;
|
---|
| 26 | }
|
---|
| 27 | } while (--retries);
|
---|
| 28 |
|
---|
| 29 | *template = 0;
|
---|
| 30 | errno = EEXIST;
|
---|
| 31 | return template;
|
---|
| 32 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.