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

Function parse

src/sample1d.c:158–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158static int parse (struct GMT_CTRL *GMT, struct SAMPLE1D_CTRL *Ctrl, struct GMT_OPTION *options) {
159 /* This parses the options provided to sample1d and sets parameters in CTRL.
160 * Any GMT common options will override values set previously by other commands.
161 * It also replaces any file names specified as input or output with the data ID
162 * returned when registering these sources/destinations with the API.
163 */
164
165 unsigned int n_errors = 0;
166 int col;
167 bool old_syntax = false;
168 char string[GMT_LEN64] = {""};
169 char *i_arg = NULL, *s_arg = NULL, *t_arg = NULL, *f = NULL;
170 struct GMT_OPTION *opt = NULL;
171 struct GMTAPI_CTRL *API = GMT->parent;
172
173 /* Determine if we are using GMT 6 syntax with -T<tmin/tmax/tinc>[+a|n] vs old ways of using -N -I -S -T<col> */
174
175 for (opt = options; opt; opt = opt->next) {
176 switch (opt->option) {
177
178 case 'I': /* Always indicative of old option */
179 old_syntax = true;
180 break;
181 case 'N': /* Indicative of old option if a valid file is appended */
182 if (!gmt_access (GMT, opt->arg, F_OK))
183 old_syntax = true;
184 break;
185 case 'S': /* Always indicative of old option */
186 old_syntax = true;
187 break;
188 default:
189 break;
190 }
191 }
192
193 for (opt = options; opt; opt = opt->next) {
194 switch (opt->option) {
195
196 case '<': /* Skip input files */
197 if (GMT_Get_FilePath (API, GMT_IS_DATASET, GMT_IN, GMT_FILE_REMOTE, &(opt->arg))) n_errors++;
198 break;
199 case '>': /* Got named output file */
200 n_errors += gmt_M_repeated_module_option (API, Ctrl->Out.active);
201 n_errors += gmt_get_required_file (GMT, opt->arg, opt->option, 0, GMT_IS_DATASET, GMT_OUT, GMT_FILE_LOCAL, &(Ctrl->Out.file));
202 break;
203
204 /* Processes program-specific parameters */
205
206 case 'A': /* Change track resampling mode */
207 n_errors += gmt_M_repeated_module_option (API, Ctrl->A.active);
208 if (opt->arg[0] != '+') { /* Gave a mode */
209 switch (opt->arg[0]) {
210 case 'f': Ctrl->A.mode = GMT_TRACK_FILL; break;
211 case 'm': Ctrl->A.mode = GMT_TRACK_FILL_M; break;
212 case 'p': Ctrl->A.mode = GMT_TRACK_FILL_P; break;
213 case 'r': Ctrl->A.mode = GMT_TRACK_SAMPLE_FIX; break;
214 case 'R': Ctrl->A.mode = GMT_TRACK_SAMPLE_ADJ; break;
215 default: GMT_Report (API, GMT_MSG_ERROR, "Option -A: Bad modifier %c\n", opt->arg[0]); n_errors++; break;

Callers 1

GMT_sample1dFunction · 0.70

Calls 12

gmt_accessFunction · 0.85
GMT_Get_FilePathFunction · 0.85
gmt_get_required_fileFunction · 0.85
GMT_ReportFunction · 0.85
strdupFunction · 0.85
gmt_strrstrFunction · 0.85
gmt_get_no_argumentFunction · 0.85
gmt_parse_interpolantFunction · 0.85
gmt_default_option_errorFunction · 0.85
gmt_parse_arrayFunction · 0.85
gmt_check_binary_ioFunction · 0.85

Tested by

no test coverage detected