21 #include "parser_local_proto.h" 191 char *file_name =
NULL;
193 int random_int = rand();
201 char desc[KEYLENGTH];
206 fp = fopen(file_name,
"w+");
208 fprintf(stderr,
"Unable to open temporary file <%s>\n", file_name);
215 for (flag = &
st->first_flag; flag; flag = flag->
next_flag) {
225 for (opt = &
st->first_option; opt; opt = opt->
next_opt) {
250 if (
st->n_flags && num_flags > 0) {
254 fprintf(fp,
" \"flags\":\"");
256 for (flag = &
st->first_flag; flag; flag = flag->
next_flag) {
258 fprintf(fp,
"%c", flag->
key);
265 if (
st->n_opts && num_inputs > 0) {
270 fprintf(fp,
" \"inputs\":[\n");
271 for (opt = &
st->first_option; opt; opt = opt->
next_opt) {
278 if (i < num_inputs) {
289 fprintf(fp,
" {\"param\": \"%s\", ", opt->
key);
290 fprintf(fp,
"\"value\": \"%s\"}", opt->
answer);
292 if (i < num_inputs) {
305 if (
st->n_opts && num_outputs > 0) {
310 fprintf(fp,
" \"outputs\":[\n");
311 for (opt = &
st->first_option; opt; opt = opt->
next_opt) {
318 if (i < num_outputs) {
335 fp = fopen(file_name,
"r");
337 fprintf(stderr,
"Unable to open temporary file <%s>\n", file_name);
343 fprintf(stdout,
"%c", c);
361 int i = 0, urlfound = 0;
365 G_debug(2,
"tokenize opt string: <%s> with '@'", opt->
answer);
372 G_fatal_error(
_(
"Input string not understood: <%s>. Multiple '@' chars?"),
377 G_debug(2,
"tokens[1]: <%s>", tokens[1]);
378 if (strncmp(tokens[1],
"http://", 7) == 0 ||
379 strncmp(tokens[1],
"https://", 8) == 0 ||
380 strncmp(tokens[1],
"ftp://", 6) == 0) {
386 G_debug(2,
"name@mapset found");
392 if (i > 1 && urlfound == 1) {
395 "\"import_descr\": {\"source\":\"%s\", \"type\":\"raster\"},\n ",
401 "\"import_descr\": {\"source\":\"%s\", \"type\":\"file\"},\n ",
407 "\"import_descr\": {\"source\":\"%s\", \"type\":\"vector\"},\n ",
413 fprintf(fp,
"\"param\": \"%s\", ", opt->
key);
416 fprintf(fp,
"\"value\": \"%s\"",
420 fprintf(fp,
"\"value\": \"%s\"",
443 int has_file_export = 0;
457 "\"export\": {\"format\":\"%s\", \"type\":\"raster\"},\n ",
462 "\"export\": {\"format\":\"%s\", \"type\":\"file\"},\n ",
468 "\"export\": {\"format\":\"%s\", \"type\":\"vector\"},\n ",
473 fprintf(fp,
"\"param\": \"%s\", ", opt->
key);
474 if (has_file_export == 1) {
475 fprintf(fp,
"\"value\": \"$file::%s\"",
479 fprintf(fp,
"\"value\": \"%s\"",
510 if (always_remove == 1)
int G_strncasecmp(const char *, const char *, int)
String compare ignoring case (upper or lower) - limited number of characters.
const char * G_program_name(void)
Return module name.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
char * G__json(void)
This function generates actinia JSON process chain building blocks from the command line arguments th...
void check_create_import_opts(struct Option *, char *, FILE *)
char ** G_tokenize(const char *, const char *)
Tokenize string.
int int G_strcasecmp(const char *, const char *)
String compare ignoring case (upper or lower)
char * G_tempfile(void)
Returns a temporary file name.
Structure that stores flag info.
char * G_chop(char *)
Chop leading and trailing white spaces.
void G__split_gisprompt(const char *gisprompt, char *age, char *element, char *desc)
const char * G_mapset(void)
Get current mapset name.
void G_free_tokens(char **)
Free memory allocated to tokens.
char * check_mapset_in_layer_name(char *, int)
Structure that stores option information.
int G_debug(int, const char *,...) __attribute__((format(printf
void check_create_export_opts(struct Option *, char *, FILE *)