summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/afb-hsrv.c29
-rw-r--r--src/afb-hsrv.h2
2 files changed, 22 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;
diff --git a/src/afb-hsrv.h b/src/afb-hsrv.h
index 913de80c..0f469a89 100644
--- a/src/afb-hsrv.h
+++ b/src/afb-hsrv.h
@@ -20,6 +20,7 @@
struct afb_hsrv;
struct afb_hreq;
+struct locale_root;
extern struct afb_hsrv *afb_hsrv_create();
extern void afb_hsrv_put(struct afb_hsrv *hsrv);
@@ -28,5 +29,6 @@ extern void afb_hsrv_stop(struct afb_hsrv *hsrv);
extern int afb_hsrv_start(struct afb_hsrv *hsrv, uint16_t port, unsigned int connection_timeout);
extern int afb_hsrv_set_cache_timeout(struct afb_hsrv *hsrv, int duration);
extern int afb_hsrv_add_alias(struct afb_hsrv *hsrv, const char *prefix, const char *alias, int priority, int relax);
+extern int afb_hsrv_add_alias_root(struct afb_hsrv *hsrv, const char *prefix, struct locale_root *root, int priority, int relax);
extern int afb_hsrv_add_handler(struct afb_hsrv *hsrv, const char *prefix, int (*handler) (struct afb_hreq *, void *), void *data, int priority);