[MINOR] Allow to specify a domain for a cookie

This patch allows to specify a domain used when inserting a cookie
providing a session stickiness. Usefull for example with wildcard domains.

The patch adds one new variable to the struct proxy: cookiedomain.
When set the domain is appended to a Set-Cookie header.

Domain name is validated using the new invalid_domainchar() function.
It is basically invalid_char() limited to [A-Za-z0-9_.-]. Yes, the test
is too trivial and does not cover all wrong situations, but the main
purpose is to detect most common mistakes, not intentional abuses.

The underscore ("_") character is not RFC-valid but as it is
often (mis)used so I decided to allow it.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 7dbadd1..9ca8ae6 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -895,8 +895,33 @@
 			else if (!strcmp(args[cur_arg], "prefix")) {
 				curproxy->options |= PR_O_COOK_PFX;
 			}
+			else if (!strcmp(args[cur_arg], "domain")) {
+				if (!*args[cur_arg + 1]) {
+					Alert("parsing [%s:%d]: '%s' expects <domain> as argument.\n",
+						file, linenum, args[cur_arg]);
+					return -1;
+				}
+
+				if (*args[cur_arg + 1] != '.' || !strchr(args[cur_arg + 1] + 1, '.')) {
+					/* rfc2109, 4.3.2 Rejecting Cookies */
+					Alert("parsing [%s:%d]: domain '%s' contains no embedded"
+						" dots or does not start with a dot.\n",
+						file, linenum, args[cur_arg + 1]);
+					return -1;
+				}
+
+				err = invalid_domainchar(args[cur_arg + 1]);
+				if (err) {
+					Alert("parsing [%s:%d]: character '%c' is not permitted in domain name '%s'.\n",
+						file, linenum, *err, args[cur_arg + 1]);
+					return -1;
+				}
+
+				curproxy->cookiedomain = strdup(args[cur_arg + 1]);
+				cur_arg++;
+			}
 			else {
-				Alert("parsing [%s:%d] : '%s' supports 'rewrite', 'insert', 'prefix', 'indirect', 'nocache' and 'postonly' options.\n",
+				Alert("parsing [%s:%d] : '%s' supports 'rewrite', 'insert', 'prefix', 'indirect', 'nocache' and 'postonly', 'domain' options.\n",
 				      file, linenum, args[0]);
 				return -1;
 			}