SDDSlib
Loading...
Searching...
No Matches
sddsquery.c File Reference

Reads an SDDS file header and summarizes it. More...

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

Go to the source code of this file.

Enumerations

enum  option_type {
  SET_COLUMN_LIST , SET_PARAMETER_LIST , SET_ASSOCIATE_LIST , SET_ARRAY_LIST ,
  SET_DELIMITER , SET_APPEND_UNITS , SET_VERSION , SET_PIPE ,
  SET_SDDSOUTPUT , SET_READALL , N_OPTIONS
}
 

Functions

long InitializeSDDSHeaderOutput (SDDS_DATASET *outSet, char *filename)
 
long MakeSDDSHeaderSummary (SDDS_DATASET *outSet, SDDS_DATASET *inSet, long listRequest, char *inputFile)
 
long MakeColumnHeaderSummary (SDDS_DATASET *outSet, SDDS_DATASET *inSet, char *inputFile)
 
long MakeParameterHeaderSummary (SDDS_DATASET *outSet, SDDS_DATASET *inSet, char *inputFile)
 
long MakeArrayHeaderSummary (SDDS_DATASET *outSet, SDDS_DATASET *inSet, char *inputFile)
 
int main (int argc, char **argv)
 

Variables

char * option [N_OPTIONS]
 
char * USAGE
 
static long indexName
 
static long indexUnits
 
static long indexSymbol
 
static long indexFormat
 
static long indexType
 
static long indexDescription
 
static long indexGroup
 

Detailed Description

Reads an SDDS file header and summarizes it.

This program accesses a series of SDDS files and summarizes the file header for each. It also provides lists of arrays, columns, parameters, or associates.

License
This file is distributed under the terms of the Software License Agreement found in the file LICENSE included with this distribution.
Author
M. Borland, C. Saunders, R. Soliday

Definition in file sddsquery.c.

Enumeration Type Documentation

◆ option_type

enum option_type

Definition at line 24 of file sddsquery.c.

24 {
25 SET_COLUMN_LIST,
26 SET_PARAMETER_LIST,
27 SET_ASSOCIATE_LIST,
28 SET_ARRAY_LIST,
29 SET_DELIMITER,
30 SET_APPEND_UNITS,
31 SET_VERSION,
32 SET_PIPE,
33 SET_SDDSOUTPUT,
34 SET_READALL,
35 N_OPTIONS
36};

Function Documentation

◆ InitializeSDDSHeaderOutput()

long InitializeSDDSHeaderOutput ( SDDS_DATASET * outSet,
char * filename )

Definition at line 410 of file sddsquery.c.

410 {
411 if (!SDDS_InitializeOutput(outSet, SDDS_BINARY, 0, NULL, NULL, filename))
412 return 0;
413 if (0 > (indexName = SDDS_DefineColumn(outSet, "Name", NULL, NULL, NULL, NULL, SDDS_STRING, 0)) ||
414 0 > (indexUnits = SDDS_DefineColumn(outSet, "Units", NULL, NULL, NULL, NULL, SDDS_STRING, 0)) ||
415 0 > (indexSymbol = SDDS_DefineColumn(outSet, "Symbol", NULL, NULL, NULL, NULL, SDDS_STRING, 0)) ||
416 0 > (indexFormat = SDDS_DefineColumn(outSet, "Format", NULL, NULL, NULL, NULL, SDDS_STRING, 0)) ||
417 0 > (indexType = SDDS_DefineColumn(outSet, "Type", NULL, NULL, NULL, NULL, SDDS_STRING, 0)) ||
418 0 > (indexDescription = SDDS_DefineColumn(outSet, "Description", NULL, NULL, NULL, NULL, SDDS_STRING, 0)) ||
419 0 > (indexGroup = SDDS_DefineColumn(outSet, "Group", NULL, NULL, NULL, NULL, SDDS_STRING, 0)))
420 return 0;
421 if (0 > SDDS_DefineParameter(outSet, "Class", NULL, NULL, NULL, NULL, SDDS_STRING, 0) ||
422 0 > SDDS_DefineParameter(outSet, "Filename", NULL, NULL, NULL, NULL, SDDS_STRING, 0))
423 return 0;
424 if (!SDDS_WriteLayout(outSet))
425 return 0;
426 return 1;
427}
int32_t SDDS_InitializeOutput(SDDS_DATASET *SDDS_dataset, int32_t data_mode, int32_t lines_per_row, const char *description, const char *contents, const char *filename)
Initializes the SDDS output dataset.
int32_t SDDS_DefineColumn(SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, int32_t field_length)
Defines a data column within the SDDS dataset.
int32_t SDDS_WriteLayout(SDDS_DATASET *SDDS_dataset)
Writes the SDDS layout header to the output file.
int32_t SDDS_DefineParameter(SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, char *fixed_value)
Defines a data parameter with a fixed string value.
#define SDDS_STRING
Identifier for the string data type.
Definition SDDStypes.h:85

