New cf_pairtovp() function, to support the "update" sections
authoraland <aland>
Wed, 30 May 2007 08:34:42 +0000 (08:34 +0000)
committeraland <aland>
Wed, 30 May 2007 08:34:42 +0000 (08:34 +0000)
src/include/conffile.h
src/main/conffile.c

index 385d5bb..9a4dba5 100644 (file)
@@ -69,6 +69,7 @@ int cf_data_add(CONF_SECTION *, const char *, void *, void (*)(void *));
 
 char *cf_pair_attr(CONF_PAIR *pair);
 char *cf_pair_value(CONF_PAIR *pair);
+VALUE_PAIR *cf_pairtovp(CONF_PAIR *pair);
 const char *cf_section_name1(const CONF_SECTION *);
 const char *cf_section_name2(const CONF_SECTION *);
 int dump_config(void);
index ad795de..ae1ae6a 100644 (file)
@@ -1494,6 +1494,26 @@ char *cf_pair_value(CONF_PAIR *pair)
 }
 
 /*
+ * Turn a CONF_PAIR into a VALUE_PAIR
+ * For now, ignore the "value_type" field...
+ */
+VALUE_PAIR *cf_pairtovp(CONF_PAIR *pair)
+{
+       DICT_ATTR *da;
+       VALUE_PAIR *vp;
+
+       da = dict_attrbyname(pair->attr);
+       if (!da) return NULL;
+
+       vp = pairalloc(da);
+       if (!vp) return NULL;
+
+       vp->operator = pair->operator;
+
+       return vp;
+}
+
+/*
  * Return the first label of a CONF_SECTION
  */