]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: config: add 51Degrees config parsing.
authorThomas Holmes <tom@51degrees.com>
Tue, 12 May 2015 14:50:47 +0000 (15:50 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 2 Jun 2015 12:00:25 +0000 (14:00 +0200)
src/cfgparse.c

index 7ffc0377f2540c44e1d7ca4815ef6d3e51c085b6..44b1c2ca33371725834a97e990bd2bfe0d8f4757 100644 (file)
@@ -1749,6 +1749,48 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
                goto out;
 #endif
        }
+#ifdef USE_51DEGREES
+       else if (strcmp(args[0], "51degrees-data-file") == 0) {
+               if(!*(args[1])) {
+                       Alert("parsing [%s:%d]: '%s' expects a filepath to a 51Degrees data file.\n", file, linenum, args[0]);
+                       err_code |= ERR_ALERT | ERR_FATAL;
+                       goto out;
+               }
+               global._51d_data_file_path = strdup(args[1]);
+       }
+       else if (strcmp(args[0], "51degrees-property-seperator") == 0) {
+               if(!*(args[1])) {
+                       Alert("parsing [%s:%d]: '%s' expects a ingle character.\n", file, linenum, args[0]);
+                       err_code |= ERR_ALERT | ERR_FATAL;
+                       goto out;
+               }
+               if (strlen(args[1]) > 1) {
+                       Alert("parsing [%s:%d]: '%s' expects a ingle character, got '%s'.\n", file, linenum, args[0], args[1]);
+                       err_code |= ERR_ALERT | ERR_FATAL;
+                       goto out;
+               }
+               global._51d_property_seperator = *args[1];
+       }
+       else if (strcmp(args[0], "51degrees-property-name-list") == 0) {
+               int arg;
+               struct _51d_property_names *name;
+
+               arg = 1;
+               if (!*args[arg]) {
+                       Alert("parsing [%s:%d]: '%s' expects at least one 51Degrees property name.\n", file, linenum, args[0]);
+                       err_code |= ERR_ALERT | ERR_FATAL;
+                       goto out;
+               }
+
+               LIST_INIT(&global._51d_property_names);
+               while (*args[arg]) {
+                       name = calloc(1, sizeof(struct _51d_property_names));
+                       name->name = strdup(args[arg]);
+                       LIST_ADDQ(&global._51d_property_names, &name->list);
+                       ++arg;
+               }
+       }
+#endif
        else {
                struct cfg_kw_list *kwl;
                int index;