File: parser.h

package info (click to toggle)
multipath-tools 0.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,992 kB
  • sloc: ansic: 63,788; perl: 1,622; makefile: 729; sh: 647; pascal: 150
file content (77 lines) | stat: -rw-r--r-- 2,285 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Soft:        Keepalived is a failover program for the LVS project
 *              <www.linuxvirtualserver.org>. It monitor & manipulate
 *              a loadbalanced server pool using multi-layer checks.
 *
 * Part:        cfreader.c include file.
 *
 * Version:     $Id: parser.h,v 1.0.3 2003/05/11 02:28:03 acassen Exp $
 *
 * Author:      Alexandre Cassen, <acassen@linux-vs.org>
 */

#ifndef PARSER_H_INCLUDED
#define PARSER_H_INCLUDED

/* system includes */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <syslog.h>
#include <ctype.h>

/* local includes */
#include "vector.h"
struct strbuf;
struct config;

/* Global definitions */
#define EOB  "}"
#define MAXBUF	1024


/* keyword definition */
typedef int print_fn(struct config *, struct strbuf *, const void *);
typedef int handler_fn(struct config *, vector, const char *file, int line_nr);

struct keyword {
	char *string;
	handler_fn *handler;
	print_fn *print;
	vector sub;
	int unique;
};

/* Reloading helpers */
#define SET_RELOAD      (reload = 1)
#define UNSET_RELOAD    (reload = 0)
#define RELOAD_DELAY    5

/* iterator helper */
#define iterate_sub_keywords(k,p,i) \
	for (i = 0; i < (k)->sub->allocated && ((p) = (k)->sub->slot[i]); i++)

/* Prototypes */
int keyword_alloc(vector keywords, char *string, handler_fn *handler,
		  print_fn *print, int unique);
#define install_keyword_root(str, h) keyword_alloc(keywords, str, h, NULL, 1)
void install_sublevel(void);
void install_sublevel_end(void);

int install_keyword__(vector keywords, char *string, handler_fn *handler,
		      print_fn *print, int unique);
#define install_keyword(str, vec, pri) install_keyword__(keywords, str, vec, pri, 1)
#define install_keyword_multi(str, vec, pri) install_keyword__(keywords, str, vec, pri, 0)
void dump_keywords(vector keydump, int level);
void free_keywords(vector keywords);
vector alloc_strvec(char *string);
void *set_value(vector strvec);
int process_file(struct config *conf, const char *conf_file);
struct keyword * find_keyword(vector keywords, vector v, char * name);
int snprint_keyword(struct strbuf *buff, const char *fmt, struct keyword *kw,
		    const void *data);
bool is_quote(const char* token);

#endif