#include "lib/chartype.h"
#include "lib/fastbuf.h"
-#include "lib/lfs.h"
+#include "lib/pools.h"
#include "lib/conf.h"
#define MAX_LEVEL 8
static struct cfitem *cfsection;
+static struct mempool *cfpool;
+
+static void CONSTRUCTOR
+conf_init(void)
+{
+ cfpool = mp_new(4096);
+}
+
+void *
+cfg_malloc(uns size)
+{
+ return mp_alloc(cfpool, size);
+}
+
+byte *
+cfg_stralloc(byte *s)
+{
+ uns l = strlen(s);
+ byte *k = cfg_malloc(l + 1);
+ strcpy(k, s);
+ return k;
+}
void cf_register(struct cfitem *items)
{
break;
}
case CT_STRING:
- *((byte **) item->var) = stralloc(value);
+ *((byte **) item->var) = cfg_stralloc(value);
break;
case CT_FUNCTION:
- msg = ((ci_func) item->var)(item, value);
+ msg = ((ci_func) item->var)(item, cfg_stralloc(value));
break;
default:
msg = "Unknown keyword";
return 0;
}
- fd=sh_open(filename,O_RDONLY, 0666);
+ fd=open(filename,O_RDONLY, 0666);
if(fd<0){
log(L_ERROR,"Cannot open configuration file %s: %m",filename);
return 0;
#include <getopt.h>
+/*
+ * Allocation in configuration memory pool.
+ */
+
+void *
+cfg_malloc(uns size);
+
+byte *
+cfg_stralloc(byte *s);
+
/*
* Every module places its configuration setting into some section. Section is
* an array of cfitem, whose first record is of type CT_SECTION and contains