[MEDIUM] checks: group health checks methods by values and save option bits

Adding health checks has become a real pain, with cross-references to all
checks everywhere because they're all a single bit. Since they're all
exclusive, let's change this to have a check number only. We reserve 4
bits allowing up to 16 checks (15+tcp), only 7 of which are currently
used. The code has shrunk by almost 1kB and we saved a few option bits.

The "dispatch" option has been moved to px->options, making a few tests
a bit cleaner.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 44fc1da..8c61f3d 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -3255,13 +3255,8 @@
 			/* use HTTP request to check servers' health */
 			free(curproxy->check_req);
 			curproxy->check_req = NULL;
-			curproxy->options &= ~PR_O_SMTP_CHK;
-			curproxy->options2 &= ~PR_O2_SSL3_CHK;
-			curproxy->options2 &= ~PR_O2_MYSQL_CHK;
-			curproxy->options2 &= ~PR_O2_PGSQL_CHK;
-			curproxy->options2 &= ~PR_O2_LDAP_CHK;
-			curproxy->options2 &= ~PR_O2_REDIS_CHK;
-			curproxy->options |= PR_O_HTTP_CHK;
+			curproxy->options2 &= ~PR_O2_CHK_ANY;
+			curproxy->options2 |= PR_O2_HTTP_CHK;
 			if (!*args[2]) { /* no argument */
 				curproxy->check_req = strdup(DEF_CHECK_REQ); /* default request */
 				curproxy->check_len = strlen(DEF_CHECK_REQ);
@@ -3289,25 +3284,15 @@
 
 			free(curproxy->check_req);
 			curproxy->check_req = NULL;
-			curproxy->options &= ~PR_O_HTTP_CHK;
-			curproxy->options &= ~PR_O_SMTP_CHK;
-			curproxy->options2 &= ~PR_O2_MYSQL_CHK;
-			curproxy->options2 &= ~PR_O2_PGSQL_CHK;
-			curproxy->options2 &= ~PR_O2_LDAP_CHK;
-			curproxy->options2 &= ~PR_O2_REDIS_CHK;
+			curproxy->options2 &= ~PR_O2_CHK_ANY;
 			curproxy->options2 |= PR_O2_SSL3_CHK;
 		}
 		else if (!strcmp(args[1], "smtpchk")) {
 			/* use SMTP request to check servers' health */
 			free(curproxy->check_req);
 			curproxy->check_req = NULL;
-			curproxy->options &= ~PR_O_HTTP_CHK;
-			curproxy->options2 &= ~PR_O2_SSL3_CHK;
-			curproxy->options2 &= ~PR_O2_MYSQL_CHK;
-			curproxy->options2 &= ~PR_O2_PGSQL_CHK;
-			curproxy->options2 &= ~PR_O2_LDAP_CHK;
-			curproxy->options2 &= ~PR_O2_REDIS_CHK;
-			curproxy->options |= PR_O_SMTP_CHK;
+			curproxy->options2 &= ~PR_O2_CHK_ANY;
+			curproxy->options2 |= PR_O2_SMTP_CHK;
 
 			if (!*args[2] || !*args[3]) { /* no argument or incomplete EHLO host */
 				curproxy->check_req = strdup(DEF_SMTP_CHECK_REQ); /* default request */
@@ -3333,12 +3318,7 @@
 
 			free(curproxy->check_req);
 			curproxy->check_req = NULL;
-			curproxy->options &= ~PR_O_HTTP_CHK;
-			curproxy->options &= ~PR_O_SMTP_CHK;
-			curproxy->options2 &= ~PR_O2_SSL3_CHK;
-			curproxy->options2 &= ~PR_O2_LDAP_CHK;
-			curproxy->options2 &= ~PR_O2_REDIS_CHK;
-			curproxy->options2 &= ~PR_O2_MYSQL_CHK;
+			curproxy->options2 &= ~PR_O2_CHK_ANY;
 			curproxy->options2 |= PR_O2_PGSQL_CHK;
 
 			if (*(args[2])) {
@@ -3397,12 +3377,7 @@
 
 			free(curproxy->check_req);
 			curproxy->check_req = NULL;
-			curproxy->options &= ~PR_O_HTTP_CHK;
-			curproxy->options &= ~PR_O_SMTP_CHK;
-			curproxy->options2 &= ~PR_O2_SSL3_CHK;
-			curproxy->options2 &= ~PR_O2_MYSQL_CHK;
-			curproxy->options2 &= ~PR_O2_PGSQL_CHK;
-			curproxy->options2 &= ~PR_O2_LDAP_CHK;
+			curproxy->options2 &= ~PR_O2_CHK_ANY;
 			curproxy->options2 |= PR_O2_REDIS_CHK;
 
 			curproxy->check_req = (char *) malloc(sizeof(DEF_REDIS_CHECK_REQ) - 1);
@@ -3417,12 +3392,7 @@
 
 			free(curproxy->check_req);
 			curproxy->check_req = NULL;
-			curproxy->options &= ~PR_O_HTTP_CHK;
-			curproxy->options &= ~PR_O_SMTP_CHK;
-			curproxy->options2 &= ~PR_O2_SSL3_CHK;
-			curproxy->options2 &= ~PR_O2_LDAP_CHK;
-			curproxy->options2 &= ~PR_O2_REDIS_CHK;
-			curproxy->options2 &= ~PR_O2_PGSQL_CHK;
+			curproxy->options2 &= ~PR_O2_CHK_ANY;
 			curproxy->options2 |= PR_O2_MYSQL_CHK;
 
 			/* This is an exemple of an MySQL >=4.0 client Authentication packet kindly provided by Cyril Bonte.
@@ -3489,12 +3459,7 @@
 			/* use LDAP request to check servers' health */
 			free(curproxy->check_req);
 			curproxy->check_req = NULL;
-			curproxy->options &= ~PR_O_HTTP_CHK;
-			curproxy->options &= ~PR_O_SMTP_CHK;
-			curproxy->options2 &= ~PR_O2_SSL3_CHK;
-			curproxy->options2 &= ~PR_O2_MYSQL_CHK;
-			curproxy->options2 &= ~PR_O2_PGSQL_CHK;
-			curproxy->options2 &= ~PR_O2_REDIS_CHK;
+			curproxy->options2 &= ~PR_O2_CHK_ANY;
 			curproxy->options2 |= PR_O2_LDAP_CHK;
 
 			curproxy->check_req = (char *) malloc(sizeof(DEF_LDAP_CHECK_REQ) - 1);
@@ -3836,7 +3801,7 @@
 			goto out;
 		}
 		curproxy->dispatch_addr = *sk;
-		curproxy->options2 |= PR_O2_DISPATCH;
+		curproxy->options |= PR_O_DISPATCH;
 	}
 	else if (!strcmp(args[0], "balance")) {  /* set balancing with optional algorithm */
 		if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL))
