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

Function batch_set_product_prefix

src/batch.c:184–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184GMT_LOCAL void batch_set_product_prefix (struct GMT_CTRL *GMT, struct GMT_DATASET *D, unsigned int row, unsigned int n_fmts, char *template, char *custom_name) {
185 /* Create the custom product file prefix */
186 struct GMT_DATASEGMENT *S = D->table[0]->segment[0]; /* Current (and only) segment */
187 gmt_M_unused (GMT);
188 if (D->type == GMT_READ_DATA) { /* No trailing text used */
189 switch (n_fmts) { /* May use 1-5 numerical columns */
190 case 1: sprintf (custom_name, template, S->data[0][row]); break;
191 case 2: sprintf (custom_name, template, S->data[0][row], S->data[1][row]); break;
192 case 3: sprintf (custom_name, template, S->data[0][row], S->data[1][row], S->data[2][row]); break;
193 case 4: sprintf (custom_name, template, S->data[0][row], S->data[1][row], S->data[2][row], S->data[3][row]); break;
194 case 5: sprintf (custom_name, template, S->data[0][row], S->data[1][row], S->data[2][row], S->data[3][row], S->data[4][row]); break;
195 default: break; /* We have checked it is no more than 5 */
196 }
197 }
198 else { /* Use the trailing text as well */
199 switch (n_fmts) { /* May use 0-5 numerical columns since trailing text is also used */
200 case 0: sprintf (custom_name, template, S->text[row]); break;
201 case 1: sprintf (custom_name, template, S->data[0][row], S->text[row]); break;
202 case 2: sprintf (custom_name, template, S->data[0][row], S->data[1][row], S->text[row]); break;
203 case 3: sprintf (custom_name, template, S->data[0][row], S->data[1][row], S->data[2][row], S->text[row]); break;
204 case 4: sprintf (custom_name, template, S->data[0][row], S->data[1][row], S->data[2][row], S->data[3][row], S->text[row]); break;
205 case 5: sprintf (custom_name, template, S->data[0][row], S->data[1][row], S->data[2][row], S->data[3][row], S->data[4][row], S->text[row]); break;
206 default: break; /* We have checked it is no more than 5 */
207 }
208 }
209 gmt_strrepc (custom_name, ' ', '_'); /* Replace any spaces with underscores to avoid template disasters */
210 gmt_strrepc (custom_name, '\t', '_'); /* Replace any tabs with underscores to avoid template disasters */
211}
212
213static int usage (struct GMTAPI_CTRL *API, int level) {
214 const char *name = gmt_show_name_and_purpose (API, THIS_MODULE_LIB, THIS_MODULE_CLASSIC_NAME, THIS_MODULE_PURPOSE);

Callers 1

GMT_batchFunction · 0.85

Calls 1

gmt_strrepcFunction · 0.85

Tested by

no test coverage detected