50char *option[N_OPTIONS] = {
56char *USAGE =
"sddsendian [<input>] [<output>]\n\
57 [-pipe=[input][,output]]\n\
59 [-majorOrder=row|column]\n\
61 -pipe=[input][,output] Use pipe for input and/or output.\n\
62 -majorOrder=row|column Set the major order to row or column.\n\
63 -nonNative Handle non-native byte order files.\n\
65 Converts between big-endian and little-endian formats.\n\
66 This program is designed to handle Self-Describing Data Sets (SDDS)\n\
67 efficiently, allowing for platform-independent data sharing.\n\
69 Michael Borland and Robert Soliday\n\
71 Link date: " __DATE__
" " __TIME__
", SVN revision: " SVN_VERSION
"\n";
73int main(
int argc,
char **argv) {
75 long i_arg, tmpfile_used;
77 char *input, *output, *description_text, *description_contents;
78 unsigned long pipe_flags, major_order_flag;
79 long page_number, non_native = 0;
80 char *output_endianess = NULL;
82 short column_major_order = -1;
93 input = output = description_text = description_contents = NULL;
97 for (i_arg = 1; i_arg < argc; i_arg++) {
98 if (s_arg[i_arg].arg_type == OPTION) {
100 switch (
match_string(s_arg[i_arg].list[0], option, N_OPTIONS, 0)) {
101 case SET_MAJOR_ORDER:
102 major_order_flag = 0;
103 s_arg[i_arg].n_items--;
105 if (s_arg[i_arg].n_items > 0 && (!
scanItemList(&major_order_flag, s_arg[i_arg].list + 1,
106 &s_arg[i_arg].n_items, 0,
"row", -1, NULL, 0,
107 SDDS_ROW_MAJOR_ORDER,
"column", -1, NULL, 0,
108 SDDS_COLUMN_MAJOR_ORDER, NULL)))
109 SDDS_Bomb(
"invalid -majorOrder syntax/values");
110 if (major_order_flag & SDDS_COLUMN_MAJOR_ORDER)
111 column_major_order = 1;
112 else if (major_order_flag & SDDS_ROW_MAJOR_ORDER)
113 column_major_order = 0;
118 s_arg[i_arg].n_items - 1, &pipe_flags))
126 fprintf(stderr,
"Error (%s): unknown switch: %s\n", argv[0],
127 s_arg[i_arg].list[0]);
134 input = s_arg[i_arg].list[0];
135 else if (output == NULL)
136 output = s_arg[i_arg].list[0];
147 output_endianess = getenv(
"SDDS_OUTPUT_ENDIANESS");
149 if (output_endianess) {
150 putenv(
"SDDS_OUTPUT_ENDIANESS=");
160 if (!description_text)
170 if (column_major_order != -1)
171 SDDSout.layout.data_mode.column_major = column_major_order;
173 SDDSout.layout.data_mode.column_major = SDDSin.layout.data_mode.column_major;
209 if (output_endianess) {
210 sprintf(buffer,
"SDDS_OUTPUT_ENDIANESS=%s", output_endianess);
SDDS (Self Describing Data Set) Data Types Definitions and Function Prototypes.
int32_t SDDS_WriteNonNativeBinaryPage(SDDS_DATASET *SDDS_dataset)
Writes a non-native endian binary page to an SDDS dataset.
int32_t SDDS_ReadNonNativePage(SDDS_DATASET *SDDS_dataset)
Reads a non-native endian page from an SDDS dataset.
int32_t SDDS_InitializeCopy(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source, char *filename, char *filemode)
int32_t SDDS_CopyPage(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
int32_t SDDS_WritePage(SDDS_DATASET *SDDS_dataset)
Writes the current data table to the output file.
int32_t SDDS_WriteLayout(SDDS_DATASET *SDDS_dataset)
Writes the SDDS layout header to the output file.
int32_t SDDS_SetDataMode(SDDS_DATASET *SDDS_dataset, int32_t newmode)
Sets the data mode (ASCII or Binary) for the SDDS dataset.
void SDDS_PrintErrors(FILE *fp, int32_t mode)
Prints recorded error messages to a specified file stream.
void SDDS_RegisterProgramName(const char *name)
Registers the executable program name for use in error messages.
void SDDS_Bomb(char *message)
Terminates the program after printing an error message and recorded errors.
void bomb(char *error, char *usage)
Reports error messages to the terminal and aborts the program.
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.
long replaceFileAndBackUp(char *file, char *replacement)
Replaces a file with a replacement file and creates a backup of the original.
int scanargs(SCANNED_ARG **scanned, int argc, char **argv)
long processPipeOption(char **item, long items, unsigned long *flags)
void processFilenames(char *programName, char **input, char **output, unsigned long pipeFlags, long noWarnings, long *tmpOutputUsed)
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.