blob: 6988cbe6ece7224d070639ae07db0c74db5d66ba [file] [log] [blame]
Thierry FOURNIER4b5e4222013-11-22 17:40:18 +01001/*
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 */
32struct list maps = LIST_HEAD_INIT(maps); /* list of struct map_reference */
33
34struct 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
45struct 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
55struct sample_storage;
56struct map_descriptor {
57 struct list list; /* used for listing */
58 struct map_reference *ref; /* the reference used for unindexed entries */
59 struct sample_conv *conv; /* original convertissor descriptor */
60 int (*parse)(const char *text, /* The function that can parse the output value */
61 struct sample_storage *smp);
62 struct acl_expr acl; /* dummy acl expression. just for using the acl
63 match primitive and storage system */
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 */