minor build fix for zonekeeperless builds
[distributedratelimiting.git] / drl / config.c
index d9d9ede..86d1ec4 100644 (file)
@@ -113,11 +113,15 @@ static int parse_common(xmlDocPtr doc, xmlNodePtr ident, ident_config *common) {
     xmlChar *mainloop_intervals;
     xmlChar *communication_intervals;
     xmlChar *independent;
+    xmlChar *htb_node;
+    xmlChar *htb_parent;
     xmlNodePtr fields = ident->children;
     ident_peer *current = NULL;
 
     /* The struct has been memsetted to 0, this is just to be safe. */
+#ifdef BUILD_ZOOKEEPER
     common->zk_host = NULL;
+#endif
     common->peers = NULL;
     common->members = NULL;
     common->next = NULL;
@@ -266,6 +270,21 @@ static int parse_common(xmlDocPtr doc, xmlNodePtr ident, ident_config *common) {
         xmlFree(independent);
     }
 
+    htb_node = xmlGetProp(ident, (const xmlChar *) "htb_node");
+    htb_parent = xmlGetProp(ident, (const xmlChar *) "htb_parent");
+    if (htb_node == NULL) {
+        common->htb_node = -1;
+    } else {
+        sscanf((const char *)htb_node, "%x", &common->htb_node);
+        xmlFree(htb_node);
+    }
+    if (htb_parent == NULL) {
+        common->htb_parent = -1;
+    } else {
+        sscanf((const char *)htb_parent, "%x", &common->htb_parent);
+        xmlFree(htb_parent);
+    }
+
     while (fields != NULL) {
         if((!xmlStrcmp(fields->name, (const xmlChar *) "peer"))) {
             xmlChar *ip = xmlNodeListGetString(doc, fields->children, 1);
@@ -294,11 +313,12 @@ static int parse_common(xmlDocPtr doc, xmlNodePtr ident, ident_config *common) {
         } else if ((!xmlStrcmp(fields->name, (const xmlChar *) "zkhost"))) {
             xmlChar *host = xmlNodeListGetString(doc, fields->children, 1);
 
+#ifdef BUILD_ZOOKEEPER
             common->zk_host = strdup((const char *) host);
             if (common->zk_host == NULL) {
                 return ENOMEM;
             }
-
+#endif
             xmlFree(host);
         }
         fields = fields->next;
@@ -309,11 +329,12 @@ static int parse_common(xmlDocPtr doc, xmlNodePtr ident, ident_config *common) {
         return EINVAL;
     }
 
+#ifdef BUILD_ZOOKEEPER
     if (common->membership == ZOOKEEPER && common->zk_host == NULL) {
         printlog(LOG_CRITICAL, "Group membership protocol ZOOKEEPER requires a zkhost field.\n");
         return EINVAL;
     }
-
+#endif
     /* No errors. */
     return 0;
 }