| 240 | } |
| 241 | |
| 242 | static int parse (struct GMT_CTRL *GMT, struct GMTLOGO_CTRL *Ctrl, struct GMT_OPTION *options) { |
| 243 | /* This parses the options provided to gmtlogo and sets parameters in Ctrl. |
| 244 | * Note Ctrl has already been initialized and non-zero default values set. |
| 245 | * Any GMT common options will override values set previously by other commands. |
| 246 | * It also replaces any file names specified as input or output with the data ID |
| 247 | * returned when registering these sources/destinations with the API. |
| 248 | */ |
| 249 | |
| 250 | unsigned int n_errors = 0; |
| 251 | int n; |
| 252 | char string[GMT_LEN256] = {""}; |
| 253 | struct GMT_OPTION *opt = NULL; |
| 254 | struct GMTAPI_CTRL *API = GMT->parent; |
| 255 | |
| 256 | for (opt = options; opt; opt = opt->next) { /* Process all the options given */ |
| 257 | |
| 258 | switch (opt->option) { |
| 259 | |
| 260 | /* Processes program-specific parameters */ |
| 261 | |
| 262 | case 'D': |
| 263 | n_errors += gmt_M_repeated_module_option (API, Ctrl->D.active); |
| 264 | if ((Ctrl->D.refpoint = gmt_get_refpoint (GMT, opt->arg, 'D')) == NULL) |
| 265 | n_errors++; /* Failed basic parsing */ |
| 266 | else { /* args are [+h<height>|w<width>][+j<justify>][+o<dx>[/<dy>]] */ |
| 267 | if (gmt_validate_modifiers (GMT, Ctrl->D.refpoint->args, 'D', "hjow", GMT_MSG_ERROR)) n_errors++; |
| 268 | if (gmt_get_modifier (Ctrl->D.refpoint->args, 'j', string)) |
| 269 | Ctrl->D.justify = gmt_just_decode (GMT, string, PSL_NO_DEF); |
| 270 | else /* With -Dj or -DJ, set default to reference justify point, else BL */ |
| 271 | Ctrl->D.justify = gmt_M_just_default (GMT, Ctrl->D.refpoint, PSL_BL); |
| 272 | if (gmt_get_modifier (Ctrl->D.refpoint->args, 'o', string)) { |
| 273 | if ((n = gmt_get_pair (GMT, string, GMT_PAIR_DIM_DUP, Ctrl->D.off)) < 0) n_errors++; |
| 274 | } |
| 275 | if (gmt_get_modifier (Ctrl->D.refpoint->args, 'h', string)) /* Get logo height */ |
| 276 | Ctrl->D.height = gmt_M_to_inch (GMT, string); |
| 277 | if (gmt_get_modifier (Ctrl->D.refpoint->args, 'w', string)) /* Get logo width */ |
| 278 | Ctrl->D.width = gmt_M_to_inch (GMT, string); |
| 279 | } |
| 280 | break; |
| 281 | case 'F': |
| 282 | n_errors += gmt_M_repeated_module_option (API, Ctrl->F.active); |
| 283 | if (gmt_getpanel (GMT, opt->option, opt->arg, &(Ctrl->F.panel))) { |
| 284 | gmt_mappanel_syntax (GMT, 'F', "Specify a rectangular panel behind the logo.", 0); |
| 285 | n_errors++; |
| 286 | } |
| 287 | break; |
| 288 | case 'S': |
| 289 | n_errors += gmt_M_repeated_module_option (API, Ctrl->S.active); |
| 290 | switch (opt->arg[0]) { |
| 291 | case 'l': Ctrl->S.mode = GMTLOGO_LABEL_NAME; break; /* Label */ |
| 292 | case 'u': Ctrl->S.mode = GMTLOGO_LABEL_URL; break; /* url */ |
| 293 | case 'n': Ctrl->S.mode = GMTLOGO_LABEL_NONE; break; /* no label */ |
| 294 | default: Ctrl->S.mode = GMTLOGO_LABEL_NAME; break; /* Label */ |
| 295 | } |
| 296 | break; |
| 297 | case 'W': /* Scale for the logo */ |
| 298 | GMT_Report (API, GMT_MSG_COMPAT, "Option -W is deprecated; -D...+w%s was set instead, use this in the future.\n", opt->arg); |
| 299 | n_errors += gmt_get_required_double (GMT, opt->arg, opt->option, 0, &Ctrl->D.width); |
no test coverage detected