Willy Tarreau | 2ac5718 | 2012-04-19 15:24:50 +0200 | [diff] [blame] | 1 | /* |
| 2 | * include/types/arg.h |
| 3 | * This file contains structure declarations for generaic argument parsing. |
| 4 | * |
| 5 | * Copyright 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_ARG_H |
| 23 | #define _TYPES_ARG_H |
| 24 | |
| 25 | #include <sys/socket.h> |
| 26 | #include <netinet/in.h> |
Willy Tarreau | c7e4238 | 2012-08-24 19:22:53 +0200 | [diff] [blame] | 27 | |
| 28 | #include <common/chunk.h> |
Willy Tarreau | 2ac5718 | 2012-04-19 15:24:50 +0200 | [diff] [blame] | 29 | |
| 30 | enum { |
| 31 | ARGT_STOP = 0, /* end of the arg list */ |
| 32 | ARGT_UINT, /* unsigned integer, which is a positive integer without any sign */ |
| 33 | ARGT_SINT, /* signed integer, the sign (+/-) was explicit. Falls back to UINT if no sign. */ |
| 34 | ARGT_STR, /* string */ |
| 35 | ARGT_IPV4, /* an IPv4 address */ |
| 36 | ARGT_MSK4, /* an IPv4 address mask (integer or dotted), stored as ARGT_IPV4 */ |
| 37 | ARGT_IPV6, /* an IPv6 address */ |
| 38 | ARGT_MSK6, /* an IPv6 address mask (integer or dotted), stored as ARGT_IPV4 */ |
| 39 | ARGT_TIME, /* a delay in ms by default, stored as ARGT_UINT */ |
| 40 | ARGT_SIZE, /* a size in bytes by default, stored as ARGT_UINT */ |
| 41 | ARGT_FE, /* a pointer to a frontend only */ |
| 42 | ARGT_BE, /* a pointer to a backend only */ |
| 43 | ARGT_TAB, /* a pointer to a stick table */ |
| 44 | ARGT_SRV, /* a pointer to a server */ |
| 45 | ARGT_USR, /* a pointer to a user list */ |
| 46 | ARGT_UNASSIGNED15, /* will probably be used for variables later */ |
| 47 | ARGT_NBTYPES /* no more values past 15 */ |
| 48 | }; |
| 49 | |
| 50 | /* some types that are externally defined */ |
| 51 | struct proxy; |
| 52 | struct server; |
| 53 | struct userlist; |
| 54 | |
| 55 | union arg_data { |
| 56 | unsigned int uint; /* used for uint, time, size */ |
| 57 | int sint; |
| 58 | struct chunk str; |
| 59 | struct in_addr ipv4; |
| 60 | struct in6_addr ipv6; |
| 61 | struct proxy *prx; /* used for fe, be, tables */ |
| 62 | struct server *srv; |
| 63 | struct userlist *usr; |
| 64 | }; |
| 65 | |
| 66 | struct arg { |
Willy Tarreau | 496aa01 | 2012-06-01 10:38:29 +0200 | [diff] [blame] | 67 | unsigned char type; /* argument type, ARGT_* */ |
| 68 | unsigned char unresolved; /* argument contains a string in <str> that must be resolved and freed */ |
| 69 | union arg_data data; /* argument data */ |
Willy Tarreau | 2ac5718 | 2012-04-19 15:24:50 +0200 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | |
| 73 | #endif /* _TYPES_ARG_H */ |
| 74 | |
| 75 | /* |
| 76 | * Local variables: |
| 77 | * c-indent-level: 8 |
| 78 | * c-basic-offset: 8 |
| 79 | * End: |
| 80 | */ |