From 501b255d375ab099bc59455374a24f15da05d7d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Tue, 2 Oct 2007 23:13:23 +0000 Subject: [PATCH] * calculate dirs right * use the static.local / static aproach in our templates section too. --- webcit/Makefile.in | 17 ++--------------- webcit/configure.ac | 5 ++++- webcit/subst.c | 25 +++++++++++++++++++------ webcit/webserver.c | 4 ++-- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/webcit/Makefile.in b/webcit/Makefile.in index ef6465b1f..1c31348aa 100644 --- a/webcit/Makefile.in +++ b/webcit/Makefile.in @@ -17,9 +17,8 @@ top_builddir=`pwd` LIB_SUBDIRS= PROG_SUBDIRS=@PROG_SUBDIRS@ SUBDIRS=$(LIB_SUBDIRS) $(PROG_SUBDIRS) -#LOCALEDIR=@LOCALEDIR@ -#WWWDIR=@WWWDIR@ -#EDITORDIR=@EDITORDIR@ +LOCALEDIR=@LOCALEDIR@ +WWWDIR=@WWWDIR@ # End of configuration section @@ -73,18 +72,6 @@ webserver: webserver.o context_loop.o tools.o ical_dezonify.o \ .cpp.o: $(CC) $(CFLAGS) $(DEFS) -c $(PTHREAD_DEFS) $< -#.c.o: -# $(CC) $(CFLAGS) $(DEFS) -c $(PTHREAD_DEFS) \ -# -DWEBCITDIR=\"$(WWWDIR)\" \ -# -DLOCALEDIR=\"$(LOCALEDIR)\" \ -# -DEDITORDIR=\"$(EDITORDIR)\" $< -# -#.cpp.o: -# $(CC) $(CFLAGS) $(DEFS) -c $(PTHREAD_DEFS) \ -# -DWEBCITDIR=\"$(WWWDIR)\" \ -# -DLOCALEDIR=\"$(LOCALEDIR)\" \ -# -DEDITORDIR=\"$(EDITORDIR)\"$< -# Makefile: $(srcdir)/Makefile.in config.status CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status diff --git a/webcit/configure.ac b/webcit/configure.ac index d5335eb4d..f0f968738 100644 --- a/webcit/configure.ac +++ b/webcit/configure.ac @@ -412,6 +412,8 @@ AC_ARG_WITH(localedir, ] ) AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir",[where to find our pot files]) +LOCALEDIR=$localedir +AC_SUBST(LOCALEDIR) dnl Checks where to put our templates AC_ARG_WITH(wwwdir, @@ -422,7 +424,8 @@ AC_ARG_WITH(wwwdir, ] ) AC_DEFINE_UNQUOTED(WWWDIR, "$wwwdir", [where to find our templates and pics]) - +WWWDIR=$wwwdir +AC_SUBST(WWWDIR) dnl Checks for the run-dir for the sockets diff --git a/webcit/subst.c b/webcit/subst.c index 2cccbc147..77c8a370d 100644 --- a/webcit/subst.c +++ b/webcit/subst.c @@ -8,8 +8,12 @@ /*@{*/ -#include "webcit.h" +#include "sysdep.h" +#include +#include +#include +#include "webcit.h" /** * \brief Clear out the list of substitution variables local to this session @@ -190,27 +194,36 @@ void print_value_of(char *keyname) { } } - +extern char *static_dirs[PATH_MAX]; /**< Disk representation */ /** * \brief Display a variable-substituted template * \param templatename template file to load */ void do_template(void *templatename) { + char flat_filename[PATH_MAX]; char filename[PATH_MAX]; FILE *fp; char inbuf[1024]; char outbuf[sizeof inbuf]; char key[sizeof inbuf]; int i, pos; + struct stat mystat; - strcpy(filename, "static/"); - strcat(filename, templatename); + strcpy(flat_filename, templatename); if (WC->is_wap) - strcat(filename, ".wml"); + strcat(flat_filename, ".wml"); else - strcat(filename, ".html"); + strcat(flat_filename, ".html"); + strcpy(filename, static_dirs[1]); + strcat(filename, flat_filename); + if (stat(filename, &mystat) == -1) + { + strcpy(filename, static_dirs[0]); + strcat(filename, flat_filename); + } + fp = fopen(filename, "r"); if (fp == NULL) { wprintf(_("ERROR: could not open template ")); diff --git a/webcit/webserver.c b/webcit/webserver.c index d280ac8fe..d67fcc956 100644 --- a/webcit/webserver.c +++ b/webcit/webserver.c @@ -772,9 +772,9 @@ int main(int argc, char **argv) (dirbuffer[0]!='\0')?"/":""); basedir=RUNDIR; COMPUTE_DIRECTORY(socket_dir); - basedir=DATADIR "/static"; + basedir=WWWDIR "/static"; COMPUTE_DIRECTORY(static_dir); - basedir=DATADIR "/static.local"; + basedir=WWWDIR "/static.local"; COMPUTE_DIRECTORY(static_local_dir); snprintf(file_crpt_file_key, -- 2.30.2