X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fsubst.c;h=77c8a370d51cc8a1e122e6a956e88c4b408cb5b7;hb=501b255d375ab099bc59455374a24f15da05d7d2;hp=2cccbc1478a46f19873954fa4268eee3364a46b9;hpb=c2233a60c147fc68531834b0227c703ecdacc5d0;p=citadel.git 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 "));