SDDS ToolKit Programs and Libraries for C and Python
All Classes Files Functions Variables Macros Pages
sdds2plaindata.c File Reference

Detailed Description

Converts SDDS files to plain data format (ASCII or binary).

This program reads an SDDS (Self Describing Data Set) file and converts its content to a plain data file. The output format, ordering, and included data elements can be customized using various options. Both ASCII and binary output modes are supported.

Usage

sdds2plaindata [<inputfile>] [<outputfile>]
[-pipe[=input][,output]]
[-outputMode={ascii|binary}]
[-separator=<string>]
[-noRowCount]
[-order={rowMajor|columnMajor}]
[-parameter=<name>[,format=<string>]...]
[-column=<name>[,format=<string>]...]
[-labeled]
[-nowarnings]

Options

Option Description
-pipe Use pipes for input and/or output.
-outputMode Specify output format as ASCII or binary. Default is ASCII.
-separator Define the column separator string in ASCII mode.
-noRowCount Exclude the row count from the output.
-order Specify data ordering: rowMajor (default) or columnMajor.
-parameter Include specific parameters in the output. Optionally specify a format.
-column Include specific columns in the output. Supports wildcards and formatting.
-labeled Add labels for parameters or columns in ASCII mode.
-nowarnings Suppress warning messages.

Incompatibilities

  • -outputMode=binary is incompatible with -noRowCount.
  • -labeled is only valid for -outputMode=ascii.

Specific Requirements

  • -separator is valid only in -outputMode=ascii.
  • At least one of -parameter or -column must be specified.
License
This file is distributed under the terms of the Software License Agreement found in the file LICENSE included with this distribution.
Authors
R. Soliday, M. Borland, H. Shang

Definition in file sdds2plaindata.c.

#include "mdb.h"
#include "SDDS.h"
#include "scan.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 136 of file sdds2plaindata.c.

