blob: dcc40036220432ed296c7a013f851e1d372c32f8 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
Willy Tarreau0a3dd742012-05-08 19:47:01 +02002 * include/common/cfgparse.h
3 * Configuration parsing functions.
4 *
5 * Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu
6 *
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 */
Willy Tarreaubaaee002006-06-26 02:48:02 +020021
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
Krzysztof Piotr Oledzki96105042010-01-29 17:50:44 +010035#define CFG_USERLIST 3
Emeric Brun32da3c42010-09-23 18:39:19 +020036#define CFG_PEERS 4
Willy Tarreaubaaee002006-06-26 02:48:02 +020037
Willy Tarreau5b2c3362008-07-09 19:39:06 +020038struct cfg_keyword {
39 int section; /* section type for this keyword */
40 const char *kw; /* the keyword itself */
Willy Tarreau39f23b62008-07-09 20:22:56 +020041 int (*parse)( /* 0=OK, <0=Alert, >0=Warning */
42 char **args, /* command line and arguments */
Willy Tarreau5b2c3362008-07-09 19:39:06 +020043 int section_type, /* current section CFG_{GLOBAL|LISTEN} */
44 struct proxy *curpx, /* current proxy (NULL in GLOBAL) */
45 struct proxy *defpx, /* default proxy (NULL in GLOBAL) */
Willy Tarreau28a47d62012-09-18 20:02:48 +020046 const char *file, /* config file name */
47 int line, /* config file line number */
Willy Tarreau0a3dd742012-05-08 19:47:01 +020048 char **err); /* error or warning message output pointer */
Willy Tarreau5b2c3362008-07-09 19:39:06 +020049};
50
51/* A keyword list. It is a NULL-terminated array of keywords. It embeds a
52 * struct list in order to be linked to other lists, allowing it to easily
53 * be declared where it is needed, and linked without duplicating data nor
54 * allocating memory.
55 */
56struct cfg_kw_list {
57 struct list list;
58 struct cfg_keyword kw[VAR_ARRAY];
59};
60
61
Willy Tarreaubaaee002006-06-26 02:48:02 +020062extern int cfg_maxpconn;
63extern int cfg_maxconn;
64
Krzysztof Oledzki336d4752007-12-25 02:40:22 +010065int cfg_parse_global(const char *file, int linenum, char **args, int inv);
66int cfg_parse_listen(const char *file, int linenum, char **args, int inv);
Willy Tarreaub17916e2006-10-15 15:17:57 +020067int readcfgfile(const char *file);
Willy Tarreau5b2c3362008-07-09 19:39:06 +020068void cfg_register_keywords(struct cfg_kw_list *kwl);
69void cfg_unregister_keywords(struct cfg_kw_list *kwl);
Willy Tarreau915e1eb2009-06-22 15:48:36 +020070void init_default_instance();
71int check_config_validity();
Willy Tarreau4fbb2282012-09-20 20:01:39 +020072int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf, const char *file, int line, char **err);
Willy Tarreaubaaee002006-06-26 02:48:02 +020073
Willy Tarreau2dd0d472006-06-29 17:53:05 +020074#endif /* _COMMON_CFGPARSE_H */
Willy Tarreaubaaee002006-06-26 02:48:02 +020075
76/*
77 * Local variables:
78 * c-indent-level: 8
79 * c-basic-offset: 8
80 * End:
81 */