◆ main()

int main ( int argc,
char ** argv )

Definition at line 78 of file sddsquery.c.

78 {
79 SDDS_DATASET SDDS_dataset, SDDSout;
80 SDDS_LAYOUT *layout;
81 COLUMN_DEFINITION *coldef;
83 ARRAY_DEFINITION *arraydef;
84 long list_request;
85 char s[SDDS_MAXLINE];
86 char **filename, *ptr, *sddsOutputFile;
87 long i, i_arg, filenames, file, append_units, sddsOutput;
88 SCANNED_ARG *s_arg;
89 char *text, *contents, *delimiter, *unitsTemplate;
90 FILE *fp;
91 unsigned long pipeFlags;
92 long readAll;
93
94 list_request = -1;
95 filename = NULL;
96 sddsOutput = 0;
97 filenames = append_units = 0;
98 delimiter = sddsOutputFile = unitsTemplate = NULL;
99 pipeFlags = 0;
100 readAll = 0;
101
103 argc = scanargs(&s_arg, argc, argv);
104
105 for (i_arg = 1; i_arg < argc; i_arg++) {
106 if (s_arg[i_arg].arg_type == OPTION) {
107 delete_chars(s_arg[i_arg].list[0], "_");
108 switch (match_string(s_arg[i_arg].list[0], option, N_OPTIONS, 0)) {
109 case SET_COLUMN_LIST:
110 list_request = SET_COLUMN_LIST;
111 break;
112 case SET_PARAMETER_LIST:
113 list_request = SET_PARAMETER_LIST;
114 break;
115 case SET_ASSOCIATE_LIST:
116 list_request = SET_ASSOCIATE_LIST;
117 break;
118 case SET_ARRAY_LIST:
119 list_request = SET_ARRAY_LIST;
120 break;
121 case SET_VERSION:
122 list_request = SET_VERSION;
123 break;
124 case SET_DELIMITER:
125 if (s_arg[i_arg].n_items < 2)
126 SDDS_Bomb("invalid -delimiter syntax");
127 delimiter = s_arg[i_arg].list[1];
128 break;
129 case SET_APPEND_UNITS:
130 append_units = 1;
131 if (s_arg[i_arg].n_items == 2) {
132 if (strncmp(s_arg[i_arg].list[1], "bare", strlen(s_arg[i_arg].list[1])) == 0)
133 unitsTemplate = " %s";
134 else
135 SDDS_Bomb("invalid -appendUnits syntax");
136 } else if (s_arg[i_arg].n_items > 2)
137 SDDS_Bomb("invalid -appendUnits syntax");
138 else
139 unitsTemplate = " (%s)";
140 break;
141 case SET_PIPE:
142 if (!processPipeOption(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1, &pipeFlags))
143 SDDS_Bomb("invalid -pipe syntax");
144 break;
145 case SET_SDDSOUTPUT:
146 sddsOutput = 1;
147 sddsOutputFile = NULL;
148 if ((s_arg[i_arg].n_items != 1 && s_arg[i_arg].n_items != 2) ||
149 (s_arg[i_arg].n_items == 2 && SDDS_StringIsBlank(sddsOutputFile = s_arg[i_arg].list[1])))
150 SDDS_Bomb("invalid -sddsOutput syntax");
151 break;
152 case SET_READALL:
153 readAll = 1;
154 break;
155 default:
156 bomb("unknown switch", USAGE);
157 break;
158 }
159 } else {
160 filename = trealloc(filename, sizeof(*filename) * (filenames + 1));
161 filename[filenames++] = s_arg[i_arg].list[0];
162 }
163 }
164
165 if (!filenames && !(pipeFlags & USE_STDIN))
166 bomb(NULL, USAGE);
167 if (pipeFlags & USE_STDIN) {
168 char **filename1;
169 filename1 = tmalloc(sizeof(*filename1) * (filenames + 1));
170 filename1[0] = NULL;
171 for (file = 0; file < filenames; file++)
172 filename1[file + 1] = filename[file];
173 if (filename)
174 free(filename);
175 filename = filename1;
176 filenames++;
177 }
178#ifdef DEBUG
179 fprintf(stderr, "files: ");
180 for (file = 0; file < filenames; file++)
181 fprintf(stderr, "%s ", filename[file] ? filename[file] : "NULL");
182 fprintf(stderr, "\n");
183#endif
184
185 if (sddsOutput && !InitializeSDDSHeaderOutput(&SDDSout, sddsOutputFile)) {
186 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
187 exit(EXIT_FAILURE);
188 }
189
190 for (file = 0; file < filenames; file++) {
191#ifdef DEBUG
192 fprintf(stderr, "working on file %ld\n", file);
193#endif
194 if (list_request != SET_VERSION && !SDDS_InitializeInput(&SDDS_dataset, filename[file])) {
195 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
196 exit(EXIT_FAILURE);
197 }
198#ifdef DEBUG
199 fprintf(stderr, "file initialized\n");
200#endif
201 if (sddsOutput) {
202#ifdef DEBUG
203 fprintf(stderr, "Making SDDS header summary\n");
204#endif
205 if (!MakeSDDSHeaderSummary(&SDDSout, &SDDS_dataset, list_request, filename[file])) {
206 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
207 exit(EXIT_FAILURE);
208 }
209#ifdef SOLARIS
210 if (!SDDS_Terminate(&SDDS_dataset)) {
211 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
212 exit(EXIT_FAILURE);
213 }
214#endif
215 continue;
216 }
217 layout = &SDDS_dataset.layout;
218 if (list_request >= 0) {
219 switch (list_request) {
220 case SET_COLUMN_LIST:
221#ifdef DEBUG
222 fprintf(stderr, "printing column info\n");
223#endif
224 for (i = 0; i < layout->n_columns; i++) {
225 fputs(layout->column_definition[i].name, stdout);
226 if (append_units && layout->column_definition[i].units &&
227 !SDDS_StringIsBlank(layout->column_definition[i].units))
228 fprintf(stdout, unitsTemplate, layout->column_definition[i].units);
229 fputs(delimiter ? delimiter : "\n", stdout);
230 }
231 break;
232 case SET_PARAMETER_LIST:
233#ifdef DEBUG
234 fprintf(stderr, "printing parameter info\n");
235#endif
236 for (i = 0; i < layout->n_parameters; i++) {
237 fputs(layout->parameter_definition[i].name, stdout);
238 if (append_units && layout->parameter_definition[i].units &&
239 !SDDS_StringIsBlank(layout->parameter_definition[i].units))
240 fprintf(stdout, unitsTemplate, layout->parameter_definition[i].units);
241 fputs(delimiter ? delimiter : "\n", stdout);
242 }
243 break;
244 case SET_ASSOCIATE_LIST:
245#ifdef DEBUG
246 fprintf(stderr, "printing associate info\n");
247#endif
248 for (i = 0; i < layout->n_associates; i++) {
249 fputs(layout->associate_definition[i].filename, stdout);
250 fputs(delimiter ? delimiter : "\n", stdout);
251 }
252 break;
253 case SET_ARRAY_LIST:
254#ifdef DEBUG
255 fprintf(stderr, "printing array info\n");
256#endif
257 for (i = 0; i < layout->n_arrays; i++) {
258 fputs(layout->array_definition[i].name, stdout);
259 if (append_units && layout->array_definition[i].units &&
260 !SDDS_StringIsBlank(layout->array_definition[i].units))
261 fprintf(stdout, unitsTemplate, layout->array_definition[i].units);
262 fputs(delimiter ? delimiter : "\n", stdout);
263 }
264 break;
265 case SET_VERSION:
266#ifdef DEBUG
267 fprintf(stderr, "printing version info\n");
268#endif
269 s[0] = 0;
270 if (!(fp = fopen(filename[file], "r")) || !fgets(s, SDDS_MAXLINE, fp)) {
271 puts("-1");
272 exit(EXIT_FAILURE);
273 }
274 if (strncmp(s, "SDDS", 4) != 0)
275 puts("0");
276 else {
277 if (!(ptr = strchr(s, '\n')))
278 puts("0");
279 else {
280 *ptr = 0;
281 puts(s + 4);
282 }
283 }
284 fclose(fp);
285 break;
286 default:
287 SDDS_Bomb("something impossible happened!");
288 break;
289 }
290 if (readAll) {
291 while (SDDS_ReadPageSparse(&SDDS_dataset, 0, 1000, 0, 0) > 0)
292 ;
293 }
294#ifdef SOLARIS
295 if (list_request != SET_VERSION && !SDDS_Terminate(&SDDS_dataset)) {
296 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
297 exit(EXIT_FAILURE);
298 }
299#endif
300 exit(EXIT_SUCCESS);
301 }
302
303 fprintf(stdout, "\nfile %s is in SDDS protocol version %" PRId32 "\n",
304 filename[file] ? filename[file] : "stdin", layout->version);
305 if (!SDDS_GetDescription(&SDDS_dataset, &text, &contents))
306 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
307 if (text)
308 fprintf(stdout, "description: %s\n", text);
309 if (contents)
310 fprintf(stdout, "contents: %s\n", contents);
311 if (layout->data_mode.mode == SDDS_ASCII) {
312 fprintf(stdout, "\ndata is ASCII with %" PRId32 " lines per row and %" PRId32 " additional header lines expected.\n",
313 layout->data_mode.lines_per_row, layout->data_mode.additional_header_lines);
314 fprintf(stdout, "row counts: %s\n", layout->data_mode.no_row_counts ? "no" : "yes");
315 } else {
316 if (!SDDS_dataset.layout.byteOrderDeclared)
317 fprintf(stdout, "data is binary (no byte order declared)\n");
318 else if (SDDS_IsBigEndianMachine()) {
319 if (SDDS_dataset.swapByteOrder)
320 fprintf(stdout, "data is little-endian binary\n");
321 else
322 fprintf(stdout, "data is big-endian binary\n");
323 } else {
324 if (SDDS_dataset.swapByteOrder)
325 fprintf(stdout, "data is big-endian binary\n");
326 else
327 fprintf(stdout, "data is little-endian binary\n");
328 }
329 }
330
331 if (layout->n_columns) {
332 fprintf(stdout, "\n%" PRId32 " columns of data:\n", layout->n_columns);
333 fprintf(stdout, "NAME UNITS SYMBOL FORMAT TYPE FIELD DESCRIPTION\n");
334 fprintf(stdout, " LENGTH\n");
335 for (i = 0; i < layout->n_columns; i++) {
336 coldef = layout->column_definition + i;
337 fprintf(stdout, "%-15s %-15s %-15s %-15s %-7s %-7" PRId32 " %s\n",
338 coldef->name ? coldef->name : "NULL",
339 coldef->units ? coldef->units : "NULL",
340 coldef->symbol ? coldef->symbol : "NULL",
341 coldef->format_string ? coldef->format_string : "NULL",
342 SDDS_type_name[coldef->type - 1] ? SDDS_type_name[coldef->type - 1] : "NULL",
343 coldef->field_length, coldef->description ? coldef->description : "NULL");
344 }
345 }
346
347 if (layout->n_parameters) {
348 fprintf(stdout, "\n%" PRId32 " parameters:\n", layout->n_parameters);
349 fprintf(stdout, "NAME UNITS SYMBOL TYPE DESCRIPTION\n");
350 for (i = 0; i < layout->n_parameters; i++) {
351 pardef = layout->parameter_definition + i;
352 fprintf(stdout, "%-19s %-19s %-19s %-19s %s\n",
353 pardef->name ? pardef->name : "NULL",
354 pardef->units ? pardef->units : "NULL",
355 pardef->symbol ? pardef->symbol : "NULL",
356 SDDS_type_name[pardef->type - 1] ? SDDS_type_name[pardef->type - 1] : "NULL",
357 pardef->description ? pardef->description : "NULL");
358 }
359 }
360
361 if (layout->n_arrays) {
362 fprintf(stdout, "\n%" PRId32 " arrays of data:\n", layout->n_arrays);
363 fprintf(stdout, "NAME UNITS SYMBOL FORMAT TYPE FIELD GROUP DESCRIPTION\n");
364 fprintf(stdout, " LENGTH NAME\n");
365 for (i = 0; i < layout->n_arrays; i++) {
366 arraydef = layout->array_definition + i;
367 fprintf(stdout, "%-15s %-15s %-15s %-7s %-8s*^%-5" PRId32 " %-7" PRId32 " %-15s %s\n",
368 arraydef->name ? arraydef->name : "NULL",
369 arraydef->units ? arraydef->units : "NULL",
370 arraydef->symbol ? arraydef->symbol : "NULL",
371 arraydef->format_string ? arraydef->format_string : "NULL",
372 SDDS_type_name[arraydef->type - 1],
373 arraydef->dimensions,
374 arraydef->field_length,
375 arraydef->group_name ? arraydef->group_name : "NULL",
376 arraydef->description ? arraydef->description : "NULL");
377 }
378 }
379
380 if (layout->n_associates) {
381 fprintf(stdout, "\n%" PRId32 " associates:\n", layout->n_associates);
382 fprintf(stdout, "SDDS FILENAME PATH CONTENTS DESCRIPTION\n");
383 for (i = 0; i < layout->n_associates; i++)
384 fprintf(stdout, "%-5s %-19s %-29s %-19s %s\n",
385 layout->associate_definition[i].sdds ? "yes" : "no",
386 layout->associate_definition[i].filename ? layout->associate_definition[i].filename : "NULL",
387 layout->associate_definition[i].path ? layout->associate_definition[i].path : "NULL",
388 layout->associate_definition[i].contents ? layout->associate_definition[i].contents : "NULL",
389 layout->associate_definition[i].description ? layout->associate_definition[i].description : "NULL");
390 }
391 fflush(stdout);
392 if (readAll) {
393 while (SDDS_ReadPageSparse(&SDDS_dataset, 0, 1000, 0, 0) > 0)
394 ;
395 }
396 if (!SDDS_Terminate(&SDDS_dataset)) {
397 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
398 exit(EXIT_FAILURE);
399 }
400 }
401 if (sddsOutput && !SDDS_Terminate(&SDDSout)) {
402 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
403 exit(EXIT_FAILURE);
404 }
405 return EXIT_SUCCESS;
406}
char * SDDS_type_name[SDDS_NUM_TYPES]
Array of supported data type names.
Definition SDDS_data.c:43
int32_t SDDS_GetDescription(SDDS_DATASET *SDDS_dataset, char **text, char **contents)
Retrieves the text and contents descriptions from an SDDS dataset.
int32_t SDDS_ReadPageSparse(SDDS_DATASET *SDDS_dataset, uint32_t mode, int64_t sparse_interval, int64_t sparse_offset, int32_t sparse_statistics)
int32_t SDDS_InitializeInput(SDDS_DATASET *SDDS_dataset, char *filename)
Definition SDDS_input.c:49
int32_t SDDS_Terminate(SDDS_DATASET *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_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).
void SDDS_Bomb(char *message)
Terminates the program after printing an error message and recorded errors.
Definition SDDS_utils.c:342
int32_t SDDS_IsBigEndianMachine()
Determines whether the current machine uses big-endian byte ordering.
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 * delete_chars(char *s, char *t)
Removes all occurrences of characters found in string t from string s.
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
long processPipeOption(char **item, long items, unsigned long *flags)
Definition scanargs.c:356

