GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
overwrite.c
Go to the documentation of this file.
1 
17 #include <stdlib.h>
18 #include <string.h>
19 #include <grass/gis.h>
20 
37 int G_check_overwrite(int argc, char **argv)
38 {
39  char *overstr;
40  int overwrite;
41 
42  overwrite = 0;
43  if ((overstr = G__getenv("OVERWRITE"))) {
44  overwrite = atoi(overstr);
45  }
46 
47  /* check if inherited GRASS_OVERWRITE is 1 */
48  if (!overwrite && (overstr = getenv("GRASS_OVERWRITE"))) {
49  overwrite = atoi(overstr);
50  }
51 
52  /* check for --o or --overwrite option */
53  if (!overwrite) {
54  int i;
55 
56  for (i = 0; i < argc; i++) {
57  if (strcmp(argv[i], "--o") == 0 ||
58  strcmp(argv[i], "--overwrite") == 0) {
59  overwrite = 1;
60  break;
61  }
62  }
63  }
64 
65  G__setenv("OVERWRITE", "1");
66 
67  return overwrite;
68 }
char * G__getenv(const char *name)
Get environment variable.
Definition: env.c:312
char * getenv()
int G_check_overwrite(int argc, char **argv)
Check for overwrite mode.
Definition: overwrite.c:37
int G__setenv(const char *name, const char *value)
Set environment name to value.
Definition: env.c:388