Thierry FOURNIER | 4b5e422 | 2013-11-22 17:40:18 +0100 | [diff] [blame] | 1 | /* |
| 2 | * include/types/map.h |
| 3 | * This file provides structures and types for MAPs. |
| 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 | */ |
| 21 | |
| 22 | #ifndef _TYPES_MAP_H |
| 23 | #define _TYPES_MAP_H |
| 24 | |
| 25 | #include <types/acl.h> |
| 26 | |
| 27 | /* These structs contains a string representation of the map. These struct is |
| 28 | * sorted by file. Permit to hot-add and hot-remove entries. |
| 29 | * |
| 30 | * "maps" is the list head. This list cotains all the mao file name identifier. |
| 31 | */ |
Thierry FOURNIER | 275db69 | 2013-12-06 10:39:36 +0100 | [diff] [blame] | 32 | extern struct list maps; |
Thierry FOURNIER | 4b5e422 | 2013-11-22 17:40:18 +0100 | [diff] [blame] | 33 | |
| 34 | struct map_reference { |
| 35 | struct list list; /* used for listing */ |
| 36 | char *reference; /* contain the unique identifier used as map identifier. |
| 37 | in many cases this identifier is the filename that contain |
| 38 | the patterns */ |
| 39 | struct list entries; /* the list of all the entries of the map. This |
| 40 | is a list of "struct map_entry" */ |
| 41 | struct list maps; /* the list of all maps associated with the file |
| 42 | name identifier. This is a list of struct map_descriptor */ |
| 43 | }; |
| 44 | |
| 45 | struct map_entry { |
| 46 | struct list list; /* used for listing */ |
| 47 | int line; /* The original line into the file. It is used for log reference. |
| 48 | If the line is '> 0', this entry is from the original load, |
| 49 | If the line is '< 0', this entry is modify by dynamux process (CLI) */ |
| 50 | char *key; /* The string containing the key before conversion |
| 51 | and indexation */ |
| 52 | char *value; /* The string containing the value */ |
| 53 | }; |
| 54 | |
| 55 | struct sample_storage; |
| 56 | struct map_descriptor { |
| 57 | struct list list; /* used for listing */ |
| 58 | struct map_reference *ref; /* the reference used for unindexed entries */ |
Thierry FOURNIER | d5f624d | 2013-11-26 11:52:33 +0100 | [diff] [blame] | 59 | struct sample_conv *conv; /* original converter descriptor */ |
Thierry FOURNIER | 4b5e422 | 2013-11-22 17:40:18 +0100 | [diff] [blame] | 60 | int (*parse)(const char *text, /* The function that can parse the output value */ |
| 61 | struct sample_storage *smp); |
Thierry FOURNIER | 0ffe78c | 2013-12-05 14:40:25 +0100 | [diff] [blame] | 62 | struct pattern_expr *pat; /* the pattern matching associated to the map */ |
| 63 | int do_free; /* set if <pat> is the orignal pat and must be freed */ |
Thierry FOURNIER | 4b5e422 | 2013-11-22 17:40:18 +0100 | [diff] [blame] | 64 | char *default_value; /* a copy of default value. This copy is |
| 65 | useful if the type is str */ |
| 66 | struct sample_storage *def; /* contain the default value */ |
| 67 | }; |
| 68 | |
| 69 | #endif /* _TYPES_MAP_H */ |