MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / parse

Function parse

src/batch.c:272–453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270}
271
272static int parse (struct GMT_CTRL *GMT, struct BATCH_CTRL *Ctrl, struct GMT_OPTION *options) {
273
274 /* This parses the options provided to batch and sets parameters in CTRL.
275 * Any GMT common options will override values set previously by other commands.
276 */
277
278 unsigned int n_errors = 0, k, pos;
279 char p[GMT_LEN256] = {""}, *c = NULL;
280 struct GMT_OPTION *opt = NULL;
281 struct GMTAPI_CTRL *API = GMT->parent;
282
283 for (opt = options; opt; opt = opt->next) {
284 switch (opt->option) {
285
286 case '<': /* Input file */
287 n_errors += gmt_M_repeated_module_option (API, Ctrl->In.active);
288 n_errors += gmt_get_required_file (GMT, opt->arg, opt->option, 0, GMT_IS_DATASET, GMT_IN, GMT_FILE_REMOTE, &(Ctrl->In.file));
289 break;
290
291 case 'D': /* Turn off moving products up to top dir */
292 n_errors += gmt_M_repeated_module_option (API, Ctrl->D.active);
293 break;
294
295 case 'F': /* Product name template */
296 n_errors += gmt_M_repeated_module_option (API, Ctrl->F.active);
297 n_errors += gmt_get_required_string (GMT, opt->arg, opt->option, 0, &Ctrl->F.template);
298 break;
299
300 case 'I': /* Include file with settings used by all scripts */
301 n_errors += gmt_M_repeated_module_option (API, Ctrl->I.active);
302 n_errors += gmt_get_required_file (GMT, opt->arg, opt->option, 0, GMT_IS_DATASET, GMT_IN, GMT_FILE_REMOTE, &(Ctrl->I.file));
303 break;
304
305 case 'M': /* Create a single job as well as batch (unless -Q is active) */
306 n_errors += gmt_M_repeated_module_option (API, Ctrl->M.active);
307 if (opt->arg[0]) /* Gave a job number [0] */
308 Ctrl->M.job = atoi (opt->arg);
309 break;
310
311 case 'N': /* Batch job prefix and directory name */
312 n_errors += gmt_M_repeated_module_option (API, Ctrl->N.active);
313 n_errors += gmt_get_required_string (GMT, opt->arg, opt->option, 0, &Ctrl->N.prefix);
314 break;
315
316 case 'Q': /* Debug - leave temp files and directories behind; Use -Qs to only write scripts */
317 n_errors += gmt_M_repeated_module_option (API, Ctrl->Q.active);
318 if (opt->arg[0] == 's') Ctrl->Q.scripts = true;
319 break;
320
321 case 'S': /* postflight and preflight scripts */
322 if (opt->arg[0] == 'b')
323 k = BATCH_PREFLIGHT; /* postflight */
324 else if (opt->arg[0] == 'f')
325 k = BATCH_POSTFLIGHT; /* preflight */
326 else { /* Bad directive */
327 n_errors++;
328 GMT_Report (API, GMT_MSG_ERROR, "Option -S: Select -Sb or -Sf\n");
329 break;

Callers 1

GMT_batchFunction · 0.70

Calls 13

gmt_get_required_fileFunction · 0.85
gmt_get_required_stringFunction · 0.85
GMT_ReportFunction · 0.85
gmt_first_modifierFunction · 0.85
gmt_getmodoptFunction · 0.85
gmt_get_required_uintFunction · 0.85
gmt_get_strwithtabFunction · 0.85
strdupFunction · 0.85
batch_parse_x_optionFunction · 0.85
gmt_default_option_errorFunction · 0.85
gmt_check_languageFunction · 0.85
gmt_script_is_classicFunction · 0.85

Tested by

no test coverage detected