StrBuf *FileName;
int nTokensUsed;
int TokenSpace;
+ StrBuf *MimeType;
WCTemplateToken **Tokens;
} WCTemplate;
}
FreeStrBuf(&FreeMe->FileName);
FreeStrBuf(&FreeMe->Data);
+ FreeStrBuf(&FreeMe->MimeType);
free(FreeMe);
}
NewTemplate->nTokensUsed = 0;
NewTemplate->TokenSpace = 0;
NewTemplate->Tokens = NULL;
+ NewTemplate->MimeType = NewStrBufPlain(GuessMimeByFilename (SKEY(NewTemplate->FileName)), -1);
if (StrBufReadBLOB(NewTemplate->Data, &fd, 1, statbuf.st_size, &Err) < 0) {
close(fd);
FreeWCTemplate(NewTemplate);
-void ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, WCTemplputParams *CallingTP)
+const StrBuf *ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, WCTemplputParams *CallingTP)
{
WCTemplate *pTmpl = Tmpl;
int done = 0;
Target,
"<pre>\nError loading Template [%s]\n See Logfile for details\n</pre>\n",
ChrPtr(Tmpl->FileName));
- return;
+ return NULL;
}
}
if (LoadTemplates != 0) {
FreeWCTemplate(pTmpl);
}
+ return Tmpl->MimeType;
+
}
/**
* \brief Display a variable-substituted template
* \param templatename template file to load
+ * \returns the mimetype of the template its doing
*/
-void DoTemplate(const char *templatename, long len, StrBuf *Target, WCTemplputParams *TP)
+const StrBuf *DoTemplate(const char *templatename, long len, StrBuf *Target, WCTemplputParams *TP)
{
WCTemplputParams LocalTP;
HashList *Static;
{
lprintf (1, "Can't to load a template with empty name!\n");
StrBufAppendPrintf(Target, "<pre>\nCan't to load a template with empty name!\n</pre>");
- return;
+ return NULL;
}
if (!GetHash(StaticLocal, templatename, len, &vTmpl) &&
dbg_PrintHash(Static, PrintTemplate, NULL);
PrintHash(Static, VarPrintTransition, PrintTemplate);
#endif
- return;
+ return NULL;
}
if (vTmpl == NULL)
- return;
- ProcessTemplate(vTmpl, Target, TP);
+ return NULL;
+ return ProcessTemplate(vTmpl, Target, TP);
+
}
/*-----------------------------------------------------------------------------
#define do_template(a, b) DoTemplate(a, sizeof(a) -1, NULL, &NoCtx);
-void DoTemplate(const char *templatename, long len, StrBuf *Target, WCTemplputParams *TP);
+const StrBuf *DoTemplate(const char *templatename, long len, StrBuf *Target, WCTemplputParams *TP);
void url_do_template(void);
* A template has been requested
*/
void url_do_template(void) {
+ const StrBuf *MimeType;
const StrBuf *Tmpl = sbstr("template");
begin_burst();
- output_headers(1, 0, 0, 0, 1, 0);
- DoTemplate(SKEY(Tmpl), NULL, &NoCtx);
- end_burst();
+ output_headers(0, 0, 0, 0, 1, 0);
+ MimeType = DoTemplate(SKEY(Tmpl), NULL, &NoCtx);
+ http_transmit_thing(ChrPtr(MimeType), 0);
}