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 */
ccp4_signal
void ccp4_signal(const int, const char *const, void(*)())
Definition: library_err.c:278
mat4_to_rotandtrn
ccp4_symop mat4_to_rotandtrn(const float rsm[4][4])
Definition: ccp4_parser.c:1564
ccp4_parse_comments
int ccp4_parse_comments(CCP4PARSERARRAY *parsePtr, const char *comment_chars)
Definition: ccp4_parser.c:315
ccp4_utils.h
Utility functions.
ccp4_keymatch
int ccp4_keymatch(const char *keyin1, const char *keyin2)
Definition: ccp4_parser.c:1012
ccp4_parser
int ccp4_parser(char *line, const int nchars, CCP4PARSERARRAY *parser, const int print)
Definition: ccp4_parser.c:742
CCP4PARSERARRAY::token
CCP4PARSERTOKEN * token
Definition: ccp4_parser.h:153
symop_to_mat4
const char * symop_to_mat4(const char *symchs_begin, const char *symchs_end, float *rot)
Definition: ccp4_parser.c:1398
ccp4_parse_comments
int ccp4_parse_comments(CCP4PARSERARRAY *parsePtr, const char *comment_chars)
Definition: ccp4_parser.c:315
ccp4_keymatch
int ccp4_keymatch(const char *keyin1, const char *keyin2)
Definition: ccp4_parser.c:1012
ccp4_parse_maxmin
int ccp4_parse_maxmin(CCP4PARSERARRAY *parsePtr, const double max_exponent, const double min_exponent)
Definition: ccp4_parser.c:363
mat4_to_recip_symop
char * mat4_to_recip_symop(char *symchs_begin, char *symchs_end, const float rsm[4][4])
Definition: ccp4_parser.c:1737
rotandtrn_to_symop
char * rotandtrn_to_symop(char *symchs_begin, char *symchs_end, const ccp4_symop symop)
Definition: ccp4_parser.c:1587
CCP4PARSERARRAY::delim
char * delim
Definition: ccp4_parser.h:157
strtoupper
char * strtoupper(char *str1, const char *str2)
Definition: ccp4_parser.c:1056
CCP4PARSERARRAY::maxtokens
int maxtokens
Definition: ccp4_parser.h:156
CCP4PARSERARRAY::fp
FILE * fp
Definition: ccp4_parser.h:155
symop_to_rotandtrn
ccp4_symop symop_to_rotandtrn(const char *symchs_begin, const char *symchs_end)
Definition: ccp4_parser.c:1356
CCP4PARSERARRAY::min_exponent
double min_exponent
Definition: ccp4_parser.h:161
ccp4_parse_reset
int ccp4_parse_reset(CCP4PARSERARRAY *parsePtr)
Definition: ccp4_parser.c:214
ccp4_parse_end
int ccp4_parse_end(CCP4PARSERARRAY *parsePtr)
Definition: ccp4_parser.c:143
ccp4_utils_malloc
void * ccp4_utils_malloc(size_t)
Definition: library_utils.c:401
strmatch
int strmatch(const char *str1, const char *str2)
Definition: ccp4_parser.c:1094
doublefromstr
int doublefromstr(const char *str, const double max_exp, const double min_exp, double *valuePtr, double *intvaluePtr, int *intdigitsPtr, double *frcvaluePtr, int *frcdigitsPtr, double *expvaluePtr, int *expdigitsPtr)
Definition: ccp4_parser.c:1174
ccp4_parse_reset
int ccp4_parse_reset(CCP4PARSERARRAY *parsePtr)
Definition: ccp4_parser.c:214
ccp4_parse_delimiters
int ccp4_parse_delimiters(CCP4PARSERARRAY *parsePtr, const char *delim, const char *nulldelim)
Definition: ccp4_parser.c:241
rotandtrn_to_mat4
void rotandtrn_to_mat4(float rsm[4][4], const ccp4_symop symop)
Definition: ccp4_parser.c:1599
CCP4PARSERTOKEN::word
char word[5]
Definition: ccp4_parser.h:129
ccp4_parse_start
CCP4PARSERARRAY * ccp4_parse_start(const int maxtokens)
Definition: ccp4_parser.c:71
ccp4_symop
struct ccp4_symop_ ccp4_symop
CCP4PARSERTOKEN
CCP4 Parser token Construct to hold the information about a single token.
Definition: ccp4_parser.h:127
doublefromstr
int doublefromstr(const char *str, const double max_exp, const double min_exp, double *valuePtr, double *intvaluePtr, int *intdigitsPtr, double *frcvaluePtr, int *frcdigitsPtr, double *expvaluePtr, int *expdigitsPtr)
Definition: ccp4_parser.c:1174
ccp4_parse_start
CCP4PARSERARRAY * ccp4_parse_start(const int maxtokens)
Definition: ccp4_parser.c:71
ccp4_parse_delimiters
int ccp4_parse_delimiters(CCP4PARSERARRAY *parsePtr, const char *delim, const char *nulldelim)
Definition: ccp4_parser.c:241
CCP4PARSERTOKEN::isnumber
int isnumber
Definition: ccp4_parser.h:133
ccp4_parser
int ccp4_parser(char *line, const int n, CCP4PARSERARRAY *parser, const int print)
Definition: ccp4_parser.c:742
rotandtrn_to_mat4
void rotandtrn_to_mat4(float rsm[4][4], const ccp4_symop symop)
Definition: ccp4_parser.c:1599
charmatch
int charmatch(const char character, const char *charlist)
Definition: ccp4_parser.c:1124
strtoupper
char * strtoupper(char *str1, const char *str2)
Definition: ccp4_parser.c:1056
CCP4PARSERARRAY::max_exponent
double max_exponent
Definition: ccp4_parser.h:160
mat4_to_symop
char * mat4_to_symop(char *symchs_begin, char *symchs_end, const float rsm[4][4])
Definition: ccp4_parser.c:1625
charmatch
int charmatch(const char character, const char *charlist)
Definition: ccp4_parser.c:1124
ccp4_symop_
Kevin's symmetry operator.
Definition: ccp4_spg.h:48
CCP4PARSERTOKEN::intdigits
int intdigits
Definition: ccp4_parser.h:134
ccp4_parser.h
Functions to read in and "parse" CCP4-style keyworded input.
mat4_to_symop
char * mat4_to_symop(char *symchs_begin, char *symchs_end, const float rsm[4][4])
Definition: ccp4_parser.c:1625
ccp4_parse
int ccp4_parse(const char *line, CCP4PARSERARRAY *parser)
Definition: ccp4_parser.c:411
CCP4PARSERTOKEN::isnull
int isnull
Definition: ccp4_parser.h:139
CCP4PARSERTOKEN::frcdigits
int frcdigits
Definition: ccp4_parser.h:136
ccp4_parse_init_token
int ccp4_parse_init_token(const CCP4PARSERARRAY *parsePtr, const int itok)
Definition: ccp4_parser.c:175
symop_to_mat4
const char * symop_to_mat4(const char *symchs_begin, const char *symchs_end, float *rot)
Definition: ccp4_parser.c:1398
ccp4_parse
int ccp4_parse(const char *line, CCP4PARSERARRAY *parser)
Definition: ccp4_parser.c:411
CCP4PARSERTOKEN::ibeg
int ibeg
Definition: ccp4_parser.h:140
CCP4PARSERTOKEN::value
double value
Definition: ccp4_parser.h:130
ccp4_parse_init_token
int ccp4_parse_init_token(const CCP4PARSERARRAY *parsePtr, const int itok)
Definition: ccp4_parser.c:175
ccp4_symop_::trn
float trn[3]
Definition: ccp4_spg.h:51
ccp4_sysdep.h
System-dependent definitions.
CCP4PARSERTOKEN::strlength
int strlength
Definition: ccp4_parser.h:132
CCP4PARSERTOKEN::fullstring
char * fullstring
Definition: ccp4_parser.h:128
mat4_to_rotandtrn
ccp4_symop mat4_to_rotandtrn(const float rsm[4][4])
Definition: ccp4_parser.c:1564
symop_to_rotandtrn
ccp4_symop symop_to_rotandtrn(const char *symchs_begin, const char *symchs_end)
Definition: ccp4_parser.c:1356
CCP4PARSERARRAY::nulldelim
char * nulldelim
Definition: ccp4_parser.h:158
CCP4PARSERARRAY
CCP4 Parser array Construct to hold the information about a parsed line.
Definition: ccp4_parser.h:149
ccp4_spg.h
Data structure for symmetry information.
ccp4_parse_maxmin
int ccp4_parse_maxmin(CCP4PARSERARRAY *parsePtr, const double max_exponent, const double min_exponent)
Definition: ccp4_parser.c:363
CCP4PARSERTOKEN::isquoted
int isquoted
Definition: ccp4_parser.h:138
ccp4_errno.h
Header file for error handling routines Error codes based on system errors.
strtolower
char * strtolower(char *str1, const char *str2)
Definition: ccp4_parser.c:1076
CCP4PARSERTOKEN::isstring
int isstring
Definition: ccp4_parser.h:131
CCP4PARSERARRAY::comment
char * comment
Definition: ccp4_parser.h:159
CCP4PARSERTOKEN::iend
int iend
Definition: ccp4_parser.h:141
strtolower
char * strtolower(char *str1, const char *str2)
Definition: ccp4_parser.c:1076
CCP4PARSERARRAY::keyword
char keyword[5]
Definition: ccp4_parser.h:151
ccp4_parse_end
int ccp4_parse_end(CCP4PARSERARRAY *parsePtr)
Definition: ccp4_parser.c:143
strmatch
int strmatch(const char *str1, const char *str2)
Definition: ccp4_parser.c:1094
CCP4PARSERARRAY::ntokens
int ntokens
Definition: ccp4_parser.h:152
mat4_to_recip_symop
char * mat4_to_recip_symop(char *symchs_begin, char *symchs_end, const float rsm[4][4])
Definition: ccp4_parser.c:1737
ccp4_symop_::rot
float rot[3][3]
Definition: ccp4_spg.h:50
rotandtrn_to_symop
char * rotandtrn_to_symop(char *symchs_begin, char *symchs_end, const ccp4_symop symop)
Definition: ccp4_parser.c:1587