2 * This is the main transaction loop of the web service. It maintains a
3 * persistent session to the Citadel server, handling HTTP WebCit requests as
4 * they arrive and presenting a user interface.
6 #define SHOW_ME_VAPPEND_PRINTF
11 #include "webserver.h"
14 StrBuf *csslocal = NULL;
15 HashList *HandlerHash = NULL;
17 void PutRequestLocalMem(void *Data, DeleteHashDataFunc DeleteIt)
22 n = GetCount(WCC->Hdr->HTTPHeaders);
23 Put(WCC->Hdr->HTTPHeaders, IKEY(n), Data, DeleteIt);
26 void DeleteWebcitHandler(void *vHandler)
28 WebcitHandler *Handler = (WebcitHandler*) vHandler;
29 FreeStrBuf(&Handler->Name);
30 FreeStrBuf(&Handler->DisplayName);
34 void WebcitAddUrlHandler(const char * UrlString, long UrlSLen,
35 const char *DisplayName, long dslen,
39 WebcitHandler *NewHandler;
40 NewHandler = (WebcitHandler*) malloc(sizeof(WebcitHandler));
42 NewHandler->Flags = Flags;
43 NewHandler->Name = NewStrBufPlain(UrlString, UrlSLen);
44 StrBufShrinkToFit(NewHandler->Name, 1);
45 NewHandler->DisplayName = NewStrBufPlain(DisplayName, dslen);
46 StrBufShrinkToFit(NewHandler->DisplayName, 1);
47 Put(HandlerHash, UrlString, UrlSLen, NewHandler, DeleteWebcitHandler);
50 void tmplput_HANDLER_DISPLAYNAME(StrBuf *Target, WCTemplputParams *TP)
53 if (WCC->Hdr->HR.Handler != NULL)
54 StrBufAppendTemplate(Target, TP, WCC->Hdr->HR.Handler->DisplayName, 0);
59 * web-printing funcion. uses our vsnprintf wrapper
61 #ifdef UBER_VERBOSE_DEBUGGING
62 void wcc_printf(const char *FILE, const char *FUNCTION, long LINE, const char *format,...)
64 void wc_printf(const char *format,...)
70 if (WCC->WBuf == NULL)
71 WCC->WBuf = NewStrBuf();
72 #ifdef UBER_VERBOSE_DEBUGGING
73 StrBufAppendPrintf(WCC->WBuf, "\n%s:%s:%d[", FILE, FUNCTION, LINE);
76 va_start(arg_ptr, format);
77 StrBufVAppendPrintf(WCC->WBuf, format, arg_ptr);
79 #ifdef UBER_VERBOSE_DEBUGGING
80 StrBufAppendPrintf(WCC->WBuf, "]\n");
85 * http-header-printing funcion. uses our vsnprintf wrapper
87 void hprintf(const char *format,...)
92 va_start(arg_ptr, format);
93 StrBufVAppendPrintf(WCC->HBuf, format, arg_ptr);
100 * wrap up an HTTP session, closes tags, etc.
102 * print_standard_html_footer should be set to:
103 * 0 - to transmit only,
104 * nonzero - to append the closing tags
106 void wDumpContent(int print_standard_html_footer)
108 if (print_standard_html_footer) {
109 wc_printf("</div> <!-- end of 'content' div -->\n");
110 do_template("trailing", NULL);
113 /* If we've been saving it all up for one big output burst,
114 * go ahead and do that now.
123 * Output HTTP headers and leading HTML for a page
125 void output_headers( int do_httpheaders, /* 1 = output HTTP headers */
126 int do_htmlhead, /* 1 = output HTML <head> section and <body> opener */
128 int do_room_banner, /* 0=no, 1=yes,
129 * 2 = I'm going to embed my own, so don't open the
130 * <div id="content"> either.
133 int unset_cookies, /* 1 = session is terminating, so unset the cookies */
134 int suppress_check, /* 1 = suppress check for instant messages */
135 int cache /* 1 = allow browser to cache this page */
140 hprintf("HTTP/1.1 200 OK\n");
141 http_datestring(httpnow, sizeof httpnow, time(NULL));
143 if (do_httpheaders) {
144 if (WCC->serv_info != NULL)
145 hprintf("Content-type: text/html; charset=utf-8\r\n"
147 "Connection: close\r\n",
149 ChrPtr(WCC->serv_info->serv_software));
151 hprintf("Content-type: text/html; charset=utf-8\r\n"
152 "Server: %s / [n/a]\n"
153 "Connection: close\r\n",
158 char httpTomorow[128];
160 http_datestring(httpTomorow, sizeof httpTomorow,
161 time(NULL) + 60 * 60 * 24 * 2);
163 hprintf("Pragma: public\r\n"
164 "Cache-Control: max-age=3600, must-revalidate\r\n"
165 "Last-modified: %s\r\n"
172 hprintf("Pragma: no-cache\r\n"
173 "Cache-Control: no-store\r\n"
178 if (cache < 2) stuff_to_cookie(unset_cookies);
182 do_template("head", NULL);
184 /* check for ImportantMessages (these display in a div overlaying the main screen) */
185 if (!IsEmptyStr(WCC->ImportantMessage)) {
186 wc_printf("<div id=\"important_message\">\n"
187 "<span class=\"imsg\">");
188 StrEscAppend(WCC->WBuf, NULL, WCC->ImportantMessage, 0, 0);
189 wc_printf("</span><br>\n"
192 StrBufAppendBufPlain(WCC->trailing_javascript,
193 HKEY("setTimeout('hide_imsg_popup()', 5000); \n"),
196 WCC->ImportantMessage[0] = 0;
198 else if (StrLength(WCC->ImportantMsg) > 0) {
199 wc_printf("<div id=\"important_message\">\n"
200 "<span class=\"imsg\">");
201 StrEscAppend(WCC->WBuf, WCC->ImportantMsg, NULL, 0, 0);
202 wc_printf("</span><br>\n"
205 StrBufAppendBufPlain(WCC->trailing_javascript,
206 HKEY("setTimeout('hide_imsg_popup()', 5000); \n"),
209 FlushStrBuf(WCC->ImportantMsg);
211 if ( (WCC->logged_in) && (!unset_cookies) ) {
212 DoTemplate(HKEY("paging"), NULL, &NoCtx);
215 if (do_room_banner == 1) {
216 tmplput_roombanner(NULL, NULL);
220 if (do_room_banner == 1) {
221 wc_printf("<div id=\"content\">\n");
225 void output_custom_content_header(const char *ctype) {
226 hprintf("HTTP/1.1 200 OK\r\n");
227 hprintf("Content-type: %s; charset=utf-8\r\n",ctype);
228 hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
229 hprintf("Connection: close\r\n");
234 * Generic function to do an HTTP redirect. Easy and fun.
236 void http_redirect(const char *whichpage) {
237 hprintf("HTTP/1.1 302 Moved Temporarily\n");
238 hprintf("Location: %s\r\n", whichpage);
239 hprintf("URI: %s\r\n", whichpage);
240 hprintf("Content-type: text/html; charset=utf-8\r\n");
242 wc_printf("<html><body>");
243 wc_printf("Go <a href=\"%s\">here</A>.", whichpage);
244 wc_printf("</body></html>\n");
251 * Output a piece of content to the web browser using conformant HTTP and MIME semantics
253 void http_transmit_thing(const char *content_type, int is_static)
256 lprintf(9, "http_transmit_thing(%s)%s\n", content_type, ((is_static > 0) ? " (static)" : ""));
257 output_headers(0, 0, 0, 0, 0, is_static);
259 hprintf("Content-type: %s\r\n"
261 "Connection: close\r\n",
270 * Convenience functions to display a page containing only a string
272 * titlebarcolor color of the titlebar of the frame
273 * titlebarmsg text to display in the title bar
274 * messagetext body of the box
276 void convenience_page(const char *titlebarcolor, const char *titlebarmsg, const char *messagetext)
278 hprintf("HTTP/1.1 200 OK\n");
279 output_headers(1, 1, 2, 0, 0, 0);
280 wc_printf("<div id=\"banner\">\n");
281 wc_printf("<table width=100%% border=0 bgcolor=\"#%s\"><tr><td>", titlebarcolor);
282 wc_printf("<span class=\"titlebar\">%s</span>\n", titlebarmsg);
283 wc_printf("</td></tr></table>\n");
284 wc_printf("</div>\n<div id=\"content\">\n");
285 escputs(messagetext);
287 wc_printf("<hr />\n");
293 * Display a blank page.
295 void blank_page(void) {
296 output_headers(1, 1, 0, 0, 0, 0);
302 * A template has been requested
304 void url_do_template(void) {
305 const StrBuf *MimeType;
306 const StrBuf *Tmpl = sbstr("template");
308 MimeType = DoTemplate(SKEY(Tmpl), NULL, &NoCtx);
309 http_transmit_thing(ChrPtr(MimeType), 0);
315 * convenience function to indicate success
317 void display_success(char *successmessage)
319 convenience_page("007700", "OK", successmessage);
324 * Authorization required page (sends a 401, causing the browser to request login credentials)
326 void authorization_required(void)
329 const char *message = "";
331 hprintf("HTTP/1.1 401 Authorization Required\r\n");
333 "Server: %s / %s\r\n"
334 "Connection: close\r\n",
335 PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
337 hprintf("WWW-Authenticate: Basic realm=\"%s\"\r\n", ChrPtr(WC->serv_info->serv_humannode));
338 hprintf("Content-Type: text/html\r\n");
341 wc_printf(_("Authorization Required"));
342 wc_printf("</h1>\r\n");
345 if (WCC->ImportantMsg != NULL)
346 message = ChrPtr(WCC->ImportantMsg);
347 else if (WCC->ImportantMessage != NULL)
348 message = WCC->ImportantMessage;
350 wc_printf(_("The resource you requested requires a valid username and password. "
351 "You could not be logged in: %s\n"), message);
353 end_webcit_session();
357 * Convenience functions to wrap around asynchronous ajax responses
359 void begin_ajax_response(void) {
362 FlushStrBuf(WCC->HBuf);
363 output_headers(0, 0, 0, 0, 0, 0);
365 hprintf("Content-type: text/html; charset=UTF-8\r\n"
367 "Connection: close\r\n"
374 * print ajax response footer
376 void end_ajax_response(void) {
383 * Wraps a Citadel server command in an AJAX transaction.
385 void ajax_servcmd(void)
393 begin_ajax_response();
395 serv_puts(bstr("g_cmd"));
396 StrBuf_ServGetln(Buf);
397 StrBufAppendBuf(WCC->WBuf, Buf, 0);
398 StrBufAppendBufPlain(WCC->WBuf, HKEY("\n"), 0);
400 switch (GetServerStatus(Buf, NULL)) {
402 serv_puts("\n\n000");
403 if ( (StrLength(Buf)==3) &&
404 !strcmp(ChrPtr(Buf), "000")) {
405 StrBufAppendBufPlain(WCC->WBuf, HKEY("\000"), 0);
410 StrBuf_ServGetln(Buf);
411 if ( (StrLength(Buf)==3) &&
412 !strcmp(ChrPtr(Buf), "000")) {
415 StrBufAppendBuf(WCC->WBuf, Buf, 0);
416 StrBufAppendBufPlain(WCC->WBuf, HKEY("\n"), 0);
420 text_to_server(bstr("g_input"));
424 len = atol(&ChrPtr(Buf)[4]);
425 StrBuf_ServGetBLOBBuffered(Buf, len);
428 len = atol(&ChrPtr(Buf)[4]);
430 memset(junk, 0, len);
431 serv_write(junk, len);
438 * This is kind of an ugly hack, but this is the only place it can go.
439 * If the command was GEXP, then the instant messenger window must be
440 * running, so reset the "last_pager_check" watchdog timer so
441 * that page_popup() doesn't try to open it a second time.
443 if (!strncasecmp(bstr("g_cmd"), "GEXP", 4)) {
444 WCC->last_pager_check = time(NULL);
451 * Helper function for the asynchronous check to see if we need
452 * to open the instant messenger window.
454 void seconds_since_last_gexp(void)
458 if ( (time(NULL) - WC->last_pager_check) < 30) {
464 serv_getln(buf, sizeof buf);
476 int ReadPostData(void)
479 int urlencoded_post = 0;
481 StrBuf *content = NULL;
483 urlencoded_post = (strncasecmp(ChrPtr(WCC->Hdr->HR.ContentType), "application/x-www-form-urlencoded", 33) == 0) ;
485 content = NewStrBufPlain(NULL, WCC->Hdr->HR.ContentLength + 256);
487 if (!urlencoded_post)
489 StrBufPrintf(content,
491 "Content-length: %ld\n\n",
492 ChrPtr(WCC->Hdr->HR.ContentType),
493 WCC->Hdr->HR.ContentLength);
496 /** Read the entire input data at once. */
497 rc = client_read_to(WCC->Hdr, content,
498 WCC->Hdr->HR.ContentLength,
504 if (urlencoded_post) {
505 ParseURLParams(content);
506 } else if (!strncasecmp(ChrPtr(WCC->Hdr->HR.ContentType), "multipart", 9)) {
511 len = StrLength(content);
512 Buf = SmashStrBuf(&content);
514 mime_parser(Buf, BufEnd, *upload_handler, NULL, NULL, NULL, 0);
516 } else if (WCC->Hdr->HR.ContentLength > 0) {
517 WCC->upload = content;
518 WCC->upload_length = StrLength(WCC->upload);
521 FreeStrBuf(&content);
526 void ParseREST_URL(void)
529 StrBuf *pFloor = NULL;
532 const char *pCh = NULL;
536 lprintf(1, "parsing rest URL: %s\n", ChrPtr(WCC->Hdr->HR.ReqLine));
538 WCC->Directory = NewHash(1, Flathash);
539 WCC->CurrentFloor = NULL;
542 while (StrBufExtract_NextToken(Buf, WCC->Hdr->HR.ReqLine, &pCh, '/') >= 0)
544 if (StrLength(Buf) != 0) {
545 /* ignore empty path segments */
546 StrBufUnescape(Buf, 1);
547 Put(WCC->Directory, IKEY(i), Buf, HFreeStrBuf);
558 Floors = GetFloorListHash(NULL, NULL);
562 if (GetHash(WCC->FloorsByName, SKEY(pFloor), &vFloor))
563 WCC->CurrentFloor = (Floor*) vFloor;
568 int Conditional_REST_DEPTH(StrBuf *Target, WCTemplputParams *TP)
574 if (WCC->Hdr->HR.Handler != NULL)
576 Depth = GetTemplateTokenNumber(Target, TP, 2, 0);
577 IsDepth = GetCount(WCC->Directory) + offset;
579 // LogTemplateError(Target, "bla", 1, TP, "REST_DEPTH: %ld : %ld\n", Depth, IsDepth);
582 return IsDepth > Depth;
585 return Depth == IsDepth;
591 * Entry point for WebCit transaction
593 void session_loop(void)
600 * We stuff these with the values coming from the client cookies,
601 * so we can use them to reconnect a timed out session if we have to.
606 WCC->upload_length = 0;
609 WCC->Hdr->nWildfireHeaders = 0;
610 if (WCC->Hdr->HR.Handler != NULL)
611 Flags = WCC->Hdr->HR.Handler->Flags; /* so we can temporarily add our own... */
613 if (WCC->Hdr->HR.ContentLength > 0) {
614 if (ReadPostData() < 0) {
620 WCC->trailing_javascript = NewStrBuf();
622 /* Convert base64-encoded URL's back to plain text */
623 if (!strncmp(ChrPtr(WCC->Hdr->this_page), "/B64", 4)) {
624 StrBufCutLeft(WCC->Hdr->this_page, 4);
625 StrBufDecodeBase64(WCC->Hdr->this_page);
626 http_redirect(ChrPtr(WCC->Hdr->this_page));
627 goto SKIP_ALL_THIS_CRAP;
630 /* If there are variables in the URL, we must grab them now */
631 if (WCC->Hdr->PlainArgs != NULL)
632 ParseURLParams(WCC->Hdr->PlainArgs);
634 /* If the client sent a nonce that is incorrect, kill the request. */
635 if (havebstr("nonce")) {
636 lprintf(9, "Comparing supplied nonce %s to session nonce %ld\n",
637 bstr("nonce"), WCC->nonce);
638 if (ibstr("nonce") != WCC->nonce) {
639 lprintf(9, "Ignoring request with mismatched nonce.\n");
640 hprintf("HTTP/1.1 404 Security check failed\r\n");
641 hprintf("Content-Type: text/plain\r\n");
643 wc_printf("Security check failed.\r\n");
645 goto SKIP_ALL_THIS_CRAP;
650 * If we're not connected to a Citadel server, try to hook up the connection now.
652 if (!WCC->connected) {
653 if (GetConnected()) {
654 hprintf("HTTP/1.1 503 Service Unavailable\r\n");
655 hprintf("Content-Type: text/html\r\n");
657 wc_printf("<html><head><title>503 Service Unavailable</title></head><body>\n");
658 wc_printf(_("This program was unable to connect or stay "
659 "connected to the Citadel server. Please report "
660 "this problem to your system administrator.")
662 wc_printf("</body></html>\n");
664 goto SKIP_ALL_THIS_CRAP;
669 * If we're not logged in, but we have authentication data (either from
670 * a cookie or from http-auth), try logging in to Citadel using that.
672 if ((!WCC->logged_in)
673 && (StrLength(WCC->Hdr->c_username) > 0)
674 && (StrLength(WCC->Hdr->c_password) > 0))
679 serv_printf("USER %s", ChrPtr(WCC->Hdr->c_username));
680 StrBuf_ServGetln(Buf);
681 if (GetServerStatus(Buf, &Status) == 3) {
682 serv_printf("PASS %s", ChrPtr(WCC->Hdr->c_password));
683 StrBuf_ServGetln(Buf);
684 if (GetServerStatus(Buf, NULL) == 2) {
685 become_logged_in(WCC->Hdr->c_username,
686 WCC->Hdr->c_password, Buf);
688 /* Should only display when password is wrong */
689 WCC->ImportantMsg = NewStrBufPlain(ChrPtr(Buf) + 4, StrLength(Buf) - 4);
690 authorization_required();
692 goto SKIP_ALL_THIS_CRAP;
695 else if (Status == 541) {
700 xhttp = (WCC->Hdr->HR.eReqType != eGET) &&
701 (WCC->Hdr->HR.eReqType != ePOST) &&
702 (WCC->Hdr->HR.eReqType != eHEAD);
705 * If a 'gotofirst' parameter has been specified, attempt to goto that room
706 * prior to doing anything else.
708 if (havebstr("gotofirst")) {
710 ret = gotoroom(sbstr("gotofirst")); /* do quietly to avoid session output! */
711 if ((ret/100) != 2) {
712 lprintf(1, "GOTOFIRST: Unable to change to [%s]; Reason: %d\n",
713 bstr("gotofirst"), ret);
718 * If we aren't in any room yet, but we have cookie data telling us where we're
719 * supposed to be, and 'gotofirst' was not specified, then go there.
721 else if ( (StrLength(WCC->CurRoom.name) == 0) && ( (StrLength(WCC->Hdr->c_roomname) > 0) )) {
724 lprintf(9, "We are in '%s' but cookie indicates '%s', going there...\n",
725 ChrPtr(WCC->CurRoom.name),
726 ChrPtr(WCC->Hdr->c_roomname)
728 ret = gotoroom(WCC->Hdr->c_roomname); /* do quietly to avoid session output! */
729 if ((ret/100) != 2) {
730 lprintf(1, "COOKIEGOTO: Unable to change to [%s]; Reason: %d\n",
731 ChrPtr(WCC->Hdr->c_roomname), ret);
735 if (WCC->Hdr->HR.Handler != NULL) {
736 if ( (!WCC->logged_in)
737 && ((WCC->Hdr->HR.Handler->Flags & ANONYMOUS) == 0)
738 && (WCC->serv_info->serv_supports_guest == 0)
744 if ((WCC->Hdr->HR.Handler->Flags & PARSE_REST_URL) != 0)
747 if ((WCC->Hdr->HR.Handler->Flags & AJAX) != 0)
748 begin_ajax_response();
749 WCC->Hdr->HR.Handler->F();
750 if ((WCC->Hdr->HR.Handler->Flags & AJAX) != 0)
754 /* When all else fails, display the default landing page or a main menu. */
757 * ordinary browser users get a nice login screen, DAV etc. requsets
758 * are given a 401 so they can handle it appropriate.
760 if (!WCC->logged_in) {
762 authorization_required();
765 display_default_landing_page();
769 * Toplevel dav requests? or just a flat browser request?
787 * Display the appropriate landing page for this site.
789 void display_default_landing_page(void) {
790 if (WC->serv_info->serv_supports_guest) {
791 /* default action. probably revisit this. */
792 StrBuf *teh_lobby = NewStrBufPlain(HKEY("_BASEROOM_"));
793 smart_goto(teh_lobby);
794 FreeStrBuf(&teh_lobby);
803 * Replacement for sleep() that uses select() in order to avoid SIGALRM
805 void sleeeeeeeeeep(int seconds)
811 select(0, NULL, NULL, NULL, &tv);
814 int Conditional_IS_HTTPS(StrBuf *Target, WCTemplputParams *TP)
816 return is_https != 0;
819 void AppendImportantMessage(const char *pch, long len)
823 if (StrLength(WCC->ImportantMsg) > 0) {
824 StrBufAppendBufPlain(WCC->ImportantMsg, HKEY("\n"), 0);
827 StrBufAppendBufPlain(WCC->ImportantMsg, pch, len, 0);
830 int ConditionalImportantMesage(StrBuf *Target, WCTemplputParams *TP)
834 return ((!IsEmptyStr(WCC->ImportantMessage)) ||
835 (StrLength(WCC->ImportantMsg) > 0));
840 void tmplput_importantmessage(StrBuf *Target, WCTemplputParams *TP)
845 if (!IsEmptyStr(WCC->ImportantMessage)) {
846 StrEscAppend(Target, NULL, WCC->ImportantMessage, 0, 0);
847 WCC->ImportantMessage[0] = '\0';
849 else if (StrLength(WCC->ImportantMsg) > 0) {
850 StrEscAppend(Target, WCC->ImportantMsg, NULL, 0, 0);
851 FlushStrBuf(WCC->ImportantMsg);
856 void tmplput_trailing_javascript(StrBuf *Target, WCTemplputParams *TP)
861 StrBufAppendTemplate(Target, TP, WCC->trailing_javascript, 0);
864 void tmplput_csslocal(StrBuf *Target, WCTemplputParams *TP)
866 StrBufAppendBuf(Target,
870 extern char static_local_dir[PATH_MAX];
878 WebcitAddUrlHandler(HKEY("blank"), "", 0, blank_page, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC);
879 WebcitAddUrlHandler(HKEY("do_template"), "", 0, url_do_template, ANONYMOUS);
880 WebcitAddUrlHandler(HKEY("sslg"), "", 0, seconds_since_last_gexp, AJAX|LOGCHATTY);
881 WebcitAddUrlHandler(HKEY("ajax_servcmd"), "", 0, ajax_servcmd, 0);
882 WebcitAddUrlHandler(HKEY("webcit"), "", 0, blank_page, URLNAMESPACE);
884 WebcitAddUrlHandler(HKEY("401"), "", 0, authorization_required, ANONYMOUS|COOKIEUNNEEDED);
885 RegisterConditional(HKEY("COND:IMPMSG"), 0, ConditionalImportantMesage, CTX_NONE);
886 RegisterConditional(HKEY("COND:REST:DEPTH"), 0, Conditional_REST_DEPTH, CTX_NONE);
887 RegisterConditional(HKEY("COND:IS_HTTPS"), 0, Conditional_IS_HTTPS, CTX_NONE);
889 RegisterNamespace("CSSLOCAL", 0, 0, tmplput_csslocal, NULL, CTX_NONE);
890 RegisterNamespace("IMPORTANTMESSAGE", 0, 0, tmplput_importantmessage, NULL, CTX_NONE);
891 RegisterNamespace("TRAILING_JAVASCRIPT", 0, 0, tmplput_trailing_javascript, NULL, CTX_NONE);
892 RegisterNamespace("URL:DISPLAYNAME", 0, 1, tmplput_HANDLER_DISPLAYNAME, NULL, CTX_NONE);
895 snprintf(dir, SIZ, "%s/webcit.css", static_local_dir);
896 if (!access(dir, R_OK)) {
897 lprintf(9, "Using local Stylesheet [%s]\n", dir);
898 csslocal = NewStrBufPlain(HKEY("<link href=\"static.local/webcit.css\" rel=\"stylesheet\" type=\"text/css\" />"));
901 lprintf(9, "No Site-local Stylesheet [%s] installed. \n", dir);
906 ServerStartModule_WEBCIT
909 HandlerHash = NewHash(1, NULL);
914 ServerShutdownModule_WEBCIT
917 FreeStrBuf(&csslocal);
918 DeleteHash(&HandlerHash);
924 SessionNewModule_WEBCIT
927 sess->ImportantMsg = NewStrBuf();
928 sess->WBuf = NewStrBufPlain(NULL, SIZ * 4);
929 sess->HBuf = NewStrBufPlain(NULL, SIZ / 4);
933 SessionDetachModule_WEBCIT
936 DeleteHash(&sess->Directory);
938 FreeStrBuf(&sess->upload);
939 sess->upload_length = 0;
941 FreeStrBuf(&sess->trailing_javascript);
943 if (StrLength(sess->WBuf) > SIZ * 30) /* Bigger than 120K? release. */
945 FreeStrBuf(&sess->WBuf);
946 sess->WBuf = NewStrBuf();
949 FlushStrBuf(sess->WBuf);
950 FlushStrBuf(sess->HBuf);
954 SessionDestroyModule_WEBCIT
957 FreeStrBuf(&sess->WBuf);
958 FreeStrBuf(&sess->HBuf);
959 FreeStrBuf(&sess->ImportantMsg);