Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 1 | /* |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 2 | include/common/cfgparse.h |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 3 | Configuration parsing functions. |
| 4 | |
Willy Tarreau | 5b2c336 | 2008-07-09 19:39:06 +0200 | [diff] [blame] | 5 | Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 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 | */ |
| 21 | |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 22 | #ifndef _COMMON_CFGPARSE_H |
| 23 | #define _COMMON_CFGPARSE_H |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 24 | |
Willy Tarreau | 5b2c336 | 2008-07-09 19:39:06 +0200 | [diff] [blame] | 25 | #include <common/compat.h> |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 26 | #include <common/config.h> |
Willy Tarreau | 5b2c336 | 2008-07-09 19:39:06 +0200 | [diff] [blame] | 27 | #include <common/mini-clist.h> |
| 28 | |
| 29 | #include <types/proxy.h> |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 30 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 31 | /* configuration sections */ |
| 32 | #define CFG_NONE 0 |
| 33 | #define CFG_GLOBAL 1 |
| 34 | #define CFG_LISTEN 2 |
| 35 | |
Willy Tarreau | 5af24ef | 2009-03-15 15:23:16 +0100 | [diff] [blame] | 36 | /* list of overlapping ACL rules that we can detect */ |
| 37 | enum { |
| 38 | CFG_ACL_TCP = 1, |
| 39 | CFG_ACL_BLOCK = 2, |
| 40 | CFG_ACL_REDIR = 4, |
| 41 | CFG_ACL_BACKEND = 8, |
| 42 | }; |
| 43 | |
Willy Tarreau | 5b2c336 | 2008-07-09 19:39:06 +0200 | [diff] [blame] | 44 | struct cfg_keyword { |
| 45 | int section; /* section type for this keyword */ |
| 46 | const char *kw; /* the keyword itself */ |
Willy Tarreau | 39f23b6 | 2008-07-09 20:22:56 +0200 | [diff] [blame] | 47 | int (*parse)( /* 0=OK, <0=Alert, >0=Warning */ |
| 48 | char **args, /* command line and arguments */ |
Willy Tarreau | 5b2c336 | 2008-07-09 19:39:06 +0200 | [diff] [blame] | 49 | int section_type, /* current section CFG_{GLOBAL|LISTEN} */ |
| 50 | struct proxy *curpx, /* current proxy (NULL in GLOBAL) */ |
| 51 | struct proxy *defpx, /* default proxy (NULL in GLOBAL) */ |
| 52 | char *err, /* error message buffer (do not add '\n') */ |
| 53 | int errlen); /* error buffer size, '\0' included */ |
| 54 | }; |
| 55 | |
| 56 | /* A keyword list. It is a NULL-terminated array of keywords. It embeds a |
| 57 | * struct list in order to be linked to other lists, allowing it to easily |
| 58 | * be declared where it is needed, and linked without duplicating data nor |
| 59 | * allocating memory. |
| 60 | */ |
| 61 | struct cfg_kw_list { |
| 62 | struct list list; |
| 63 | struct cfg_keyword kw[VAR_ARRAY]; |
| 64 | }; |
| 65 | |
| 66 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 67 | extern int cfg_maxpconn; |
| 68 | extern int cfg_maxconn; |
Willy Tarreau | 5af24ef | 2009-03-15 15:23:16 +0100 | [diff] [blame] | 69 | extern unsigned int acl_seen; /* CFG_ACL_* for current proxy being parsed */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 70 | |
Krzysztof Oledzki | 336d475 | 2007-12-25 02:40:22 +0100 | [diff] [blame] | 71 | int cfg_parse_global(const char *file, int linenum, char **args, int inv); |
| 72 | int cfg_parse_listen(const char *file, int linenum, char **args, int inv); |
Willy Tarreau | b17916e | 2006-10-15 15:17:57 +0200 | [diff] [blame] | 73 | int readcfgfile(const char *file); |
Willy Tarreau | 5b2c336 | 2008-07-09 19:39:06 +0200 | [diff] [blame] | 74 | void cfg_register_keywords(struct cfg_kw_list *kwl); |
| 75 | void cfg_unregister_keywords(struct cfg_kw_list *kwl); |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 76 | |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 77 | #endif /* _COMMON_CFGPARSE_H */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 78 | |
| 79 | /* |
| 80 | * Local variables: |
| 81 | * c-indent-level: 8 |
| 82 | * c-basic-offset: 8 |
| 83 | * End: |
| 84 | */ |