GRASS GIS 7 Programmer's Manual
7.8.3(2020)-exported
|
Go to the documentation of this file.
17 #include <grass/gis.h>
19 #include "parser_local_proto.h"
189 char *file_name =
NULL;
191 int random_int = rand();
199 char desc[KEYLENGTH];
204 fp = fopen(file_name,
"w+");
207 fprintf(stderr,
"Unable to open temporary file <%s>\n", file_name);
213 for (flag = &
st->first_flag; flag; flag = flag->next_flag) {
222 for (opt = &
st->first_option; opt; opt = opt->next_opt) {
224 if (opt->gisprompt) {
246 if (
st->n_flags && num_flags > 0) {
249 fprintf(fp,
" \"flags\":\"");
251 for (flag = &
st->first_flag; flag; flag = flag->next_flag) {
253 fprintf(fp,
"%c", flag->key);
260 if (
st->n_opts && num_inputs > 0) {
264 fprintf(fp,
" \"inputs\":[\n");
265 for (opt = &
st->first_option; opt; opt = opt->next_opt) {
266 if (opt->gisprompt) {
272 if (i < num_inputs) {fprintf(fp,
",\n");}
273 else {fprintf(fp,
"\n");}
276 }
else if (opt->answer) {
278 fprintf(fp,
" {\"param\": \"%s\", ", opt->key);
279 fprintf(fp,
"\"value\": \"%s\"}", opt->answer);
281 if (i < num_inputs) {fprintf(fp,
",\n");}
282 else {fprintf(fp,
"\n");}
290 if (
st->n_opts && num_outputs > 0) {
294 fprintf(fp,
" \"outputs\":[\n");
295 for (opt = &
st->first_option; opt; opt = opt->next_opt) {
296 if (opt->gisprompt) {
302 if (i < num_outputs) {fprintf(fp,
",\n");}
303 else {fprintf(fp,
"\n");}
315 fp = fopen(file_name,
"r");
318 fprintf(stderr,
"Unable to open temporary file <%s>\n", file_name);
325 fprintf (stdout,
"%c", c);
357 fprintf(fp,
"\"import_descr\": {\"source\":\"%s\", \"type\":\"raster\"},\n ", tokens[1]);
361 fprintf(fp,
"\"import_descr\": {\"source\":\"%s\", \"type\":\"file\"},\n ", tokens[1]);
365 fprintf(fp,
"\"import_descr\": {\"source\":\"%s\", \"type\":\"vector\"},\n ", tokens[1]);
370 fprintf(fp,
"\"param\": \"%s\", ", opt->key);
393 int has_file_export = 0;
406 fprintf(fp,
"\"export\": {\"format\":\"%s\", \"type\":\"raster\"},\n ", tokens[1]);
409 fprintf(fp,
"\"export\": {\"format\":\"%s\", \"type\":\"file\"},\n ", tokens[1]);
413 fprintf(fp,
"\"export\": {\"format\":\"%s\", \"type\":\"vector\"},\n ", tokens[1]);
417 fprintf(fp,
"\"param\": \"%s\", ", opt->key);
418 if (has_file_export == 1) {
451 if (always_remove == 1)
const char * G_program_name(void)
Return module name.
int G_strcasecmp(const char *x, const char *y)
String compare ignoring case (upper or lower)
int G_strncasecmp(const char *x, const char *y, int n)
String compare ignoring case (upper or lower) - limited number of characters.
char * G_chop(char *line)
Chop leading and trailing white spaces.
const char * G_mapset(void)
Get current mapset name.
char * G__json(void)
This function generates actinia JSON process chain building blocks from the command line arguments th...
void G__split_gisprompt(const char *gisprompt, char *age, char *element, char *desc)
char * check_mapset_in_layer_name(char *, int)
void check_create_import_opts(struct Option *, char *, FILE *)
void check_create_export_opts(struct Option *, char *, FILE *)
void G_free_tokens(char **tokens)
Free memory allocated to tokens.
char * G_tempfile(void)
Returns a temporary file name.
char ** G_tokenize(const char *buf, const char *delim)
Tokenize string.