MINOR: proxy: Register keywords to parse errorfile and errorloc directives

errorfile and errorloc directives are now pased in dedicated functions in
http_htx.c.
diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c
index 9177181..61bf7cd 100644
--- a/src/cfgparse-listen.c
+++ b/src/cfgparse-listen.c
@@ -3805,56 +3805,6 @@
 		err_code |= ERR_ALERT | ERR_FATAL;
 		goto out;
 	}
-	else if (!strcmp(args[0], "errorloc") ||
-		 !strcmp(args[0], "errorloc302") ||
-		 !strcmp(args[0], "errorloc303")) { /* error location */
-		struct buffer *msg;
-		int errloc, status;
-
-		if (warnifnotcap(curproxy, PR_CAP_FE | PR_CAP_BE, file, linenum, args[0], NULL))
-			err_code |= ERR_WARN;
-
-		if (*(args[1]) == 0 || *(args[2]) == 0) {
-			ha_alert("parsing [%s:%d] : <%s> expects <status_code> and <url> as arguments.\n", file, linenum, args[0]);
-			err_code |= ERR_ALERT | ERR_FATAL;
-			goto out;
-		}
-
-		status = atol(args[1]);
-		errloc = (!strcmp(args[0], "errorloc303") ? 303 : 302);
-		msg = http_parse_errorloc(errloc, status, args[2], &errmsg);
-		if (!msg) {
-			ha_alert("parsing [%s:%d] : %s: %s\n", file, linenum, args[0], errmsg);
-			err_code |= ERR_ALERT | ERR_FATAL;
-			goto out;
-		}
-		rc = http_get_status_idx(status);
-		curproxy->errmsg[rc] = msg;
-	}
-	else if (!strcmp(args[0], "errorfile")) { /* error message from a file */
-		struct buffer *msg;
-		int status;
-
-		if (warnifnotcap(curproxy, PR_CAP_FE | PR_CAP_BE, file, linenum, args[0], NULL))
-			err_code |= ERR_WARN;
-
-		if (*(args[1]) == 0 || *(args[2]) == 0) {
-			ha_alert("parsing [%s:%d] : %s: expects <status_code> and <file> as arguments.\n",
-				 file, linenum, args[0]);
-			err_code |= ERR_ALERT | ERR_FATAL;
-			goto out;
-		}
-
-		status = atol(args[1]);
-		msg = http_parse_errorfile(status, args[2], &errmsg);
-		if (!msg) {
-			ha_alert("parsing [%s:%d] : %s: %s\n", file, linenum, args[0], errmsg);
-			err_code |= ERR_ALERT | ERR_FATAL;
-			goto out;
-		}
-		rc = http_get_status_idx(status);
-		curproxy->errmsg[rc] = msg;
-	}
 	else {
 		struct cfg_kw_list *kwl;
 		int index;
diff --git a/src/http_htx.c b/src/http_htx.c
index 33edcac..98a62bd 100644
--- a/src/http_htx.c
+++ b/src/http_htx.c
@@ -1050,6 +1050,87 @@
 	return buf;
 }
 
+/* Parses the "errorloc[302|303]" proxy keyword */
+static int proxy_parse_errorloc(char **args, int section, struct proxy *curpx,
+				  struct proxy *defpx, const char *file, int line,
+				  char **errmsg)
+{
+	struct buffer *msg;
+	int errloc, status, rc, ret = 0;
+
+	if (warnifnotcap(curpx, PR_CAP_FE | PR_CAP_BE, file, line, args[0], NULL)) {
+		ret = 1;
+		goto out;
+	}
+
+	if (*(args[1]) == 0 || *(args[2]) == 0) {
+		memprintf(errmsg, "%s : expects <status_code> and <url> as arguments.\n", args[0]);
+		ret = -1;
+		goto out;
+	}
+
+	status = atol(args[1]);
+	errloc = (!strcmp(args[0], "errorloc303") ? 303 : 302);
+	msg = http_parse_errorloc(errloc, status, args[2], errmsg);
+	if (!msg) {
+		memprintf(errmsg, "%s : %s", args[0], *errmsg);
+		ret = -1;
+		goto out;
+	}
+
+	rc = http_get_status_idx(status);
+	curpx->errmsg[rc] = msg;
+
+  out:
+	return ret;
+}
+
+
+/* Parses the "errorfile" proxy keyword */
+static int proxy_parse_errorfile(char **args, int section, struct proxy *curpx,
+				 struct proxy *defpx, const char *file, int line,
+				 char **errmsg)
+{
+	struct buffer *msg;
+	int status, rc, ret = 0;
+
+	if (warnifnotcap(curpx, PR_CAP_FE | PR_CAP_BE, file, line, args[0], NULL)) {
+		ret = 1;
+		goto out;
+	}
+
+	if (*(args[1]) == 0 || *(args[2]) == 0) {
+		memprintf(errmsg, "%s : expects <status_code> and <file> as arguments.\n", args[0]);
+		ret = -1;
+		goto out;
+	}
+
+	status = atol(args[1]);
+	msg = http_parse_errorfile(status, args[2], errmsg);
+	if (!msg) {
+		memprintf(errmsg, "%s : %s", args[0], *errmsg);
+		ret = -1;
+		goto out;
+	}
+
+	rc = http_get_status_idx(status);
+	curpx->errmsg[rc] = msg;
+
+  out:
+	return ret;
+
+}
+
+static struct cfg_kw_list cfg_kws = {ILH, {
+        { CFG_LISTEN, "errorloc",     proxy_parse_errorloc },
+        { CFG_LISTEN, "errorloc302",  proxy_parse_errorloc },
+        { CFG_LISTEN, "errorloc303",  proxy_parse_errorloc },
+        { CFG_LISTEN, "errorfile",    proxy_parse_errorfile },
+        { 0, NULL, NULL },
+}};
+
+INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
+
 /************************************************************************/
 /*                             HTX sample fetches                       */
 /************************************************************************/