39 |
{ |
{ |
40 |
const char *path; |
const char *path; |
41 |
char *chp; |
char *chp; |
42 |
unsigned opt; |
unsigned opts; |
43 |
|
|
44 |
|
path = getenv("TMPDIR"); |
45 |
|
if (!path || path[0] == '\0') |
46 |
|
path = "/tmp"; |
47 |
|
|
48 |
|
/* -q and -t are ignored */ |
49 |
opt_complementary = "?1"; /* 1 argument max */ |
opt_complementary = "?1"; /* 1 argument max */ |
50 |
opt = getopt32(argv, "dqtp:", &path); |
opts = getopt32(argv, "dqtp:", &path); |
|
chp = argv[optind] ? argv[optind] : xstrdup("tmp.XXXXXX"); |
|
51 |
|
|
52 |
if (opt & (4|8)) { /* -t and/or -p */ |
chp = argv[optind] ? argv[optind] : xstrdup("tmp.XXXXXX"); |
53 |
const char *dir = getenv("TMPDIR"); |
if (chp[0] != '/' || (opts & 8)) |
|
if (dir && *dir != '\0') |
|
|
path = dir; |
|
|
else if (!(opt & 8)) /* no -p */ |
|
|
path = "/tmp/"; |
|
|
/* else path comes from -p DIR */ |
|
54 |
chp = concat_path_file(path, chp); |
chp = concat_path_file(path, chp); |
|
} |
|
55 |
|
|
56 |
if (opt & 1) { /* -d */ |
if (opts & 1) { /* -d */ |
57 |
if (mkdtemp(chp) == NULL) |
if (mkdtemp(chp) == NULL) |
58 |
return EXIT_FAILURE; |
return EXIT_FAILURE; |
59 |
} else { |
} else { |