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

Function parse

src/pssolar.c:161–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161static int parse (struct GMT_CTRL *GMT, struct PSSOLAR_CTRL *Ctrl, struct GMT_OPTION *options) {
162 /* This parses the options provided to pssolar and sets parameters in Ctrl.
163 * Note Ctrl has already been initialized and non-zero default values set.
164 * Any GMT common options will override values set previously by other commands.
165 */
166
167 int j, TZ = 0, n_files = 0, n_errors = 0;
168 char *pch = NULL, *date = NULL;
169 double t;
170 struct GMT_OPTION *opt = NULL;
171 struct GMTAPI_CTRL *API = GMT->parent;
172
173 for (opt = options; opt; opt = opt->next) { /* Process all the options given */
174
175 switch (opt->option) {
176
177 case '<': /* Input files */
178 n_files++;
179 break;
180
181 /* Processes program-specific parameters */
182
183 case 'C': /* Format -I output as a vector. No text. */
184 n_errors += gmt_M_repeated_module_option (API, Ctrl->C.active);
185 n_errors += gmt_get_no_argument (GMT, opt->arg, opt->option, 0);
186 break;
187 case 'G': /* Set fill for symbols or polygon */
188 n_errors += gmt_M_repeated_module_option (API, Ctrl->G.active);
189 if (opt->arg[0] == '\0' || (opt->arg[0] == 'c' && !opt->arg[1]))
190 Ctrl->G.clip = true;
191 else if (gmt_getfill (GMT, opt->arg, &Ctrl->G.fill)) {
192 gmt_fill_syntax (GMT, 'G', NULL, " ");
193 n_errors++;
194 }
195 break;
196 case 'I': /* Infos -I[<lon>/<lat>][+d<date>][+z<TZ>] */
197 n_errors += gmt_M_repeated_module_option (API, Ctrl->I.active);
198 if (opt->arg[0]) { /* Also gave location */
199 Ctrl->I.position = true;
200 if (opt->arg[0] != '+') { /* Then it must be a location */
201 n_errors += gmt_M_check_condition (GMT, sscanf (opt->arg, "%lf/%lf", &Ctrl->I.lon, &Ctrl->I.lat) != 2,
202 "Expected -I[<lon>/<lat>]\n");
203 }
204 if ((pch = strchr(opt->arg, '+')) != NULL) { /* Have one or two extra options */
205 pssolar_parse_date_tz(pch, &date, &TZ);
206 Ctrl->I.TZ = TZ;
207 if (date) {
208 gmt_scanf_arg (GMT, date, GMT_IS_ABSTIME, false, &t);
209 gmt_gcal_from_dt (GMT, t, &Ctrl->I.calendar); /* Convert t to a complete calendar structure */
210 gmt_M_str_free (date);
211 }
212 }
213 }
214 break;
215 case 'M':
216 n_errors += gmt_M_repeated_module_option (API, Ctrl->M.active);
217 n_errors += gmt_get_no_argument (GMT, opt->arg, opt->option, 0);
218 break;

Callers 1

GMT_pssolarFunction · 0.70

Calls 11

gmt_get_no_argumentFunction · 0.85
gmt_getfillFunction · 0.85
gmt_fill_syntaxFunction · 0.85
pssolar_parse_date_tzFunction · 0.85
gmt_scanf_argFunction · 0.85
gmt_gcal_from_dtFunction · 0.85
gmt_getpenFunction · 0.85
gmt_pen_syntaxFunction · 0.85
gmt_default_option_errorFunction · 0.85
GMT_ReportFunction · 0.85
gmt_parse_common_optionsFunction · 0.85

Tested by

no test coverage detected