multipath: add '-t' option to dump internal hwtable
[platform/upstream/multipath-tools.git] / libmultipath / parser.h
1 /* 
2  * Soft:        Keepalived is a failover program for the LVS project
3  *              <www.linuxvirtualserver.org>. It monitor & manipulate
4  *              a loadbalanced server pool using multi-layer checks.
5  * 
6  * Part:        cfreader.c include file.
7  *  
8  * Version:     $Id: parser.h,v 1.0.3 2003/05/11 02:28:03 acassen Exp $
9  *
10  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
11  *
12  *              This program is distributed in the hope that it will be useful,
13  *              but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *              MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *              See the GNU General Public License for more details.
16  *
17  *              This program is free software; you can redistribute it and/or
18  *              modify it under the terms of the GNU General Public License
19  *              as published by the Free Software Foundation; either version
20  *              2 of the License, or (at your option) any later version.
21  */
22
23 #ifndef _PARSER_H
24 #define _PARSER_H
25
26 /* system includes */
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <string.h>
30 #include <stdint.h>
31 #include <syslog.h>
32 #include <ctype.h>
33
34 /* local includes */
35 #include "vector.h"
36
37 /* Global definitions */
38 #define EOB  "}"
39 #define MAXBUF  1024
40
41 /* ketword definition */
42 struct keyword {
43         char *string;
44         int (*handler) (vector);
45         int (*print) (char *, int, void *);
46         vector sub;
47         int unique;
48 };
49
50 /* global var exported */
51 FILE *stream;
52
53 /* Reloading helpers */
54 #define SET_RELOAD      (reload = 1)
55 #define UNSET_RELOAD    (reload = 0)
56 #define RELOAD_DELAY    5
57
58 /* iterator helper */
59 #define iterate_sub_keywords(k,p,i) \
60         for (i = 0; i < (k)->sub->allocated && ((p) = (k)->sub->slot[i]); i++)
61
62 /* Prototypes */
63 extern int keyword_alloc(vector keywords, char *string, int (*handler) (vector),
64                          int (*print) (char *, int, void *), int unique);
65 extern int install_keyword_root(char *string, int (*handler) (vector));
66 extern void install_sublevel(void);
67 extern void install_sublevel_end(void);
68 extern int _install_keyword(char *string, int (*handler) (vector),
69                             int (*print) (char *, int, void *), int unique);
70 #define install_keyword(str, vec, pri) _install_keyword(str, vec, pri, 1)
71 #define install_keyword_multi(str, vec, pri) _install_keyword(str, vec, pri, 0)
72 extern void dump_keywords(vector keydump, int level);
73 extern void free_keywords(vector keywords);
74 extern vector alloc_strvec(char *string);
75 extern int read_line(char *buf, int size);
76 extern vector read_value_block(void);
77 extern int alloc_value_block(vector strvec, void (*alloc_func) (vector));
78 extern void *set_value(vector strvec);
79 extern int process_stream(vector keywords);
80 extern int alloc_keywords(void);
81 extern int init_data(char *conf_file, void (*init_keywords) (void));
82 extern struct keyword * find_keyword(vector v, char * name);
83 void set_current_keywords (vector *k);
84 int snprint_keyword(char *buff, int len, char *fmt, struct keyword *kw,
85                     void *data);
86
87 #endif