◆ MakeArrayHeaderSummary()

long MakeArrayHeaderSummary ( SDDS_DATASET * outSet,
SDDS_DATASET * inSet,
char * inputFile )

Definition at line 517 of file sddsquery.c.

517 {
518 SDDS_LAYOUT *layout;
519 ARRAY_DEFINITION *arrdef;
520 long i;
521
522 layout = &inSet->layout;
523 if (!layout->n_arrays)
524 return 1;
525 if (!SDDS_StartPage(outSet, layout->n_arrays))
526 return 0;
527 for (i = 0; i < layout->n_arrays; i++) {
528 arrdef = layout->array_definition + i;
529 if (!SDDS_SetRowValues(outSet, SDDS_SET_BY_INDEX | SDDS_PASS_BY_VALUE, i,
530 indexName, arrdef->name,
531 indexUnits, arrdef->units,
532 indexSymbol, arrdef->symbol,
533 indexFormat, arrdef->format_string,
534 indexType, SDDS_type_name[arrdef->type - 1],
535 indexDescription, arrdef->description,
536 indexGroup, arrdef->group_name,
537 -1))
538 return 0;
539 }
540 if (!SDDS_SetParameters(outSet, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE,
541 "Class", "array",
542 "Filename", inputFile,
543 NULL))
544 return 0;
545 if (!SDDS_WritePage(outSet))
546 return 0;
547 return 1;
548}
int32_t SDDS_SetRowValues(SDDS_DATASET *SDDS_dataset, int32_t mode, int64_t row,...)
int32_t SDDS_StartPage(SDDS_DATASET *SDDS_dataset, int64_t expected_n_rows)
int32_t SDDS_SetParameters(SDDS_DATASET *SDDS_dataset, int32_t mode,...)
int32_t SDDS_WritePage(SDDS_DATASET *SDDS_dataset)
Writes the current data table to the output file.

