chiark / gitweb /
Merge branch 'master' of login.chiark.greenend.org.uk:public-git/inn-innduct
[inn-innduct.git] / innfeed / configfile.h
1 /*  $Id: configfile.h 5801 2002-10-07 07:36:12Z rra $
2 **
3 **  Interface to innfeed's configuration file parser.
4 **
5 **  Written by James Brister <brister@vix.com>
6 */
7
8 #if ! defined ( configfile_h__ )
9 #define configfile_h__
10
11 /* Avoid conflicts with parsedate.y's generated yacc code. */
12 #define yy_yyv  innfeed_yy_yyv
13 #define yyact   innfeed_yyact
14 #define yychk   innfeed_yychk
15 #define yydef   innfeed_yydef
16 #define yyexca  innfeed_yyexca
17 #define yylval  innfeed_yylval
18 #define yypact  innfeed_yypact
19 #define yypgo   innfeed_yypgo
20 #define yyr1    innfeed_yyr1
21 #define yyr2    innfeed_yyr2
22 #define yys     innfeed_yys
23 #define yyv     innfeed_yyv
24 #define yyval   innfeed_yyval
25
26 /* pointer to function taking void-star param and returning int. */
27 typedef int (*PFIVP)(void *) ;
28
29 typedef enum { intval, charval, boolval, realval, stringval, scopeval } tag ;
30   
31 typedef struct _scope {
32     struct _value *me ;
33     char *scope_type ;
34     int value_count ;
35     int value_idx ;
36     struct _value **values ;
37     struct _scope *parent ;
38 } scope ;
39
40 typedef struct _value {
41     char *name ;
42     struct _scope *myscope ;
43     tag type ;
44     union {
45         char *charp_val ;
46         char char_val ;
47         double real_val ;
48         int bool_val ;
49         long int_val ;
50         struct _scope *scope_val ;
51     } v ;
52 } value ;
53
54 extern scope *topScope ;
55 extern char *errbuff ;
56
57 int isWord (scope *s, const char *name, int inherit) ;
58 int isName (scope *s, const char *name, int inherit) ;
59
60 int getReal (scope *s, const char *name, double *rval, int inherit) ;
61 int getInteger (scope *s, const char *name, long *rval, int inherit) ;
62 int getBool (scope *s, const char *name, int *rval, int inherit) ;
63 int getString (scope *s, const char *name, char **rval, int inherit) ;
64 int getWord (scope *s, const char *name, char **rval, int inherit) ;
65
66 void freeScopeTree (scope *s) ;
67 char *addInteger (scope *s, const char *name, long val) ;
68 char *addChar (scope *s, const char *name, char val) ;
69 char *addBoolean (scope *s, const char *name, int val) ;
70 char *addName (scope *s, const char *name, char *val) ;
71 char *addWord (scope *s, const char *name, char *val) ;
72 char *addReal (scope *s, const char *name, double val) ;
73 char *addString (scope *s, const char *name, const char *val) ;
74 scope *findScope (scope *s, const char *name, int mustExist) ;
75 value *findValue (scope *s, const char *name, int inherit) ;
76 value *findPeer (const char *name) ;
77 value *getNextPeer (int *cookie) ;
78 void configAddLoadCallback (PFIVP func,void *arg) ;
79 void configRemoveLoadCallback (PFIVP func) ;
80 int readConfig (const char *file, FILE *errorDest, int justCheck, int dump) ;
81 int buildPeerTable (FILE *fp, scope *currScope);
82 void configCleanup (void) ;
83
84 #define ARTICLE_TIMEOUT "article-timeout"
85 #define BACKLOG_LIMIT "backlog-limit"
86 #define INITIAL_CONNECTIONS "initial-connections"
87 #define IP_NAME "ip-name"
88 #define MAX_CONNECTIONS "max-connections"
89 #define MAX_QUEUE_SIZE "max-queue-size"
90 #define NO_CHECK_HIGH "no-check-high"
91 #define NO_CHECK_LOW "no-check-low"
92 #define PORT_NUMBER "port-number"
93 #define RESP_TIMEOUT "response-timeout"
94 #define STREAMING "streaming"
95 #define DROP_DEFERRED "drop-deferred"
96
97 #define ISPEER(V) (ISSCOPE(V) && strcmp ((V)->v.scope_val->scope_type,"peer") == 0)
98 #define ISSCOPE(V) (V->type == scopeval)
99
100 #define INHERIT 1
101 #define NO_INHERIT 0
102
103 /* Interface between lexer and parser. */
104 int yylex (void) ; 
105
106 #endif /* configfile_h__ */