MINOR: config: Export parse_process_number and use it wherever it's applicable

This function is used when "bind-process" directive is parsed and when "process"
parameter on a "bind" or a "stats socket" line is parsed.
diff --git a/include/common/cfgparse.h b/include/common/cfgparse.h
index 230c35f..7332bd5 100644
--- a/include/common/cfgparse.h
+++ b/include/common/cfgparse.h
@@ -86,6 +86,7 @@
 int too_many_args(int maxarg, char **args, char **msg, int *err_code);
 int alertif_too_many_args_idx(int maxarg, int index, const char *file, int linenum, char **args, int *err_code);
 int alertif_too_many_args(int maxarg, const char *file, int linenum, char **args, int *err_code);
+int parse_process_number(const char *arg, unsigned long *proc, char **err);
 
 /*
  * Sends a warning if proxy <proxy> does not have at least one of the
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 2245f51..d4cfa86 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -596,7 +596,7 @@
  * Note: this function can also be used to parse a thread number or a set of
  * threads.
  */
-static int parse_process_number(const char *arg, unsigned long *proc, char **err)
+int parse_process_number(const char *arg, unsigned long *proc, char **err)
 {
 	if (strcmp(arg, "all") == 0)
 		*proc |= ~0UL;
@@ -3283,43 +3283,12 @@
 		unsigned long set = 0;
 
 		while (*args[cur_arg]) {
-			unsigned int low, high;
-
 			if (strcmp(args[cur_arg], "all") == 0) {
 				set = 0;
 				break;
 			}
-			else if (strcmp(args[cur_arg], "odd") == 0) {
-				set |= ~0UL/3UL; /* 0x555....555 */
-			}
-			else if (strcmp(args[cur_arg], "even") == 0) {
-				set |= (~0UL/3UL) << 1; /* 0xAAA...AAA */
-			}
-			else if (isdigit((int)*args[cur_arg])) {
-				char *dash = strchr(args[cur_arg], '-');
-
-				low = high = str2uic(args[cur_arg]);
-				if (dash)
-					high = str2uic(dash + 1);
-
-				if (high < low) {
-					unsigned int swap = low;
-					low = high;
-					high = swap;
-				}
-
-				if (low < 1 || high > LONGBITS) {
-					Alert("parsing [%s:%d]: %s supports process numbers from 1 to %d.\n",
-					      file, linenum, args[0], LONGBITS);
-					err_code |= ERR_ALERT | ERR_FATAL;
-					goto out;
-				}
-				while (low <= high)
-					set |= 1UL << (low++ - 1);
-			}
-			else {
-				Alert("parsing [%s:%d]: %s expects 'all', 'odd', 'even', or a list of process ranges with numbers from 1 to %d.\n",
-				      file, linenum, args[0], LONGBITS);
+			if (parse_process_number(args[cur_arg], &set, &errmsg)) {
+				Alert("parsing [%s:%d] : %s : %s\n", file, linenum, args[0], errmsg);
 				err_code |= ERR_ALERT | ERR_FATAL;
 				goto out;
 			}
diff --git a/src/cli.c b/src/cli.c
index 6625a09..05cc15e 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -323,43 +323,12 @@
 		}
 
 		while (*args[cur_arg]) {
-			unsigned int low, high;
-
 			if (strcmp(args[cur_arg], "all") == 0) {
 				set = 0;
 				break;
 			}
-			else if (strcmp(args[cur_arg], "odd") == 0) {
-				set |= ~0UL/3UL; /* 0x555....555 */
-			}
-			else if (strcmp(args[cur_arg], "even") == 0) {
-				set |= (~0UL/3UL) << 1; /* 0xAAA...AAA */
-			}
-			else if (isdigit((int)*args[cur_arg])) {
-				char *dash = strchr(args[cur_arg], '-');
-
-				low = high = str2uic(args[cur_arg]);
-				if (dash)
-					high = str2uic(dash + 1);
-
-				if (high < low) {
-					unsigned int swap = low;
-					low = high;
-					high = swap;
-				}
-
-				if (low < 1 || high > LONGBITS) {
-					memprintf(err, "'%s %s' supports process numbers from 1 to %d.\n",
-					          args[0], args[1], LONGBITS);
-					return -1;
-				}
-				while (low <= high)
-					set |= 1UL << (low++ - 1);
-			}
-			else {
-				memprintf(err,
-				          "'%s %s' expects 'all', 'odd', 'even', or a list of process ranges with numbers from 1 to %d.\n",
-				          args[0], args[1], LONGBITS);
+			if (parse_process_number(args[cur_arg], &set, err)) {
+				memprintf(err, "'%s %s' : %s", args[0], args[1], *err);
 				return -1;
 			}
 			cur_arg++;
diff --git a/src/listener.c b/src/listener.c
index aede0d3..a06a464 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -19,6 +19,7 @@
 #include <fcntl.h>
 
 #include <common/accept4.h>
+#include <common/cfgparse.h>
 #include <common/config.h>
 #include <common/errors.h>
 #include <common/mini-clist.h>
@@ -941,39 +942,9 @@
 static int bind_parse_process(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
 {
 	unsigned long set = 0;
-	unsigned int low, high;
 
-	if (strcmp(args[cur_arg + 1], "all") == 0) {
-		set |= ~0UL;
-	}
-	else if (strcmp(args[cur_arg + 1], "odd") == 0) {
-		set |= ~0UL/3UL; /* 0x555....555 */
-	}
-	else if (strcmp(args[cur_arg + 1], "even") == 0) {
-		set |= (~0UL/3UL) << 1; /* 0xAAA...AAA */
-	}
-	else if (isdigit((int)*args[cur_arg + 1])) {
-		char *dash = strchr(args[cur_arg + 1], '-');
-
-		low = high = str2uic(args[cur_arg + 1]);
-		if (dash)
-			high = str2uic(dash + 1);
-
-		if (high < low) {
-			unsigned int swap = low;
-			low = high;
-			high = swap;
-		}
-
-		if (low < 1 || high > LONGBITS) {
-			memprintf(err, "'%s' : invalid range %d-%d, allowed range is 1..%d", args[cur_arg], low, high, LONGBITS);
-			return ERR_ALERT | ERR_FATAL;
-		}
-		while (low <= high)
-			set |= 1UL << (low++ - 1);
-	}
-	else {
-		memprintf(err, "'%s' expects 'all', 'odd', 'even', or a process range with numbers from 1 to %d.", args[cur_arg], LONGBITS);
+	if (parse_process_number(args[cur_arg + 1], &set, err)) {
+		memprintf(err, "'%s' : %s", args[cur_arg], *err);
 		return ERR_ALERT | ERR_FATAL;
 	}