31 int nusers, user, name, secret;
42 userfile = CONFIG_DIR
"/router-users.xml";
44 f = fopen(userfile,
"rb");
46 log_write(r->
log, LOG_ERR,
"couldn't open user table file %s: %s", userfile, strerror(errno));
50 fseek(f, 0, SEEK_END);
52 fseek(f, 0, SEEK_SET);
54 buf = (
char *) malloc(
sizeof(
char) * size);
56 if (fread(buf, 1, size, f) != size || ferror(f)) {
57 log_write(r->
log, LOG_ERR,
"couldn't read from user table file: %s", strerror(errno));
81 log_write(r->
log, LOG_ERR,
"malformed user entry in user table file, skipping");
87 xhash_put(r->
users,
pstrdupx(
xhash_pool(r->
users),
NAD_CDATA(nad, name),
NAD_CDATA_L(nad, name)),
pstrdupx(
xhash_pool(r->
users),
NAD_CDATA(nad, secret),
NAD_CDATA_L(nad, secret)));
96 log_write(r->
log, LOG_NOTICE,
"loaded user table (%d users)", nusers);
#define NAD_CDATA_L(N, E)
int nad_find_elem(nad_t nad, int elem, int ns, const char *name, int depth)
locate the next elem at a given depth with an optional matching name
void log_write(log_t log, int level, const char *msgfmt,...)
int user_table_load(router_t r)
user table manager
void nad_free(nad_t nad)
free that nad
void user_table_unload(router_t r)
nad_t nad_parse(const char *buf, int len)
create a nad from raw xml
char * pstrdupx(pool_t p, const char *src, int len)
use given size
void xhash_put(xht h, const char *key, void *val)
pool_t xhash_pool(xht h)
get our pool
const char * config_get_one(config_t c, const char *key, int num)
get config value n for this key