3,7 → 3,7 |
one is unloaded first. |
--- /dev/null |
+++ b/shared/dlopen_templates.c |
@@ -0,0 +1,34 @@ |
@@ -0,0 +1,40 @@ |
+#include <dlfcn.h> |
+#include "shared.h" |
+ |
21,6 → 21,10 |
+ if (!handle || strcmp(tmi->name, set)) { |
+ char *filename = pool_printf(NIL, "/usr/lib/prayer/templates/%s%s.so", |
+ set, suffix); |
+ char *map_symbol = pool_printf(NIL, "template_map_%s", |
+ set); |
+ char *count_symbol = pool_printf(NIL, "template_map_%s_count", |
+ set); |
+ |
+ if (handle) { |
+ dlclose(handle); |
28,13 → 32,15 |
+ } |
+ tmi->name = pool_strdup(NIL, set); |
+ if (!(handle = dlopen(filename, RTLD_NOW)) |
+ || !(tmi->template_map = dlsym(handle, "template_map")) |
+ || !(tmi->count = dlsym(handle, "template_map_count"))) { |
+ || !(tmi->template_map = dlsym(handle, map_symbol)) |
+ || !(tmi->count = dlsym(handle, count_symbol))) { |
+ log_fatal("Failed to load template library: %s", |
+ dlerror()); |
+ } |
+ log_debug("Loaded library %s with %d templates", filename, *tmi->count); |
+ free(filename); |
+ free(map_symbol); |
+ free(count_symbol); |
+ } |
+ return tmi; |
+} |
44,15 → 50,8 |
+struct template_map_index *dlopen_templates(const char *set, const char *suffix); |
--- a/templates/cam/Makefile |
+++ b/templates/cam/Makefile |
@@ -8,10 +8,14 @@ endif |
@@ -11,7 +11,7 @@ LDFLAGS = $(BASELDFLAGS) |
|
CFLAGS = $(BASECFLAGS) |
LDFLAGS = $(BASELDFLAGS) |
+LDFLAGS_TEMPLATELIB = \ |
+ -Wl,--defsym=template_map=template_map_$(TYPE) \ |
+ -Wl,--defsym=template_map_count=template_map_$(TYPE)_count |
+LDFLAGS += $(LDFLAGS_TEMPLATELIB) |
|
TYPE=cam |
|
-TARGETS=templates.a templates_frontend.a |
60,20 → 59,20 |
|
T_FILES_FRONTEND=login.t login_hermes.t \ |
frontend_login_error.t frontend_security.t frontend_session.t \ |
@@ -111,6 +115,12 @@ templates.a: $(O_FILES) |
@@ -111,6 +111,12 @@ templates.a: $(O_FILES) |
rm -f templates.a |
ar q templates.a $(O_FILES) |
|
+$(TYPE)_frontend.so: $(O_FILES_FRONTEND) |
+ $(CC) $(LDFLAGS) -shared -o $@ $(O_FILES_FRONTEND) |
+ $(CC) $(LDFLAGS) -ldl -shared -o $@ $(O_FILES_FRONTEND) |
+ |
+$(TYPE).so: $(O_FILES) |
+ $(CC) $(LDFLAGS) -shared -o $@ $(O_FILES) |
+ $(CC) $(LDFLAGS) -ldl -shared -o $@ $(O_FILES) |
+ |
%.o: %.c Makefile |
$(CC) $(CFLAGS) -I../../lib -c $< |
|
@@ -129,6 +139,10 @@ install: |
@@ -129,8 +135,12 @@ install: |
cp *.t $(BROOT)$(PREFIX)/templates/$(TYPE) |
cp *.vars $(BROOT)$(PREFIX)/templates/$(TYPE) |
|
82,19 → 81,15 |
+ cp *.so $(BROOT)$(LIB_PREFIX)/templates/ |
+ |
clean: |
rm -f $(TARGETS) *.html *.o *.c \#*\# *~ |
- rm -f $(TARGETS) *.html *.o *.c \#*\# *~ |
+ rm -f $(TARGETS) *.html *.o *.so *.c \#*\# *~ |
|
include Makefile.deps |
|
--- a/templates/old/Makefile |
+++ b/templates/old/Makefile |
@@ -8,10 +8,14 @@ endif |
@@ -11,7 +11,7 @@ LDFLAGS = $(BASELDFLAGS) |
|
CFLAGS = $(BASECFLAGS) |
LDFLAGS = $(BASELDFLAGS) |
+LDFLAGS_TEMPLATELIB = \ |
+ -Wl,--defsym=template_map=template_map_$(TYPE) \ |
+ -Wl,--defsym=template_map_count=template_map_$(TYPE)_count |
+LDFLAGS += $(LDFLAGS_TEMPLATELIB) |
|
TYPE=old |
|
-TARGETS=templates.a templates_frontend.a |
102,20 → 97,20 |
|
T_FILES_FRONTEND=login.t \ |
frontend_login_error.t frontend_security.t frontend_session.t \ |
@@ -110,6 +114,12 @@ templates.a: $(O_FILES) |
@@ -110,6 +110,12 @@ templates.a: $(O_FILES) |
rm -f templates.a |
ar q templates.a $(O_FILES) |
|
+$(TYPE)_frontend.so: $(O_FILES_FRONTEND) |
+ $(CC) $(LDFLAGS) -shared -o $@ $(O_FILES_FRONTEND) |
+ $(CC) $(LDFLAGS) -ldl -shared -o $@ $(O_FILES_FRONTEND) |
+ |
+$(TYPE).so: $(O_FILES) |
+ $(CC) $(LDFLAGS) -shared -o $@ $(O_FILES) |
+ $(CC) $(LDFLAGS) -ldl -shared -o $@ $(O_FILES) |
+ |
%.o: %.c Makefile |
$(CC) $(CFLAGS) -I../../lib -c $< |
|
@@ -128,6 +138,10 @@ install: |
@@ -128,8 +134,12 @@ install: |
cp *.t $(BROOT)$(PREFIX)/templates/$(TYPE) |
cp *.vars $(BROOT)$(PREFIX)/templates/$(TYPE) |
|
124,8 → 119,11 |
+ cp *.so $(BROOT)$(LIB_PREFIX)/templates/ |
+ |
clean: |
rm -f $(TARGETS) *.html *.o *.c \#*\# *~ |
- rm -f $(TARGETS) *.html *.o *.c \#*\# *~ |
+ rm -f $(TARGETS) *.html *.o *.so *.c \#*\# *~ |
|
include Makefile.deps |
|
--- a/servers/prayer_chroot.c |
+++ b/servers/prayer_chroot.c |
@@ -255,6 +255,8 @@ int main(int argc, char *argv[]) |