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;
347 if (!
st->module_info.label && !
st->module_info.description)
348 G_warning(_(
"Bug in UI description. Missing module description"));
352 opt = &
st->first_option;
353 while (
st->n_opts && opt) {
355 st->has_required = 1;
358 G_warning(_(
"Bug in UI description. Missing option key"));
359 if (!valid_option_name(opt->key))
360 G_warning(_(
"Bug in UI description. Option key <%s> is not valid"), opt->key);
361 if (!opt->label && !opt->description)
362 G_warning(_(
"Bug in UI description. Description for option <%s> missing"), opt->key ? opt->key :
"?");
367 char **tokens, delm[2];
380 opt->opts = G_calloc(cnt + 1,
sizeof(
const char *));
384 opt->opts[i] =
G_store(tokens[i]);
389 if (opt->descriptions) {
392 opt->descs = G_calloc(cnt + 1,
sizeof(
const char *));
406 while (opt->opts[j]) {
407 if (strcmp(opt->opts[j], tokens[i]) == 0) {
414 G_warning(_(
"Bug in UI description. Option '%s' in <%s> does not exist"),
415 tokens[i], opt->key);
418 opt->descs[j] =
G_store(tokens[i + 1]);
428 if (opt->multiple && opt->answers && opt->answers[0]) {
429 opt->answer = G_malloc(strlen(opt->answers[0]) + 1);
430 strcpy(opt->answer, opt->answers[0]);
431 for (i = 1; opt->answers[i]; i++) {
432 opt->answer = G_realloc(opt->answer,
433 strlen(opt->answer) +
434 strlen(opt->answers[i]) + 2);
435 strcat(opt->answer,
",");
436 strcat(opt->answer, opt->answers[i]);
439 opt->def = opt->answer;
446 && !
st->no_interactive && isatty(0) &&
447 (gui_envvar &&
G_strcasecmp(gui_envvar,
"text") != 0)) {
448 if (module_gui_wx() == 0)
452 if (argc < 2 && st->has_required && isatty(0)) {
456 else if (argc >= 2) {
459 if (strcmp(argv[1],
"help") == 0 ||
460 strcmp(argv[1],
"-help") == 0 || strcmp(argv[1],
"--help") == 0) {
467 if (strcmp(argv[1],
"--help-text") == 0) {
474 if (strcmp(argv[1],
"--interface-description") == 0) {
481 if (strcmp(argv[1],
"--html-description") == 0) {
488 if (strcmp(argv[1],
"--rst-description") == 0) {
495 if (strcmp(argv[1],
"--wps-process-description") == 0) {
502 if (strcmp(argv[1],
"--script") == 0) {
512 if (strcmp(ptr,
"help") == 0 || strcmp(ptr,
"--h") == 0 ||
513 strcmp(ptr,
"-help") == 0 || strcmp(ptr,
"--help") == 0) {
519 if (strcmp(ptr,
"--o") == 0 || strcmp(ptr,
"--overwrite") == 0) {
524 else if (strcmp(ptr,
"--v") == 0 || strcmp(ptr,
"--verbose") == 0) {
531 if (
st->quiet == 1) {
532 G_warning(_(
"Use either --quiet or --verbose flag, not both. Assuming --verbose."));
538 else if (strcmp(ptr,
"--q") == 0 || strcmp(ptr,
"--quiet") == 0) {
545 if (
st->quiet == -1) {
546 G_warning(_(
"Use either --quiet or --verbose flag, not both. Assuming --quiet."));
552 else if (strcmp(ptr,
"--qq") == 0 ) {
560 if (
st->quiet == -1) {
561 G_warning(_(
"Use either --qq or --verbose flag, not both. Assuming --qq."));
567 else if (strcmp(ptr,
"--ui") == 0) {
572 else if (*ptr ==
'-') {
578 else if (is_option(ptr)) {
584 else if (need_first_opt &&
st->n_opts) {
586 st->first_option.count++;
592 G_asprintf(&err, _(
"Sorry <%s> is not a valid option"), ptr);
604 if (module_gui_wx() != 0)
605 G_fatal_error(_(
"Your installation doesn't include GUI, exiting."));
610 check_multiple_opts();
617 if (!
st->suppress_required)
622 if (
st->n_errors > 0) {
626 fprintf(stderr,
"\n");
627 for (i = 0; i <
st->n_errors; i++) {
628 fprintf(stderr,
"%s: %s\n", _(
"ERROR"),
st->error[i]);
634 if (!
st->suppress_overwrite) {
635 if (check_overwrite())
663 G_debug(3,
"G_recreate_command()");
667 buff = G_calloc(1024,
sizeof(
char));
674 if (len >= nalloced) {
675 nalloced += (1024 > len) ? 1024 : len + 1;
676 buff = G_realloc(buff, nalloced);
683 slen = strlen(
" --overwrite");
684 if (len + slen >= nalloced) {
685 nalloced += (1024 > len) ? 1024 : len + 1;
686 buff = G_realloc(buff, nalloced);
688 strcpy(cur,
" --overwrite");
701 if (len + slen >= nalloced) {
702 nalloced += (1024 > len) ? 1024 : len + 1;
703 buff = G_realloc(buff, nalloced);
711 flag = &
st->first_flag;
713 if (flag->answer == 1) {
719 if (len + slen >= nalloced) {
721 (nalloced + 1024 > len + slen) ? 1024 : slen + 1;
722 buff = G_realloc(buff, nalloced);
729 flag = flag->next_flag;
733 opt = &
st->first_option;
734 while (
st->n_opts && opt) {
735 if (opt->answer && opt->answer[0] ==
'\0') {
736 slen = strlen(opt->key) + 4;
737 if (len + slen >= nalloced) {
738 nalloced += (nalloced + 1024 > len + slen) ? 1024 : slen + 1;
739 buff = G_realloc(buff, nalloced);
744 strcpy(cur, opt->key);
745 cur = strchr(cur,
'\0');
748 if (opt->type == TYPE_STRING) {
753 }
else if (opt->answer && opt->answers && opt->answers[0]) {
754 slen = strlen(opt->key) + strlen(opt->answers[0]) + 4;
755 if (len + slen >= nalloced) {
756 nalloced += (nalloced + 1024 > len + slen) ? 1024 : slen + 1;
757 buff = G_realloc(buff, nalloced);
762 strcpy(cur, opt->key);
763 cur = strchr(cur,
'\0');
766 if (opt->type == TYPE_STRING) {
770 strcpy(cur, opt->answers[0]);
771 cur = strchr(cur,
'\0');
773 for (n = 1; opt->answers[n]; n++) {
774 if (!opt->answers[n])
776 slen = strlen(opt->answers[n]) + 2;
777 if (len + slen >= nalloced) {
779 (nalloced + 1024 > len + slen) ? 1024 : slen + 1;
780 buff = G_realloc(buff, nalloced);
785 strcpy(cur, opt->answers[n]);
786 cur = strchr(cur,
'\0');
789 if (opt->type == TYPE_STRING) {
839 if (
st->n_keys >=
st->n_keys_alloc) {
840 st->n_keys_alloc += 10;
841 st->module_info.keywords = G_realloc(
st->module_info.keywords,
842 st->n_keys_alloc *
sizeof(
char *));
845 st->module_info.keywords[
st->n_keys++] =
G_store(keyword);
856 st->module_info.keywords = (
const char **)tokens;
868 if (
st->module_info.overwrite)
874 opt = &
st->first_option;
876 if (opt->gisprompt) {
877 split_gisprompt(opt->gisprompt, age, element, desc);
878 if (strcmp(age,
"new") == 0)
901 for(i = 0; i <
st->n_keys; i++) {
903 fprintf(fd,
"%s",
st->module_info.keywords[i]);
906 format(fd,
st->module_info.keywords[i]);
908 if (i < st->n_keys - 1)
923 return st->module_info.overwrite;
926 void define_keywords(
void)
929 st->n_keys_alloc = 0;
942 int module_gui_wx(
void)
944 char script[GPATH_MAX];
952 sprintf(script,
"%s/gui/wxpython/gui_core/forms.py",
954 if (access(script, F_OK) != -1)
955 G_spawn(getenv(
"GRASS_PYTHON"), getenv(
"GRASS_PYTHON"),
978 flag = &
st->first_flag;
980 if (flag->key == f) {
982 if (flag->suppress_required)
983 st->suppress_required = 1;
984 if (flag->suppress_overwrite)
985 st->suppress_overwrite = 1;
988 flag = flag->next_flag;
998 int contains(
const char *s,
int c)
1008 int valid_option_name(
const char *
string)
1010 int m = strlen(
string);
1011 int n = strspn(
string,
"abcdefghijklmnopqrstuvwxyz0123456789_");
1019 if (
string[m-1] ==
'_')
1025 int is_option(
const char *
string)
1027 int n = strspn(
string,
"abcdefghijklmnopqrstuvwxyz0123456789_");
1029 return n > 0 &&
string[n] ==
'=' &&
string[0] !=
'_' &&
string[n-1] !=
'_';
1032 int match_option_1(
const char *
string,
const char *option)
1036 if (*
string ==
'\0')
1039 if (*option ==
'\0')
1042 if (*
string == *option && match_option_1(
string + 1, option + 1))
1045 if (*option ==
'_' && match_option_1(
string, option + 1))
1048 next = strchr(option,
'_');
1053 return match_option_1(
string + 1, next + 1);
1055 return match_option_1(
string, next + 1);
1058 int match_option(
const char *
string,
const char *option)
1060 return (*
string == *option)
1061 && match_option_1(
string + 1, option + 1);
1064 void set_option(
const char *
string)
1066 struct Option *at_opt =
NULL;
1067 struct Option *opt =
NULL;
1076 for (ptr = the_key; *
string !=
'='; ptr++,
string++)
1082 key_len = strlen(the_key);
1083 for (at_opt = &
st->first_option; at_opt; at_opt = at_opt->next_opt) {
1087 if (strcmp(the_key, at_opt->key) == 0) {
1088 matches[0] = at_opt;
1093 if (strncmp(the_key, at_opt->key, key_len) == 0 ||
1094 match_option(the_key, at_opt->key)) {
1097 matches[found++] = at_opt;
1103 int length = strlen(matches[0]->key);
1106 for (i = 1; i < found; i++) {
1107 int len = strlen(matches[i]->key);
1113 for (i = 0; prefix && i < found; i++)
1114 if (strncmp(matches[i]->key, matches[shortest]->key, length) != 0)
1117 matches[0] = matches[shortest];
1123 for (i = 0; i < found; i++) {
1124 G_asprintf(&err, _(
"Option <%s=> matches"), matches[i]->key);
1136 const char *renamed_key =
NULL;
1138 renamed_key = get_renamed_option(the_key);
1140 for (at_opt = &
st->first_option; at_opt; at_opt = at_opt->next_opt) {
1141 if (strcmp(renamed_key, at_opt->key) == 0) {
1142 G_warning(_(
"Please update the usage of <%s>: " 1143 "option <%s> has been renamed to <%s>"),
1160 if (getenv(
"GRASS_FULL_OPTION_NAMES") && strcmp(the_key, opt->key) != 0)
1161 G_warning(_(
"<%s> is an abbreviation for <%s>"), the_key, opt->key);
1165 if (!opt->multiple) {
1166 G_asprintf(&err, _(
"Option <%s> does not accept multiple answers"), opt->key);
1169 opt->answer = G_realloc(opt->answer,
1170 strlen(opt->answer) + strlen(
string) + 2);
1171 strcat(opt->answer,
",");
1172 strcat(opt->answer,
string);
1175 opt->answer =
G_store(
string);
1178 void check_opts(
void)
1186 opt = &
st->first_option;
1191 if (opt->multiple == 0)
1192 check_an_opt(opt->key, opt->type,
1193 opt->options, opt->opts, &opt->answer);
1195 for (ans = 0; opt->answers[ans] !=
'\0'; ans++)
1196 check_an_opt(opt->key, opt->type,
1197 opt->options, opt->opts, &opt->answers[ans]);
1204 opt->checker(opt->answer);
1206 opt = opt->next_opt;
1210 void check_an_opt(
const char *key,
int type,
const char *options,
1211 const char **opts,
char **answerp)
1213 const char *answer = *answerp;
1224 error = check_int(answer, opts);
1227 error = check_double(answer, opts);
1230 error = check_string(answer, opts, &found);
1238 _(
"Illegal range syntax for parameter <%s>\n" 1239 "\tPresented as: %s"), key, options);
1244 _(
"Value <%s> out of range for parameter <%s>\n" 1245 "\tLegal range: %s"), answer, key, options);
1250 _(
"Missing value for parameter <%s>"),
1256 _(
"Value <%s> ambiguous for parameter <%s>\n" 1257 "\tValid options: %s"), answer, key, options);
1261 *answerp =
G_store(opts[found]);
1267 int check_int(
const char *ans,
const char **opts)
1272 if (strcmp(ans,
"-") == 0)
1275 if (sscanf(ans,
"%d", &d) != 1)
1281 for (i = 0; opts[i]; i++) {
1282 const char *opt = opts[i];
1285 if (contains(opt,
'-')) {
1286 if (sscanf(opt,
"%d-%d", &lo, &hi) == 2) {
1287 if (d >= lo && d <= hi)
1290 else if (sscanf(opt,
"-%d", &hi) == 1) {
1294 else if (sscanf(opt,
"%d-", &lo) == 1) {
1302 if (sscanf(opt,
"%d", &lo) == 1) {
1314 int check_double(
const char *ans,
const char **opts)
1320 if (strcmp(ans,
"-") == 0)
1323 if (sscanf(ans,
"%lf", &d) != 1)
1329 for (i = 0; opts[i]; i++) {
1330 const char *opt = opts[i];
1333 if (contains(opt,
'-')) {
1334 if (sscanf(opt,
"%lf-%lf", &lo, &hi) == 2) {
1335 if (d >= lo && d <= hi)
1338 else if (sscanf(opt,
"-%lf", &hi) == 1) {
1342 else if (sscanf(opt,
"%lf-", &lo) == 1) {
1350 if (sscanf(opt,
"%lf", &lo) == 1) {
1362 int check_string(
const char *ans,
const char **opts,
int *result)
1364 int len = strlen(ans);
1372 for (i = 0; opts[i]; i++) {
1373 if (strcmp(ans, opts[i]) == 0)
1375 if (strncmp(ans, opts[i], len) == 0 || match_option(ans, opts[i])) {
1378 matches[found++] = i;
1384 int length = strlen(opts[matches[0]]);
1387 for (i = 1; i < found; i++) {
1388 int len = strlen(opts[matches[i]]);
1394 for (i = 0; prefix && i < found; i++)
1395 if (strncmp(opts[matches[i]], opts[matches[shortest]], length) != 0)
1398 matches[0] = matches[shortest];
1404 *result = matches[0];
1406 if (found > 0 && getenv(
"GRASS_FULL_OPTION_NAMES") && strcmp(ans, opts[matches[0]]) != 0)
1407 G_warning(_(
"<%s> is an abbreviation for <%s>"), ans, opts[matches[0]]);
1416 void check_required(
void)
1426 opt = &
st->first_option;
1428 if (opt->required && !opt->answer) {
1429 G_asprintf(&err, _(
"Required parameter <%s> not set:\n" 1431 opt->key, (opt->label ? opt->label : opt->description));
1434 opt = opt->next_opt;
1438 void split_opts(
void)
1451 opt = &
st->first_option;
1456 opt->answers = G_malloc(allocated *
sizeof(
char *));
1460 opt->answers[ans_num] =
NULL;
1463 for (len = 0, ptr2 = ptr1; *ptr2 !=
'\0' && *ptr2 !=
',';
1467 opt->answers[ans_num] = G_malloc(len + 1);
1468 memcpy(opt->answers[ans_num], ptr1, len);
1469 opt->answers[ans_num][len] = 0;
1473 if (ans_num >= allocated) {
1475 opt->answers = G_realloc(opt->answers,
1476 allocated *
sizeof(
char *));
1479 opt->answers[ans_num] =
NULL;
1491 opt = opt->next_opt;
1495 void check_multiple_opts(
void)
1507 opt = &
st->first_option;
1510 if (opt->answer && strcmp(opt->answer,
"-") && opt->key_desc) {
1513 for (ptr = opt->key_desc; *ptr !=
'\0'; ptr++)
1517 for (n = 0; opt->answers[n] !=
'\0'; n++) ;
1521 _(
"Option <%s> must be provided in multiples of %d\n" 1522 "\tYou provided %d item(s): %s"),
1523 opt->key, n_commas, n, opt->answer);
1528 opt = opt->next_opt;
1533 int check_overwrite(
void)
1540 const char *overstr;
1543 st->module_info.overwrite = 0;
1551 over = atoi(overstr);
1555 if ((overstr = getenv(
"GRASS_OVERWRITE"))) {
1560 if (
st->overwrite || over) {
1561 st->module_info.overwrite = 1;
1563 putenv(
"GRASS_OVERWRITE=1");
1568 opt = &
st->first_option;
1570 if (opt->answer && opt->gisprompt) {
1571 split_gisprompt(opt->gisprompt, age, element, desc);
1573 if (strcmp(age,
"new") == 0) {
1577 for (i = 0; opt->answers[i]; i++) {
1579 if (strcmp(element,
"file") == 0) {
1580 if (access(opt->answers[i], F_OK) == 0)
1583 else if (strcmp(element,
"mapset") != 0) {
1592 if (!
st->overwrite && !over) {
1595 fprintf(stderr, _(
"ERROR: "));
1597 _(
"option <%s>: <%s> exists. To overwrite, use the --overwrite flag"),
1598 opt->key, opt->answers[i]);
1599 fprintf(stderr,
"\n");
1602 fprintf(stderr,
"GRASS_INFO_ERROR(%d,1): ", getpid());
1604 _(
"option <%s>: <%s> exists. To overwrite, use the --overwrite flag"),
1605 opt->key, opt->answers[i]);
1606 fprintf(stderr,
"\n");
1607 fprintf(stderr,
"GRASS_INFO_END(%d,1)\n",
1617 opt = opt->next_opt;
1623 void split_gisprompt(
const char *gisprompt,
char *age,
char *
element,
1629 for (ptr1 = gisprompt, ptr2 = age; *ptr1 !=
'\0'; ptr1++, ptr2++) {
1636 for (ptr1++, ptr2 = element; *ptr1 !=
'\0'; ptr1++, ptr2++) {
1643 for (ptr1++, ptr2 = desc; *ptr1 !=
'\0'; ptr1++, ptr2++) {
1651 void append_error(
const char *msg)
1653 st->error = G_realloc(
st->error,
sizeof(
char *) * (
st->n_errors + 1));
1657 const char *get_renamed_option(
const char *key)
1659 const char *pgm, *key_new;
1662 if (!
st->renamed_options) {
1664 char path[GPATH_MAX];
1677 pgm_key = (
char *) G_malloc (strlen(pgm) + strlen(key) + 2);
1712 if (option->gisprompt ==
NULL ||
1713 strcmp(option->gisprompt,
"old,separator,separator") != 0)
1714 G_fatal_error(_(
"%s= is not a separator option"), option->key);
1716 if (option->answer ==
NULL)
1717 G_fatal_error(_(
"No separator given for %s="), option->key);
1719 if (strcmp(option->answer,
"pipe") == 0)
1721 else if (strcmp(option->answer,
"comma") == 0)
1723 else if (strcmp(option->answer,
"space") == 0)
1725 else if (strcmp(option->answer,
"tab") == 0 ||
1726 strcmp(option->answer,
"\\t") == 0)
1728 else if (strcmp(option->answer,
"newline") == 0 ||
1729 strcmp(option->answer,
"\\n") == 0)
1732 sep =
G_store(option->answer);
1734 G_debug(3,
"G_option_to_separator(): key = %s -> sep = '%s'",
1775 stdinout = !option->answer || !*(option->answer) ||
1776 strcmp(option->answer,
"-") == 0;
1778 if (option->gisprompt ==
NULL)
1780 else if (option->multiple)
1781 G_fatal_error(_(
"Opening multiple files not supported for %s="),
1783 else if (strcmp(option->gisprompt,
"old,file,file") == 0) {
1786 else if ((fp = fopen(option->answer,
"r")) ==
NULL)
1788 option->key, option->answer);
1789 }
else if (strcmp(option->gisprompt,
"new,file,file") == 0) {
1792 else if ((fp = fopen(option->answer,
"w")) ==
NULL)
1794 option->key, option->answer);
1809 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.