gpp4  1.3.1
CParser library

File list

Overview

These functions do CCP4-style parsing, as used for processing keywords of CCP4 programs, MTZ header records, etc.

Usage

The following code snippets illustrate how the functions might be used to read from stdin:

int ntok=0;
char line[201],*key;
CCP4PARSERTOKEN * token=NULL;
CCP4PARSERARRAY * parser;
key = parser->keyword;
token = parser->token;
RC = 0;
while (!RC) {
line[0] = '\0';
ntok = ccp4_parser(line,200,parser,1);
if (ntok < 1) {
RC = 111;
} else {
if (ccp4_keymatch("MINDIST",key)) {
if (ntok != 2) {
ccperror ( 1,"MINDIST requires a single numerical argument" );
RC = -100;
} else {
minDist = token[1].value;
}
} else {
printf ( "Unrecognised keyword \"%s\"\n",token[0].fullstring );
RC = -118;
}
}
}
ccp4_parse_end ( parser );

Examples

See the distributed programs NCONT and PDBCUR.

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
ccp4_keymatch
int ccp4_keymatch(const char *keyin1, const char *keyin2)
Definition: ccp4_parser.c:1012
ccperror
int ccperror(int ierr, const char *message)
Definition: ccp4_general.c:67
CCP4PARSERTOKEN
CCP4 Parser token Construct to hold the information about a single token.
Definition: ccp4_parser.h:127
ccp4_parse_start
CCP4PARSERARRAY * ccp4_parse_start(const int maxtokens)
Definition: ccp4_parser.c:71
CCP4PARSERTOKEN::value
double value
Definition: ccp4_parser.h:130
CCP4PARSERARRAY
CCP4 Parser array Construct to hold the information about a parsed line.
Definition: ccp4_parser.h:149
CCP4PARSERARRAY::keyword
char keyword[5]
Definition: ccp4_parser.h:151
ccp4_parse_end
int ccp4_parse_end(CCP4PARSERARRAY *parsePtr)
Definition: ccp4_parser.c:143