GRASS Programmer's Manual  6.4.1(2011)
overwrite.c
Go to the documentation of this file.
00001 
00017 #include <stdlib.h>
00018 #include <string.h>
00019 #include <grass/gis.h>
00020 
00037 int G_check_overwrite(int argc, char **argv)
00038 {
00039     char *overstr;
00040     int overwrite;
00041 
00042     overwrite = 0;
00043     if ((overstr = G__getenv("OVERWRITE"))) {
00044         overwrite = atoi(overstr);
00045     }
00046 
00047     /* check if inherited GRASS_OVERWRITE is 1 */
00048     if (!overwrite && (overstr = getenv("GRASS_OVERWRITE"))) {
00049         overwrite = atoi(overstr);
00050     }
00051 
00052     /* check for --o or --overwrite option */
00053     if (!overwrite) {
00054         int i;
00055 
00056         for (i = 0; i < argc; i++) {
00057             if (strcmp(argv[i], "--o") == 0 ||
00058                 strcmp(argv[i], "--overwrite") == 0) {
00059                 overwrite = 1;
00060                 break;
00061             }
00062         }
00063     }
00064 
00065     G__setenv("OVERWRITE", "1");
00066 
00067     return overwrite;
00068 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines