83 #include <grass/gis.h> 84 #include <grass/spawn.h> 85 #include <grass/glocale.h> 87 #include "parser_local_proto.h" 98 #define MAX_MATCHES 50 105 static void set_flag(
int);
106 static int contains(
const char *,
int);
107 static int valid_option_name(
const char *);
108 static int is_option(
const char *);
109 static int match_option_1(
const char *,
const char *);
110 static int match_option(
const char *,
const char *);
111 static void set_option(
const char *);
112 static void check_opts(
void);
113 static void check_an_opt(
const char *,
int,
const char *,
const char **,
char **);
114 static int check_int(
const char *,
const char **);
115 static int check_double(
const char *,
const char **);
116 static int check_string(
const char *,
const char **,
int *);
117 static void check_required(
void);
118 static void split_opts(
void);
119 static void check_multiple_opts(
void);
120 static int check_overwrite(
void);
121 static void define_keywords(
void);
122 static int module_gui_wx(
void);
123 static void append_error(
const char *);
124 static const char *get_renamed_option(
const char *);
139 st->no_interactive = 1;
162 flag = G_malloc(
sizeof(
struct Flag));
163 st->current_flag->next_flag = flag;
166 flag = &
st->first_flag;
170 G_zero(flag,
sizeof(
struct Flag));
172 st->current_flag = flag;
176 item = G_malloc(
sizeof(
struct Item));
177 st->current_item->next_item = item;
180 item = &
st->first_item;
182 G_zero(item,
sizeof(
struct Item));
187 st->current_item = item;
216 opt = G_malloc(
sizeof(
struct Option));
217 st->current_option->next_opt = opt;
220 opt = &
st->first_option;
223 G_zero(opt,
sizeof(
struct Option));
228 st->current_option = opt;
232 item = G_malloc(
sizeof(
struct Item));
233 st->current_item->next_item = item;
236 item = &
st->first_item;
238 G_zero(item,
sizeof(
struct Item));
242 st->current_item = item;
255 struct GModule *module;
258 module = &
st->module_info;
261 G_zero(module,
sizeof(
struct GModule));
322 const char *gui_envvar;
323 char *ptr, *tmp_name, *
err;
326 char force_gui =
FALSE;
332 st->pgm_path = tmp_name;
336 i = strlen(tmp_name);
344 st->pgm_name = tmp_name;
346 if (!
st->module_info.label && !
st->module_info.description)
347 G_warning(_(
"Bug in UI description. Missing module description"));
351 opt = &
st->first_option;
352 while (
st->n_opts && opt) {
354 st->has_required = 1;
357 G_warning(_(
"Bug in UI description. Missing option key"));
358 if (!valid_option_name(opt->key))
359 G_warning(_(
"Bug in UI description. Option key <%s> is not valid"), opt->key);
360 if (!opt->label && !opt->description)
361 G_warning(_(
"Bug in UI description. Description for option <%s> missing"), opt->key ? opt->key :
"?");
366 char **tokens, delm[2];
379 opt->opts = G_calloc(cnt + 1,
sizeof(
const char *));
383 opt->opts[i] =
G_store(tokens[i]);
388 if (opt->descriptions) {
391 opt->descs = G_calloc(cnt + 1,
sizeof(
const char *));
405 while (opt->opts[j]) {
406 if (strcmp(opt->opts[j], tokens[i]) == 0) {
413 G_warning(_(
"Bug in UI description. Option '%s' in <%s> does not exist"),
414 tokens[i], opt->key);
417 opt->descs[j] =
G_store(tokens[i + 1]);
427 if (opt->multiple && opt->answers && opt->answers[0]) {
428 opt->answer = G_malloc(strlen(opt->answers[0]) + 1);
429 strcpy(opt->answer, opt->answers[0]);
430 for (i = 1; opt->answers[i]; i++) {
431 opt->answer = G_realloc(opt->answer,
432 strlen(opt->answer) +
433 strlen(opt->answers[i]) + 2);
434 strcat(opt->answer,
",");
435 strcat(opt->answer, opt->answers[i]);
438 opt->def = opt->answer;
445 && !
st->no_interactive && isatty(0) &&
446 (gui_envvar &&
G_strcasecmp(gui_envvar,
"text") != 0)) {
447 if (module_gui_wx() == 0)
451 if (argc < 2 && st->has_required && isatty(0)) {
455 else if (argc >= 2) {
458 if (strcmp(argv[1],
"help") == 0 ||
459 strcmp(argv[1],
"-help") == 0 || strcmp(argv[1],
"--help") == 0) {
466 if (strcmp(argv[1],
"--help-text") == 0) {
473 if (strcmp(argv[1],
"--interface-description") == 0) {
480 if (strcmp(argv[1],
"--html-description") == 0) {
487 if (strcmp(argv[1],
"--rst-description") == 0) {
494 if (strcmp(argv[1],
"--wps-process-description") == 0) {
501 if (strcmp(argv[1],
"--script") == 0) {
511 if (strcmp(ptr,
"help") == 0 || strcmp(ptr,
"--h") == 0 ||
512 strcmp(ptr,
"-help") == 0 || strcmp(ptr,
"--help") == 0) {
518 if (strcmp(ptr,
"--json") == 0) {
524 if (strcmp(ptr,
"--o") == 0 || strcmp(ptr,
"--overwrite") == 0) {
529 else if (strcmp(ptr,
"--v") == 0 || strcmp(ptr,
"--verbose") == 0) {
536 if (
st->quiet == 1) {
537 G_warning(_(
"Use either --quiet or --verbose flag, not both. Assuming --verbose."));
543 else if (strcmp(ptr,
"--q") == 0 || strcmp(ptr,
"--quiet") == 0) {
550 if (
st->quiet == -1) {
551 G_warning(_(
"Use either --quiet or --verbose flag, not both. Assuming --quiet."));
557 else if (strcmp(ptr,
"--qq") == 0 ) {
565 if (
st->quiet == -1) {
566 G_warning(_(
"Use either --qq or --verbose flag, not both. Assuming --qq."));
572 else if (strcmp(ptr,
"--ui") == 0) {
577 else if (*ptr ==
'-') {
583 else if (is_option(ptr)) {
589 else if (need_first_opt &&
st->n_opts) {
591 st->first_option.count++;
597 G_asprintf(&err, _(
"Sorry <%s> is not a valid option"), ptr);
609 if (module_gui_wx() != 0)
610 G_fatal_error(_(
"Your installation doesn't include GUI, exiting."));
615 check_multiple_opts();
622 if (!
st->suppress_required)
627 if (
st->n_errors > 0) {
631 fprintf(stderr,
"\n");
632 for (i = 0; i <
st->n_errors; i++) {
633 fprintf(stderr,
"%s: %s\n", _(
"ERROR"),
st->error[i]);
640 if(print_json == 1) {
645 if (!
st->suppress_overwrite) {
646 if (check_overwrite())
674 G_debug(3,
"G_recreate_command()");
678 buff = G_calloc(1024,
sizeof(
char));
685 if (len >= nalloced) {
686 nalloced += (1024 > len) ? 1024 : len + 1;
687 buff = G_realloc(buff, nalloced);
694 slen = strlen(
" --overwrite");
695 if (len + slen >= nalloced) {
696 nalloced += (1024 > len) ? 1024 : len + 1;
697 buff = G_realloc(buff, nalloced);
699 strcpy(cur,
" --overwrite");
712 if (len + slen >= nalloced) {
713 nalloced += (1024 > len) ? 1024 : len + 1;
714 buff = G_realloc(buff, nalloced);
722 flag = &
st->first_flag;
724 if (flag->answer == 1) {
730 if (len + slen >= nalloced) {
732 (nalloced + 1024 > len + slen) ? 1024 : slen + 1;
733 buff = G_realloc(buff, nalloced);
740 flag = flag->next_flag;
744 opt = &
st->first_option;
745 while (
st->n_opts && opt) {
746 if (opt->answer && opt->answer[0] ==
'\0') {
747 slen = strlen(opt->key) + 4;
748 if (len + slen >= nalloced) {
749 nalloced += (nalloced + 1024 > len + slen) ? 1024 : slen + 1;
750 buff = G_realloc(buff, nalloced);
755 strcpy(cur, opt->key);
756 cur = strchr(cur,
'\0');
759 if (opt->type == TYPE_STRING) {
764 }
else if (opt->answer && opt->answers && opt->answers[0]) {
765 slen = strlen(opt->key) + strlen(opt->answers[0]) + 4;
766 if (len + slen >= nalloced) {
767 nalloced += (nalloced + 1024 > len + slen) ? 1024 : slen + 1;
768 buff = G_realloc(buff, nalloced);
773 strcpy(cur, opt->key);
774 cur = strchr(cur,
'\0');
777 if (opt->type == TYPE_STRING) {
781 strcpy(cur, opt->answers[0]);
782 cur = strchr(cur,
'\0');
784 for (n = 1; opt->answers[n]; n++) {
785 if (!opt->answers[n])
787 slen = strlen(opt->answers[n]) + 2;
788 if (len + slen >= nalloced) {
790 (nalloced + 1024 > len + slen) ? 1024 : slen + 1;
791 buff = G_realloc(buff, nalloced);
796 strcpy(cur, opt->answers[n]);
797 cur = strchr(cur,
'\0');
800 if (opt->type == TYPE_STRING) {
850 if (
st->n_keys >=
st->n_keys_alloc) {
851 st->n_keys_alloc += 10;
852 st->module_info.keywords = G_realloc(
st->module_info.keywords,
853 st->n_keys_alloc *
sizeof(
char *));
856 st->module_info.keywords[
st->n_keys++] =
G_store(keyword);
867 st->module_info.keywords = (
const char **)tokens;
877 char desc[KEYLENGTH];
879 if (
st->module_info.overwrite)
885 opt = &
st->first_option;
887 if (opt->gisprompt) {
889 if (strcmp(age,
"new") == 0)
912 for(i = 0; i <
st->n_keys; i++) {
914 fprintf(fd,
"%s",
st->module_info.keywords[i]);
917 format(fd,
st->module_info.keywords[i]);
919 if (i < st->n_keys - 1)
934 return st->module_info.overwrite;
937 void define_keywords(
void)
940 st->n_keys_alloc = 0;
953 int module_gui_wx(
void)
955 char script[GPATH_MAX];
963 sprintf(script,
"%s/gui/wxpython/gui_core/forms.py",
965 if (access(script, F_OK) != -1)
966 G_spawn(getenv(
"GRASS_PYTHON"), getenv(
"GRASS_PYTHON"),
989 flag = &
st->first_flag;
991 if (flag->key == f) {
993 if (flag->suppress_required)
994 st->suppress_required = 1;
995 if (flag->suppress_overwrite)
996 st->suppress_overwrite = 1;
999 flag = flag->next_flag;
1009 int contains(
const char *s,
int c)
1019 int valid_option_name(
const char *
string)
1021 int m = strlen(
string);
1022 int n = strspn(
string,
"abcdefghijklmnopqrstuvwxyz0123456789_");
1030 if (
string[m-1] ==
'_')
1036 int is_option(
const char *
string)
1038 int n = strspn(
string,
"abcdefghijklmnopqrstuvwxyz0123456789_");
1040 return n > 0 &&
string[n] ==
'=' &&
string[0] !=
'_' &&
string[n-1] !=
'_';
1043 int match_option_1(
const char *
string,
const char *option)
1047 if (*
string ==
'\0')
1050 if (*option ==
'\0')
1053 if (*
string == *option && match_option_1(
string + 1, option + 1))
1056 if (*option ==
'_' && match_option_1(
string, option + 1))
1059 next = strchr(option,
'_');
1064 return match_option_1(
string + 1, next + 1);
1066 return match_option_1(
string, next + 1);
1069 int match_option(
const char *
string,
const char *option)
1071 return (*
string == *option)
1072 && match_option_1(
string + 1, option + 1);
1075 void set_option(
const char *
string)
1077 struct Option *at_opt =
NULL;
1078 struct Option *opt =
NULL;
1080 char the_key[KEYLENGTH];
1087 for (ptr = the_key; *
string !=
'='; ptr++,
string++)
1093 key_len = strlen(the_key);
1094 for (at_opt = &
st->first_option; at_opt; at_opt = at_opt->next_opt) {
1098 if (strcmp(the_key, at_opt->key) == 0) {
1099 matches[0] = at_opt;
1104 if (strncmp(the_key, at_opt->key, key_len) == 0 ||
1105 match_option(the_key, at_opt->key)) {
1108 matches[found++] = at_opt;
1114 int length = strlen(matches[0]->key);
1117 for (i = 1; i < found; i++) {
1118 int len = strlen(matches[i]->key);
1124 for (i = 0; prefix && i < found; i++)
1125 if (strncmp(matches[i]->key, matches[shortest]->key, length) != 0)
1128 matches[0] = matches[shortest];
1134 for (i = 0; i < found; i++) {
1135 G_asprintf(&err, _(
"Option <%s=> matches"), matches[i]->key);
1147 const char *renamed_key =
NULL;
1149 renamed_key = get_renamed_option(the_key);
1151 for (at_opt = &
st->first_option; at_opt; at_opt = at_opt->next_opt) {
1152 if (strcmp(renamed_key, at_opt->key) == 0) {
1153 G_warning(_(
"Please update the usage of <%s>: " 1154 "option <%s> has been renamed to <%s>"),
1171 if (getenv(
"GRASS_FULL_OPTION_NAMES") && strcmp(the_key, opt->key) != 0)
1172 G_warning(_(
"<%s> is an abbreviation for <%s>"), the_key, opt->key);
1176 if (!opt->multiple) {
1177 G_asprintf(&err, _(
"Option <%s> does not accept multiple answers"), opt->key);
1180 opt->answer = G_realloc(opt->answer,
1181 strlen(opt->answer) + strlen(
string) + 2);
1182 strcat(opt->answer,
",");
1183 strcat(opt->answer,
string);
1186 opt->answer =
G_store(
string);
1189 void check_opts(
void)
1197 opt = &
st->first_option;
1202 if (opt->multiple == 0)
1203 check_an_opt(opt->key, opt->type,
1204 opt->options, opt->opts, &opt->answer);
1206 for (ans = 0; opt->answers[ans] !=
'\0'; ans++)
1207 check_an_opt(opt->key, opt->type,
1208 opt->options, opt->opts, &opt->answers[ans]);
1215 opt->checker(opt->answer);
1217 opt = opt->next_opt;
1221 void check_an_opt(
const char *key,
int type,
const char *options,
1222 const char **opts,
char **answerp)
1224 const char *answer = *answerp;
1235 error = check_int(answer, opts);
1238 error = check_double(answer, opts);
1241 error = check_string(answer, opts, &found);
1249 _(
"Illegal range syntax for parameter <%s>\n" 1250 "\tPresented as: %s"), key, options);
1255 _(
"Value <%s> out of range for parameter <%s>\n" 1256 "\tLegal range: %s"), answer, key, options);
1261 _(
"Missing value for parameter <%s>"),
1267 _(
"Value <%s> ambiguous for parameter <%s>\n" 1268 "\tValid options: %s"), answer, key, options);
1272 *answerp =
G_store(opts[found]);
1278 int check_int(
const char *ans,
const char **opts)
1283 if (strcmp(ans,
"-") == 0)
1286 if (sscanf(ans,
"%d", &d) != 1)
1292 for (i = 0; opts[i]; i++) {
1293 const char *opt = opts[i];
1296 if (contains(opt,
'-')) {
1297 if (sscanf(opt,
"%d-%d", &lo, &hi) == 2) {
1298 if (d >= lo && d <= hi)
1301 else if (sscanf(opt,
"-%d", &hi) == 1) {
1305 else if (sscanf(opt,
"%d-", &lo) == 1) {
1313 if (sscanf(opt,
"%d", &lo) == 1) {
1325 int check_double(
const char *ans,
const char **opts)
1331 if (strcmp(ans,
"-") == 0)
1334 if (sscanf(ans,
"%lf", &d) != 1)
1340 for (i = 0; opts[i]; i++) {
1341 const char *opt = opts[i];
1344 if (contains(opt,
'-')) {
1345 if (sscanf(opt,
"%lf-%lf", &lo, &hi) == 2) {
1346 if (d >= lo && d <= hi)
1349 else if (sscanf(opt,
"-%lf", &hi) == 1) {
1353 else if (sscanf(opt,
"%lf-", &lo) == 1) {
1361 if (sscanf(opt,
"%lf", &lo) == 1) {
1373 int check_string(
const char *ans,
const char **opts,
int *result)
1375 int len = strlen(ans);
1383 for (i = 0; opts[i]; i++) {
1384 if (strcmp(ans, opts[i]) == 0)
1386 if (strncmp(ans, opts[i], len) == 0 || match_option(ans, opts[i])) {
1389 matches[found++] = i;
1395 int length = strlen(opts[matches[0]]);
1398 for (i = 1; i < found; i++) {
1399 int len = strlen(opts[matches[i]]);
1405 for (i = 0; prefix && i < found; i++)
1406 if (strncmp(opts[matches[i]], opts[matches[shortest]], length) != 0)
1409 matches[0] = matches[shortest];
1415 *result = matches[0];
1417 if (found > 0 && getenv(
"GRASS_FULL_OPTION_NAMES") && strcmp(ans, opts[matches[0]]) != 0)
1418 G_warning(_(
"<%s> is an abbreviation for <%s>"), ans, opts[matches[0]]);
1427 void check_required(
void)
1437 opt = &
st->first_option;
1439 if (opt->required && !opt->answer) {
1440 G_asprintf(&err, _(
"Required parameter <%s> not set:\n" 1442 opt->key, (opt->label ? opt->label : opt->description));
1445 opt = opt->next_opt;
1449 void split_opts(
void)
1462 opt = &
st->first_option;
1467 opt->answers = G_malloc(allocated *
sizeof(
char *));
1471 opt->answers[ans_num] =
NULL;
1474 for (len = 0, ptr2 = ptr1; *ptr2 !=
'\0' && *ptr2 !=
',';
1478 opt->answers[ans_num] = G_malloc(len + 1);
1479 memcpy(opt->answers[ans_num], ptr1, len);
1480 opt->answers[ans_num][len] = 0;
1484 if (ans_num >= allocated) {
1486 opt->answers = G_realloc(opt->answers,
1487 allocated *
sizeof(
char *));
1490 opt->answers[ans_num] =
NULL;
1502 opt = opt->next_opt;
1506 void check_multiple_opts(
void)
1518 opt = &
st->first_option;
1521 if (opt->answer && strcmp(opt->answer,
"-") && opt->key_desc) {
1524 for (ptr = opt->key_desc; *ptr !=
'\0'; ptr++)
1528 for (n = 0; opt->answers[n] !=
'\0'; n++) ;
1532 _(
"Option <%s> must be provided in multiples of %d\n" 1533 "\tYou provided %d item(s): %s"),
1534 opt->key, n_commas, n, opt->answer);
1539 opt = opt->next_opt;
1544 int check_overwrite(
void)
1547 char age[KEYLENGTH];
1549 char desc[KEYLENGTH];
1551 const char *overstr;
1554 st->module_info.overwrite = 0;
1562 over = atoi(overstr);
1566 if ((overstr = getenv(
"GRASS_OVERWRITE"))) {
1571 if (
st->overwrite || over) {
1572 st->module_info.overwrite = 1;
1574 putenv(
"GRASS_OVERWRITE=1");
1579 opt = &
st->first_option;
1581 if (opt->answer && opt->gisprompt) {
1584 if (strcmp(age,
"new") == 0) {
1588 for (i = 0; opt->answers[i]; i++) {
1590 if (strcmp(element,
"file") == 0) {
1591 if (access(opt->answers[i], F_OK) == 0)
1594 else if (strcmp(element,
"mapset") != 0) {
1603 if (!
st->overwrite && !over) {
1606 fprintf(stderr, _(
"ERROR: "));
1608 _(
"option <%s>: <%s> exists. To overwrite, use the --overwrite flag"),
1609 opt->key, opt->answers[i]);
1610 fprintf(stderr,
"\n");
1613 fprintf(stderr,
"GRASS_INFO_ERROR(%d,1): ", getpid());
1615 _(
"option <%s>: <%s> exists. To overwrite, use the --overwrite flag"),
1616 opt->key, opt->answers[i]);
1617 fprintf(stderr,
"\n");
1618 fprintf(stderr,
"GRASS_INFO_END(%d,1)\n",
1628 opt = opt->next_opt;
1640 for (ptr1 = gisprompt, ptr2 = age; *ptr1 !=
'\0'; ptr1++, ptr2++) {
1647 for (ptr1++, ptr2 = element; *ptr1 !=
'\0'; ptr1++, ptr2++) {
1654 for (ptr1++, ptr2 = desc; *ptr1 !=
'\0'; ptr1++, ptr2++) {
1662 void append_error(
const char *msg)
1664 st->error = G_realloc(
st->error,
sizeof(
char *) * (
st->n_errors + 1));
1668 const char *get_renamed_option(
const char *key)
1670 const char *pgm, *key_new;
1673 if (!
st->renamed_options) {
1675 char path[GPATH_MAX];
1688 pgm_key = (
char *) G_malloc (strlen(pgm) + strlen(key) + 2);
1723 if (option->gisprompt ==
NULL ||
1724 strcmp(option->gisprompt,
"old,separator,separator") != 0)
1725 G_fatal_error(_(
"%s= is not a separator option"), option->key);
1727 if (option->answer ==
NULL)
1728 G_fatal_error(_(
"No separator given for %s="), option->key);
1730 if (strcmp(option->answer,
"pipe") == 0)
1732 else if (strcmp(option->answer,
"comma") == 0)
1734 else if (strcmp(option->answer,
"space") == 0)
1736 else if (strcmp(option->answer,
"tab") == 0 ||
1737 strcmp(option->answer,
"\\t") == 0)
1739 else if (strcmp(option->answer,
"newline") == 0 ||
1740 strcmp(option->answer,
"\\n") == 0)
1743 sep =
G_store(option->answer);
1745 G_debug(3,
"G_option_to_separator(): key = %s -> sep = '%s'",
1786 stdinout = !option->answer || !*(option->answer) ||
1787 strcmp(option->answer,
"-") == 0;
1789 if (option->gisprompt ==
NULL)
1791 else if (option->multiple)
1792 G_fatal_error(_(
"Opening multiple files not supported for %s="),
1794 else if (strcmp(option->gisprompt,
"old,file,file") == 0) {
1797 else if ((fp = fopen(option->answer,
"r")) ==
NULL)
1799 option->key, option->answer);
1800 }
else if (strcmp(option->gisprompt,
"new,file,file") == 0) {
1803 else if ((fp = fopen(option->answer,
"w")) ==
NULL)
1805 option->key, option->answer);
1820 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.
char * G__json(void)
This function generates actinia JSON process chain building blocks from the command line arguments th...
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.
void G__split_gisprompt(const char *gisprompt, char *age, char *element, char *desc)
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.