136 {
137 FILE *fileID;
138 SDDS_LAYOUT *layout = NULL;
139 SDDS_FILEBUFFER *fBuffer = NULL;
140
141 SDDS_DATASET SDDS_dataset, SDDS_dummy;
142 SCANNED_ARG *s_arg;
143 long i_arg, retval, page_number = 0, size, columnOrder = 0;
144 int64_t i, j;
145 int64_t rows = 0;
146 int32_t rows32;
147 char *input, *output;
148 unsigned long pipeFlags = 0, flags = 0;
149 long noWarnings = 0, tmpfile_used = 0;
150 long labeled = 0;
151
152 long *parameterType, *columnType, *parameterIndex;
153 int32_t *columnIndex;
154 char **parameterUnits;
155 void **columnData;
156 char *buffer;
157 static char printBuffer[SDDS_MAXLINE * 16];
158 static char formatbuffer[100], formatbuffer2[100];
159
160 long binary = 0, noRowCount = 0;
161 char *separator, *ptr = NULL;
162 char **parameter, **parameterFormat;
163 char **column, **columnFormat, **columnUnits, **columnMatch, **columnMatchFormat, **columnName;
164 long parameters = 0, columns = 0, columnMatches = 0;
165 int32_t columnNames = 0;
166
167 input = output = NULL;
168 parameter = column = parameterFormat = columnFormat = columnMatch = columnMatchFormat = columnName = NULL;
169 separator = NULL;
170
171 parameterType = columnType = parameterIndex = NULL;
172 columnIndex = NULL;
173 columnData = NULL;
174 parameterUnits = columnUnits = NULL;
175
176 buffer = tmalloc(sizeof(char) * 16);
177
179 argc = scanargs(&s_arg, argc, argv);
180 if (argc < 3)
181 bomb(NULL, USAGE);
182
183 for (i_arg = 1; i_arg < argc; i_arg++) {
184 if (s_arg[i_arg].arg_type == OPTION) {
185 switch (match_string(s_arg[i_arg].list[0], option, N_OPTIONS, 0)) {
186 case SET_OUTPUTMODE:
187 if (s_arg[i_arg].n_items != 2)
188 SDDS_Bomb("invalid -outputMode syntax");
189 switch (match_string(s_arg[i_arg].list[1], mode_name, MODES, 0)) {
190 case ASCII_MODE:
191 binary = 0;
192 break;
193 case BINARY_MODE:
194 binary = 1;
195 break;
196 default:
197 SDDS_Bomb("invalid -outputMode syntax");
198 break;
199 }
200 break;
201 case SET_SEPARATOR:
202 if (s_arg[i_arg].n_items != 2)
203 SDDS_Bomb("invalid -separator syntax");
204 separator = s_arg[i_arg].list[1];
205 break;
206 case SET_NOROWCOUNT:
207 if (s_arg[i_arg].n_items != 1)
208 SDDS_Bomb("invalid -noRowCount syntax");
209 noRowCount = 1;
210 break;
211 case SET_ORDER:
212 if (s_arg[i_arg].n_items != 2)
213 SDDS_Bomb("invalid -order syntax");
214 switch (match_string(s_arg[i_arg].list[1], order_names, ORDERS, 0)) {
215 case ROW_ORDER:
216 columnOrder = 0;
217 break;
218 case COLUMN_ORDER:
219 columnOrder = 1;
220 break;
221 default:
222 SDDS_Bomb("invalid -order syntax");
223 break;
224 }
225 break;
226 case SET_PARAMETER:
227 if ((s_arg[i_arg].n_items != 2) && (s_arg[i_arg].n_items != 4))
228 SDDS_Bomb("invalid -parameter syntax");
229 parameter = trealloc(parameter, sizeof(*parameter) * (++parameters));
230 parameterFormat = trealloc(parameterFormat, sizeof(*parameterFormat) * (parameters));
231 parameter[parameters - 1] = s_arg[i_arg].list[1];
232 parameterFormat[parameters - 1] = NULL;
233 s_arg[i_arg].n_items -= 2;
234 if (!scanItemList(&flags, s_arg[i_arg].list + 2, &s_arg[i_arg].n_items, 0, "format", SDDS_STRING, &(parameterFormat[parameters - 1]), 1, 0, NULL))
235 SDDS_Bomb("invalid -parameter syntax");
236 if (parameterFormat[parameters - 1]) {
237 replaceString(formatbuffer, parameterFormat[parameters - 1], "ld", PRId32, -1, 0);
238 replaceString(formatbuffer2, formatbuffer, "lu", PRIu32, -1, 0);
239 parameterFormat[parameters - 1] = malloc(sizeof(*(parameterFormat[parameters - 1])) * (strlen(formatbuffer2) + 1));
240 sprintf(parameterFormat[parameters - 1], "%s", formatbuffer2);
241 }
242 break;
243 case SET_COLUMN:
244 if ((s_arg[i_arg].n_items < 2))
245 SDDS_Bomb("invalid -column syntax");
246 if (has_wildcards(s_arg[i_arg].list[1])) {
247 columnMatch = trealloc(columnMatch, sizeof(*columnMatch) * (++columnMatches));
248 columnMatchFormat = trealloc(columnMatchFormat, sizeof(*columnMatchFormat) * (columnMatches));
249 SDDS_CopyString(&columnMatch[columnMatches - 1], s_arg[i_arg].list[1]);
250 columnMatchFormat[columnMatches - 1] = NULL;
251 s_arg[i_arg].n_items -= 2;
252 if (!scanItemList(&flags, s_arg[i_arg].list + 2, &s_arg[i_arg].n_items, 0, "format", SDDS_STRING, &(columnMatchFormat[columnMatches - 1]), 1, 0, NULL))
253 SDDS_Bomb("invalid -columns syntax");
254 if (columnMatchFormat[columnMatches - 1]) {
255 replaceString(formatbuffer, columnMatchFormat[columnMatches - 1], "ld", PRId32, -1, 0);
256 replaceString(formatbuffer2, formatbuffer, "lu", PRIu32, -1, 0);
257 columnMatchFormat[columnMatches - 1] = malloc(sizeof(*(columnMatchFormat[columnMatches - 1])) * (strlen(formatbuffer2) + 1));
258 sprintf(columnMatchFormat[columnMatches - 1], "%s", formatbuffer2);
259 }
260 } else {
261 column = trealloc(column, sizeof(*column) * (++columns));
262 columnFormat = trealloc(columnFormat, sizeof(*columnFormat) * (columns));
263 SDDS_CopyString(&column[columns - 1], s_arg[i_arg].list[1]);
264 columnFormat[columns - 1] = NULL;
265 s_arg[i_arg].n_items -= 2;
266 if (!scanItemList(&flags, s_arg[i_arg].list + 2, &s_arg[i_arg].n_items, 0, "format", SDDS_STRING, &(columnFormat[columns - 1]), 1, 0, NULL))
267 SDDS_Bomb("invalid -columns syntax");
268 if (columnFormat[columns - 1]) {
269 replaceString(formatbuffer, columnFormat[columns - 1], "ld", PRId32, -1, 0);
270 replaceString(formatbuffer2, formatbuffer, "lu", PRIu32, -1, 0);
271 columnFormat[columns - 1] = malloc(sizeof(*(columnFormat[columns - 1])) * (strlen(formatbuffer2) + 1));
272 sprintf(columnFormat[columns - 1], "%s", formatbuffer2);
273 }
274 }
275 break;
276 case SET_PIPE:
277 if (!processPipeOption(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1, &pipeFlags))
278 SDDS_Bomb("invalid -pipe syntax");
279 break;
280 case SET_NOWARNINGS:
281 if (s_arg[i_arg].n_items != 1)
282 SDDS_Bomb("invalid -nowarnings syntax");
283 noWarnings = 1;
284 break;
285 case SET_LABELED:
286 labeled = 1;
287 break;
288 default:
289 fprintf(stderr, "error: unknown switch: %s\n", s_arg[i_arg].list[0]);
290 exit(EXIT_FAILURE);
291 break;
292 }
293 } else {
294 if (input == NULL) {
295 input = s_arg[i_arg].list[0];
296 } else if (output == NULL) {
297 output = s_arg[i_arg].list[0];
298 } else {
299 fprintf(stderr, "error: too many filenames provided.\n");
300 exit(EXIT_FAILURE);
301 }
302 }
303 }
304
305 processFilenames("sdds2plaindata", &input, &output, pipeFlags, noWarnings, &tmpfile_used);
306
307 if (!columns && !columnMatches && !parameters)
308 SDDS_Bomb("error: you must specify at least one of the -column or -parameter options.");
309 if (!separator) {
310 cp_str(&separator, "");
311 }
312
313 if (!SDDS_InitializeInput(&SDDS_dataset, input)) {
314 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
315 exit(EXIT_FAILURE);
316 }
317 if (columnMatches) {
318 if (!(columnName = SDDS_GetColumnNames(&SDDS_dataset, &columnNames)))
319 SDDS_PrintErrors(stderr, SDDS_EXIT_PrintErrors | SDDS_VERBOSE_PrintErrors);
320 for (i = 0; i < columnMatches; i++) {
321 ptr = expand_ranges(columnMatch[i]);
322 for (j = 0; j < columnNames; j++) {
323 if (wild_match(columnName[j], ptr)) {
324 if (columns > 0) {
325 if (match_string(columnName[j], column, columns, EXACT_MATCH) < 0) {
326 column = trealloc(column, sizeof(*column) * (columns + 1));
327 SDDS_CopyString(&column[columns], columnName[j]);
328 columnFormat = trealloc(columnFormat, sizeof(*columnFormat) * (columns + 1));
329 columnFormat[columns] = NULL;
330 if (columnMatchFormat[i])
331 SDDS_CopyString(&columnFormat[columns], columnMatchFormat[i]);
332 columns++;
333 }
334 } else {
335 column = trealloc(column, sizeof(*column) * (columns + 1));
336 SDDS_CopyString(&column[columns], columnName[j]);
337 columnFormat = trealloc(columnFormat, sizeof(*columnFormat) * (columns + 1));
338 columnFormat[columns] = NULL;
339 if (columnMatchFormat[i])
340 SDDS_CopyString(&columnFormat[columns], columnMatchFormat[i]);
341 columns++;
342 }
343 }
344 }
345 }
346 SDDS_FreeStringArray(columnName, columnNames);
347 free(columnName);
348 SDDS_FreeStringArray(columnMatch, columnMatches);
349 free(columnMatch);
350 SDDS_FreeStringArray(columnMatchFormat, columnMatches);
351 free(columnMatchFormat);
352 }
353
354 if (parameters) {
355 parameterType = tmalloc(sizeof(*parameterType) * parameters);
356 parameterIndex = tmalloc(sizeof(*parameterIndex) * parameters);
357 parameterUnits = tmalloc(sizeof(*parameterUnits) * parameters);
358 for (i = 0; i < parameters; i++) {
359 if ((parameterIndex[i] = SDDS_GetParameterIndex(&SDDS_dataset, parameter[i])) < 0) {
360 fprintf(stderr, "error: parameter '%s' does not exist.\n", parameter[i]);
361 exit(EXIT_FAILURE);
362 }
363 if ((parameterType[i] = SDDS_GetParameterType(&SDDS_dataset, parameterIndex[i])) <= 0 ||
364 SDDS_GetParameterInformation(&SDDS_dataset, "units", &parameterUnits[i], SDDS_GET_BY_INDEX, parameterIndex[i]) != SDDS_STRING) {
365 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
366 exit(EXIT_FAILURE);
367 }
368 }
369 }
370 if (columns) {
371 columnType = tmalloc(sizeof(*columnType) * columns);
372 columnIndex = tmalloc(sizeof(*columnIndex) * columns);
373 columnData = tmalloc(sizeof(*columnData) * columns);
374 columnUnits = tmalloc(sizeof(*columnUnits) * columns);
375 for (i = 0; i < columns; i++) {
376 if ((columnIndex[i] = SDDS_GetColumnIndex(&SDDS_dataset, column[i])) < 0) {
377 fprintf(stderr, "error: column '%s' does not exist.\n", column[i]);
378 exit(EXIT_FAILURE);
379 }
380 if ((columnType[i] = SDDS_GetColumnType(&SDDS_dataset, columnIndex[i])) <= 0 ||
381 SDDS_GetColumnInformation(&SDDS_dataset, "units", &columnUnits[i], SDDS_GET_BY_INDEX, columnIndex[i]) != SDDS_STRING) {
382 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
383 exit(EXIT_FAILURE);
384 }
385 }
386 }
387
388 if (!output) {
389 if (binary) {
390#if defined(_WIN32)
391 if (_setmode(_fileno(stdout), _O_BINARY) == -1) {
392 fprintf(stderr, "error: unable to set stdout to binary mode.\n");
393 exit(EXIT_FAILURE);
394 }
395#endif
396 }
397 fileID = stdout;
398 } else {
399 if (binary) {
400 fileID = fopen(output, "wb");
401 } else {
402 fileID = fopen(output, "w");
403 }
404 }
405 if (fileID == NULL) {
406 fprintf(stderr, "error: unable to open output file for writing.\n");
407 exit(EXIT_FAILURE);
408 }
409
410 if (binary) {
411 layout = &SDDS_dataset.layout;
412 fBuffer = &SDDS_dummy.fBuffer;
413 fBuffer->buffer = NULL;
414 if (!fBuffer->buffer) {
415 if (!(fBuffer->buffer = fBuffer->data = SDDS_Malloc(sizeof(char) * SDDS_FILEBUFFER_SIZE))) {
416 fprintf(stderr, "error: unable to allocate buffer for binary output.\n");
417 exit(EXIT_FAILURE);
418 }
419 fBuffer->bufferSize = SDDS_FILEBUFFER_SIZE;
420 fBuffer->bytesLeft = SDDS_FILEBUFFER_SIZE;
421 }
422 }
423
424 retval = -1;
425 while (retval != page_number && (retval = SDDS_ReadPage(&SDDS_dataset)) > 0) {
426 if (page_number && retval != page_number)
427 continue;
428 if (columns != 0) {
429 if ((rows = SDDS_CountRowsOfInterest(&SDDS_dataset)) < 0) {
430 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
431 exit(EXIT_FAILURE);
432 }
433 }
434 if ((binary) && (!noRowCount)) {
435 if (rows > INT32_MAX) {
436 rows32 = INT32_MIN;
437 if (!SDDS_BufferedWrite(&rows32, sizeof(rows32), fileID, fBuffer)) {
438 fprintf(stderr, "error: failed to write row count (overflow).\n");
439 exit(EXIT_FAILURE);
440 }
441 if (!SDDS_BufferedWrite(&rows, sizeof(rows), fileID, fBuffer)) {
442 fprintf(stderr, "error: failed to write row count.\n");
443 exit(EXIT_FAILURE);
444 }
445 } else {
446 rows32 = rows;
447 if (!SDDS_BufferedWrite(&rows32, sizeof(rows32), fileID, fBuffer)) {
448 fprintf(stderr, "error: failed to write row count.\n");
449 exit(EXIT_FAILURE);
450 }
451 }
452 }
453
454 for (i = 0; i < parameters; i++) {
455 if (binary) {
456 /*
457 if (layout->parameter_definition[i].fixed_value)
458 continue;
459 */
460 if (parameterType[i] == SDDS_STRING) {
461 if (!SDDS_WriteBinaryString(*((char **)SDDS_dataset.parameter[parameterIndex[i]]), fileID, fBuffer)) {
462 fprintf(stderr, "error: failed to write string parameter.\n");
463 exit(EXIT_FAILURE);
464 }
465 } else if (!SDDS_BufferedWrite(SDDS_dataset.parameter[parameterIndex[i]], SDDS_type_size[layout->parameter_definition[parameterIndex[i]].type - 1], fileID, fBuffer)) {
466 fprintf(stderr, "error: failed to write parameter value.\n");
467 exit(EXIT_FAILURE);
468 }
469 } else {
470 if (!SDDS_GetParameter(&SDDS_dataset, parameter[i], buffer)) {
471 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
472 exit(EXIT_FAILURE);
473 }
474 SDDS_SprintTypedValue(buffer, 0, parameterType[i], parameterFormat[i], printBuffer, 0);
475 if (labeled) {
476 fputs(parameter[i], fileID);
477 fputs(separator, fileID);
478 if (parameterUnits[i])
479 fputs(parameterUnits[i], fileID);
480 fputs(separator, fileID);
481 }
482 fputs(printBuffer, fileID);
483 fputc('\n', fileID);
484 }
485 }
486
487 if (!binary) {
488 if (!noRowCount)
489 fprintf(fileID, "\t%" PRId64 "\n", rows);
490 if (labeled && columns) {
491 for (j = 0; j < columns; j++) {
492 fputs(column[j], fileID);
493 if (j != (columns - 1))
494 fputs(separator, fileID);
495 }
496 fputc('\n', fileID);
497 for (j = 0; j < columns; j++) {
498 if (columnUnits[j])
499 fputs(columnUnits[j], fileID);
500 if (j != (columns - 1))
501 fputs(separator, fileID);
502 }
503 fputc('\n', fileID);
504 }
505 }
506
507 if (columns) {
508 if (rows) {
509 if (binary) {
510 if (columnOrder) {
511 for (j = 0; j < columns; j++) {
512 if (columnType[j] == SDDS_STRING) {
513 for (i = 0; i < rows; i++) {
514 if (!SDDS_WriteBinaryString(*((char **)SDDS_dataset.data[columnIndex[j]] + i), fileID, fBuffer)) {
515 fprintf(stderr, "error: failed to write string data for column '%s'.\n", column[j]);
516 exit(EXIT_FAILURE);
517 }
518 }
519 } else {
520 size = SDDS_type_size[columnType[j] - 1];
521 for (i = 0; i < rows; i++) {
522 if (!SDDS_BufferedWrite((char *)SDDS_dataset.data[columnIndex[j]] + i * size, size, fileID, fBuffer)) {
523 fprintf(stderr, "error: failed to write data for column '%s'.\n", column[j]);
524 exit(EXIT_FAILURE);
525 }
526 }
527 }
528 }
529 } else {
530 for (i = 0; i < rows; i++) {
531 for (j = 0; j < columns; j++) {
532 if (columnType[j] == SDDS_STRING) {
533 if (!SDDS_WriteBinaryString(*((char **)SDDS_dataset.data[columnIndex[j]] + i), fileID, fBuffer)) {
534 fprintf(stderr, "error: failed to write string data for column '%s'.\n", column[j]);
535 exit(EXIT_FAILURE);
536 }
537 } else {
538 size = SDDS_type_size[columnType[j] - 1];
539 if (!SDDS_BufferedWrite((char *)SDDS_dataset.data[columnIndex[j]] + i * size, size, fileID, fBuffer)) {
540 fprintf(stderr, "error: failed to write data for column '%s'.\n", column[j]);
541 exit(EXIT_FAILURE);
542 }
543 }
544 }
545 }
546 }
547 } else {
548 for (i = 0; i < columns; i++) {
549 if (!(columnData[i] = SDDS_GetInternalColumn(&SDDS_dataset, column[i]))) {
550 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
551 exit(EXIT_FAILURE);
552 }
553 }
554 if (columnOrder) {
555 for (i = 0; i < columns; i++) {
556 for (j = 0; j < rows; j++) {
557 SDDS_SprintTypedValue(columnData[i], j, columnType[i], columnFormat[i], printBuffer, 0);
558 fputs(printBuffer, fileID);
559 if (j != rows - 1)
560 fprintf(fileID, "%s", separator);
561 }
562 fputc('\n', fileID);
563 }
564 } else {
565 for (j = 0; j < rows; j++) {
566 for (i = 0; i < columns; i++) {
567 SDDS_SprintTypedValue(columnData[i], j, columnType[i], columnFormat[i], printBuffer, 0);
568 fputs(printBuffer, fileID);
569 if (i != columns - 1)
570 fprintf(fileID, "%s", separator);
571 }
572 fputc('\n', fileID);
573 }
574 }
575 }
576 }
577 }
578
579 if (retval == 0) {
580 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
581 exit(EXIT_FAILURE);
582 }
583 }
584
585 if (binary) {
586 if (!SDDS_FlushBuffer(fileID, fBuffer)) {
587 SDDS_SetError("Unable to write page--buffer flushing problem (SDDS_WriteBinaryPage)");
588 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
589 exit(EXIT_FAILURE);
590 }
591 } else {
592 fflush(fileID);
593 }
594 fclose(fileID);
595
596 if (columns) {
597 SDDS_FreeStringArray(column, columns);
598 free(column);
599 SDDS_FreeStringArray(columnFormat, columns);
600 free(columnFormat);
601 }
602 if (parameters) {
603 SDDS_FreeStringArray(parameter, parameters);
604 free(parameter);
605 SDDS_FreeStringArray(parameterFormat, parameters);
606 free(parameterFormat);
607 }
608 free_scanargs(&s_arg, argc);
609 if (!SDDS_Terminate(&SDDS_dataset)) {
610 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
611 exit(EXIT_FAILURE);
612 }
613
614 exit(EXIT_SUCCESS);
615}
int32_t SDDS_BufferedWrite(void *target, int64_t targetSize, FILE *fp, SDDS_FILEBUFFER *fBuffer)
int32_t SDDS_WriteBinaryString(char *string, FILE *fp, SDDS_FILEBUFFER *fBuffer)
Writes a binary string to a file with buffering.
int32_t SDDS_FlushBuffer(FILE *fp, SDDS_FILEBUFFER *fBuffer)
int32_t SDDS_type_size[SDDS_NUM_TYPES]
Array of sizes for each supported data type.
Definition SDDS_data.c:62
int64_t SDDS_CountRowsOfInterest(SDDS_DATASET *SDDS_dataset)
Counts the number of rows marked as "of interest" in the current data table.
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_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
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)
int32_t SDDS_FreeStringArray(char **string, int64_t strings)
Frees an array of strings by deallocating each individual string.
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_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.
char ** SDDS_GetColumnNames(SDDS_DATASET *SDDS_dataset, int32_t *number)
Retrieves the names of all columns in the SDDS dataset.
void SDDS_PrintErrors(FILE *fp, int32_t mode)
Prints recorded error messages to a specified file stream.
Definition SDDS_utils.c:432
void * SDDS_Malloc(size_t size)
Allocates memory of a specified size.
Definition SDDS_utils.c:639
void SDDS_RegisterProgramName(const char *name)
Registers the executable program name for use in error messages.
Definition SDDS_utils.c:288
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_CopyString(char **target, const char *source)
Copies a source string to a target string with memory allocation.
Definition SDDS_utils.c:856
#define SDDS_STRING
Identifier for the string data type.
Definition SDDStypes.h:85
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 replaceString(char *t, char *s, char *orig, char *repl, long count_limit, long here)
Replace occurrences of one string with another string with additional options.
int scanargs(SCANNED_ARG **scanned, int argc, char **argv)
Definition scanargs.c:36
long processPipeOption(char **item, long items, unsigned long *flags)
Definition scanargs.c:356
void processFilenames(char *programName, char **input, char **output, unsigned long pipeFlags, long noWarnings, long *tmpOutputUsed)
Definition scanargs.c:390
void free_scanargs(SCANNED_ARG **scanned, int argc)
Definition scanargs.c:584
long scanItemList(unsigned long *flags, char **item, long *items, unsigned long mode,...)
Scans a list of items and assigns values based on provided keywords and types.
int has_wildcards(char *template)
Check if a template string contains any wildcard characters.
Definition wild_match.c:498
char * expand_ranges(char *template)
Expand range specifiers in a wildcard template into explicit character lists.
Definition wild_match.c:429
int wild_match(char *string, char *template)
Determine whether one string is a wildcard match for another.
Definition wild_match.c:49