summaryrefslogtreecommitdiff
path: root/accel-pppd/triton
diff options
context:
space:
mode:
authorKozlov Dmitry <dima@server>2012-10-03 19:04:10 +0400
committerKozlov Dmitry <xeb@mail.ru>2013-01-24 23:49:22 +0400
commit16ea2cdf30cf0ec046e7e1766659ffa27e63aa33 (patch)
tree7723bbdb1224af6baa0cd1282d8b8796e1377df6 /accel-pppd/triton
parent59a82263d482f74f1405c19fb78f16873f2f8bac (diff)
downloadaccel-ppp-16ea2cdf30cf0ec046e7e1766659ffa27e63aa33.tar.gz
accel-ppp-16ea2cdf30cf0ec046e7e1766659ffa27e63aa33.zip
ipool: implemneted net30 allocator
Diffstat (limited to 'accel-pppd/triton')
-rw-r--r--accel-pppd/triton/conf_file.c16
-rw-r--r--accel-pppd/triton/triton.h1
2 files changed, 13 insertions, 4 deletions
diff --git a/accel-pppd/triton/conf_file.c b/accel-pppd/triton/conf_file.c
index ce8549c9..d859596e 100644
--- a/accel-pppd/triton/conf_file.c
+++ b/accel-pppd/triton/conf_file.c
@@ -24,14 +24,14 @@ static char* skip_word(char *str);
static struct conf_sect_t *find_sect(const char *name);
static struct conf_sect_t *create_sect(const char *name);
-static void sect_add_item(struct conf_sect_t *sect, const char *name, const char *val);
+static void sect_add_item(struct conf_sect_t *sect, const char *name, const char *val, char *raw);
static struct conf_option_t *find_item(struct conf_sect_t *, const char *name);
static char *buf;
int __conf_load(const char *fname, struct conf_sect_t *cur_sect)
{
- char *str,*str2;
+ char *str, *str2, *raw;
int cur_line = 0;
FILE *f = fopen(fname, "r");
@@ -50,6 +50,7 @@ int __conf_load(const char *fname, struct conf_sect_t *cur_sect)
str = skip_space(buf);
if (*str == '#' || *str == 0)
continue;
+
if (strncmp(str, "$include", 8) == 0) {
str = skip_word(str);
str = skip_space(str);
@@ -57,6 +58,7 @@ int __conf_load(const char *fname, struct conf_sect_t *cur_sect)
break;
continue;
}
+
if (*str == '[') {
for (str2 = ++str; *str2 && *str2 != ']'; str2++);
if (*str2 != ']') {
@@ -69,15 +71,19 @@ int __conf_load(const char *fname, struct conf_sect_t *cur_sect)
cur_sect = create_sect(str);
continue;
}
+
if (!cur_sect) {
fprintf(stderr, "conf_file:%s:%i: no section opened\n", fname, cur_line);
return -1;
}
+
+ raw = _strdup(str);
str2 = skip_word(str);
if (*str2 == ' ') {
*str2 = 0;
++str2;
}
+
str2 = skip_space(str2);
if (*str2 == '=' || *str2 == ',') {
*str2 = 0;
@@ -99,7 +105,7 @@ int __conf_load(const char *fname, struct conf_sect_t *cur_sect)
}
} else
str2 = NULL;
- sect_add_item(cur_sect, str, str2);
+ sect_add_item(cur_sect, str, str2, raw);
}
fclose(f);
@@ -162,6 +168,7 @@ int conf_reload(const char *fname)
if (opt->val)
_free(opt->val);
_free(opt->name);
+ _free(opt->raw);
_free(opt);
}
_free((char *)sect->sect->name);
@@ -205,12 +212,13 @@ static struct conf_sect_t *create_sect(const char *name)
return s->sect;
}
-static void sect_add_item(struct conf_sect_t *sect, const char *name, const char *val)
+static void sect_add_item(struct conf_sect_t *sect, const char *name, const char *val, char *raw)
{
struct conf_option_t *opt = _malloc(sizeof(struct conf_option_t));
opt->name = _strdup(name);
opt->val = val ? _strdup(val) : NULL;
+ opt->raw = raw;
list_add_tail(&opt->entry, &sect->items);
}
diff --git a/accel-pppd/triton/triton.h b/accel-pppd/triton/triton.h
index 95851c2d..98955dfc 100644
--- a/accel-pppd/triton/triton.h
+++ b/accel-pppd/triton/triton.h
@@ -42,6 +42,7 @@ struct conf_option_t
struct list_head entry;
char *name;
char *val;
+ char *raw;
};
struct conf_sect_t