SDDSlib
Loading...
Searching...
No Matches
sdds2stream.c
Go to the documentation of this file.
1/**
2 * @file sdds2stream.c
3 * @brief Utility for streaming SDDS data values.
4 *
5 * @details
6 * This program reads an SDDS data set and outputs selected column or parameter values in a delimited format.
7 * Users can specify the columns, parameters, or arrays to stream, as well as other options like page filtering,
8 * row counting, and delimiter customization.
9 *
10 * @features
11 * - Stream data values from specified columns, parameters, or arrays.
12 * - Output is formatted as delimited text, with customizable delimiters.
13 * - Handles multiple input files and multiple data pages.
14 * - Includes options for filtering by page or rows.
15 *
16 * @usage
17 * ```
18 * sdds2stream [-pipe] [<SDDSinput>...]
19 * [-columns=<column-name>[,...]]
20 * [-parameters=<parameter-name>[,...]]
21 * [-arrays=<array-name>[,...]]
22 * [-page=<pageNumber>] [-delimiter=<delimiting-string>]
23 * [-filenames] [-rows[=bare][,total][,scientific]]
24 * [-npages=<bare>] [-noquotes]
25 * [-ignoreFormats] [-description]
26 * ```
27 *
28 * Examples:
29 * ```
30 * sdds2stream -columns=x,y input.sdds
31 * sdds2stream -columns=x,y -delimiter=\\, input.sdds > output.csv
32 * ```
33 *
34 * @copyright
35 * - (c) 2002 The University of Chicago, as Operator of Argonne National Laboratory.
36 * - (c) 2002 The Regents of the University of California, as Operator of Los Alamos National Laboratory.
37 *
38 * @license
39 * This file is distributed under the terms of the Software License Agreement
40 * found in the file LICENSE included with this distribution.
41 *
42 * @author M. Borland, C. Saunders, R. Soliday
43 */
44
45#include "mdb.h"
46#include "SDDS.h"
47#include "scan.h"
48
49#define SET_COLUMNS 0
50#define SET_PARAMETERS 1
51/* the -table option is retained for backward compatibility */
52#define SET_TABLE 2
53#define SET_DELIMITER 3
54#define SET_FILENAMES 4
55#define SET_ROWS 5
56#define SET_NOQUOTES 6
57#define SET_PIPE 7
58#define SET_PAGE 8
59#define SET_ARRAYS 9
60#define SET_IGNOREFORMATS 10
61#define SET_DESCRIPTION 11
62#define SET_SHOW_PAGES 12
63#define N_OPTIONS 13
64
65char *option[N_OPTIONS] =
66 {
67 "columns",
68 "parameters",
69 "table",
70 "delimiter",
71 "filenames",
72 "rows",
73 "noquotes",
74 "pipe",
75 "page",
76 "arrays",
77 "ignoreformats",
78 "description",
79 "npages",
80 };
81
82char *USAGE = "sdds2stream [-pipe] [<SDDSinput>...]\n"
83 " [-columns=<column-name>[,...]]\n"
84 " [-parameters=<parameter-name>[,...]]\n"
85 " [-arrays=<array-name>[,...]]]\n"
86 " [-page=<pageNumber>] [-delimiter=<delimiting-string>]\n"
87 " [-filenames] [-rows[=bare][,total][,scientific]]\n"
88 " [-npages=<bare>] [-noquotes]\n"
89 " [-ignoreFormats] [-description]\n\n"
90 "sdds2stream provides stream output to the standard output of data values from "
91 "a group of columns or parameters. Each line of the output contains a different "
92 "row of the tabular data or a different parameter. Values from different columns "
93 "are separated by the delimiter string, which by default is a single space. "
94 "If -page is not employed, all data pages are output sequentially. "
95 "If multiple filenames are given, the files are processed sequentially in the "
96 "order given.\n\n"
97 "Program by Michael Borland. (" __DATE__ " " __TIME__ ", SVN revision: " SVN_VERSION ")\n";
98
99long SDDS_SprintTypedValue2(char *s, char *format, char *buffer, unsigned long mode);
100
101int main(int argc, char **argv) {
102 SDDS_DATASET SDDS_dataset;
103 long i, k, i_arg, retval, description;
104 int64_t j, rows;
105 SCANNED_ARG *s_arg;
106 char **input;
107 char **column_name, **parameter_name, **array_name;
108 char **parameterFormat, **columnFormat, **arrayFormat;
109 long column_names, parameter_names, array_names, page_number, *type, inputs;
110 char *delimiter;
111 void **data;
112 char *buffer;
113 long filenames, print_rows, print_pages, noQuotes, pipe, ignoreFormats;
114 static char printBuffer[SDDS_MAXLINE * 16];
115 long n_rows_bare, n_rows_total, n_pages, n_pages_bare, n_rows_scinotation;
116 int64_t n_rows;
117
119 argc = scanargs(&s_arg, argc, argv);
120 if (argc < 3)
121 bomb(NULL, USAGE);
122
123 type = NULL;
124 data = NULL;
125 buffer = tmalloc(sizeof(char) * 16); /* large enough for any data type */
126 delimiter = NULL;
127 input = parameter_name = column_name = array_name = NULL;
128 parameterFormat = columnFormat = arrayFormat = NULL;
129 inputs = parameter_names = column_names = array_names = 0;
130 page_number = filenames = ignoreFormats = 0;
131 n_rows = n_rows_bare = n_rows_total = n_pages = n_pages_bare = 0;
132 print_rows = print_pages = noQuotes = pipe = description = 0;
133 n_rows_scinotation = 0;
134
135 /* Parse command-line arguments */
136 for (i_arg = 1; i_arg < argc; i_arg++) {
137 if (s_arg[i_arg].arg_type == OPTION) {
138 int optIndex = match_string(s_arg[i_arg].list[0], option, N_OPTIONS, 0);
139 switch (optIndex) {
140 case SET_COLUMNS:
141 if (s_arg[i_arg].n_items < 2)
142 SDDS_Bomb("invalid -columns syntax");
143 if (column_names)
144 SDDS_Bomb("invalid syntax: specify -columns once only");
145 column_name = tmalloc(sizeof(*column_name) * (s_arg[i_arg].n_items - 1));
146 for (i = 1; i < s_arg[i_arg].n_items; i++)
147 column_name[i - 1] = s_arg[i_arg].list[i];
148 column_names = s_arg[i_arg].n_items - 1;
149 break;
150
151 case SET_PARAMETERS:
152 if (s_arg[i_arg].n_items < 2)
153 SDDS_Bomb("invalid -parameters syntax");
154 if (parameter_names)
155 SDDS_Bomb("invalid syntax: specify -parameters once only");
156 parameter_name = tmalloc(sizeof(*parameter_name) * (s_arg[i_arg].n_items - 1));
157 for (i = 1; i < s_arg[i_arg].n_items; i++)
158 parameter_name[i - 1] = s_arg[i_arg].list[i];
159 parameter_names = s_arg[i_arg].n_items - 1;
160 break;
161
162 case SET_ARRAYS:
163 if (s_arg[i_arg].n_items < 2)
164 SDDS_Bomb("invalid -arrays syntax");
165 if (array_names)
166 SDDS_Bomb("invalid syntax: specify -arrays once only");
167 array_name = tmalloc(sizeof(*array_name) * (s_arg[i_arg].n_items - 1));
168 for (i = 1; i < s_arg[i_arg].n_items; i++)
169 array_name[i - 1] = s_arg[i_arg].list[i];
170 array_names = s_arg[i_arg].n_items - 1;
171 break;
172
173 case SET_TABLE:
174 case SET_PAGE:
175 if (s_arg[i_arg].n_items < 2 || s_arg[i_arg].n_items > 2)
176 SDDS_Bomb("invalid -page syntax");
177 if (page_number != 0)
178 SDDS_Bomb("invalid syntax: specify -page once only");
179 if (sscanf(s_arg[i_arg].list[1], "%ld", &page_number) != 1 || page_number <= 0)
180 SDDS_Bomb("invalid -page syntax or value");
181 break;
182
183 case SET_DELIMITER:
184 if (s_arg[i_arg].n_items < 2)
185 SDDS_Bomb("invalid -delimiter syntax");
186 delimiter = s_arg[i_arg].list[1];
187 break;
188
189 case SET_FILENAMES:
190 filenames = 1;
191 break;
192
193 case SET_ROWS:
194 if (s_arg[i_arg].n_items > 4)
195 SDDS_Bomb("invalid -rows syntax");
196 else {
197 char *rowsOutputMode[3] = {"bare", "total", "scientific"};
198 for (i = 1; i < s_arg[i_arg].n_items; i++) {
199 int rm = match_string(s_arg[i_arg].list[i],
200 rowsOutputMode, 3, 0);
201 if (rm == 0)
202 n_rows_bare = 1;
203 else if (rm == 1)
204 n_rows_total = 1;
205 else if (rm == 2)
206 n_rows_scinotation = 1;
207 else
208 SDDS_Bomb("unknown output mode for -rows option");
209 }
210 }
211 print_rows = 1;
212 break;
213
214 case SET_SHOW_PAGES:
215 if (s_arg[i_arg].n_items > 2)
216 SDDS_Bomb("invalid -pages syntax");
217 else {
218 char *pagesOutputMode[1] = {"bare"};
219 for (i = 1; i < s_arg[i_arg].n_items; i++) {
220 if (strcmp(s_arg[i_arg].list[i], "") != 0) {
221 int pm = match_string(s_arg[i_arg].list[i],
222 pagesOutputMode, 1, 0);
223 if (pm == 0)
224 n_pages_bare = 1;
225 else
226 SDDS_Bomb("unknown output mode for -npages option");
227 } else
228 SDDS_Bomb("unknown output mode for -npages option");
229 }
230 }
231 print_pages = 1;
232 break;
233
234 case SET_NOQUOTES:
235 noQuotes = 1;
236 break;
237
238 case SET_PIPE:
239 pipe = 1;
240 break;
241
242 case SET_IGNOREFORMATS:
243 ignoreFormats = 1;
244 break;
245
246 case SET_DESCRIPTION:
247 description = 1;
248 break;
249
250 default:
251 fprintf(stderr, "error: unknown switch: %s\n",
252 s_arg[i_arg].list[0]);
253 exit(1);
254 break;
255 }
256 } else {
257 input = trealloc(input, sizeof(*input) * (inputs + 1));
258 input[inputs++] = s_arg[i_arg].list[0];
259 }
260 }
261
262 if (!inputs) {
263 if (!pipe)
264 SDDS_Bomb("too few filenames");
265 inputs = 1;
266 input = trealloc(input, sizeof(*input) * (inputs + 1));
267 input[0] = NULL;
268 }
269
270 if (!column_names && !parameter_names && !array_names && !print_rows && !description && !print_pages)
271 SDDS_Bomb("you must specify one of -columns, -parameters, "
272 "-arrays, -rows or -description");
273
274 if (!delimiter) {
275 if (column_names || array_names)
276 cp_str(&delimiter, " ");
277 else
278 cp_str(&delimiter, "\n");
279 }
280
281 SDDS_SetTerminateMode(TERMINATE_DONT_FREE_TABLE_STRINGS + TERMINATE_DONT_FREE_ARRAY_STRINGS);
282
283 /* Process each input file */
284 for (k = 0; k < inputs; k++) {
285 if (!SDDS_InitializeInput(&SDDS_dataset, input[k])) {
286 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
287 exit(1);
288 }
289 n_pages = 0;
290
291 /* Setup columns, parameters, or arrays */
292 if (column_names) {
293 if (k == 0) {
294 type = tmalloc(sizeof(*type) * column_names);
295 data = tmalloc(sizeof(*data) * column_names);
296 columnFormat = tmalloc(sizeof(*columnFormat) * column_names);
297 }
298 for (i = 0; i < column_names; i++) {
299 j = SDDS_GetColumnIndex(&SDDS_dataset, column_name[i]);
300 if (j < 0) {
301 fprintf(stderr, "error: column %s does not exist\n",
302 column_name[i]);
303 exit(1);
304 }
305 type[i] = SDDS_GetColumnType(&SDDS_dataset, j);
306 if (type[i] <= 0 || !SDDS_GetColumnInformation(&SDDS_dataset,
307 "format_string",
308 columnFormat + i,
309 SDDS_GET_BY_INDEX, j)) {
310 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
311 exit(1);
312 }
313 }
314 } else if (array_names) {
315 if (k == 0) {
316 type = tmalloc(sizeof(*type) * array_names);
317 data = tmalloc(sizeof(*data) * array_names);
318 arrayFormat = tmalloc(sizeof(*arrayFormat) * array_names);
319 }
320
321 for (i = 0; i < array_names; i++) {
322 j = SDDS_GetArrayIndex(&SDDS_dataset, array_name[i]);
323 if (j < 0) {
324 fprintf(stderr, "error: array %s does not exist\n",
325 array_name[i]);
326 exit(1);
327 }
328 type[i] = SDDS_GetArrayType(&SDDS_dataset, j);
329 if (type[i] <= 0 || !SDDS_GetArrayInformation(&SDDS_dataset, "format_string",
330 arrayFormat + i,
331 SDDS_BY_INDEX, j)) {
332 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
333 exit(1);
334 }
335 }
336 } else if (parameter_names) {
337 if (k == 0) {
338 type = tmalloc(sizeof(*type) * parameter_names);
339 parameterFormat = tmalloc(sizeof(*parameterFormat) * parameter_names);
340 }
341 for (i = 0; i < parameter_names; i++) {
342 j = SDDS_GetParameterIndex(&SDDS_dataset, parameter_name[i]);
343 if (j < 0) {
344 fprintf(stderr, "error: parameter %s does not exist\n",
345 parameter_name[i]);
346 exit(1);
347 }
348 type[i] = SDDS_GetParameterType(&SDDS_dataset, j);
349 if (type[i] <= 0 || !SDDS_GetParameterInformation(&SDDS_dataset,
350 "format_string",
351 parameterFormat + i,
352 SDDS_BY_INDEX, j)) {
353 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
354 exit(1);
355 }
356 }
357 }
358
359 /* Print description if requested */
360 if (description) {
361 if (!SDDS_SprintTypedValue2(SDDS_dataset.layout.description, NULL,
362 printBuffer,
363 noQuotes ? SDDS_PRINT_NOQUOTES : 0)) {
364 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
365 exit(1);
366 }
367
368 fputs(printBuffer, stdout);
369 fprintf(stdout, "%s", delimiter);
370
371 if (!SDDS_SprintTypedValue2(SDDS_dataset.layout.contents, NULL,
372 printBuffer,
373 noQuotes ? SDDS_PRINT_NOQUOTES : 0)) {
374 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
375 exit(1);
376 }
377 fputs(printBuffer, stdout);
378 fprintf(stdout, "%s", delimiter);
379
380 if (!strchr(delimiter, '\n'))
381 fputc('\n', stdout);
382 }
383
384 retval = -1;
385 while (retval != page_number && (retval = SDDS_ReadPage(&SDDS_dataset)) > 0) {
386 if (page_number && retval != page_number)
387 continue;
388
389 if (print_rows) {
390 uint64_t counti = SDDS_CountRowsOfInterest(&SDDS_dataset);
391 if (n_rows_total && !page_number) {
392 n_rows += counti;
393 } else {
394 if (!n_rows_scinotation || counti == 0) {
395 if (n_rows_bare)
396 fprintf(stdout, "%" PRId64 "\n", (int64_t)counti);
397 else
398 fprintf(stdout, "%" PRId64 " rows\n", (int64_t)counti);
399 } else {
400 char format[20];
401 double count = counti;
402 snprintf(format, 20, "%%.%ldle%s",
403 (long)(log10(count)),
404 n_rows_bare ? "" : " rows");
405 fprintf(stdout, format, count);
406 fputc('\n', stdout);
407 }
408 }
409 }
410
411 if (column_names) {
412 rows = SDDS_CountRowsOfInterest(&SDDS_dataset);
413 if (rows < 0) {
414 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
415 exit(1);
416 }
417 if (rows) {
418 if (filenames) {
419 fprintf(stdout, "%s%s", input[k], delimiter);
420 if (!strchr(delimiter, '\n'))
421 fputc('\n', stdout);
422 }
423 for (i = 0; i < column_names; i++) {
424 data[i] = SDDS_GetInternalColumn(&SDDS_dataset,
425 column_name[i]);
426 if (!data[i]) {
427 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
428 exit(1);
429 }
430 }
431 for (j = 0; j < rows; j++) {
432 for (i = 0; i < column_names; i++) {
433 if (!SDDS_SprintTypedValue(data[i], j, type[i],
434 ignoreFormats ? NULL : columnFormat[i],
435 printBuffer,
436 noQuotes ? SDDS_PRINT_NOQUOTES : 0)) {
437 SDDS_PrintErrors(stderr,
438 SDDS_VERBOSE_PrintErrors);
439 exit(1);
440 }
441 fputs(printBuffer, stdout);
442 if (i != column_names - 1)
443 fprintf(stdout, "%s", delimiter);
444 }
445 fputc('\n', stdout);
446 }
447 }
448 } else if (array_names) {
449 SDDS_ARRAY *array;
450 if (filenames) {
451 fprintf(stdout, "%s%s", input[k], delimiter);
452 if (!strchr(delimiter, '\n'))
453 fputc('\n', stdout);
454 }
455 for (i = 0; i < array_names; i++) {
456 array = SDDS_GetArray(&SDDS_dataset, array_name[i], NULL);
457 if (!array) {
458 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
459 exit(1);
460 }
461 for (j = 0; j < array->elements; j++) {
462 if (!SDDS_SprintTypedValue(array->data, j, type[i],
463 ignoreFormats ? NULL : arrayFormat[i],
464 printBuffer,
465 noQuotes ? SDDS_PRINT_NOQUOTES : 0)) {
466 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
467 exit(1);
468 }
469 fputs(printBuffer, stdout);
470 fprintf(stdout, "%s", delimiter);
471 }
472 }
473 if (!strchr(delimiter, '\n'))
474 fputc('\n', stdout);
475 } else if (parameter_names) {
476 if (filenames)
477 fprintf(stdout, "%s%s", input[k], delimiter);
478 for (i = 0; i < parameter_names; i++) {
479 if (!SDDS_GetParameter(&SDDS_dataset, parameter_name[i],
480 buffer)) {
481 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
482 exit(1);
483 }
484 if (!SDDS_SprintTypedValue(buffer, 0, type[i],
485 ignoreFormats ? NULL : parameterFormat[i],
486 printBuffer,
487 noQuotes ? SDDS_PRINT_NOQUOTES : 0)) {
488 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
489 exit(1);
490 }
491 fputs(printBuffer, stdout);
492 fprintf(stdout, "%s", delimiter);
493 }
494 if (!strchr(delimiter, '\n'))
495 fputc('\n', stdout);
496 }
497
498 n_pages++;
499 }
500
501 if (retval == 0) {
502 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
503 exit(1);
504 } else {
505 if (print_rows && (n_rows_total || (retval == -1 && n_pages == 0)) && !page_number) {
506 if (!n_rows_scinotation || n_rows == 0) {
507 if (n_rows_bare)
508 fprintf(stdout, "%" PRId64 "\n", n_rows);
509 else
510 fprintf(stdout, "%" PRId64 " rows\n", n_rows);
511 } else {
512 char format[20];
513 double count = n_rows;
514 snprintf(format, 20, "%%.%ldle%s",
515 (long)(log10(count)),
516 n_rows_bare ? "" : " rows");
517 fprintf(stdout, format, count);
518 fputc('\n', stdout);
519 }
520 }
521 if (print_pages) {
522 if (n_pages_bare)
523 fprintf(stdout, "%ld\n", n_pages);
524 else
525 fprintf(stdout, "%ld pages\n", n_pages);
526 }
527 }
528 if (!SDDS_Terminate(&SDDS_dataset)) {
529 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
530 exit(1);
531 }
532 }
533 return 0;
534}
535
536long SDDS_SprintTypedValue2(char *s, char *format, char *buffer, unsigned long mode) {
537 char buffer2[SDDS_PRINT_BUFLEN];
538 short printed;
539
540 if (!s)
541 s = "";
542
543 if (!buffer) {
544 SDDS_SetError("Unable to print value--buffer pointer is NULL "
545 "(SDDS_SprintTypedValue2)");
546 return 0;
547 }
548 if ((long)strlen(s) > SDDS_PRINT_BUFLEN - 3) {
549 SDDS_SetError("Buffer size overflow (SDDS_SprintTypedValue2)");
550 return 0;
551 }
552
553 if (!(mode & SDDS_PRINT_NOQUOTES)) {
554 printed = 0;
555 if (!s || SDDS_StringIsBlank(s))
556 sprintf(buffer, "\"\"");
557 else if (strchr(s, '"')) {
558 strcpy(buffer2, s);
559 SDDS_EscapeQuotes(buffer2, '"');
560 if (SDDS_HasWhitespace(buffer2))
561 sprintf(buffer, "\"%s\"", buffer2);
562 else
563 strcpy(buffer, buffer2);
564 } else if (SDDS_HasWhitespace(s))
565 sprintf(buffer, "\"%s\"", s);
566 else {
567 sprintf(buffer, format ? format : "%s", s);
568 printed = 1;
569 }
570 if (!printed) {
571 sprintf(buffer2, format ? format : "%s", buffer);
572 strcpy(buffer, buffer2);
573 }
574 } else {
575 sprintf(buffer, format ? format : "%s", s);
576 }
577 return 1;
578}
SDDS (Self Describing Data Set) Data Types Definitions and Function Prototypes.
int64_t SDDS_CountRowsOfInterest(SDDS_DATASET *SDDS_dataset)
Counts the number of rows marked as "of interest" in the current data table.
SDDS_ARRAY * SDDS_GetArray(SDDS_DATASET *SDDS_dataset, char *array_name, SDDS_ARRAY *memory)
Retrieves an array from the current data table of an SDDS dataset.
void * SDDS_GetInternalColumn(SDDS_DATASET *SDDS_dataset, char *column_name)
Retrieves an internal pointer to the data of a specified column, including all rows.
void * SDDS_GetParameter(SDDS_DATASET *SDDS_dataset, char *parameter_name, void *memory)
Retrieves the value of a specified parameter from the current data table of a data set.
int32_t SDDS_GetArrayInformation(SDDS_DATASET *SDDS_dataset, char *field_name, void *memory, int32_t mode,...)
Retrieves information about a specified array in the SDDS dataset.
Definition SDDS_info.c:192
int32_t SDDS_GetParameterInformation(SDDS_DATASET *SDDS_dataset, char *field_name, void *memory, int32_t mode,...)
Retrieves information about a specified parameter in the SDDS dataset.
Definition SDDS_info.c:117
int32_t SDDS_GetColumnInformation(SDDS_DATASET *SDDS_dataset, char *field_name, void *memory, int32_t mode,...)
Retrieves information about a specified column in the SDDS dataset.
Definition SDDS_info.c:41
void SDDS_SetTerminateMode(uint32_t mode)
int32_t SDDS_InitializeInput(SDDS_DATASET *SDDS_dataset, char *filename)
Definition SDDS_input.c:49
int32_t SDDS_Terminate(SDDS_DATASET *SDDS_dataset)
int32_t SDDS_ReadPage(SDDS_DATASET *SDDS_dataset)
void SDDS_SetError(char *error_text)
Records an error message in the SDDS error stack.
Definition SDDS_utils.c:379
int32_t SDDS_GetParameterType(SDDS_DATASET *SDDS_dataset, int32_t index)
Retrieves the data type of a parameter in the SDDS dataset by its index.
int32_t SDDS_GetArrayIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named array in the SDDS dataset.
int32_t SDDS_GetParameterIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named parameter in the SDDS dataset.
int32_t SDDS_SprintTypedValue(void *data, int64_t index, int32_t type, const char *format, char *buffer, uint32_t mode)
Formats a data value of a specified type into a string buffer using an optional printf format string.
Definition SDDS_utils.c:151
int32_t SDDS_GetColumnIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named column in the SDDS dataset.
void SDDS_EscapeQuotes(char *s, char quote_char)
Escapes quote characters within a string by inserting backslashes.
int32_t SDDS_GetArrayType(SDDS_DATASET *SDDS_dataset, int32_t index)
Retrieves the data type of an array in the SDDS dataset by its index.
void SDDS_PrintErrors(FILE *fp, int32_t mode)
Prints recorded error messages to a specified file stream.
Definition SDDS_utils.c:432
void SDDS_RegisterProgramName(const char *name)
Registers the executable program name for use in error messages.
Definition SDDS_utils.c:288
int32_t SDDS_StringIsBlank(char *s)
Checks if a string is blank (contains only whitespace characters).
int32_t SDDS_GetColumnType(SDDS_DATASET *SDDS_dataset, int32_t index)
Retrieves the data type of a column in the SDDS dataset by its index.
void SDDS_Bomb(char *message)
Terminates the program after printing an error message and recorded errors.
Definition SDDS_utils.c:342
int32_t SDDS_HasWhitespace(char *string)
Checks if a string contains any whitespace characters.
void * trealloc(void *old_ptr, uint64_t size_of_block)
Reallocates a memory block to a new size.
Definition array.c:181
void * tmalloc(uint64_t size_of_block)
Allocates a memory block of the specified size with zero initialization.
Definition array.c:59
void bomb(char *error, char *usage)
Reports error messages to the terminal and aborts the program.
Definition bomb.c:26
char * cp_str(char **s, char *t)
Copies a string, allocating memory for storage.
Definition cp_str.c:28
long match_string(char *string, char **option, long n_options, long mode)
Matches a given string against an array of option strings based on specified modes.
int scanargs(SCANNED_ARG **scanned, int argc, char **argv)
Definition scanargs.c:36