version 1.8, 2002/02/16 21:27:49 |
version 1.9, 2003/04/07 19:25:43 |
|
|
{ |
{ |
int ch, fd, uflag = 0, quiet = 0, tflag = 0, makedir = 0; |
int ch, fd, uflag = 0, quiet = 0, tflag = 0, makedir = 0; |
char *cp, *template, *tempfile, *prefix = _PATH_TMP; |
char *cp, *template, *tempfile, *prefix = _PATH_TMP; |
size_t plen; |
int plen; |
|
|
while ((ch = getopt(argc, argv, "dp:qtu")) != -1) |
while ((ch = getopt(argc, argv, "dp:qtu")) != -1) |
switch(ch) { |
switch(ch) { |
|
|
if (tflag) { |
if (tflag) { |
if (strchr(template, '/')) { |
if (strchr(template, '/')) { |
if (!quiet) |
if (!quiet) |
warnx("template must not contain directory separators in -t mode"); |
warnx("template must not contain directory " |
|
"separators in -t mode"); |
exit(1); |
exit(1); |
} |
} |
|
|
|
|
while (plen != 0 && prefix[plen - 1] == '/') |
while (plen != 0 && prefix[plen - 1] == '/') |
plen--; |
plen--; |
|
|
tempfile = (char *)malloc(plen + 1 + strlen(template) + 1); |
tempfile = NULL; |
if (tempfile == NULL) { |
asprintf(&tempfile, "%.*s/%s", plen, prefix, template); |
if (!quiet) |
} else |
warnx("cannot allocate memory"); |
tempfile = strdup(template); |
exit(1); |
if (tempfile == NULL) { |
} |
if (!quiet) |
(void)memcpy(tempfile, prefix, plen); |
warnx("cannot allocate memory"); |
tempfile[plen] = '/'; |
exit(1); |
(void)strcpy(tempfile + plen + 1, template); /* SAFE */ |
|
} else { |
|
if ((tempfile = strdup(template)) == NULL) { |
|
if (!quiet) |
|
warnx("cannot allocate memory"); |
|
exit(1); |
|
} |
|
} |
} |
|
|
if (makedir) { |
if (makedir) { |