21 #include "parser_local_proto.h" 192 char *file_name =
NULL;
194 int random_int = rand();
202 char desc[KEYLENGTH];
207 fp = fopen(file_name,
"w+");
209 fprintf(stderr,
"Unable to open temporary file <%s>\n", file_name);
216 for (flag = &
st->first_flag; flag; flag = flag->
next_flag) {
226 for (opt = &
st->first_option; opt; opt = opt->
next_opt) {
251 if (
st->n_flags && num_flags > 0) {
255 fprintf(fp,
" \"flags\":\"");
257 for (flag = &
st->first_flag; flag; flag = flag->
next_flag) {
259 fprintf(fp,
"%c", flag->
key);
266 if (
st->n_opts && num_inputs > 0) {
271 fprintf(fp,
" \"inputs\":[\n");
272 for (opt = &
st->first_option; opt; opt = opt->
next_opt) {
279 if (i < num_inputs) {
290 fprintf(fp,
" {\"param\": \"%s\", ", opt->
key);
291 fprintf(fp,
"\"value\": \"%s\"}", opt->
answer);
293 if (i < num_inputs) {
306 if (
st->n_opts && num_outputs > 0) {
311 fprintf(fp,
" \"outputs\":[\n");
312 for (opt = &
st->first_option; opt; opt = opt->
next_opt) {
319 if (i < num_outputs) {
336 fp = fopen(file_name,
"r");
338 fprintf(stderr,
"Unable to open temporary file <%s>\n", file_name);
344 fprintf(stdout,
"%c", c);
362 int i = 0, urlfound = 0;
366 G_debug(2,
"tokenize opt string: <%s> with '@'", opt->
answer);
373 G_fatal_error(
_(
"Input string not understood: <%s>. Multiple '@' chars?"),
378 G_debug(2,
"tokens[1]: <%s>", tokens[1]);
379 if (strncmp(tokens[1],
"http://", 7) == 0 ||
380 strncmp(tokens[1],
"https://", 8) == 0 ||
381 strncmp(tokens[1],
"ftp://", 6) == 0) {
387 G_debug(2,
"name@mapset found");
393 if (i > 1 && urlfound == 1) {
396 "\"import_descr\": {\"source\":\"%s\", \"type\":\"raster\"},\n ",
402 "\"import_descr\": {\"source\":\"%s\", \"type\":\"file\"},\n ",
408 "\"import_descr\": {\"source\":\"%s\", \"type\":\"vector\"},\n ",
414 fprintf(fp,
"\"param\": \"%s\", ", opt->
key);
417 fprintf(fp,
"\"value\": \"%s\"",
421 fprintf(fp,
"\"value\": \"%s\"",
444 int has_file_export = 0;
458 "\"export\": {\"format\":\"%s\", \"type\":\"raster\"},\n ",
463 "\"export\": {\"format\":\"%s\", \"type\":\"file\"},\n ",
469 "\"export\": {\"format\":\"%s\", \"type\":\"vector\"},\n ",
474 fprintf(fp,
"\"param\": \"%s\", ", opt->
key);
475 if (has_file_export == 1) {
476 fprintf(fp,
"\"value\": \"$file::%s\"",
480 fprintf(fp,
"\"value\": \"%s\"",
511 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 *)