blob: 556d45254fe3255beedae42503a734fa54bd9a05 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#define _XOPEN_SOURCE
#define _XOPEN_SOURCE_EXTENDED
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
char template[FILENAME_MAX] = "tmp.XXXXXXXXXX";
if (argc != 1) {
strcpy(template, argv[1]);
}
if (!strstr(template, "XXXXXX")) {
fprintf(stderr, "template must contain at least six 'X' characters\n");
return 1;
}
close(mkstemp(template));
unlink(template);
printf("%s\n", template);
return 0;
}
|