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

Function parse

src/pshistogram.c:640–882  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

638}
639
640static int parse (struct GMT_CTRL *GMT, struct PSHISTOGRAM_CTRL *Ctrl, struct GMT_OPTION *options) {
641 /* This parses the options provided to pshistogram and sets parameters in Ctrl.
642 * Note Ctrl has already been initialized and non-zero default values set.
643 * Any GMT common options will override values set previously by other commands.
644 * It also replaces any file names specified as input or output with the data ID
645 * returned when registering these sources/destinations with the API.
646 */
647
648 unsigned int n_errors = 0, mode = 0, pos = 0;
649 int sval;
650 size_t L;
651 char *c = NULL, *l_arg = NULL, *t_arg = NULL, *w_arg = NULL, p[GMT_BUFSIZ] = {""};
652 struct GMT_OPTION *opt = NULL;
653 struct GMTAPI_CTRL *API = GMT->parent;
654
655 for (opt = options; opt; opt = opt->next) { /* Process all the options given */
656
657 switch (opt->option) {
658
659 case '<': /* Skip input files after checking they exist */
660 if (GMT_Get_FilePath (API, GMT_IS_DATASET, GMT_IN, GMT_FILE_REMOTE, &(opt->arg))) n_errors++;
661 break;
662 case '>': /* Got named output file */
663 n_errors += gmt_M_repeated_module_option (API, Ctrl->Out.active);
664 n_errors += gmt_get_required_file (GMT, opt->arg, opt->option, 0, GMT_IS_DATASET, GMT_OUT, GMT_FILE_LOCAL, &(Ctrl->Out.file));
665 break;
666
667 /* Processes program-specific parameters */
668
669 case 'A':
670 n_errors += gmt_M_repeated_module_option (API, Ctrl->A.active);
671 n_errors += gmt_get_no_argument (GMT, opt->arg, opt->option, 0);
672 break;
673 case 'C':
674 n_errors += gmt_M_repeated_module_option (API, Ctrl->C.active);
675 if (opt->arg[0] && (c = strstr (opt->arg, "+b"))) {
676 Ctrl->C.binval = true;
677 c[0] = '\0'; /* Remove modifier */
678 }
679 gmt_M_str_free (Ctrl->C.file);
680 if (opt->arg[0]) Ctrl->C.file = strdup (opt->arg);
681 if (c) c[0] = '+'; /* Restore modifier */
682 break;
683 case 'D':
684 n_errors += gmt_M_repeated_module_option (API, Ctrl->D.active);
685 while (gmt_getmodopt (GMT, 'D', opt->arg, "bfor", &pos, p, &n_errors) && n_errors == 0) { /* Looking for +b, +f, +o, +r */
686 switch (p[0]) {
687 case 'b': /* beneath */
688 Ctrl->D.just = 1;
689 break;
690 case 'o': /* offset */
691 Ctrl->D.offset = gmt_M_to_inch (GMT, &p[1]);
692 break;
693 case 'f': /* offset */
694 n_errors += gmt_getfont (GMT, &p[1], &(Ctrl->D.font));
695 break;
696 case 'r': /* rotate */
697 Ctrl->D.mode = 1;

Callers 1

GMT_pshistogramFunction · 0.70

Calls 15

GMT_Get_FilePathFunction · 0.85
gmt_get_required_fileFunction · 0.85
gmt_get_no_argumentFunction · 0.85
strdupFunction · 0.85
gmt_getmodoptFunction · 0.85
gmt_getfontFunction · 0.85
gmt_getfillFunction · 0.85
gmt_fill_syntaxFunction · 0.85
GMT_ReportFunction · 0.85
gmt_getpenFunction · 0.85
gmt_pen_syntaxFunction · 0.85
gmt_default_option_errorFunction · 0.85

Tested by

no test coverage detected