gpp4  1.3.1
ccp4_parser.h
Go to the documentation of this file.
1 /*
2  ccp4_parser.h: Headers for functions to read in and "parse" CCP4
3  keyworded input.
4  Copyright (C) 2001 CCLRC, Peter Briggs
5 
6  This library is free software: you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation, either
9  version 3 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with This library. If not, see
18  <http://www.gnu.org/licenses/>.
19 
20 */
21 
93 /* Macro definitions */
94 
95 
96 #ifndef __CCP4_Parser__
97 #define __CCP4_Parser__
98 
99 
100 /* note order: these must be outside CCP4 namespace */
101 #include <stdio.h>
102 #include"ccp4_utils.h"
103 #include"ccp4_spg.h"
104 
105 /* Macro to make C functions callable from C++ */
106 #ifdef __cplusplus
107 namespace CCP4 {
108 extern "C" {
110 #endif
111 
112 
113 /* Parser String Sizes */
114 
115 #define CCP4_PARSER_MAXLINELENGTH 200
116 #define CCP4_PARSER_MAXFILENAMELENGTH 200
119 /* Structures and typedefs */
120 
121 
127 typedef struct {
128  char *fullstring;
129  char word[5];
130  double value;
131  int isstring;
132  int strlength;
133  int isnumber;
134  int intdigits;
136  int frcdigits;
138  int isquoted;
139  int isnull;
140  int ibeg;
141  int iend;
142 } CCP4PARSERTOKEN;
149 typedef struct {
150  /* "Public" members */
151  char keyword[5];
152  int ntokens;
154  /* "Private" members */
155  FILE *fp;
156  int maxtokens;
157  char *delim;
158  char *nulldelim;
159  char *comment;
160  double max_exponent;
161  double min_exponent;
162 } CCP4PARSERARRAY;
165 /* Function Prototypes */
166 
167 
168 /* Core cparser functions */
169 
176 CCP4PARSERARRAY* ccp4_parse_start(const int maxtokens);
177 
183 int ccp4_parse_end(CCP4PARSERARRAY *parsePtr);
184 
185 int ccp4_parse_init_token(const CCP4PARSERARRAY *parsePtr, const int itok);
186 
187 int ccp4_parse_delimiters(CCP4PARSERARRAY *parsePtr, const char *delim,
188  const char *nulldelim);
189 int ccp4_parse_comments(CCP4PARSERARRAY *parsePtr, const char *comment_chars);
190 
191 int ccp4_parse_maxmin(CCP4PARSERARRAY *parsePtr, const double max_exponent,
192  const double min_exponent);
193 int ccp4_parse_reset(CCP4PARSERARRAY *parsePtr);
194 
195 int ccp4_parse(const char *line, CCP4PARSERARRAY *parser);
196 
213 int ccp4_parser(char *line, const int n, CCP4PARSERARRAY *parser,
214  const int print);
215 
216 /* External utility functions */
217 
224 int ccp4_keymatch(const char *keyin1, const char *keyin2);
225 
226 /* Internal utility functions */
227 
233 char *strtoupper (char *str1, const char *str2);
234 
235 char *strtolower (char *str1, const char *str2);
236 
237 int strmatch (const char *str1, const char *str2);
238 
239 int charmatch(const char character, const char *charlist);
240 
241 int doublefromstr(const char *str, const double max_exp, const double min_exp,
242  double *valuePtr, double *intvaluePtr, int *intdigitsPtr,
243  double *frcvaluePtr, int *frcdigitsPtr,
244  double *expvaluePtr, int *expdigitsPtr);
245 
252 ccp4_symop symop_to_rotandtrn(const char *symchs_begin, const char *symchs_end);
253 
263 const char * symop_to_mat4(const char *symchs_begin, const char *symchs_end, float *rot);
264 
265  /*
266 int symop_to_mat4_err(const char *symop);
267  */
268 
269 ccp4_symop mat4_to_rotandtrn(const float rsm[4][4]);
270 
271 /* This is Charles' version of symtr */
272 char *rotandtrn_to_symop(char *symchs_begin, char *symchs_end, const ccp4_symop symop);
273 
274 void rotandtrn_to_mat4(float rsm[4][4], const ccp4_symop symop);
275 
285 char *mat4_to_symop(char *symchs_begin, char *symchs_end, const float rsm[4][4]);
286 
296 char *mat4_to_recip_symop(char *symchs_begin, char *symchs_end, const float rsm[4][4]);
297 
298 #ifdef __cplusplus
299 }
300 }
301 #endif
302 
303 #endif /* __CCP4_Parser__ */
304 
305 /*
306  Local variables:
307  mode: font-lock
308  End:
309 */