58char *
USAGE =
"Usage: sddsendian [options] <input> <output>\n\
60 -pipe=[input][,output] Use pipe for input and/or output.\n\
61 -majorOrder=row|column Set the major order to row or column.\n\
62 -nonNative Handle non-native byte order files.\n\
64 Converts between big-endian and little-endian formats.\n\
65 This program is designed to handle Self-Describing Data Sets (SDDS)\n\
66 efficiently, allowing for platform-independent data sharing.\n\
68 Michael Borland and Robert Soliday\n\
70 Link date: " __DATE__
" " __TIME__
", SVN revision: " SVN_VERSION
"\n";
72int main(
int argc,
char **argv) {
74 long i_arg, tmpfile_used;
76 char *input, *output, *description_text, *description_contents;
77 unsigned long pipe_flags, major_order_flag;
78 long page_number, non_native = 0;
79 char *output_endianess = NULL;
81 short column_major_order = -1;
92 input = output = description_text = description_contents = NULL;
96 for (i_arg = 1; i_arg < argc; i_arg++) {
97 if (s_arg[i_arg].arg_type == OPTION) {
100 case SET_MAJOR_ORDER:
101 major_order_flag = 0;
102 s_arg[i_arg].n_items--;
104 if (s_arg[i_arg].n_items > 0 && (!
scanItemList(&major_order_flag, s_arg[i_arg].list + 1,
105 &s_arg[i_arg].n_items, 0,
"row", -1, NULL, 0,
106 SDDS_ROW_MAJOR_ORDER,
"column", -1, NULL, 0,
107 SDDS_COLUMN_MAJOR_ORDER, NULL)))
108 SDDS_Bomb(
"invalid -majorOrder syntax/values");
109 if (major_order_flag & SDDS_COLUMN_MAJOR_ORDER)
110 column_major_order = 1;
111 else if (major_order_flag & SDDS_ROW_MAJOR_ORDER)
112 column_major_order = 0;
117 s_arg[i_arg].n_items - 1, &pipe_flags))
125 fprintf(stderr,
"Error (%s): unknown switch: %s\n", argv[0],
126 s_arg[i_arg].list[0]);
133 input = s_arg[i_arg].list[0];
134 else if (output == NULL)
135 output = s_arg[i_arg].list[0];
146 output_endianess = getenv(
"SDDS_OUTPUT_ENDIANESS");
148 if (output_endianess) {
149 putenv(
"SDDS_OUTPUT_ENDIANESS=");
159 if (!description_text)
169 if (column_major_order != -1)
170 SDDSout.layout.data_mode.column_major = column_major_order;
172 SDDSout.layout.data_mode.column_major = SDDSin.layout.data_mode.column_major;
208 if (output_endianess) {
209 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.