| 270 | } |
| 271 | |
| 272 | static 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; |
no test coverage detected