+ return mp_alloc_zero(cfpool, size);
+}
+
+byte *
+cfg_strdup(byte *s)
+{
+ return mp_strdup(cfpool, s);
+}
+
+void cf_register(struct cfitem *items)
+{
+ if(items[0].type!=CT_SECTION && items[0].type!=CT_INCOMPLETE_SECTION)
+ die("cf_register: Invalid section type");
+ items[0].var=cfsection;
+ cfsection=items;
+}
+
+int cf_item_count(void)
+{
+ struct cfitem *sect, *item;
+ int count = 0;
+ for (sect = cfsection; sect; sect = sect->var)
+ for (item = sect+1; item->type; item++)
+ count++;
+ return count;
+}
+
+struct cfitem *cf_get_item(byte *sect, byte *name)
+{
+ struct cfitem *item, *section;
+
+ item=cfsection;
+ while(item && strcasecmp(item->name,sect))
+ item=item->var;
+ if(!item) /* unknown section */
+ return NULL;
+ section = item;
+
+ for(item++; item->type && strcasecmp(item->name,name); item++);
+ if (!item->type && section->type == CT_INCOMPLETE_SECTION)
+ return NULL;
+
+ return item; /* item->type == 0 if not found */
+}
+
+struct unit {
+ uns name; /* One-letter name of the unit */
+ uns num, den; /* Fraction */
+};
+
+static const struct unit units[] = {
+ { 'd', 86400, 1 },
+ { 'h', 3600, 1 },
+ { 'k', 1000, 1 },
+ { 'm', 1000000, 1 },
+ { 'g', 1000000000, 1 },
+ { 'K', 1024, 1 },
+ { 'M', 1048576, 1 },
+ { 'G', 1073741824, 1 },
+ { '%', 1, 100 },
+ { 0, 0, 0 }