| 213 | } |
| 214 | |
| 215 | static int parse (struct GMT_CTRL *GMT, struct GRD2CPT_CTRL *Ctrl, struct GMT_OPTION *options) { |
| 216 | /* This parses the options provided to grdcut and sets parameters in CTRL. |
| 217 | * Any GMT common options will override values set previously by other commands. |
| 218 | * It also replaces any file names specified as input or output with the data ID |
| 219 | * returned when registering these sources/destinations with the API. |
| 220 | */ |
| 221 | |
| 222 | int n; |
| 223 | unsigned int n_errors = 0, pos = 0, n_files = 0; |
| 224 | char txt_a[GMT_LEN512] = {""}, txt_b[GMT_LEN32] = {""}, *c = NULL; |
| 225 | char *T_arg = NULL, *S_arg = NULL; |
| 226 | struct GMT_OPTION *opt = NULL; |
| 227 | struct GMTAPI_CTRL *API = GMT->parent; |
| 228 | |
| 229 | for (opt = options; opt; opt = opt->next) { |
| 230 | switch (opt->option) { |
| 231 | |
| 232 | case '<': /* Input files (repeatable - check if they exist) */ |
| 233 | Ctrl->In.active = true; |
| 234 | n_files++; |
| 235 | if (GMT_Get_FilePath (API, GMT_IS_GRID, GMT_IN, GMT_FILE_REMOTE, &(opt->arg))) n_errors++; |
| 236 | break; |
| 237 | case '>': /* Got named output file */ |
| 238 | n_errors += gmt_M_repeated_module_option (API, Ctrl->Out.active); |
| 239 | n_errors += gmt_get_required_file (GMT, opt->arg, opt->option, 0, GMT_IS_DATASET, GMT_OUT, GMT_FILE_LOCAL, &(Ctrl->Out.file)); |
| 240 | break; |
| 241 | |
| 242 | /* Processes program-specific parameters */ |
| 243 | |
| 244 | case 'A': /* Sets transparency [-A<transp>[+a]] */ |
| 245 | n_errors += gmt_M_repeated_module_option (API, Ctrl->A.active); |
| 246 | if (opt->arg[0] == '+') { /* Old syntax */ |
| 247 | Ctrl->A.mode = 1; |
| 248 | Ctrl->A.value = 0.01 * atof (&opt->arg[1]); |
| 249 | } |
| 250 | else if ((c = strstr (opt->arg, "+a"))) { |
| 251 | Ctrl->A.mode = 1; |
| 252 | c[0] = '\0'; |
| 253 | Ctrl->A.value = 0.01 * atof (opt->arg); |
| 254 | c[0] = '+'; |
| 255 | } |
| 256 | else |
| 257 | Ctrl->A.value = 0.01 * atof (opt->arg); |
| 258 | break; |
| 259 | case 'C': /* Get CPT */ |
| 260 | n_errors += gmt_M_repeated_module_option (API, Ctrl->C.active); |
| 261 | if (opt->arg[0]) Ctrl->C.file = strdup (opt->arg); |
| 262 | break; |
| 263 | case 'D': /* Set fore/back-ground to match end-colors */ |
| 264 | n_errors += gmt_M_repeated_module_option (API, Ctrl->D.active); |
| 265 | Ctrl->D.mode = 1; |
| 266 | if (opt->arg[0] == 'i') Ctrl->D.mode = 2; |
| 267 | break; |
| 268 | case 'E': /* Use n levels */ |
| 269 | n_errors += gmt_M_repeated_module_option (API, Ctrl->E.active); |
| 270 | if (opt->arg[0]) { /* Got an argument */ |
| 271 | if (gmt_validate_modifiers (GMT, opt->arg, 'E', "cf", GMT_MSG_ERROR)) n_errors++; |
| 272 | if ((c = gmt_first_modifier (GMT, opt->arg, "cf")) ) { |
no test coverage detected