summaryrefslogtreecommitdiff
path: root/lib/conf.c
diff options
context:
space:
mode:
authorlinus <linus@nordu.net>2011-01-21 13:09:00 +0100
committerlinus <linus@nordu.net>2011-01-21 13:09:00 +0100
commita29c3f1a7a00684804b032970ed347fa05ca9cce (patch)
treed17f8a509ec2c216898e925ec2979e9434d06ae4 /lib/conf.c
parent2bd25761177373972eb38a0700426787f1fb2d24 (diff)
Fix bug where one or two stanzas in a config file would be but not more.
Also restructure error handling in rs_context_create().
Diffstat (limited to 'lib/conf.c')
-rw-r--r--lib/conf.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/conf.c b/lib/conf.c
index d42f2cd..8519922 100644
--- a/lib/conf.c
+++ b/lib/conf.c
@@ -70,10 +70,8 @@ rs_context_read_config(struct rs_context *ctx, const char *config_file)
if (!r)
return rs_err_ctx_push_fl (ctx, RSE_NOMEM, __FILE__, __LINE__, NULL);
memset (r, 0, sizeof(*r));
- if (ctx->realms)
- ctx->realms->next = r;
- else
- ctx->realms = r;
+ r->next = ctx->realms->next;
+ ctx->realms->next = r;
cfg_config = cfg_getnsec (cfg, "config", i);
r->name = strdup (cfg_title (cfg_config));
@@ -115,12 +113,12 @@ rs_context_read_config(struct rs_context *ctx, const char *config_file)
return RSE_OK;
}
-struct rs_realm
-*rs_conf_find_realm(struct rs_context *ctx, const char *name)
+struct rs_realm *
+rs_conf_find_realm(struct rs_context *ctx, const char *name)
{
struct rs_realm *r;
- for (r = ctx->realms; r; r = r->next)
+ for (r = ctx->realms->next; r != ctx->realms; r = r->next)
if (!strcmp (r->name, name))
return r;
return NULL;