◆ MakeColumnHeaderSummary()

long MakeColumnHeaderSummary ( SDDS_DATASET * outSet,
SDDS_DATASET * inSet,
char * inputFile )

Definition at line 453 of file sddsquery.c.

453 {
454 SDDS_LAYOUT *layout;
455 COLUMN_DEFINITION *coldef;
456 long i;
457
458 layout = &inSet->layout;
459 if (!layout->n_columns)
460 return 1;
461 if (!SDDS_StartPage(outSet, layout->n_columns))
462 return 0;
463 for (i = 0; i < layout->n_columns; i++) {
464 coldef = layout->column_definition + i;
465 if (!SDDS_SetRowValues(outSet, SDDS_SET_BY_INDEX | SDDS_PASS_BY_VALUE, i,
466 indexName, coldef->name,
467 indexUnits, coldef->units,
468 indexSymbol, coldef->symbol,
469 indexFormat, coldef->format_string,
470 indexType, SDDS_type_name[coldef->type - 1],
471 indexDescription, coldef->description,
472 indexGroup, NULL, -1))
473 return 0;
474 }
475 if (!SDDS_SetParameters(outSet, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE,
476 "Class", "column",
477 "Filename", inputFile,
478 NULL))
479 return 0;
480 if (!SDDS_WritePage(outSet))
481 return 0;
482 return 1;
483}

