21 #include "parser_local_proto.h"
195 char *file_name =
NULL;
197 int random_int = rand();
205 char desc[KEYLENGTH];
210 fp = fopen(file_name,
"w+");
212 fprintf(stderr,
"Unable to open temporary file <%s>\n", file_name);
219 for (flag = &
st->first_flag; flag; flag = flag->
next_flag) {
230 for (opt = &
st->first_option; opt; opt = opt->
next_opt) {
256 if (
st->n_flags && num_flags > 0) {
260 fprintf(fp,
" \"flags\":\"");
262 for (flag = &
st->first_flag; flag; flag = flag->
next_flag) {
264 fprintf(fp,
"%c", flag->
key);
271 if (
st->n_opts && num_inputs > 0) {
276 fprintf(fp,
" \"inputs\":[\n");
277 for (opt = &
st->first_option; opt; opt = opt->
next_opt) {
284 if (i < num_inputs) {
295 fprintf(fp,
" {\"param\": \"%s\", ", opt->
key);
296 fprintf(fp,
"\"value\": \"%s\"}", opt->
answer);
298 if (i < num_inputs) {
311 if (
st->n_opts && num_outputs > 0) {
316 fprintf(fp,
" \"outputs\":[\n");
317 for (opt = &
st->first_option; opt; opt = opt->
next_opt) {
324 if (i < num_outputs) {
341 fp = fopen(file_name,
"r");
343 fprintf(stderr,
"Unable to open temporary file <%s>\n", file_name);
349 fprintf(stdout,
"%c", c);
366 int i = 0, urlfound = 0;
370 G_debug(2,
"tokenize opt string: <%s> with '@'", opt->
answer);
378 _(
"Input string not understood: <%s>. Multiple '@' chars?"),
383 G_debug(2,
"tokens[1]: <%s>", tokens[1]);
384 if (strncmp(tokens[1],
"http://", 7) == 0 ||
385 strncmp(tokens[1],
"https://", 8) == 0 ||
386 strncmp(tokens[1],
"ftp://", 6) == 0) {
392 G_debug(2,
"name@mapset found");
398 if (i > 1 && urlfound == 1) {
401 "\"import_descr\": {\"source\":\"%s\", "
402 "\"type\":\"raster\"},\n ",
408 "\"import_descr\": {\"source\":\"%s\", "
409 "\"type\":\"file\"},\n ",
415 "\"import_descr\": {\"source\":\"%s\", "
416 "\"type\":\"vector\"},\n ",
422 fprintf(fp,
"\"param\": \"%s\", ", opt->
key);
425 fprintf(fp,
"\"value\": \"%s\"",
429 fprintf(fp,
"\"value\": \"%s\"",
452 int has_file_export = 0;
467 "\"export\": {\"format\":\"%s\", \"type\":\"raster\"},\n ",
473 "\"export\": {\"format\":\"%s\", \"type\":\"file\"},\n ",
480 "\"export\": {\"format\":\"%s\", \"type\":\"vector\"},\n ",
485 fprintf(fp,
"\"param\": \"%s\", ", opt->
key);
486 if (has_file_export == 1) {
487 fprintf(fp,
"\"value\": \"$file::%s\"",
491 fprintf(fp,
"\"value\": \"%s\"",
522 if (always_remove == 1)
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
char * G_tempfile(void)
Returns a temporary file name.
const char * G_mapset(void)
Get current mapset name.
void G_free_tokens(char **)
Free memory allocated to tokens.
int int G_strcasecmp(const char *, const char *)
String compare ignoring case (upper or lower)
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.
char * G_chop(char *)
Chop leading and trailing white spaces.
int G_debug(int, const char *,...) __attribute__((format(printf
char ** G_tokenize(const char *, const char *)
Tokenize string.
void G__split_gisprompt(const char *gisprompt, char *age, char *element, char *desc)
void check_create_import_opts(struct Option *, char *, FILE *)
void check_create_export_opts(struct Option *, char *, FILE *)
char * G__json(void)
This function generates actinia JSON process chain building blocks from the command line arguments th...
char * check_mapset_in_layer_name(char *, int)
Structure that stores flag info.
Structure that stores option information.