X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fwebcit.c;h=8f51833deb32a180f9ebced1bc9ddc3177a9c016;hb=639575323070fadad9cc0e2687741e07c0d42cdd;hp=869793a2c2ace1b4c524d9d388b99c2e3c2dbaef;hpb=19efac53a8a87446e66e6e0213d7f9b46af60a48;p=citadel.git
diff --git a/webcit/webcit.c b/webcit/webcit.c
index 869793a2c..8f51833de 100644
--- a/webcit/webcit.c
+++ b/webcit/webcit.c
@@ -1,6 +1,4 @@
/*
- * $Id$
- *
* This is the main transaction loop of the web service. It maintains a
* persistent session to the Citadel server, handling HTTP WebCit requests as
* they arrive and presenting a user interface.
@@ -13,26 +11,28 @@
#include "webserver.h"
-/*
- * String to unset the cookie.
- * Any date "in the past" will work, so I chose my birthday, right down to
- * the exact minute. :)
- */
-static char *unset = "; expires=28-May-1971 18:10:00 GMT";
StrBuf *csslocal = NULL;
HashList *HandlerHash = NULL;
+void PutRequestLocalMem(void *Data, DeleteHashDataFunc DeleteIt)
+{
+ wcsession *WCC = WC;
+ int n;
+
+ n = GetCount(WCC->Hdr->HTTPHeaders);
+ Put(WCC->Hdr->HTTPHeaders, IKEY(n), Data, DeleteIt);
+}
void DeleteWebcitHandler(void *vHandler)
{
WebcitHandler *Handler = (WebcitHandler*) vHandler;
FreeStrBuf(&Handler->Name);
+ FreeStrBuf(&Handler->DisplayName);
free (Handler);
-
}
-void WebcitAddUrlHandler(const char * UrlString,
- long UrlSLen,
+void WebcitAddUrlHandler(const char * UrlString, long UrlSLen,
+ const char *DisplayName, long dslen,
WebcitHandlerFunc F,
long Flags)
{
@@ -42,24 +42,43 @@ void WebcitAddUrlHandler(const char * UrlString,
NewHandler->Flags = Flags;
NewHandler->Name = NewStrBufPlain(UrlString, UrlSLen);
StrBufShrinkToFit(NewHandler->Name, 1);
+ NewHandler->DisplayName = NewStrBufPlain(DisplayName, dslen);
+ StrBufShrinkToFit(NewHandler->DisplayName, 1);
Put(HandlerHash, UrlString, UrlSLen, NewHandler, DeleteWebcitHandler);
}
+void tmplput_HANDLER_DISPLAYNAME(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ if (WCC->Hdr->HR.Handler != NULL)
+ StrBufAppendTemplate(Target, TP, WCC->Hdr->HR.Handler->DisplayName, 0);
+}
+
/*
* web-printing funcion. uses our vsnprintf wrapper
*/
-void wprintf(const char *format,...)
+#ifdef UBER_VERBOSE_DEBUGGING
+void wcc_printf(const char *FILE, const char *FUNCTION, long LINE, const char *format,...)
+#else
+void wc_printf(const char *format,...)
+#endif
{
wcsession *WCC = WC;
va_list arg_ptr;
if (WCC->WBuf == NULL)
WCC->WBuf = NewStrBuf();
+#ifdef UBER_VERBOSE_DEBUGGING
+ StrBufAppendPrintf(WCC->WBuf, "\n%s:%s:%d[", FILE, FUNCTION, LINE);
+#endif
va_start(arg_ptr, format);
StrBufVAppendPrintf(WCC->WBuf, format, arg_ptr);
va_end(arg_ptr);
+#ifdef UBER_VERBOSE_DEBUGGING
+ StrBufAppendPrintf(WCC->WBuf, "]\n");
+#endif
}
/*
@@ -87,7 +106,7 @@ void hprintf(const char *format,...)
void wDumpContent(int print_standard_html_footer)
{
if (print_standard_html_footer) {
- wprintf(" \n");
+ wc_printf(" \n");
do_template("trailing", NULL);
}
@@ -103,20 +122,19 @@ void wDumpContent(int print_standard_html_footer)
/*
* Output HTTP headers and leading HTML for a page
*/
-void output_headers( int do_httpheaders, /* 1 = output HTTP headers */
+void output_headers( int do_httpheaders, /* 1 = output HTTP headers */
int do_htmlhead, /* 1 = output HTML
section and opener */
- int do_room_banner, /* 0=no, 1=yes,
+ int do_room_banner, /* 0=no, 1=yes,
* 2 = I'm going to embed my own, so don't open the
- *
either.
+ *
either.
*/
int unset_cookies, /* 1 = session is terminating, so unset the cookies */
- int suppress_check, /* 1 = suppress check for instant messages */
- int cache /* 1 = allow browser to cache this page */
+ int suppress_check, /* 1 = suppress check for instant messages */
+ int cache /* 1 = allow browser to cache this page */
) {
wcsession *WCC = WC;
- char cookie[1024];
char httpnow[128];
hprintf("HTTP/1.1 200 OK\n");
@@ -157,25 +175,7 @@ void output_headers( int do_httpheaders, /* 1 = output HTTP headers
);
}
- if (cache < 2) {
-
- stuff_to_cookie(cookie, 1024,
- WCC->wc_session,
- WCC->wc_username,
- WCC->wc_password,
- WCC->wc_roomname,
- get_selected_language()
- );
-
- if (unset_cookies) {
- hprintf("Set-cookie: webcit=%s; path=/\r\n", unset);
- } else {
- hprintf("Set-cookie: webcit=%s; path=/\r\n", cookie);
- if (server_cookie != NULL) {
- hprintf("%s\n", server_cookie);
- }
- }
- }
+ if (cache < 2) stuff_to_cookie(unset_cookies);
if (do_htmlhead) {
begin_burst();
@@ -183,10 +183,10 @@ void output_headers( int do_httpheaders, /* 1 = output HTTP headers
/* check for ImportantMessages (these display in a div overlaying the main screen) */
if (!IsEmptyStr(WCC->ImportantMessage)) {
- wprintf("