configglue.h 1.5 KB
Newer Older
Philip Carns's avatar
Philip Carns committed
1 2 3 4 5 6
/*
 * Copyright (C) 2013 University of Chicago.
 * See COPYRIGHT notice in top-level directory.
 *
 */

7 8 9 10 11
#ifndef SRC_COMMON_MODELCONFIG_CONFIGGLUE_H
#define SRC_COMMON_MODELCONFIG_CONFIGGLUE_H

/* Common header for parser and lexer */

12
#include <codes/configfile.h>
13 14 15 16


typedef struct
{
17
   struct ConfigVTable * configfile;
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

   SectionHandle sectionstack [20];
   unsigned int stacktop;

   /* used to construct a multival key */
   struct 
   { 
            char ** keyvals;
            unsigned int count;
            unsigned int maxsize;
   }; 

   int                  parser_error_code;

   /* if error_code != 0 the user needs to free error_string */
   char *               parser_error_string;
   int                  lexer_error_code;
   char *               lexer_error_string;
} ParserParams;

38
void cfgp_initparams (ParserParams * p, struct ConfigVTable * h);
39

40
/* Free private data (but not the ConfigVTable) */
41 42 43 44 45 46 47 48
void cfgp_freeparams (ParserParams * p);

int cfgp_parser_error (ParserParams * p, const char* str, 
      unsigned int l1, unsigned int c1, unsigned int l2, unsigned int c2);

int cfgp_lex_error (ParserParams * p, int lineno, int colno, const char * msg); 

/* Return true if parse and lex went ok; false otherwise, and puts
49
 * error message in buf. Note: ConfigVTable might still contain the partial 
50 51 52 53
 * parsed tree */
int cfgp_parse_ok (const ParserParams * p, char * buf, int bufsize);

#endif
Philip Carns's avatar
Philip Carns committed
54 55 56 57 58 59 60 61 62

/*
 * Local variables:
 *  c-indent-level: 4
 *  c-basic-offset: 4
 * End:
 *
 * vim: ts=8 sts=4 sw=4 expandtab
 */