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

Function parse

src/psscale.c:261–649  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259}
260
261static int parse (struct GMT_CTRL *GMT, struct PSSCALE_CTRL *Ctrl, struct GMT_OPTION *options) {
262 /* This parses the options provided to psscale and sets parameters in Ctrl.
263 * Note Ctrl has already been initialized and non-zero default values set.
264 * Any GMT common options will override values set previously by other commands.
265 * It also replaces any file names specified as input or output with the data ID
266 * returned when registering these sources/destinations with the API.
267 */
268
269 unsigned int n_errors = 0, n_files = 0;
270 int n, j;
271 bool auto_m = false;
272 char string[GMT_LEN256] = {""}, txt_a[GMT_LEN256] = {""}, txt_b[GMT_LEN256] = {""}, *c = NULL;
273 char txt_c[GMT_LEN256] = {""}, txt_d[GMT_LEN256] = {""}, txt_e[GMT_LEN256] = {""};
274 struct GMT_OPTION *opt = NULL;
275 struct GMTAPI_CTRL *API = GMT->parent;
276
277 for (opt = options; opt; opt = opt->next) { /* Process all the options given */
278
279 switch (opt->option) {
280
281 case '<': /* Input files (should be 0) */
282 n_files++;
283 break;
284
285 /* Processes program-specific parameters */
286
287 case 'A':
288 GMT_Report (API, GMT_MSG_COMPAT, "-A option is deprecated; use -D modifier +m instead.\n");
289 Ctrl->D.move = true;
290 if (!opt->arg[0]) Ctrl->D.mmode = (PSSCALE_FLIP_ANNOT+PSSCALE_FLIP_LABEL); /* Default is +mal */
291 for (j = 0; opt->arg[j]; j++) {
292 switch (opt->arg[j]) {
293 case 'a': Ctrl->D.mmode |= PSSCALE_FLIP_ANNOT; break;
294 case 'l': Ctrl->D.mmode |= PSSCALE_FLIP_LABEL; break;
295 case 'c': Ctrl->D.mmode |= PSSCALE_FLIP_VERT; break;
296 case 'u': Ctrl->D.mmode |= PSSCALE_FLIP_UNIT; break;
297 }
298 }
299 break;
300 case 'C':
301 n_errors += gmt_M_repeated_module_option (API, Ctrl->C.active);
302 gmt_M_str_free (Ctrl->C.file);
303 if (opt->arg[0]) Ctrl->C.file = strdup (opt->arg);
304 break;
305 case 'D':
306 n_errors += gmt_M_repeated_module_option (API, Ctrl->D.active);
307 if (opt->arg[0] == '+' && (gmt_found_modifier (GMT, opt->arg, "en")) && strstr (opt->arg, "w") == NULL) {
308 /* Only want +e or +n to be added to defaults */
309 sprintf (string, "%s%s", Ctrl->D.opt, opt->arg);
310 gmt_M_str_free (Ctrl->D.opt);
311 Ctrl->D.opt = strdup (string);
312 }
313 else if (opt->arg[0]) {
314 gmt_M_str_free (Ctrl->D.opt);
315 Ctrl->D.opt = strdup (opt->arg);
316 }
317 break;
318 case 'E':

Callers 1

GMT_psscaleFunction · 0.70

Calls 15

GMT_ReportFunction · 0.85
strdupFunction · 0.85
gmt_found_modifierFunction · 0.85
gmt_default_option_errorFunction · 0.85
gmt_getpanelFunction · 0.85
gmt_mappanel_syntaxFunction · 0.85
gmt_get_no_argumentFunction · 0.85
gmt_first_modifierFunction · 0.85
gmt_getmodoptFunction · 0.85
gmt_strtokFunction · 0.85
gmt_get_required_fileFunction · 0.85
gmt_get_required_doubleFunction · 0.85

Tested by

no test coverage detected