83 #include <grass/gis.h> 84 #include <grass/spawn.h> 85 #include <grass/glocale.h> 87 #include "parser_local_proto.h" 99 #define MAX_MATCHES 50 106 static void set_flag(
int);
107 static int contains(
const char *,
int);
108 static int valid_option_name(
const char *);
109 static int is_option(
const char *);
110 static int match_option_1(
const char *,
const char *);
111 static int match_option(
const char *,
const char *);
112 static void set_option(
const char *);
113 static void check_opts(
void);
114 static void check_an_opt(
const char *,
int,
const char *,
const char **,
char **);
115 static int check_int(
const char *,
const char **);
116 static int check_double(
const char *,
const char **);
117 static int check_string(
const char *,
const char **,
int *);
118 static void check_required(
void);
119 static void split_opts(
void);
120 static void check_multiple_opts(
void);
121 static int check_overwrite(
void);
122 static void define_keywords(
void);
123 static void split_gisprompt(
const char *,
char *,
char *,
char *);
124 static int module_gui_wx(
void);
125 static void append_error(
const char *);
126 static const char *get_renamed_option(
const char *);
141 st->no_interactive = 1;
164 flag = G_malloc(
sizeof(
struct Flag));
165 st->current_flag->next_flag = flag;
168 flag = &
st->first_flag;
172 G_zero(flag,
sizeof(
struct Flag));
174 st->current_flag = flag;
178 item = G_malloc(
sizeof(
struct Item));
179 st->current_item->next_item = item;
182 item = &
st->first_item;
184 G_zero(item,
sizeof(
struct Item));
189 st->current_item = item;
218 opt = G_malloc(
sizeof(
struct Option));
219 st->current_option->next_opt = opt;
222 opt = &
st->first_option;
225 G_zero(opt,
sizeof(
struct Option));
230 st->current_option = opt;
234 item = G_malloc(
sizeof(
struct Item));
235 st->current_item->next_item = item;
238 item = &
st->first_item;
240 G_zero(item,
sizeof(
struct Item));
244 st->current_item = item;
257 struct GModule *module;
260 module = &
st->module_info;
263 G_zero(module,
sizeof(
struct GModule));
324 const char *gui_envvar;
325 char *ptr, *tmp_name, *
err;
328 char force_gui =
FALSE;
333 st->pgm_path = tmp_name;
337 i = strlen(tmp_name);
345 st->pgm_name = tmp_name;
349 opt = &
st->first_option;
350 while (
st->n_opts && opt) {
352 st->has_required = 1;
354 if (!valid_option_name(opt->key))
355 G_warning(_(
"BUG in option name, '%s' is not valid"), opt->key);
360 char **tokens, delm[2];
373 opt->opts = G_calloc(cnt + 1,
sizeof(
const char *));
377 opt->opts[i] =
G_store(tokens[i]);
382 if (opt->descriptions) {
385 opt->descs = G_calloc(cnt + 1,
sizeof(
const char *));
399 while (opt->opts[j]) {
400 if (strcmp(opt->opts[j], tokens[i]) == 0) {
407 G_warning(_(
"BUG in descriptions, option '%s' in <%s> does not exist"),
408 tokens[i], opt->key);
411 opt->descs[j] =
G_store(tokens[i + 1]);
421 if (opt->multiple && opt->answers && opt->answers[0]) {
422 opt->answer = G_malloc(strlen(opt->answers[0]) + 1);
423 strcpy(opt->answer, opt->answers[0]);
424 for (i = 1; opt->answers[i]; i++) {
425 opt->answer = G_realloc(opt->answer,
426 strlen(opt->answer) +
427 strlen(opt->answers[i]) + 2);
428 strcat(opt->answer,
",");
429 strcat(opt->answer, opt->answers[i]);
432 opt->def = opt->answer;
439 && !
st->no_interactive && isatty(0) &&
440 (gui_envvar &&
G_strcasecmp(gui_envvar,
"text") != 0)) {
441 if (module_gui_wx() == 0)
445 if (argc < 2 && st->has_required && isatty(0)) {
449 else if (argc >= 2) {
452 if (strcmp(argv[1],
"help") == 0 ||
453 strcmp(argv[1],
"-help") == 0 || strcmp(argv[1],
"--help") == 0) {
460 if (strcmp(argv[1],
"--help-text") == 0) {
467 if (strcmp(argv[1],
"--interface-description") == 0) {
474 if (strcmp(argv[1],
"--html-description") == 0) {
481 if (strcmp(argv[1],
"--rst-description") == 0) {
488 if (strcmp(argv[1],
"--wps-process-description") == 0) {
495 if (strcmp(argv[1],
"--script") == 0) {
505 if (strcmp(ptr,
"help") == 0 || strcmp(ptr,
"--h") == 0 ||
506 strcmp(ptr,
"-help") == 0 || strcmp(ptr,
"--help") == 0) {
512 if (strcmp(ptr,
"--o") == 0 || strcmp(ptr,
"--overwrite") == 0) {
517 else if (strcmp(ptr,
"--v") == 0 || strcmp(ptr,
"--verbose") == 0) {
524 if (
st->quiet == 1) {
525 G_warning(_(
"Use either --quiet or --verbose flag, not both. Assuming --verbose."));
531 else if (strcmp(ptr,
"--q") == 0 || strcmp(ptr,
"--quiet") == 0) {
538 if (
st->quiet == -1) {
539 G_warning(_(
"Use either --quiet or --verbose flag, not both. Assuming --quiet."));
545 else if (strcmp(ptr,
"--qq") == 0 ) {
553 if (
st->quiet == -1) {
554 G_warning(_(
"Use either --qq or --verbose flag, not both. Assuming --qq."));
560 else if (strcmp(ptr,
"--ui") == 0) {
565 else if (*ptr ==
'-') {
571 else if (is_option(ptr)) {
577 else if (need_first_opt &&
st->n_opts) {
579 st->first_option.count++;
585 G_asprintf(&err, _(
"Sorry <%s> is not a valid option"), ptr);
597 if (module_gui_wx() != 0)
598 G_fatal_error(_(
"Your installation doesn't include GUI, exiting."));
603 check_multiple_opts();
610 if (!
st->suppress_required)
615 if (
st->n_errors > 0) {
619 fprintf(stderr,
"\n");
620 for (i = 0; i <
st->n_errors; i++) {
621 fprintf(stderr,
"%s: %s\n", _(
"ERROR"),
st->error[i]);
627 if (check_overwrite())
654 G_debug(3,
"G_recreate_command()");
658 buff = G_calloc(1024,
sizeof(
char));
665 if (len >= nalloced) {
666 nalloced += (1024 > len) ? 1024 : len + 1;
667 buff = G_realloc(buff, nalloced);
674 slen = strlen(
" --overwrite");
675 if (len + slen >= nalloced) {
676 nalloced += (1024 > len) ? 1024 : len + 1;
677 buff = G_realloc(buff, nalloced);
679 strcpy(cur,
" --overwrite");
692 if (len + slen >= nalloced) {
693 nalloced += (1024 > len) ? 1024 : len + 1;
694 buff = G_realloc(buff, nalloced);
702 flag = &
st->first_flag;
704 if (flag->answer == 1) {
710 if (len + slen >= nalloced) {
712 (nalloced + 1024 > len + slen) ? 1024 : slen + 1;
713 buff = G_realloc(buff, nalloced);
720 flag = flag->next_flag;
724 opt = &
st->first_option;
725 while (
st->n_opts && opt) {
726 if (opt->answer && opt->answer[0] ==
'\0') {
727 slen = strlen(opt->key) + 4;
728 if (len + slen >= nalloced) {
729 nalloced += (nalloced + 1024 > len + slen) ? 1024 : slen + 1;
730 buff = G_realloc(buff, nalloced);
735 strcpy(cur, opt->key);
736 cur = strchr(cur,
'\0');
739 if (opt->type == TYPE_STRING) {
744 }
else if (opt->answer && opt->answers && opt->answers[0]) {
745 slen = strlen(opt->key) + strlen(opt->answers[0]) + 4;
746 if (len + slen >= nalloced) {
747 nalloced += (nalloced + 1024 > len + slen) ? 1024 : slen + 1;
748 buff = G_realloc(buff, nalloced);
753 strcpy(cur, opt->key);
754 cur = strchr(cur,
'\0');
757 if (opt->type == TYPE_STRING) {
761 strcpy(cur, opt->answers[0]);
762 cur = strchr(cur,
'\0');
764 for (n = 1; opt->answers[n]; n++) {
765 if (!opt->answers[n])
767 slen = strlen(opt->answers[n]) + 2;
768 if (len + slen >= nalloced) {
770 (nalloced + 1024 > len + slen) ? 1024 : slen + 1;
771 buff = G_realloc(buff, nalloced);
776 strcpy(cur, opt->answers[n]);
777 cur = strchr(cur,
'\0');
780 if (opt->type == TYPE_STRING) {
830 if (
st->n_keys >=
st->n_keys_alloc) {
831 st->n_keys_alloc += 10;
832 st->module_info.keywords = G_realloc(
st->module_info.keywords,
833 st->n_keys_alloc *
sizeof(
char *));
836 st->module_info.keywords[
st->n_keys++] =
G_store(keyword);
847 st->module_info.keywords = (
const char **)tokens;
859 if (
st->module_info.overwrite)
865 opt = &
st->first_option;
867 if (opt->gisprompt) {
868 split_gisprompt(opt->gisprompt, age, element, desc);
869 if (strcmp(age,
"new") == 0)
892 for(i = 0; i <
st->n_keys; i++) {
894 fprintf(fd,
"%s",
st->module_info.keywords[i]);
897 format(fd,
st->module_info.keywords[i]);
899 if (i < st->n_keys - 1)
914 return st->overwrite;
917 void define_keywords(
void)
920 st->n_keys_alloc = 0;
933 int module_gui_wx(
void)
935 char script[GPATH_MAX];
943 sprintf(script,
"%s/gui/wxpython/gui_core/forms.py",
945 if (access(script, F_OK) != -1)
946 G_spawn(getenv(
"GRASS_PYTHON"), getenv(
"GRASS_PYTHON"),
969 flag = &
st->first_flag;
971 if (flag->key == f) {
973 if (flag->suppress_required)
974 st->suppress_required = 1;
977 flag = flag->next_flag;
987 int contains(
const char *s,
int c)
997 int valid_option_name(
const char *
string)
999 int m = strlen(
string);
1000 int n = strspn(
string,
"abcdefghijklmnopqrstuvwxyz0123456789_");
1008 if (
string[m-1] ==
'_')
1014 int is_option(
const char *
string)
1016 int n = strspn(
string,
"abcdefghijklmnopqrstuvwxyz0123456789_");
1018 return n > 0 &&
string[n] ==
'=' &&
string[0] !=
'_' &&
string[n-1] !=
'_';
1021 int match_option_1(
const char *
string,
const char *option)
1025 if (*
string ==
'\0')
1028 if (*option ==
'\0')
1031 if (*
string == *option && match_option_1(
string + 1, option + 1))
1034 if (*option ==
'_' && match_option_1(
string, option + 1))
1037 next = strchr(option,
'_');
1042 return match_option_1(
string + 1, next + 1);
1044 return match_option_1(
string, next + 1);
1047 int match_option(
const char *
string,
const char *option)
1049 return (*
string == *option)
1050 && match_option_1(
string + 1, option + 1);
1053 void set_option(
const char *
string)
1055 struct Option *at_opt =
NULL;
1056 struct Option *opt =
NULL;
1065 for (ptr = the_key; *
string !=
'='; ptr++,
string++)
1071 key_len = strlen(the_key);
1072 for (at_opt = &
st->first_option; at_opt; at_opt = at_opt->next_opt) {
1076 if (strcmp(the_key, at_opt->key) == 0) {
1077 matches[0] = at_opt;
1082 if (strncmp(the_key, at_opt->key, key_len) == 0 ||
1083 match_option(the_key, at_opt->key)) {
1086 matches[found++] = at_opt;
1092 int length = strlen(matches[0]->key);
1095 for (i = 1; i < found; i++) {
1096 int len = strlen(matches[i]->key);
1102 for (i = 0; prefix && i < found; i++)
1103 if (strncmp(matches[i]->key, matches[shortest]->key, length) != 0)
1106 matches[0] = matches[shortest];
1112 for (i = 0; i < found; i++) {
1113 G_asprintf(&err, _(
"Option <%s=> matches"), matches[i]->key);
1125 const char *renamed_key =
NULL;
1127 renamed_key = get_renamed_option(the_key);
1129 for (at_opt = &
st->first_option; at_opt; at_opt = at_opt->next_opt) {
1130 if (strcmp(renamed_key, at_opt->key) == 0) {
1131 G_warning(_(
"Please update the usage of <%s>: " 1132 "option <%s> has been renamed to <%s>"),
1149 if (getenv(
"GRASS_FULL_OPTION_NAMES") && strcmp(the_key, opt->key) != 0)
1150 G_warning(_(
"<%s> is an abbreviation for <%s>"), the_key, opt->key);
1154 if (!opt->multiple) {
1155 G_asprintf(&err, _(
"Option <%s> does not accept multiple answers"), opt->key);
1158 opt->answer = G_realloc(opt->answer,
1159 strlen(opt->answer) + strlen(
string) + 2);
1160 strcat(opt->answer,
",");
1161 strcat(opt->answer,
string);
1164 opt->answer =
G_store(
string);
1167 void check_opts(
void)
1175 opt = &
st->first_option;
1180 if (opt->multiple == 0)
1181 check_an_opt(opt->key, opt->type,
1182 opt->options, opt->opts, &opt->answer);
1184 for (ans = 0; opt->answers[ans] !=
'\0'; ans++)
1185 check_an_opt(opt->key, opt->type,
1186 opt->options, opt->opts, &opt->answers[ans]);
1193 opt->checker(opt->answer);
1195 opt = opt->next_opt;
1199 void check_an_opt(
const char *key,
int type,
const char *options,
1200 const char **opts,
char **answerp)
1202 const char *answer = *answerp;
1213 error = check_int(answer, opts);
1216 error = check_double(answer, opts);
1219 error = check_string(answer, opts, &found);
1227 _(
"Illegal range syntax for parameter <%s>\n" 1228 "\tPresented as: %s"), key, options);
1233 _(
"Value <%s> out of range for parameter <%s>\n" 1234 "\tLegal range: %s"), answer, key, options);
1239 _(
"Missing value for parameter <%s>"),
1245 _(
"Value <%s> ambiguous for parameter <%s>\n" 1246 "\tValid options: %s"), answer, key, options);
1250 *answerp =
G_store(opts[found]);
1256 int check_int(
const char *ans,
const char **opts)
1261 if (strcmp(ans,
"-") == 0)
1264 if (sscanf(ans,
"%d", &d) != 1)
1270 for (i = 0; opts[i]; i++) {
1271 const char *opt = opts[i];
1274 if (contains(opt,
'-')) {
1275 if (sscanf(opt,
"%d-%d", &lo, &hi) == 2) {
1276 if (d >= lo && d <= hi)
1279 else if (sscanf(opt,
"-%d", &hi) == 1) {
1283 else if (sscanf(opt,
"%d-", &lo) == 1) {
1291 if (sscanf(opt,
"%d", &lo) == 1) {
1303 int check_double(
const char *ans,
const char **opts)
1309 if (strcmp(ans,
"-") == 0)
1312 if (sscanf(ans,
"%lf", &d) != 1)
1318 for (i = 0; opts[i]; i++) {
1319 const char *opt = opts[i];
1322 if (contains(opt,
'-')) {
1323 if (sscanf(opt,
"%lf-%lf", &lo, &hi) == 2) {
1324 if (d >= lo && d <= hi)
1327 else if (sscanf(opt,
"-%lf", &hi) == 1) {
1331 else if (sscanf(opt,
"%lf-", &lo) == 1) {
1339 if (sscanf(opt,
"%lf", &lo) == 1) {
1351 int check_string(
const char *ans,
const char **opts,
int *result)
1353 int len = strlen(ans);
1361 for (i = 0; opts[i]; i++) {
1362 if (strcmp(ans, opts[i]) == 0)
1364 if (strncmp(ans, opts[i], len) == 0 || match_option(ans, opts[i])) {
1367 matches[found++] = i;
1373 int length = strlen(opts[matches[0]]);
1376 for (i = 1; i < found; i++) {
1377 int len = strlen(opts[matches[i]]);
1383 for (i = 0; prefix && i < found; i++)
1384 if (strncmp(opts[matches[i]], opts[matches[shortest]], length) != 0)
1387 matches[0] = matches[shortest];
1393 *result = matches[0];
1395 if (found > 0 && getenv(
"GRASS_FULL_OPTION_NAMES") && strcmp(ans, opts[matches[0]]) != 0)
1396 G_warning(_(
"<%s> is an abbreviation for <%s>"), ans, opts[matches[0]]);
1405 void check_required(
void)
1415 opt = &
st->first_option;
1417 if (opt->required && !opt->answer) {
1418 G_asprintf(&err, _(
"Required parameter <%s> not set:\n" 1420 opt->key, (opt->label ? opt->label : opt->description));
1423 opt = opt->next_opt;
1427 void split_opts(
void)
1440 opt = &
st->first_option;
1445 opt->answers = G_malloc(allocated *
sizeof(
char *));
1449 opt->answers[ans_num] =
NULL;
1452 for (len = 0, ptr2 = ptr1; *ptr2 !=
'\0' && *ptr2 !=
',';
1456 opt->answers[ans_num] = G_malloc(len + 1);
1457 memcpy(opt->answers[ans_num], ptr1, len);
1458 opt->answers[ans_num][len] = 0;
1462 if (ans_num >= allocated) {
1464 opt->answers = G_realloc(opt->answers,
1465 allocated *
sizeof(
char *));
1468 opt->answers[ans_num] =
NULL;
1480 opt = opt->next_opt;
1484 void check_multiple_opts(
void)
1496 opt = &
st->first_option;
1499 if (opt->answer && strcmp(opt->answer,
"-") && opt->key_desc) {
1502 for (ptr = opt->key_desc; *ptr !=
'\0'; ptr++)
1506 for (n = 0; opt->answers[n] !=
'\0'; n++) ;
1510 _(
"Option <%s> must be provided in multiples of %d\n" 1511 "\tYou provided %d item(s): %s"),
1512 opt->key, n_commas, n, opt->answer);
1517 opt = opt->next_opt;
1522 int check_overwrite(
void)
1529 const char *overstr;
1532 st->module_info.overwrite = 0;
1540 over = atoi(overstr);
1544 if ((overstr = getenv(
"GRASS_OVERWRITE"))) {
1549 if (
st->overwrite || over) {
1550 st->module_info.overwrite = 1;
1552 putenv(
"GRASS_OVERWRITE=1");
1557 opt = &
st->first_option;
1559 if (opt->answer && opt->gisprompt) {
1560 split_gisprompt(opt->gisprompt, age, element, desc);
1562 if (strcmp(age,
"new") == 0) {
1566 for (i = 0; opt->answers[i]; i++) {
1568 if (strcmp(element,
"file") == 0) {
1569 if (access(opt->answers[i], F_OK) == 0)
1572 else if (strcmp(element,
"mapset") != 0) {
1581 if (!
st->overwrite && !over) {
1584 fprintf(stderr, _(
"ERROR: "));
1586 _(
"option <%s>: <%s> exists. To overwrite, use the --overwrite flag"),
1587 opt->key, opt->answers[i]);
1588 fprintf(stderr,
"\n");
1591 fprintf(stderr,
"GRASS_INFO_ERROR(%d,1): ", getpid());
1593 _(
"option <%s>: <%s> exists. To overwrite, use the --overwrite flag"),
1594 opt->key, opt->answers[i]);
1595 fprintf(stderr,
"\n");
1596 fprintf(stderr,
"GRASS_INFO_END(%d,1)\n",
1606 opt = opt->next_opt;
1612 void split_gisprompt(
const char *gisprompt,
char *age,
char *
element,
1618 for (ptr1 = gisprompt, ptr2 = age; *ptr1 !=
'\0'; ptr1++, ptr2++) {
1625 for (ptr1++, ptr2 = element; *ptr1 !=
'\0'; ptr1++, ptr2++) {
1632 for (ptr1++, ptr2 = desc; *ptr1 !=
'\0'; ptr1++, ptr2++) {
1640 void append_error(
const char *msg)
1642 st->error = G_realloc(
st->error,
sizeof(
char *) * (
st->n_errors + 1));
1646 const char *get_renamed_option(
const char *key)
1648 const char *pgm, *key_new;
1651 if (!
st->renamed_options) {
1653 char path[GPATH_MAX];
1666 pgm_key = (
char *) G_malloc (strlen(pgm) + strlen(key) + 2);
1701 if (option->gisprompt ==
NULL ||
1702 strcmp(option->gisprompt,
"old,separator,separator") != 0)
1703 G_fatal_error(_(
"%s= is not a separator option"), option->key);
1705 if (option->answer ==
NULL)
1706 G_fatal_error(_(
"No separator given for %s="), option->key);
1708 if (strcmp(option->answer,
"pipe") == 0)
1710 else if (strcmp(option->answer,
"comma") == 0)
1712 else if (strcmp(option->answer,
"space") == 0)
1714 else if (strcmp(option->answer,
"tab") == 0 ||
1715 strcmp(option->answer,
"\\t") == 0)
1717 else if (strcmp(option->answer,
"newline") == 0 ||
1718 strcmp(option->answer,
"\\n") == 0)
1721 sep =
G_store(option->answer);
1723 G_debug(3,
"G_option_to_separator(): key = %s -> sep = '%s'",
1764 stdinout = !option->answer || !*(option->answer) ||
1765 strcmp(option->answer,
"-") == 0;
1767 if (option->gisprompt ==
NULL)
1769 else if (option->multiple)
1770 G_fatal_error(_(
"Opening multiple files not supported for %s="),
1772 else if (strcmp(option->gisprompt,
"old,file,file") == 0) {
1775 else if ((fp = fopen(option->answer,
"r")) ==
NULL)
1777 option->key, option->answer);
1778 }
else if (strcmp(option->gisprompt,
"new,file,file") == 0) {
1781 else if ((fp = fopen(option->answer,
"w")) ==
NULL)
1783 option->key, option->answer);
1798 if (fp != stdin && fp != stdout && fp != stderr)
int G__uses_new_gisprompt(void)
int G_info_format(void)
Get current message format.
int G_strcasecmp(const char *x, const char *y)
String compare ignoring case (upper or lower)
int G__has_required_rule(void)
Checks if there is any rule RULE_REQUIRED (internal use only).
void G__usage_html(void)
Print module usage description in HTML format.
const char * G_find_key_value(const char *key, const struct Key_Value *kv)
Find given key (case sensitive)
const char * G_original_program_name(void)
Return original path of the executed program.
const char * G_mapset(void)
Get current mapset name.
void G__usage_xml(void)
Print module usage description in XML format.
struct GModule * G_define_module(void)
Initializes a new module.
void G_zero(void *buf, int i)
Zero out a buffer, buf, of length i.
const char * G_find_file(const char *element, char *name, const char *mapset)
Searches for a file from the mapset search list or in a specified mapset.
char * recreate_command(int original_path)
Creates command to run non-interactive.
void G__usage_rest(void)
Print module usage description in reStructuredText format.
char * G_store(const char *s)
Copy string to allocated memory.
void G__check_option_rules(void)
Check for option rules (internal use only)
int G_asprintf(char **out, const char *fmt,...)
int G_get_overwrite()
Get overwrite value.
char * G_chop(char *line)
Chop leading and trailing white spaces.
char * G_option_to_separator(const struct Option *option)
Get separator string from the option.
char * G_recreate_command(void)
Creates command to run non-interactive.
char * G_recreate_command_original_path(void)
Creates command to run non-interactive.
struct Flag * G_define_flag(void)
Initializes a Flag struct.
int G_number_of_tokens(char **tokens)
Return number of tokens.
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
int G_snprintf(char *str, size_t size, const char *fmt,...)
snprintf() clone.
void G_close_option_file(FILE *fp)
Close an input/output file returned by G_open_option_file(). If the file pointer is stdin...
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)
int G_suppress_warnings(int flag)
Suppress printing a warning message to stderr.
struct Key_Value * G_read_key_value_file(const char *file)
Read key/values pairs from file.
int G_parser(int argc, char **argv)
Parse command line.
struct Option * G_define_option(void)
Initializes an Option struct.
int G_verbose_max(void)
Get max verbosity level.
int G_debug(int level, const char *msg,...)
Print debugging message.
const char * G_getenv_nofatal(const char *name)
Get environment variable.
void G_set_keywords(const char *keywords)
Set keywords from the string.
void G__script(void)
Generate Python script-like output.
char * G_basename(char *filename, const char *desired_ext)
Truncates filename to the base part (before the last '.') if it matches the extension, otherwise leaves it unchanged.
const char * G_program_name(void)
Return module name.
int G_verbose_std(void)
Get standard verbosity level.
void G_free_tokens(char **tokens)
Free memory allocated to tokens.
int G_verbose(void)
Get current verbosity level.
void G_usage(void)
Command line help/usage message.
FILE * G_open_option_file(const struct Option *option)
Get an input/output file pointer from the option. If the file name is omitted or '-', it returns either stdin or stdout based on the gisprompt.
void G_disable_interactive(void)
Disables the ability of the parser to operate interactively.
char ** G_tokenize(const char *buf, const char *delim)
Tokenize string.
int G_verbose_min(void)
Get min verbosity level.
void G__print_keywords(FILE *fd, void(*format)(FILE *, const char *))
Print list of keywords (internal use only)
void G_add_keyword(const char *keyword)
Add keyword to the list.
int G_is_dirsep(char c)
Checks if a specified character is a valid directory separator character on the host system...
void G__wps_print_process_description(void)
Print the WPS 1.0.0 process description XML document to stdout.
void G_free(void *buf)
Free allocated memory.
const char * G_gisbase(void)
Get full path name of the top level module directory.
void G_warning(const char *msg,...)
Print a warning message to stderr.
int G_spawn(const char *command,...)
Spawn new process based on command.