5
5
* AUTHOR(S): Michael Shapiro CERL (original contributor)
6
6
* Markus Neteler <neteler itc.it>,
7
* Roberto Flor <flor itc.it>, Bernhard Reiter <bernhard intevation.de>,
8
* Jan-Oliver Wagner <jan intevation.de>
7
* Roberto Flor <flor itc.it>,
8
* Bernhard Reiter <bernhard intevation.de>,
9
* Jan-Oliver Wagner <jan intevation.de>,
10
* Martin Landa <landa.martin gmail.com>
10
* COPYRIGHT: (C) 1999-2006 by the GRASS Development Team
12
* COPYRIGHT: (C) 1999-2006, 2011 by the GRASS Development Team
12
* This program is free software under the GNU General Public
13
* License (>=v2). Read the file COPYING that comes with GRASS
14
* This program is free software under the GNU General
15
* Public License (>=v2). Read the file COPYING that
16
* comes with GRASS for details.
16
18
*****************************************************************************/
17
19
#include <stdlib.h>
27
29
struct GModule *module;
28
30
struct Option *pid;
29
char *tempfile, *G__tempfile();
33
35
G_gisinit(argv[0]);
35
37
module = G_define_module();
36
module->keywords = _("general, map management");
38
"Creates a temporary file and prints the file name.";
38
G_add_keyword(_("general"));
39
G_add_keyword(_("support"));
40
G_add_keyword(_("scripts"));
41
module->description = _("Creates a temporary file and prints it's file name.");
40
43
pid = G_define_option();
42
45
pid->type = TYPE_INTEGER;
43
46
pid->required = YES;
44
pid->description = "Process id to use when naming the tempfile";
47
pid->description = _("Process id to use when naming the tempfile");
49
dry_run = G_define_flag();
51
dry_run->description = _("Dry run - don't create a file, just prints it's file name");
46
53
G_disable_interactive();
47
54
if (G_parser(argc, argv))
50
57
if (sscanf(pid->answer, "%d", &p) != 1) {
52
59
exit(EXIT_FAILURE);
54
tempfile = G__tempfile(p);
61
tempfile = G_tempfile_pid(p);
56
63
/* create tempfile so next run of this program will create a unique name */
57
close(creat(tempfile, 0666));
65
close(creat(tempfile, 0666));
58
66
fprintf(stdout, "%s\n", tempfile);
59
68
exit(EXIT_SUCCESS);