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