◆ MakeParameterHeaderSummary()

long MakeParameterHeaderSummary ( SDDS_DATASET * outSet,
SDDS_DATASET * inSet,
char * inputFile )

Definition at line 485 of file sddsquery.c.

485 {
486 SDDS_LAYOUT *layout;
487 PARAMETER_DEFINITION *pardef;
488 long i;
489
490 layout = &inSet->layout;
491 if (!layout->n_parameters)
492 return 1;
493 if (!SDDS_StartPage(outSet, layout->n_parameters))
494 return 0;
495 for (i = 0; i < layout->n_parameters; i++) {
496 pardef = layout->parameter_definition + i;
497 if (!SDDS_SetRowValues(outSet, SDDS_SET_BY_INDEX | SDDS_PASS_BY_VALUE, i,
498 indexName, pardef->name,
499 indexUnits, pardef->units,
500 indexSymbol, pardef->symbol,
501 indexFormat, pardef->format_string,
502 indexType, SDDS_type_name[pardef->type - 1],
503 indexDescription, pardef->description,
504 indexGroup, NULL, -1))
505 return 0;
506 }
507 if (!SDDS_SetParameters(outSet, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE,
508 "Class", "parameter",
509 "Filename", inputFile,
510 NULL))
511 return 0;
512 if (!SDDS_WritePage(outSet))
513 return 0;
514 return 1;
515}

