MEDIUM: add a new typed argument list parsing framework

make_arg_list() builds an array of typed arguments with their values,
that the caller describes how to parse. This will be used to support
multiple arguments for ACLs and patterns, which is currently problematic
and prevents ACLs and patterns from being merged. Up to 7 arguments types
may be enumerated in a single 32-bit word, including their number of
mandatory parts.

At the moment, these files are not used yet, they're only built. Note that
the 4-bit encoding for the type has left only one unused type!
diff --git a/include/proto/arg.h b/include/proto/arg.h
new file mode 100644
index 0000000..68eb379
--- /dev/null
+++ b/include/proto/arg.h
@@ -0,0 +1,67 @@
+/*
+ * include/proto/arg.h
+ * This file contains functions and macros declarations for generic argument parsing.
+ *
+ * Copyright 2012 Willy Tarreau <w@1wt.eu>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, version 2.1
+ * exclusively.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef _PROTO_ARG_H
+#define _PROTO_ARG_H
+
+#include <types/arg.h>
+
+/* Some macros used to build some arg list. We can declare various argument
+ * combinations from 0 to 7 args using a single 32-bit integer. The first
+ * argument of these macros is always the mandatory number of arguments, and
+ * remaining ones are optional args. Note: ARGM() may also be used to return
+ * the number of mandatory arguments in a mask.
+ */
+#define ARGM(m) \
+	(m & 15)
+
+#define ARG1(m, t1) \
+	(ARGM(m) + (ARGT_##t1 << 4))
+
+#define ARG2(m, t1, t2) \
+	(ARG1(m, t1) + (ARGT_##t2 << 8))
+
+#define ARG3(m, t1, t2, t3) \
+	(ARG2(m, t1, t2) + (ARGT_##t3 << 12))
+
+#define ARG4(m, t1, t2, t3, t4) \
+	(ARG3(m, t1, t2, t3) + (ARGT_##t4 << 16))
+
+#define ARG5(m, t1, t2, t3, t4, t5) \
+	(ARG4(m, t1, t2, t3, t4) + (ARGT_##t5 << 20))
+
+#define ARG6(m, t1, t2, t3, t4, t5, t6) \
+	(ARG5(m, t1, t2, t3, t4, t5) + (ARGT_##t6 << 24))
+
+#define ARG7(m, t1, t2, t3, t4, t5, t6, t7) \
+	(ARG6(m, t1, t2, t3, t4, t5, t6) + (ARGT_##t7 << 28))
+
+int make_arg_list(const char *in, int len, unsigned int mask, struct arg **argp,
+		  char **err_msg, const char **err_ptr, int *err_arg);
+
+#endif /* _PROTO_ARG_H */
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ * End:
+ */
diff --git a/include/types/arg.h b/include/types/arg.h
new file mode 100644
index 0000000..2369721
--- /dev/null
+++ b/include/types/arg.h
@@ -0,0 +1,78 @@
+/*
+ * include/types/arg.h
+ * This file contains structure declarations for generaic argument parsing.
+ *
+ * Copyright 2012 Willy Tarreau <w@1wt.eu>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, version 2.1
+ * exclusively.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef _TYPES_ARG_H
+#define _TYPES_ARG_H
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <types/buffers.h>
+
+enum {
+	ARGT_STOP = 0, /* end of the arg list */
+	ARGT_UINT,     /* unsigned integer, which is a positive integer without any sign */
+	ARGT_SINT,     /* signed integer, the sign (+/-) was explicit. Falls back to UINT if no sign. */
+	ARGT_STR,      /* string */
+	ARGT_IPV4,     /* an IPv4 address */
+	ARGT_MSK4,     /* an IPv4 address mask (integer or dotted), stored as ARGT_IPV4 */
+	ARGT_IPV6,     /* an IPv6 address */
+	ARGT_MSK6,     /* an IPv6 address mask (integer or dotted), stored as ARGT_IPV4 */
+	ARGT_TIME,     /* a delay in ms by default, stored as ARGT_UINT */
+	ARGT_SIZE,     /* a size in bytes by default, stored as ARGT_UINT */
+	ARGT_FE,       /* a pointer to a frontend only */
+	ARGT_BE,       /* a pointer to a backend only */
+	ARGT_TAB,      /* a pointer to a stick table */
+	ARGT_SRV,      /* a pointer to a server */
+	ARGT_USR,      /* a pointer to a user list */
+	ARGT_UNASSIGNED15, /* will probably be used for variables later */
+	ARGT_NBTYPES   /* no more values past 15 */
+};
+
+/* some types that are externally defined */
+struct proxy;
+struct server;
+struct userlist;
+
+union arg_data {
+	unsigned int uint; /* used for uint, time, size */
+	int sint;
+	struct chunk str;
+	struct in_addr ipv4;
+	struct in6_addr ipv6;
+	struct proxy *prx; /* used for fe, be, tables */
+	struct server *srv;
+	struct userlist *usr;
+};
+
+struct arg {
+	int type;              /* argument type */
+	union arg_data data;   /* argument data */
+};
+
+
+#endif /* _TYPES_ARG_H */
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ * End:
+ */