blob: c5777f98b630a24d62ae69fac009290836993aa1 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
Willy Tarreau2dd0d472006-06-29 17:53:05 +02002 include/common/cfgparse.h
Willy Tarreaubaaee002006-06-26 02:48:02 +02003 Configuration parsing functions.
4
Willy Tarreau5b2c3362008-07-09 19:39:06 +02005 Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu
Willy Tarreaubaaee002006-06-26 02:48:02 +02006
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation, version 2.1
10 exclusively.
11
12 This library 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. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/
21
Willy Tarreau2dd0d472006-06-29 17:53:05 +020022#ifndef _COMMON_CFGPARSE_H
23#define _COMMON_CFGPARSE_H
Willy Tarreaubaaee002006-06-26 02:48:02 +020024
Willy Tarreau5b2c3362008-07-09 19:39:06 +020025#include <common/compat.h>
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020026#include <common/config.h>
Willy Tarreau5b2c3362008-07-09 19:39:06 +020027#include <common/mini-clist.h>
28
29#include <types/proxy.h>
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020030
Willy Tarreaubaaee002006-06-26 02:48:02 +020031/* configuration sections */
32#define CFG_NONE 0
33#define CFG_GLOBAL 1
34#define CFG_LISTEN 2
35
Willy Tarreau5b2c3362008-07-09 19:39:06 +020036struct cfg_keyword {
37 int section; /* section type for this keyword */
38 const char *kw; /* the keyword itself */
39 int (*parse)(char **args, /* command line and arguments */
40 int section_type, /* current section CFG_{GLOBAL|LISTEN} */
41 struct proxy *curpx, /* current proxy (NULL in GLOBAL) */
42 struct proxy *defpx, /* default proxy (NULL in GLOBAL) */
43 char *err, /* error message buffer (do not add '\n') */
44 int errlen); /* error buffer size, '\0' included */
45};
46
47/* A keyword list. It is a NULL-terminated array of keywords. It embeds a
48 * struct list in order to be linked to other lists, allowing it to easily
49 * be declared where it is needed, and linked without duplicating data nor
50 * allocating memory.
51 */
52struct cfg_kw_list {
53 struct list list;
54 struct cfg_keyword kw[VAR_ARRAY];
55};
56
57
Willy Tarreaubaaee002006-06-26 02:48:02 +020058extern int cfg_maxpconn;
59extern int cfg_maxconn;
60
Krzysztof Oledzki336d4752007-12-25 02:40:22 +010061int cfg_parse_global(const char *file, int linenum, char **args, int inv);
62int cfg_parse_listen(const char *file, int linenum, char **args, int inv);
Willy Tarreaub17916e2006-10-15 15:17:57 +020063int readcfgfile(const char *file);
Willy Tarreau5b2c3362008-07-09 19:39:06 +020064void cfg_register_keywords(struct cfg_kw_list *kwl);
65void cfg_unregister_keywords(struct cfg_kw_list *kwl);
Willy Tarreaubaaee002006-06-26 02:48:02 +020066
Willy Tarreau2dd0d472006-06-29 17:53:05 +020067#endif /* _COMMON_CFGPARSE_H */
Willy Tarreaubaaee002006-06-26 02:48:02 +020068
69/*
70 * Local variables:
71 * c-indent-level: 8
72 * c-basic-offset: 8
73 * End:
74 */