@@ -5619,14 +5584,13 @@
 					cfgerr++;
 				}
 #endif
-				else if (curproxy->options2 & PR_O2_DISPATCH) {
+				else if (curproxy->options & PR_O_DISPATCH) {
 					Warning("config : dispatch address of %s '%s' will be ignored in balance mode.\n",
 						proxy_type_str(curproxy), curproxy->id);
 					err_code |= ERR_WARN;
 				}
 			}
-			else if (!(curproxy->options & (PR_O_TRANSP | PR_O_HTTP_PROXY)) &&
-				 !(curproxy->options2 & PR_O2_DISPATCH)) {
+			else if (!(curproxy->options & (PR_O_TRANSP | PR_O_DISPATCH | PR_O_HTTP_PROXY))) {
 				/* If no LB algo is set in a backend, and we're not in
 				 * transparent mode, dispatch mode nor proxy mode, we
 				 * want to use balance roundrobin by default.
@@ -5636,31 +5600,26 @@
 			}
 		}
 
-		if (curproxy->options2 & PR_O2_DISPATCH) {
-			curproxy->options  &= ~PR_O_TRANSP;
-			curproxy->options  &= ~PR_O_HTTP_PROXY;
-		}
-		else if (curproxy->options & PR_O_HTTP_PROXY) {
-			curproxy->options2 &= ~PR_O2_DISPATCH;
-			curproxy->options  &= ~PR_O_TRANSP;
-		}
-		else if (curproxy->options & PR_O_TRANSP) {
-			curproxy->options2 &= ~PR_O2_DISPATCH;
-			curproxy->options  &= ~PR_O_HTTP_PROXY;
-		}
-
-		if ((curproxy->options & PR_O_DISABLE404) && !(curproxy->options & PR_O_HTTP_CHK)) {
-			curproxy->options &= ~PR_O_DISABLE404;
-			Warning("config : '%s' will be ignored for %s '%s' (requires 'option httpchk').\n",
-				"disable-on-404", proxy_type_str(curproxy), curproxy->id);
-			err_code |= ERR_WARN;
-		}
+		if (curproxy->options & PR_O_DISPATCH)
+			curproxy->options &= ~(PR_O_TRANSP | PR_O_HTTP_PROXY);
+		else if (curproxy->options & PR_O_HTTP_PROXY)
+			curproxy->options &= ~(PR_O_DISPATCH | PR_O_TRANSP);
+		else if (curproxy->options & PR_O_TRANSP)
+			curproxy->options &= ~(PR_O_DISPATCH | PR_O_HTTP_PROXY);
 
-		if ((curproxy->options2 & PR_O2_CHK_SNDST) && !(curproxy->options & PR_O_HTTP_CHK)) {
-			curproxy->options &= ~PR_O2_CHK_SNDST;
-			Warning("config : '%s' will be ignored for %s '%s' (requires 'option httpchk').\n",
-				"send-state", proxy_type_str(curproxy), curproxy->id);
-			err_code |= ERR_WARN;
+		if ((curproxy->options2 & PR_O2_CHK_ANY) != PR_O2_HTTP_CHK) {
+			if (curproxy->options & PR_O_DISABLE404) {
+				Warning("config : '%s' will be ignored for %s '%s' (requires 'option httpchk').\n",
+					"disable-on-404", proxy_type_str(curproxy), curproxy->id);
+				err_code |= ERR_WARN;
+				curproxy->options &= ~PR_O_DISABLE404;
+			}
+			if (curproxy->options2 & PR_O2_CHK_SNDST) {
+				Warning("config : '%s' will be ignored for %s '%s' (requires 'option httpchk').\n",
+					"send-state", proxy_type_str(curproxy), curproxy->id);
+				err_code |= ERR_WARN;
+				curproxy->options &= ~PR_O2_CHK_SNDST;
+			}
 		}
 
 		/* if a default backend was specified, let's find it */
@@ -6001,7 +5960,7 @@
 			}
 		}
 
-		if (curproxy->options2 & PR_O2_SSL3_CHK) {
+		if ((curproxy->options2 & PR_O2_CHK_ANY) == PR_O2_SSL3_CHK) {
 			curproxy->check_len = sizeof(sslv3_client_hello_pkt) - 1;
 			curproxy->check_req = (char *)malloc(curproxy->check_len);
 			memcpy(curproxy->check_req, sslv3_client_hello_pkt, curproxy->check_len);