72 {
74 long i_arg, tmpfile_used;
75 SCANNED_ARG *s_arg;
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;
80 char buffer[40];
81 short column_major_order = -1;
82
83
85
86
88 if (argc < 2)
90
91
92 input = output = description_text = description_contents = NULL;
93 pipe_flags = 0;
94
95
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--;
103
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;
113 break;
114 case SET_PIPE:
115
117 s_arg[i_arg].n_items - 1, &pipe_flags))
119 break;
120 case NONNATIVE:
121 non_native = 1;
122 break;
123 default:
124
125 fprintf(stderr, "Error (%s): unknown switch: %s\n", argv[0],
126 s_arg[i_arg].list[0]);
127 exit(1);
128 break;
129 }
130 } else {
131
132 if (input == NULL)
133 input = s_arg[i_arg].list[0];
134 else if (output == NULL)
135 output = s_arg[i_arg].list[0];
136 else
138 }
139 }
140
141
143 &tmpfile_used);
144
145
146 output_endianess = getenv("SDDS_OUTPUT_ENDIANESS");
147
148 if (output_endianess) {
149 putenv("SDDS_OUTPUT_ENDIANESS=");
150 }
151
152
155 exit(1);
156 }
157
158
159 if (!description_text)
161
162
165 exit(1);
166 }
167
168
169 if (column_major_order != -1)
170 SDDSout.layout.data_mode.column_major = column_major_order;
171 else
172 SDDSout.layout.data_mode.column_major = SDDSin.layout.data_mode.column_major;
173
174
177 exit(1);
178 }
179
180
181 if (non_native) {
185 exit(1);
186 }
187 }
188 } else {
192 exit(1);
193 }
194 }
195 }
196
197
200 exit(1);
201 }
202
203
205 exit(1);
206
207
208 if (output_endianess) {
209 sprintf(buffer, "SDDS_OUTPUT_ENDIANESS=%s", output_endianess);
210 putenv(buffer);
211 }
212
213 return 0;
214}
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.