~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to general/g.tempfile/main.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * MODULE:       g.tempfile
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>
9
11
 * PURPOSE:      
10
 
 * COPYRIGHT:    (C) 1999-2006 by the GRASS Development Team
 
12
 * COPYRIGHT:    (C) 1999-2006, 2011 by the GRASS Development Team
11
13
 *
12
 
 *               This program is free software under the GNU General Public
13
 
 *               License (>=v2). Read the file COPYING that comes with GRASS
14
 
 *               for details.
 
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.
15
17
 *
16
18
 *****************************************************************************/
17
19
#include <stdlib.h>
26
28
{
27
29
    struct GModule *module;
28
30
    struct Option *pid;
29
 
    char *tempfile, *G__tempfile();
 
31
    struct Flag *dry_run;
 
32
    char *tempfile;
30
33
    int p;
31
 
 
32
 
 
 
34
    
33
35
    G_gisinit(argv[0]);
34
36
 
35
37
    module = G_define_module();
36
 
    module->keywords = _("general, map management");
37
 
    module->description =
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.");
39
42
 
40
43
    pid = G_define_option();
41
44
    pid->key = "pid";
42
45
    pid->type = TYPE_INTEGER;
43
46
    pid->required = YES;
44
 
    pid->description = "Process id to use when naming the tempfile";
45
 
 
 
47
    pid->description = _("Process id to use when naming the tempfile");
 
48
    
 
49
    dry_run = G_define_flag();
 
50
    dry_run->key = 'd';
 
51
    dry_run->description = _("Dry run - don't create a file, just prints it's file name");
 
52
    
46
53
    G_disable_interactive();
47
54
    if (G_parser(argc, argv))
48
 
        exit(1);
49
 
 
 
55
        exit(EXIT_FAILURE);
 
56
    
50
57
    if (sscanf(pid->answer, "%d", &p) != 1) {
51
58
        G_usage();
52
59
        exit(EXIT_FAILURE);
53
60
    }
54
 
    tempfile = G__tempfile(p);
55
 
 
 
61
    tempfile = G_tempfile_pid(p);
 
62
    
56
63
    /* create tempfile so next run of this program will create a unique name */
57
 
    close(creat(tempfile, 0666));
 
64
    if (!dry_run->answer)
 
65
        close(creat(tempfile, 0666));
58
66
    fprintf(stdout, "%s\n", tempfile);
 
67
    
59
68
    exit(EXIT_SUCCESS);
60
69
}