◆ MakeSDDSHeaderSummary()

long MakeSDDSHeaderSummary ( SDDS_DATASET * outSet,
SDDS_DATASET * inSet,
long listRequest,
char * inputFile )

Definition at line 429 of file sddsquery.c.

429 {
430 switch (listRequest) {
431 case SET_COLUMN_LIST:
432 if (!MakeColumnHeaderSummary(outSet, inSet, inputFile))
433 return 0;
434 break;
435 case SET_PARAMETER_LIST:
436 if (!MakeParameterHeaderSummary(outSet, inSet, inputFile))
437 return 0;
438 break;
439 case SET_ARRAY_LIST:
440 if (!MakeArrayHeaderSummary(outSet, inSet, inputFile))
441 return 0;
442 break;
443 default:
444 if (!MakeColumnHeaderSummary(outSet, inSet, inputFile) ||
445 !MakeParameterHeaderSummary(outSet, inSet, inputFile) ||
446 !MakeArrayHeaderSummary(outSet, inSet, inputFile))
447 return 0;
448 break;
449 }
450 return 1;
451}

Variable Documentation

◆ indexDescription

long indexDescription
static

Definition at line 408 of file sddsquery.c.

◆ indexFormat

long indexFormat
static

Definition at line 408 of file sddsquery.c.

