86#include <grass/spawn.h>
87#include <grass/glocale.h>
89#include "parser_local_proto.h"
100#define MAX_MATCHES 50
107static void set_flag(
int);
108static int contains(
const char *,
int);
109static int valid_option_name(
const char *);
110static int is_option(
const char *);
111static int match_option_1(
const char *,
const char *);
112static int match_option(
const char *,
const char *);
113static void set_option(
const char *);
114static void check_opts(
void);
115static void check_an_opt(
const char *,
int,
const char *,
const char **,
117static int check_int(
const char *,
const char **);
118static int check_double(
const char *,
const char **);
119static int check_string(
const char *,
const char **,
int *);
120static void check_required(
void);
121static void split_opts(
void);
122static void check_multiple_opts(
void);
123static int check_overwrite(
void);
124static void define_keywords(
void);
125static int module_gui_wx(
void);
126static void append_error(
const char *);
127static const char *get_renamed_option(
const char *);
142 st->no_interactive = 1;
165 flag = G_malloc(
sizeof(
struct Flag));
166 st->current_flag->next_flag = flag;
169 flag = &
st->first_flag;
173 G_zero(flag,
sizeof(
struct Flag));
175 st->current_flag = flag;
179 item = G_malloc(
sizeof(
struct Item));
180 st->current_item->next_item = item;
183 item = &
st->first_item;
185 G_zero(item,
sizeof(
struct Item));
190 st->current_item = item;
219 opt = G_malloc(
sizeof(
struct Option));
220 st->current_option->next_opt = opt;
223 opt = &
st->first_option;
226 G_zero(opt,
sizeof(
struct Option));
231 st->current_option = opt;
235 item = G_malloc(
sizeof(
struct Item));
236 st->current_item->next_item = item;
239 item = &
st->first_item;
241 G_zero(item,
sizeof(
struct Item));
245 st->current_item = item;
258 struct GModule *
module;
261 module = &st->module_info;
264 G_zero(module,
sizeof(
struct GModule));
325 const char *gui_envvar;
326 char *ptr, *tmp_name, *
err;
329 char force_gui =
FALSE;
335 st->pgm_path = tmp_name;
339 i = strlen(tmp_name);
347 st->pgm_name = tmp_name;
349 if (!
st->module_info.label && !
st->module_info.description)
350 G_warning(_(
"Bug in UI description. Missing module description"));
354 opt = &
st->first_option;
355 while (
st->n_opts && opt) {
357 st->has_required = 1;
360 G_warning(_(
"Bug in UI description. Missing option key"));
361 if (!valid_option_name(opt->key))
362 G_warning(_(
"Bug in UI description. Option key <%s> is not valid"),
364 if (!opt->label && !opt->description)
366 _(
"Bug in UI description. Description for option <%s> missing"),
367 opt->key ? opt->key :
"?");
372 char **tokens, delm[2];
385 opt->opts = G_calloc(cnt + 1,
sizeof(
const char *));
389 opt->opts[i] =
G_store(tokens[i]);
394 if (opt->descriptions) {
397 opt->descs = G_calloc(cnt + 1,
sizeof(
const char *));
411 while (opt->opts[j]) {
412 if (strcmp(opt->opts[j], tokens[i]) == 0) {
419 G_warning(_(
"Bug in UI description. Option '%s' in "
420 "<%s> does not exist"),
421 tokens[i], opt->key);
424 opt->descs[j] =
G_store(tokens[i + 1]);
434 if (opt->multiple && opt->answers && opt->answers[0]) {
435 opt->answer = G_malloc(strlen(opt->answers[0]) + 1);
436 strcpy(opt->answer, opt->answers[0]);
437 for (i = 1; opt->answers[i]; i++) {
439 G_realloc(opt->answer, strlen(opt->answer) +
440 strlen(opt->answers[i]) + 2);
441 strcat(opt->answer,
",");
442 strcat(opt->answer, opt->answers[i]);
445 opt->def = opt->answer;
452 !
st->no_interactive && isatty(0) &&
453 (gui_envvar &&
G_strcasecmp(gui_envvar,
"text") != 0)) {
454 if (module_gui_wx() == 0)
458 if (argc < 2 && st->has_required && isatty(0)) {
462 else if (argc >= 2) {
465 if (strcmp(argv[1],
"help") == 0 || strcmp(argv[1],
"-help") == 0 ||
466 strcmp(argv[1],
"--help") == 0) {
473 if (strcmp(argv[1],
"--help-text") == 0) {
480 if (strcmp(argv[1],
"--interface-description") == 0) {
487 if (strcmp(argv[1],
"--html-description") == 0) {
494 if (strcmp(argv[1],
"--rst-description") == 0) {
501 if (strcmp(argv[1],
"--wps-process-description") == 0) {
508 if (strcmp(argv[1],
"--script") == 0) {
518 if (strcmp(ptr,
"help") == 0 || strcmp(ptr,
"--h") == 0 ||
519 strcmp(ptr,
"-help") == 0 || strcmp(ptr,
"--help") == 0) {
525 if (strcmp(ptr,
"--json") == 0) {
531 if (strcmp(ptr,
"--o") == 0 || strcmp(ptr,
"--overwrite") == 0) {
536 else if (strcmp(ptr,
"--v") == 0 || strcmp(ptr,
"--verbose") == 0) {
543 if (
st->quiet == 1) {
544 G_warning(_(
"Use either --quiet or --verbose flag, not "
545 "both. Assuming --verbose."));
551 else if (strcmp(ptr,
"--q") == 0 || strcmp(ptr,
"--quiet") == 0) {
558 if (
st->quiet == -1) {
559 G_warning(_(
"Use either --quiet or --verbose flag, not "
560 "both. Assuming --quiet."));
566 else if (strcmp(ptr,
"--qq") == 0) {
574 if (
st->quiet == -1) {
575 G_warning(_(
"Use either --qq or --verbose flag, not both. "
582 else if (strcmp(ptr,
"--ui") == 0) {
587 else if (*ptr ==
'-') {
592 else if (is_option(ptr)) {
598 else if (need_first_opt &&
st->n_opts) {
600 st->first_option.count++;
606 G_asprintf(&
err, _(
"Sorry <%s> is not a valid option"), ptr);
617 if (module_gui_wx() != 0)
618 G_fatal_error(_(
"Your installation doesn't include GUI, exiting."));
623 check_multiple_opts();
630 if (!
st->suppress_required)
635 if (
st->n_errors > 0) {
639 fprintf(stderr,
"\n");
640 for (i = 0; i <
st->n_errors; i++) {
641 fprintf(stderr,
"%s: %s\n", _(
"ERROR"),
st->error[i]);
648 if (print_json == 1) {
653 if (!
st->suppress_overwrite) {
654 if (check_overwrite())
682 G_debug(3,
"G_recreate_command()");
686 buff = G_calloc(1024,
sizeof(
char));
693 if (len >= nalloced) {
694 nalloced += (1024 > len) ? 1024 : len + 1;
695 buff = G_realloc(buff, nalloced);
702 slen = strlen(
" --overwrite");
703 if (len + slen >= nalloced) {
704 nalloced += (1024 > len) ? 1024 : len + 1;
705 buff = G_realloc(buff, nalloced);
707 strcpy(cur,
" --overwrite");
721 if (len + slen >= nalloced) {
722 nalloced += (1024 > len) ? 1024 : len + 1;
723 buff = G_realloc(buff, nalloced);
731 flag = &
st->first_flag;
733 if (flag->answer == 1) {
739 if (len + slen >= nalloced) {
741 (nalloced + 1024 > len + slen) ? 1024 : slen + 1;
742 buff = G_realloc(buff, nalloced);
749 flag = flag->next_flag;
753 opt = &
st->first_option;
754 while (
st->n_opts && opt) {
755 if (opt->answer && opt->answer[0] ==
'\0') {
756 slen = strlen(opt->key) + 4;
757 if (len + slen >= nalloced) {
758 nalloced += (nalloced + 1024 > len + slen) ? 1024 : slen + 1;
759 buff = G_realloc(buff, nalloced);
764 strcpy(cur, opt->key);
765 cur = strchr(cur,
'\0');
768 if (opt->type == TYPE_STRING) {
774 else if (opt->answer && opt->answers && opt->answers[0]) {
775 slen = strlen(opt->key) + strlen(opt->answers[0]) +
777 if (len + slen >= nalloced) {
778 nalloced += (nalloced + 1024 > len + slen) ? 1024 : slen + 1;
779 buff = G_realloc(buff, nalloced);
784 strcpy(cur, opt->key);
785 cur = strchr(cur,
'\0');
788 if (opt->type == TYPE_STRING) {
792 strcpy(cur, opt->answers[0]);
793 cur = strchr(cur,
'\0');
795 for (n = 1; opt->answers[n]; n++) {
796 if (!opt->answers[n])
798 slen = strlen(opt->answers[n]) + 2;
799 if (len + slen >= nalloced) {
801 (nalloced + 1024 > len + slen) ? 1024 : slen + 1;
802 buff = G_realloc(buff, nalloced);
807 strcpy(cur, opt->answers[n]);
808 cur = strchr(cur,
'\0');
811 if (opt->type == TYPE_STRING) {
861 if (
st->n_keys >=
st->n_keys_alloc) {
862 st->n_keys_alloc += 10;
863 st->module_info.keywords = G_realloc(
st->module_info.keywords,
864 st->n_keys_alloc *
sizeof(
char *));
867 st->module_info.keywords[
st->n_keys++] =
G_store(keyword);
879 st->module_info.keywords = (
const char **)tokens;
888 char desc[KEYLENGTH];
890 if (
st->module_info.overwrite)
896 opt = &
st->first_option;
898 if (opt->gisprompt) {
900 if (strcmp(age,
"new") == 0)
923 for (i = 0; i <
st->n_keys; i++) {
925 fprintf(fd,
"%s",
st->module_info.keywords[i]);
928 format(fd,
st->module_info.keywords[i]);
930 if (i < st->n_keys - 1)
945 return st->module_info.overwrite;
948void define_keywords(
void)
951 st->n_keys_alloc = 0;
964int module_gui_wx(
void)
966 char script[GPATH_MAX];
974 sprintf(script,
"%s/gui/wxpython/gui_core/forms.py", getenv(
"GISBASE"));
975 if (access(script, F_OK) != -1)
976 G_spawn(getenv(
"GRASS_PYTHON"), getenv(
"GRASS_PYTHON"), script,
1000 flag = &
st->first_flag;
1002 if (flag->key == f) {
1004 if (flag->suppress_required)
1005 st->suppress_required = 1;
1006 if (flag->suppress_overwrite)
1007 st->suppress_overwrite = 1;
1010 flag = flag->next_flag;
1021int contains(
const char *s,
int c)
1031int valid_option_name(
const char *
string)
1033 int m = strlen(
string);
1034 int n = strspn(
string,
"abcdefghijklmnopqrstuvwxyz0123456789_");
1042 if (
string[m - 1] ==
'_')
1048int is_option(
const char *
string)
1050 int n = strspn(
string,
"abcdefghijklmnopqrstuvwxyz0123456789_");
1052 return n > 0 &&
string[n] ==
'=' &&
string[0] !=
'_' &&
1053 string[n - 1] !=
'_';
1056int match_option_1(
const char *
string,
const char *option)
1060 if (*
string ==
'\0')
1063 if (*option ==
'\0')
1066 if (*
string == *option && match_option_1(
string + 1, option + 1))
1069 if (*option ==
'_' && match_option_1(
string, option + 1))
1072 next = strchr(option,
'_');
1077 return match_option_1(
string + 1, next + 1);
1079 return match_option_1(
string, next + 1);
1082int match_option(
const char *
string,
const char *option)
1084 return (*
string == *option) && match_option_1(
string + 1, option + 1);
1087void set_option(
const char *
string)
1089 struct Option *at_opt =
NULL;
1090 struct Option *opt =
NULL;
1092 char the_key[KEYLENGTH];
1099 for (ptr = the_key; *
string !=
'='; ptr++,
string++)
1109 key_len = strlen(the_key);
1110 for (at_opt = &
st->first_option; at_opt; at_opt = at_opt->next_opt) {
1114 if (strcmp(the_key, at_opt->key) == 0) {
1115 matches[0] = at_opt;
1120 if (strncmp(the_key, at_opt->key, key_len) == 0 ||
1121 match_option(the_key, at_opt->key)) {
1124 matches[found++] = at_opt;
1130 int length = strlen(matches[0]->key);
1134 for (i = 1; i < found; i++) {
1135 int len = strlen(matches[i]->key);
1142 for (i = 0; prefix && i < found; i++)
1143 if (strncmp(matches[i]->key, matches[shortest]->key, length) != 0)
1146 matches[0] = matches[shortest];
1153 for (i = 0; i < found; i++) {
1154 G_asprintf(&
err, _(
"Option <%s=> matches"), matches[i]->key);
1166 const char *renamed_key =
NULL;
1168 renamed_key = get_renamed_option(the_key);
1170 for (at_opt = &
st->first_option; at_opt;
1171 at_opt = at_opt->next_opt) {
1172 if (strcmp(renamed_key, at_opt->key) == 0) {
1173 G_warning(_(
"Please update the usage of <%s>: "
1174 "option <%s> has been renamed to <%s>"),
1186 G_asprintf(&
err, _(
"%s: Sorry, <%s> is not a valid parameter"),
1192 if (getenv(
"GRASS_FULL_OPTION_NAMES") && strcmp(the_key, opt->key) != 0)
1193 G_warning(_(
"<%s> is an abbreviation for <%s>"), the_key, opt->key);
1197 if (!opt->multiple) {
1198 G_asprintf(&
err, _(
"Option <%s> does not accept multiple answers"),
1203 G_realloc(opt->answer, strlen(opt->answer) + strlen(
string) + 2);
1204 strcat(opt->answer,
",");
1205 strcat(opt->answer,
string);
1208 opt->answer =
G_store(
string);
1211void check_opts(
void)
1219 opt = &
st->first_option;
1224 if (opt->multiple == 0)
1225 check_an_opt(opt->key, opt->type, opt->options, opt->opts,
1228 for (ans = 0; opt->answers[ans] !=
NULL; ans++)
1229 check_an_opt(opt->key, opt->type, opt->options, opt->opts,
1230 &opt->answers[ans]);
1237 opt->checker(opt->answer);
1239 opt = opt->next_opt;
1243void check_an_opt(
const char *key,
int type,
const char *options,
1244 const char **opts,
char **answerp)
1246 const char *answer = *answerp;
1257 error = check_int(answer, opts);
1260 error = check_double(answer, opts);
1263 error = check_string(answer, opts, &found);
1271 _(
"Illegal range syntax for parameter <%s>\n"
1272 "\tPresented as: %s"),
1278 _(
"Value <%s> out of range for parameter <%s>\n"
1279 "\tLegal range: %s"),
1280 answer, key, options);
1284 G_asprintf(&
err, _(
"Missing value for parameter <%s>"), key);
1288 G_asprintf(&
err, _(
"Invalid value <%s> for parameter <%s>"), answer,
1294 _(
"Value <%s> ambiguous for parameter <%s>\n"
1295 "\tValid options: %s"),
1296 answer, key, options);
1300 *answerp =
G_store(opts[found]);
1306int check_int(
const char *ans,
const char **opts)
1311 if (strcmp(ans,
"-") == 0)
1317 if (sscanf(ans,
"%d", &d) != 1)
1323 for (i = 0; opts[i]; i++) {
1324 const char *opt = opts[i];
1327 if (contains(opt,
'-')) {
1328 if (sscanf(opt,
"%d-%d", &lo, &hi) == 2) {
1329 if (d >= lo && d <= hi)
1332 else if (sscanf(opt,
"-%d", &hi) == 1) {
1336 else if (sscanf(opt,
"%d-", &lo) == 1) {
1344 if (sscanf(opt,
"%d", &lo) == 1) {
1356int check_double(
const char *ans,
const char **opts)
1362 if (strcmp(ans,
"-") == 0)
1368 if (sscanf(ans,
"%lf", &d) != 1)
1374 for (i = 0; opts[i]; i++) {
1375 const char *opt = opts[i];
1378 if (contains(opt,
'-')) {
1379 if (sscanf(opt,
"%lf-%lf", &lo, &hi) == 2) {
1380 if (d >= lo && d <= hi)
1383 else if (sscanf(opt,
"-%lf", &hi) == 1) {
1387 else if (sscanf(opt,
"%lf-", &lo) == 1) {
1395 if (sscanf(opt,
"%lf", &lo) == 1) {
1407int check_string(
const char *ans,
const char **opts,
int *result)
1409 int len = strlen(ans);
1417 for (i = 0; opts[i]; i++) {
1418 if (strcmp(ans, opts[i]) == 0)
1420 if (strncmp(ans, opts[i], len) == 0 || match_option(ans, opts[i])) {
1423 matches[found++] = i;
1429 int length = strlen(opts[matches[0]]);
1432 for (i = 1; i < found; i++) {
1433 int lengthi = strlen(opts[matches[i]]);
1435 if (lengthi < length) {
1440 for (i = 0; prefix && i < found; i++)
1441 if (strncmp(opts[matches[i]], opts[matches[shortest]], length) != 0)
1444 matches[0] = matches[shortest];
1450 *result = matches[0];
1452 if (found > 0 && getenv(
"GRASS_FULL_OPTION_NAMES") &&
1453 strcmp(ans, opts[matches[0]]) != 0)
1454 G_warning(_(
"<%s> is an abbreviation for <%s>"), ans, opts[matches[0]]);
1466void check_required(
void)
1476 opt = &
st->first_option;
1478 if (opt->required && !opt->answer) {
1480 _(
"Required parameter <%s> not set:\n"
1482 opt->key, (opt->label ? opt->label : opt->description));
1485 opt = opt->next_opt;
1489void split_opts(
void)
1501 opt = &
st->first_option;
1506 opt->answers = G_malloc(allocated *
sizeof(
char *));
1510 opt->answers[ans_num] =
NULL;
1513 for (len = 0, ptr2 = ptr1; *ptr2 !=
'\0' && *ptr2 !=
',';
1518 opt->answers[ans_num] = G_malloc(len + 1);
1519 memcpy(opt->answers[ans_num], ptr1, len);
1520 opt->answers[ans_num][len] = 0;
1524 if (ans_num >= allocated) {
1527 G_realloc(opt->answers, allocated *
sizeof(
char *));
1530 opt->answers[ans_num] =
NULL;
1542 opt = opt->next_opt;
1546void check_multiple_opts(
void)
1558 opt = &
st->first_option;
1561 if (opt->answer && strcmp(opt->answer,
"-") && opt->key_desc) {
1564 for (ptr = opt->key_desc; *ptr !=
'\0'; ptr++)
1568 for (n = 0; opt->answers[n] !=
NULL; n++)
1573 _(
"Option <%s> must be provided in multiples of %d\n"
1574 "\tYou provided %d item(s): %s"),
1575 opt->key, n_commas, n, opt->answer);
1579 opt = opt->next_opt;
1584int check_overwrite(
void)
1587 char age[KEYLENGTH];
1589 char desc[KEYLENGTH];
1591 const char *overstr;
1594 st->module_info.overwrite = 0;
1602 over = atoi(overstr);
1606 if ((overstr = getenv(
"GRASS_OVERWRITE"))) {
1611 if (
st->overwrite || over) {
1612 st->module_info.overwrite = 1;
1614 putenv(
"GRASS_OVERWRITE=1");
1619 opt = &
st->first_option;
1621 if (opt->answer && opt->gisprompt) {
1624 if (strcmp(age,
"new") == 0) {
1628 for (i = 0; opt->answers[i]; i++) {
1630 if (strcmp(
element,
"file") == 0) {
1631 if (access(opt->answers[i], F_OK) == 0)
1634 else if (strcmp(
element,
"mapset") != 0) {
1643 if (!
st->overwrite && !over) {
1646 fprintf(stderr, _(
"ERROR: "));
1648 _(
"option <%s>: <%s> exists. To "
1649 "overwrite, use the --overwrite "
1651 opt->key, opt->answers[i]);
1652 fprintf(stderr,
"\n");
1655 fprintf(stderr,
"GRASS_INFO_ERROR(%d,1): ",
1658 _(
"option <%s>: <%s> exists. To "
1659 "overwrite, use the --overwrite "
1661 opt->key, opt->answers[i]);
1662 fprintf(stderr,
"\n");
1663 fprintf(stderr,
"GRASS_INFO_END(%d,1)\n",
1673 opt = opt->next_opt;
1685 for (ptr1 = gisprompt, ptr2 = age; *ptr1 !=
'\0'; ptr1++, ptr2++) {
1692 for (ptr1++, ptr2 =
element; *ptr1 !=
'\0'; ptr1++, ptr2++) {
1699 for (ptr1++, ptr2 = desc; *ptr1 !=
'\0'; ptr1++, ptr2++) {
1707void append_error(
const char *msg)
1709 st->error = G_realloc(
st->error,
sizeof(
char *) * (
st->n_errors + 1));
1713const char *get_renamed_option(
const char *key)
1715 const char *pgm, *key_new;
1718 if (!
st->renamed_options) {
1720 char path[GPATH_MAX];
1733 pgm_key = (
char *)G_malloc(strlen(pgm) + strlen(key) + 2);
1768 if (option->gisprompt ==
NULL ||
1769 strcmp(option->gisprompt,
"old,separator,separator") != 0)
1770 G_fatal_error(_(
"%s= is not a separator option"), option->key);
1772 if (option->answer ==
NULL)
1773 G_fatal_error(_(
"No separator given for %s="), option->key);
1775 if (strcmp(option->answer,
"pipe") == 0)
1777 else if (strcmp(option->answer,
"comma") == 0)
1779 else if (strcmp(option->answer,
"space") == 0)
1781 else if (strcmp(option->answer,
"tab") == 0 ||
1782 strcmp(option->answer,
"\\t") == 0)
1784 else if (strcmp(option->answer,
"newline") == 0 ||
1785 strcmp(option->answer,
"\\n") == 0)
1788 sep =
G_store(option->answer);
1790 G_debug(3,
"G_option_to_separator(): key = %s -> sep = '%s'", option->key,
1831 stdinout = !option->answer || !*(option->answer) ||
1832 strcmp(option->answer,
"-") == 0;
1834 if (option->gisprompt ==
NULL)
1836 else if (option->multiple)
1837 G_fatal_error(_(
"Opening multiple files not supported for %s="),
1839 else if (strcmp(option->gisprompt,
"old,file,file") == 0) {
1842 else if ((fp = fopen(option->answer,
"r")) ==
NULL)
1843 G_fatal_error(_(
"Unable to open %s file <%s>: %s"), option->key,
1844 option->answer, strerror(errno));
1846 else if (strcmp(option->gisprompt,
"new,file,file") == 0) {
1849 else if ((fp = fopen(option->answer,
"w")) ==
NULL)
1850 G_fatal_error(_(
"Unable to create %s file <%s>: %s"), option->key,
1851 option->answer, strerror(errno));
1867 if (fp != stdin && fp != stdout && fp != stderr)
void G_free(void *buf)
Free allocated memory.
int G_asprintf(char **out, const char *fmt,...)
char * G_basename(char *filename, const char *desired_ext)
Truncates filename to the base part (before the last '.') if it matches the extension,...
int G_debug(int level, const char *msg,...)
Print debugging message.
const char * G_getenv_nofatal(const char *name)
Get environment variable.
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.
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
int G_suppress_warnings(int flag)
Suppress printing a warning message to stderr.
void G_warning(const char *msg,...)
Print a warning message to stderr.
int G_info_format(void)
Get current message format.
const char * G_gisbase(void)
Get full path name of the top level module directory.
const char * G_find_key_value(const char *key, const struct Key_Value *kv)
Find given key (case sensitive)
struct Key_Value * G_read_key_value_file(const char *file)
Read key/values pairs from file.
const char * G_mapset(void)
Get current mapset name.
struct GModule * G_define_module(void)
Initializes a new module.
struct Flag * G_define_flag(void)
Initializes a Flag struct.
int G_parser(int argc, char **argv)
Parse command line.
void G_set_keywords(const char *keywords)
Set keywords from the string.
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 '-',...
int G__uses_new_gisprompt(void)
void G_add_keyword(const char *keyword)
Add keyword to the list.
int G_get_overwrite(void)
Get overwrite value.
char * G_option_to_separator(const struct Option *option)
Get separator string from the option.
char * recreate_command(int original_path)
Creates command to run non-interactive.
void G_close_option_file(FILE *fp)
Close an input/output file returned by G_open_option_file(). If the file pointer is stdin,...
char * G_recreate_command(void)
Creates command to run non-interactive.
struct Option * G_define_option(void)
Initializes an Option struct.
void G_disable_interactive(void)
Disables the ability of the parser to operate interactively.
char * G_recreate_command_original_path(void)
Creates command to run non-interactive.
void G__print_keywords(FILE *fd, void(*format)(FILE *, const char *))
Print list of keywords (internal use only)
void G__split_gisprompt(const char *gisprompt, char *age, char *element, char *desc)
void G__check_option_rules(void)
Check for option rules (internal use only)
int G__has_required_rule(void)
Checks if there is any rule RULE_REQUIRED (internal use only).
void G_usage(void)
Command line help/usage message.
void G__usage_html(void)
Print module usage description in HTML format.
void G__usage_xml(void)
Print module usage description in XML format.
char * G__json(void)
This function generates actinia JSON process chain building blocks from the command line arguments th...
void G__usage_rest(void)
Print module usage description in reStructuredText format.
void G__script(void)
Generate Python script-like output.
void G__wps_print_process_description(void)
Print the WPS 1.0.0 process description XML document to stdout.
int G_is_dirsep(char c)
Checks if a specified character is a valid directory separator character on the host system.
const char * G_program_name(void)
Return module name.
const char * G_original_program_name(void)
Return original path of the executed program.
int G_snprintf(char *str, size_t size, const char *fmt,...)
snprintf() clone.
int G_spawn(const char *command,...)
Spawn new process based on command.
char * G_chop(char *line)
Chop leading and trailing white spaces.
int G_strcasecmp(const char *x, const char *y)
String compare ignoring case (upper or lower)
char * G_store(const char *s)
Copy string to allocated memory.
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)
void G_free_tokens(char **tokens)
Free memory allocated to tokens.
char ** G_tokenize(const char *buf, const char *delim)
Tokenize string.
int G_number_of_tokens(char **tokens)
Return number of tokens.
int G_verbose_max(void)
Get max verbosity level.
int G_verbose(void)
Get current verbosity level.
int G_verbose_min(void)
Get min verbosity level.
int G_verbose_std(void)
Get standard verbosity level.
void G_zero(void *buf, int i)
Zero out a buffer, buf, of length i.