73 {
75 long i_arg, tmpfile_used;
76 SCANNED_ARG *s_arg;
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;
81 char buffer[40];
82 short column_major_order = -1;
83
84
86
87
89 if (argc < 2)
91
92
93 input = output = description_text = description_contents = NULL;
94 pipe_flags = 0;
95
96
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--;
104
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;
114 break;
115 case SET_PIPE:
116
118 s_arg[i_arg].n_items - 1, &pipe_flags))
120 break;
121 case NONNATIVE:
122 non_native = 1;
123 break;
124 default:
125
126 fprintf(stderr, "Error (%s): unknown switch: %s\n", argv[0],
127 s_arg[i_arg].list[0]);
128 exit(1);
129 break;
130 }
131 } else {
132
133 if (input == NULL)
134 input = s_arg[i_arg].list[0];
135 else if (output == NULL)
136 output = s_arg[i_arg].list[0];
137 else
139 }
140 }
141
142
144 &tmpfile_used);
145
146
147 output_endianess = getenv("SDDS_OUTPUT_ENDIANESS");
148
149 if (output_endianess) {
150 putenv("SDDS_OUTPUT_ENDIANESS=");
151 }
152
153
156 exit(1);
157 }
158
159
160 if (!description_text)
162
163
166 exit(1);
167 }
168
169
170 if (column_major_order != -1)
171 SDDSout.layout.data_mode.column_major = column_major_order;
172 else
173 SDDSout.layout.data_mode.column_major = SDDSin.layout.data_mode.column_major;
174
175
178 exit(1);
179 }
180
181
182 if (non_native) {
186 exit(1);
187 }
188 }
189 } else {
193 exit(1);
194 }
195 }
196 }
197
198
201 exit(1);
202 }
203
204
206 exit(1);
207
208
209 if (output_endianess) {
210 sprintf(buffer, "SDDS_OUTPUT_ENDIANESS=%s", output_endianess);
211 putenv(buffer);
212 }
213
214 return 0;
215}
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.