◆ indexGroup

long indexGroup
static

Definition at line 408 of file sddsquery.c.

◆ indexName

long indexName
static

Definition at line 408 of file sddsquery.c.

◆ indexSymbol

long indexSymbol
static

Definition at line 408 of file sddsquery.c.

◆ indexType

long indexType
static

Definition at line 408 of file sddsquery.c.

◆ indexUnits

long indexUnits
static

Definition at line 408 of file sddsquery.c.

◆ option

char* option[N_OPTIONS]
Initial value:
= {
"columnlist",
"parameterlist",
"associatelist",
"arraylist",
"delimiter",
"appendunits",
"version",
"pipe",
"sddsoutput",
"readall",
}

Definition at line 38 of file sddsquery.c.

38 {
39 "columnlist",
40 "parameterlist",
41 "associatelist",
42 "arraylist",
43 "delimiter",
44 "appendunits",
45 "version",
46 "pipe",
47 "sddsoutput",
48 "readall",
49};

◆ USAGE

char* USAGE
Initial value:
=
"Usage: sddsquery [OPTIONS] [<SDDSfilename>...]\n"
"\n"
"Options:\n"
" -pipe[=input] Read input from a pipe.\n"
" -sddsOutput[=<filename>] Write SDDS output to a file.\n"
" -arraylist List arrays.\n"
" -associatelist List associates.\n"
" -columnlist List columns.\n"
" -parameterlist List parameters.\n"
" -version Show version information.\n"
" -delimiter=<string> Use <string> as a delimiter.\n"
" -appendunits[=bare] Append units to the output.\n"
" -readAll Read all pages.\n"
"\n"
"Description:\n"
" sddsquery accesses a series of SDDS files and summarizes the file header for each. "
"It also provides lists of arrays, columns, parameters, or associates.\n"
"\n"
"Program by Michael Borland. (" __DATE__ " " __TIME__ ", SVN revision: " SVN_VERSION ")\n"

Definition at line 51 of file sddsquery.c.