4 * This is the main transaction loop of the web service. It maintains a
5 * persistent session to the Citadel server, handling HTTP WebCit requests as
6 * they arrive and presenting a user interface.
8 #define SHOW_ME_VAPPEND_PRINTF
13 #include "webserver.h"
17 * String to unset the cookie.
18 * Any date "in the past" will work, so I chose my birthday, right down to
19 * the exact minute. :)
21 static char *unset = "; expires=28-May-1971 18:10:00 GMT";
22 StrBuf *csslocal = NULL;
23 HashList *HandlerHash = NULL;
25 void WebcitAddUrlHandler(const char * UrlString,
30 WebcitHandler *NewHandler;
31 NewHandler = (WebcitHandler*) malloc(sizeof(WebcitHandler));
33 NewHandler->Flags = Flags;
34 Put(HandlerHash, UrlString, UrlSLen, NewHandler, NULL);
39 * web-printing funcion. uses our vsnprintf wrapper
41 void wprintf(const char *format,...)
46 if (WCC->WBuf == NULL)
47 WCC->WBuf = NewStrBuf();
49 va_start(arg_ptr, format);
50 StrBufVAppendPrintf(WCC->WBuf, format, arg_ptr);
55 * http-header-printing funcion. uses our vsnprintf wrapper
57 void hprintf(const char *format,...)
62 va_start(arg_ptr, format);
63 StrBufVAppendPrintf(WCC->HBuf, format, arg_ptr);
70 * wrap up an HTTP session, closes tags, etc.
72 * print_standard_html_footer should be set to:
73 * 0 - to transmit only,
74 * nonzero - to append the closing tags
76 void wDumpContent(int print_standard_html_footer)
78 if (print_standard_html_footer) {
79 wprintf("</div> <!-- end of 'content' div -->\n");
80 do_template("trailing", NULL);
83 /* If we've been saving it all up for one big output burst,
84 * go ahead and do that now.
93 * Output HTTP headers and leading HTML for a page
95 void output_headers( int do_httpheaders, /* 1 = output HTTP headers */
96 int do_htmlhead, /* 1 = output HTML <head> section and <body> opener */
98 int do_room_banner, /* 0=no, 1=yes,
99 * 2 = I'm going to embed my own, so don't open the
100 * <div id="content"> either.
103 int unset_cookies, /* 1 = session is terminating, so unset the cookies */
104 int suppress_check, /* 1 = suppress check for instant messages */
105 int cache /* 1 = allow browser to cache this page */
111 hprintf("HTTP/1.1 200 OK\n");
112 http_datestring(httpnow, sizeof httpnow, time(NULL));
114 if (do_httpheaders) {
115 if (WCC->serv_info != NULL)
116 hprintf("Content-type: text/html; charset=utf-8\r\n"
118 "Connection: close\r\n",
120 ChrPtr(WCC->serv_info->serv_software));
122 hprintf("Content-type: text/html; charset=utf-8\r\n"
123 "Server: %s / [n/a]\n"
124 "Connection: close\r\n",
129 char httpTomorow[128];
131 http_datestring(httpTomorow, sizeof httpTomorow,
132 time(NULL) + 60 * 60 * 24 * 2);
134 hprintf("Pragma: public\r\n"
135 "Cache-Control: max-age=3600, must-revalidate\r\n"
136 "Last-modified: %s\r\n"
143 hprintf("Pragma: no-cache\r\n"
144 "Cache-Control: no-store\r\n"
149 stuff_to_cookie(cookie, 1024,
150 WCC->wc_session, WCC->wc_username,
151 WCC->wc_password, WCC->wc_roomname);
154 hprintf("Set-cookie: webcit=%s; path=/\r\n", unset);
156 hprintf("Set-cookie: webcit=%s; path=/\r\n", cookie);
157 if (server_cookie != NULL) {
158 hprintf("%s\n", server_cookie);
164 do_template("head", NULL);
166 /* check for ImportantMessages (these display in a div overlaying the main screen) */
167 if (!IsEmptyStr(WCC->ImportantMessage)) {
168 wprintf("<div id=\"important_message\">\n"
169 "<span class=\"imsg\">");
170 StrEscAppend(WCC->WBuf, NULL, WCC->ImportantMessage, 0, 0);
171 wprintf("</span><br />\n"
174 StrBufAppendBufPlain(WCC->trailing_javascript,
175 HKEY("setTimeout('hide_imsg_popup()', 5000); \n"),
178 WCC->ImportantMessage[0] = 0;
180 else if (StrLength(WCC->ImportantMsg) > 0) {
181 wprintf("<div id=\"important_message\">\n"
182 "<span class=\"imsg\">");
183 StrEscAppend(WCC->WBuf, WCC->ImportantMsg, NULL, 0, 0);
184 wprintf("</span><br />\n"
187 StrBufAppendBufPlain(WCC->trailing_javascript,
188 HKEY("setTimeout('hide_imsg_popup()', 5000); \n"),
191 FlushStrBuf(WCC->ImportantMsg);
193 if ( (WCC->logged_in) && (!unset_cookies) ) {
194 /*DoTemplate(HKEY("iconbar"), NULL, &NoCtx);*/
198 if (do_room_banner == 1) {
199 wprintf("<div id=\"banner\">\n");
200 embed_room_banner(NULL, navbar_default);
205 if (do_room_banner == 1) {
206 wprintf("<div id=\"content\">\n");
210 void output_custom_content_header(const char *ctype) {
211 hprintf("HTTP/1.1 200 OK\r\n");
212 hprintf("Content-type: %s; charset=utf-8\r\n",ctype);
213 hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
214 hprintf("Connection: close\r\n");
219 * Generic function to do an HTTP redirect. Easy and fun.
221 void http_redirect(const char *whichpage) {
222 hprintf("HTTP/1.1 302 Moved Temporarily\n");
223 hprintf("Location: %s\r\n", whichpage);
224 hprintf("URI: %s\r\n", whichpage);
225 hprintf("Content-type: text/html; charset=utf-8\r\n");
226 wprintf("<html><body>");
227 wprintf("Go <a href=\"%s\">here</A>.", whichpage);
228 wprintf("</body></html>\n");
235 * Output a piece of content to the web browser using conformant HTTP and MIME semantics
237 void http_transmit_thing(const char *content_type,
241 lprintf(9, "http_transmit_thing(%s)%s\n",
243 (is_static ? " (static)" : "")
246 output_headers(0, 0, 0, 0, 0, is_static);
248 hprintf("Content-type: %s\r\n"
250 "Connection: close\r\n",
258 * print menu box like used in the floor view or admin interface.
259 * This function takes pair of strings as va_args,
260 * Title Title string of the box
261 * Class CSS Class for the box
262 * nLines How many string pairs should we print? (URL, UrlText)
263 * ... Pairs of URL Strings and their Names
265 void print_menu_box(char* Title, char *Class, int nLines, ...)
270 svput("BOXTITLE", WCS_STRING, Title);
271 do_template("beginboxx", NULL);
273 wprintf("<ul class=\"%s\">", Class);
275 va_start(arg_list, nLines);
276 for (i = 0; i < nLines; ++i)
278 wprintf("<li><a href=\"%s\">", va_arg(arg_list, char *));
279 wprintf((char *) va_arg(arg_list, char *));
280 wprintf("</a></li>\n");
284 wprintf("</a></li>\n");
288 do_template("endbox", NULL);
293 * dump out static pages from disk
295 void output_static(void)
301 const char *content_type;
304 char what[] = "TODO";
305 fd = open(what, O_RDONLY);
307 lprintf(9, "output_static('%s') -- NOT FOUND --\n", what);
308 hprintf("HTTP/1.1 404 %s\r\n", strerror(errno));
309 hprintf("Content-Type: text/plain\r\n");
310 wprintf("Cannot open %s: %s\r\n", what, strerror(errno));
314 content_type = GuessMimeByFilename(what, len);
316 if (fstat(fd, &statbuf) == -1) {
317 lprintf(9, "output_static('%s') -- FSTAT FAILED --\n", what);
318 hprintf("HTTP/1.1 404 %s\r\n", strerror(errno));
319 hprintf("Content-Type: text/plain\r\n");
320 wprintf("Cannot fstat %s: %s\n", what, strerror(errno));
326 bytes = statbuf.st_size;
328 if (StrBufReadBLOB(WC->WBuf, &fd, 1, bytes, &Err) < 0)
330 if (fd > 0) close(fd);
331 lprintf(9, "output_static('%s') -- FREAD FAILED (%s) --\n", what, strerror(errno));
332 hprintf("HTTP/1.1 500 internal server error \r\n");
333 hprintf("Content-Type: text/plain\r\n");
341 lprintf(9, "output_static('%s') %s\n", what, content_type);
343 http_transmit_thing(content_type, 1);
345 if (yesbstr("force_close_session")) {
346 end_webcit_session();
352 * Convenience functions to display a page containing only a string
354 * titlebarcolor color of the titlebar of the frame
355 * titlebarmsg text to display in the title bar
356 * messagetext body of the box
358 void convenience_page(const char *titlebarcolor, const char *titlebarmsg, const char *messagetext)
360 hprintf("HTTP/1.1 200 OK\n");
361 output_headers(1, 1, 2, 0, 0, 0);
362 wprintf("<div id=\"banner\">\n");
363 wprintf("<table width=100%% border=0 bgcolor=\"#%s\"><tr><td>", titlebarcolor);
364 wprintf("<span class=\"titlebar\">%s</span>\n", titlebarmsg);
365 wprintf("</td></tr></table>\n");
366 wprintf("</div>\n<div id=\"content\">\n");
367 escputs(messagetext);
375 * Display a blank page.
377 void blank_page(void) {
378 output_headers(1, 1, 0, 0, 0, 0);
384 * A template has been requested
386 void url_do_template(void) {
387 const StrBuf *MimeType;
388 const StrBuf *Tmpl = sbstr("template");
390 MimeType = DoTemplate(SKEY(Tmpl), NULL, &NoCtx);
391 http_transmit_thing(ChrPtr(MimeType), 0);
397 * convenience function to indicate success
399 void display_success(char *successmessage)
401 convenience_page("007700", "OK", successmessage);
406 * Authorization required page
407 * This is probably temporary and should be revisited
409 void authorization_required(const char *message)
411 hprintf("HTTP/1.1 401 Authorization Required\r\n");
412 hprintf("WWW-Authenticate: Basic realm=\"%s\"\r\n", ChrPtr(WC->serv_info->serv_humannode));
413 hprintf("Content-Type: text/html\r\n");
415 wprintf(_("Authorization Required"));
416 wprintf("</h1>\r\n");
417 wprintf(_("The resource you requested requires a valid username and password. "
418 "You could not be logged in: %s\n"), message);
424 * Convenience functions to wrap around asynchronous ajax responses
426 void begin_ajax_response(void) {
429 FlushStrBuf(WCC->HBuf);
430 output_headers(0, 0, 0, 0, 0, 0);
432 hprintf("Content-type: text/html; charset=UTF-8\r\n"
434 "Connection: close\r\n"
441 * print ajax response footer
443 void end_ajax_response(void) {
447 /* If it's a "force 404" situation then display the error and bail. */
450 hprintf("HTTP/1.1 404 Not found\r\n");
451 hprintf("Content-Type: text/plain\r\n");
452 wprintf("Not found\r\n");
457 /* Static content can be sent without connecting to Citadel. * /
459 for (a=0; a<ndirs && ! is_static; ++a) {
460 if (!strcasecmp(action, (char*)static_content_dirs[a])) { /* map web to disk location * /
468 snprintf(buf, sizeof buf, "%s/%s/%s/%s/%s/%s/%s/%s",
469 static_dirs[n_static],
470 index[1], index[2], index[3], index[4], index[5], index[6], index[7]);
471 for (a=0; a<8; ++a) {
472 if (buf[strlen(buf)-1] == '/') {
473 buf[strlen(buf)-1] = 0;
476 for (a = 0; a < strlen(buf); ++a) {
477 if (isspace(buf[a])) {
485 lprintf(9, "Suspicious request. Ignoring.");
486 hprintf("HTTP/1.1 404 Security check failed\r\n");
487 hprintf("Content-Type: text/plain\r\n\r\n");
488 wprintf("You have sent a malformed or invalid request.\r\n");
491 goto SKIP_ALL_THIS_CRAP; /* Don't try to connect * /
497 * Wraps a Citadel server command in an AJAX transaction.
499 void ajax_servcmd(void)
507 begin_ajax_response();
509 serv_puts(bstr("g_cmd"));
510 StrBuf_ServGetln(Buf);
511 StrBufAppendBuf(WCC->WBuf, Buf, 0);
512 StrBufAppendBufPlain(WCC->WBuf, HKEY("\n"), 0);
514 switch (GetServerStatus(Buf, NULL)) {
516 serv_puts("\n\n000");
517 if ( (StrLength(Buf)==3) &&
518 !strcmp(ChrPtr(Buf), "000")) {
519 StrBufAppendBufPlain(WCC->WBuf, HKEY("\000"), 0);
524 StrBuf_ServGetln(Buf);
525 if ( (StrLength(Buf)==3) &&
526 !strcmp(ChrPtr(Buf), "000")) {
529 StrBufAppendBuf(WCC->WBuf, Buf, 0);
530 StrBufAppendBufPlain(WCC->WBuf, HKEY("\n"), 0);
534 text_to_server(bstr("g_input"));
538 len = atol(&ChrPtr(Buf)[4]);
539 StrBuf_ServGetBLOBBuffered(Buf, len);
542 len = atol(&ChrPtr(Buf)[4]);
544 memset(junk, 0, len);
545 serv_write(junk, len);
552 * This is kind of an ugly hack, but this is the only place it can go.
553 * If the command was GEXP, then the instant messenger window must be
554 * running, so reset the "last_pager_check" watchdog timer so
555 * that page_popup() doesn't try to open it a second time.
557 if (!strncasecmp(bstr("g_cmd"), "GEXP", 4)) {
558 WCC->last_pager_check = time(NULL);
565 * Helper function for the asynchronous check to see if we need
566 * to open the instant messenger window.
568 void seconds_since_last_gexp(void)
572 if ( (time(NULL) - WC->last_pager_check) < 30) {
578 serv_getln(buf, sizeof buf);
590 void ReadPostData(void)
592 const char *content_end = NULL;
595 StrBuf *content = NULL;
597 content = NewStrBuf();
599 StrBufPrintf(content,
601 "Content-length: %ld\n\n",
602 ChrPtr(WCC->Hdr->ContentType),
603 WCC->Hdr->ContentLength);
605 hprintf("Content-type: %s\n"
606 "Content-length: %d\n\n",
607 ContentType, ContentLength);
609 body_start = StrLength(content);
611 /** Read the entire input data at once. */
612 client_read_to(&WCC->Hdr->http_sock,
614 WCC->Hdr->ReadBuf, &WCC->Hdr->Pos,
615 WCC->Hdr->ContentLength,
618 if (!strncasecmp(ChrPtr(WCC->Hdr->ContentType), "application/x-www-form-urlencoded", 33)) {
619 StrBufCutLeft(content, body_start);
620 ParseURLParams(content);
621 } else if (!strncasecmp(ChrPtr(WCC->Hdr->ContentType), "multipart", 9)) {
622 content_end = ChrPtr(content) +
623 WCC->Hdr->ContentLength +
625 mime_parser(ChrPtr(content), content_end, *upload_handler, NULL, NULL, NULL, 0);
627 FreeStrBuf(&content);
632 * Entry point for WebCit transaction
634 void session_loop(void)
643 * We stuff these with the values coming from the client cookies,
644 * so we can use them to reconnect a timed out session if we have to.
653 WCC->upload_length = 0;
656 WCC->trailing_javascript = NewStrBuf();
657 WCC->Hdr->nWildfireHeaders = 0;
658 if (WCC->Hdr->Handler != NULL)
659 Flags = WCC->Hdr->Handler->Flags; /* so we can temporarily add our own... */
660 /** Figure out the action * /
662 sizes[0] = sizeof action;
666 sizes[a] = sizeof arg[a-1];
671 for ( a = 0; a < 9; ++a)
673 extract_token(index[a], ChrPtr(ReqLine), a + 1, '/', sizes[a]);
674 if (strstr(index[a], "?")) *strstr(index[a], "?") = 0;
675 if (strstr(index[a], "&")) *strstr(index[a], "&") = 0;
676 if (strstr(index[a], " ")) *strstr(index[a], " ") = 0;
677 if ((index[a][0] == '.') && (index[a][1] == '.'))
679 if (index[a][0] == '\0')
683 if (WCC->Hdr->ContentLength > 0) {
687 /* If there are variables in the URL, we must grab them now */
688 if (WCC->Hdr->PlainArgs != NULL)
689 ParseURLParams(WCC->Hdr->PlainArgs);
691 /* If the client sent a nonce that is incorrect, kill the request. */
692 if (havebstr("nonce")) {
693 lprintf(9, "Comparing supplied nonce %s to session nonce %ld\n",
694 bstr("nonce"), WCC->nonce);
695 if (ibstr("nonce") != WCC->nonce) {
696 lprintf(9, "Ignoring request with mismatched nonce.\n");
697 hprintf("HTTP/1.1 404 Security check failed\r\n");
698 hprintf("Content-Type: text/plain\r\n\r\n");
699 wprintf("Security check failed.\r\n");
701 goto SKIP_ALL_THIS_CRAP;
706 * If we're not connected to a Citadel server, try to hook up the
709 if (!WCC->connected) {
711 goto SKIP_ALL_THIS_CRAP;
716 * If we're not logged in, but we have HTTP Authentication data,
717 * try logging in to Citadel using that.
719 if ((!WCC->logged_in)
720 && (StrLength(WCC->Hdr->c_username) > 0)
721 && (StrLength(WCC->Hdr->c_password) > 0))
724 serv_printf("USER %s", ChrPtr(WCC->Hdr->c_username));
725 StrBuf_ServGetln(Buf);
726 if (GetServerStatus(Buf, NULL) == 3) {
727 serv_printf("PASS %s", ChrPtr(WCC->Hdr->c_password));
728 StrBuf_ServGetln(Buf);
729 if (GetServerStatus(Buf, NULL) == 2) {
730 become_logged_in(WCC->Hdr->c_username,
731 WCC->Hdr->c_password, Buf);
733 /* Should only display when password is wrong */
734 authorization_required(&buf[4]);
736 goto SKIP_ALL_THIS_CRAP;
741 xhttp = (WCC->Hdr->eReqType != eGET) &&
742 (WCC->Hdr->eReqType != ePOST) &&
743 (WCC->Hdr->eReqType != eHEAD);
746 * If we're not logged in, but we have username and password cookies
747 * supplied by the browser, try using them to log in.
749 if ((!WCC->logged_in)
750 && (StrLength(WCC->Hdr->c_username)>0)
751 && (StrLength(WCC->Hdr->c_password)>0)) {
752 ReEstablish_Session();
756 * If a 'gotofirst' parameter has been specified, attempt to goto that room
757 * prior to doing anything else.
759 if (havebstr("gotofirst")) {
761 ret = gotoroom(sbstr("gotofirst")); /* do this quietly to avoid session output! */
763 lprintf(1, "GOTOFIRST: Unable to change to [%s]; Reason: %d\n", bstr("gotofirst"), ret);
766 if (WCC->Hdr->Handler != NULL) {
767 if (!WCC->logged_in && ((WCC->Hdr->Handler->Flags & ANONYMOUS) == 0)) {
772 if((WCC->Hdr->Handler->Flags & NEED_URL)) {
773 if (WCC->UrlFragment1 == NULL)
774 WCC->UrlFragment1 = NewStrBuf();
775 if (WCC->UrlFragment2 == NULL)
776 WCC->UrlFragment2 = NewStrBuf();
777 if (WCC->UrlFragment3 == NULL)
778 WCC->UrlFragment3 = NewStrBuf();
779 if (WCC->UrlFragment4 == NULL)
780 WCC->UrlFragment4 = NewStrBuf();
781 StrBufPlain(WCC->UrlFragment1, index[0], -1);
782 StrBufPlain(WCC->UrlFragment2, index[1], -1);
783 StrBufPlain(WCC->UrlFragment3, index[2], -1);
784 StrBufPlain(WCC->UrlFragment4, index[3], -1);
787 if ((WCC->Hdr->Handler->Flags & AJAX) != 0)
788 begin_ajax_response();
789 WCC->Hdr->Handler->F();
790 if ((WCC->Hdr->Handler->Flags & AJAX) != 0)
794 /* When all else fais, display the main menu. */
803 if (WCC->SavePrefsToServer) {
805 WCC->SavePrefsToServer = 0;
809 WCC->Hdr->http_host = NULL;
814 * Replacement for sleep() that uses select() in order to avoid SIGALRM
816 void sleeeeeeeeeep(int seconds)
822 select(0, NULL, NULL, NULL, &tv);
826 int ConditionalImportantMesage(StrBuf *Target, WCTemplputParams *TP)
830 return ((!IsEmptyStr(WCC->ImportantMessage)) ||
831 (StrLength(WCC->ImportantMsg) > 0));
836 void tmplput_importantmessage(StrBuf *Target, WCTemplputParams *TP)
841 if (!IsEmptyStr(WCC->ImportantMessage)) {
842 StrEscAppend(Target, NULL, WCC->ImportantMessage, 0, 0);
843 WCC->ImportantMessage[0] = '\0';
845 else if (StrLength(WCC->ImportantMsg) > 0) {
846 StrEscAppend(Target, WCC->ImportantMsg, NULL, 0, 0);
847 FlushStrBuf(WCC->ImportantMsg);
852 void tmplput_trailing_javascript(StrBuf *Target, WCTemplputParams *TP)
857 StrBufAppendTemplate(Target, TP, WCC->trailing_javascript, 0);
860 void tmplput_csslocal(StrBuf *Target, WCTemplputParams *TP)
862 StrBufAppendBuf(Target,
866 extern char static_local_dir[PATH_MAX];
869 /* TODO: integrate this into the static startup logic
871 * While we're at it, gracefully handle requests for the
872 * robots.txt and favicon.ico files.
874 if ((StrLength(ReqLine) >= 11) &&
875 !strncasecmp(ChrPtr(ReqLine), "/robots.txt", 11)) {
877 HKEY("/static/robots.txt"
878 "?force_close_session=yes HTTP/1.1"));
881 else if ((StrLength(ReqLine) >= 11) &&
882 !strncasecmp(ChrPtr(ReqLine), "/favicon.ico", 12)) {
883 StrBufPlain(ReqLine, HKEY("/static/favicon.ico"));
893 WebcitAddUrlHandler(HKEY("404"), do_404, ANONYMOUS|COOKIEUNNEEDED);
894 WebcitAddUrlHandler(HKEY("blank"), blank_page, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC);
896 WebcitAddUrlHandler(HKEY("robots.txt"), output_static, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC);
897 WebcitAddUrlHandler(HKEY("favicon.ico"), output_static, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC);
898 WebcitAddUrlHandler(HKEY("static"), output_static, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC);
899 WebcitAddUrlHandler(HKEY("static.local"), output_static, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC);
900 WebcitAddUrlHandler(HKEY("tinymce"), output_static, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC);
902 WebcitAddUrlHandler(HKEY("blank"), blank_page, ANONYMOUS);
903 WebcitAddUrlHandler(HKEY("do_template"), url_do_template, ANONYMOUS);
904 WebcitAddUrlHandler(HKEY("sslg"), seconds_since_last_gexp, AJAX|LOGCHATTY);
905 WebcitAddUrlHandler(HKEY("ajax_servcmd"), ajax_servcmd, 0);
907 RegisterConditional(HKEY("COND:IMPMSG"), 0, ConditionalImportantMesage, CTX_NONE);
908 RegisterNamespace("CSSLOCAL", 0, 0, tmplput_csslocal, CTX_NONE);
909 RegisterNamespace("IMPORTANTMESSAGE", 0, 0, tmplput_importantmessage, CTX_NONE);
910 RegisterNamespace("TRAILING_JAVASCRIPT", 0, 0, tmplput_trailing_javascript, CTX_NONE);
912 snprintf(dir, SIZ, "%s/static.local/webcit.css", static_local_dir);
913 if (!access(dir, R_OK)) {
914 lprintf(9, "Using local Stylesheet [%s]\n", dir);
915 csslocal = NewStrBufPlain(HKEY("<link href=\"static.local/webcit.css\" rel=\"stylesheet\" type=\"text/css\">"));
918 lprintf(9, "Didn't find site local Stylesheet [%s]\n", dir);
923 ServerStartModule_WEBCIT
926 HandlerHash = NewHash(1, NULL);
931 ServerShutdownModule_WEBCIT
934 FreeStrBuf(&csslocal);
935 DeleteHash(&HandlerHash);
941 SessionNewModule_WEBCIT
944 sess->ImportantMsg = NewStrBuf();
945 sess->WBuf = NewStrBuf();
946 sess->HBuf = NewStrBuf();
950 SessionDetachModule_WEBCIT
953 DeleteHash(&sess->Hdr->urlstrings);// TODO?
954 if (sess->upload_length > 0) {
956 sess->upload_length = 0;
958 FreeStrBuf(&sess->trailing_javascript);
960 if (StrLength(sess->WBuf) > SIZ * 30) /* Bigger than 120K? release. */
962 FreeStrBuf(&sess->WBuf);
963 sess->WBuf = NewStrBuf();
966 FlushStrBuf(sess->WBuf);
967 FlushStrBuf(sess->HBuf);
971 SessionDestroyModule_WEBCIT
974 FreeStrBuf(&sess->WBuf);
975 FreeStrBuf(&sess->HBuf);
977 FreeStrBuf(&sess->UrlFragment1);
978 FreeStrBuf(&sess->UrlFragment2);
979 FreeStrBuf(&sess->UrlFragment3);
980 FreeStrBuf(&sess->UrlFragment4);
982 FreeStrBuf(&sess->ImportantMsg);