]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: tools: move list_append_word to cfgparse
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Wed, 7 Aug 2024 16:12:48 +0000 (18:12 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Aug 2024 16:41:41 +0000 (18:41 +0200)
Let's move list_append_word to cfgparse.c as it is used only to fill
cfg_cfgfiles list with configuration file names.

include/haproxy/cfgparse.h
include/haproxy/tools.h
src/cfgparse.c
src/tools.c

index bafe985df246c82aaec9e65c3a183927791738e3..1b59c89fa7c1c01bb3af01ffdee3803e0e0afca3 100644 (file)
@@ -140,6 +140,7 @@ const char *cfg_find_best_match(const char *word, const struct list *list, int s
 int warnifnotcap(struct proxy *proxy, int cap, const char *file, int line, const char *arg, const char *hint);
 int failifnotcap(struct proxy *proxy, int cap, const char *file, int line, const char *arg, const char *hint);
 void cfg_dump_registered_keywords();
+int list_append_word(struct list *li, const char *str, char **err);
 
 /* simplified way to define a section parser */
 #define REGISTER_CONFIG_SECTION(name, parse, post)                            \
index 425814f6d1efcfbf6b4157fdec3e4da1713e824b..c010af2a0e75dd54c9e3f509e4eea927d06e5a6e 100644 (file)
@@ -1034,8 +1034,6 @@ static inline unsigned long long rdtsc()
  * The caller is responsible for freeing the <err> and <str> copy
  * memory area using free()
  */
-struct list;
-int list_append_word(struct list *li, const char *str, char **err);
 
 int dump_text(struct buffer *out, const char *buf, int bsize);
 int dump_binary(struct buffer *out, const char *buf, int bsize);
index 8c231bbbdf18db9527368a0871db66efc2697861..77b302e3d54c6ef5d0f351394714c7848aeebd05 100644 (file)
@@ -1717,6 +1717,38 @@ static int cfg_parse_global_def_path(char **args, int section_type, struct proxy
        return ret;
 }
 
+/* append a copy of string <str> (in a wordlist) at the end of the list <li>
+ * On failure : return 0 and <err> filled with an error message.
+ * The caller is responsible for freeing the <err> and <str> copy
+ * memory area using free()
+ */
+int list_append_word(struct list *li, const char *str, char **err)
+{
+       struct wordlist *wl;
+
+       wl = calloc(1, sizeof(*wl));
+       if (!wl) {
+               memprintf(err, "out of memory");
+               goto fail_wl;
+       }
+
+       wl->s = strdup(str);
+       if (!wl->s) {
+               memprintf(err, "out of memory");
+               goto fail_wl_s;
+       }
+
+       LIST_APPEND(li, &wl->list);
+
+       return 1;
+
+fail_wl_s:
+       free(wl->s);
+fail_wl:
+       free(wl);
+       return 0;
+}
+
 /*
  * This function reads and parses the configuration file given in the argument.
  * Returns the error code, 0 if OK, -1 if the config file couldn't be opened,
index 21e990cbf50cd8463ed78a570bb03daefdb66a04..124b2b74154f6fa49f5c9a1f1cc7fff2a72355d6 100644 (file)
@@ -4883,38 +4883,6 @@ unsigned char utf8_next(const char *s, int len, unsigned int *c)
        return code | ((p-(unsigned char *)s)&0x0f);
 }
 
-/* append a copy of string <str> (in a wordlist) at the end of the list <li>
- * On failure : return 0 and <err> filled with an error message.
- * The caller is responsible for freeing the <err> and <str> copy
- * memory area using free()
- */
-int list_append_word(struct list *li, const char *str, char **err)
-{
-       struct wordlist *wl;
-
-       wl = calloc(1, sizeof(*wl));
-       if (!wl) {
-               memprintf(err, "out of memory");
-               goto fail_wl;
-       }
-
-       wl->s = strdup(str);
-       if (!wl->s) {
-               memprintf(err, "out of memory");
-               goto fail_wl_s;
-       }
-
-       LIST_APPEND(li, &wl->list);
-
-       return 1;
-
-fail_wl_s:
-       free(wl->s);
-fail_wl:
-       free(wl);
-       return 0;
-}
-
 /* indicates if a memory location may safely be read or not. The trick consists
  * in performing a harmless syscall using this location as an input and letting
  * the operating system report whether it's OK or not. For this we have the