170
170
/* Core cparser functions */
172
/** Initialise a CCP4PARSERARRAY to be used in subsequent calls to
173
* ccp4_parser routines. The calling function must supply the maximum
174
* number of tokens on a line (including continuation lines).
175
* @param maxtokens maximum number of tokens on a line
176
* @return pointer to a new CCP4PARSERARRAY structure
172
178
CCP4PARSERARRAY* ccp4_parse_start(const int maxtokens);
180
/** Cleans up a CCP4PARSEARRAY after being used by ccp4_parse/
181
ccp4_parser functions.
182
* @param parsePtr pointer to a CCP4PARSERARRAY structure
183
* @return 0 on completion
173
185
int ccp4_parse_end(CCP4PARSERARRAY *parsePtr);
174
187
int ccp4_parse_init_token(const CCP4PARSERARRAY *parsePtr, const int itok);
175
189
int ccp4_parse_delimiters(CCP4PARSERARRAY *parsePtr, const char *delim,
176
190
const char *nulldelim);
177
191
int ccp4_parse_comments(CCP4PARSERARRAY *parsePtr, const char *comment_chars);
178
193
int ccp4_parse_maxmin(CCP4PARSERARRAY *parsePtr, const double max_exponent,
179
194
const double min_exponent);
180
195
int ccp4_parse_reset(CCP4PARSERARRAY *parsePtr);
181
197
int ccp4_parse(const char *line, CCP4PARSERARRAY *parser);
199
/** The main function for parsing lines, either supplied or read
201
* @param line pointer to a null-terminated string of characters,
202
* forming the input to be processed. On input can either be an empty
203
* string ("") which forces reading from stdin, or contain characters
204
* to be processed. On output "line" will be overwritten with the actual
206
* @param n maximum number of characters that can be read into
207
* "line" i.e. the size of "line" in memory.
208
* @param parser pointer to a CCP4PARSERARRAY structure which will
209
* be used to hold the results of processing the input line.
210
* @param print flag controlling echoing of input lines to stdout.
211
* print=0: suppress echoing of lines to stdout. Otherwise echoing is
213
* @return Number of tokens found.
182
215
int ccp4_parser(char *line, const int n, CCP4PARSERARRAY *parser,
183
216
const int print);
185
218
/* External utility functions */
220
/** Test whether two keywords are identical. Keywords are identical if
221
* they are the same up to the first four characters, independent of case.
222
* @param keyin1 keyword 1.
223
* @param keyin2 keyword 2.
224
* @return 1 if keywords keyin1 and keyin2 are "identical", 0 otherwise.
187
226
int ccp4_keymatch(const char *keyin1, const char *keyin2);
189
228
/* Internal utility functions */
230
/** Convert string to uppercase.
231
* @param str1 On exit str1 will contain uppercased copy of str2
232
* @param str2 Input string
191
235
char *strtoupper (char *str1, const char *str2);
192
237
char *strtolower (char *str1, const char *str2);
193
239
int strmatch (const char *str1, const char *str2);
194
241
int charmatch(const char character, const char *charlist);
195
243
int doublefromstr(const char *str, const double max_exp, const double min_exp,
196
244
double *valuePtr, double *intvaluePtr, int *intdigitsPtr,
197
245
double *frcvaluePtr, int *frcdigitsPtr,
198
246
double *expvaluePtr, int *expdigitsPtr);
248
/** Convert symmetry operator as string to ccp4_symop struct.
249
* @param symchs_begin pointer to beginning of string
250
* @param symchs_end pointer to end of string (i.e. last character
251
* is *(symchs_end-1) )
252
* @return pointer to ccp4_symop struct
200
254
ccp4_symop symop_to_rotandtrn(const char *symchs_begin, const char *symchs_end);
256
/** Convert symmetry operator as string to matrix.
257
* This is Charles' version of symfr. Note that translations
258
* are held in elements [*][3] and [3][3] is set to 1.0
259
* @param symchs_begin pointer to beginning of string
260
* @param symchs_end pointer to end of string (i.e. last character
261
* is *(symchs_end-1) )
262
* @param rot 4 x 4 matrix operator
263
* @return NULL on error, final position pointer on success
201
265
const char * symop_to_mat4(const char *symchs_begin, const char *symchs_end, float *rot);
202
static int symop_to_mat4_err(const char *symop);
268
int symop_to_mat4_err(const char *symop);
203
270
ccp4_symop mat4_to_rotandtrn(const float rsm[4][4]);
272
/* This is Charles' version of symtr */
204
273
char *rotandtrn_to_symop(char *symchs_begin, char *symchs_end, const ccp4_symop symop);
205
275
void rotandtrn_to_mat4(float rsm[4][4], const ccp4_symop symop);
277
/** Convert symmetry operator as matrix to string.
278
* This is Charles' version of symtr. Note that translations
279
* are held in elements [*][3] and [3][3] is set to 1.0
280
* @param symchs_begin pointer to beginning of string
281
* @param symchs_end pointer to end of string (i.e. last character
282
* is *(symchs_end-1) )
283
* @param rsm 4 x 4 matrix operator
284
* @return pointer to beginning of string
206
286
char *mat4_to_symop(char *symchs_begin, char *symchs_end, const float rsm[4][4]);
288
/** Convert symmetry operator as matrix to string in reciprocal space notation.
289
* This is Charles' version of symtr. Note that translations
290
* are held in elements [*][3] and [3][3] is set to 1.0
291
* @param symchs_begin pointer to beginning of string
292
* @param symchs_end pointer to end of string (i.e. last character
293
* is *(symchs_end-1) )
294
* @param rsm 4 x 4 matrix operator
295
* @return pointer to beginning of string
207
297
char *mat4_to_recip_symop(char *symchs_begin, char *symchs_end, const float rsm[4][4]);
209
299
#ifdef __cplusplus