97 |
/* Directory to use for temporary files. On Unix, it ends with a slash. */ |
/* Directory to use for temporary files. On Unix, it ends with a slash. */ |
98 |
char *tempdir; |
char *tempdir; |
99 |
|
|
|
/* Start of filename to use for temporary files. */ |
|
|
char *tempbase; |
|
|
|
|
100 |
/* Number of last temporary file. */ |
/* Number of last temporary file. */ |
101 |
int tempcount; |
int tempcount; |
102 |
|
|
181 |
|
|
182 |
decode_command (argc, argv); |
decode_command (argc, argv); |
183 |
|
|
|
tempbase = mktemp (concat ("txiXXXXXX", "", "")); |
|
|
|
|
184 |
/* Process input files completely, one by one. */ |
/* Process input files completely, one by one. */ |
185 |
|
|
186 |
for (i = 0; i < num_infiles; i++) |
for (i = 0; i < num_infiles; i++) |
379 |
usage (1); |
usage (1); |
380 |
} |
} |
381 |
|
|
382 |
/* Return a name for a temporary file. */ |
/* Return a name for temporary file COUNT. */ |
383 |
|
|
384 |
static char * |
static char * |
385 |
maketempname (count) |
maketempname (count) |
386 |
int count; |
int count; |
387 |
{ |
{ |
388 |
|
static char *tempbase = NULL; |
389 |
char tempsuffix[10]; |
char tempsuffix[10]; |
390 |
|
|
391 |
|
if (!tempbase) |
392 |
|
{ |
393 |
|
int fd; |
394 |
|
char *tmpdir = getenv ("TEMPDIR"); |
395 |
|
if (!tmpdir) |
396 |
|
tmpdir = "/tmp"; |
397 |
|
tempbase = concat (tmpdir, "/txidxXXXXXX"); |
398 |
|
|
399 |
|
fd = mkstemp (tempbase); |
400 |
|
if (fd == -1) |
401 |
|
pfatal_with_name (tempbase); |
402 |
|
} |
403 |
|
|
404 |
sprintf (tempsuffix, ".%d", count); |
sprintf (tempsuffix, ".%d", count); |
405 |
return concat (tempdir, tempbase, tempsuffix); |
return concat (tempdir, tempbase, tempsuffix); |
406 |
} |
} |
407 |
|
|
408 |
|
|
409 |
/* Delete all temporary files up to TO_COUNT. */ |
/* Delete all temporary files up to TO_COUNT. */ |
410 |
|
|
411 |
void |
void |