diff options
author | José Bollo <jose.bollo@iot.bzh> | 2016-08-29 23:31:47 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2016-08-29 23:31:47 +0200 |
commit | 540ece2baf7de59565b42d427e206769ec4da56a (patch) | |
tree | 211d4030ea22dbf32fffe6fd6f9619c63d74242c /src/afb-hsrv.c | |
parent | 399d235e33b55922f15570f0ee0076529c518efc (diff) |
afb-hsrv: expose locale root for alias
This prepare further use of locale_root
here and ther in the code.
Change-Id: I473e8de79db1cbd69b507f6e0e70733f0f02badc
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-hsrv.c')
-rw-r--r-- | src/afb-hsrv.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/afb-hsrv.c b/src/afb-hsrv.c index 15b2a5f2..45779483 100644 --- a/src/afb-hsrv.c +++ b/src/afb-hsrv.c @@ -342,28 +342,39 @@ int afb_hsrv_add_handler( return 1; } -int afb_hsrv_add_alias(struct afb_hsrv *hsrv, const char *prefix, const char *alias, int priority, int relax) +int afb_hsrv_add_alias_root(struct afb_hsrv *hsrv, const char *prefix, struct locale_root *root, int priority, int relax) { - struct locale_root *root; struct hsrv_alias *da; - root = locale_root_create(AT_FDCWD, alias); - if (root == NULL) { - /* TODO message */ - return 0; - } da = malloc(sizeof *da); if (da != NULL) { da->root = root; da->relax = relax; - if (afb_hsrv_add_handler(hsrv, prefix, handle_alias, da, priority)) + if (afb_hsrv_add_handler(hsrv, prefix, handle_alias, da, priority)) { + locale_root_addref(root); return 1; + } free(da); } - locale_root_unref(root); return 0; } +int afb_hsrv_add_alias(struct afb_hsrv *hsrv, const char *prefix, const char *alias, int priority, int relax) +{ + struct locale_root *root; + int rc; + + root = locale_root_create(AT_FDCWD, alias); + if (root == NULL) { + /* TODO message */ + rc = 0; + } else { + rc = afb_hsrv_add_alias_root(hsrv, prefix, root, priority, relax); + locale_root_unref(root); + } + return rc; +} + int afb_hsrv_set_cache_timeout(struct afb_hsrv *hsrv, int duration) { int rc; |