indent -kr -i8 -brf -bbb -fnc -l132 -nce on all of webcit-classic
authorArt Cancro <ajc@citadel.org>
Thu, 8 Sep 2022 21:57:24 +0000 (17:57 -0400)
committerArt Cancro <ajc@citadel.org>
Thu, 8 Sep 2022 21:57:24 +0000 (17:57 -0400)
83 files changed:
webcit/addressbook_popup.c
webcit/auth.c
webcit/autocompletion.c
webcit/availability.c
webcit/bbsview_renderer.c
webcit/blogview_renderer.c
webcit/calendar.c
webcit/calendar.h
webcit/calendar_tools.c
webcit/calendar_view.c
webcit/context_loop.c
webcit/cookie_conversion.c
webcit/crypto.c
webcit/dav.h
webcit/dav_delete.c
webcit/dav_get.c
webcit/dav_main.c
webcit/dav_options.c
webcit/dav_propfind.c
webcit/dav_put.c
webcit/dav_report.c
webcit/downloads.c
webcit/event.c
webcit/feed_generator.c
webcit/fmt_date.c
webcit/gettext.c
webcit/graphics.c
webcit/html2html.c
webcit/http_datestring.c
webcit/ical_dezonify.c
webcit/ical_subst.c
webcit/iconbar.c
webcit/icontheme.c
webcit/inetconf.c
webcit/jsonview_renderer.c
webcit/listsub.c
webcit/locate_host.c
webcit/mailview_renderer.c
webcit/mainmenu.c
webcit/marchlist.c
webcit/messages.c
webcit/messages.h
webcit/msg_renderers.c
webcit/netconf.c
webcit/notes.c
webcit/openid.c
webcit/paging.c
webcit/paramhandling.c
webcit/paramhandling.h
webcit/preferences.c
webcit/preferences.h
webcit/pushemail.c
webcit/roomchat.c
webcit/roomlist.c
webcit/roomops.c
webcit/roomops.h
webcit/roomtokens.c
webcit/roomviews.c
webcit/serv_func.c
webcit/sieve.c
webcit/siteconfig.c
webcit/sitemap.c
webcit/smtpqueue.c
webcit/sockets.c
webcit/sockets.h
webcit/static.c
webcit/subst.c
webcit/subst.h
webcit/summary.c
webcit/sysdep.c
webcit/sysmsgs.c
webcit/tabs.c
webcit/tasks.c
webcit/useredit.c
webcit/utils.c
webcit/utils.h
webcit/vcard_edit.c
webcit/webcit.c
webcit/webcit.h
webcit/webserver.c
webcit/webserver.h
webcit/who.c
webcit/wiki.c

index afbf3a0c78d11aeec3e88628b38116ab017ead57..097d13a55454eace8ebdc9299a0bfe204af36cc6 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Dynamic HTML (formerly known as "AJAX") powered auto-completion
  *
@@ -18,8 +19,7 @@
 /*
  * Address book popup results
  */
-HashList* GetAddressbookList()
-{
+HashList *GetAddressbookList() {
        HashList *List = NULL;
        const StrBuf *WhichAddrBook;
        StrBuf *saved_roomname;
@@ -41,19 +41,13 @@ HashList* GetAddressbookList()
                gotoroom(WhichAddrBook);
                serv_puts("DVCA");
        }
-       
+
        Line = NewStrBuf();
        StrBuf_ServGetln(Line);
-       if (GetServerStatus(Line, NULL)  == 1) {
+       if (GetServerStatus(Line, NULL) == 1) {
                List = NewHash(1, NULL);
-               while (BufLen = StrBuf_ServGetln(Line), 
-                      ((BufLen >= 0) && 
-                       ((BufLen != 3) || strcmp(ChrPtr(Line), "000"))))
-               {
-                       if (IsLocalAddrBook &&
-                           (BufLen > 5) &&
-                           (strncmp(ChrPtr(Line), "SYS_", 4) == 0))
-                       {
+               while (BufLen = StrBuf_ServGetln(Line), ((BufLen >= 0) && ((BufLen != 3) || strcmp(ChrPtr(Line), "000")))) {
+                       if (IsLocalAddrBook && (BufLen > 5) && (strncmp(ChrPtr(Line), "SYS_", 4) == 0)) {
                                continue;
                        }
                        Name = NewStrBufPlain(NULL, StrLength(Line));
@@ -75,10 +69,7 @@ HashList* GetAddressbookList()
 
 
 
-void 
-InitModule_ADDRBOOK_POPUP
-(void)
-{
+void InitModule_ADDRBOOK_POPUP(void) {
 
        RegisterIterator("ITERATE:ABNAMES", 0, NULL, GetAddressbookList, NULL, NULL, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
 }
index 74d9237e94d9d47358ca47e3dcf582ddf01c4fb9..790d5429bc3700081cb7dec604bfffab4107f964 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * These functions handle authentication of users to a Citadel server.
  *
 #include "webserver.h"
 #include <ctype.h>
 
-extern uint32_t hashlittle( const void *key, size_t length, uint32_t initval);
+extern uint32_t hashlittle(const void *key, size_t length, uint32_t initval);
 
 /*
  * Access level definitions.  This is initialized from a function rather than a
  * static array so that the strings may be localized.
  */
-char *axdefs[7]; 
+char *axdefs[7];
 
 void initialize_axdefs(void) {
 
        /* an erased user */
-       axdefs[0] = _("Deleted");       
+       axdefs[0] = _("Deleted");
 
        /* a new user */
-       axdefs[1] = _("New User");      
+       axdefs[1] = _("New User");
 
        /* a trouble maker */
-       axdefs[2] = _("Problem User");  
+       axdefs[2] = _("Problem User");
 
        /* user with normal privileges */
-       axdefs[3] = _("Local User");    
+       axdefs[3] = _("Local User");
 
        /* a user that may access network resources */
-       axdefs[4] = _("Network User");  
+       axdefs[4] = _("Network User");
 
        /* a moderator */
        axdefs[5] = _("Preferred User");
 
        /* chief */
-       axdefs[6] = _("Admin");          
+       axdefs[6] = _("Admin");
 }
 
 
@@ -54,8 +55,7 @@ void initialize_axdefs(void) {
  * Display the login screen
  * mesg = the error message if last attempt failed.
  */
-void display_login(void)
-{
+void display_login(void) {
        begin_burst();
        output_headers(1, 0, 0, 0, 1, 0);
        do_template("login");
@@ -78,8 +78,7 @@ void display_login(void)
  * pass                        his password
  * serv_response       The parameters returned from a Citadel USER or NEWU command
  */
-void become_logged_in(const StrBuf *user, const StrBuf *pass, StrBuf *serv_response)
-{
+void become_logged_in(const StrBuf * user, const StrBuf * pass, StrBuf * serv_response) {
        wcsession *WCC = WC;
        StrBuf *Buf;
        StrBuf *FloorDiv;
@@ -89,8 +88,8 @@ void become_logged_in(const StrBuf *user, const StrBuf *pass, StrBuf *serv_respo
        if (WCC->wc_fullname == NULL)
                WCC->wc_fullname = NewStrBufPlain(NULL, StrLength(serv_response));
        StrBufExtract_token(WCC->wc_fullname, serv_response, 0, '|');
-       StrBufCutLeft(WCC->wc_fullname, 4 );
-       
+       StrBufCutLeft(WCC->wc_fullname, 4);
+
        if (WCC->wc_username == NULL)
                WCC->wc_username = NewStrBufDup(user);
        else {
@@ -119,11 +118,11 @@ void become_logged_in(const StrBuf *user, const StrBuf *pass, StrBuf *serv_respo
                const char *pch;
 
                pch = ChrPtr(Buf) + 4;
-               /*WCC->new_mail  =*/ StrBufExtractNext_long(Buf, &pch, '|');
+               /*WCC->new_mail  = */ StrBufExtractNext_long(Buf, &pch, '|');
                WCC->need_regi = StrBufExtractNext_long(Buf, &pch, '|');
                WCC->need_vali = StrBufExtractNext_long(Buf, &pch, '|');
                if (WCC->cs_inet_email == NULL)
-                       WCC->cs_inet_email  = NewStrBuf();
+                       WCC->cs_inet_email = NewStrBuf();
                StrBufExtract_NextToken(WCC->cs_inet_email, Buf, &pch, '|');
        }
        get_preference("floordiv_expanded", &FloorDiv);
@@ -182,8 +181,7 @@ void ajax_login_newuser(void) {
 /* 
  * Try to create an account manually after an OpenID was verified
  */
-void openid_manual_create(void)
-{
+void openid_manual_create(void) {
        StrBuf *Buf;
 
        /* Did the user change his mind?  Pack up and go home. */
@@ -221,7 +219,8 @@ void openid_manual_create(void)
                        do_template("authpopup_finished");
                        end_burst();
                }
-       } else {
+       }
+       else {
                /* Still no good!  Go back to teh dialog to select a username */
                const StrBuf *Buf;
                putbstr("__claimed_id", NewStrBufDup(sbstr("openid_url")));
@@ -243,16 +242,12 @@ void openid_manual_create(void)
  * Perform authentication using OpenID
  * assemble the checkid_setup request and then redirect to the user's identity provider
  */
-void do_openid_login(void)
-{
+void do_openid_login(void) {
        char buf[4096];
 
        snprintf(buf, sizeof buf,
-               "OIDS %s|%s/finalize_openid_login|%s",
-               bstr("openid_url"),
-               ChrPtr(site_prefix),
-               ChrPtr(site_prefix)
-       );
+                "OIDS %s|%s/finalize_openid_login|%s", bstr("openid_url"), ChrPtr(site_prefix), ChrPtr(site_prefix)
+           );
 
        serv_puts(buf);
        serv_getln(buf, sizeof buf);
@@ -275,8 +270,7 @@ void do_openid_login(void)
  * Complete the authentication using OpenID
  * This function handles the positive or negative assertion from the user's Identity Provider
  */
-void finalize_openid_login(void)
-{
+void finalize_openid_login(void) {
        StrBuf *Buf;
        wcsession *WCC = WC;
        int linecount = 0;
@@ -298,10 +292,10 @@ void finalize_openid_login(void)
                                const char *HKey;
                                HashPos *Cursor;
                                int len;
-                               
-                               Cursor = GetNewHashPos (WCC->Hdr->urlstrings, 0);
+
+                               Cursor = GetNewHashPos(WCC->Hdr->urlstrings, 0);
                                while (GetNextHashPos(WCC->Hdr->urlstrings, Cursor, &HKLen, &HKey, &U)) {
-                                       u = (urlcontent*) U;
+                                       u = (urlcontent *) U;
                                        if (!strncasecmp(u->url_key, "openid.", 7)) {
                                                serv_printf("%s|%s", &u->url_key[7], ChrPtr(u->url_data));
                                        }
@@ -310,11 +304,9 @@ void finalize_openid_login(void)
                                serv_puts("000");
 
                                linecount = 0;
-                               while (len = StrBuf_ServGetln(Buf), 
-                                      ((len >= 0) &&
-                                       ((len != 3) || strcmp(ChrPtr(Buf), "000") )))
-                               {
-                                       if (linecount == 0) result = NewStrBufDup(Buf);
+                               while (len = StrBuf_ServGetln(Buf), ((len >= 0) && ((len != 3) || strcmp(ChrPtr(Buf), "000")))) {
+                                       if (linecount == 0)
+                                               result = NewStrBufDup(Buf);
                                        if (!strcasecmp(ChrPtr(result), "authenticate")) {
                                                if (linecount == 1) {
                                                        username = NewStrBufDup(Buf);
@@ -344,7 +336,7 @@ void finalize_openid_login(void)
        /*
         * Is this an attempt to associate a new OpenID with an account that is already logged in?
         */
-       if ( (WCC->logged_in) && (havebstr("attach_existing")) ) {
+       if ((WCC->logged_in) && (havebstr("attach_existing"))) {
                display_openids();
        }
 
@@ -360,7 +352,8 @@ void finalize_openid_login(void)
                        output_headers(1, 0, 0, 0, 1, 0);
                        do_template("authpopup_finished");
                        end_burst();
-               } else {
+               }
+               else {
                        begin_burst();
                        output_headers(1, 0, 0, 0, 1, 0);
                        wc_printf("<html><body>");
@@ -416,7 +409,7 @@ void do_welcome(void) {
         * Go to the user's preferred start page
         */
        if (!get_preference("startpage", &Buf)) {
-               Buf = NewStrBuf ();
+               Buf = NewStrBuf();
                StrBufPrintf(Buf, "dotskip?room=_BASEROOM_");
                set_preference("startpage", Buf, 1);
        }
@@ -444,8 +437,7 @@ void end_webcit_session(void) {
 /* 
  * Log out the session with the Citadel server
  */
-void do_logout(void)
-{
+void do_logout(void) {
        wcsession *WCC = WC;
        char buf[SIZ];
 
@@ -476,19 +468,14 @@ void do_logout(void)
 /* 
  * Special page for monitoring scripts etc
  */
-void monitor(void)
-{
+void monitor(void) {
        output_headers(0, 0, 0, 0, 0, 0);
 
-       hprintf("Content-type: text/plain\r\n"
-               "Server: " PACKAGE_STRING "\r\n"
-               "Connection: close\r\n"
-       );
+       hprintf("Content-type: text/plain\r\n" "Server: " PACKAGE_STRING "\r\n" "Connection: close\r\n");
        begin_burst();
 
-       wc_printf("Connection to Citadel server in %s : %s\r\n", ctdl_dir,
-               (WC->connected ? "SUCCESS" : "FAIL")
-       );
+       wc_printf("Connection to Citadel server in %s : %s\r\n", ctdl_dir, (WC->connected ? "SUCCESS" : "FAIL")
+           );
 
        wDumpContent(0);
 }
@@ -497,8 +484,7 @@ void monitor(void)
 /*
  * validate new users
  */
-void validate(void)
-{
+void validate(void) {
        char cmd[SIZ];
        char user[SIZ];
        char buf[SIZ];
@@ -506,9 +492,9 @@ void validate(void)
 
        output_headers(1, 1, 1, 0, 0, 0);
 
-        do_template("box_begin_1");
-        StrBufAppendBufPlain(WC->WBuf, _("Validate new users"), -1, 0);
-        do_template("box_begin_2");
+       do_template("box_begin_1");
+       StrBufAppendBufPlain(WC->WBuf, _("Validate new users"), -1, 0);
+       do_template("box_begin_2");
 
        /* If the user just submitted a validation, process it... */
        safestrncpy(buf, bstr("user"), sizeof buf);
@@ -550,8 +536,7 @@ void validate(void)
                        serv_getln(buf, sizeof buf);
                        ++a;
                        if (a == 1)
-                               wc_printf("#%s<br><H1>%s</H1>",
-                                       buf, &cmd[4]);
+                               wc_printf("#%s<br><H1>%s</H1>", buf, &cmd[4]);
                        if (a == 2) {
                                char *pch;
                                int haveChar = 0;
@@ -559,23 +544,18 @@ void validate(void)
                                int haveOther = 0;
                                int haveLong = 0;
                                pch = buf;
-                               while (!IsEmptyStr(pch))
-                               {
+                               while (!IsEmptyStr(pch)) {
                                        if (isdigit(*pch))
                                                haveNum = 1;
                                        else if (isalpha(*pch))
                                                haveChar = 1;
                                        else
                                                haveOther = 1;
-                                       pch ++;
+                                       pch++;
                                }
                                if (pch - buf > 7)
                                        haveLong = 1;
-                               switch (haveLong + 
-                                       haveChar + 
-                                       haveNum + 
-                                       haveOther)
-                               {
+                               switch (haveLong + haveChar + haveNum + haveOther) {
                                case 0:
                                        pch = _("very weak");
                                        break;
@@ -605,10 +585,10 @@ void validate(void)
                        if (a == 8)
                                wc_printf("%s<br>\n", buf);
                        if (a == 9)
-                               wc_printf(_("Current access level: %d (%s)\n"),
-                                       atoi(buf), axdefs[atoi(buf)]);
+                               wc_printf(_("Current access level: %d (%s)\n"), atoi(buf), axdefs[atoi(buf)]);
                } while (strcmp(buf, "000"));
-       } else {
+       }
+       else {
                wc_printf("<H1>%s</H1>%s<br>\n", user, &cmd[4]);
        }
 
@@ -618,8 +598,7 @@ void validate(void)
        for (a = 0; a <= 6; ++a) {
                wc_printf("<a href=\"validate?nonce=%d?user=", WC->nonce);
                urlescputs(user);
-               wc_printf("&axlevel=%d\">%s</A>&nbsp;&nbsp;&nbsp;\n",
-                       a, axdefs[a]);
+               wc_printf("&axlevel=%d\">%s</A>&nbsp;&nbsp;&nbsp;\n", a, axdefs[a]);
        }
        wc_printf("<br>\n");
 
@@ -636,8 +615,7 @@ void validate(void)
  * (Set during_login to 1 if this registration is being performed during
  * new user login and will require chaining to the proper screen.)
  */
-void display_reg(int during_login)
-{
+void display_reg(int during_login) {
        folder Room;
        StrBuf *Buf;
        message_summary *VCMsg = NULL;
@@ -655,7 +633,7 @@ void display_reg(int during_login)
                        display_main_menu();
                }
                FreeStrBuf(&Buf);
-               FlushFolder(&Room);             
+               FlushFolder(&Room);
                return;
        }
        FlushFolder(&Room);
@@ -690,8 +668,7 @@ void display_reg(int during_login)
  * change password
  * if passwords match, propagate it to citserver.
  */
-void changepw(void)
-{
+void changepw(void) {
        StrBuf *Line;
        char newpass1[32], newpass2[32];
 
@@ -721,14 +698,10 @@ void changepw(void)
        StrBuf_ServGetln(Line);
        if (GetServerStatusMsg(Line, NULL, 1, 0) == 2) {
                if (WC->wc_password == NULL)
-                       WC->wc_password = NewStrBufPlain(
-                               ChrPtr(Line) + 4, 
-                               StrLength(Line) - 4);
+                       WC->wc_password = NewStrBufPlain(ChrPtr(Line) + 4, StrLength(Line) - 4);
                else {
                        FlushStrBuf(WC->wc_password);
-                       StrBufAppendBufPlain(WC->wc_password,  
-                                            ChrPtr(Line) + 4, 
-                                            StrLength(Line) - 4, 0);
+                       StrBufAppendBufPlain(WC->wc_password, ChrPtr(Line) + 4, StrLength(Line) - 4, 0);
                }
                display_main_menu();
        }
@@ -739,9 +712,8 @@ void changepw(void)
 }
 
 
-int ConditionalHaveAccessCreateRoom(StrBuf *Target, WCTemplputParams *TP)
-{
-       StrBuf *Buf;    
+int ConditionalHaveAccessCreateRoom(StrBuf * Target, WCTemplputParams * TP) {
+       StrBuf *Buf;
 
        Buf = NewStrBuf();
        serv_puts("CRE8 0");
@@ -758,15 +730,13 @@ int ConditionalHaveAccessCreateRoom(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-int ConditionalAide(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalAide(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
-       return (WCC != NULL) ? ((WCC->logged_in == 0)||(WC->is_aide == 0)) : 0;
+       return (WCC != NULL) ? ((WCC->logged_in == 0) || (WC->is_aide == 0)) : 0;
 }
 
 
-int ConditionalIsLoggedIn(StrBuf *Target, WCTemplputParams *TP) 
-{
+int ConditionalIsLoggedIn(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
        return (WCC != NULL) ? (WCC->logged_in == 0) : 0;
 
@@ -787,24 +757,22 @@ void _display_reg(void) {
 }
 
 
-void Header_HandleAuth(StrBuf *Line, ParsedHttpHdrs *hdr)
-{
-       if (hdr->HR.got_auth == NO_AUTH) /* don't override cookie auth... */
-       {
+void Header_HandleAuth(StrBuf * Line, ParsedHttpHdrs * hdr) {
+       if (hdr->HR.got_auth == NO_AUTH) {      /* don't override cookie auth... */
                if (strncasecmp(ChrPtr(Line), "Basic", 5) == 0) {
                        StrBufCutLeft(Line, 6);
                        StrBufDecodeBase64(Line);
                        hdr->HR.plainauth = Line;
                        hdr->HR.got_auth = AUTH_BASIC;
                }
-               else 
+               else
                        syslog(LOG_WARNING, "Authentication scheme not supported! [%s]\n", ChrPtr(Line));
        }
 }
 
 
-void CheckAuthBasic(ParsedHttpHdrs *hdr)
-{
+void CheckAuthBasic(ParsedHttpHdrs * hdr) {
+
 /*
   todo: enable this if we can have other sessions than authenticated ones.
        if (hdr->DontNeedAuth)
@@ -815,8 +783,7 @@ void CheckAuthBasic(ParsedHttpHdrs *hdr)
 }
 
 
-void GetAuthBasic(ParsedHttpHdrs *hdr)
-{
+void GetAuthBasic(ParsedHttpHdrs * hdr) {
        const char *Pos = NULL;
        if (hdr->c_username == NULL)
                hdr->c_username = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_USER));
@@ -827,9 +794,9 @@ void GetAuthBasic(ParsedHttpHdrs *hdr)
 }
 
 
-void Header_HandleCookie(StrBuf *Line, ParsedHttpHdrs *hdr)
-{
+void Header_HandleCookie(StrBuf * Line, ParsedHttpHdrs * hdr) {
        const char *pch;
+
 /*
   todo: enable this if we can have other sessions than authenticated ones.
        if (hdr->DontNeedAuth)
@@ -844,20 +811,12 @@ void Header_HandleCookie(StrBuf *Line, ParsedHttpHdrs *hdr)
        StrBufCutLeft(hdr->HR.RawCookie, (pch - ChrPtr(hdr->HR.RawCookie)) + 7);
        StrBufDecodeHex(hdr->HR.RawCookie);
 
-       cookie_to_stuff(Line, &hdr->HR.desired_session,
-                       hdr->c_username,
-                       hdr->c_password,
-                       hdr->c_roomname,
-                       hdr->c_language
-       );
+       cookie_to_stuff(Line, &hdr->HR.desired_session, hdr->c_username, hdr->c_password, hdr->c_roomname, hdr->c_language);
        hdr->HR.got_auth = AUTH_COOKIE;
 }
 
 
-void 
-HttpNewModule_AUTH
-(ParsedHttpHdrs *httpreq)
-{
+void HttpNewModule_AUTH(ParsedHttpHdrs * httpreq) {
        httpreq->c_username = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_USER));
        httpreq->c_password = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_PASS));
        httpreq->c_roomname = NewStrBuf();
@@ -865,10 +824,7 @@ HttpNewModule_AUTH
 }
 
 
-void 
-HttpDetachModule_AUTH
-(ParsedHttpHdrs *httpreq)
-{
+void HttpDetachModule_AUTH(ParsedHttpHdrs * httpreq) {
        FLUSHStrBuf(httpreq->c_username);
        FLUSHStrBuf(httpreq->c_password);
        FLUSHStrBuf(httpreq->c_roomname);
@@ -876,10 +832,7 @@ HttpDetachModule_AUTH
 }
 
 
-void 
-HttpDestroyModule_AUTH
-(ParsedHttpHdrs *httpreq)
-{
+void HttpDestroyModule_AUTH(ParsedHttpHdrs * httpreq) {
        FreeStrBuf(&httpreq->c_username);
        FreeStrBuf(&httpreq->c_password);
        FreeStrBuf(&httpreq->c_roomname);
@@ -887,18 +840,15 @@ HttpDestroyModule_AUTH
 }
 
 
-void 
-InitModule_AUTH
-(void)
-{
+void InitModule_AUTH(void) {
        initialize_axdefs();
        RegisterHeaderHandler(HKEY("COOKIE"), Header_HandleCookie);
        RegisterHeaderHandler(HKEY("AUTHORIZATION"), Header_HandleAuth);
 
        /* no url pattern at all? Show login. */
-       WebcitAddUrlHandler(HKEY(""), "", 0, do_welcome, ANONYMOUS|COOKIEUNNEEDED);
+       WebcitAddUrlHandler(HKEY(""), "", 0, do_welcome, ANONYMOUS | COOKIEUNNEEDED);
 
-       WebcitAddUrlHandler(HKEY("do_welcome"), "", 0, do_welcome, ANONYMOUS|COOKIEUNNEEDED);
+       WebcitAddUrlHandler(HKEY("do_welcome"), "", 0, do_welcome, ANONYMOUS | COOKIEUNNEEDED);
        WebcitAddUrlHandler(HKEY("openid_login"), "", 0, do_openid_login, ANONYMOUS);
        WebcitAddUrlHandler(HKEY("finalize_openid_login"), "", 0, finalize_openid_login, ANONYMOUS);
        WebcitAddUrlHandler(HKEY("openid_manual_create"), "", 0, openid_manual_create, ANONYMOUS);
@@ -907,22 +857,19 @@ InitModule_AUTH
        WebcitAddUrlHandler(HKEY("display_reg"), "", 0, _display_reg, 0);
        WebcitAddUrlHandler(HKEY("changepw"), "", 0, changepw, 0);
        WebcitAddUrlHandler(HKEY("termquit"), "", 0, do_logout, 0);
-       WebcitAddUrlHandler(HKEY("do_logout"), "", 0, do_logout, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
-       WebcitAddUrlHandler(HKEY("monitor"), "", 0, monitor, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
-       WebcitAddUrlHandler(HKEY("ajax_login_username_password"), "", 0, ajax_login_username_password, AJAX|ANONYMOUS);
-       WebcitAddUrlHandler(HKEY("ajax_login_newuser"), "", 0, ajax_login_newuser, AJAX|ANONYMOUS);
+       WebcitAddUrlHandler(HKEY("do_logout"), "", 0, do_logout, ANONYMOUS | COOKIEUNNEEDED | FORCE_SESSIONCLOSE);
+       WebcitAddUrlHandler(HKEY("monitor"), "", 0, monitor, ANONYMOUS | COOKIEUNNEEDED | FORCE_SESSIONCLOSE);
+       WebcitAddUrlHandler(HKEY("ajax_login_username_password"), "", 0, ajax_login_username_password, AJAX | ANONYMOUS);
+       WebcitAddUrlHandler(HKEY("ajax_login_newuser"), "", 0, ajax_login_newuser, AJAX | ANONYMOUS);
        WebcitAddUrlHandler(HKEY("switch_language"), "", 0, switch_language, ANONYMOUS);
        RegisterConditional("COND:AIDE", 2, ConditionalAide, CTX_NONE);
        RegisterConditional("COND:LOGGEDIN", 2, ConditionalIsLoggedIn, CTX_NONE);
-       RegisterConditional("COND:MAY_CREATE_ROOM", 2,  ConditionalHaveAccessCreateRoom, CTX_NONE);
+       RegisterConditional("COND:MAY_CREATE_ROOM", 2, ConditionalHaveAccessCreateRoom, CTX_NONE);
        return;
 }
 
 
-void 
-SessionDestroyModule_AUTH
-(wcsession *sess)
-{
+void SessionDestroyModule_AUTH(wcsession * sess) {
        FreeStrBuf(&sess->wc_username);
        FreeStrBuf(&sess->wc_fullname);
        FreeStrBuf(&sess->wc_password);
index e936068fdc1011770111ad96d817a70a5563d64e..95948c60f5a97f1bed8235d4cc4dced7e0c47bbc 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * dynamic html autocompletion
  *
@@ -25,12 +26,7 @@ void recp_autocomplete(char *partial) {
 
        hprintf("Content-type: text/html\r\n"
                "Server: %s\r\n"
-               "Connection: close\r\n"
-               "Pragma: no-cache\r\n"
-               "Cache-Control: no-store\r\n"
-               "Expires: -1\r\n"
-               ,
-               PACKAGE_STRING);
+               "Connection: close\r\n" "Pragma: no-cache\r\n" "Cache-Control: no-store\r\n" "Expires: -1\r\n", PACKAGE_STRING);
        begin_burst();
 
        wc_printf("<ul>");
@@ -38,7 +34,7 @@ void recp_autocomplete(char *partial) {
        serv_printf("AUTO %s", partial);
        serv_getln(buf, sizeof buf);
        if (buf[0] == '1') {
-               while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+               while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
                        extract_token(name, buf, 0, '|', sizeof name);
                        wc_printf("<li>");
                        escputs(name);
@@ -53,16 +49,19 @@ void recp_autocomplete(char *partial) {
 }
 
 
-void _recp_autocomplete(void) {recp_autocomplete(bstr("recp"));}
-void _cc_autocomplete(void)   {recp_autocomplete(bstr("cc"));} 
-void _bcc_autocomplete(void)  {recp_autocomplete(bstr("bcc"));}
+void _recp_autocomplete(void) {
+       recp_autocomplete(bstr("recp"));
+}
+void _cc_autocomplete(void) {
+       recp_autocomplete(bstr("cc"));
+}
+void _bcc_autocomplete(void) {
+       recp_autocomplete(bstr("bcc"));
+}
 
 
-void 
-InitModule_AUTO_COMPLETE
-(void)
-{
+void InitModule_AUTO_COMPLETE(void) {
        WebcitAddUrlHandler(HKEY("recp_autocomplete"), "", 0, _recp_autocomplete, 0);
-       WebcitAddUrlHandler(HKEY("cc_autocomplete"),   "", 0, _cc_autocomplete, 0);
-       WebcitAddUrlHandler(HKEY("bcc_autocomplete"),  "", 0, _bcc_autocomplete, 0);
+       WebcitAddUrlHandler(HKEY("cc_autocomplete"), "", 0, _cc_autocomplete, 0);
+       WebcitAddUrlHandler(HKEY("bcc_autocomplete"), "", 0, _bcc_autocomplete, 0);
 }
index 17edb3393f7068c7420e148224eb1928a1548f04..9a302b1aeceb766506b5f20c013f78a9c947846f 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2012 by the citadel.org team
  *
@@ -33,14 +34,14 @@ icalcomponent *get_freebusy_for_user(char *who) {
        if (serialized_fb == NULL) {
                return NULL;
        }
-       
+
        fb = icalcomponent_new_from_string(ChrPtr(serialized_fb));
        FreeStrBuf(&serialized_fb);
        if (fb == NULL) {
                return NULL;
        }
 
-       return(fb);
+       return (fb);
 }
 
 
@@ -52,30 +53,28 @@ icalcomponent *get_freebusy_for_user(char *who) {
  *
  * Returns nonzero if they do overlap.
  */
-int ical_ctdl_is_overlap(
-                       struct icaltimetype t1start,
-                       struct icaltimetype t1end,
-                       struct icaltimetype t2start,
-                       struct icaltimetype t2end
-) {
+int ical_ctdl_is_overlap(struct icaltimetype t1start,
+                        struct icaltimetype t1end, struct icaltimetype t2start, struct icaltimetype t2end) {
 
-       if (icaltime_is_null_time(t1start)) return(0);
-       if (icaltime_is_null_time(t2start)) return(0);
+       if (icaltime_is_null_time(t1start))
+               return (0);
+       if (icaltime_is_null_time(t2start))
+               return (0);
 
        /* if either event lacks end time, assume end = start */
        if (icaltime_is_null_time(t1end))
                memcpy(&t1end, &t1start, sizeof(struct icaltimetype));
        else {
                if (t1end.is_date && icaltime_compare(t1start, t1end)) {
-                        /*
-                         * the end date is non-inclusive so adjust it by one
-                         * day because our test is inclusive, note that a day is
-                         * not too much because we are talking about all day
-                         * events
+                       /*
+                        * the end date is non-inclusive so adjust it by one
+                        * day because our test is inclusive, note that a day is
+                        * not too much because we are talking about all day
+                        * events
                         * if start = end we assume that nevertheless the whole
                         * day is meant
-                         */
-                       icaltime_adjust(&t1end, -1, 0, 0, 0);   
+                        */
+                       icaltime_adjust(&t1end, -1, 0, 0, 0);
                }
        }
 
@@ -83,38 +82,42 @@ int ical_ctdl_is_overlap(
                memcpy(&t2end, &t2start, sizeof(struct icaltimetype));
        else {
                if (t2end.is_date && icaltime_compare(t2start, t2end)) {
-                       icaltime_adjust(&t2end, -1, 0, 0, 0);   
+                       icaltime_adjust(&t2end, -1, 0, 0, 0);
                }
        }
 
        /* First, check for all-day events */
        if (t1start.is_date || t2start.is_date) {
                /* If event 1 ends before event 2 starts, we're in the clear. */
-               if (icaltime_compare_date_only(t1end, t2start) < 0) return(0);
+               if (icaltime_compare_date_only(t1end, t2start) < 0)
+                       return (0);
 
                /* If event 2 ends before event 1 starts, we're also ok. */
-               if (icaltime_compare_date_only(t2end, t1start) < 0) return(0);
+               if (icaltime_compare_date_only(t2end, t1start) < 0)
+                       return (0);
 
-               return(1);
+               return (1);
        }
 
        /* syslog(LOG_DEBUG, "Comparing t1start %d:%d t1end %d:%d t2start %d:%d t2end %d:%d \n",
-               t1start.hour, t1start.minute, t1end.hour, t1end.minute,
-               t2start.hour, t2start.minute, t2end.hour, t2end.minute);
-       */
+          t1start.hour, t1start.minute, t1end.hour, t1end.minute,
+          t2start.hour, t2start.minute, t2end.hour, t2end.minute);
+        */
 
        /* Now check for overlaps using date *and* time. */
 
        /* If event 1 ends before event 2 starts, we're in the clear. */
-       if (icaltime_compare(t1end, t2start) <= 0) return(0);
+       if (icaltime_compare(t1end, t2start) <= 0)
+               return (0);
        /* syslog(LOG_DEBUG, "first passed\n"); */
 
        /* If event 2 ends before event 1 starts, we're also ok. */
-       if (icaltime_compare(t2end, t1start) <= 0) return(0);
+       if (icaltime_compare(t2end, t1start) <= 0)
+               return (0);
        /* syslog(LOG_DEBUG, "second passed\n"); */
 
        /* Otherwise, they overlap. */
-       return(1);
+       return (1);
 }
 
 
@@ -132,9 +135,7 @@ int ical_ctdl_is_overlap(
  * The result is placed in 'annotation'.
  */
 void check_individual_attendee(char *attendee_string,
-                               struct icaltimetype event_start,
-                               struct icaltimetype event_end,
-                               char *annotation) {
+                              struct icaltimetype event_start, struct icaltimetype event_end, char *annotation) {
 
        icalcomponent *fbc = NULL;
        icalcomponent *fb = NULL;
@@ -169,13 +170,11 @@ void check_individual_attendee(char *attendee_string,
                strcpy(annotation, _("free"));
 
                for (thisfb = icalcomponent_get_first_property(fb, ICAL_FREEBUSY_PROPERTY);
-                   thisfb != NULL;
-                   thisfb = icalcomponent_get_next_property(fb, ICAL_FREEBUSY_PROPERTY) ) {
+                    thisfb != NULL; thisfb = icalcomponent_get_next_property(fb, ICAL_FREEBUSY_PROPERTY)) {
 
                        /** Do the check */
                        period = icalproperty_get_freebusy(thisfb);
-                       if (ical_ctdl_is_overlap(period.start, period.end,
-                          event_start, event_end)) {
+                       if (ical_ctdl_is_overlap(period.start, period.end, event_start, event_end)) {
                                strcpy(annotation, _("BUSY"));
                        }
 
@@ -194,7 +193,7 @@ void check_individual_attendee(char *attendee_string,
  *
  * vevent      the event which should be compared with attendees calendar
  */
-void check_attendee_availability(icalcomponent *vevent) {
+void check_attendee_availability(icalcomponent * vevent) {
        icalproperty *attendee = NULL;
        icalproperty *dtstart_p = NULL;
        icalproperty *dtend_p = NULL;
@@ -218,11 +217,8 @@ void check_attendee_availability(icalcomponent *vevent) {
         * new one.
         */
        if (icalcomponent_isa(vevent) == ICAL_VCALENDAR_COMPONENT) {
-               check_attendee_availability(
-                       icalcomponent_get_first_component(
-                               vevent, ICAL_VEVENT_COMPONENT
-                       )
-               );
+               check_attendee_availability(icalcomponent_get_first_component(vevent, ICAL_VEVENT_COMPONENT)
+                   );
                return;
        }
 
@@ -232,17 +228,18 @@ void check_attendee_availability(icalcomponent *vevent) {
         * Learn the start and end times.
         */
        dtstart_p = icalcomponent_get_first_property(vevent, ICAL_DTSTART_PROPERTY);
-       if (dtstart_p != NULL) dtstart_t = icalproperty_get_dtstart(dtstart_p);
+       if (dtstart_p != NULL)
+               dtstart_t = icalproperty_get_dtstart(dtstart_p);
 
        dtend_p = icalcomponent_get_first_property(vevent, ICAL_DTEND_PROPERTY);
-       if (dtend_p != NULL) dtend_t = icalproperty_get_dtend(dtend_p);
+       if (dtend_p != NULL)
+               dtend_t = icalproperty_get_dtend(dtend_p);
 
        /*
         * Iterate through attendees.
         */
        for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY);
-           attendee != NULL;
-           attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
+            attendee != NULL; attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
                ch = icalproperty_get_attendee(attendee);
                if ((ch != NULL) && !strncasecmp(ch, "MAILTO:", 7)) {
 
@@ -250,17 +247,14 @@ void check_attendee_availability(icalcomponent *vevent) {
                        safestrncpy(attendee_string, ch + 7, sizeof(attendee_string));
                        striplt(attendee_string);
 
-                       check_individual_attendee(attendee_string,
-                                               dtstart_t, dtend_t,
-                                               annotation);
+                       check_individual_attendee(attendee_string, dtstart_t, dtend_t, annotation);
 
                        /** Replace the attendee name with an annotated one. */
                        snprintf(annotated_attendee_string, sizeof annotated_attendee_string,
-                               "MAILTO:%s (%s)", attendee_string, annotation);
+                                "MAILTO:%s (%s)", attendee_string, annotation);
                        icalproperty_set_attendee(attendee, annotated_attendee_string);
 
                }
        }
 
 }
-
index 67f42b12fb025aa4f9d7079bbcefcb2d5247c5bf..005d70364458da22d6bd1e915bf0ad7784b2bfeb 100644 (file)
@@ -1,3 +1,4 @@
+
 /* 
  * BBS View renderer module for WebCit
  *
@@ -42,8 +43,7 @@ struct bbsview {
  * Attempt to determine the closest thing to the "last seen message number" using the
  * results of the GTSN command
  */
-long bbsview_get_last_seen(void)
-{
+long bbsview_get_last_seen(void) {
        char buf[SIZ] = "0";
 
        serv_puts("GTSN");
@@ -63,7 +63,7 @@ long bbsview_get_last_seen(void)
                }
        }
 
-       return(atol(buf));
+       return (atol(buf));
 }
 
 
@@ -71,21 +71,15 @@ long bbsview_get_last_seen(void)
 /*
  * Entry point for message read operations.
  */
-int bbsview_GetParamsGetServerCall(SharedMessageStatus *Stat, 
-                                  void **ViewSpecific, 
-                                  long oper, 
-                                  char *cmd, 
-                                  long len,
-                                  char *filter,
-                                  long flen)
-{
+int bbsview_GetParamsGetServerCall(SharedMessageStatus * Stat,
+                                  void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen) {
        struct bbsview *BBS = malloc(sizeof(struct bbsview));
        memset(BBS, 0, sizeof(struct bbsview));
        *ViewSpecific = BBS;
 
-       Stat->startmsg = (-1);                                  /* not used here */
-       Stat->sortit = 1;                                       /* not used here */
-       Stat->num_displayed = DEFAULT_MAXMSGS;                  /* not used here */
+       Stat->startmsg = (-1);  /* not used here */
+       Stat->sortit = 1;       /* not used here */
+       Stat->num_displayed = DEFAULT_MAXMSGS;  /* not used here */
        BBS->requested_page = 0;
        BBS->lastseen = bbsview_get_last_seen();
        BBS->start_reading_at = 0;
@@ -115,11 +109,12 @@ int bbsview_GetParamsGetServerCall(SharedMessageStatus *Stat,
        if (havebstr("maxmsgs")) {
                Stat->maxmsgs = ibstr("maxmsgs");
        }
-       if (Stat->maxmsgs == 0) Stat->maxmsgs = DEFAULT_MAXMSGS;
-       
+       if (Stat->maxmsgs == 0)
+               Stat->maxmsgs = DEFAULT_MAXMSGS;
+
        /* perform a "read all" call to fetch the message list -- we'll cut it down later */
        rlid[2].cmd(cmd, len);
-       
+
        return 200;
 }
 
@@ -127,25 +122,20 @@ int bbsview_GetParamsGetServerCall(SharedMessageStatus *Stat,
 /*
  * This function is called for every message in the list.
  */
-int bbsview_LoadMsgFromServer(SharedMessageStatus *Stat, 
-                             void **ViewSpecific, 
-                             message_summary* Msg, 
-                             int is_new, 
-                             int i)
-{
+int bbsview_LoadMsgFromServer(SharedMessageStatus * Stat, void **ViewSpecific, message_summary * Msg, int is_new, int i) {
        struct bbsview *BBS = (struct bbsview *) *ViewSpecific;
 
        if (BBS->alloc_msgs == 0) {
                BBS->alloc_msgs = 1000;
                BBS->msgs = malloc(BBS->alloc_msgs * sizeof(long));
-               memset(BBS->msgs, 0, (BBS->alloc_msgs * sizeof(long)) );
+               memset(BBS->msgs, 0, (BBS->alloc_msgs * sizeof(long)));
        }
 
        /* Check our buffer size */
        if (BBS->num_msgs >= BBS->alloc_msgs) {
                BBS->alloc_msgs *= 2;
                BBS->msgs = realloc(BBS->msgs, (BBS->alloc_msgs * sizeof(long)));
-               memset(&BBS->msgs[BBS->num_msgs], 0, ((BBS->alloc_msgs - BBS->num_msgs) * sizeof(long)) );
+               memset(&BBS->msgs[BBS->num_msgs], 0, ((BBS->alloc_msgs - BBS->num_msgs) * sizeof(long)));
        }
 
        BBS->msgs[BBS->num_msgs++] = Msg->msgnum;
@@ -158,19 +148,18 @@ int bbsview_sortfunc(const void *s1, const void *s2) {
        long l1;
        long l2;
 
-       l1 = *(long *)(s1);
-       l2 = *(long *)(s2);
+       l1 = *(long *) (s1);
+       l2 = *(long *) (s2);
 
-       if (l1 > l2) return(+1);
-       if (l1 < l2) return(-1);
-       return(0);
+       if (l1 > l2)
+               return (+1);
+       if (l1 < l2)
+               return (-1);
+       return (0);
 }
 
 
-int bbsview_RenderView_or_Tail(SharedMessageStatus *Stat, 
-                              void **ViewSpecific, 
-                              long oper)
-{
+int bbsview_RenderView_or_Tail(SharedMessageStatus * Stat, void **ViewSpecific, long oper) {
        struct bbsview *BBS = (struct bbsview *) *ViewSpecific;
        int i;
        int seq;
@@ -181,7 +170,7 @@ int bbsview_RenderView_or_Tail(SharedMessageStatus *Stat,
 
        if (Stat->nummsgs > 0) {
                syslog(LOG_DEBUG, "sorting %d messages\n", BBS->num_msgs);
-               qsort(BBS->msgs, (size_t)(BBS->num_msgs), sizeof(long), bbsview_sortfunc);
+               qsort(BBS->msgs, (size_t) (BBS->num_msgs), sizeof(long), bbsview_sortfunc);
        }
 
        if ((BBS->num_msgs % Stat->maxmsgs) == 0) {
@@ -200,12 +189,11 @@ int bbsview_RenderView_or_Tail(SharedMessageStatus *Stat,
                        BBS->requested_page = 0;
                }
                else {
-                       for (i=0; i<BBS->num_msgs; ++i) {
-                               if (
-                                       (BBS->msgs[i] >= BBS->start_reading_at)
-                                       && (BBS->requested_page == (-4))
-                               ) {
-                                       BBS->requested_page = (i / Stat->maxmsgs) ;
+                       for (i = 0; i < BBS->num_msgs; ++i) {
+                               if ((BBS->msgs[i] >= BBS->start_reading_at)
+                                   && (BBS->requested_page == (-4))
+                                   ) {
+                                       BBS->requested_page = (i / Stat->maxmsgs);
                                }
                        }
                }
@@ -222,10 +210,9 @@ int bbsview_RenderView_or_Tail(SharedMessageStatus *Stat,
                         */
                        BBS->requested_page = 0;
                }
-               else if (
-                       (BBS->num_msgs > 0) 
-                       && (BBS->lastseen <= BBS->msgs[0])
-               ) {
+               else if ((BBS->num_msgs > 0)
+                        && (BBS->lastseen <= BBS->msgs[0])
+                   ) {
                        /*
                         * All messages are new; this is probably the user's first visit to the room,
                         * so start at the last page instead of showing ancient history.
@@ -237,12 +224,11 @@ int bbsview_RenderView_or_Tail(SharedMessageStatus *Stat,
                        /*
                         * Some messages are old and some are new.  Go to the start of new messages.
                         */
-                       for (i=0; i<BBS->num_msgs; ++i) {
-                               if (
-                                       (BBS->msgs[i] > BBS->lastseen)
-                                       && ( (i == 0) || (BBS->msgs[i-1] <= BBS->lastseen) )
-                               ) {
-                                       BBS->requested_page = (i / Stat->maxmsgs) ;
+                       for (i = 0; i < BBS->num_msgs; ++i) {
+                               if ((BBS->msgs[i] > BBS->lastseen)
+                                   && ((i == 0) || (BBS->msgs[i - 1] <= BBS->lastseen))
+                                   ) {
+                                       BBS->requested_page = (i / Stat->maxmsgs);
                                }
                        }
                }
@@ -261,23 +247,25 @@ int bbsview_RenderView_or_Tail(SharedMessageStatus *Stat,
        }
 
        /* keep the requested page within bounds */
-       if (BBS->requested_page < 0) BBS->requested_page = 0;
-       if (BBS->requested_page >= BBS->num_pages) BBS->requested_page = BBS->num_pages - 1;
+       if (BBS->requested_page < 0)
+               BBS->requested_page = 0;
+       if (BBS->requested_page >= BBS->num_pages)
+               BBS->requested_page = BBS->num_pages - 1;
 
        start_index = BBS->requested_page * Stat->maxmsgs;
-       if (start_index < 0) start_index = 0;
+       if (start_index < 0)
+               start_index = 0;
        end_index = start_index + Stat->maxmsgs - 1;
 
-       for (seq = 0; seq < 3; ++seq) {         /* cheap & sleazy way of rendering the page numbers twice */
+       for (seq = 0; seq < 3; ++seq) { /* cheap & sleazy way of rendering the page numbers twice */
 
-               if ( (seq == 1) && (Stat->nummsgs > 0)) {
+               if ((seq == 1) && (Stat->nummsgs > 0)) {
                        /* display the selected range of messages */
 
-                       for (i=start_index; (i<=end_index && i<BBS->num_msgs); ++i) {
-                               if (
-                                       (BBS->msgs[i] > BBS->lastseen)
-                                       && ( (i == 0) || (BBS->msgs[i-1] <= BBS->lastseen) )
-                               ) {
+                       for (i = start_index; (i <= end_index && i < BBS->num_msgs); ++i) {
+                               if ((BBS->msgs[i] > BBS->lastseen)
+                                   && ((i == 0) || (BBS->msgs[i - 1] <= BBS->lastseen))
+                                   ) {
                                        /* new messages start here */
                                        do_template("start_of_new_msgs");
                                        if (!go_to_the_very_end) {
@@ -287,10 +275,9 @@ int bbsview_RenderView_or_Tail(SharedMessageStatus *Stat,
                                if (BBS->msgs[i] > 0L) {
                                        read_message(WC->WBuf, HKEY("view_message"), BBS->msgs[i], NULL, &Mime, NULL);
                                }
-                               if (
-                                       (i == (BBS->num_msgs - 1))
-                                       && (BBS->msgs[i] <= BBS->lastseen)
-                               ) {
+                               if ((i == (BBS->num_msgs - 1))
+                                   && (BBS->msgs[i] <= BBS->lastseen)
+                                   ) {
                                        /* no new messages */
                                        do_template("no_new_msgs");
                                        if (!go_to_the_very_end) {
@@ -300,7 +287,7 @@ int bbsview_RenderView_or_Tail(SharedMessageStatus *Stat,
                        }
                }
 
-               else if ( (seq == 0) || (seq == 2) ) {
+               else if ((seq == 0) || (seq == 2)) {
                        int first;
                        int last;
                        /* Display the selecto-bar with the page numbers */
@@ -317,22 +304,19 @@ int bbsview_RenderView_or_Tail(SharedMessageStatus *Stat,
                        first = 0;
                        last = BBS->num_pages - 1;
 
-                       for (i=0; i<=last; ++i) {
-
-                               if (
-                                       (i == first)
-                                       || (i == last)
-                                       || (i == BBS->requested_page)
-                                       || (
-                                               ((BBS->requested_page - i) < RANGE)
-                                               && ((BBS->requested_page - i) > (0 - RANGE))
-                                       )
-                               ) {
-
-                                       if (
-                                               (i == last) 
-                                               && (last - BBS->requested_page > RANGE)
-                                       ) {
+                       for (i = 0; i <= last; ++i) {
+
+                               if ((i == first)
+                                   || (i == last)
+                                   || (i == BBS->requested_page)
+                                   || (((BBS->requested_page - i) < RANGE)
+                                       && ((BBS->requested_page - i) > (0 - RANGE))
+                                   )
+                                   ) {
+
+                                       if ((i == last)
+                                           && (last - BBS->requested_page > RANGE)
+                                           ) {
                                                wc_printf("...&nbsp;");
                                        }
                                        if (i == BBS->requested_page) {
@@ -341,22 +325,19 @@ int bbsview_RenderView_or_Tail(SharedMessageStatus *Stat,
                                        else {
                                                wc_printf("<a href=\"readfwd?go=");
                                                urlescputs(ChrPtr(WC->CurRoom.name));
-                                               wc_printf("?start_reading_at=%ld\">",
-                                                       BBS->msgs[i*Stat->maxmsgs]
-                                               );
+                                               wc_printf("?start_reading_at=%ld\">", BBS->msgs[i * Stat->maxmsgs]
+                                                   );
                                                /* wc_printf("?page=%d\">", i); */
                                                wc_printf("<span class=\"moreprompt_link\">");
                                        }
-                                       if (
-                                               (i == first)
-                                               && (BBS->requested_page > (RANGE + 1))
-                                       ) {
+                                       if ((i == first)
+                                           && (BBS->requested_page > (RANGE + 1))
+                                           ) {
                                                wc_printf(_("First"));
                                        }
-                                       else if (
-                                               (i == last)
-                                               && (last - BBS->requested_page > RANGE)
-                                       ) {
+                                       else if ((i == last)
+                                                && (last - BBS->requested_page > RANGE)
+                                           ) {
                                                wc_printf(_("Last"));
                                        }
                                        else {
@@ -369,10 +350,9 @@ int bbsview_RenderView_or_Tail(SharedMessageStatus *Stat,
                                                wc_printf("</span>");
                                                wc_printf("</a>");
                                        }
-                                       if (
-                                               (i == first)
-                                               && (BBS->requested_page > (RANGE + 1))
-                                       ) {
+                                       if ((i == first)
+                                           && (BBS->requested_page > (RANGE + 1))
+                                           ) {
                                                wc_printf("&nbsp;...");
                                        }
                                        if (i != last) {
@@ -387,12 +367,11 @@ int bbsview_RenderView_or_Tail(SharedMessageStatus *Stat,
        if (go_to_the_very_end) {
                StrBufAppendPrintf(WC->trailing_javascript, "location.href=\"#end_of_msgs\";\n");
        }
-       return(0);
+       return (0);
 }
 
 
-int bbsview_Cleanup(void **ViewSpecific)
-{
+int bbsview_Cleanup(void **ViewSpecific) {
        struct bbsview *BBS = (struct bbsview *) *ViewSpecific;
 
        if (BBS->alloc_msgs != 0) {
@@ -405,19 +384,8 @@ int bbsview_Cleanup(void **ViewSpecific)
 }
 
 
-void 
-InitModule_BBSVIEWRENDERERS
-(void)
-{
-       RegisterReadLoopHandlerset(
-               VIEW_BBS,
-               bbsview_GetParamsGetServerCall,
-               NULL,
-               NULL,
-               NULL, 
-               bbsview_LoadMsgFromServer,
-               bbsview_RenderView_or_Tail,
-               bbsview_Cleanup,
-               NULL
-       );
+void InitModule_BBSVIEWRENDERERS(void) {
+       RegisterReadLoopHandlerset(VIEW_BBS,
+                                  bbsview_GetParamsGetServerCall,
+                                  NULL, NULL, NULL, bbsview_LoadMsgFromServer, bbsview_RenderView_or_Tail, bbsview_Cleanup, NULL);
 }
index 5cec69676e69439aa4428ab1b35ee50b30e9cfc4..d49788e57b5fc306d2816c9131edde813ca94f0a 100644 (file)
@@ -1,3 +1,4 @@
+
 /* 
  * Blog view renderer module for WebCit
  *
@@ -38,7 +39,7 @@ typedef struct _blogpost {
        int num_msgs;           /* Number of msgnums stored in 'msgs' */
        int alloc_msgs;         /* Currently allocated size of array */
        int unread_oments;
-}blogpost;
+} blogpost;
 
 
 /*
@@ -57,16 +58,17 @@ void sitemap_do_blog(void) {
 
        memset(&Stat, 0, sizeof Stat);
        memset(&oneBP, 0, sizeof(blogpost));
-        memset(&SubTP, 0, sizeof(WCTemplputParams));    
+       memset(&SubTP, 0, sizeof(WCTemplputParams));
        StackContext(NULL, &SubTP, &oneBP, CTX_BLOGPOST, 0, NULL);
 
        Stat.maxload = INT_MAX;
        Stat.lowest_found = (-1);
        Stat.highest_found = (-1);
        num_msgs = load_msg_ptrs("MSGS ALL", NULL, NULL, &Stat, NULL, NULL, NULL, NULL, 0);
-       if (num_msgs < 1) return;
+       if (num_msgs < 1)
+               return;
 
-       for (i=0; i<num_msgs; ++i) {
+       for (i = 0; i < num_msgs; ++i) {
                Msg = GetMessagePtrAt(i, WCC->summ);
                if (Msg != NULL) {
                        ReadOneMessageSummary(Msg, FoundCharset, Buf);
@@ -89,21 +91,21 @@ void sitemap_do_blog(void) {
  * (Call with NULL arguments to make this function wcprintf() the permalink
  * instead of writing it to the template)
  */
-void tmplput_blog_toplevel_id(StrBuf *Target, WCTemplputParams *TP) {
-       blogpost *bp = (blogpost*) CTX(CTX_BLOGPOST);
+void tmplput_blog_toplevel_id(StrBuf * Target, WCTemplputParams * TP) {
+       blogpost *bp = (blogpost *) CTX(CTX_BLOGPOST);
        char buf[SIZ];
        snprintf(buf, SIZ, "%d", bp->top_level_id);
        StrBufAppendTemplateStr(Target, TP, buf, 0);
 }
 
-void tmplput_blog_comment_count(StrBuf *Target, WCTemplputParams *TP) {
-       blogpost *bp = (blogpost*) CTX(CTX_BLOGPOST);
+void tmplput_blog_comment_count(StrBuf * Target, WCTemplputParams * TP) {
+       blogpost *bp = (blogpost *) CTX(CTX_BLOGPOST);
        char buf[SIZ];
-       snprintf(buf, SIZ, "%d", bp->num_msgs -1);
+       snprintf(buf, SIZ, "%d", bp->num_msgs - 1);
        StrBufAppendTemplateStr(Target, TP, buf, 0);
 }
-void tmplput_blog_comment_unread_count(StrBuf *Target, WCTemplputParams *TP) {
-       blogpost *bp = (blogpost*) CTX(CTX_BLOGPOST);
+void tmplput_blog_comment_unread_count(StrBuf * Target, WCTemplputParams * TP) {
+       blogpost *bp = (blogpost *) CTX(CTX_BLOGPOST);
        char buf[SIZ];
        snprintf(buf, SIZ, "%d", bp->unread_oments);
        StrBufAppendTemplateStr(Target, TP, buf, 0);
@@ -114,14 +116,13 @@ void tmplput_blog_comment_unread_count(StrBuf *Target, WCTemplputParams *TP) {
 /*
  * Render a single blog post and (optionally) its comments
  */
-void blogpost_render(blogpost *bp, int with_comments, WCTemplputParams *TP)
-{
+void blogpost_render(blogpost * bp, int with_comments, WCTemplputParams * TP) {
        wcsession *WCC = WC;
        WCTemplputParams SubTP;
        const StrBuf *Mime;
        int i;
 
-        memset(&SubTP, 0, sizeof(WCTemplputParams));
+       memset(&SubTP, 0, sizeof(WCTemplputParams));
        StackContext(TP, &SubTP, bp, CTX_BLOGPOST, 0, NULL);
 
        /* Always show the top level post, unless we somehow ended up with an empty list */
@@ -133,7 +134,7 @@ void blogpost_render(blogpost *bp, int with_comments, WCTemplputParams *TP)
                /* Show any existing comments, then offer the comment box */
                DoTemplate(HKEY("view_blog_show_commentlink"), WCC->WBuf, &SubTP);
 
-               for (i=1; i<bp->num_msgs; ++i) {
+               for (i = 1; i < bp->num_msgs; ++i) {
                        read_message(WC->WBuf, HKEY("view_blog_comment"), bp->msgs[i], NULL, &Mime, &SubTP);
                }
                DoTemplate(HKEY("view_blog_comment_box"), WCC->WBuf, &SubTP);
@@ -150,7 +151,7 @@ void blogpost_render(blogpost *bp, int with_comments, WCTemplputParams *TP)
 /*
  * Destructor for "blogpost"
  */
-void blogpost_destroy(blogpost *bp) {
+void blogpost_destroy(blogpost * bp) {
        if (bp->alloc_msgs > 0) {
                free(bp->msgs);
        }
@@ -161,34 +162,30 @@ void blogpost_destroy(blogpost *bp) {
 /*
  * Entry point for message read operations.
  */
-int blogview_GetParamsGetServerCall(SharedMessageStatus *Stat, 
-                                   void **ViewSpecific, 
-                                   long oper, 
-                                   char *cmd, 
-                                   long len,
-                                   char *filter,
-                                   long flen)
-{
-       BLOG *BL = (BLOG*) malloc(sizeof(BLOG)); 
+int blogview_GetParamsGetServerCall(SharedMessageStatus * Stat,
+                                   void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen) {
+       BLOG *BL = (BLOG *) malloc(sizeof(BLOG));
        BL->BLOGPOSTS = NewHash(1, lFlathash);
-       
+
        /* are we looking for a specific post? */
        BL->p = lbstr("p");
        BL->gotonext = havebstr("gotonext");
        BL->Charset = NewStrBuf();
        BL->Buf = NewStrBuf();
        BL->FilterTag = sbstr("FilterTag");
-       BL->firstp = lbstr("firstp");   /* start reading at... */
-       BL->maxp   = lbstr("maxp");         /* max posts to show... */
-       if (BL->maxp < 1) BL->maxp = 5;     /* default; move somewhere else? */
+       BL->firstp = lbstr("firstp");   /* start reading at... */
+       BL->maxp = lbstr("maxp");       /* max posts to show... */
+       if (BL->maxp < 1)
+               BL->maxp = 5;   /* default; move somewhere else? */
        putlbstr("maxp", BL->maxp);
        *ViewSpecific = BL;
 
-       Stat->startmsg = (-1);                                  /* not used here */
-       Stat->sortit = 1;                                       /* not used here */
-       Stat->num_displayed = DEFAULT_MAXMSGS;                  /* not used here */
-       if (Stat->maxmsgs == 0) Stat->maxmsgs = DEFAULT_MAXMSGS;
-       
+       Stat->startmsg = (-1);  /* not used here */
+       Stat->sortit = 1;       /* not used here */
+       Stat->num_displayed = DEFAULT_MAXMSGS;  /* not used here */
+       if (Stat->maxmsgs == 0)
+               Stat->maxmsgs = DEFAULT_MAXMSGS;
+
        /* perform a "read all" call to fetch the message list -- we'll cut it down later */
        snprintf(cmd, len, "MSGS ALL||2|8\n");
 
@@ -198,54 +195,45 @@ int blogview_GetParamsGetServerCall(SharedMessageStatus *Stat,
 }
 
 
-int blogview_IdentifyBlogposts (StrBuf *Line, 
-                               const char **pos, 
-                               message_summary *Msg, 
-                               StrBuf *ConversionBuffer,
-                               void **ViewSpecific)
-{
-       BLOG *BL = (BLOG*) *ViewSpecific;
+int blogview_IdentifyBlogposts(StrBuf * Line,
+                              const char **pos, message_summary * Msg, StrBuf * ConversionBuffer, void **ViewSpecific) {
+       BLOG *BL = (BLOG *) * ViewSpecific;
        blogpost *bp = NULL;
 
        /* Stop processing if the viewer is only interested in a single post and
         * that message ID is neither the id nor the refs.
         */
-       if ((BL->p != 0) &&
-           (BL->p != Msg->reply_inreplyto_hash) &&
-           (BL->p != Msg->reply_references_hash)) {
+       if ((BL->p != 0) && (BL->p != Msg->reply_inreplyto_hash) && (BL->p != Msg->reply_references_hash)) {
                return 0;
        }
 
-       if ((Msg->reply_references_hash == 0) && 
-           (BL->FilterTag != NULL) && 
-           (strstr(ChrPtr(Msg->EnvTo) , ChrPtr(BL->FilterTag)) == NULL)) {
+       if ((Msg->reply_references_hash == 0) &&
+           (BL->FilterTag != NULL) && (strstr(ChrPtr(Msg->EnvTo), ChrPtr(BL->FilterTag)) == NULL)) {
                /* filtering for tags, blogpost doesn't fit. */
                return 0;
        }
-           
+
        /*
         * build up a hashtable of the blogposts.
         */
        if (Msg->reply_references_hash == 0) {
                bp = malloc(sizeof(blogpost));
 
-               if (bp == NULL) return 0;
+               if (bp == NULL)
+                       return 0;
 
-               memset(bp, 0, sizeof (blogpost));
+               memset(bp, 0, sizeof(blogpost));
 
-               bp->top_level_id = Msg->reply_inreplyto_hash;
+               bp->top_level_id = Msg->reply_inreplyto_hash;
                bp->alloc_msgs = 1000;
                bp->msgs = malloc(bp->alloc_msgs * sizeof(long));
-               memset(bp->msgs, 0, (bp->alloc_msgs * sizeof(long)) );
+               memset(bp->msgs, 0, (bp->alloc_msgs * sizeof(long)));
 
                /* the first one is the blogpost itself, all subequent are comments. */
                bp->msgs[0] = Msg->msgnum;
                bp->num_msgs = 1;
 
-               Put(BL->BLOGPOSTS,
-                   LKEY(Msg->reply_inreplyto_hash),
-                   bp,
-                   (DeleteHashDataFunc)blogpost_destroy);
+               Put(BL->BLOGPOSTS, LKEY(Msg->reply_inreplyto_hash), bp, (DeleteHashDataFunc) blogpost_destroy);
        }
        /*
         * Comments will be handled on the next iteration.
@@ -258,22 +246,15 @@ int blogview_IdentifyBlogposts (StrBuf *Line,
 /*
  * This function is called for every message in the list.
  */
-int blogview_LoadMsgFromServer(SharedMessageStatus *Stat, 
-                             void **ViewSpecific, 
-                             message_summary* Msg, 
-                             int is_new, 
-                             int i)
-{
+int blogview_LoadMsgFromServer(SharedMessageStatus * Stat, void **ViewSpecific, message_summary * Msg, int is_new, int i) {
        blogpost *bp = NULL;
-       BLOG *BL = (BLOG*) *ViewSpecific;
+       BLOG *BL = (BLOG *) * ViewSpecific;
 
        if (Msg->reply_references_hash != 0) {
                /* 
                 * this is a comment. try to assign it to a blogpost.
                 */
-               GetHash(BL->BLOGPOSTS,
-                       LKEY(Msg->reply_references_hash),
-                       (void *)&bp);
+               GetHash(BL->BLOGPOSTS, LKEY(Msg->reply_references_hash), (void *) &bp);
 
                /*
                 * Now we have a 'blogpost' to which we can add the comment.  It's either the
@@ -284,8 +265,7 @@ int blogview_LoadMsgFromServer(SharedMessageStatus *Stat,
                        if (bp->num_msgs >= bp->alloc_msgs) {
                                bp->alloc_msgs *= 2;
                                bp->msgs = realloc(bp->msgs, (bp->alloc_msgs * sizeof(long)));
-                               memset(&bp->msgs[bp->num_msgs], 0,
-                                      ((bp->alloc_msgs - bp->num_msgs) * sizeof(long)) );
+                               memset(&bp->msgs[bp->num_msgs], 0, ((bp->alloc_msgs - bp->num_msgs) * sizeof(long)));
                        }
                        bp->msgs[bp->num_msgs++] = Msg->msgnum;
                        if ((Msg->Flags & MSGFLAG_READ) != 0) {
@@ -308,13 +288,15 @@ int blogview_LoadMsgFromServer(SharedMessageStatus *Stat,
  * Sort a list of 'struct blogpost' pointers by newest-to-oldest msgnum.
  * With big thanks to whoever wrote http://www.c.happycodings.com/Sorting_Searching/code14.html
  */
-static int blogview_sortfunc(const void *a, const void *b) { 
+static int blogview_sortfunc(const void *a, const void *b) {
        blogpost const *one = GetSearchPayload(a);
        blogpost const *two = GetSearchPayload(b);
 
-       if ( one->msgs[0] > two->msgs[0] ) return(-1);
-       if ( one->msgs[0] < two->msgs[0] ) return(+1);
-       return(0);
+       if (one->msgs[0] > two->msgs[0])
+               return (-1);
+       if (one->msgs[0] < two->msgs[0])
+               return (+1);
+       return (0);
 }
 
 
@@ -322,10 +304,9 @@ static int blogview_sortfunc(const void *a, const void *b) {
  * All blogpost entries are now in the hash list.
  * Sort them, select the desired range, and render what we want to see.
  */
-int blogview_render(SharedMessageStatus *Stat, void **ViewSpecific, long oper)
-{
+int blogview_render(SharedMessageStatus * Stat, void **ViewSpecific, long oper) {
        wcsession *WCC = WC;
-       BLOG *BL = (BLOG*) *ViewSpecific;
+       BLOG *BL = (BLOG *) * ViewSpecific;
        HashPos *it;
        const char *Key;
        blogpost *thisBlogpost;
@@ -346,8 +327,8 @@ int blogview_render(SharedMessageStatus *Stat, void **ViewSpecific, long oper)
                /* Nothing to do... */
                return 0;
        }
-        memset(&SubTP, 0, sizeof(WCTemplputParams));    
-        memset(&StopSubTP, 0, sizeof(WCTemplputParams));    
+       memset(&SubTP, 0, sizeof(WCTemplputParams));
+       memset(&StopSubTP, 0, sizeof(WCTemplputParams));
        memset(&oneBP, 0, sizeof(blogpost));
 
        /* Comments are shown if we are only viewing a single blog post */
@@ -370,7 +351,7 @@ int blogview_render(SharedMessageStatus *Stat, void **ViewSpecific, long oper)
                        }
                }
                if (unread_count == 1) {
-                       blogpost_render(unread_bp, 1, NULL);/// TODO other than null?
+                       blogpost_render(unread_bp, 1, NULL);    /// TODO other than null?
 
                        DeleteHashPos(&it);
                        return 0;
@@ -394,13 +375,13 @@ int blogview_render(SharedMessageStatus *Stat, void **ViewSpecific, long oper)
                                firstPOffset = count;
                                break;
                        }
-                       count ++;
+                       count++;
                }
        }
 
-       if ((num_blogposts > BL->maxp) || (firstPOffset != 0)){
+       if ((num_blogposts > BL->maxp) || (firstPOffset != 0)) {
                PrevNext = NewStrBuf();
-               if (firstPOffset  > 0) {
+               if (firstPOffset > 0) {
                        const char *k;
                        long len;
                        long posPrev = 0;
@@ -435,7 +416,7 @@ int blogview_render(SharedMessageStatus *Stat, void **ViewSpecific, long oper)
                /* allow the user to select a starting point in the list */
                if (totalCount < firstPOffset) {
                        /* skip all till we found the first valid: */
-                       totalCount ++;
+                       totalCount++;
                        continue;
                }
                if (count >= BL->maxp) {
@@ -445,20 +426,19 @@ int blogview_render(SharedMessageStatus *Stat, void **ViewSpecific, long oper)
                StackContext(NULL, &SubTP, thisBlogpost, CTX_BLOGPOST, 0, NULL);
                blogpost_render(thisBlogpost, with_comments, &SubTP);
                UnStackContext(&SubTP);
-               count ++;
-               totalCount ++;
+               count++;
+               totalCount++;
        }
        StrBufAppendBuf(WCC->WBuf, PrevNext, 0);
        FreeStrBuf(&PrevNext);
        DeleteHashPos(&it);
 
-       return(0);
+       return (0);
 }
 
 
-int blogview_Cleanup(void **ViewSpecific)
-{
-       BLOG *BL = (BLOG*) *ViewSpecific;
+int blogview_Cleanup(void **ViewSpecific) {
+       BLOG *BL = (BLOG *) * ViewSpecific;
 
        FreeStrBuf(&BL->Buf);
        FreeStrBuf(&BL->Charset);
@@ -469,11 +449,8 @@ int blogview_Cleanup(void **ViewSpecific)
 }
 
 
-void 
-InitModule_BLOGVIEWRENDERERS
-(void)
-{
-       const char* browseListFields[] = {
+void InitModule_BLOGVIEWRENDERERS(void) {
+       const char *browseListFields[] = {
                "msgn",
                "nvto",
                "wefw",
@@ -481,17 +458,12 @@ InitModule_BLOGVIEWRENDERERS
        };
        RegisterCTX(CTX_BLOGPOST);
 
-       RegisterReadLoopHandlerset(
-               VIEW_BLOG,
-               blogview_GetParamsGetServerCall,
-               NULL,
-               NULL,
-               blogview_IdentifyBlogposts, 
-               blogview_LoadMsgFromServer,
-               blogview_render,
-               blogview_Cleanup,
-               browseListFields
-       );
+       RegisterReadLoopHandlerset(VIEW_BLOG,
+                                  blogview_GetParamsGetServerCall,
+                                  NULL,
+                                  NULL,
+                                  blogview_IdentifyBlogposts,
+                                  blogview_LoadMsgFromServer, blogview_render, blogview_Cleanup, browseListFields);
 
        RegisterNamespace("BLOG:TOPLEVEL:MSGID", 0, 0, tmplput_blog_toplevel_id, NULL, CTX_BLOGPOST);
        RegisterNamespace("BLOG:COMMENTS:COUNT", 0, 0, tmplput_blog_comment_count, NULL, CTX_BLOGPOST);
index 1185bfc22d233dbb8bda5e3d94573a1443ad63b0..42e574b5b63b6d42a5208434f18f073d9a7435b8 100644 (file)
 
 // Process a calendar object.  At this point it's already been deserialized by cal_process_attachment()
 //
-// cal:                        the calendar object
-// recursion_level:    Number of times we've recursed into this function
-// msgnum:             Message number on the Citadel server
-// cal_partnum:                MIME part number within that message containing the calendar object
-void cal_process_object(StrBuf *Target,
-                       icalcomponent *cal,
-                       int recursion_level,
-                       long msgnum,
-                       const char *cal_partnum) 
-{
+// cal:                 the calendar object
+// recursion_level:     Number of times we've recursed into this function
+// msgnum:              Message number on the Citadel server
+// cal_partnum:         MIME part number within that message containing the calendar object
+void cal_process_object(StrBuf * Target, icalcomponent * cal, int recursion_level, long msgnum, const char *cal_partnum) {
        icalcomponent *c;
        icalproperty *method = NULL;
        icalproperty_method the_method = ICAL_METHOD_NONE;
@@ -66,7 +61,7 @@ void cal_process_object(StrBuf *Target,
                StrBufAppendPrintf(Target, "<div id=\"%s_title\">", divname);
                StrBufAppendPrintf(Target, "<img src=\"static/webcit_icons/essen/32x32/calendar.png\">");
                StrBufAppendPrintf(Target, "<span>");
-               switch(the_method) {
+               switch (the_method) {
                case ICAL_METHOD_REQUEST:
                        title = _("Meeting invitation");
                        break;
@@ -82,26 +77,26 @@ void cal_process_object(StrBuf *Target,
                }
                StrBufAppendPrintf(Target, "</span>");
 
-               StrBufAppendPrintf(Target, "&nbsp;&nbsp;%s",title);
+               StrBufAppendPrintf(Target, "&nbsp;&nbsp;%s", title);
                StrBufAppendPrintf(Target, "</div>");
        }
 
        StrBufAppendPrintf(Target, "<dl>");
-       p = icalcomponent_get_first_property(cal, ICAL_SUMMARY_PROPERTY);
+       p = icalcomponent_get_first_property(cal, ICAL_SUMMARY_PROPERTY);
        if (p != NULL) {
                StrBufAppendPrintf(Target, "<dt>");
                StrBufAppendPrintf(Target, _("Summary:"));
                StrBufAppendPrintf(Target, "</dt><dd>");
-               StrEscAppend(Target, NULL, (char *)icalproperty_get_comment(p), 0, 0);
+               StrEscAppend(Target, NULL, (char *) icalproperty_get_comment(p), 0, 0);
                StrBufAppendPrintf(Target, "</dd>\n");
        }
 
-       p = icalcomponent_get_first_property(cal, ICAL_LOCATION_PROPERTY);
+       p = icalcomponent_get_first_property(cal, ICAL_LOCATION_PROPERTY);
        if (p != NULL) {
                StrBufAppendPrintf(Target, "<dt>");
                StrBufAppendPrintf(Target, _("Location:"));
                StrBufAppendPrintf(Target, "</dt><dd>");
-               StrEscAppend(Target, NULL, (char *)icalproperty_get_comment(p), 0, 0);
+               StrEscAppend(Target, NULL, (char *) icalproperty_get_comment(p), 0, 0);
                StrBufAppendPrintf(Target, "</dd>\n");
        }
 
@@ -109,7 +104,7 @@ void cal_process_object(StrBuf *Target,
        // component.  Otherwise it shows bogus dates for things like timezone.
        if (icalcomponent_isa(cal) == ICAL_VEVENT_COMPONENT) {
 
-               p = icalcomponent_get_first_property(cal, ICAL_DTSTART_PROPERTY);
+               p = icalcomponent_get_first_property(cal, ICAL_DTSTART_PROPERTY);
                if (p != NULL) {
                        t = icalproperty_get_dtstart(p);
 
@@ -133,8 +128,8 @@ void cal_process_object(StrBuf *Target,
                                StrBufAppendPrintf(Target, "</dt><dd>%s</dd>", buf);
                        }
                }
-       
-               p = icalcomponent_get_first_property(cal, ICAL_DTEND_PROPERTY);
+
+               p = icalcomponent_get_first_property(cal, ICAL_DTEND_PROPERTY);
                if (p != NULL) {
                        t = icalproperty_get_dtend(p);
                        tt = icaltime_as_timet(t);
@@ -146,27 +141,24 @@ void cal_process_object(StrBuf *Target,
 
        }
 
-       p = icalcomponent_get_first_property(cal, ICAL_DESCRIPTION_PROPERTY);
+       p = icalcomponent_get_first_property(cal, ICAL_DESCRIPTION_PROPERTY);
        if (p != NULL) {
                StrBufAppendPrintf(Target, "<dt>");
                StrBufAppendPrintf(Target, _("Description:"));
                StrBufAppendPrintf(Target, "</dt><dd>");
-               StrEscAppend(Target, NULL, (char *)icalproperty_get_comment(p), 0, 0);
+               StrEscAppend(Target, NULL, (char *) icalproperty_get_comment(p), 0, 0);
                StrBufAppendPrintf(Target, "</dd>\n");
        }
 
        if (icalcomponent_get_first_property(cal, ICAL_RRULE_PROPERTY)) {
                // Unusual string syntax used here in order to re-use existing translations
-               StrBufAppendPrintf(Target, "<dt>%s:</dt><dd>%s.</dd>\n",
-                       _("Recurrence"),
-                       _("This is a recurring event")
-               );
+               StrBufAppendPrintf(Target, "<dt>%s:</dt><dd>%s.</dd>\n", _("Recurrence"), _("This is a recurring event")
+                   );
        }
 
        // If the component has attendees, iterate through them.
-       for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY); 
-            (p != NULL); 
-            p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) {
+       for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY);
+            (p != NULL); p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) {
                StrBufAppendPrintf(Target, "<dt>");
                StrBufAppendPrintf(Target, _("Attendee:"));
                StrBufAppendPrintf(Target, "</dt><dd>");
@@ -188,11 +180,10 @@ void cal_process_object(StrBuf *Target,
 
        // If the component has subcomponents, recurse through them.
        for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT);
-               (c != 0);
-               c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)
-       ) {
+            (c != 0); c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)
+           ) {
                // Recursively process subcomponent
-               cal_process_object(Target, c, recursion_level+1, msgnum, cal_partnum);
+               cal_process_object(Target, c, recursion_level + 1, msgnum, cal_partnum);
        }
 
        // If this is a REQUEST, display conflicts and buttons
@@ -213,15 +204,13 @@ void cal_process_object(StrBuf *Target,
                                }
                                else {
                                        snprintf(conflict_message, sizeof conflict_message,
-                                                _("This event would conflict with '%s' which is already in your calendar."), conflict_name);
+                                                _("This event would conflict with '%s' which is already in your calendar."),
+                                                conflict_name);
                                }
 
-                               StrBufAppendPrintf(Target, "<dt>%s",
-                                       (is_update ?
-                                        _("Update:") :
-                                        _("CONFLICT:")
-                                               )
-                                       );
+                               StrBufAppendPrintf(Target, "<dt>%s", (is_update ? _("Update:") : _("CONFLICT:")
+                                                  )
+                                   );
                                StrBufAppendPrintf(Target, "</dt><dd>");
                                StrEscAppend(Target, NULL, conflict_message, 0, 0);
                                StrBufAppendPrintf(Target, "</dd>\n");
@@ -233,20 +222,20 @@ void cal_process_object(StrBuf *Target,
 
                // Display the Accept/Decline buttons
                StrBufAppendPrintf(Target, "<p id=\"%s_question\">"
-                       "%s "
-                       "&nbsp;&nbsp;&nbsp;<span class=\"button_link\"> "
-                       "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Accept');\">%s</a>"
-                       "</span>&nbsp;&nbsp;&nbsp;<span class=\"button_link\">"
-                       "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Tentative');\">%s</a>"
-                       "</span>&nbsp;&nbsp;&nbsp;<span class=\"button_link\">"
-                       "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Decline');\">%s</a>"
-                       "</span></p>\n",
-                       divname,
-                       _("How would you like to respond to this invitation?"),
-                       divname, divname, msgnum, cal_partnum, _("Accept"),
-                       divname, divname, msgnum, cal_partnum, _("Tentative"),
-                       divname, divname, msgnum, cal_partnum, _("Decline")
-                       );
+                                  "%s "
+                                  "&nbsp;&nbsp;&nbsp;<span class=\"button_link\"> "
+                                  "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Accept');\">%s</a>"
+                                  "</span>&nbsp;&nbsp;&nbsp;<span class=\"button_link\">"
+                                  "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Tentative');\">%s</a>"
+                                  "</span>&nbsp;&nbsp;&nbsp;<span class=\"button_link\">"
+                                  "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Decline');\">%s</a>"
+                                  "</span></p>\n",
+                                  divname,
+                                  _("How would you like to respond to this invitation?"),
+                                  divname, divname, msgnum, cal_partnum, _("Accept"),
+                                  divname, divname, msgnum, cal_partnum, _("Tentative"),
+                                  divname, divname, msgnum, cal_partnum, _("Decline")
+                   );
 
        }
 
@@ -255,20 +244,20 @@ void cal_process_object(StrBuf *Target,
 
                // Display the update buttons
                StrBufAppendPrintf(Target, "<p id=\"%s_question\" >"
-                       "%s "
-                       "&nbsp;&nbsp;&nbsp;<span class=\"button_link\"> "
-                       "<a href=\"javascript:HandleRSVP('%s_question','%s_title','%ld','%s','Update');\">%s</a>"
-                       "</span>&nbsp;&nbsp;&nbsp;<span class=\"button_link\">"
-                       "<a href=\"javascript:HandleRSVP('%s_question','%s_title','%ld','%s','Ignore');\">%s</a>"
-                       "</span></p>\n",
-                       divname,
-                       _("Click <i>Update</i> to accept this reply and update your calendar."),
-                       divname, divname, msgnum, cal_partnum, _("Update"),
-                       divname, divname, msgnum, cal_partnum, _("Ignore")
-                       );
-       
-       }
-       
+                                  "%s "
+                                  "&nbsp;&nbsp;&nbsp;<span class=\"button_link\"> "
+                                  "<a href=\"javascript:HandleRSVP('%s_question','%s_title','%ld','%s','Update');\">%s</a>"
+                                  "</span>&nbsp;&nbsp;&nbsp;<span class=\"button_link\">"
+                                  "<a href=\"javascript:HandleRSVP('%s_question','%s_title','%ld','%s','Ignore');\">%s</a>"
+                                  "</span></p>\n",
+                                  divname,
+                                  _("Click <i>Update</i> to accept this reply and update your calendar."),
+                                  divname, divname, msgnum, cal_partnum, _("Update"),
+                                  divname, divname, msgnum, cal_partnum, _("Ignore")
+                   );
+
+       }
+
        // Trailing HTML for the display of this object
        if (recursion_level == 0) {
                StrBufAppendPrintf(Target, "<p>&nbsp;</p></div>\n");
@@ -277,7 +266,7 @@ void cal_process_object(StrBuf *Target,
 
 
 // Deserialize a calendar object in a message so it can be displayed.
-void cal_process_attachment(wc_mime_attachment *Mime) {
+void cal_process_attachment(wc_mime_attachment * Mime) {
        icalcomponent *cal;
 
        cal = icalcomponent_new_from_string(ChrPtr(Mime->Data));
@@ -301,29 +290,25 @@ void respond_to_request(void) {
 
        begin_ajax_response();
 
-       serv_printf("ICAL respond|%s|%s|%s|",
-               bstr("msgnum"),
-               bstr("cal_partnum"),
-               bstr("sc")
-       );
+       serv_printf("ICAL respond|%s|%s|%s|", bstr("msgnum"), bstr("cal_partnum"), bstr("sc")
+           );
        serv_getln(buf, sizeof buf);
 
        if (buf[0] == '2') {
                wc_printf("<img src=\"static/webcit_icons/essen/32x32/calendar.png\"><span>");
                if (!strcasecmp(bstr("sc"), "accept")) {
-                       wc_printf(_("You have accepted this meeting invitation.  "
-                               "It has been entered into your calendar.")
-                       );
+                       wc_printf(_("You have accepted this meeting invitation.  " "It has been entered into your calendar.")
+                           );
                }
                else if (!strcasecmp(bstr("sc"), "tentative")) {
                        wc_printf(_("You have tentatively accepted this meeting invitation.  "
-                               "It has been 'pencilled in' to your calendar.")
-                       );
+                                   "It has been 'pencilled in' to your calendar.")
+                           );
                }
                else if (!strcasecmp(bstr("sc"), "decline")) {
                        wc_printf(_("You have declined this meeting invitation.  "
-                                 "It has <b>not</b> been entered into your calendar.")
-                               );
+                                   "It has <b>not</b> been entered into your calendar.")
+                           );
                }
                wc_printf(" ");
                wc_printf(_("A reply has been sent to the meeting organizer."));
@@ -344,11 +329,8 @@ void handle_rsvp(void) {
 
        begin_ajax_response();
 
-       serv_printf("ICAL handle_rsvp|%s|%s|%s|",
-               bstr("msgnum"),
-               bstr("cal_partnum"),
-               bstr("sc")
-       );
+       serv_printf("ICAL handle_rsvp|%s|%s|%s|", bstr("msgnum"), bstr("cal_partnum"), bstr("sc")
+           );
        serv_getln(buf, sizeof buf);
 
        if (buf[0] == '2') {
@@ -360,9 +342,8 @@ void handle_rsvp(void) {
                        wc_printf(_("Your calendar has been updated to reflect this RSVP."));
                }
                else if (!strcasecmp(bstr("sc"), "ignore")) {
-                       wc_printf(_("You have chosen to ignore this RSVP. "
-                                 "Your calendar has <b>not</b> been updated.")
-                       );
+                       wc_printf(_("You have chosen to ignore this RSVP. " "Your calendar has <b>not</b> been updated.")
+                           );
                }
                wc_printf("</span>");
        }
@@ -377,7 +358,7 @@ void handle_rsvp(void) {
 
 // free memory allocated using libical
 void delete_cal(void *vCal) {
-       disp_cal *Cal = (disp_cal*) vCal;
+       disp_cal *Cal = (disp_cal *) vCal;
        icalcomponent_free(Cal->cal);
        free(Cal->from);
        free(Cal);
@@ -388,7 +369,7 @@ void delete_cal(void *vCal) {
 // As we encounter calendar items in messages being read from the server, we break out
 // any iCalendar objects and store them in a hash table.  Later on, the second phase will
 // use this hash table to render the calendar for display.
-void display_individual_cal(icalcomponent *event, long msgnum, char *from, int unread, calview *calv) {
+void display_individual_cal(icalcomponent * event, long msgnum, char *from, int unread, calview * calv) {
        icalproperty *ps = NULL;
        struct icaltimetype dtstart, dtend;
        struct icaldurationtype dur;
@@ -407,9 +388,8 @@ void display_individual_cal(icalcomponent *event, long msgnum, char *from, int u
        int stop_rr = 0;
 
        // first and foremost, check for bogosity.  bail if we see no DTSTART property
-       if (icalcomponent_get_first_property(icalcomponent_get_first_component(
-               event, ICAL_VEVENT_COMPONENT), ICAL_DTSTART_PROPERTY) == NULL
-       ) {
+       if (icalcomponent_get_first_property(icalcomponent_get_first_component(event, ICAL_VEVENT_COMPONENT), ICAL_DTSTART_PROPERTY)
+           == NULL) {
                return;
        }
 
@@ -417,13 +397,13 @@ void display_individual_cal(icalcomponent *event, long msgnum, char *from, int u
 
        dtstart = icaltime_null_time();
        dtend = icaltime_null_time();
-       
+
        if (WCC->disp_cal_items == NULL) {
                WCC->disp_cal_items = NewHash(0, Flathash);
        }
 
        // Note: anything we do here, we also have to do below for the recurrences.
-       Cal = (disp_cal*) malloc(sizeof(disp_cal));
+       Cal = (disp_cal *) malloc(sizeof(disp_cal));
        memset(Cal, 0, sizeof(disp_cal));
        Cal->cal = icalcomponent_new_clone(event);
 
@@ -440,7 +420,7 @@ void display_individual_cal(icalcomponent *event, long msgnum, char *from, int u
 
        Cal->unread = unread;
        len = strlen(from);
-       Cal->from = (char*)malloc(len+ 1);
+       Cal->from = (char *) malloc(len + 1);
        memcpy(Cal->from, from, len + 1);
        Cal->cal_msgnum = msgnum;
 
@@ -462,13 +442,14 @@ void display_individual_cal(icalcomponent *event, long msgnum, char *from, int u
 
        // Store it in the hash list.
        // syslog(LOG_DEBUG, "INITIAL: %s", ctime(&Cal->event_start));
-       Put(WCC->disp_cal_items, (char*) &Cal->event_start, sizeof(Cal->event_start), Cal, delete_cal);
+       Put(WCC->disp_cal_items, (char *) &Cal->event_start, sizeof(Cal->event_start), Cal, delete_cal);
 
        //***************************** handle recurring events ******************************
 
-       if (icaltime_is_null_time(dtstart)) return;     /* Can't recur without a start time */
+       if (icaltime_is_null_time(dtstart))
+               return;         /* Can't recur without a start time */
 
-       if (!icaltime_is_null_time(dtend)) {            /* Need duration for recurrences */
+       if (!icaltime_is_null_time(dtend)) {    /* Need duration for recurrences */
                dur = icaltime_subtract(dtend, dtstart);
        }
        else {
@@ -484,28 +465,32 @@ void display_individual_cal(icalcomponent *event, long msgnum, char *from, int u
        if (icalcomponent_isa(cptr) != ICAL_VEVENT_COMPONENT) {
                cptr = icalcomponent_get_first_component(cptr, ICAL_VEVENT_COMPONENT);
        }
-       if (!cptr) return;
+       if (!cptr)
+               return;
        ps = icalcomponent_get_first_property(cptr, ICAL_DTSTART_PROPERTY);
-       if (ps == NULL) return;
+       if (ps == NULL)
+               return;
        dtstart = icalproperty_get_dtstart(ps);
        rrule = icalcomponent_get_first_property(cptr, ICAL_RRULE_PROPERTY);
-       if (!rrule) return;
+       if (!rrule)
+               return;
        recur = icalproperty_get_rrule(rrule);
        ritr = icalrecur_iterator_new(recur, dtstart);
-       if (!ritr) return;
+       if (!ritr)
+               return;
 
-       while (next = icalrecur_iterator_next(ritr), ((!icaltime_is_null_time(next))&&(!stop_rr)) ) {
+       while (next = icalrecur_iterator_next(ritr), ((!icaltime_is_null_time(next)) && (!stop_rr))) {
                ++num_recur;
-               if (num_recur > 1) {            /* Skip the first one.  We already did it at the root. */
+               if (num_recur > 1) {    /* Skip the first one.  We already did it at the root. */
                        icalcomponent *cptr;
 
                        /* Note: anything we do here, we also have to do above for the root event. */
-                       Cal = (disp_cal*) malloc(sizeof(disp_cal));
+                       Cal = (disp_cal *) malloc(sizeof(disp_cal));
                        memset(Cal, 0, sizeof(disp_cal));
                        Cal->cal = icalcomponent_new_clone(event);
                        Cal->unread = unread;
                        len = strlen(from);
-                       Cal->from = (char*)malloc(len+ 1);
+                       Cal->from = (char *) malloc(len + 1);
                        memcpy(Cal->from, from, len + 1);
                        Cal->cal_msgnum = msgnum;
 
@@ -518,9 +503,7 @@ void display_individual_cal(icalcomponent *event, long msgnum, char *from, int u
                        if (cptr) {
 
                                /* Remove any existing DTSTART properties */
-                               while ( ps = icalcomponent_get_first_property(cptr, ICAL_DTSTART_PROPERTY),
-                                       ps != NULL
-                               ) {
+                               while (ps = icalcomponent_get_first_property(cptr, ICAL_DTSTART_PROPERTY), ps != NULL) {
                                        icalcomponent_remove_property(cptr, ps);
                                }
 
@@ -552,23 +535,19 @@ void display_individual_cal(icalcomponent *event, long msgnum, char *from, int u
                                }
                        }
 
-                       if (    (Cal->event_start > calv->lower_bound)
-                               && (Cal->event_start < calv->upper_bound)
-                       ) {
+                       if ((Cal->event_start > calv->lower_bound)
+                           && (Cal->event_start < calv->upper_bound)
+                           ) {
                                /* syslog(LOG_DEBUG, "REPEATS: %s", ctime(&Cal->event_start)); */
-                               Put(WCC->disp_cal_items, 
-                                       (char*) &Cal->event_start,
-                                       sizeof(Cal->event_start), 
-                                       Cal, 
-                                       delete_cal
-                               );
+                               Put(WCC->disp_cal_items, (char *) &Cal->event_start, sizeof(Cal->event_start), Cal, delete_cal);
                        }
                        else {
                                delete_cal(Cal);
                        }
 
                        /* If an upper bound is set, stop when we go out of scope */
-                       if (final_recurrence > calv->upper_bound) stop_rr = 1;
+                       if (final_recurrence > calv->upper_bound)
+                               stop_rr = 1;
                }
        }
        icalrecur_iterator_free(ritr);
@@ -577,12 +556,7 @@ void display_individual_cal(icalcomponent *event, long msgnum, char *from, int u
 
 
 void process_ical_object(long msgnum, int unread,
-                        char *from, 
-                        char *FlatIcal, 
-                        icalcomponent_kind which_kind,
-                        IcalCallbackFunc CallBack,
-                        calview *calv
-) {
+                        char *from, char *FlatIcal, icalcomponent_kind which_kind, IcalCallbackFunc CallBack, calview * calv) {
        icalcomponent *cal, *c;
 
        cal = icalcomponent_new_from_string(FlatIcal);
@@ -592,24 +566,23 @@ void process_ical_object(long msgnum, int unread,
                if (which_kind == (-1)) {
                        CallBack(cal, msgnum, from, unread, calv);
                }
-               
+
                /* Otherwise recurse and hunt */
                else {
-                       
+
                        /* Simple components of desired type */
                        if (icalcomponent_isa(cal) == which_kind) {
                                CallBack(cal, msgnum, from, unread, calv);
                        }
-                       
+
                        /* Subcomponents of desired type */
                        for (c = icalcomponent_get_first_component(cal, which_kind);
-                            (c != 0);
-                            c = icalcomponent_get_next_component(cal, which_kind)) {
+                            (c != 0); c = icalcomponent_get_next_component(cal, which_kind)) {
                                CallBack(c, msgnum, from, unread, calv);
                        }
-                       
+
                }
-               
+
                icalcomponent_free(cal);
        }
 }
@@ -619,11 +592,7 @@ void process_ical_object(long msgnum, int unread,
 // the relevant part, deserialize it into a libical component, filter it for
 // the requested object type, and feed it to the specified handler.
 void load_ical_object(long msgnum, int unread,
-                     icalcomponent_kind which_kind,
-                     IcalCallbackFunc CallBack,
-                     calview *calv,
-                     int RenderAsync
-) {
+                     icalcomponent_kind which_kind, IcalCallbackFunc CallBack, calview * calv, int RenderAsync) {
        StrBuf *Buf;
        StrBuf *Data = NULL;
        const char *bptr;
@@ -635,7 +604,7 @@ void load_ical_object(long msgnum, int unread,
        char mime_disposition[256];
        char relevant_partnum[256];
        char *relevant_source = NULL;
-       int phase = 0;                          /* 0 = citadel headers, 1 = mime headers, 2 = body */
+       int phase = 0;          /* 0 = citadel headers, 1 = mime headers, 2 = body */
        char msg4_content_type[256] = "";
        char msg4_content_encoding[256] = "";
        int msg4_content_length = 0;
@@ -645,12 +614,11 @@ void load_ical_object(long msgnum, int unread,
        Buf = NewStrBuf();
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) != 1) {
-               FreeStrBuf (&Buf);
+               FreeStrBuf(&Buf);
                return;
        }
-       while (!Done && (StrBuf_ServGetln(Buf)>=0)) {
-               if ( (StrLength(Buf)==3) && 
-                    !strcmp(ChrPtr(Buf), "000")) {
+       while (!Done && (StrBuf_ServGetln(Buf) >= 0)) {
+               if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
                        Done = 1;
                        break;
                }
@@ -662,13 +630,13 @@ void load_ical_object(long msgnum, int unread,
                                extract_token(mime_partnum, &bptr[5], 2, '|', sizeof mime_partnum);
                                extract_token(mime_disposition, &bptr[5], 3, '|', sizeof mime_disposition);
                                extract_token(mime_content_type, &bptr[5], 4, '|', sizeof mime_content_type);
-                               /* do we care? mime_length = */extract_int(&bptr[5], 5);
+                               /* do we care? mime_length = */ extract_int(&bptr[5], 5);
 
-                               if (  (!strcasecmp(mime_content_type, "text/calendar"))
-                                     || (!strcasecmp(mime_content_type, "application/ics"))
-                                     || (!strcasecmp(mime_content_type, "text/vtodo"))
-                                     || (!strcasecmp(mime_content_type, "text/todo"))
-                                       ) {
+                               if ((!strcasecmp(mime_content_type, "text/calendar"))
+                                   || (!strcasecmp(mime_content_type, "application/ics"))
+                                   || (!strcasecmp(mime_content_type, "text/vtodo"))
+                                   || (!strcasecmp(mime_content_type, "text/todo"))
+                                   ) {
                                        strcpy(relevant_partnum, mime_partnum);
                                }
                        }
@@ -678,7 +646,7 @@ void load_ical_object(long msgnum, int unread,
                        else if ((phase == 0) && (!strncasecmp(bptr, "text", 4))) {
                                phase = 1;
                        }
-               break;
+                       break;
                case 1:
                        if (!IsEmptyStr(bptr)) {
                                if (!strncasecmp(bptr, "Content-type: ", 14)) {
@@ -696,16 +664,15 @@ void load_ical_object(long msgnum, int unread,
                        }
                        else {
                                phase++;
-                               
+
                                if ((msg4_content_length > 0)
-                                   && ( !strcasecmp(msg4_content_encoding, "7bit"))
+                                   && (!strcasecmp(msg4_content_encoding, "7bit"))
                                    && ((!strcasecmp(mime_content_type, "text/calendar"))
                                        || (!strcasecmp(mime_content_type, "application/ics"))
                                        || (!strcasecmp(mime_content_type, "text/vtodo"))
                                        || (!strcasecmp(mime_content_type, "text/todo"))
-                                           )
-                                       ) 
-                               {
+                                   )
+                                   ) {
                                }
                        }
                case 2:
@@ -713,7 +680,7 @@ void load_ical_object(long msgnum, int unread,
                                Data = NewStrBufPlain(NULL, msg4_content_length * 2);
                        if (msg4_content_length > 0) {
                                StrBuf_ServGetBLOBBuffered(Data, msg4_content_length);
-                               phase ++;
+                               phase++;
                        }
                        else {
                                StrBufAppendBuf(Data, Buf, 0);
@@ -732,23 +699,18 @@ void load_ical_object(long msgnum, int unread,
        }
 
        if (Data != NULL) {
-               relevant_source = (char*) ChrPtr(Data);
-               process_ical_object(msgnum, unread,
-                                   from, 
-                                   relevant_source, 
-                                   which_kind,
-                                   CallBack,
-                                   calv);
+               relevant_source = (char *) ChrPtr(Data);
+               process_ical_object(msgnum, unread, from, relevant_source, which_kind, CallBack, calv);
        }
-       FreeStrBuf (&Data);
+       FreeStrBuf(&Data);
 
        icalmemory_free_ring();
 }
 
 
 // Display a calendar item
-int calendar_LoadMsgFromServer(SharedMessageStatus *Stat, void **ViewSpecific, message_summary* Msg, int is_new, int i) {
-       calview *c = (calview*) *ViewSpecific;
+int calendar_LoadMsgFromServer(SharedMessageStatus * Stat, void **ViewSpecific, message_summary * Msg, int is_new, int i) {
+       calview *c = (calview *) * ViewSpecific;
        load_ical_object(Msg->msgnum, is_new, (-1), display_individual_cal, c, 1);
        return 0;
 }
@@ -800,10 +762,10 @@ void do_freebusy(void) {
        unescape_input(who);
 
        len = strlen(who);
-       if ( (!strcasecmp(&who[len-4], ".vcf"))
-            || (!strcasecmp(&who[len-4], ".ifb"))
-            || (!strcasecmp(&who[len-4], ".vfb")) ) {
-               who[len-4] = 0;
+       if ((!strcasecmp(&who[len - 4], ".vcf"))
+           || (!strcasecmp(&who[len - 4], ".ifb"))
+           || (!strcasecmp(&who[len - 4], ".vfb"))) {
+               who[len - 4] = 0;
        }
 
        syslog(LOG_INFO, "freebusy requested for <%s>\n", who);
@@ -826,11 +788,11 @@ void do_freebusy(void) {
 
 int calendar_Cleanup(void **ViewSpecific) {
        calview *c;
-       
-       c = (calview *) *ViewSpecific;
+
+       c = (calview *) * ViewSpecific;
 
        wDumpContent(1);
-       free (c);
+       free(c);
        *ViewSpecific = NULL;
 
        return 0;
@@ -839,41 +801,26 @@ int calendar_Cleanup(void **ViewSpecific) {
 
 int __calendar_Cleanup(void **ViewSpecific) {
        calview *c;
-       
-       c = (calview *) *ViewSpecific;
 
-       free (c);
+       c = (calview *) * ViewSpecific;
+
+       free(c);
        *ViewSpecific = NULL;
 
        return 0;
 }
 
 
-void 
-InitModule_CALENDAR
-(void)
-{
-       RegisterReadLoopHandlerset(
-               VIEW_CALENDAR,
-               calendar_GetParamsGetServerCall,
-               NULL,
-               NULL,
-               NULL,
-               calendar_LoadMsgFromServer,
-               calendar_RenderView_or_Tail,
-               calendar_Cleanup,
-               NULL);
-
-       RegisterReadLoopHandlerset(
-               VIEW_CALBRIEF,
-               calendar_GetParamsGetServerCall,
-               NULL,
-               NULL,
-               NULL,
-               calendar_LoadMsgFromServer,
-               calendar_RenderView_or_Tail,
-               calendar_Cleanup,
-               NULL);
+void InitModule_CALENDAR(void) {
+       RegisterReadLoopHandlerset(VIEW_CALENDAR,
+                                  calendar_GetParamsGetServerCall,
+                                  NULL,
+                                  NULL, NULL, calendar_LoadMsgFromServer, calendar_RenderView_or_Tail, calendar_Cleanup, NULL);
+
+       RegisterReadLoopHandlerset(VIEW_CALBRIEF,
+                                  calendar_GetParamsGetServerCall,
+                                  NULL,
+                                  NULL, NULL, calendar_LoadMsgFromServer, calendar_RenderView_or_Tail, calendar_Cleanup, NULL);
 
 
 
@@ -881,7 +828,7 @@ InitModule_CALENDAR
        RegisterPreference("dayend", _("Calendar day view ends at:"), PRF_INT, NULL);
        RegisterPreference("weekstart", _("Week starts on:"), PRF_INT, NULL);
 
-       WebcitAddUrlHandler(HKEY("freebusy"), "", 0, do_freebusy, COOKIEUNNEEDED|ANONYMOUS|FORCE_SESSIONCLOSE);
+       WebcitAddUrlHandler(HKEY("freebusy"), "", 0, do_freebusy, COOKIEUNNEEDED | ANONYMOUS | FORCE_SESSIONCLOSE);
        WebcitAddUrlHandler(HKEY("display_edit_task"), "", 0, display_edit_task, 0);
        WebcitAddUrlHandler(HKEY("display_edit_event"), "", 0, display_edit_event, 0);
        WebcitAddUrlHandler(HKEY("save_event"), "", 0, save_event, 0);
index ee1f8bc6a061a0f7ddcfe196eb810470c364bf9e..7b17c3faabdb3fcca386ff220af55e75cf88c647 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2013 by the citadel.org team
  *
@@ -12,6 +13,7 @@
 
 #ifndef __CALENDAR_H__
 #define __CALENDAR_H__
+
 /*
  * calview contains data passed back and forth between the message fetching loop
  * and the calendar view renderer.
@@ -31,50 +33,29 @@ typedef struct _calview {
        int day;
        time_t lower_bound;
        time_t upper_bound;
-}calview;
+} calview;
 
-typedef void (*IcalCallbackFunc)(icalcomponent *, long, char*, int, calview *);
+typedef void (*IcalCallbackFunc)(icalcomponent *, long, char *, int, calview *);
 
-void display_individual_cal(icalcomponent *cal, long msgnum, char *from, int unread, calview *calv);
+void display_individual_cal(icalcomponent * cal, long msgnum, char *from, int unread, calview * calv);
 void load_ical_object(long msgnum, int unread,
-                     icalcomponent_kind which_kind,
-                     IcalCallbackFunc CallBack,
-                     calview *calv,
-                     int RenderAsync
-       );
+                     icalcomponent_kind which_kind, IcalCallbackFunc CallBack, calview * calv, int RenderAsync);
 
-int calendar_LoadMsgFromServer(SharedMessageStatus *Stat, 
-                              void **ViewSpecific, 
-                              message_summary* Msg, 
-                              int is_new, 
-                              int i);
-int calendar_RenderView_or_Tail(SharedMessageStatus *Stat, 
-                               void **ViewSpecific, 
-                               long oper);
+int calendar_LoadMsgFromServer(SharedMessageStatus * Stat, void **ViewSpecific, message_summary * Msg, int is_new, int i);
+int calendar_RenderView_or_Tail(SharedMessageStatus * Stat, void **ViewSpecific, long oper);
 
-int calendar_GetParamsGetServerCall(SharedMessageStatus *Stat, 
-                                   void **ViewSpecific, 
-                                   long oper, 
-                                   char *cmd, 
-                                   long len,
-                                   char *filter,
-                                   long flen);
+int calendar_GetParamsGetServerCall(SharedMessageStatus * Stat,
+                                   void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen);
 
 int calendar_Cleanup(void **ViewSpecific);
 int __calendar_Cleanup(void **ViewSpecific);
 
-void render_calendar_view(calview *c);
-void display_edit_individual_event(icalcomponent *supplied_vtodo, long msgnum, char *from,
-       int unread, calview *calv);
-void save_individual_event(icalcomponent *supplied_vtodo, long msgnum, char *from,
-       int unread, calview *calv);
-void ical_dezonify(icalcomponent *cal);
+void render_calendar_view(calview * c);
+void display_edit_individual_event(icalcomponent * supplied_vtodo, long msgnum, char *from, int unread, calview * calv);
+void save_individual_event(icalcomponent * supplied_vtodo, long msgnum, char *from, int unread, calview * calv);
+void ical_dezonify(icalcomponent * cal);
 
-int tasks_LoadMsgFromServer(SharedMessageStatus *Stat, 
-                           void **ViewSpecific, 
-                           message_summary* Msg, 
-                           int is_new, 
-                           int i);
+int tasks_LoadMsgFromServer(SharedMessageStatus * Stat, void **ViewSpecific, message_summary * Msg, int is_new, int i);
 
 void display_edit_task(void);
 void display_edit_event(void);
@@ -83,15 +64,11 @@ icaltimezone *get_default_icaltimezone(void);
 void display_icaltimetype_as_webform(struct icaltimetype *, char *, int);
 void icaltime_from_webform(struct icaltimetype *result, char *prefix);
 void icaltime_from_webform_dateonly(struct icaltimetype *result, char *prefix);
-void partstat_as_string(char *buf, icalproperty *attendee);
-icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp);
-void check_attendee_availability(icalcomponent *supplied_vevent);
-int ical_ctdl_is_overlap(
-                        struct icaltimetype t1start,
-                        struct icaltimetype t1end,
-                        struct icaltimetype t2start,
-                        struct icaltimetype t2end
-);
+void partstat_as_string(char *buf, icalproperty * attendee);
+icalcomponent *ical_encapsulate_subcomponent(icalcomponent * subcomp);
+void check_attendee_availability(icalcomponent * supplied_vevent);
+int ical_ctdl_is_overlap(struct icaltimetype t1start,
+                        struct icaltimetype t1end, struct icaltimetype t2start, struct icaltimetype t2end);
 
 
 #endif
index 3d875c307bdbc738c73b86a7072cf5b0ab5a55f1..c40fcde49091db6b6ad02ac9e1cce35fcf39c29a 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Miscellaneous functions which handle calendar components.
  *
@@ -52,14 +53,16 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix, int d
        int all_day_event = 0;
        int time_format;
        char timebuf[32];
-       
-       time_format = get_time_format_cached ();
+
+       time_format = get_time_format_cached();
 
        now = time(NULL);
        localtime_r(&now, &tm_now);
 
-       if (t == NULL) return;
-       if (t->is_date) all_day_event = 1;
+       if (t == NULL)
+               return;
+       if (t->is_date)
+               all_day_event = 1;
        tt = icaltime_as_timet(*t);
        if (all_day_event) {
                gmtime_r(&tt, &tm);
@@ -93,19 +96,14 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix, int d
        wc_printf("_time\">");
        wc_printf(_("Hour: "));
        wc_printf("<SELECT NAME=\"%s_hour\" SIZE=\"1\">\n", prefix);
-       for (i=0; i<=23; ++i) {
+       for (i = 0; i <= 23; ++i) {
 
                if (time_format == WC_TIMEFORMAT_24) {
-                       wc_printf("<OPTION %s VALUE=\"%d\">%d</OPTION>\n",
-                               ((tm.tm_hour == i) ? "SELECTED" : ""),
-                               i, i
-                               );
+                       wc_printf("<OPTION %s VALUE=\"%d\">%d</OPTION>\n", ((tm.tm_hour == i) ? "SELECTED" : ""), i, i);
                }
                else {
-                       wc_printf("<OPTION %s VALUE=\"%d\">%s</OPTION>\n",
-                               ((tm.tm_hour == i) ? "SELECTED" : ""),
-                               i, hourname[i]
-                               );
+                       wc_printf("<OPTION %s VALUE=\"%d\">%s</OPTION>\n", ((tm.tm_hour == i) ? "SELECTED" : ""), i, hourname[i]
+                           );
                }
 
        }
@@ -113,12 +111,9 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix, int d
 
        wc_printf(_("Minute: "));
        wc_printf("<SELECT NAME=\"%s_minute\" SIZE=\"1\">\n", prefix);
-       for (i=0; i<=59; ++i) {
-               if ( (i % 5 == 0) || (tm.tm_min == i) ) {
-                       wc_printf("<OPTION %s VALUE=\"%d\">:%02d</OPTION>\n",
-                               ((tm.tm_min == i) ? "SELECTED" : ""),
-                               i, i
-                               );
+       for (i = 0; i <= 59; ++i) {
+               if ((i % 5 == 0) || (tm.tm_min == i)) {
+                       wc_printf("<OPTION %s VALUE=\"%d\">:%02d</OPTION>\n", ((tm.tm_min == i) ? "SELECTED" : ""), i, i);
                }
        }
        wc_printf("</SELECT></span>\n");
@@ -132,18 +127,19 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix, int d
  * Get date/time from a web form and convert it into an icaltimetype struct.
  */
 void icaltime_from_webform(struct icaltimetype *t, char *prefix) {
-       char vname[32];
+       char vname[32];
 
-       if (!t) return;
+       if (!t)
+               return;
 
-       /* Stuff with zero values */
+       /* Stuff with zero values */
        memset(t, 0, sizeof(struct icaltimetype));
 
        /* Get the year/month/date all in one shot -- it will be in ISO YYYY-MM-DD format */
-       sscanf((char*)BSTR(prefix), "%04d-%02d-%02d", &t->year, &t->month, &t->day);
+       sscanf((char *) BSTR(prefix), "%04d-%02d-%02d", &t->year, &t->month, &t->day);
 
        /* hour */
-       sprintf(vname, "%s_hour", prefix);
+       sprintf(vname, "%s_hour", prefix);
        t->hour = IBSTR(vname);
 
        /* minute */
@@ -160,13 +156,14 @@ void icaltime_from_webform(struct icaltimetype *t, char *prefix) {
  * Get date (no time) from a web form and convert it into an icaltimetype struct.
  */
 void icaltime_from_webform_dateonly(struct icaltimetype *t, char *prefix) {
-       if (!t) return;
+       if (!t)
+               return;
 
-       /* Stuff with zero values */
+       /* Stuff with zero values */
        memset(t, 0, sizeof(struct icaltimetype));
 
        /* Get the year/month/date all in one shot -- it will be in ISO YYYY-MM-DD format */
-       sscanf((char*)BSTR(prefix), "%04d-%02d-%02d", &t->year, &t->month, &t->day);
+       sscanf((char *) BSTR(prefix), "%04d-%02d-%02d", &t->year, &t->month, &t->day);
 
        /* time zone is set to the default zone for this server */
        t->zone = icaltimezone_get_utc_timezone();
@@ -177,22 +174,19 @@ void icaltime_from_webform_dateonly(struct icaltimetype *t, char *prefix) {
 /*
  * Render a PARTSTAT parameter as a string (and put it in parentheses)
  */
-void partstat_as_string(char *buf, icalproperty *attendee) {
+void partstat_as_string(char *buf, icalproperty * attendee) {
        icalparameter *partstat_param;
        icalparameter_partstat partstat;
 
        strcpy(buf, _("(status unknown)"));
 
-       partstat_param = icalproperty_get_first_parameter(
-               attendee,
-               ICAL_PARTSTAT_PARAMETER
-               );
+       partstat_param = icalproperty_get_first_parameter(attendee, ICAL_PARTSTAT_PARAMETER);
        if (partstat_param == NULL) {
                return;
        }
 
        partstat = icalparameter_get_partstat(partstat_param);
-       switch(partstat) {
+       switch (partstat) {
        case ICAL_PARTSTAT_X:
                strcpy(buf, "(x)");
                break;
@@ -231,7 +225,7 @@ void partstat_as_string(char *buf, icalproperty *attendee) {
  *
  * Note: if you change anything here, change it in Citadel server's ical_send_out_invitations() too.
  */
-icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp) {
+icalcomponent *ical_encapsulate_subcomponent(icalcomponent * subcomp) {
        icalcomponent *encaps;
        icalproperty *p;
        struct icaltimetype t;
@@ -256,28 +250,26 @@ icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp) {
 
        /* search for... */
        for (p = icalcomponent_get_first_property(subcomp, ICAL_ANY_PROPERTY);
-            p != NULL;
-            p = icalcomponent_get_next_property(subcomp, ICAL_ANY_PROPERTY))
-       {
-               if ( (icalproperty_isa(p) == ICAL_COMPLETED_PROPERTY)
-                 || (icalproperty_isa(p) == ICAL_CREATED_PROPERTY)
-                 || (icalproperty_isa(p) == ICAL_DATEMAX_PROPERTY)
-                 || (icalproperty_isa(p) == ICAL_DATEMIN_PROPERTY)
-                 || (icalproperty_isa(p) == ICAL_DTEND_PROPERTY)
-                 || (icalproperty_isa(p) == ICAL_DTSTAMP_PROPERTY)
-                 || (icalproperty_isa(p) == ICAL_DTSTART_PROPERTY)
-                 || (icalproperty_isa(p) == ICAL_DUE_PROPERTY)
-                 || (icalproperty_isa(p) == ICAL_EXDATE_PROPERTY)
-                 || (icalproperty_isa(p) == ICAL_LASTMODIFIED_PROPERTY)
-                 || (icalproperty_isa(p) == ICAL_MAXDATE_PROPERTY)
-                 || (icalproperty_isa(p) == ICAL_MINDATE_PROPERTY)
-                 || (icalproperty_isa(p) == ICAL_RECURRENCEID_PROPERTY)
-               ) {
+            p != NULL; p = icalcomponent_get_next_property(subcomp, ICAL_ANY_PROPERTY)) {
+               if ((icalproperty_isa(p) == ICAL_COMPLETED_PROPERTY)
+                   || (icalproperty_isa(p) == ICAL_CREATED_PROPERTY)
+                   || (icalproperty_isa(p) == ICAL_DATEMAX_PROPERTY)
+                   || (icalproperty_isa(p) == ICAL_DATEMIN_PROPERTY)
+                   || (icalproperty_isa(p) == ICAL_DTEND_PROPERTY)
+                   || (icalproperty_isa(p) == ICAL_DTSTAMP_PROPERTY)
+                   || (icalproperty_isa(p) == ICAL_DTSTART_PROPERTY)
+                   || (icalproperty_isa(p) == ICAL_DUE_PROPERTY)
+                   || (icalproperty_isa(p) == ICAL_EXDATE_PROPERTY)
+                   || (icalproperty_isa(p) == ICAL_LASTMODIFIED_PROPERTY)
+                   || (icalproperty_isa(p) == ICAL_MAXDATE_PROPERTY)
+                   || (icalproperty_isa(p) == ICAL_MINDATE_PROPERTY)
+                   || (icalproperty_isa(p) == ICAL_RECURRENCEID_PROPERTY)
+                   ) {
                        t = icalproperty_get_dtstart(p);        /*/ it's safe to use dtstart for all of them */
-                       if ((icaltime_is_valid_time(t)) && (z=icaltime_get_timezone(t), z)) {
-                       
+                       if ((icaltime_is_valid_time(t)) && (z = icaltime_get_timezone(t), z)) {
+
                                zone_already_attached = 0;
-                               for (i=0; i<5; ++i) {
+                               for (i = 0; i < 5; ++i) {
                                        if (z == attached_zones[i]) {
                                                ++zone_already_attached;
                                                syslog(LOG_DEBUG, "zone already attached!!\n");
@@ -288,9 +280,8 @@ icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp) {
                                        attached_zones[num_zones_attached++] = z;
                                }
 
-                               icalproperty_set_parameter(p,
-                                       icalparameter_new_tzid(icaltimezone_get_tzid((icaltimezone *)z))
-                               );
+                               icalproperty_set_parameter(p, icalparameter_new_tzid(icaltimezone_get_tzid((icaltimezone *) z))
+                                   );
                        }
                }
        }
@@ -309,15 +300,16 @@ icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp) {
        icalcomponent_add_property(encaps, icalproperty_new_version("2.0"));
 
        /* Attach any timezones we need */
-       if (num_zones_attached > 0) for (i=0; i<num_zones_attached; ++i) {
-               icalcomponent *zc;
-               zc = icalcomponent_new_clone(icaltimezone_get_component((icaltimezone *)attached_zones[i]));
-               icalcomponent_add_component(encaps, zc);
-       }
+       if (num_zones_attached > 0)
+               for (i = 0; i < num_zones_attached; ++i) {
+                       icalcomponent *zc;
+                       zc = icalcomponent_new_clone(icaltimezone_get_component((icaltimezone *) attached_zones[i]));
+                       icalcomponent_add_component(encaps, zc);
+               }
 
        /* Encapsulate the subcomponent inside */
        icalcomponent_add_component(encaps, subcomp);
 
        /* Return the object we just created. */
-       return(encaps);
+       return (encaps);
 }
index 1b6e8681ebe2f9f3f2deeeb3ef7b5cf666f403c7..b9e95418e992c8276bfc7a4828ef7c516706e948 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Handles the HTML display of calendar items.
  *
@@ -20,8 +21,7 @@
 #define TIMELINE       22
 #define EXTRATIMELINE  22
 
-void embeddable_mini_calendar(int year, int month)
-{
+void embeddable_mini_calendar(int year, int month) {
        struct tm starting_tm;
        struct tm tm;
        time_t thetime;
@@ -35,16 +35,17 @@ void embeddable_mini_calendar(int year, int month)
        char url[256];
        char div_id[256];
 
-       snprintf(div_id, sizeof div_id, "mini_calendar_%d", rand() );
+       snprintf(div_id, sizeof div_id, "mini_calendar_%d", rand());
 
        /* Determine what day to start.  If an impossible value is found, start on Sunday.
-       */
+        */
        get_pref_long("weekstart", &weekstart, 17);
-       if (weekstart > 6) weekstart = 0;
+       if (weekstart > 6)
+               weekstart = 0;
 
        /*
-       * Now back up to the 1st of the month...
-       */
+        * Now back up to the 1st of the month...
+        */
        memset(&starting_tm, 0, sizeof(struct tm));
 
        starting_tm.tm_year = year - 1900;
@@ -54,18 +55,18 @@ void embeddable_mini_calendar(int year, int month)
 
        memcpy(&tm, &starting_tm, sizeof(struct tm));
        while (tm.tm_mday != 1) {
-               thetime = thetime - (time_t)86400;      /* go back 24 hours */
+               thetime = thetime - (time_t) 86400;     /* go back 24 hours */
                localtime_r(&thetime, &tm);
        }
 
        /* Determine previous and next months ... for links */
-       previous_month = thetime - (time_t)864000L;     /* back 10 days */
-       next_month = thetime + (time_t)(31L * 86400L);  /* ahead 31 days */
+       previous_month = thetime - (time_t) 864000L;    /* back 10 days */
+       next_month = thetime + (time_t) (31L * 86400L); /* ahead 31 days */
 
        /* Now back up until we're on the user's preferred start day */
        localtime_r(&thetime, &tm);
        while (tm.tm_wday != weekstart) {
-               thetime = thetime - (time_t)86400;      /* go back 24 hours */
+               thetime = thetime - (time_t) 86400;     /* go back 24 hours */
                localtime_r(&thetime, &tm);
        }
 
@@ -73,26 +74,20 @@ void embeddable_mini_calendar(int year, int month)
 
        /* Previous month link */
        localtime_r(&previous_month, &tm);
-       wc_printf("<a href=\"javascript:minical_change_month(%d,%d);\">&laquo;</a>", 
-               (int)(tm.tm_year)+1900, tm.tm_mon + 1);
+       wc_printf("<a href=\"javascript:minical_change_month(%d,%d);\">&laquo;</a>", (int) (tm.tm_year) + 1900, tm.tm_mon + 1);
 
        wc_strftime(colheader_label, sizeof colheader_label, "%B", &starting_tm);
        wc_printf("&nbsp;&nbsp;"
-               "<span class=\"mini_calendar_month_label\">"
-               "%s %d"
-               "</span>"
-               "&nbsp;&nbsp;", colheader_label, year);
+                 "<span class=\"mini_calendar_month_label\">" "%s %d" "</span>" "&nbsp;&nbsp;", colheader_label, year);
 
        /* Next month link */
        localtime_r(&next_month, &tm);
-       wc_printf("<a href=\"javascript:minical_change_month(%d,%d);\">&raquo;</a>",
-               (int)(tm.tm_year)+1900, tm.tm_mon + 1);
+       wc_printf("<a href=\"javascript:minical_change_month(%d,%d);\">&raquo;</a>", (int) (tm.tm_year) + 1900, tm.tm_mon + 1);
 
-       wc_printf("<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" class=\"mini_calendar_days\">"
-               "<tr>");
+       wc_printf("<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" class=\"mini_calendar_days\">" "<tr>");
        colheader_time = thetime;
-       for (i=0; i<7; ++i) {
-               colheader_time = thetime + (i * 86400) ;
+       for (i = 0; i < 7; ++i) {
+               colheader_time = thetime + (i * 86400);
                localtime_r(&colheader_time, &colheader_tm);
                wc_strftime(colheader_label, sizeof colheader_label, "%A", &colheader_tm);
                wc_printf("<th>%c</th>", colheader_label[0]);
@@ -101,20 +96,20 @@ void embeddable_mini_calendar(int year, int month)
        wc_printf("</tr>\n");
 
 
-        /* Now do 35 or 42 days */
-        for (i = 0; i < 42; ++i) {
-                localtime_r(&thetime, &tm);
+       /* Now do 35 or 42 days */
+       for (i = 0; i < 42; ++i) {
+               localtime_r(&thetime, &tm);
 
-                if (i < 35) {
+               if (i < 35) {
 
                        /* Before displaying Sunday, start a new row */
                        if ((i % 7) == 0) {
                                wc_printf("<tr>");
                        }
 
-                       if (tm.tm_mon == month-1) {
+                       if (tm.tm_mon == month - 1) {
                                snprintf(url, sizeof url, "readfwd?calview=day?year=%d?month=%d?day=%d",
-                                       tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday);
+                                        tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
                                wc_printf("<td><a href=\"%s\">%d</a></td>", url, tm.tm_mday);
                        }
                        else {
@@ -128,39 +123,34 @@ void embeddable_mini_calendar(int year, int month)
 
                }
 
-               thetime += (time_t)86400;               /* ahead 24 hours */
+               thetime += (time_t) 86400;      /* ahead 24 hours */
        }
 
-       wc_printf("</table>"                    /* end of inner table */
-               "</div>\n");
+       wc_printf("</table>"    /* end of inner table */
+                 "</div>\n");
 
        StrBufAppendPrintf(WC->trailing_javascript,
-               "       function minical_change_month(year, month) {                                    \n"
-               "               p = 'year=' + year + '&month=' + month                                  \n"
-               "                       + '&r=' + ctdlRandomString();                                   \n"
-               "               new Ajax.Updater('%s', 'mini_calendar',                                 \n"
-               "                       { method: 'get', parameters: p, evalScripts: true } );          \n"
-               "       }                                                                               \n"
-               "",
-               div_id
-       );
+                          "    function minical_change_month(year, month) {                                    \n"
+                          "            p = 'year=' + year + '&month=' + month                                  \n"
+                          "                    + '&r=' + ctdlRandomString();                                   \n"
+                          "            new Ajax.Updater('%s', 'mini_calendar',                                 \n"
+                          "                    { method: 'get', parameters: p, evalScripts: true } );          \n"
+                          "    }                                                                               \n" "", div_id);
 
 }
 
 /*
  * ajax embedder for the above mini calendar 
  */
-void ajax_mini_calendar(void) 
-{
-       embeddable_mini_calendar( ibstr("year"), ibstr("month"));
+void ajax_mini_calendar(void) {
+       embeddable_mini_calendar(ibstr("year"), ibstr("month"));
 }
 
 
 /*
  * Display one day of a whole month view of a calendar
  */
-void calendar_month_view_display_events(int year, int month, int day)
-{
+void calendar_month_view_display_events(int year, int month, int day) {
        long hklen;
        const char *HashKey;
        void *vCal;
@@ -220,7 +210,7 @@ void calendar_month_view_display_events(int year, int month, int day)
         */
        Pos = GetNewHashPos(WCC->disp_cal_items, 0);
        while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
-               Cal = (disp_cal*)vCal;
+               Cal = (disp_cal *) vCal;
                all_day_event = 0;
                q = icalcomponent_get_first_property(Cal->cal, ICAL_DTSTART_PROPERTY);
                if (q != NULL) {
@@ -236,28 +226,27 @@ void calendar_month_view_display_events(int year, int month, int day)
                else {
                        memset(&end_t, 0, sizeof end_t);
                }
-               if (t.is_date) all_day_event = 1;
+               if (t.is_date)
+                       all_day_event = 1;
 
-               if (all_day_event)
-               {
+               if (all_day_event) {
                        show_event = ical_ctdl_is_overlap(t, end_t, today_t, icaltime_null_time());
                }
-               else
-               {
+               else {
                        show_event = ical_ctdl_is_overlap(t, end_t, today_start_t, today_end_t);
                }
 
                /*
                 * If we determined that this event occurs today, then display it.
-                */
+                */
                if (show_event) {
 
                        /* time_t logtt = icaltime_as_timet(t);
-                       syslog(LOG_DEBUG, "Match on %04d-%02d-%02d for event %x%s on %s",
-                               year, month, day,
-                               (int)Cal, ((all_day_event) ? " (all day)" : ""),
-                               ctime(&logtt)
-                       ); */
+                          syslog(LOG_DEBUG, "Match on %04d-%02d-%02d for event %x%s on %s",
+                          year, month, day,
+                          (int)Cal, ((all_day_event) ? " (all day)" : ""),
+                          ctime(&logtt)
+                          ); */
 
                        p = icalcomponent_get_first_property(Cal->cal, ICAL_SUMMARY_PROPERTY);
                        if (p == NULL) {
@@ -267,36 +256,28 @@ void calendar_month_view_display_events(int year, int month, int day)
                        if (p != NULL) {
 
                                if (all_day_event) {
-                                       wc_printf("<table border=\"0\" cellpadding=\"2\"><TR>"
-                                               "<td bgcolor=\"#CCCCDD\">"
-                                               );
+                                       wc_printf("<table border=\"0\" cellpadding=\"2\"><TR>" "<td bgcolor=\"#CCCCDD\">");
                                }
 
 
                                wc_printf("<font size=\"-1\">"
-                                       "<a class=\"event%s\" href=\"display_edit_event?"
-                                       "msgnum=%ld?calview=month?year=%d?month=%d?day=%d\">"
-                                       ,
-                                       (Cal->unread)?"_unread":"_read",
-                                       Cal->cal_msgnum,
-                                       year, month, day
-                               );
+                                         "<a class=\"event%s\" href=\"display_edit_event?"
+                                         "msgnum=%ld?calview=month?year=%d?month=%d?day=%d\">",
+                                         (Cal->unread) ? "_unread" : "_read", Cal->cal_msgnum, year, month, day);
 
                                escputs((char *) icalproperty_get_comment(p));
 
                                wc_printf("<span class=\"tooltip\"><span class=\"btttop\"></span><span class=\"bttmiddle\">");
 
                                wc_printf("<i>%s: %s</i><br>", _("From"), Cal->from);
-                               wc_printf("<i>%s</i> ",          _("Summary:"));
-                               escputs((char *)icalproperty_get_comment(p));
+                               wc_printf("<i>%s</i> ", _("Summary:"));
+                               escputs((char *) icalproperty_get_comment(p));
                                wc_printf("<br>");
 
-                               q = icalcomponent_get_first_property(
-                                       Cal->cal,
-                                       ICAL_LOCATION_PROPERTY);
+                               q = icalcomponent_get_first_property(Cal->cal, ICAL_LOCATION_PROPERTY);
                                if (q) {
                                        wc_printf("<i>%s</i> ", _("Location:"));
-                                       escputs((char *)icalproperty_get_comment(q));
+                                       escputs((char *) icalproperty_get_comment(q));
                                        wc_printf("<br>");
                                }
 
@@ -339,30 +320,25 @@ void calendar_month_view_display_events(int year, int month, int day)
                                                        wc_strftime(buf, sizeof buf, "%x", &d_tm);
 
                                                        if (no_end || !icaltime_compare(t, end_t)) {
-                                                               wc_printf("<i>%s</i> %s<br>",
-                                                                       _("Date:"), buf);
+                                                               wc_printf("<i>%s</i> %s<br>", _("Date:"), buf);
                                                        }
                                                        else {
-                                                               wc_printf("<i>%s</i> %s<br>",
-                                                                       _("Starting date:"), buf);
+                                                               wc_printf("<i>%s</i> %s<br>", _("Starting date:"), buf);
                                                                d_tm.tm_year = end_t.year - 1900;
                                                                d_tm.tm_mon = end_t.month - 1;
                                                                d_tm.tm_mday = end_t.day;
                                                                wc_strftime(buf, sizeof buf, "%x", &d_tm);
-                                                               wc_printf("<i>%s</i> %s<br>",
-                                                                       _("Ending date:"), buf);
+                                                               wc_printf("<i>%s</i> %s<br>", _("Ending date:"), buf);
                                                        }
                                                }
                                                else {
                                                        tt = icaltime_as_timet(t);
                                                        webcit_fmt_date(buf, 256, tt, DATEFMT_BRIEF);
                                                        if (no_end || !icaltime_compare(t, end_t)) {
-                                                               wc_printf("<i>%s</i> %s<br>",
-                                                                       _("Date/time:"), buf);
+                                                               wc_printf("<i>%s</i> %s<br>", _("Date/time:"), buf);
                                                        }
                                                        else {
-                                                               wc_printf("<i>%s</i> %s<br>",
-                                                                       _("Starting date/time:"), buf);
+                                                               wc_printf("<i>%s</i> %s<br>", _("Starting date/time:"), buf);
                                                                tt = icaltime_as_timet(end_t);
                                                                webcit_fmt_date(buf, 256, tt, DATEFMT_BRIEF);
                                                                wc_printf("<i>%s</i> %s<br>", _("Ending date/time:"), buf);
@@ -376,7 +352,7 @@ void calendar_month_view_display_events(int year, int month, int day)
                                q = icalcomponent_get_first_property(Cal->cal, ICAL_DESCRIPTION_PROPERTY);
                                if (q) {
                                        wc_printf("<i>%s</i> ", _("Notes:"));
-                                       escputs((char *)icalproperty_get_comment(q));
+                                       escputs((char *) icalproperty_get_comment(q));
                                        wc_printf("<br>");
                                }
 
@@ -420,23 +396,27 @@ void calendar_month_view_brief_events(time_t thetime, const char *daycolor) {
        char *timeformat;
        int time_format;
 
-       time_format = get_time_format_cached ();
+       time_format = get_time_format_cached();
 
-       if (time_format == WC_TIMEFORMAT_24) timeformat="%k:%M";
-       else timeformat="%I:%M %p";
+       if (time_format == WC_TIMEFORMAT_24)
+               timeformat = "%k:%M";
+       else
+               timeformat = "%I:%M %p";
 
        localtime_r(&thetime, &today_tm);
 
        Pos = GetNewHashPos(WCC->disp_cal_items, 0);
        while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
-               Cal = (disp_cal*)vCal;
+               Cal = (disp_cal *) vCal;
                p = icalcomponent_get_first_property(Cal->cal, ICAL_DTSTART_PROPERTY);
                if (p != NULL) {
                        t = icalproperty_get_dtstart(p);
                        event_tt = icaltime_as_timet(t);
-                       event_tts=event_tt;
-                       if (t.is_date) all_day_event = 1;
-                       else all_day_event = 0;
+                       event_tts = event_tt;
+                       if (t.is_date)
+                               all_day_event = 1;
+                       else
+                               all_day_event = 0;
 
                        if (all_day_event) {
                                gmtime_r(&event_tts, &event_tms);
@@ -446,57 +426,46 @@ void calendar_month_view_brief_events(time_t thetime, const char *daycolor) {
                        }
                        /* \todo epoch &! daymask */
                        if ((event_tms.tm_year == today_tm.tm_year)
-                               && (event_tms.tm_mon == today_tm.tm_mon)
-                       && (event_tms.tm_mday == today_tm.tm_mday)) {
+                           && (event_tms.tm_mon == today_tm.tm_mon)
+                           && (event_tms.tm_mday == today_tm.tm_mday)) {
 
 
-                       char sbuf[255];
-                       char ebuf[255];
+                               char sbuf[255];
+                               char ebuf[255];
 
-                       p = icalcomponent_get_first_property(
-                               Cal->cal,
-                               ICAL_SUMMARY_PROPERTY);
-                       if (p == NULL) {
-                               p = icalproperty_new_summary(_("Untitled Event"));
-                               icalcomponent_add_property(Cal->cal, p);
-                       }
-                       e = icalcomponent_get_first_property(
-                               Cal->cal, 
-                               ICAL_DTEND_PROPERTY);
-                       if ((p != NULL) && (e != NULL)) {
-                               time_t difftime;
-                               int hours, minutes;
-                               t = icalproperty_get_dtend(e);
-                               event_tte = icaltime_as_timet(t);
-                               localtime_r(&event_tte, &event_tme);
-                               difftime=(event_tte-event_tts)/60;
-                               hours=(int)(difftime / 60);
-                               minutes=difftime % 60;
-                               wc_printf("<tr><td bgcolor='%s'>%i:%2i</td><td bgcolor='%s'>"
-                                       "<font size=\"-1\">"
-                                       "<a class=\"event%s\" href=\"display_edit_event?msgnum=%ld?calview=calbrief?year=%s?month=%s?day=%s\">",
-                                       daycolor,
-                                       hours, minutes,
-                                       (Cal->unread)?"_unread":"_read",
-                                       daycolor,
-                                       Cal->cal_msgnum,
-                                       bstr("year"),
-                                       bstr("month"),
-                                       bstr("day")
-                                       );
-
-                               escputs((char *)
-                                       icalproperty_get_comment(p));
-                               /* \todo: allso ammitime format */
-                               wc_strftime(&sbuf[0], sizeof(sbuf), timeformat, &event_tms);
-                               wc_strftime(&ebuf[0], sizeof(sbuf), timeformat, &event_tme);
-
-                               wc_printf("</a></font></td>"
-                                       "<td bgcolor='%s'>%s</td><td bgcolor='%s'>%s</td></tr>",
-                                       daycolor,
-                                       sbuf,
-                                       daycolor,
-                                       ebuf);
+                               p = icalcomponent_get_first_property(Cal->cal, ICAL_SUMMARY_PROPERTY);
+                               if (p == NULL) {
+                                       p = icalproperty_new_summary(_("Untitled Event"));
+                                       icalcomponent_add_property(Cal->cal, p);
+                               }
+                               e = icalcomponent_get_first_property(Cal->cal, ICAL_DTEND_PROPERTY);
+                               if ((p != NULL) && (e != NULL)) {
+                                       time_t difftime;
+                                       int hours, minutes;
+                                       t = icalproperty_get_dtend(e);
+                                       event_tte = icaltime_as_timet(t);
+                                       localtime_r(&event_tte, &event_tme);
+                                       difftime = (event_tte - event_tts) / 60;
+                                       hours = (int) (difftime / 60);
+                                       minutes = difftime % 60;
+                                       wc_printf("<tr><td bgcolor='%s'>%i:%2i</td><td bgcolor='%s'>"
+                                                 "<font size=\"-1\">"
+                                                 "<a class=\"event%s\" href=\"display_edit_event?msgnum=%ld?calview=calbrief?year=%s?month=%s?day=%s\">",
+                                                 daycolor,
+                                                 hours, minutes,
+                                                 (Cal->unread) ? "_unread" : "_read",
+                                                 daycolor, Cal->cal_msgnum, bstr("year"), bstr("month"), bstr("day")
+                                           );
+
+                                       escputs((char *)
+                                               icalproperty_get_comment(p));
+                                       /* \todo: allso ammitime format */
+                                       wc_strftime(&sbuf[0], sizeof(sbuf), timeformat, &event_tms);
+                                       wc_strftime(&ebuf[0], sizeof(sbuf), timeformat, &event_tme);
+
+                                       wc_printf("</a></font></td>"
+                                                 "<td bgcolor='%s'>%s</td><td bgcolor='%s'>%s</td></tr>",
+                                                 daycolor, sbuf, daycolor, ebuf);
                                }
 
                        }
@@ -535,7 +504,8 @@ void calendar_month_view(int year, int month, int day) {
         * Determine what day to start.  If an impossible value is found, start on Sunday.
         */
        get_pref_long("weekstart", &weekstart, 17);
-       if (weekstart > 6) weekstart = 0;
+       if (weekstart > 6)
+               weekstart = 0;
 
        /*
         * Now back up to the 1st of the month...
@@ -549,97 +519,84 @@ void calendar_month_view(int year, int month, int day) {
 
        memcpy(&tm, &starting_tm, sizeof(struct tm));
        while (tm.tm_mday != 1) {
-               thetime = thetime - (time_t)86400;      /* go back 24 hours */
+               thetime = thetime - (time_t) 86400;     /* go back 24 hours */
                localtime_r(&thetime, &tm);
        }
 
        /* Determine previous and next months ... for links */
-       previous_month = thetime - (time_t)864000L;     /* back 10 days */
-       next_month = thetime + (time_t)(31L * 86400L);  /* ahead 31 days */
+       previous_month = thetime - (time_t) 864000L;    /* back 10 days */
+       next_month = thetime + (time_t) (31L * 86400L); /* ahead 31 days */
 
        /* Now back up until we're on the user's preferred start day */
        localtime_r(&thetime, &tm);
        while (tm.tm_wday != weekstart) {
-               thetime = thetime - (time_t)86400;      /* go back 24 hours */
+               thetime = thetime - (time_t) 86400;     /* go back 24 hours */
                localtime_r(&thetime, &tm);
        }
 
        /* Outer table (to get the background color) */
-       wc_printf("<table class=\"calendar\"> \n <tr><td>"); 
+       wc_printf("<table class=\"calendar\"> \n <tr><td>");
 
        wc_printf("<table width=\"100%%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>\n");
 
        wc_printf("<td align=\"center\">");
 
        localtime_r(&previous_month, &tm);
-       wc_printf("<a href=\"readfwd?calview=month?year=%d?month=%d?day=1\">",
-               (int)(tm.tm_year)+1900, tm.tm_mon + 1);
-       wc_printf("<img alt=\"%s\" align=\"middle\" src=\"static/webcit_icons/essen/32x32/back.png\" border=\"0\"></a>\n", _("previous"));
+       wc_printf("<a href=\"readfwd?calview=month?year=%d?month=%d?day=1\">", (int) (tm.tm_year) + 1900, tm.tm_mon + 1);
+       wc_printf("<img alt=\"%s\" align=\"middle\" src=\"static/webcit_icons/essen/32x32/back.png\" border=\"0\"></a>\n",
+                 _("previous"));
 
        wc_strftime(colheader_label, sizeof colheader_label, "%B", &starting_tm);
-       wc_printf("&nbsp;&nbsp;"
-               "<font size=\"+1\" color=\"#FFFFFF\">"
-               "%s %d"
-               "</font>"
-               "&nbsp;&nbsp;", colheader_label, year);
+       wc_printf("&nbsp;&nbsp;" "<font size=\"+1\" color=\"#FFFFFF\">" "%s %d" "</font>" "&nbsp;&nbsp;", colheader_label, year);
 
        localtime_r(&next_month, &tm);
-       wc_printf("<a href=\"readfwd?calview=month?year=%d?month=%d?day=1\">",
-               (int)(tm.tm_year)+1900, tm.tm_mon + 1);
-       wc_printf("<img alt=\"%s\" align=\"middle\" src=\"static/webcit_icons/essen/32x32/forward.png\" border=\"0\"></A>\n", _("next"));
+       wc_printf("<a href=\"readfwd?calview=month?year=%d?month=%d?day=1\">", (int) (tm.tm_year) + 1900, tm.tm_mon + 1);
+       wc_printf("<img alt=\"%s\" align=\"middle\" src=\"static/webcit_icons/essen/32x32/forward.png\" border=\"0\"></A>\n",
+                 _("next"));
 
        wc_printf("</td></tr></table>\n");
 
        /* Inner table (the real one) */
        wc_printf("<table width=\"100%%\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" "
-               "bgcolor='#204B78' id=\"inner_month\"><tr>");
+                 "bgcolor='#204B78' id=\"inner_month\"><tr>");
        wc_printf("<th align=\"center\" width=\"2%%\"></th>");
        colheader_time = thetime;
-       for (i=0; i<7; ++i) {
-               colheader_time = thetime + (i * 86400) ;
+       for (i = 0; i < 7; ++i) {
+               colheader_time = thetime + (i * 86400);
                localtime_r(&colheader_time, &colheader_tm);
                wc_strftime(colheader_label, sizeof colheader_label, "%A", &colheader_tm);
-               wc_printf("<th align=\"center\" width=\"14%%\">"
-                       "<font color=\"#FFFFFF\">%s</font></th>", colheader_label);
+               wc_printf("<th align=\"center\" width=\"14%%\">" "<font color=\"#FFFFFF\">%s</font></th>", colheader_label);
 
        }
        wc_printf("</tr>\n");
 
 
-        /* Now do 35 or 42 days */
+       /* Now do 35 or 42 days */
        localtime_r(&thetime, &tm);
-        for (i = 0; i<42; ++i) {
+       for (i = 0; i < 42; ++i) {
 
                /* Before displaying the first day of the week, start a new row */
                if ((i % 7) == 0) {
                        wc_printf("<tr><td class=\"week_of_year\">");
                        wc_strftime(colheader_label, sizeof colheader_label, "%V", &tm);
-                        wc_printf("%s ", colheader_label);
+                       wc_printf("%s ", colheader_label);
                }
 
                wc_printf("<td class=\"cal%s\"><div class=\"day\">",
-                       ((tm.tm_mon != month-1) ? "out" :
-                               (((tm.tm_year == today_tm.tm_year) && (tm.tm_mon == today_tm.tm_mon) && (tm.tm_mday == today_tm.tm_mday)) ? "today" :
-                               ((tm.tm_wday==0 || tm.tm_wday==6) ? "weekend" :
-                                       "day")))
-                       );
-               if ((i==0) || (tm.tm_mday == 1)) {
+                         ((tm.tm_mon != month - 1) ? "out" :
+                          (((tm.tm_year == today_tm.tm_year) && (tm.tm_mon == today_tm.tm_mon)
+                            && (tm.tm_mday == today_tm.tm_mday)) ? "today" : ((tm.tm_wday == 0
+                                                                               || tm.tm_wday == 6) ? "weekend" : "day")))
+                   );
+               if ((i == 0) || (tm.tm_mday == 1)) {
                        wc_strftime(colheader_label, sizeof colheader_label, "%B", &tm);
                        wc_printf("%s ", colheader_label);
                }
                wc_printf("<a href=\"readfwd?calview=day?year=%d?month=%d?day=%d\">"
-                       "%d</a></div>",
-                       tm.tm_year + 1900,
-                       tm.tm_mon + 1,
-                       tm.tm_mday,
-                       tm.tm_mday);
+                         "%d</a></div>", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_mday);
 
                /* put the data here, stupid */
-               calendar_month_view_display_events(
-                       tm.tm_year + 1900,
-                       tm.tm_mon + 1,
-                       tm.tm_mday
-                       );
+               calendar_month_view_display_events(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
 
                wc_printf("</td>");
 
@@ -648,17 +605,17 @@ void calendar_month_view(int year, int month, int day) {
                        wc_printf("</tr>\n");
                }
 
-               thetime += (time_t)86400;               /* ahead 24 hours */
+               thetime += (time_t) 86400;      /* ahead 24 hours */
                localtime_r(&thetime, &tm);
 
-               if ( ((i % 7) == 6) && (tm.tm_mon != month-1) && (tm.tm_mday < 15) ) {
+               if (((i % 7) == 6) && (tm.tm_mon != month - 1) && (tm.tm_mday < 15)) {
                        i = 100;        /* break out of the loop */
                }
        }
 
-       wc_printf("</table>"                    /* end of inner table */
-               "</td></tr></table>\n"          /* end of outer table */
-       );
+       wc_printf("</table>"    /* end of inner table */
+                 "</td></tr></table>\n"        /* end of outer table */
+           );
 }
 
 /*
@@ -684,51 +641,45 @@ void calendar_brief_month_view(int year, int month, int day) {
 
        memcpy(&tm, &starting_tm, sizeof(struct tm));
        while (tm.tm_mday != 1) {
-               thetime = thetime - (time_t)86400;      /* go back 24 hours */
+               thetime = thetime - (time_t) 86400;     /* go back 24 hours */
                localtime_r(&thetime, &tm);
        }
 
        /* Determine previous and next months ... for links */
-       previous_month = thetime - (time_t)864000L;     /* back 10 days */
-       next_month = thetime + (time_t)(31L * 86400L);  /* ahead 31 days */
+       previous_month = thetime - (time_t) 864000L;    /* back 10 days */
+       next_month = thetime + (time_t) (31L * 86400L); /* ahead 31 days */
 
        /* Now back up until we're on a Sunday */
        localtime_r(&thetime, &tm);
        while (tm.tm_wday != 0) {
-               thetime = thetime - (time_t)86400;      /* go back 24 hours */
+               thetime = thetime - (time_t) 86400;     /* go back 24 hours */
                localtime_r(&thetime, &tm);
        }
 
        /* Outer table (to get the background color) */
-       wc_printf("<table width=\"100%%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" "
-               "bgcolor=#204B78><tr><td>\n");
+       wc_printf("<table width=\"100%%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" " "bgcolor=#204B78><tr><td>\n");
 
        wc_printf("<table width=\"100%%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>\n");
 
        wc_printf("<td align=\"center\">");
 
        localtime_r(&previous_month, &tm);
-       wc_printf("<a href=\"readfwd?calview=month?year=%d?month=%d?day=1\">",
-               (int)(tm.tm_year)+1900, tm.tm_mon + 1);
-       wc_printf("<img alt=\"%s\" align=\"middle\" src=\"static/webcit_icons/essen/32x32/back.png\" border=\"0\"></a>\n", _("previous"));
+       wc_printf("<a href=\"readfwd?calview=month?year=%d?month=%d?day=1\">", (int) (tm.tm_year) + 1900, tm.tm_mon + 1);
+       wc_printf("<img alt=\"%s\" align=\"middle\" src=\"static/webcit_icons/essen/32x32/back.png\" border=\"0\"></a>\n",
+                 _("previous"));
 
        wc_strftime(month_label, sizeof month_label, "%B", &tm);
-       wc_printf("&nbsp;&nbsp;"
-               "<font size=\"+1\" color=\"#FFFFFF\">"
-               "%s %d"
-               "</font>"
-               "&nbsp;&nbsp;", month_label, year);
+       wc_printf("&nbsp;&nbsp;" "<font size=\"+1\" color=\"#FFFFFF\">" "%s %d" "</font>" "&nbsp;&nbsp;", month_label, year);
 
        localtime_r(&next_month, &tm);
-       wc_printf("<a href=\"readfwd?calview=month?year=%d?month=%d?day=1\">",
-               (int)(tm.tm_year)+1900, tm.tm_mon + 1);
-       wc_printf("<img alt=\"%s\" align=\"middle\" src=\"static/webcit_icons/essen/32x32/forward.png\" border=\"0\"></a>\n", _("next"));
+       wc_printf("<a href=\"readfwd?calview=month?year=%d?month=%d?day=1\">", (int) (tm.tm_year) + 1900, tm.tm_mon + 1);
+       wc_printf("<img alt=\"%s\" align=\"middle\" src=\"static/webcit_icons/essen/32x32/forward.png\" border=\"0\"></a>\n",
+                 _("next"));
 
        wc_printf("</td></tr></table>\n");
 
        /* Inner table (the real one) */
-       wc_printf("<table width=\"100%%\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" "
-               "bgcolor=#EEEECC><TR>");
+       wc_printf("<table width=\"100%%\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" " "bgcolor=#EEEECC><TR>");
        wc_printf("</tr>\n");
        wc_printf("<tr><td colspan=\"100%%\">\n");
 
@@ -744,27 +695,17 @@ void calendar_brief_month_view(int year, int month, int day) {
                if ((i % 7) == 0) {
                        wc_strftime(&weeknumber[0], sizeof(weeknumber), "%U", &tm);
                        wc_printf("<table border='0' bgcolor=\"#EEEECC\" width='100%%'> <tr><th colspan='4'>%s %s</th></tr>"
-                               "   <tr><td>%s</td><td width='70%%'>%s</td><td>%s</td><td>%s</td></tr>\n",
-                               _("Week"),
-                               weeknumber,
-                               _("Hours"),
-                               _("Subject"),
-                               _("Start"),
-                               _("End")
-                               );
+                                 "   <tr><td>%s</td><td width='70%%'>%s</td><td>%s</td><td>%s</td></tr>\n",
+                                 _("Week"), weeknumber, _("Hours"), _("Subject"), _("Start"), _("End")
+                           );
                }
 
-               daycolor=((tm.tm_mon != month-1) ? "DDDDDD" :
-                       ((tm.tm_wday==0 || tm.tm_wday==6) ? "EEEECC" :
-                               "FFFFFF"));
+               daycolor = ((tm.tm_mon != month - 1) ? "DDDDDD" : ((tm.tm_wday == 0 || tm.tm_wday == 6) ? "EEEECC" : "FFFFFF"));
 
                /* Day Header */
                wc_strftime(weekday_name, sizeof weekday_name, "%A", &tm);
                wc_printf("<tr><td bgcolor='%s' colspan='1' align='left'> %s,%i."
-                       "</td><td bgcolor='%s' colspan='3'><hr></td></tr>\n",
-                       daycolor,
-                       weekday_name,tm.tm_mday,
-                       daycolor);
+                         "</td><td bgcolor='%s' colspan='3'><hr></td></tr>\n", daycolor, weekday_name, tm.tm_mday, daycolor);
 
                /* put the data of one day  here, stupid */
                calendar_month_view_brief_events(thetime, daycolor);
@@ -775,12 +716,12 @@ void calendar_brief_month_view(int year, int month, int day) {
                        wc_printf("</td></tr></table>\n");
                }
 
-               thetime += (time_t)86400;               /* ahead 24 hours */
+               thetime += (time_t) 86400;      /* ahead 24 hours */
        }
 
-       wc_printf("</table>"                    /* end of inner table */
-               "</td></tr></table>\n"          /* end of outer table */
-       );
+       wc_printf("</table>"    /* end of inner table */
+                 "</td></tr></table>\n"        /* end of outer table */
+           );
 }
 
 /*
@@ -798,14 +739,7 @@ void calendar_week_view(int year, int month, int day) {
  *
  * dstart and dend indicate which hours our "daytime" begins and end
  */
-void calendar_day_view_display_events(time_t thetime,
-       int year,
-       int month,
-       int day,
-       int notime_events,
-       int dstart,
-       int dend)
-{
+void calendar_day_view_display_events(time_t thetime, int year, int month, int day, int notime_events, int dstart, int dend) {
        long hklen;
        const char *HashKey;
        void *vCal;
@@ -835,7 +769,7 @@ void calendar_day_view_display_events(time_t thetime,
        int diffmin = 0;
        int endmin = 0;
 
-        char buf[256];
+       char buf[256];
 
        if (GetCount(WCC->disp_cal_items) == 0) {
                /* nothing to display */
@@ -873,10 +807,10 @@ void calendar_day_view_display_events(time_t thetime,
         */
        Pos = GetNewHashPos(WCC->disp_cal_items, 0);
        while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
-               Cal = (disp_cal*)vCal;
+               Cal = (disp_cal *) vCal;
 
                all_day_event = 0;
-               ongoing_event=0;
+               ongoing_event = 0;
 
                q = icalcomponent_get_first_property(Cal->cal, ICAL_DTSTART_PROPERTY);
                if (q != NULL) {
@@ -888,7 +822,8 @@ void calendar_day_view_display_events(time_t thetime,
                        memset(&t, 0, sizeof t);
                }
 
-               if (t.is_date) all_day_event = 1;
+               if (t.is_date)
+                       all_day_event = 1;
 
                q = icalcomponent_get_first_property(Cal->cal, ICAL_DTEND_PROPERTY);
                if (q != NULL) {
@@ -899,8 +834,7 @@ void calendar_day_view_display_events(time_t thetime,
                        memcpy(&end_t, &t, sizeof(struct icaltimetype));
                }
 
-               if (all_day_event)
-               {
+               if (all_day_event) {
                        show_event = ical_ctdl_is_overlap(t, end_t, today_t, icaltime_null_time());
                        if (icaltime_compare(t, end_t)) {
                                /*
@@ -912,8 +846,7 @@ void calendar_day_view_display_events(time_t thetime,
                                icaltime_adjust(&end_t, -1, 0, 0, 0);
                        }
                }
-               else
-               {
+               else {
                        show_event = ical_ctdl_is_overlap(t, end_t, today_start_t, today_end_t);
                }
 
@@ -921,8 +854,8 @@ void calendar_day_view_display_events(time_t thetime,
                localtime_r(&event_tte, &event_tm);
 
                /* If we determined that this event occurs today, then display it.
-                */
-               p = icalcomponent_get_first_property(Cal->cal,ICAL_SUMMARY_PROPERTY);
+                */
+               p = icalcomponent_get_first_property(Cal->cal, ICAL_SUMMARY_PROPERTY);
                if (p == NULL) {
                        p = icalproperty_new_summary(_("Untitled Event"));
                        icalcomponent_add_property(Cal->cal, p);
@@ -930,32 +863,29 @@ void calendar_day_view_display_events(time_t thetime,
 
                if ((show_event) && (p != NULL)) {
 
-                       if ((event_te.tm_mday != day) || (event_tm.tm_mday != day)) ongoing_event = 1; 
+                       if ((event_te.tm_mday != day) || (event_tm.tm_mday != day))
+                               ongoing_event = 1;
 
-                       if (all_day_event && notime_events)
-                       {
+                       if (all_day_event && notime_events) {
                                wc_printf("<li class=\"event_framed%s\"> "
-                                       "<a href=\"display_edit_event?"
-                                       "msgnum=%ld?calview=day?year=%d?month=%d?day=%d\" "
-                                       " class=\"event_title\">"
-                                       ,
-                                       (Cal->unread)?"_unread":"_read",
-                                        Cal->cal_msgnum, year, month, day
-                               );
-                                escputs((char *) icalproperty_get_comment(p));
+                                         "<a href=\"display_edit_event?"
+                                         "msgnum=%ld?calview=day?year=%d?month=%d?day=%d\" "
+                                         " class=\"event_title\">",
+                                         (Cal->unread) ? "_unread" : "_read", Cal->cal_msgnum, year, month, day);
+                               escputs((char *) icalproperty_get_comment(p));
                                wc_printf("<span class=\"tooltip\"><span class=\"btttop\"></span><span class=\"bttmiddle\">");
-                                wc_printf("<i>%s</i><br>",      _("All day event"));
-                               wc_printf("<i>%s: %s</i><br>",  _("From"), Cal->from);
-                                wc_printf("<i>%s</i> ",           _("Summary:"));
-                                escputs((char *) icalproperty_get_comment(p));
-                                wc_printf("<br>");
-                               q = icalcomponent_get_first_property(Cal->cal,ICAL_LOCATION_PROPERTY);
-                                if (q) {
-                                        wc_printf("<i>%s</i> ", _("Location:"));
-                                        escputs((char *)icalproperty_get_comment(q));
-                                        wc_printf("<br>");
+                               wc_printf("<i>%s</i><br>", _("All day event"));
+                               wc_printf("<i>%s: %s</i><br>", _("From"), Cal->from);
+                               wc_printf("<i>%s</i> ", _("Summary:"));
+                               escputs((char *) icalproperty_get_comment(p));
+                               wc_printf("<br>");
+                               q = icalcomponent_get_first_property(Cal->cal, ICAL_LOCATION_PROPERTY);
+                               if (q) {
+                                       wc_printf("<i>%s</i> ", _("Location:"));
+                                       escputs((char *) icalproperty_get_comment(q));
+                                       wc_printf("<br>");
                                }
-                               if (!icaltime_compare(t, end_t)) { /* one day only */
+                               if (!icaltime_compare(t, end_t)) {      /* one day only */
                                        webcit_fmt_date(buf, 256, event_tt, DATEFMT_LOCALEDATE);
                                        wc_printf("<i>%s</i> %s<br>", _("Date:"), buf);
                                }
@@ -965,61 +895,58 @@ void calendar_day_view_display_events(time_t thetime,
                                        webcit_fmt_date(buf, 256, event_tte, DATEFMT_LOCALEDATE);
                                        wc_printf("<i>%s</i> %s<br>", _("Ending date:"), buf);
                                }
-                               q = icalcomponent_get_first_property(Cal->cal,ICAL_DESCRIPTION_PROPERTY);
-                                if (q) {
-                                        wc_printf("<i>%s</i> ", _("Notes:"));
-                                        escputs((char *)icalproperty_get_comment(q));
-                                        wc_printf("<br>");
-                                }
+                               q = icalcomponent_get_first_property(Cal->cal, ICAL_DESCRIPTION_PROPERTY);
+                               if (q) {
+                                       wc_printf("<i>%s</i> ", _("Notes:"));
+                                       escputs((char *) icalproperty_get_comment(q));
+                                       wc_printf("<br>");
+                               }
                                wc_printf("</span><span class=\"bttbottom\"></span></span>");
-                                wc_printf("</a> <span>(");
-                                wc_printf(_("All day event"));
-                                wc_printf(")</span></li>\n");
+                               wc_printf("</a> <span>(");
+                               wc_printf(_("All day event"));
+                               wc_printf(")</span></li>\n");
                        }
-                       else if (ongoing_event && notime_events) 
-                       {
+                       else if (ongoing_event && notime_events) {
                                wc_printf("<li class=\"event_framed%s\"> "
-                                       "<a href=\"display_edit_event?"
-                                       "msgnum=%ld&calview=day?year=%d?month=%d?day=%d\" "
-                                       " class=\"event_title\">" 
-                                       ,
-                                       (Cal->unread)?"_unread":"_read",
-                                       Cal->cal_msgnum, year, month, day
-                               );
+                                         "<a href=\"display_edit_event?"
+                                         "msgnum=%ld&calview=day?year=%d?month=%d?day=%d\" "
+                                         " class=\"event_title\">",
+                                         (Cal->unread) ? "_unread" : "_read", Cal->cal_msgnum, year, month, day);
                                escputs((char *) icalproperty_get_comment(p));
                                wc_printf("<span class=\"tooltip\"><span class=\"btttop\"></span><span class=\"bttmiddle\">");
-                                wc_printf("<i>%s</i><br>",     _("Ongoing event"));
+                               wc_printf("<i>%s</i><br>", _("Ongoing event"));
                                wc_printf("<i>%s: %s</i><br>", _("From"), Cal->from);
-                                wc_printf("<i>%s</i> ",          _("Summary:"));
-                                escputs((char *) icalproperty_get_comment(p));
-                                wc_printf("<br>");
-                                q = icalcomponent_get_first_property(Cal->cal,ICAL_LOCATION_PROPERTY);
-                                if (q) {
-                                        wc_printf("<i>%s</i> ", _("Location:"));
-                                        escputs((char *)icalproperty_get_comment(q));
-                                        wc_printf("<br>");
-                                                               }
-                                webcit_fmt_date(buf, 256, event_tt, DATEFMT_BRIEF);
-                                wc_printf("<i>%s</i> %s<br>", _("Starting date/time:"), buf);
-                                webcit_fmt_date(buf, 256, event_tte, DATEFMT_BRIEF);
-                                wc_printf("<i>%s</i> %s<br>", _("Ending date/time:"), buf);
-                                q = icalcomponent_get_first_property(Cal->cal,ICAL_DESCRIPTION_PROPERTY);
-                                if (q) {
-                                        wc_printf("<i>%s</i> ", _("Notes:"));
-                                        escputs((char *)icalproperty_get_comment(q));
-                                        wc_printf("<br>");
-                                }
-                                wc_printf("</span><span class=\"bttbottom\"></span></span>");
+                               wc_printf("<i>%s</i> ", _("Summary:"));
+                               escputs((char *) icalproperty_get_comment(p));
+                               wc_printf("<br>");
+                               q = icalcomponent_get_first_property(Cal->cal, ICAL_LOCATION_PROPERTY);
+                               if (q) {
+                                       wc_printf("<i>%s</i> ", _("Location:"));
+                                       escputs((char *) icalproperty_get_comment(q));
+                                       wc_printf("<br>");
+                               }
+                               webcit_fmt_date(buf, 256, event_tt, DATEFMT_BRIEF);
+                               wc_printf("<i>%s</i> %s<br>", _("Starting date/time:"), buf);
+                               webcit_fmt_date(buf, 256, event_tte, DATEFMT_BRIEF);
+                               wc_printf("<i>%s</i> %s<br>", _("Ending date/time:"), buf);
+                               q = icalcomponent_get_first_property(Cal->cal, ICAL_DESCRIPTION_PROPERTY);
+                               if (q) {
+                                       wc_printf("<i>%s</i> ", _("Notes:"));
+                                       escputs((char *) icalproperty_get_comment(q));
+                                       wc_printf("<br>");
+                               }
+                               wc_printf("</span><span class=\"bttbottom\"></span></span>");
                                wc_printf("</a> <span>(");
                                wc_printf(_("Ongoing event"));
                                wc_printf(")</span></li>\n");
                        }
-                       else if (!all_day_event && !notime_events)
-                       {
+                       else if (!all_day_event && !notime_events) {
                                gap++;
 
-                               if (event_te.tm_mday != day) event_te.tm_hour = 0;
-                               if (event_tm.tm_mday != day) event_tm.tm_hour = 24;
+                               if (event_te.tm_mday != day)
+                                       event_te.tm_hour = 0;
+                               if (event_tm.tm_mday != day)
+                                       event_tm.tm_hour = 24;
 
                                /* Calculate the location of the top of the box */
                                if (event_te.tm_hour < dstart) {
@@ -1030,9 +957,11 @@ void calendar_day_view_display_events(time_t thetime,
                                        startmin = diffmin = (event_te.tm_min / 2);
                                        top = (dstart * EXTRATIMELINE) + ((event_te.tm_hour - dstart) * TIMELINE) + startmin;
                                }
-                               else if (event_te.tm_hour >dend) {
+                               else if (event_te.tm_hour > dend) {
                                        startmin = diffmin = event_te.tm_min / 6;
-                                       top = (dstart * EXTRATIMELINE) + ((dend - dstart - 1) * TIMELINE) + ((event_tm.tm_hour - dend + 1) * EXTRATIMELINE) + startmin ;
+                                       top =
+                                           (dstart * EXTRATIMELINE) + ((dend - dstart - 1) * TIMELINE) +
+                                           ((event_tm.tm_hour - dend + 1) * EXTRATIMELINE) + startmin;
                                }
                                else {
                                        /* should never get here */
@@ -1045,42 +974,39 @@ void calendar_day_view_display_events(time_t thetime,
                                }
                                else if ((event_tm.tm_hour >= dstart) && (event_tm.tm_hour <= dend)) {
                                        endmin = diffmin = (event_tm.tm_min / 2);
-                                       bottom = (dstart * EXTRATIMELINE) + ((event_tm.tm_hour - dstart) * TIMELINE) + endmin ;
+                                       bottom = (dstart * EXTRATIMELINE) + ((event_tm.tm_hour - dstart) * TIMELINE) + endmin;
                                }
-                               else if (event_tm.tm_hour >dend) {
+                               else if (event_tm.tm_hour > dend) {
                                        endmin = diffmin = event_tm.tm_min / 6;
-                                       bottom = (dstart * EXTRATIMELINE) + ((dend - dstart + 1) * TIMELINE) + ((event_tm.tm_hour - dend - 1) * EXTRATIMELINE) + endmin;
+                                       bottom =
+                                           (dstart * EXTRATIMELINE) + ((dend - dstart + 1) * TIMELINE) +
+                                           ((event_tm.tm_hour - dend - 1) * EXTRATIMELINE) + endmin;
                                }
                                else {
                                        /* should never get here */
                                }
 
                                wc_printf("<dd  class=\"event_framed%s\" "
-                                       "style=\"position: absolute; "
-                                       "top:%dpx; left:%dpx; "
-                                       "height:%dpx; \" >",
-                                       (Cal->unread)?"_unread":"_read",
-                                       top, (gap * 40), (bottom-top)
-                                       );
+                                         "style=\"position: absolute; "
+                                         "top:%dpx; left:%dpx; "
+                                         "height:%dpx; \" >", (Cal->unread) ? "_unread" : "_read", top, (gap * 40), (bottom - top)
+                                   );
                                wc_printf("<a href=\"display_edit_event?"
-                                       "msgnum=%ld?calview=day?year=%d?month=%d?day=%d?hour=%d\" "
-                                       "class=\"event_title\">"
-                                       ,
-                                       Cal->cal_msgnum, year, month, day, t.hour
-                               );
+                                         "msgnum=%ld?calview=day?year=%d?month=%d?day=%d?hour=%d\" "
+                                         "class=\"event_title\">", Cal->cal_msgnum, year, month, day, t.hour);
                                escputs((char *) icalproperty_get_comment(p));
                                wc_printf("<span class=\"tooltip\"><span class=\"btttop\"></span><span class=\"bttmiddle\">");
                                wc_printf("<i>%s: %s</i><br>", _("From"), Cal->from);
-                                wc_printf("<i>%s</i> ",          _("Summary:"));
-                                escputs((char *) icalproperty_get_comment(p));
-                                wc_printf("<br>");
-                                q = icalcomponent_get_first_property(Cal->cal,ICAL_LOCATION_PROPERTY);
-                                if (q) {
-                                        wc_printf("<i>%s</i> ", _("Location:"));
-                                        escputs((char *)icalproperty_get_comment(q));
-                                        wc_printf("<br>");
-                                                               }
-                               if (!icaltime_compare(t, end_t)) { /* one day only */
+                               wc_printf("<i>%s</i> ", _("Summary:"));
+                               escputs((char *) icalproperty_get_comment(p));
+                               wc_printf("<br>");
+                               q = icalcomponent_get_first_property(Cal->cal, ICAL_LOCATION_PROPERTY);
+                               if (q) {
+                                       wc_printf("<i>%s</i> ", _("Location:"));
+                                       escputs((char *) icalproperty_get_comment(q));
+                                       wc_printf("<br>");
+                               }
+                               if (!icaltime_compare(t, end_t)) {      /* one day only */
                                        webcit_fmt_date(buf, 256, event_tt, DATEFMT_BRIEF);
                                        wc_printf("<i>%s</i> %s<br>", _("Date/time:"), buf);
                                }
@@ -1090,12 +1016,12 @@ void calendar_day_view_display_events(time_t thetime,
                                        webcit_fmt_date(buf, 256, event_tte, DATEFMT_BRIEF);
                                        wc_printf("<i>%s</i> %s<br>", _("Ending date/time:"), buf);
                                }
-                               q = icalcomponent_get_first_property(Cal->cal,ICAL_DESCRIPTION_PROPERTY);
-                                if (q) {
-                                        wc_printf("<i>%s</i> ", _("Notes:"));
-                                        escputs((char *)icalproperty_get_comment(q));
-                                        wc_printf("<br>");
-                                }
+                               q = icalcomponent_get_first_property(Cal->cal, ICAL_DESCRIPTION_PROPERTY);
+                               if (q) {
+                                       wc_printf("<i>%s</i> ", _("Notes:"));
+                                       escputs((char *) icalproperty_get_comment(q));
+                                       wc_printf("<br>");
+                               }
                                wc_printf("</span><span class=\"bttbottom\"></span></span>");
                                wc_printf("</a></dd>\n");
                        }
@@ -1122,7 +1048,7 @@ void calendar_day_view(int year, int month, int day) {
        int hourlabel;
        int extrahourlabel;
 
-       time_format = get_time_format_cached ();
+       time_format = get_time_format_cached();
        get_pref_long("daystart", &daystart, 8);
        get_pref_long("dayend", &dayend, 17);
 
@@ -1137,7 +1063,7 @@ void calendar_day_view(int year, int month, int day) {
        d_tm.tm_year = year - 1900;
        d_tm.tm_mon = month - 1;
        d_tm.tm_mday = day;
-       today_t = mktime(&d_tm); 
+       today_t = mktime(&d_tm);
 
        /* Figure out the dates for "yesterday" and "tomorrow" links */
 
@@ -1160,34 +1086,32 @@ void calendar_day_view(int year, int month, int day) {
 
        /* Innermost cell (contains hours etc.) */
        wc_printf("<td class=\"events_of_the_day\" >");
-               wc_printf("<dl class=\"events\" >");
+       wc_printf("<dl class=\"events\" >");
 
        /* Now the middle of the day... */
 
        extrahourlabel = extratimeline - 2;
        hourlabel = extrahourlabel * 150 / 100;
-       if (hourlabel > (timeline - 2)) hourlabel = timeline - 2;
+       if (hourlabel > (timeline - 2))
+               hourlabel = timeline - 2;
 
        for (hour = 0; hour < daystart; ++hour) {       /* could do HEIGHT=xx */
                wc_printf("<dt class=\"extrahour\">"
-                       "<a href=\"display_edit_event?msgnum=0"
-                       "?calview=day?year=%d?month=%d?day=%d?hour=%d?minute=0\">",
+                         "<a href=\"display_edit_event?msgnum=0" "?calview=day?year=%d?month=%d?day=%d?hour=%d?minute=0\">",
+
 /* TODO: what have these been used for?
                        (hour * extratimeline ),
                        extratimeline,
                        extrahourlabel,
 */
-                       year, month, day, hour
-                       );
+                         year, month, day, hour);
 
                if (time_format == WC_TIMEFORMAT_24) {
                        wc_printf("%2d:00</a> ", hour);
                }
                else {
-                       wc_printf("%d:00%s</a> ",
-                               ((hour == 0) ? 12 : (hour <= 12 ? hour : hour-12)),
-                               (hour < 12 ? "am" : "pm")
-                               );
+                       wc_printf("%d:00%s</a> ", ((hour == 0) ? 12 : (hour <= 12 ? hour : hour - 12)), (hour < 12 ? "am" : "pm")
+                           );
                }
 
                wc_printf("</dt>");
@@ -1195,107 +1119,93 @@ void calendar_day_view(int year, int month, int day) {
 
        gap = daystart * extratimeline;
 
-        for (hour = daystart; hour <= dayend; ++hour) {       /* could do HEIGHT=xx */
-                wc_printf("<dt class=\"hour\">"
-                        "<a href=\"display_edit_event?msgnum=0?calview=day"
-                        "?year=%d?month=%d?day=%d?hour=%d?minute=0\">",
+       for (hour = daystart; hour <= dayend; ++hour) { /* could do HEIGHT=xx */
+               wc_printf("<dt class=\"hour\">"
+                         "<a href=\"display_edit_event?msgnum=0?calview=day" "?year=%d?month=%d?day=%d?hour=%d?minute=0\">",
+
 /*TODO: what have these been used for?
                         gap + ((hour - daystart) * timeline ),
                        timeline,
                        hourlabel,
 */
-                        year, month, day, hour
-                       );
-
-                if (time_format == WC_TIMEFORMAT_24) {
-                        wc_printf("%2d:00</a> ", hour);
-                }
-                else {
-                        wc_printf("%d:00%s</a> ",
-                                (hour <= 12 ? hour : hour-12),
-                                (hour < 12 ? "am" : "pm")
-                                               );
-                }
-
-                wc_printf("</dt>");
-        }
+                         year, month, day, hour);
+
+               if (time_format == WC_TIMEFORMAT_24) {
+                       wc_printf("%2d:00</a> ", hour);
+               }
+               else {
+                       wc_printf("%d:00%s</a> ", (hour <= 12 ? hour : hour - 12), (hour < 12 ? "am" : "pm")
+                           );
+               }
+
+               wc_printf("</dt>");
+       }
 
        gap = gap + ((dayend - daystart + 1) * timeline);
 
-        for (hour = (dayend + 1); hour < 24; ++hour) {       /* could do HEIGHT=xx */
-                wc_printf("<dt class=\"extrahour\">"
-                        "<a href=\"display_edit_event?msgnum=0?calview=day"
-                        "?year=%d?month=%d?day=%d?hour=%d?minute=0\">",
+       for (hour = (dayend + 1); hour < 24; ++hour) {  /* could do HEIGHT=xx */
+               wc_printf("<dt class=\"extrahour\">"
+                         "<a href=\"display_edit_event?msgnum=0?calview=day" "?year=%d?month=%d?day=%d?hour=%d?minute=0\">",
+
 /*TODO: what have these been used for?
                         gap + ((hour - dayend - 1) * extratimeline ),
                        extratimeline,
                        extrahourlabel,
 */
-                        year, month, day, hour
-                );
-
-                if (time_format == WC_TIMEFORMAT_24) {
-                        wc_printf("%2d:00</a> ", hour);
-                }
-                else {
-                        wc_printf("%d:00%s</a> ",
-                                (hour <= 12 ? hour : hour-12),
-                                (hour < 12 ? "am" : "pm")
-                        );
-                }
-
-                wc_printf("</dt>");
-        }
+                         year, month, day, hour);
+
+               if (time_format == WC_TIMEFORMAT_24) {
+                       wc_printf("%2d:00</a> ", hour);
+               }
+               else {
+                       wc_printf("%d:00%s</a> ", (hour <= 12 ? hour : hour - 12), (hour < 12 ? "am" : "pm")
+                           );
+               }
+
+               wc_printf("</dt>");
+       }
 
        /* Display events with start and end times on this day */
        calendar_day_view_display_events(today_t, year, month, day, 0, daystart, dayend);
 
-               wc_printf("</dl>");
-       wc_printf("</td>");                     /* end of innermost table */
+       wc_printf("</dl>");
+       wc_printf("</td>");     /* end of innermost table */
 
        /* Display extra events (start/end times not present or not today) in the middle column */
-        wc_printf("<td class=\"extra_events\">");
+       wc_printf("<td class=\"extra_events\">");
 
-        wc_printf("<ul>");
+       wc_printf("<ul>");
 
-        /* Display all-day events */
+       /* Display all-day events */
        calendar_day_view_display_events(today_t, year, month, day, 1, daystart, dayend);
 
-        wc_printf("</ul>");
+       wc_printf("</ul>");
 
        wc_printf("</td>");     /* end extra on the middle */
 
        wc_printf("<td width='20%%' align=\"center\" valign=top>");     /* begin stuff-on-the-right */
 
        /* Begin todays-date-with-left-and-right-arrows */
-       wc_printf("<table border=\"0\" width=\"100%%\" "
-               "cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#FFFFFF\">\n");
+       wc_printf("<table border=\"0\" width=\"100%%\" " "cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#FFFFFF\">\n");
        wc_printf("<tr>");
 
        /* Left arrow */
        wc_printf("<td align=\"center\">");
-       wc_printf("<a href=\"readfwd?calview=day?year=%d?month=%d?day=%d\">",
-               yesterday.year, yesterday.month, yesterday.day);
+       wc_printf("<a href=\"readfwd?calview=day?year=%d?month=%d?day=%d\">", yesterday.year, yesterday.month, yesterday.day);
        wc_printf("<img alt=\"previous\" align=\"middle\" src=\"static/webcit_icons/essen/32x32/back.png\" border=\"0\"></a>");
        wc_printf("</td>");
 
        wc_strftime(d_str, sizeof d_str,
-               "<td align=\"center\">"
-               "<font size='+2'>%A</font><br>"
-               "<font size='+2'>%B</font><br>"
-               "<font size='+3'>%d</font><br>"
-               "<font size='+2'>%Y</font><br>"
-               "</td>",
-               &d_tm
-               );
+                   "<td align=\"center\">"
+                   "<font size='+2'>%A</font><br>"
+                   "<font size='+2'>%B</font><br>" "<font size='+3'>%d</font><br>" "<font size='+2'>%Y</font><br>" "</td>", &d_tm);
        wc_printf("%s", d_str);
 
        /* Right arrow */
        wc_printf("<td align=\"center\">");
-       wc_printf("<a href=\"readfwd?calview=day?year=%d?month=%d?day=%d\">",
-               tomorrow.year, tomorrow.month, tomorrow.day);
+       wc_printf("<a href=\"readfwd?calview=day?year=%d?month=%d?day=%d\">", tomorrow.year, tomorrow.month, tomorrow.day);
        wc_printf("<img alt=\"%s\" align=\"middle\" src=\"static/webcit_icons/essen/32x32/forward.png\""
-               " border=\"0\"></a>\n", _("next"));
+                 " border=\"0\"></a>\n", _("next"));
        wc_printf("</td>");
 
        wc_printf("</tr></table>\n");
@@ -1305,8 +1215,8 @@ void calendar_day_view(int year, int month, int day) {
        wc_printf("<br>\n");
        embeddable_mini_calendar(year, month);
 
-       wc_printf("</td></tr>");                        /* end stuff-on-the-right */
-       wc_printf("</table>\n");                        /* end of inner table */
+       wc_printf("</td></tr>");        /* end stuff-on-the-right */
+       wc_printf("</table>\n");        /* end of inner table */
 }
 
 
@@ -1331,7 +1241,7 @@ int calendar_summary_view(void) {
        int num_displayed = 0;
 
        if (GetCount(WC->disp_cal_items) == 0) {
-               return(0);
+               return (0);
        }
 
        now = time(NULL);
@@ -1339,7 +1249,7 @@ int calendar_summary_view(void) {
 
        Pos = GetNewHashPos(WCC->disp_cal_items, 0);
        while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
-               Cal = (disp_cal*)vCal;
+               Cal = (disp_cal *) vCal;
                p = icalcomponent_get_first_property(Cal->cal, ICAL_DTSTART_PROPERTY);
                if (p != NULL) {
                        t = icalproperty_get_dtstart(p);
@@ -1359,41 +1269,33 @@ int calendar_summary_view(void) {
                                localtime_r(&event_tt, &event_tm);
                        }
 
-                       if ( (event_tm.tm_year == today_tm.tm_year)
-                               && (event_tm.tm_mon == today_tm.tm_mon)
-                               && (event_tm.tm_mday == today_tm.tm_mday)
-                       ) {
+                       if ((event_tm.tm_year == today_tm.tm_year)
+                           && (event_tm.tm_mon == today_tm.tm_mon)
+                           && (event_tm.tm_mday == today_tm.tm_mday)
+                           ) {
 
                                p = icalcomponent_get_first_property(Cal->cal, ICAL_SUMMARY_PROPERTY);
                                if (p == NULL) {
                                        p = icalproperty_new_summary(_("Untitled Task"));
                                        icalcomponent_add_property(Cal->cal, p);
                                }
-                               if (p != NULL)
-                               {
+                               if (p != NULL) {
                                        if (WCC->CurRoom.view == VIEW_TASKS) {
                                                wc_printf("<a href=\"display_edit_task"
-                                                       "?msgnum=%ld"
-                                                       "?return_to_summary=1"
-                                                       "?go=",
-                                                       Cal->cal_msgnum
-                                               );
+                                                         "?msgnum=%ld" "?return_to_summary=1" "?go=", Cal->cal_msgnum);
                                                escputs(ChrPtr(WCC->CurRoom.name));
                                                wc_printf("\">");
                                        }
                                        else {
                                                wc_printf("<a href=\"display_edit_event"
-                                                       "?msgnum=%ld"
-                                                       "?calview=summary"
-                                                       "?year=%d"
-                                                       "?month=%d"
-                                                       "?day=%d"
-                                                       "?go=",
-                                                       Cal->cal_msgnum,
-                                                       today_tm.tm_year + 1900,
-                                                       today_tm.tm_mon + 1,
-                                                       today_tm.tm_mday
-                                               );
+                                                         "?msgnum=%ld"
+                                                         "?calview=summary"
+                                                         "?year=%d"
+                                                         "?month=%d"
+                                                         "?day=%d"
+                                                         "?go=",
+                                                         Cal->cal_msgnum,
+                                                         today_tm.tm_year + 1900, today_tm.tm_mon + 1, today_tm.tm_mday);
                                                escputs(ChrPtr(WCC->CurRoom.name));
                                                wc_printf("\">");
                                        }
@@ -1409,20 +1311,14 @@ int calendar_summary_view(void) {
        }
        DeleteHashPos(&Pos);
        DeleteHash(&WC->disp_cal_items);
-       return(num_displayed);
+       return (num_displayed);
 }
 
 /*
  * Parse the URL variables in order to determine the scope and display of a calendar view
  */
-int calendar_GetParamsGetServerCall(SharedMessageStatus *Stat,
-                                   void **ViewSpecific,
-                                   long oper,
-                                   char *cmd,
-                                   long len,
-                                   char *filter,
-                                   long flen)
-{
+int calendar_GetParamsGetServerCall(SharedMessageStatus * Stat,
+                                   void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen) {
        wcsession *WCC = WC;
        calview *c;
        time_t now;
@@ -1431,9 +1327,9 @@ int calendar_GetParamsGetServerCall(SharedMessageStatus *Stat,
 
        int span = 3888000;
 
-       c = (calview*) malloc(sizeof(calview));
+       c = (calview *) malloc(sizeof(calview));
        memset(c, 0, sizeof(calview));
-       *ViewSpecific = (void*)c;
+       *ViewSpecific = (void *) c;
 
        Stat->load_seen = 1;
        strcpy(cmd, "MSGS ALL");
@@ -1447,9 +1343,12 @@ int calendar_GetParamsGetServerCall(SharedMessageStatus *Stat,
        c->day = tm.tm_mday;
 
        /* Now see if a date was specified */
-       if (havebstr("year")) c->year = ibstr("year");
-       if (havebstr("month")) c->month = ibstr("month");
-       if (havebstr("day")) c->day = ibstr("day");
+       if (havebstr("year"))
+               c->year = ibstr("year");
+       if (havebstr("month"))
+               c->month = ibstr("month");
+       if (havebstr("day"))
+               c->day = ibstr("day");
 
        /* How would you like that cooked? */
        if (havebstr("calview")) {
@@ -1487,11 +1386,16 @@ int calendar_GetParamsGetServerCall(SharedMessageStatus *Stat,
        tm.tm_mday = c->day;
        now = mktime(&tm);
 
-       if (c->view == calview_month)   span = 3888000;
-       if (c->view == calview_brief)   span = 3888000;
-       if (c->view == calview_week)    span = 604800;
-       if (c->view == calview_day)     span = 86400;
-       if (c->view == calview_summary) span = 86400;
+       if (c->view == calview_month)
+               span = 3888000;
+       if (c->view == calview_brief)
+               span = 3888000;
+       if (c->view == calview_week)
+               span = 604800;
+       if (c->view == calview_day)
+               span = 86400;
+       if (c->view == calview_summary)
+               span = 86400;
 
        c->lower_bound = now - span;
        c->upper_bound = now + span;
@@ -1503,12 +1407,9 @@ int calendar_GetParamsGetServerCall(SharedMessageStatus *Stat,
 /*
  * Render a calendar view from data previously loaded into memory
  */
-int calendar_RenderView_or_Tail(SharedMessageStatus *Stat,
-                               void **ViewSpecific,
-                               long oper)
-{
+int calendar_RenderView_or_Tail(SharedMessageStatus * Stat, void **ViewSpecific, long oper) {
        wcsession *WCC = WC;
-       calview *c = (calview*) *ViewSpecific;
+       calview *c = (calview *) * ViewSpecific;
 
        if (c->view == calview_day) {
                calendar_day_view(c->year, c->month, c->day);
@@ -1530,9 +1431,6 @@ int calendar_RenderView_or_Tail(SharedMessageStatus *Stat,
        return 0;
 }
 
-void 
-InitModule_CALENDAR_VIEW
-(void)
-{
+void InitModule_CALENDAR_VIEW(void) {
        WebcitAddUrlHandler(HKEY("mini_calendar"), "", 0, ajax_mini_calendar, AJAX);
 }
index f1035e71f2b33a47bd50f8f28d19894b5a41efd4..b7aec9ed1e5f38523a98b9ace3952eeabcc2a965 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * This is the other half of the webserver.  It handles the task of hooking
  * up HTTP requests with the sessions they belong to, using HTTP cookies to
@@ -29,33 +30,30 @@ HashList *HttpHeaderHandler = NULL;
 extern HashList *HandlerHash;
 
 /* the following two values start at 1 because the initial parent thread counts as one. */
-int num_threads_existing = 1;          /* Number of worker threads which exist. */
-int num_threads_executing = 1;         /* Number of worker threads currently executing. */
-int verbose=0;
+int num_threads_existing = 1;  /* Number of worker threads which exist. */
+int num_threads_executing = 1; /* Number of worker threads currently executing. */
+int verbose = 0;
 
 extern void session_loop(void);
 void spawn_another_worker_thread(void);
 
 
-void DestroyHttpHeaderHandler(void *V)
-{
+void DestroyHttpHeaderHandler(void *V) {
        OneHttpHeader *pHdr;
-       pHdr = (OneHttpHeader*) V;
+       pHdr = (OneHttpHeader *) V;
        FreeStrBuf(&pHdr->Val);
        free(pHdr);
 }
 
-void shutdown_sessions(void)
-{
+void shutdown_sessions(void) {
        wcsession *sptr;
-       
+
        for (sptr = SessionList; sptr != NULL; sptr = sptr->next) {
                sptr->killthis = 1;
        }
 }
 
-void do_housekeeping(void)
-{
+void do_housekeeping(void) {
        wcsession *sptr, *ss;
        wcsession *sessions_to_kill = NULL;
        time_t the_time;
@@ -70,9 +68,7 @@ void do_housekeeping(void)
                if (the_time == 0)
                        the_time = time(NULL);
                /* Kill idle sessions */
-               if ((sptr->inuse == 0) && 
-                   ((the_time - (sptr->lastreq)) > (time_t) WEBCIT_TIMEOUT))
-               {
+               if ((sptr->inuse == 0) && ((the_time - (sptr->lastreq)) > (time_t) WEBCIT_TIMEOUT)) {
                        syslog(LOG_DEBUG, "Timeout session %d", sptr->wc_session);
                        sptr->killthis = 1;
                }
@@ -84,11 +80,12 @@ void do_housekeeping(void)
                        if (sptr == SessionList) {
                                SessionList = SessionList->next;
                        }
-                       else for (ss=SessionList;ss!=NULL;ss=ss->next) {
-                               if (ss->next == sptr) {
-                                       ss->next = ss->next->next;
+                       else
+                               for (ss = SessionList; ss != NULL; ss = ss->next) {
+                                       if (ss->next == sptr) {
+                                               ss->next = ss->next->next;
+                                       }
                                }
-                       }
 
                        sptr->next = sessions_to_kill;
                        sessions_to_kill = sptr;
@@ -110,19 +107,16 @@ void do_housekeeping(void)
 /*
  * Check the size of our thread pool.  If all threads are executing, spawn another.
  */
-void check_thread_pool_size(void)
-{
-       if (time_to_die) return;                /* don't expand the thread pool during shutdown */
+void check_thread_pool_size(void) {
+       if (time_to_die)
+               return;         /* don't expand the thread pool during shutdown */
 
        begin_critical_section(S_SPAWNER);      /* only one of these should run at a time */
-       if (
-               (num_threads_executing >= num_threads_existing)
-               && (num_threads_existing < MAX_WORKER_THREADS)
-       ) {
+       if ((num_threads_executing >= num_threads_existing)
+           && (num_threads_existing < MAX_WORKER_THREADS)
+           ) {
                syslog(LOG_DEBUG, "%d of %d threads are executing.  Adding another worker thread.",
-                       num_threads_executing,
-                       num_threads_existing
-               );
+                      num_threads_executing, num_threads_existing);
                spawn_another_worker_thread();
        }
        end_critical_section(S_SPAWNER);
@@ -132,8 +126,7 @@ void check_thread_pool_size(void)
 /*
  * Wake up occasionally and clean house
  */
-void housekeeping_loop(void)
-{
+void housekeeping_loop(void) {
        while (1) {
                sleeeeeeeeeep(HOUSEKEEPING);
                do_housekeeping();
@@ -146,37 +139,34 @@ void housekeeping_loop(void)
  * Generate a unique WebCit session ID (which is not the same thing as the
  * Citadel session ID).
  */
-int GenerateSessionID(void)
-{
+int GenerateSessionID(void) {
        static int seq = (-1);
 
        if (seq < 0) {
                seq = (int) time(NULL);
        }
-               
+
        return ++seq;
 }
 
-wcsession *FindSession(wcsession **wclist, ParsedHttpHdrs *Hdr, pthread_mutex_t *ListMutex)
-{
+wcsession *FindSession(wcsession ** wclist, ParsedHttpHdrs * Hdr, pthread_mutex_t * ListMutex) {
        wcsession *sptr = NULL;
-       wcsession *TheSession = NULL;   
-       
+       wcsession *TheSession = NULL;
+
        if (Hdr->HR.got_auth == AUTH_BASIC) {
                GetAuthBasic(Hdr);
        }
 
        CtdlLogResult(pthread_mutex_lock(ListMutex));
        for (sptr = *wclist; ((sptr != NULL) && (TheSession == NULL)); sptr = sptr->next) {
-               
+
                /* If HTTP-AUTH, look for a session with matching credentials */
-               switch (Hdr->HR.got_auth)
-               {
+               switch (Hdr->HR.got_auth) {
                case AUTH_BASIC:
-                       if (    (!strcasecmp(ChrPtr(Hdr->c_username), ChrPtr(sptr->wc_username)))
-                               && (!strcasecmp(ChrPtr(Hdr->c_password), ChrPtr(sptr->wc_password)))
-                               && (sptr->killthis == 0)
-                       ) {
+                       if ((!strcasecmp(ChrPtr(Hdr->c_username), ChrPtr(sptr->wc_username)))
+                           && (!strcasecmp(ChrPtr(Hdr->c_password), ChrPtr(sptr->wc_password)))
+                           && (sptr->killthis == 0)
+                           ) {
                                if (verbose)
                                        syslog(LOG_DEBUG, "Matched a session with the same http-auth");
                                TheSession = sptr;
@@ -184,17 +174,17 @@ wcsession *FindSession(wcsession **wclist, ParsedHttpHdrs *Hdr, pthread_mutex_t
                        break;
                case AUTH_COOKIE:
                        /* If cookie-session, look for a session with matching session ID */
-                       if (    (Hdr->HR.desired_session != 0)
-                               && (sptr->wc_session == Hdr->HR.desired_session)
-                       ) {
+                       if ((Hdr->HR.desired_session != 0)
+                           && (sptr->wc_session == Hdr->HR.desired_session)
+                           ) {
                                if (verbose)
                                        syslog(LOG_DEBUG, "Matched a session with the same cookie");
                                TheSession = sptr;
                        }
-                       break;                       
+                       break;
                case NO_AUTH:
                        /* Any unbound session is a candidate */
-                       if ( (sptr->wc_session == 0) && (sptr->inuse == 0) ) {
+                       if ((sptr->wc_session == 0) && (sptr->inuse == 0)) {
                                if (verbose)
                                        syslog(LOG_DEBUG, "Reusing an unbound session");
                                TheSession = sptr;
@@ -209,8 +199,7 @@ wcsession *FindSession(wcsession **wclist, ParsedHttpHdrs *Hdr, pthread_mutex_t
        return TheSession;
 }
 
-wcsession *CreateSession(int Lockable, int Static, wcsession **wclist, ParsedHttpHdrs *Hdr, pthread_mutex_t *ListMutex)
-{
+wcsession *CreateSession(int Lockable, int Static, wcsession ** wclist, ParsedHttpHdrs * Hdr, pthread_mutex_t * ListMutex) {
        wcsession *TheSession;
        TheSession = (wcsession *) malloc(sizeof(wcsession));
        memset(TheSession, 0, sizeof(wcsession));
@@ -218,14 +207,14 @@ wcsession *CreateSession(int Lockable, int Static, wcsession **wclist, ParsedHtt
        TheSession->serv_sock = (-1);
        TheSession->lastreq = time(NULL);;
 
-       pthread_setspecific(MyConKey, (void *)TheSession);
-       
+       pthread_setspecific(MyConKey, (void *) TheSession);
+
        /* If we're recreating a session that expired, it's best to give it the same
         * session number that it had before.  The client browser ought to pick up
         * the new session number and start using it, but in some rare situations it
         * doesn't, and that's a Bad Thing because it causes lots of spurious sessions
         * to get created.
-        */     
+        */
        if (Hdr->HR.desired_session == 0) {
                TheSession->wc_session = GenerateSessionID();
                syslog(LOG_DEBUG, "Created new session %d", TheSession->wc_session);
@@ -256,16 +245,14 @@ wcsession *CreateSession(int Lockable, int Static, wcsession **wclist, ParsedHtt
 
 
 /* If it's a "force 404" situation then display the error and bail. */
-void do_404(void)
-{
+void do_404(void) {
        hprintf("HTTP/1.1 404 Not found\r\n");
        hprintf("Content-Type: text/plain\r\n");
        wc_printf("Not found\r\n");
        end_burst();
 }
 
-int ReadHttpSubject(ParsedHttpHdrs *Hdr, StrBuf *Line, StrBuf *Buf)
-{
+int ReadHttpSubject(ParsedHttpHdrs * Hdr, StrBuf * Line, StrBuf * Buf) {
        const char *Args;
        void *vLine, *vHandler;
        const char *Pos = NULL;
@@ -273,10 +260,8 @@ int ReadHttpSubject(ParsedHttpHdrs *Hdr, StrBuf *Line, StrBuf *Buf)
        Hdr->HR.ReqLine = Line;
        /* The requesttype... GET, POST... */
        StrBufExtract_token(Buf, Hdr->HR.ReqLine, 0, ' ');
-       if (GetHash(HttpReqTypes, SKEY(Buf), &vLine) &&
-           (vLine != NULL))
-       {
-               Hdr->HR.eReqType = *(long*)vLine;
+       if (GetHash(HttpReqTypes, SKEY(Buf), &vLine) && (vLine != NULL)) {
+               Hdr->HR.eReqType = *(long *) vLine;
        }
        else {
                Hdr->HR.eReqType = eGET;
@@ -287,7 +272,7 @@ int ReadHttpSubject(ParsedHttpHdrs *Hdr, StrBuf *Line, StrBuf *Buf)
        /* the HTTP Version... */
        StrBufExtract_token(Buf, Hdr->HR.ReqLine, 1, ' ');
        StrBufCutRight(Hdr->HR.ReqLine, StrLength(Buf) + 1);
-       
+
        if (StrLength(Buf) == 0) {
                Hdr->HR.eReqType = eGET;
                return 1;
@@ -297,25 +282,21 @@ int ReadHttpSubject(ParsedHttpHdrs *Hdr, StrBuf *Line, StrBuf *Buf)
 
        /* chop Filename / query arguments */
        Args = strchr(ChrPtr(Hdr->HR.ReqLine), '?');
-       if (Args == NULL) /* whe're not that picky about params... TODO: this will spoil '&' in filenames.*/
+       if (Args == NULL)       /* whe're not that picky about params... TODO: this will spoil '&' in filenames. */
                Args = strchr(ChrPtr(Hdr->HR.ReqLine), '&');
        if (Args != NULL) {
-               Args ++; /* skip the ? */
-               StrBufPlain(Hdr->PlainArgs, 
-                           Args, 
-                           StrLength(Hdr->HR.ReqLine) -
-                           (Args - ChrPtr(Hdr->HR.ReqLine)));
+               Args++;         /* skip the ? */
+               StrBufPlain(Hdr->PlainArgs, Args, StrLength(Hdr->HR.ReqLine) - (Args - ChrPtr(Hdr->HR.ReqLine)));
                StrBufCutAt(Hdr->HR.ReqLine, 0, Args - 1);
-       } /* don't parse them yet, maybe we don't even care... */
-       
+       }                       /* don't parse them yet, maybe we don't even care... */
+
        /* now lookup what we are going to do with this... */
        /* skip first slash */
        StrBufExtract_NextToken(Buf, Hdr->HR.ReqLine, &Pos, '/');
        do {
                StrBufExtract_NextToken(Buf, Hdr->HR.ReqLine, &Pos, '/');
 
-               GetHash(HandlerHash, SKEY(Buf), &vHandler),
-               Hdr->HR.Handler = (WebcitHandler*) vHandler;
+               GetHash(HandlerHash, SKEY(Buf), &vHandler), Hdr->HR.Handler = (WebcitHandler *) vHandler;
                if (Hdr->HR.Handler == NULL)
                        break;
                /*
@@ -328,19 +309,16 @@ int ReadHttpSubject(ParsedHttpHdrs *Hdr, StrBuf *Line, StrBuf *Buf)
                break;
        } while (1);
        /* remove the handlername from the URL */
-       if ((Pos != NULL) && (Pos != StrBufNOTNULL)){
-               StrBufCutLeft(Hdr->HR.ReqLine, 
-                             Pos - ChrPtr(Hdr->HR.ReqLine));
+       if ((Pos != NULL) && (Pos != StrBufNOTNULL)) {
+               StrBufCutLeft(Hdr->HR.ReqLine, Pos - ChrPtr(Hdr->HR.ReqLine));
        }
 
        if (Hdr->HR.Handler != NULL) {
                if ((Hdr->HR.Handler->Flags & BOGUS) != 0) {
                        return 1;
                }
-               Hdr->HR.DontNeedAuth = (
-                       ((Hdr->HR.Handler->Flags & ISSTATIC) != 0) ||
-                       ((Hdr->HR.Handler->Flags & ANONYMOUS) != 0)
-               );
+               Hdr->HR.DontNeedAuth = (((Hdr->HR.Handler->Flags & ISSTATIC) != 0) || ((Hdr->HR.Handler->Flags & ANONYMOUS) != 0)
+                   );
        }
        else {
                /* If this is a "flat" request for the root, display the configured landing page. */
@@ -348,7 +326,8 @@ int ReadHttpSubject(ParsedHttpHdrs *Hdr, StrBuf *Line, StrBuf *Buf)
                StrBuf *NewLine = NewStrBuf();
                Hdr->HR.DontNeedAuth = 1;
                StrBufAppendPrintf(NewLine, "GET /landing?go=%s?failvisibly=1 HTTP/1.0", ChrPtr(Buf));
-               if (verbose) syslog(LOG_DEBUG, "Replacing with: %s", ChrPtr(NewLine));
+               if (verbose)
+                       syslog(LOG_DEBUG, "Replacing with: %s", ChrPtr(NewLine));
                return_value = ReadHttpSubject(Hdr, NewLine, Buf);
                FreeStrBuf(&NewLine);
                return return_value;
@@ -357,16 +336,15 @@ int ReadHttpSubject(ParsedHttpHdrs *Hdr, StrBuf *Line, StrBuf *Buf)
        return 0;
 }
 
-int AnalyseHeaders(ParsedHttpHdrs *Hdr) {
+int AnalyseHeaders(ParsedHttpHdrs * Hdr) {
        OneHttpHeader *pHdr;
        void *vHdr;
        long HKLen;
        const char *HashKey;
        HashPos *at = GetNewHashPos(Hdr->HTTPHeaders, 0);
-       
-       while (GetNextHashPos(Hdr->HTTPHeaders, at, &HKLen, &HashKey, &vHdr) && 
-              (vHdr != NULL)) {
-               pHdr = (OneHttpHeader *)vHdr;
+
+       while (GetNextHashPos(Hdr->HTTPHeaders, at, &HKLen, &HashKey, &vHdr) && (vHdr != NULL)) {
+               pHdr = (OneHttpHeader *) vHdr;
                if (pHdr->HaveEvaluator)
                        pHdr->H(pHdr->Val, Hdr);
 
@@ -379,7 +357,7 @@ int AnalyseHeaders(ParsedHttpHdrs *Hdr) {
 /*
  * Read in the request
  */
-int ReadHTTPRequest(ParsedHttpHdrs *Hdr) {
+int ReadHTTPRequest(ParsedHttpHdrs * Hdr) {
        const char *pch, *pchs, *pche;
        OneHttpHeader *pHdr;
        StrBuf *Line, *LastLine, *HeaderName;
@@ -390,7 +368,7 @@ int ReadHTTPRequest(ParsedHttpHdrs *Hdr) {
        HeaderName = NewStrBuf();
        LastLine = NULL;
        do {
-               nLine ++;
+               nLine++;
                Line = NewStrBufPlain(NULL, SIZ / 4);
 
                if (ClientGetLine(Hdr, Line) < 0) {
@@ -405,7 +383,7 @@ int ReadHTTPRequest(ParsedHttpHdrs *Hdr) {
                }
                if (nLine == 1) {
                        Hdr->HTTPHeaders = NewHash(1, NULL);
-                       pHdr = (OneHttpHeader*) malloc(sizeof(OneHttpHeader));
+                       pHdr = (OneHttpHeader *) malloc(sizeof(OneHttpHeader));
                        memset(pHdr, 0, sizeof(OneHttpHeader));
                        pHdr->Val = Line;
                        Put(Hdr->HTTPHeaders, HKEY("GET /"), pHdr, DestroyHttpHeaderHandler);
@@ -413,7 +391,8 @@ int ReadHTTPRequest(ParsedHttpHdrs *Hdr) {
                                syslog(LOG_DEBUG, "%s", ChrPtr(Line));
                        }
                        isbogus = ReadHttpSubject(Hdr, Line, HeaderName);
-                       if (isbogus) break;
+                       if (isbogus)
+                               break;
                        continue;
                }
 
@@ -422,7 +401,7 @@ int ReadHTTPRequest(ParsedHttpHdrs *Hdr) {
                        pch = pchs = ChrPtr(Line);
                        pche = pchs + StrLength(Line);
                        while (isspace(*pch) && (pch < pche)) {
-                               pch ++;
+                               pch++;
                        }
                        StrBufCutLeft(Line, pch - pchs);
                        StrBufAppendBuf(LastLine, Line, 0);
@@ -431,7 +410,7 @@ int ReadHTTPRequest(ParsedHttpHdrs *Hdr) {
                        continue;
                }
 
-               StrBufSanitizeAscii(Line, (char)0xa7);
+               StrBufSanitizeAscii(Line, (char) 0xa7);
                StrBufExtract_token(HeaderName, Line, 0, ':');
 
                pchs = ChrPtr(Line);
@@ -439,17 +418,17 @@ int ReadHTTPRequest(ParsedHttpHdrs *Hdr) {
                pch = pchs + StrLength(HeaderName) + 1;
                pche = pchs + StrLength(Line);
                while ((pch < pche) && isspace(*pch)) {
-                       pch ++;
+                       pch++;
                }
                StrBufCutLeft(Line, pch - pchs);
                StrBufUpCase(HeaderName);
 
-               pHdr = (OneHttpHeader*) malloc(sizeof(OneHttpHeader));
+               pHdr = (OneHttpHeader *) malloc(sizeof(OneHttpHeader));
                memset(pHdr, 0, sizeof(OneHttpHeader));
                pHdr->Val = Line;
 
                if (GetHash(HttpHeaderHandler, SKEY(HeaderName), &vF) && (vF != NULL)) {
-                       OneHttpHeader *FHdr = (OneHttpHeader*) vF;
+                       OneHttpHeader *FHdr = (OneHttpHeader *) vF;
                        pHdr->H = FHdr->H;
                        pHdr->HaveEvaluator = 1;
                }
@@ -462,8 +441,7 @@ int ReadHTTPRequest(ParsedHttpHdrs *Hdr) {
        return isbogus;
 }
 
-void OverrideRequest(ParsedHttpHdrs *Hdr, const char *Line, long len)
-{
+void OverrideRequest(ParsedHttpHdrs * Hdr, const char *Line, long len) {
        StrBuf *Buf = NewStrBuf();
 
        if (Hdr->HR.ReqLine != NULL) {
@@ -491,40 +469,40 @@ void OverrideRequest(ParsedHttpHdrs *Hdr, const char *Line, long len)
  * function returns, the worker thread is then free to handle another
  * transaction.
  */
-void context_loop(ParsedHttpHdrs *Hdr) {
+void context_loop(ParsedHttpHdrs * Hdr) {
        int isbogus = 0;
        wcsession *TheSession;
        struct timeval tx_start;
        struct timeval tx_finish;
        int session_may_be_reused = 1;
        time_t now;
-       
-       gettimeofday(&tx_start, NULL);          /* start a stopwatch for performance timing */
+
+       gettimeofday(&tx_start, NULL);  /* start a stopwatch for performance timing */
 
        /*
         * Find out what it is that the web browser is asking for
         */
        isbogus = ReadHTTPRequest(Hdr);
 
-       Hdr->HR.dav_depth = 32767; /* TODO: find a general way to have non-0 defaults */
+       Hdr->HR.dav_depth = 32767;      /* TODO: find a general way to have non-0 defaults */
 
        if (!isbogus) {
                isbogus = AnalyseHeaders(Hdr);
        }
 
-       if (    (isbogus)
-               || ((Hdr->HR.Handler != NULL)
+       if ((isbogus)
+           || ((Hdr->HR.Handler != NULL)
                && ((Hdr->HR.Handler->Flags & BOGUS) != 0))
-       ) {
+           ) {
                wcsession *Bogus;
                Bogus = CreateSession(0, 1, NULL, Hdr, NULL);
                do_404();
                syslog(LOG_WARNING, "HTTP: 404 [%ld.%06ld] %s %s",
-                       ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
-                       ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
-                       ReqStrs[Hdr->HR.eReqType],
-                       ChrPtr(Hdr->this_page)
-                       );
+                      ((tx_finish.tv_sec * 1000000 + tx_finish.tv_usec) -
+                       (tx_start.tv_sec * 1000000 + tx_start.tv_usec)) / 1000000,
+                      ((tx_finish.tv_sec * 1000000 + tx_finish.tv_usec) -
+                       (tx_start.tv_sec * 1000000 + tx_start.tv_usec)) % 1000000, ReqStrs[Hdr->HR.eReqType], ChrPtr(Hdr->this_page)
+                   );
                session_detach_modules(Bogus);
                session_destroy_modules(&Bogus);
                return;
@@ -533,19 +511,20 @@ void context_loop(ParsedHttpHdrs *Hdr) {
        if ((Hdr->HR.Handler != NULL) && ((Hdr->HR.Handler->Flags & ISSTATIC) != 0)) {
                wcsession *Static;
                Static = CreateSession(0, 1, NULL, Hdr, NULL);
-               
+
                Hdr->HR.Handler->F();
 
                /* How long did this transaction take? */
                gettimeofday(&tx_finish, NULL);
-               
+
                if (verbose)
                        syslog(LOG_DEBUG, "HTTP: 200 [%ld.%06ld] %s %s",
-                              ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
-                              ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
-                              ReqStrs[Hdr->HR.eReqType],
+                              ((tx_finish.tv_sec * 1000000 + tx_finish.tv_usec) -
+                               (tx_start.tv_sec * 1000000 + tx_start.tv_usec)) / 1000000,
+                              ((tx_finish.tv_sec * 1000000 + tx_finish.tv_usec) -
+                               (tx_start.tv_sec * 1000000 + tx_start.tv_usec)) % 1000000, ReqStrs[Hdr->HR.eReqType],
                               ChrPtr(Hdr->this_page)
-               );
+                           );
                session_detach_modules(Static);
                session_destroy_modules(&Static);
                return;
@@ -577,14 +556,14 @@ void context_loop(ParsedHttpHdrs *Hdr) {
        /*
         * Reject transactions which require http-auth, if http-auth was not provided
         */
-       if (    (StrLength(Hdr->c_username) == 0)
-               && (!Hdr->HR.DontNeedAuth)
-               && (Hdr->HR.Handler != NULL)
-               && ((XHTTP_COMMANDS & Hdr->HR.Handler->Flags) == XHTTP_COMMANDS)
-       ) {
+       if ((StrLength(Hdr->c_username) == 0)
+           && (!Hdr->HR.DontNeedAuth)
+           && (Hdr->HR.Handler != NULL)
+           && ((XHTTP_COMMANDS & Hdr->HR.Handler->Flags) == XHTTP_COMMANDS)
+           ) {
                syslog(LOG_DEBUG, "http-auth required but not provided");
                OverrideRequest(Hdr, HKEY("GET /401 HTTP/1.0"));
-               Hdr->HR.prohibit_caching = 1;                           
+               Hdr->HR.prohibit_caching = 1;
        }
 
        /*
@@ -597,11 +576,11 @@ void context_loop(ParsedHttpHdrs *Hdr) {
         */
        now = time(NULL);;
        CtdlLogResult(pthread_mutex_lock(&TheSession->SessionMutex));
-       pthread_setspecific(MyConKey, (void *)TheSession);
-       
-       TheSession->inuse = 1;                          /* mark the session as bound */
-       TheSession->isFailure = 0;                      /* reset evntually existing error flags */
-       TheSession->lastreq = now;                      /* log */
+       pthread_setspecific(MyConKey, (void *) TheSession);
+
+       TheSession->inuse = 1;  /* mark the session as bound */
+       TheSession->isFailure = 0;      /* reset evntually existing error flags */
+       TheSession->lastreq = now;      /* log */
        TheSession->Hdr = Hdr;
 
        /*
@@ -626,11 +605,11 @@ void context_loop(ParsedHttpHdrs *Hdr) {
 
        if (verbose || strstr(ChrPtr(Hdr->this_page), "sslg") == NULL) {
                syslog(LOG_INFO, "HTTP: 200 [%ld.%06ld] %s %s",
-                      ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
-                      ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
-                      ReqStrs[Hdr->HR.eReqType],
-                      ChrPtr(Hdr->this_page)
-                       );
+                      ((tx_finish.tv_sec * 1000000 + tx_finish.tv_usec) -
+                       (tx_start.tv_sec * 1000000 + tx_start.tv_usec)) / 1000000,
+                      ((tx_finish.tv_sec * 1000000 + tx_finish.tv_usec) -
+                       (tx_start.tv_sec * 1000000 + tx_start.tv_usec)) % 1000000, ReqStrs[Hdr->HR.eReqType], ChrPtr(Hdr->this_page)
+                   );
        }
        session_detach_modules(TheSession);
 
@@ -641,51 +620,45 @@ void context_loop(ParsedHttpHdrs *Hdr) {
         * spider crawls the site without using cookies.
         */
        if ((session_may_be_reused) && (!TheSession->logged_in)) {
-               TheSession->wc_session = 0;             /* flag as available for re-use */
+               TheSession->wc_session = 0;     /* flag as available for re-use */
                TheSession->selected_language = -1;     /* clear any non-default language setting */
        }
 
        TheSession->Hdr = NULL;
-       TheSession->inuse = 0;                                  /* mark the session as unbound */
+       TheSession->inuse = 0;  /* mark the session as unbound */
        CtdlLogResult(pthread_mutex_unlock(&TheSession->SessionMutex));
 }
 
-void tmplput_nonce(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_nonce(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
-       StrBufAppendPrintf(Target, "%ld",
-                          (WCC != NULL)? WCC->nonce:0);                   
+       StrBufAppendPrintf(Target, "%ld", (WCC != NULL) ? WCC->nonce : 0);
 }
 
-void tmplput_current_user(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_current_user(StrBuf * Target, WCTemplputParams * TP) {
        StrBufAppendTemplate(Target, TP, WC->wc_fullname, 0);
 }
 
-void Header_HandleContentLength(StrBuf *Line, ParsedHttpHdrs *hdr)
-{
+void Header_HandleContentLength(StrBuf * Line, ParsedHttpHdrs * hdr) {
        hdr->HR.ContentLength = StrToi(Line);
 }
 
-void Header_HandleContentType(StrBuf *Line, ParsedHttpHdrs *hdr)
-{
+void Header_HandleContentType(StrBuf * Line, ParsedHttpHdrs * hdr) {
        hdr->HR.ContentType = Line;
 }
 
 
-void Header_HandleHost(StrBuf *Line, ParsedHttpHdrs *hdr)
-{
+void Header_HandleHost(StrBuf * Line, ParsedHttpHdrs * hdr) {
        if (hdr->HostHeader != NULL) {
                FreeStrBuf(&hdr->HostHeader);
        }
        hdr->HostHeader = NewStrBuf();
-       StrBufAppendPrintf(hdr->HostHeader, "%s://", (is_https ? "https" : "http") );
+       StrBufAppendPrintf(hdr->HostHeader, "%s://", (is_https ? "https" : "http"));
        StrBufAppendBuf(hdr->HostHeader, Line, 0);
 }
 
-void Header_HandleXFFHost(StrBuf *Line, ParsedHttpHdrs *hdr)
-{
-       if (!follow_xff) return;
+void Header_HandleXFFHost(StrBuf * Line, ParsedHttpHdrs * hdr) {
+       if (!follow_xff)
+               return;
 
        if (hdr->HostHeader != NULL) {
                FreeStrBuf(&hdr->HostHeader);
@@ -697,8 +670,7 @@ void Header_HandleXFFHost(StrBuf *Line, ParsedHttpHdrs *hdr)
 }
 
 
-void Header_HandleXFF(StrBuf *Line, ParsedHttpHdrs *hdr)
-{
+void Header_HandleXFF(StrBuf * Line, ParsedHttpHdrs * hdr) {
        hdr->HR.browser_host = Line;
 
        while (StrBufNum_tokens(hdr->HR.browser_host, ',') > 1) {
@@ -707,13 +679,11 @@ void Header_HandleXFF(StrBuf *Line, ParsedHttpHdrs *hdr)
        StrBufTrim(hdr->HR.browser_host);
 }
 
-void Header_HandleIfModSince(StrBuf *Line, ParsedHttpHdrs *hdr)
-{
+void Header_HandleIfModSince(StrBuf * Line, ParsedHttpHdrs * hdr) {
        hdr->HR.if_modified_since = httpdate_to_timestamp(Line);
 }
 
-void Header_HandleAcceptEncoding(StrBuf *Line, ParsedHttpHdrs *hdr)
-{
+void Header_HandleAcceptEncoding(StrBuf * Line, ParsedHttpHdrs * hdr) {
        /*
         * Can we compress?
         */
@@ -722,14 +692,13 @@ void Header_HandleAcceptEncoding(StrBuf *Line, ParsedHttpHdrs *hdr)
        }
 }
 
-void Header_HandleContentRange(StrBuf *Line, ParsedHttpHdrs *hdr)
-{
+void Header_HandleContentRange(StrBuf * Line, ParsedHttpHdrs * hdr) {
        const char *PRange = ChrPtr(Line);
 
        while ((*PRange != '=') && (*PRange != '\0'))
-               PRange ++;
+               PRange++;
        if (*PRange == '=')
-               PRange ++;
+               PRange++;
        if ((*PRange == '\0'))
                return;
        hdr->HaveRange = 1;
@@ -739,7 +708,7 @@ void Header_HandleContentRange(StrBuf *Line, ParsedHttpHdrs *hdr)
                PRange++;
 
        if (*PRange == '-')
-               PRange ++;
+               PRange++;
        if ((*PRange == '\0'))
                hdr->RangeTil = -1;
        else
@@ -759,10 +728,7 @@ const char *ReqStrs[eNONE] = {
        "REPORT"
 };
 
-void
-ServerStartModule_CONTEXT
-(void)
-{
+void ServerStartModule_CONTEXT(void) {
        long *v;
        HttpReqTypes = NewHash(1, NULL);
        HttpHeaderHandler = NewHash(1, NULL);
@@ -808,33 +774,26 @@ ServerStartModule_CONTEXT
        Put(HttpReqTypes, HKEY("REPORT"), v, NULL);
 }
 
-void 
-ServerShutdownModule_CONTEXT
-(void)
-{
+void ServerShutdownModule_CONTEXT(void) {
        DeleteHash(&HttpReqTypes);
        DeleteHash(&HttpHeaderHandler);
 }
 
-void RegisterHeaderHandler(const char *Name, long Len, Header_Evaluator F)
-{
+void RegisterHeaderHandler(const char *Name, long Len, Header_Evaluator F) {
        OneHttpHeader *pHdr;
-       pHdr = (OneHttpHeader*) malloc(sizeof(OneHttpHeader));
+       pHdr = (OneHttpHeader *) malloc(sizeof(OneHttpHeader));
        memset(pHdr, 0, sizeof(OneHttpHeader));
        pHdr->H = F;
        Put(HttpHeaderHandler, Name, Len, pHdr, DestroyHttpHeaderHandler);
 }
 
 
-void 
-InitModule_CONTEXT
-(void)
-{
+void InitModule_CONTEXT(void) {
        RegisterHeaderHandler(HKEY("RANGE"), Header_HandleContentRange);
        RegisterHeaderHandler(HKEY("CONTENT-LENGTH"), Header_HandleContentLength);
        RegisterHeaderHandler(HKEY("CONTENT-TYPE"), Header_HandleContentType);
-       RegisterHeaderHandler(HKEY("X-FORWARDED-HOST"), Header_HandleXFFHost); /* Apache way... */
-       RegisterHeaderHandler(HKEY("X-REAL-IP"), Header_HandleXFFHost);        /* NGinX way... */
+       RegisterHeaderHandler(HKEY("X-FORWARDED-HOST"), Header_HandleXFFHost);  /* Apache way... */
+       RegisterHeaderHandler(HKEY("X-REAL-IP"), Header_HandleXFFHost); /* NGinX way... */
        RegisterHeaderHandler(HKEY("HOST"), Header_HandleHost);
        RegisterHeaderHandler(HKEY("X-FORWARDED-FOR"), Header_HandleXFF);
        RegisterHeaderHandler(HKEY("ACCEPT-ENCODING"), Header_HandleAcceptEncoding);
@@ -843,32 +802,27 @@ InitModule_CONTEXT
        RegisterNamespace("CURRENT_USER", 0, 1, tmplput_current_user, NULL, CTX_NONE);
        RegisterNamespace("NONCE", 0, 0, tmplput_nonce, NULL, 0);
 
-       WebcitAddUrlHandler(HKEY("404"), "", 0, do_404, ANONYMOUS|COOKIEUNNEEDED);
+       WebcitAddUrlHandler(HKEY("404"), "", 0, do_404, ANONYMOUS | COOKIEUNNEEDED);
+
 /*
  * Look for commonly-found probes of malware such as worms, viruses, trojans, and Microsoft Office.
  * Short-circuit these requests so we don't have to send them through the full processing loop.
  */
-       WebcitAddUrlHandler(HKEY("scripts"), "", 0, do_404, ANONYMOUS|BOGUS);           /* /root.exe - Worms and trojans and viruses, oh my! */
-       WebcitAddUrlHandler(HKEY("c"), "", 0, do_404, ANONYMOUS|BOGUS);         /* /winnt */
-       WebcitAddUrlHandler(HKEY("MSADC"), "", 0, do_404, ANONYMOUS|BOGUS);
-       WebcitAddUrlHandler(HKEY("_vti"), "", 0, do_404, ANONYMOUS|BOGUS);              /* Broken Microsoft DAV implementation */
-       WebcitAddUrlHandler(HKEY("MSOffice"), "", 0, do_404, ANONYMOUS|BOGUS);          /* Stoopid MSOffice thinks everyone is IIS */
-       WebcitAddUrlHandler(HKEY("nonexistenshit"), "", 0, do_404, ANONYMOUS|BOGUS);    /* Exploit found in the wild January 2009 */
+       WebcitAddUrlHandler(HKEY("scripts"), "", 0, do_404, ANONYMOUS | BOGUS); /* /root.exe - Worms and trojans and viruses, oh my! */
+       WebcitAddUrlHandler(HKEY("c"), "", 0, do_404, ANONYMOUS | BOGUS);       /* /winnt */
+       WebcitAddUrlHandler(HKEY("MSADC"), "", 0, do_404, ANONYMOUS | BOGUS);
+       WebcitAddUrlHandler(HKEY("_vti"), "", 0, do_404, ANONYMOUS | BOGUS);    /* Broken Microsoft DAV implementation */
+       WebcitAddUrlHandler(HKEY("MSOffice"), "", 0, do_404, ANONYMOUS | BOGUS);        /* Stoopid MSOffice thinks everyone is IIS */
+       WebcitAddUrlHandler(HKEY("nonexistenshit"), "", 0, do_404, ANONYMOUS | BOGUS);  /* Exploit found in the wild January 2009 */
 }
-       
 
-void 
-HttpNewModule_CONTEXT
-(ParsedHttpHdrs *httpreq)
-{
+
+void HttpNewModule_CONTEXT(ParsedHttpHdrs * httpreq) {
        httpreq->PlainArgs = NewStrBufPlain(NULL, SIZ);
        httpreq->this_page = NewStrBufPlain(NULL, SIZ);
 }
 
-void 
-HttpDetachModule_CONTEXT
-(ParsedHttpHdrs *httpreq)
-{
+void HttpDetachModule_CONTEXT(ParsedHttpHdrs * httpreq) {
        FlushStrBuf(httpreq->PlainArgs);
        FlushStrBuf(httpreq->HostHeader);
        FlushStrBuf(httpreq->this_page);
@@ -877,10 +831,7 @@ HttpDetachModule_CONTEXT
        memset(&httpreq->HR, 0, sizeof(HdrRefs));
 }
 
-void 
-HttpDestroyModule_CONTEXT
-(ParsedHttpHdrs *httpreq)
-{
+void HttpDestroyModule_CONTEXT(ParsedHttpHdrs * httpreq) {
        FreeStrBuf(&httpreq->this_page);
        FreeStrBuf(&httpreq->PlainArgs);
        FreeStrBuf(&httpreq->this_page);
index dcdc6da1c0af0e1adea0ca51a117864b686d945b..111cacb7d51759d9198f28327a13e3b482b80929 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2012 by the citadel.org team
  *
  * the exact minute.  :)
  */
 static char *unset = "; expires=28-May-1971 18:10:00 GMT";
-typedef unsigned char byte;          /* Byte type used by cookie_to_stuff() */
+typedef unsigned char byte;    /* Byte type used by cookie_to_stuff() */
 extern const char *get_selected_language(void);
 
 /*
  * Pack all session info into one easy-to-digest cookie. Healthy and delicious!
  */
-void stuff_to_cookie(int unset_cookies)
-{
+void stuff_to_cookie(int unset_cookies) {
        wcsession *WCC = WC;
        char buf[SIZ];
 
        if (unset_cookies) {
                hprintf("Set-cookie: webcit=%s; path=/\r\n", unset);
        }
-       else
-       {
+       else {
                StrBufAppendPrintf(WCC->HBuf, "Set-cookie: webcit=");
                snprintf(buf, sizeof(buf), "%d", WCC->wc_session);
                StrBufHexescAppend(WCC->HBuf, NULL, buf);
@@ -48,13 +47,10 @@ void stuff_to_cookie(int unset_cookies)
                StrBufHexescAppend(WCC->HBuf, NULL, "|");
 
                if (server_cookie != NULL) {
-                       StrBufAppendPrintf(WCC->HBuf, 
-                                          ";path=/ \r\n%s\r\n", 
-                                          server_cookie);
+                       StrBufAppendPrintf(WCC->HBuf, ";path=/ \r\n%s\r\n", server_cookie);
                }
                else {
-                       StrBufAppendBufPlain(WCC->HBuf,
-                                            HKEY("; path=/\r\n"), 0);
+                       StrBufAppendBufPlain(WCC->HBuf, HKEY("; path=/\r\n"), 0);
                }
        }
 }
@@ -62,13 +58,7 @@ void stuff_to_cookie(int unset_cookies)
 /*
  * Extract all that fun stuff out of the cookie.
  */
-void cookie_to_stuff(StrBuf *cookie,
-                       int *session,
-                       StrBuf *user,
-                       StrBuf *pass,
-                       StrBuf *room,
-                       StrBuf *language)
-{
+void cookie_to_stuff(StrBuf * cookie, int *session, StrBuf * user, StrBuf * pass, StrBuf * room, StrBuf * language) {
        if (session != NULL) {
                *session = StrBufExtract_int(cookie, 0, '|');
        }
index 0a91289571e62850dca1d520d02233af6416a3d5..b4fa568b2a7a1ce7916169e0d95193cbea78cfd6 100644 (file)
@@ -52,7 +52,7 @@ void bind_to_key_and_certificate(void) {
        SSL_CTX_use_certificate_chain_file(new_ctx, cert_file);
        SSL_CTX_use_PrivateKey_file(new_ctx, key_file, SSL_FILETYPE_PEM);
 
-       if ( !SSL_CTX_check_private_key(new_ctx) ) {
+       if (!SSL_CTX_check_private_key(new_ctx)) {
                syslog(LOG_WARNING, "crypto: cannot install certificate: %s", ERR_reason_error_string(ERR_get_error()));
        }
 
@@ -106,21 +106,21 @@ int starttls(int sock) {
 
        // Check the modification time of the key and certificate -- reload if they changed
        update_key_and_cert_if_needed();
-       
+
        // SSL is a thread-specific thing, I think.
        pthread_setspecific(ThreadSSL, NULL);
 
        if (!ssl_ctx) {
-               return(1);
+               return (1);
        }
        if (!(newssl = SSL_new(ssl_ctx))) {
                syslog(LOG_WARNING, "SSL_new failed: %s", ERR_reason_error_string(ERR_get_error()));
-               return(2);
+               return (2);
        }
        if (!(SSL_set_fd(newssl, sock))) {
                syslog(LOG_WARNING, "SSL_set_fd failed: %s", ERR_reason_error_string(ERR_get_error()));
                SSL_free(newssl);
-               return(3);
+               return (3);
        }
        retval = SSL_accept(newssl);
        if (retval < 1) {
@@ -145,13 +145,12 @@ int starttls(int sock) {
        BIO_set_close(SSL_get_rbio(newssl), BIO_NOCLOSE);
        bits = SSL_CIPHER_get_bits(SSL_get_current_cipher(newssl), &alg_bits);
        syslog(LOG_INFO, "SSL/TLS using %s on %s (%d of %d bits)",
-               SSL_CIPHER_get_name(SSL_get_current_cipher(newssl)),
-               SSL_CIPHER_get_version(SSL_get_current_cipher(newssl)),
-               bits, alg_bits);
+              SSL_CIPHER_get_name(SSL_get_current_cipher(newssl)),
+              SSL_CIPHER_get_version(SSL_get_current_cipher(newssl)), bits, alg_bits);
 
        pthread_setspecific(ThreadSSL, newssl);
        syslog(LOG_INFO, "SSL started");
-       return(0);
+       return (0);
 }
 
 
@@ -174,14 +173,15 @@ void endtls(void) {
 
 
 // Send binary data to the client encrypted.
-int client_write_ssl(const StrBuf *Buf) {
+int client_write_ssl(const StrBuf * Buf) {
        const char *buf;
        int retval;
        int nremain;
        long nbytes;
        char junk[1];
 
-       if (THREADSSL == NULL) return -1;
+       if (THREADSSL == NULL)
+               return -1;
 
        nbytes = nremain = StrLength(Buf);
        buf = ChrPtr(Buf);
@@ -215,13 +215,14 @@ int client_write_ssl(const StrBuf *Buf) {
 
 
 // read data from the encrypted layer.
-int client_read_sslbuffer(StrBuf *buf, int timeout) {
+int client_read_sslbuffer(StrBuf * buf, int timeout) {
        char sbuf[16384];       // OpenSSL communicates in 16k blocks, so let's speak its native tongue.
        int rlen;
        char junk[1];
        SSL *pssl = THREADSSL;
 
-       if (pssl == NULL) return(-1);
+       if (pssl == NULL)
+               return (-1);
 
        while (1) {
                if (SSL_want_read(pssl)) {
index 3426c81cde61d30dfc652a4d0eac5a04b70c40d6..4a0e411d923d4cf6e34de445354ce81e28a3e2ee 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2013 by the citadel.org team
  *
@@ -38,10 +39,6 @@ void euid_unescapize(char *, const char *);
 void dav_identify_host(void);
 void dav_identify_hosthdr(void);
 
-void RegisterDAVNamespace(const char * UrlString, 
-                         long UrlSLen, 
-                         const char *DisplayName, 
-                         long dslen, 
-                         WebcitHandlerFunc F, 
-                         WebcitRESTDispatchID RID,
-                         long Flags);
+void RegisterDAVNamespace(const char *UrlString,
+                         long UrlSLen,
+                         const char *DisplayName, long dslen, WebcitHandlerFunc F, WebcitRESTDispatchID RID, long Flags);
index 6abd8ce8e787b5f26c887624832b62e9dc88fb84..afaae9a067aaabd389c216eaa482e864fe5f3f6d 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Handles GroupDAV DELETE requests.
  *
 /*
  * The pathname is always going to be /groupdav/room_name/euid
  */
-void dav_delete(void) 
-{
+void dav_delete(void) {
        wcsession *WCC = WC;
        char dav_uid[SIZ];
        long dav_msgnum = (-1);
        char buf[SIZ];
        int n = 0;
        StrBuf *dav_roomname = NewStrBuf();
-       
+
        /* Now extract the message euid */
        n = StrBufNum_tokens(WCC->Hdr->HR.ReqLine, '/');
-       extract_token(dav_uid, ChrPtr(WCC->Hdr->HR.ReqLine), n-1, '/', sizeof dav_uid);
+       extract_token(dav_uid, ChrPtr(WCC->Hdr->HR.ReqLine), n - 1, '/', sizeof dav_uid);
        StrBufExtract_token(dav_roomname, WCC->Hdr->HR.ReqLine, 0, '/');
 
        ///* What's left is the room name.  Remove trailing slashes. */
        //len = StrLength(WCC->Hdr->HR.ReqLine);
        //if ((len > 0) && (ChrPtr(WCC->Hdr->HR.ReqLinee)[len-1] == '/')) {
-       //      StrBufCutRight(WCC->Hdr->HR.ReqLine, 1);
+       //      StrBufCutRight(WCC->Hdr->HR.ReqLine, 1);
        //}
        //StrBufCutLeft(WCC->Hdr->HR.ReqLine, 1);
 
index 73f0c5514bbc2fd9a8e1e7d3fcbba2e88eaa6cbb..f52ed9c688c18b0eb2329f1bd437f1c969f43856 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Handles GroupDAV GET requests.
  *
@@ -20,7 +21,7 @@
 /*
  * Fetch the entire contents of the room as one big ics file.
  * This is for "webcal://" type access.
- */    
+ */
 void dav_get_big_ics(void) {
        char buf[1024];
 
@@ -31,9 +32,8 @@ void dav_get_big_ics(void) {
                dav_common_headers();
                hprintf("Content-Type: text/plain\r\n");
                begin_burst();
-               wc_printf("%s\r\n",
-                       &buf[4]
-                       );
+               wc_printf("%s\r\n", &buf[4]
+                   );
                end_burst();
                return;
        }
@@ -54,14 +54,13 @@ void dav_get_big_ics(void) {
  * Helps identify the relevant section of a multipart message
  */
 void extract_preferred(char *name, char *filename, char *partnum, char *disp,
-                       void *content, char *cbtype, char *cbcharset,
-                       size_t length, char *encoding, char *cbid, void *userdata)
-{
-       struct epdata *epdata = (struct epdata *)userdata;
+                      void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, char *cbid, void *userdata) {
+       struct epdata *epdata = (struct epdata *) userdata;
        int hit = 0;
 
        /* We only want the first one that we found */
-       if (!IsEmptyStr(epdata->found_section)) return;
+       if (!IsEmptyStr(epdata->found_section))
+               return;
 
        /* Check for a content type match */
        if (strlen(epdata->desired_content_type_1) > 0) {
@@ -95,8 +94,7 @@ void extract_preferred(char *name, char *filename, char *partnum, char *disp,
  * /groupdav/room_name/euid    (GroupDAV)
  * /groupdav/room_name         (webcal)
  */
-void dav_get(void)
-{
+void dav_get(void) {
        wcsession *WCC = WC;
        StrBuf *dav_roomname;
        StrBuf *dav_uid;
@@ -127,8 +125,7 @@ void dav_get(void)
        dav_uid = NewStrBuf();;
        StrBufExtract_token(dav_roomname, WCC->Hdr->HR.ReqLine, 0, '/');
        StrBufExtract_token(dav_uid, WCC->Hdr->HR.ReqLine, 1, '/');
-       if ((!strcasecmp(ChrPtr(dav_uid), "ics")) || 
-           (!strcasecmp(ChrPtr(dav_uid), "calendar.ics"))) {
+       if ((!strcasecmp(ChrPtr(dav_uid), "ics")) || (!strcasecmp(ChrPtr(dav_uid), "calendar.ics"))) {
                FlushStrBuf(dav_uid);
        }
 
@@ -140,8 +137,7 @@ void dav_get(void)
                hprintf("HTTP/1.1 404 not found\r\n");
                dav_common_headers();
                hprintf("Content-Type: text/plain\r\n");
-               wc_printf("There is no folder called \"%s\" on this server.\r\n",
-                       ChrPtr(dav_roomname));
+               wc_printf("There is no folder called \"%s\" on this server.\r\n", ChrPtr(dav_roomname));
                end_burst();
                FreeStrBuf(&dav_roomname);
                FreeStrBuf(&dav_uid);
@@ -164,9 +160,7 @@ void dav_get(void)
                hprintf("HTTP/1.1 404 not found\r\n");
                dav_common_headers();
                hprintf("Content-Type: text/plain\r\n");
-               wc_printf("Object \"%s\" was not found in the \"%s\" folder.\r\n",
-                       ChrPtr(dav_uid),
-                       ChrPtr(dav_roomname));
+               wc_printf("Object \"%s\" was not found in the \"%s\" folder.\r\n", ChrPtr(dav_uid), ChrPtr(dav_roomname));
                end_burst();
                FreeStrBuf(&dav_roomname);
                FreeStrBuf(&dav_uid);
@@ -186,7 +180,7 @@ void dav_get(void)
 
                /* Append it to the buffer */
                if ((msglen + linelen + 3) > msgalloc) {
-                       msgalloc = ( (msgalloc > 0) ? (msgalloc * 2) : 1024 );
+                       msgalloc = ((msgalloc > 0) ? (msgalloc * 2) : 1024);
                        msgtext = realloc(msgtext, msgalloc);
                }
                strcpy(&msgtext[msglen], buf);
@@ -208,13 +202,15 @@ void dav_get(void)
                                striplt(content_type);
                                ptr = bmstrcasestr(&buf[13], "charset=");
                                if (ptr) {
-                                       safestrncpy(charset, ptr+8, sizeof charset);
+                                       safestrncpy(charset, ptr + 8, sizeof charset);
                                        striplt(charset);
                                        endptr = strchr(charset, ';');
-                                       if (endptr != NULL) strcpy(endptr, "");
+                                       if (endptr != NULL)
+                                               strcpy(endptr, "");
                                }
                                endptr = strchr(content_type, ';');
-                               if (endptr != NULL) strcpy(endptr, "");
+                               if (endptr != NULL)
+                                       strcpy(endptr, "");
                        }
                }
        }
@@ -235,7 +231,7 @@ void dav_get(void)
         */
        if (!strncasecmp(content_type, "multipart/", 10)) {
 
-               if ( (WCC->CurRoom.defview == VIEW_CALENDAR) || (WCC->CurRoom.defview == VIEW_TASKS) ) {
+               if ((WCC->CurRoom.defview == VIEW_CALENDAR) || (WCC->CurRoom.defview == VIEW_TASKS)) {
                        strcpy(epdata.desired_content_type_1, "text/calendar");
                }
 
@@ -244,7 +240,7 @@ void dav_get(void)
                        strcpy(epdata.desired_content_type_2, "text/x-vcard");
                }
 
-               mime_parser(msgtext, &msgtext[msglen], extract_preferred, NULL, NULL, (void *)&epdata, 0);
+               mime_parser(msgtext, &msgtext[msglen], extract_preferred, NULL, NULL, (void *) &epdata, 0);
        }
 
        /* If epdata.found_section is empty, we haven't output anything yet, so output the whole thing */
@@ -252,13 +248,13 @@ void dav_get(void)
        if (IsEmptyStr(epdata.found_section)) {
                ptr = msgtext;
                endptr = &msgtext[msglen];
-       
+
                hprintf("Content-type: %s; charset=%s\r\n", content_type, charset);
-       
+
                in_body = 0;
                do {
                        ptr = memreadline(ptr, buf, sizeof buf);
-       
+
                        if (in_body) {
                                wc_printf("%s\r\n", buf);
                        }
@@ -267,7 +263,7 @@ void dav_get(void)
                                begin_burst();
                        }
                } while (ptr < endptr);
-       
+
                end_burst();
        }
 
index 31cbfafffe1399af58ecc6876a1404b7515c2374..7586dbc97e8f3f690bec2d924d0e4cc4c48a102c 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Entry point for GroupDAV functions
  *
@@ -30,11 +31,8 @@ HashList *DavNamespaces = NULL;
  *
  */
 void dav_common_headers(void) {
-       hprintf(
-               "Server: %s / %s\r\n"
-               "Connection: close\r\n",
-               PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
-       );
+       hprintf("Server: %s / %s\r\n" "Connection: close\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
+           );
 }
 
 
@@ -48,8 +46,8 @@ void euid_escapize(char *target, const char *source) {
 
        strcpy(target, "");
        len = strlen(source);
-       for (i=0; i<len; ++i) {
-               if ( (isalnum(source[i])) || (source[i]=='-') || (source[i]=='_') ) {
+       for (i = 0; i < len; ++i) {
+               if ((isalnum(source[i])) || (source[i] == '-') || (source[i] == '_')) {
                        target[target_length] = source[i];
                        target[++target_length] = 0;
                }
@@ -95,12 +93,11 @@ void euid_unescapize(char *target, const char *source) {
 /*
  * Main entry point for GroupDAV requests
  */
-void dav_main(void)
-{
+void dav_main(void) {
        wcsession *WCC = WC;
        int i, len;
 
-       syslog(LOG_DEBUG, "dav_main() called, logged_in=%d", WCC->logged_in );
+       syslog(LOG_DEBUG, "dav_main() called, logged_in=%d", WCC->logged_in);
 
        StrBufUnescape(WCC->Hdr->HR.ReqLine, 0);
        StrBufStripSlashes(WCC->Hdr->HR.ReqLine, 0);
@@ -114,8 +111,8 @@ void dav_main(void)
                StrBufTrim(WCC->Hdr->HR.dav_ifmatch);
                if (ChrPtr(WCC->Hdr->HR.dav_ifmatch)[0] == '\"') {
                        StrBufCutLeft(WCC->Hdr->HR.dav_ifmatch, 1);
-                       len --;
-                       for (i=0; i<len; ++i) {
+                       len--;
+                       for (i = 0; i < len; ++i) {
                                if (ChrPtr(WCC->Hdr->HR.dav_ifmatch)[i] == '\"') {
                                        StrBufCutAt(WCC->Hdr->HR.dav_ifmatch, i, NULL);
                                        len = StrLength(WCC->Hdr->HR.dav_ifmatch);
@@ -127,61 +124,59 @@ void dav_main(void)
                }
        }
 
-       switch (WCC->Hdr->HR.eReqType)
-       {
-       /*
-        * The OPTIONS method is not required by GroupDAV but it will be
-        * needed for future implementations of other DAV-based protocols.
-        */
+       switch (WCC->Hdr->HR.eReqType) {
+               /*
+                * The OPTIONS method is not required by GroupDAV but it will be
+                * needed for future implementations of other DAV-based protocols.
+                */
        case eOPTIONS:
                dav_options();
                break;
 
-       /*
-        * The PROPFIND method is basically used to list all objects in a
-        * room, or to list all relevant rooms on the server.
-        */
+               /*
+                * The PROPFIND method is basically used to list all objects in a
+                * room, or to list all relevant rooms on the server.
+                */
        case ePROPFIND:
                dav_propfind();
                break;
 
-       /*
-        * The GET method is used for fetching individual items.
-        */
+               /*
+                * The GET method is used for fetching individual items.
+                */
        case eGET:
                dav_get();
                break;
-       
-       /*
-        * The PUT method is used to add or modify items.
-        */
+
+               /*
+                * The PUT method is used to add or modify items.
+                */
        case ePUT:
                dav_put();
                break;
-       
-       /*
-        * The DELETE method kills, maims, and destroys.
-        */
+
+               /*
+                * The DELETE method kills, maims, and destroys.
+                */
        case eDELETE:
                dav_delete();
                break;
 
-       /*
-        * The REPORT method tells us that Mike Shaver is a self-righteous asshole.
-        */
+               /*
+                * The REPORT method tells us that Mike Shaver is a self-righteous asshole.
+                */
        case eREPORT:
                dav_report();
                break;
 
        default:
-       /*
-        * Couldn't find what we were looking for.  Die in a car fire.
-        */
+               /*
+                * Couldn't find what we were looking for.  Die in a car fire.
+                */
                hprintf("HTTP/1.1 501 Method not implemented\r\n");
                dav_common_headers();
                hprintf("Content-Type: text/plain\r\n");
-               wc_printf("GroupDAV method \"%s\" is not implemented.\r\n",
-                       ReqStrs[WCC->Hdr->HR.eReqType]);
+               wc_printf("GroupDAV method \"%s\" is not implemented.\r\n", ReqStrs[WCC->Hdr->HR.eReqType]);
                end_burst();
        }
 }
@@ -189,33 +184,30 @@ void dav_main(void)
 
 /*
  * Output our host prefix for globally absolute URL's.
- */  
+ */
 void dav_identify_host(void) {
        wc_printf("%s", ChrPtr(site_prefix));
 }
 
 
-void tmplput_dav_HOSTNAME(StrBuf *Target, WCTemplputParams *TP) 
-{
+void tmplput_dav_HOSTNAME(StrBuf * Target, WCTemplputParams * TP) {
        StrBufAppendPrintf(Target, "%s", ChrPtr(site_prefix));
 }
 
 /*
  * Output our host prefix for globally absolute URL's.
- */  
+ */
 void dav_identify_hosthdr(void) {
        hprintf("%s", ChrPtr(site_prefix));
 }
 
 
-void Header_HandleIfMatch(StrBuf *Line, ParsedHttpHdrs *hdr)
-{
+void Header_HandleIfMatch(StrBuf * Line, ParsedHttpHdrs * hdr) {
        hdr->HR.dav_ifmatch = Line;
 }
-       
 
-void Header_HandleDepth(StrBuf *Line, ParsedHttpHdrs *hdr)
-{
+
+void Header_HandleDepth(StrBuf * Line, ParsedHttpHdrs * hdr) {
        if (!strcasecmp(ChrPtr(Line), "infinity")) {
                hdr->HR.dav_depth = 32767;
        }
@@ -228,34 +220,27 @@ void Header_HandleDepth(StrBuf *Line, ParsedHttpHdrs *hdr)
 }
 
 
-int Conditional_DAV_DEPTH(StrBuf *Target, WCTemplputParams *TP)
-{
+int Conditional_DAV_DEPTH(StrBuf * Target, WCTemplputParams * TP) {
        return WC->Hdr->HR.dav_depth == GetTemplateTokenNumber(Target, TP, 2, 0);
 }
 
 
-void RegisterDAVNamespace(const char * UrlString, 
-                         long UrlSLen, 
-                         const char *DisplayName, 
-                         long dslen, 
-                         WebcitHandlerFunc F, 
-                         WebcitRESTDispatchID RID,
-                         long Flags)
-{
+void RegisterDAVNamespace(const char *UrlString,
+                         long UrlSLen,
+                         const char *DisplayName, long dslen, WebcitHandlerFunc F, WebcitRESTDispatchID RID, long Flags) {
        void *vHandler;
 
        /* first put it in... */
-       WebcitAddUrlHandler(UrlString, UrlSLen, DisplayName, dslen, F, Flags|PARSE_REST_URL);
+       WebcitAddUrlHandler(UrlString, UrlSLen, DisplayName, dslen, F, Flags | PARSE_REST_URL);
        /* get it out again... */
        GetHash(HandlerHash, UrlString, UrlSLen, &vHandler);
-       ((WebcitHandler*)vHandler)->RID = RID;
+       ((WebcitHandler *) vHandler)->RID = RID;
        /* and keep a copy of it, so we can compare it later */
        Put(DavNamespaces, UrlString, UrlSLen, vHandler, reference_free_handler);
 }
 
 
-int Conditional_DAV_NS(StrBuf *Target, WCTemplputParams *TP)
-{
+int Conditional_DAV_NS(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
        void *vHandler;
        const char *NS;
@@ -267,8 +252,7 @@ int Conditional_DAV_NS(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-int Conditional_DAV_NSCURRENT(StrBuf *Target, WCTemplputParams *TP)
-{
+int Conditional_DAV_NSCURRENT(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
        void *vHandler;
 
@@ -277,13 +261,12 @@ int Conditional_DAV_NSCURRENT(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void tmplput_DAV_NAMESPACE(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_DAV_NAMESPACE(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
        if (TP->Filter.ContextType == CTX_DAVNS) {
                WebcitHandler *H;
-               H = (WebcitHandler*) CTX(CTX_DAVNS);
+               H = (WebcitHandler *) CTX(CTX_DAVNS);
                if (H != NULL)
                        StrBufAppendTemplate(Target, TP, H->Name, 0);
        }
@@ -293,15 +276,14 @@ void tmplput_DAV_NAMESPACE(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-int GroupdavDispatchREST(RESTDispatchID WhichAction, int IgnoreFloor)
-{
+int GroupdavDispatchREST(RESTDispatchID WhichAction, int IgnoreFloor) {
        wcsession *WCC = WC;
        void *vDir;
-       
-       switch(WhichAction){
+
+       switch (WhichAction) {
        case ExistsID:
                GetHash(WCC->Directory, IKEY(WCC->ThisRoom->nRoomNameParts + 1), &vDir);
-               return locate_message_by_uid(ChrPtr((StrBuf*)vDir)) != -1;
+               return locate_message_by_uid(ChrPtr((StrBuf *) vDir)) != -1;
                /* TODO: remember euid */
        case PutID:
        case DeleteID:
@@ -313,45 +295,32 @@ int GroupdavDispatchREST(RESTDispatchID WhichAction, int IgnoreFloor)
 }
 
 
-void
-ServerStartModule_DAV
-(void)
-{
+void ServerStartModule_DAV(void) {
 
        DavNamespaces = NewHash(1, NULL);
 }
 
 
-void 
-ServerShutdownModule_DAV
-(void)
-{
+void ServerShutdownModule_DAV(void) {
        DeleteHash(&DavNamespaces);
 }
 
 
-void 
-InitModule_GROUPDAV
-(void)
-{
+void InitModule_GROUPDAV(void) {
        RegisterCTX(CTX_DAVNS);
-       RegisterDAVNamespace(HKEY("groupdav"), HKEY("GroupDAV"), 
-                            dav_main, GroupdavDispatchREST, 
-                            XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE
-       );
+       RegisterDAVNamespace(HKEY("groupdav"), HKEY("GroupDAV"),
+                            dav_main, GroupdavDispatchREST, XHTTP_COMMANDS | COOKIEUNNEEDED | FORCE_SESSIONCLOSE);
 
        RegisterNamespace("DAV:HOSTNAME", 0, 0, tmplput_dav_HOSTNAME, NULL, CTX_NONE);
 
-       RegisterConditional("COND:DAV:NS", 0, Conditional_DAV_NS,  CTX_NONE);
+       RegisterConditional("COND:DAV:NS", 0, Conditional_DAV_NS, CTX_NONE);
 
-       RegisterIterator("DAV:NS", 0, DavNamespaces, NULL, 
-                        NULL, NULL, CTX_DAVNS, CTX_NONE, IT_NOFLAG
-       );
+       RegisterIterator("DAV:NS", 0, DavNamespaces, NULL, NULL, NULL, CTX_DAVNS, CTX_NONE, IT_NOFLAG);
 
-       RegisterConditional("COND:DAV:NSCURRENT", 0, Conditional_DAV_NSCURRENT,  CTX_DAVNS);
+       RegisterConditional("COND:DAV:NSCURRENT", 0, Conditional_DAV_NSCURRENT, CTX_DAVNS);
        RegisterNamespace("DAV:NAMESPACE", 0, 1, tmplput_DAV_NAMESPACE, NULL, CTX_NONE);
 
        RegisterHeaderHandler(HKEY("IF-MATCH"), Header_HandleIfMatch);
        RegisterHeaderHandler(HKEY("DEPTH"), Header_HandleDepth);
-       RegisterConditional("COND:DAV:DEPTH", 1, Conditional_DAV_DEPTH,  CTX_NONE);
+       RegisterConditional("COND:DAV:DEPTH", 1, Conditional_DAV_DEPTH, CTX_NONE);
 }
index f7687cf4ef347269c42029f79c50eb181e69c90f..8e8e85865cdfcf8d4829137203f21838e11663cf 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Handles DAV OPTIONS requests (experimental -- not required by GroupDAV)
  *
@@ -19,8 +20,7 @@
 /*
  * The pathname is always going to be /groupdav/room_name/msg_num
  */
-void dav_options(void)
-{
+void dav_options(void) {
        wcsession *WCC = WC;
        StrBuf *dav_roomname;
        StrBuf *dav_uid;
@@ -65,13 +65,10 @@ void dav_options(void)
                hprintf("HTTP/1.1 404 not found\r\n");
                dav_common_headers();
                hprintf("Date: %s\r\n", datestring);
-               hprintf(
-                       "Content-Type: text/plain\r\n");
+               hprintf("Content-Type: text/plain\r\n");
                begin_burst();
-               wc_printf(
-                       "There is no folder called \"%s\" on this server.\r\n",
-                       ChrPtr(dav_roomname)
-               );
+               wc_printf("There is no folder called \"%s\" on this server.\r\n", ChrPtr(dav_roomname)
+                   );
                end_burst();
                FreeStrBuf(&dav_roomname);
                FreeStrBuf(&dav_uid);
@@ -89,14 +86,12 @@ void dav_options(void)
                        dav_common_headers();
                        hprintf("Content-Type: text/plain\r\n");
                        begin_burst();
-                       wc_printf(
-                               "Object \"%s\" was not found in the \"%s\" folder.\r\n",
-                               ChrPtr(dav_uid),
-                               ChrPtr(dav_roomname)
-                       );
+                       wc_printf("Object \"%s\" was not found in the \"%s\" folder.\r\n", ChrPtr(dav_uid), ChrPtr(dav_roomname)
+                           );
                        FreeStrBuf(&dav_roomname);
                        FreeStrBuf(&dav_uid);
-                       end_burst();return;
+                       end_burst();
+                       return;
                }
 
                hprintf("HTTP/1.1 200 OK\r\n");
@@ -104,7 +99,7 @@ void dav_options(void)
                hprintf("Date: %s\r\n", datestring);
                hprintf("DAV: 1\r\n");
                hprintf("Allow: OPTIONS, PROPFIND, GET, PUT, DELETE\r\n");
-               
+
                begin_burst();
                end_burst();
                FreeStrBuf(&dav_roomname);
@@ -120,9 +115,8 @@ void dav_options(void)
         * an OPTIONS on the room itself.
         */
        syslog(LOG_DEBUG, "\033[36mOPTIONS requested for room '%s' (%slogged in)\033[0m",
-               ChrPtr(WC->CurRoom.name),
-               ((WC->logged_in) ? "" : "not ")
-       );
+              ChrPtr(WC->CurRoom.name), ((WC->logged_in) ? "" : "not ")
+           );
        hprintf("HTTP/1.1 200 OK\r\n");
        dav_common_headers();
        hprintf("Date: %s\r\n", datestring);
@@ -130,7 +124,7 @@ void dav_options(void)
        /*
         * Offer CalDAV (RFC 4791) if this is a calendar room
         */
-       if ( (WC->CurRoom.view == VIEW_CALENDAR) || (WC->CurRoom.view == VIEW_CALBRIEF) ) {
+       if ((WC->CurRoom.view == VIEW_CALENDAR) || (WC->CurRoom.view == VIEW_CALBRIEF)) {
                hprintf("DAV: 1, calendar-access\r\n");
                syslog(LOG_DEBUG, "\033[36mDAV: 1, calendar-access\033[0m");
        }
index 76df63d21f35607f5abe38bd97d56d9fb7e385fc..61e7e71c72bc756600694ac450449da923fddab7 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Handles GroupDAV and CalDAV PROPFIND requests.
  *
@@ -51,7 +52,7 @@ long locate_message_by_uid(const char *uid) {
                retval = atol(&buf[4]);
        }
 
-       return(retval);
+       return (retval);
 }
 
 
@@ -59,19 +60,18 @@ long locate_message_by_uid(const char *uid) {
  * IgnoreFloor: set to 0 or 1 _nothing else_
  * Subfolders: direct child floors will be put here.
  */
-const folder *GetRESTFolder(int IgnoreFloor, HashList *Subfolders)
-{
-       wcsession  *WCC = WC;
+const folder *GetRESTFolder(int IgnoreFloor, HashList * Subfolders) {
+       wcsession *WCC = WC;
        void *vFolder;
        const folder *ThisFolder = NULL;
        const folder *FoundFolder = NULL;
        const folder *BestGuess = NULL;
        int nBestGuess = 0;
-       HashPos    *itd, *itfl;
-       StrBuf     * Dir;
-       void       *vDir;
-       long        len;
-        const char *Key;
+       HashPos *itd, *itfl;
+       StrBuf *Dir;
+       void *vDir;
+       long len;
+       const char *Key;
        int iRoom, jURL, urlp;
        int delta;
 
@@ -83,86 +83,69 @@ const folder *GetRESTFolder(int IgnoreFloor, HashList *Subfolders)
        itfl = GetNewHashPos(WCC->Floors, 0);
        urlp = GetCount(WCC->Directory);
 
-       while (GetNextHashPos(WCC->Floors, itfl, &len, &Key, &vFolder) && 
-              (ThisFolder == NULL))
-       {
+       while (GetNextHashPos(WCC->Floors, itfl, &len, &Key, &vFolder) && (ThisFolder == NULL)) {
                ThisFolder = vFolder;
-               if (!IgnoreFloor && /* so we can handle legacy URLS... */
+               if (!IgnoreFloor &&     /* so we can handle legacy URLS... */
                    (ThisFolder->Floor != WCC->CurrentFloor))
                        continue;
 
-               if (ThisFolder->nRoomNameParts > 1) 
-               {
+               if (ThisFolder->nRoomNameParts > 1) {
                        /*TODO: is that number all right? */
-//                     if (urlp - ThisFolder->nRoomNameParts != 2) {
-//                             if (BestGuess != NULL)
-//                                     continue;
+//                      if (urlp - ThisFolder->nRoomNameParts != 2) {
+//                              if (BestGuess != NULL)
+//                                      continue;
 //ThisFolder->name
-//                             itd  = GetNewHashPos(WCC->Directory, 0);
-//                             GetNextHashPos(WCC->Directory, itd, &len, &Key, &vDir); //TODO: how many to fast forward?
-//                     }
-                       itd  = GetNewHashPos(WCC->Directory, 0);
-                       GetNextHashPos(WCC->Directory, itd, &len, &Key, &vDir); //TODO: how many to fast forward?
-       
-                       for (iRoom = 0, /* Fast forward the floorname as we checked it above: */ jURL = IgnoreFloor; 
-
-                            (iRoom <= ThisFolder->nRoomNameParts) && (jURL <= urlp); 
-
-                            iRoom++, jURL++, GetNextHashPos(WCC->Directory, itd, &len, &Key, &vDir))
-                       {
-                               Dir = (StrBuf*)vDir;
-                               if (strcmp(ChrPtr(ThisFolder->RoomNameParts[iRoom]), 
-                                          ChrPtr(Dir)) != 0)
-                               {
+//                              itd  = GetNewHashPos(WCC->Directory, 0);
+//                              GetNextHashPos(WCC->Directory, itd, &len, &Key, &vDir); //TODO: how many to fast forward?
+//                      }
+                       itd = GetNewHashPos(WCC->Directory, 0);
+                       GetNextHashPos(WCC->Directory, itd, &len, &Key, &vDir); //TODO: how many to fast forward?
+
+                       for (iRoom = 0, /* Fast forward the floorname as we checked it above: */ jURL = IgnoreFloor;
+                            (iRoom <= ThisFolder->nRoomNameParts) && (jURL <= urlp);
+                            iRoom++, jURL++, GetNextHashPos(WCC->Directory, itd, &len, &Key, &vDir)) {
+                               Dir = (StrBuf *) vDir;
+                               if (strcmp(ChrPtr(ThisFolder->RoomNameParts[iRoom]), ChrPtr(Dir)) != 0) {
                                        DeleteHashPos(&itd);
                                        continue;
                                }
                        }
                        DeleteHashPos(&itd);
                        /* Gotcha? */
-                       if ((iRoom == ThisFolder->nRoomNameParts) && (jURL == urlp))
-                       {
+                       if ((iRoom == ThisFolder->nRoomNameParts) && (jURL == urlp)) {
                                FoundFolder = ThisFolder;
                        }
-                       /* URL got more parts then this room, so we remember it for the best guess*/
-                       else if ((jURL <= urlp) &&
-                                (ThisFolder->nRoomNameParts <= nBestGuess))
-                       {
+                       /* URL got more parts then this room, so we remember it for the best guess */
+                       else if ((jURL <= urlp) && (ThisFolder->nRoomNameParts <= nBestGuess)) {
                                BestGuess = ThisFolder;
                                nBestGuess = jURL - 1;
                        }
                        /* Room has more parts than the URL, it might be a sub-room? */
-                       else if (iRoom <ThisFolder->nRoomNameParts) 
-                       {//// TODO: ThisFolder->nRoomNameParts == urlp - IgnoreFloor???
-                               Put(Subfolders, SKEY(ThisFolder->name), 
+                       else if (iRoom < ThisFolder->nRoomNameParts) {  //// TODO: ThisFolder->nRoomNameParts == urlp - IgnoreFloor???
+                               Put(Subfolders, SKEY(ThisFolder->name),
                                    /* Cast away const, its a reference. */
-                                   (void*)ThisFolder, reference_free_handler);
+                                   (void *) ThisFolder, reference_free_handler);
                        }
                }
                else {
                        delta = GetCount(WCC->Directory) - ThisFolder->nRoomNameParts;
                        if ((delta != 2) && (nBestGuess > 1))
-                           continue;
-                       
-                       itd  = GetNewHashPos(WCC->Directory, 0);
-                                               
-                       if (!GetNextHashPos(WCC->Directory, 
-                                           itd, &len, &Key, &vDir) ||
-                           (vDir == NULL))
-                       {
+                               continue;
+
+                       itd = GetNewHashPos(WCC->Directory, 0);
+
+                       if (!GetNextHashPos(WCC->Directory, itd, &len, &Key, &vDir) || (vDir == NULL)) {
                                DeleteHashPos(&itd);
-                               
+
                                syslog(LOG_DEBUG, "5\n");
                                continue;
                        }
                        DeleteHashPos(&itd);
-                       Dir = (StrBuf*) vDir;
-                       if (strcmp(ChrPtr(ThisFolder->name), 
-                                              ChrPtr(Dir))
-                           != 0)
-                       {
+                       Dir = (StrBuf *) vDir;
+                       if (strcmp(ChrPtr(ThisFolder->name), ChrPtr(Dir))
+                           != 0) {
                                DeleteHashPos(&itd);
-                               
+
                                syslog(LOG_DEBUG, "5\n");
                                continue;
                        }
@@ -172,7 +155,7 @@ const folder *GetRESTFolder(int IgnoreFloor, HashList *Subfolders)
                                nBestGuess = 1;
                                BestGuess = ThisFolder;
                        }
-                       else 
+                       else
                                FoundFolder = ThisFolder;
                }
        }
@@ -188,9 +171,8 @@ const folder *GetRESTFolder(int IgnoreFloor, HashList *Subfolders)
 
 
 
-long GotoRestRoom(HashList *SubRooms)
-{
-       int IgnoreFloor = 0; /* deprecated... */
+long GotoRestRoom(HashList * SubRooms) {
+       int IgnoreFloor = 0;    /* deprecated... */
        wcsession *WCC = WC;
        long Count;
        long State;
@@ -198,44 +180,42 @@ long GotoRestRoom(HashList *SubRooms)
 
        State = REST_TOPLEVEL;
 
-       if (WCC->Hdr->HR.Handler != NULL) 
+       if (WCC->Hdr->HR.Handler != NULL)
                State |= REST_IN_NAMESPACE;
 
        Count = GetCount(WCC->Directory);
-       
-       if (Count == 0) return State;
 
-       if (Count >= 1) State |=REST_IN_FLOOR;
-       if (Count == 1) return State;
-       
+       if (Count == 0)
+               return State;
+
+       if (Count >= 1)
+               State |= REST_IN_FLOOR;
+       if (Count == 1)
+               return State;
+
        /* 
         * More than 3 params and no floor found? 
         * -> fall back to old non-floored notation
         */
        if ((Count >= 3) && (WCC->CurrentFloor == NULL))
                IgnoreFloor = 1;
-       if (Count >= 3)
-       {
+       if (Count >= 3) {
                IgnoreFloor = 0;
                State |= REST_IN_FLOOR;
 
                ThisFolder = GetRESTFolder(IgnoreFloor, SubRooms);
-               if (ThisFolder != NULL)
-               {
+               if (ThisFolder != NULL) {
                        if (WCC->ThisRoom != NULL)
                                if (CompareRooms(WCC->ThisRoom, ThisFolder) != 0)
                                        gotoroom(ThisFolder->name);
                        State |= REST_IN_ROOM;
-                       
+
                }
                if (GetCount(SubRooms) > 0)
                        State |= REST_HAVE_SUB_ROOMS;
        }
-       if ((WCC->ThisRoom != NULL) && 
-           (Count + IgnoreFloor > 3))
-       {
-               if (WCC->Hdr->HR.Handler->RID(ExistsID, IgnoreFloor))
-               {
+       if ((WCC->ThisRoom != NULL) && (Count + IgnoreFloor > 3)) {
+               if (WCC->Hdr->HR.Handler->RID(ExistsID, IgnoreFloor)) {
                        State |= REST_GOT_LOCAL_PART;
                }
                else {
@@ -254,8 +234,7 @@ long GotoRestRoom(HashList *SubRooms)
  * List rooms (or "collections" in DAV terminology) which contain
  * interesting groupware objects.
  */
-void dav_collection_list(void)
-{
+void dav_collection_list(void) {
        wcsession *WCC = WC;
        char buf[256];
        char roomname[256];
@@ -264,6 +243,7 @@ void dav_collection_list(void)
        time_t now;
        time_t mtime;
        int is_groupware_collection = 0;
+
        int starting_point = 1;         /**< 0 for /, 1 for /groupdav/ */
 
        if (WCC->Hdr->HR.Handler == NULL) {
@@ -287,34 +267,32 @@ void dav_collection_list(void)
        dav_common_headers();
        hprintf("Date: %s\r\n", datestring);
        hprintf("Content-type: text/xml\r\n");
-       if (DisableGzip || (!WCC->Hdr->HR.gzip_ok))     
+       if (DisableGzip || (!WCC->Hdr->HR.gzip_ok))
                hprintf("Content-encoding: identity\r\n");
 
        begin_burst();
 
-       wc_printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
-               "<multistatus xmlns=\"DAV:\" xmlns:G=\"http://groupdav.org/\">"
-       );
+       wc_printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>" "<multistatus xmlns=\"DAV:\" xmlns:G=\"http://groupdav.org/\">");
 
        /*
         * If the client is requesting the root, show a root node.
         */
        if (starting_point == 0) {
                wc_printf("<response>");
-                       wc_printf("<href>");
-                               dav_identify_host();
-                               wc_printf("/");
-                       wc_printf("</href>");
-                       wc_printf("<propstat>");
-                               wc_printf("<status>HTTP/1.1 200 OK</status>");
-                               wc_printf("<prop>");
-                                       wc_printf("<displayname>/</displayname>");
-                                       wc_printf("<resourcetype><collection/></resourcetype>");
-                                       wc_printf("<getlastmodified>");
-                                               escputs(datestring);
-                                       wc_printf("</getlastmodified>");
-                               wc_printf("</prop>");
-                       wc_printf("</propstat>");
+               wc_printf("<href>");
+               dav_identify_host();
+               wc_printf("/");
+               wc_printf("</href>");
+               wc_printf("<propstat>");
+               wc_printf("<status>HTTP/1.1 200 OK</status>");
+               wc_printf("<prop>");
+               wc_printf("<displayname>/</displayname>");
+               wc_printf("<resourcetype><collection/></resourcetype>");
+               wc_printf("<getlastmodified>");
+               escputs(datestring);
+               wc_printf("</getlastmodified>");
+               wc_printf("</prop>");
+               wc_printf("</propstat>");
                wc_printf("</response>");
        }
 
@@ -323,20 +301,20 @@ void dav_collection_list(void)
         */
        if ((starting_point + WCC->Hdr->HR.dav_depth) >= 1) {
                wc_printf("<response>");
-                       wc_printf("<href>");
-                               dav_identify_host();
-                               wc_printf("/groupdav");
-                       wc_printf("</href>");
-                       wc_printf("<propstat>");
-                               wc_printf("<status>HTTP/1.1 200 OK</status>");
-                               wc_printf("<prop>");
-                                       wc_printf("<displayname>GroupDAV</displayname>");
-                                       wc_printf("<resourcetype><collection/></resourcetype>");
-                                       wc_printf("<getlastmodified>");
-                                               escputs(datestring);
-                                       wc_printf("</getlastmodified>");
-                               wc_printf("</prop>");
-                       wc_printf("</propstat>");
+               wc_printf("<href>");
+               dav_identify_host();
+               wc_printf("/groupdav");
+               wc_printf("</href>");
+               wc_printf("<propstat>");
+               wc_printf("<status>HTTP/1.1 200 OK</status>");
+               wc_printf("<prop>");
+               wc_printf("<displayname>GroupDAV</displayname>");
+               wc_printf("<resourcetype><collection/></resourcetype>");
+               wc_printf("<getlastmodified>");
+               escputs(datestring);
+               wc_printf("</getlastmodified>");
+               wc_printf("</prop>");
+               wc_printf("</propstat>");
                wc_printf("</response>");
        }
 
@@ -345,84 +323,82 @@ void dav_collection_list(void)
         */
        serv_puts("LKRA");
        serv_getln(buf, sizeof buf);
-       if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-
-               extract_token(roomname, buf, 0, '|', sizeof roomname);
-               view = extract_int(buf, 7);
-               mtime = extract_long(buf, 8);
-               http_datestring(datestring, sizeof datestring, mtime);
-
-               /*
-                * For now, only list rooms that we know a GroupDAV client
-                * might be interested in.  In the future we may add
-                * the rest.
-                *
-                * We determine the type of objects which are stored in each
-                * room by looking at the *default* view for the room.  This
-                * allows, for example, a Calendar room to appear as a
-                * GroupDAV calendar even if the user has switched it to a
-                * Calendar List view.
-                */
-               if (    (view == VIEW_CALENDAR) || 
-                       (view == VIEW_TASKS) || 
-                       (view == VIEW_ADDRESSBOOK) ||
-                       (view == VIEW_NOTES) ||
-                       (view == VIEW_JOURNAL) ||
-                       (view == VIEW_WIKI)
-               ) {
-                       is_groupware_collection = 1;
-               }
-               else {
-                       is_groupware_collection = 0;
-               }
-
-               if ( (is_groupware_collection) && ((starting_point + WCC->Hdr->HR.dav_depth) >= 2) ) {
-                       wc_printf("<response>");
-
-                       wc_printf("<href>");
-                       dav_identify_host();
-                       wc_printf("/groupdav/");
-                       urlescputs(roomname);
-                       wc_printf("/</href>");
-
-                       wc_printf("<propstat>");
-                       wc_printf("<status>HTTP/1.1 200 OK</status>");
-                       wc_printf("<prop>");
-                       wc_printf("<displayname>");
-                       escputs(roomname);
-                       wc_printf("</displayname>");
-                       wc_printf("<resourcetype><collection/>");
-
-                       switch(view) {
-                       case VIEW_CALENDAR:
-                               wc_printf("<G:vevent-collection />");
-                               break;
-                       case VIEW_TASKS:
-                               wc_printf("<G:vtodo-collection />");
-                               break;
-                       case VIEW_ADDRESSBOOK:
-                               wc_printf("<G:vcard-collection />");
-                               break;
-                       case VIEW_NOTES:
-                               wc_printf("<G:vnotes-collection />");
-                               break;
-                       case VIEW_JOURNAL:
-                               wc_printf("<G:vjournal-collection />");
-                               break;
-                       case VIEW_WIKI:
-                               wc_printf("<G:wiki-collection />");
-                               break;
+       if (buf[0] == '1')
+               while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+
+                       extract_token(roomname, buf, 0, '|', sizeof roomname);
+                       view = extract_int(buf, 7);
+                       mtime = extract_long(buf, 8);
+                       http_datestring(datestring, sizeof datestring, mtime);
+
+                       /*
+                        * For now, only list rooms that we know a GroupDAV client
+                        * might be interested in.  In the future we may add
+                        * the rest.
+                        *
+                        * We determine the type of objects which are stored in each
+                        * room by looking at the *default* view for the room.  This
+                        * allows, for example, a Calendar room to appear as a
+                        * GroupDAV calendar even if the user has switched it to a
+                        * Calendar List view.
+                        */
+                       if ((view == VIEW_CALENDAR) ||
+                           (view == VIEW_TASKS) ||
+                           (view == VIEW_ADDRESSBOOK) || (view == VIEW_NOTES) || (view == VIEW_JOURNAL) || (view == VIEW_WIKI)
+                           ) {
+                               is_groupware_collection = 1;
                        }
+                       else {
+                               is_groupware_collection = 0;
+                       }
+
+                       if ((is_groupware_collection) && ((starting_point + WCC->Hdr->HR.dav_depth) >= 2)) {
+                               wc_printf("<response>");
 
-                       wc_printf("</resourcetype>");
-                       wc_printf("<getlastmodified>");
+                               wc_printf("<href>");
+                               dav_identify_host();
+                               wc_printf("/groupdav/");
+                               urlescputs(roomname);
+                               wc_printf("/</href>");
+
+                               wc_printf("<propstat>");
+                               wc_printf("<status>HTTP/1.1 200 OK</status>");
+                               wc_printf("<prop>");
+                               wc_printf("<displayname>");
+                               escputs(roomname);
+                               wc_printf("</displayname>");
+                               wc_printf("<resourcetype><collection/>");
+
+                               switch (view) {
+                               case VIEW_CALENDAR:
+                                       wc_printf("<G:vevent-collection />");
+                                       break;
+                               case VIEW_TASKS:
+                                       wc_printf("<G:vtodo-collection />");
+                                       break;
+                               case VIEW_ADDRESSBOOK:
+                                       wc_printf("<G:vcard-collection />");
+                                       break;
+                               case VIEW_NOTES:
+                                       wc_printf("<G:vnotes-collection />");
+                                       break;
+                               case VIEW_JOURNAL:
+                                       wc_printf("<G:vjournal-collection />");
+                                       break;
+                               case VIEW_WIKI:
+                                       wc_printf("<G:wiki-collection />");
+                                       break;
+                               }
+
+                               wc_printf("</resourcetype>");
+                               wc_printf("<getlastmodified>");
                                escputs(datestring);
-                       wc_printf("</getlastmodified>");
-                       wc_printf("</prop>");
-                       wc_printf("</propstat>");
-                       wc_printf("</response>");
+                               wc_printf("</getlastmodified>");
+                               wc_printf("</prop>");
+                               wc_printf("</propstat>");
+                               wc_printf("</response>");
+                       }
                }
-       }
        wc_printf("</multistatus>\n");
 
        end_burst();
@@ -442,8 +418,7 @@ void propfind_xml_end(void *data, const char *supplied_el) {
 /*
  * The pathname is always going to be /groupdav/room_name/msg_num
  */
-void dav_propfind(void) 
-{
+void dav_propfind(void) {
        wcsession *WCC = WC;
        StrBuf *dav_roomname;
        StrBuf *dav_uid;
@@ -470,10 +445,10 @@ void dav_propfind(void)
 
                const char *req = ChrPtr(WCC->upload);
                if (req) {
-                       req = strchr(req, '<');                 /* hunt for the first tag */
+                       req = strchr(req, '<'); /* hunt for the first tag */
                }
                if (!req) {
-                       req = "ERROR";                          /* force it to barf */
+                       req = "ERROR";  /* force it to barf */
                }
 
                i = XML_Parse(xp, req, strlen(req), 1);
@@ -492,7 +467,7 @@ void dav_propfind(void)
                dav_common_headers();
                hprintf("Date: %s\r\n", datestring);
                hprintf("Content-Type: text/plain\r\n");
-               wc_printf("An internal error has occurred at %s:%d.\r\n", __FILE__ , __LINE__ );
+               wc_printf("An internal error has occurred at %s:%d.\r\n", __FILE__, __LINE__);
                end_burst();
                return;
        }
@@ -502,9 +477,7 @@ void dav_propfind(void)
        StrBufExtract_token(dav_roomname, WCC->Hdr->HR.ReqLine, 0, '/');
        StrBufExtract_token(dav_uid, WCC->Hdr->HR.ReqLine, 1, '/');
 
-       syslog(LOG_DEBUG, "PROPFIND requested for '%s' at depth %d",
-               ChrPtr(dav_roomname), WCC->Hdr->HR.dav_depth
-       );
+       syslog(LOG_DEBUG, "PROPFIND requested for '%s' at depth %d", ChrPtr(dav_roomname), WCC->Hdr->HR.dav_depth);
 
        /*
         * If the room name is blank, the client is requesting a folder list.
@@ -543,17 +516,15 @@ void dav_propfind(void)
                        hprintf("HTTP/1.1 404 not found\r\n");
                        dav_common_headers();
                        hprintf("Content-Type: text/plain\r\n");
-                       wc_printf("Object \"%s\" was not found in the \"%s\" folder.\r\n",
-                               ChrPtr(dav_uid),
-                               ChrPtr(dav_roomname)
-                       );
+                       wc_printf("Object \"%s\" was not found in the \"%s\" folder.\r\n", ChrPtr(dav_uid), ChrPtr(dav_roomname)
+                           );
                        end_burst();
                        FreeStrBuf(&dav_roomname);
                        FreeStrBuf(&dav_uid);
                        return;
                }
 
-               /* Be rude.  Completely ignore the XML request and simply send them
+               /* Be rude.  Completely ignore the XML request and simply send them
                 * everything we know about (which is going to simply be the ETag and
                 * nothing else).  Let the client-side parser sort it out.
                 */
@@ -561,17 +532,15 @@ void dav_propfind(void)
                dav_common_headers();
                hprintf("Date: %s\r\n", datestring);
                hprintf("Content-type: text/xml\r\n");
-               if (DisableGzip || (!WCC->Hdr->HR.gzip_ok))     
+               if (DisableGzip || (!WCC->Hdr->HR.gzip_ok))
                        hprintf("Content-encoding: identity\r\n");
-       
+
                begin_burst();
-       
-               wc_printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
-                       "<multistatus xmlns=\"DAV:\">"
-               );
+
+               wc_printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>" "<multistatus xmlns=\"DAV:\">");
 
                wc_printf("<response>");
-               
+
                wc_printf("<href>");
                dav_identify_host();
                wc_printf("/groupdav/");
@@ -621,12 +590,8 @@ void dav_propfind(void)
        begin_burst();
 
        wc_printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
-               "<D:multistatus "
-                       "xmlns:D=\"DAV:\" "
-                       "xmlns:G=\"http://groupdav.org/\" "
-                       "xmlns:C=\"urn:ietf:params:xml:ns:caldav\""
-               ">"
-       );
+                 "<D:multistatus "
+                 "xmlns:D=\"DAV:\" " "xmlns:G=\"http://groupdav.org/\" " "xmlns:C=\"urn:ietf:params:xml:ns:caldav\"" ">");
 
        /* Transmit the collection resource */
        wc_printf("<D:response>");
@@ -644,28 +609,28 @@ void dav_propfind(void)
        escputs(ChrPtr(WCC->CurRoom.name));
        wc_printf("</D:displayname>");
 
-       wc_printf("<D:owner/>");                /* empty owner ought to be legal; see rfc3744 section 5.1 */
+       wc_printf("<D:owner/>");        /* empty owner ought to be legal; see rfc3744 section 5.1 */
 
        wc_printf("<D:resourcetype><D:collection/>");
-       switch(WCC->CurRoom.defview) {
-               case VIEW_CALENDAR:
-                       wc_printf("<G:vevent-collection />");
-                       wc_printf("<C:calendar />");
-                       break;
-               case VIEW_TASKS:
-                       wc_printf("<G:vtodo-collection />");
-                       break;
-               case VIEW_ADDRESSBOOK:
-                       wc_printf("<G:vcard-collection />");
-                       break;
+       switch (WCC->CurRoom.defview) {
+       case VIEW_CALENDAR:
+               wc_printf("<G:vevent-collection />");
+               wc_printf("<C:calendar />");
+               break;
+       case VIEW_TASKS:
+               wc_printf("<G:vtodo-collection />");
+               break;
+       case VIEW_ADDRESSBOOK:
+               wc_printf("<G:vcard-collection />");
+               break;
        }
        wc_printf("</D:resourcetype>");
 
        /* FIXME get the mtime
-       wc_printf("<D:getlastmodified>");
-               escputs(datestring);
-       wc_printf("</D:getlastmodified>");
-       */
+          wc_printf("<D:getlastmodified>");
+          escputs(datestring);
+          wc_printf("</D:getlastmodified>");
+        */
        wc_printf("</D:prop>");
        wc_printf("</D:propstat>");
        wc_printf("</D:response>");
@@ -675,51 +640,48 @@ void dav_propfind(void)
        if (WCC->Hdr->HR.dav_depth > 0) {
                MsgNum = NewStrBuf();
                serv_puts("MSGS ALL");
-       
+
                StrBuf_ServGetln(MsgNum);
                if (GetServerStatus(MsgNum, NULL) == 1)
-                       while (BufLen = StrBuf_ServGetln(MsgNum), 
-                       ((BufLen >= 0) && 
-                               ((BufLen != 3) || strcmp(ChrPtr(MsgNum), "000"))  ))
-                       {
+                       while (BufLen = StrBuf_ServGetln(MsgNum),
+                              ((BufLen >= 0) && ((BufLen != 3) || strcmp(ChrPtr(MsgNum), "000")))) {
                                msgs = realloc(msgs, ++num_msgs * sizeof(long));
-                               msgs[num_msgs-1] = StrTol(MsgNum);
+                               msgs[num_msgs - 1] = StrTol(MsgNum);
                        }
-       
-               if (num_msgs > 0) for (i=0; i<num_msgs; ++i) {
-       
-                       syslog(LOG_DEBUG, "PROPFIND enumerating message # %ld", msgs[i]);
-                       strcpy(uid, "");
-                       now = (-1);
-                       serv_printf("MSG0 %ld|3", msgs[i]);
-                       StrBuf_ServGetln(MsgNum);
-                       if (GetServerStatus(MsgNum, NULL) == 1)
-                               while (BufLen = StrBuf_ServGetln(MsgNum), 
-                               ((BufLen >= 0) && 
-                                       ((BufLen != 3) || strcmp(ChrPtr(MsgNum), "000")) ))
-                               {
-                                       if (!strncasecmp(ChrPtr(MsgNum), "exti=", 5)) {
-                                               strcpy(uid, &ChrPtr(MsgNum)[5]);
+
+               if (num_msgs > 0)
+                       for (i = 0; i < num_msgs; ++i) {
+
+                               syslog(LOG_DEBUG, "PROPFIND enumerating message # %ld", msgs[i]);
+                               strcpy(uid, "");
+                               now = (-1);
+                               serv_printf("MSG0 %ld|3", msgs[i]);
+                               StrBuf_ServGetln(MsgNum);
+                               if (GetServerStatus(MsgNum, NULL) == 1)
+                                       while (BufLen = StrBuf_ServGetln(MsgNum),
+                                              ((BufLen >= 0) && ((BufLen != 3) || strcmp(ChrPtr(MsgNum), "000")))) {
+                                               if (!strncasecmp(ChrPtr(MsgNum), "exti=", 5)) {
+                                                       strcpy(uid, &ChrPtr(MsgNum)[5]);
+                                               }
+                                               else if (!strncasecmp(ChrPtr(MsgNum), "time=", 5)) {
+                                                       now = atol(&ChrPtr(MsgNum)[5]);
+                                               }
                                        }
-                                       else if (!strncasecmp(ChrPtr(MsgNum), "time=", 5)) {
-                                               now = atol(&ChrPtr(MsgNum)[5]);
-                               }
-                       }
-       
-                       if (!IsEmptyStr(uid)) {
-                               wc_printf("<D:response>");
-                               wc_printf("<D:href>");
-                               dav_identify_host();
-                               wc_printf("/groupdav/");
-                               urlescputs(ChrPtr(WCC->CurRoom.name));
-                               euid_escapize(encoded_uid, uid);
-                               wc_printf("/%s", encoded_uid);
-                               wc_printf("</D:href>");
-                               wc_printf("<D:propstat>");
-                               wc_printf("<D:status>HTTP/1.1 200 OK</D:status>");
-                               wc_printf("<D:prop>");
-                               wc_printf("<D:getetag>\"%ld\"</D:getetag>", msgs[i]);
-                               switch(WCC->CurRoom.defview) {
+
+                               if (!IsEmptyStr(uid)) {
+                                       wc_printf("<D:response>");
+                                       wc_printf("<D:href>");
+                                       dav_identify_host();
+                                       wc_printf("/groupdav/");
+                                       urlescputs(ChrPtr(WCC->CurRoom.name));
+                                       euid_escapize(encoded_uid, uid);
+                                       wc_printf("/%s", encoded_uid);
+                                       wc_printf("</D:href>");
+                                       wc_printf("<D:propstat>");
+                                       wc_printf("<D:status>HTTP/1.1 200 OK</D:status>");
+                                       wc_printf("<D:prop>");
+                                       wc_printf("<D:getetag>\"%ld\"</D:getetag>", msgs[i]);
+                                       switch (WCC->CurRoom.defview) {
                                        case VIEW_CALENDAR:
                                                wc_printf("<D:getcontenttype>text/x-ical</D:getcontenttype>");
                                                break;
@@ -729,18 +691,18 @@ void dav_propfind(void)
                                        case VIEW_ADDRESSBOOK:
                                                wc_printf("<D:getcontenttype>text/x-vcard</D:getcontenttype>");
                                                break;
+                                       }
+                                       if (now > 0L) {
+                                               http_datestring(datestring, sizeof datestring, now);
+                                               wc_printf("<D:getlastmodified>");
+                                               escputs(datestring);
+                                               wc_printf("</D:getlastmodified>");
+                                       }
+                                       wc_printf("</D:prop>");
+                                       wc_printf("</D:propstat>");
+                                       wc_printf("</D:response>");
                                }
-                               if (now > 0L) {
-                                       http_datestring(datestring, sizeof datestring, now);
-                                       wc_printf("<D:getlastmodified>");
-                                       escputs(datestring);
-                                       wc_printf("</D:getlastmodified>");
-                               }
-                               wc_printf("</D:prop>");
-                               wc_printf("</D:propstat>");
-                               wc_printf("</D:response>");
                        }
-               }
                FreeStrBuf(&MsgNum);
        }
 
@@ -754,48 +716,34 @@ void dav_propfind(void)
 
 
 
-int ParseMessageListHeaders_EUID(StrBuf *Line, 
-                                const char **pos, 
-                                message_summary *Msg, 
-                                StrBuf *ConversionBuffer,
-                                void **ViewSpecific)
-{
+int ParseMessageListHeaders_EUID(StrBuf * Line,
+                                const char **pos, message_summary * Msg, StrBuf * ConversionBuffer, void **ViewSpecific) {
        Msg->euid = NewStrBuf();
-       StrBufExtract_NextToken(Msg->euid,  Line, pos, '|');
+       StrBufExtract_NextToken(Msg->euid, Line, pos, '|');
        Msg->date = StrBufExtractNext_long(Line, pos, '|');
-       
+
        return StrLength(Msg->euid) > 0;
 }
 
-int DavUIDL_GetParamsGetServerCall(SharedMessageStatus *Stat, 
-                                  void **ViewSpecific, 
-                                  long oper, 
-                                  char *cmd, 
-                                  long len,
-                                  char *filter,
-                                  long flen)
-{
+int DavUIDL_GetParamsGetServerCall(SharedMessageStatus * Stat,
+                                  void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen) {
        Stat->defaultsortorder = 0;
        Stat->sortit = 0;
        Stat->load_seen = 0;
-       Stat->maxmsgs  = 9999999;
+       Stat->maxmsgs = 9999999;
 
        snprintf(cmd, len, "MSGS ALL|||2");
        return 200;
 }
 
-int DavUIDL_RenderView_or_Tail(SharedMessageStatus *Stat, 
-                               void **ViewSpecific, 
-                               long oper)
-{
-       
-       DoTemplate(HKEY("msg_listview"),NULL,&NoCtx);
-       
+int DavUIDL_RenderView_or_Tail(SharedMessageStatus * Stat, void **ViewSpecific, long oper) {
+
+       DoTemplate(HKEY("msg_listview"), NULL, &NoCtx);
+
        return 0;
 }
 
-int DavUIDL_Cleanup(void **ViewSpecific)
-{
+int DavUIDL_Cleanup(void **ViewSpecific) {
        /* Note: wDumpContent() will output one additional </div> tag. */
        /* We ought to move this out into template */
        wDumpContent(1);
@@ -806,19 +754,10 @@ int DavUIDL_Cleanup(void **ViewSpecific)
 
 
 
-void 
-InitModule_PROPFIND
-(void)
-{
-       RegisterReadLoopHandlerset(
-               eReadEUIDS,
-               DavUIDL_GetParamsGetServerCall,
-               NULL,
-               NULL,
-               ParseMessageListHeaders_EUID,
-               NULL,
-               DavUIDL_RenderView_or_Tail,
-               DavUIDL_Cleanup,
-               NULL);
+void InitModule_PROPFIND(void) {
+       RegisterReadLoopHandlerset(eReadEUIDS,
+                                  DavUIDL_GetParamsGetServerCall,
+                                  NULL,
+                                  NULL, ParseMessageListHeaders_EUID, NULL, DavUIDL_RenderView_or_Tail, DavUIDL_Cleanup, NULL);
 
 }
index 8b6935ef1a2cbc94bd39d02b7668f7dd74dc42b8..3930dae46e28db1b401b4d77d3a5c5400b24885a 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Handles GroupDAV PUT requests.
  *
@@ -22,8 +23,7 @@
  * component.  This would be for webcal:// 'publish' operations, not
  * for GroupDAV.
  */
-void dav_put_bigics(void)
-{
+void dav_put_bigics(void) {
        wcsession *WCC = WC;
        char buf[1024];
 
@@ -64,8 +64,7 @@ void dav_put_bigics(void)
  * [/groupdav/]room_name/euid  (GroupDAV)
  * [/groupdav/]room_name               (webcal)
  */
-void dav_put(void) 
-{
+void dav_put(void) {
        wcsession *WCC = WC;
        StrBuf *dav_roomname;
        StrBuf *dav_uid;
@@ -88,8 +87,7 @@ void dav_put(void)
        dav_uid = NewStrBuf();;
        StrBufExtract_token(dav_roomname, WCC->Hdr->HR.ReqLine, 0, '/');
        StrBufExtract_token(dav_uid, WCC->Hdr->HR.ReqLine, 1, '/');
-       if ((!strcasecmp(ChrPtr(dav_uid), "ics")) || 
-           (!strcasecmp(ChrPtr(dav_uid), "calendar.ics"))) {
+       if ((!strcasecmp(ChrPtr(dav_uid), "ics")) || (!strcasecmp(ChrPtr(dav_uid), "calendar.ics"))) {
                FlushStrBuf(dav_uid);
        }
 
@@ -102,11 +100,10 @@ void dav_put(void)
                dav_common_headers();
                hprintf("Content-Type: text/plain\r\n");
                begin_burst();
-               wc_printf("There is no folder called \"%s\" on this server.\r\n",
-                       ChrPtr(dav_roomname));
+               wc_printf("There is no folder called \"%s\" on this server.\r\n", ChrPtr(dav_roomname));
                end_burst();
                FreeStrBuf(&dav_roomname);
-               FreeStrBuf(&dav_uid);           
+               FreeStrBuf(&dav_uid);
                return;
        }
 
@@ -124,9 +121,9 @@ void dav_put(void)
                if (StrTol(WCC->Hdr->HR.dav_ifmatch) != old_msgnum) {
                        hprintf("HTTP/1.1 412 Precondition Failed\r\n");
                        syslog(LOG_INFO, "HTTP/1.1 412 Precondition Failed (ifmatch=%ld, old_msgnum=%ld)\r\n",
-                               StrTol(WCC->Hdr->HR.dav_ifmatch), old_msgnum);
+                              StrTol(WCC->Hdr->HR.dav_ifmatch), old_msgnum);
                        dav_common_headers();
-                       
+
                        end_burst();
                        FreeStrBuf(&dav_roomname);
                        FreeStrBuf(&dav_uid);
@@ -169,14 +166,14 @@ void dav_put(void)
        n = 0;
        FlushStrBuf(dav_uid);
        while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-               switch(n++) {
-               case 0: 
+               switch (n++) {
+               case 0:
                        new_msgnum = atol(buf);
                        break;
-               case 1: 
+               case 1:
                        syslog(LOG_DEBUG, "new_msgnum=%ld (%s)\n", new_msgnum, buf);
                        break;
-               case 2: 
+               case 2:
                        StrBufAppendBufPlain(dav_uid, buf, -1, 0);
                        break;
                default:
@@ -192,8 +189,7 @@ void dav_put(void)
                dav_common_headers();
                hprintf("Content-type: text/plain\r\n");
                begin_burst();
-               wc_printf("new_msgnum is %ld\r\n"
-                       "\r\n", new_msgnum);
+               wc_printf("new_msgnum is %ld\r\n" "\r\n", new_msgnum);
                end_burst();
                FreeStrBuf(&dav_roomname);
                FreeStrBuf(&dav_uid);
@@ -202,17 +198,17 @@ void dav_put(void)
 
        /* We created this item for the first time. */
        if (old_msgnum < 0L) {
-               char escaped_uid[1024];
+               char escaped_uid[1024];
                hprintf("HTTP/1.1 201 Created\r\n");
                syslog(LOG_DEBUG, "HTTP/1.1 201 Created\r\n");
                dav_common_headers();
                hprintf("etag: \"%ld\"\r\n", new_msgnum);
                hprintf("Location: ");
                dav_identify_hosthdr();
-               hprintf("/groupdav/");/* TODO */
+               hprintf("/groupdav/");  /* TODO */
                hurlescputs(ChrPtr(dav_roomname));
-               euid_escapize(escaped_uid, ChrPtr(dav_uid));
-               hprintf("/%s\r\n", escaped_uid);
+               euid_escapize(escaped_uid, ChrPtr(dav_uid));
+               hprintf("/%s\r\n", escaped_uid);
                end_burst();
                FreeStrBuf(&dav_roomname);
                FreeStrBuf(&dav_uid);
index 9331ffd49d13dd29f93d3608e3f3e559b0f0ddbb..c823910eb735b334c8b3e0926a5bd103ada59420 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Handles GroupDAV REPORT requests.
  *
@@ -58,8 +59,7 @@ Content-length: 255
 /*
  * The pathname is always going to be /groupdav/room_name/msg_num
  */
-void dav_report(void) 
-{
+void dav_report(void) {
        char datestring[256];
        time_t now = time(NULL);
 
@@ -72,49 +72,29 @@ void dav_report(void)
        dav_common_headers();
        hprintf("Date: %s\r\n", datestring);
        hprintf("Content-Type: text/plain\r\n");
-       wc_printf("An internal error has occurred at %s:%d.\r\n", __FILE__ , __LINE__ );
+       wc_printf("An internal error has occurred at %s:%d.\r\n", __FILE__, __LINE__);
        end_burst();
        return;
 }
 
 
 
-extern int ParseMessageListHeaders_EUID(StrBuf *Line, 
-                                       const char **pos, 
-                                       message_summary *Msg, 
-                                       StrBuf *ConversionBuffer,
-                                       void **ViewSpecific);
+extern int ParseMessageListHeaders_EUID(StrBuf * Line,
+                                       const char **pos, message_summary * Msg, StrBuf * ConversionBuffer, void **ViewSpecific);
 
-extern int DavUIDL_GetParamsGetServerCall(SharedMessageStatus *Stat, 
-                                         void **ViewSpecific, 
-                                         long oper, 
-                                         char *cmd, 
-                                         long len,
-                                         char *filter,
-                                         long flen);
+extern int DavUIDL_GetParamsGetServerCall(SharedMessageStatus * Stat,
+                                         void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen);
 
-extern int DavUIDL_RenderView_or_Tail(SharedMessageStatus *Stat, 
-                               void **ViewSpecific, 
-                               long oper);
+extern int DavUIDL_RenderView_or_Tail(SharedMessageStatus * Stat, void **ViewSpecific, long oper);
 
 extern int DavUIDL_Cleanup(void **ViewSpecific);
 
 
 
-void 
-InitModule_REPORT
-(void)
-{
-       RegisterReadLoopHandlerset(
-               eReadEUIDS,
-               DavUIDL_GetParamsGetServerCall,
-               NULL,
-               NULL,
-               ParseMessageListHeaders_EUID,
-               NULL,
-               DavUIDL_RenderView_or_Tail,
-               DavUIDL_Cleanup,
-               NULL
-       );
+void InitModule_REPORT(void) {
+       RegisterReadLoopHandlerset(eReadEUIDS,
+                                  DavUIDL_GetParamsGetServerCall,
+                                  NULL,
+                                  NULL, ParseMessageListHeaders_EUID, NULL, DavUIDL_RenderView_or_Tail, DavUIDL_Cleanup, NULL);
 
 }
index 6e6c9b981b5ebf0acf8bc46dc664fc9630956acd..aa777f40ba6533f3a3fe089affe84c90417367e9 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2012 by the citadel.org team
  *
@@ -15,9 +16,9 @@
 
 CtxType CTX_FILELIST = CTX_NONE;
 
-extern void output_static(const charWhat);
+extern void output_static(const char *What);
 
-extern charstatic_dirs[];
+extern char *static_dirs[];
 
 typedef struct _FileListStruct {
        StrBuf *Filename;
@@ -28,9 +29,8 @@ typedef struct _FileListStruct {
        int Sequence;
 } FileListStruct;
 
-void FreeFiles(void *vFile)
-{
-       FileListStruct *F = (FileListStruct*) vFile;
+void FreeFiles(void *vFile) {
+       FileListStruct *F = (FileListStruct *) vFile;
        FreeStrBuf(&F->Filename);
        FreeStrBuf(&F->MimeType);
        FreeStrBuf(&F->Comment);
@@ -38,57 +38,49 @@ void FreeFiles(void *vFile)
 }
 
 /* -------------------------------------------------------------------------------- */
-void tmplput_FILE_NAME(StrBuf *Target, WCTemplputParams *TP)
-{
-       FileListStruct *F = (FileListStruct*) CTX(CTX_FILELIST);
+void tmplput_FILE_NAME(StrBuf * Target, WCTemplputParams * TP) {
+       FileListStruct *F = (FileListStruct *) CTX(CTX_FILELIST);
        StrBufAppendTemplate(Target, TP, F->Filename, 0);
 }
-void tmplput_FILE_SIZE(StrBuf *Target, WCTemplputParams *TP)
-{
-       FileListStruct *F = (FileListStruct*) CTX(CTX_FILELIST);
+void tmplput_FILE_SIZE(StrBuf * Target, WCTemplputParams * TP) {
+       FileListStruct *F = (FileListStruct *) CTX(CTX_FILELIST);
        StrBufAppendPrintf(Target, "%ld", F->FileSize);
 }
-void tmplput_FILEMIMETYPE(StrBuf *Target, WCTemplputParams *TP)
-{
-       FileListStruct *F = (FileListStruct*) CTX(CTX_FILELIST);
+void tmplput_FILEMIMETYPE(StrBuf * Target, WCTemplputParams * TP) {
+       FileListStruct *F = (FileListStruct *) CTX(CTX_FILELIST);
        StrBufAppendTemplate(Target, TP, F->MimeType, 0);
 }
-void tmplput_FILE_COMMENT(StrBuf *Target, WCTemplputParams *TP)
-{
-       FileListStruct *F = (FileListStruct*) CTX(CTX_FILELIST);
+void tmplput_FILE_COMMENT(StrBuf * Target, WCTemplputParams * TP) {
+       FileListStruct *F = (FileListStruct *) CTX(CTX_FILELIST);
        StrBufAppendTemplate(Target, TP, F->Comment, 0);
 }
 
 /* -------------------------------------------------------------------------------- */
 
-int Conditional_FILE_ISPIC(StrBuf *Target, WCTemplputParams *TP)
-{
-       FileListStruct *F = (FileListStruct*) CTX(CTX_FILELIST);
+int Conditional_FILE_ISPIC(StrBuf * Target, WCTemplputParams * TP) {
+       FileListStruct *F = (FileListStruct *) CTX(CTX_FILELIST);
        return F->IsPic;
 }
 
 /* -------------------------------------------------------------------------------- */
-int CompareFilelistByMime(const void *vFile1, const void *vFile2)
-{
-       FileListStruct *File1 = (FileListStruct*) GetSearchPayload(vFile1);
-       FileListStruct *File2 = (FileListStruct*) GetSearchPayload(vFile2);
+int CompareFilelistByMime(const void *vFile1, const void *vFile2) {
+       FileListStruct *File1 = (FileListStruct *) GetSearchPayload(vFile1);
+       FileListStruct *File2 = (FileListStruct *) GetSearchPayload(vFile2);
 
        if (File1->IsPic != File2->IsPic)
                return File1->IsPic > File2->IsPic;
        return strcasecmp(ChrPtr(File1->MimeType), ChrPtr(File2->MimeType));
 }
-int CompareFilelistByMimeRev(const void *vFile1, const void *vFile2)
-{
-       FileListStruct *File1 = (FileListStruct*) GetSearchPayload(vFile1);
-       FileListStruct *File2 = (FileListStruct*) GetSearchPayload(vFile2);
+int CompareFilelistByMimeRev(const void *vFile1, const void *vFile2) {
+       FileListStruct *File1 = (FileListStruct *) GetSearchPayload(vFile1);
+       FileListStruct *File2 = (FileListStruct *) GetSearchPayload(vFile2);
        if (File1->IsPic != File2->IsPic)
                return File1->IsPic < File2->IsPic;
        return strcasecmp(ChrPtr(File2->MimeType), ChrPtr(File1->MimeType));
 }
-int GroupchangeFilelistByMime(const void *vFile1, const void *vFile2)
-{
-       FileListStruct *File1 = (FileListStruct*) vFile1;
-       FileListStruct *File2 = (FileListStruct*) vFile2;
+int GroupchangeFilelistByMime(const void *vFile1, const void *vFile2) {
+       FileListStruct *File1 = (FileListStruct *) vFile1;
+       FileListStruct *File2 = (FileListStruct *) vFile2;
 
        if (File1->IsPic != File2->IsPic)
                return File1->IsPic > File2->IsPic;
@@ -96,88 +88,76 @@ int GroupchangeFilelistByMime(const void *vFile1, const void *vFile2)
 }
 
 
-int CompareFilelistByName(const void *vFile1, const void *vFile2)
-{
-       FileListStruct *File1 = (FileListStruct*) GetSearchPayload(vFile1);
-       FileListStruct *File2 = (FileListStruct*) GetSearchPayload(vFile2);
+int CompareFilelistByName(const void *vFile1, const void *vFile2) {
+       FileListStruct *File1 = (FileListStruct *) GetSearchPayload(vFile1);
+       FileListStruct *File2 = (FileListStruct *) GetSearchPayload(vFile2);
 
        if (File1->IsPic != File2->IsPic)
                return File1->IsPic > File2->IsPic;
        return strcasecmp(ChrPtr(File1->Filename), ChrPtr(File2->Filename));
 }
-int CompareFilelistByNameRev(const void *vFile1, const void *vFile2)
-{
-       FileListStruct *File1 = (FileListStruct*) GetSearchPayload(vFile1);
-       FileListStruct *File2 = (FileListStruct*) GetSearchPayload(vFile2);
+int CompareFilelistByNameRev(const void *vFile1, const void *vFile2) {
+       FileListStruct *File1 = (FileListStruct *) GetSearchPayload(vFile1);
+       FileListStruct *File2 = (FileListStruct *) GetSearchPayload(vFile2);
        if (File1->IsPic != File2->IsPic)
                return File1->IsPic < File2->IsPic;
        return strcasecmp(ChrPtr(File2->Filename), ChrPtr(File1->Filename));
 }
-int GroupchangeFilelistByName(const void *vFile1, const void *vFile2)
-{
-       FileListStruct *File1 = (FileListStruct*) vFile1;
-       FileListStruct *File2 = (FileListStruct*) vFile2;
+int GroupchangeFilelistByName(const void *vFile1, const void *vFile2) {
+       FileListStruct *File1 = (FileListStruct *) vFile1;
+       FileListStruct *File2 = (FileListStruct *) vFile2;
 
        return ChrPtr(File1->Filename)[0] != ChrPtr(File2->Filename)[0];
 }
 
 
-int CompareFilelistBySize(const void *vFile1, const void *vFile2)
-{
-       FileListStruct *File1 = (FileListStruct*) GetSearchPayload(vFile1);
-       FileListStruct *File2 = (FileListStruct*) GetSearchPayload(vFile2);
+int CompareFilelistBySize(const void *vFile1, const void *vFile2) {
+       FileListStruct *File1 = (FileListStruct *) GetSearchPayload(vFile1);
+       FileListStruct *File2 = (FileListStruct *) GetSearchPayload(vFile2);
        if (File1->FileSize == File2->FileSize)
                return 0;
        return (File1->FileSize > File2->FileSize);
 }
-int CompareFilelistBySizeRev(const void *vFile1, const void *vFile2)
-{
-       FileListStruct *File1 = (FileListStruct*) GetSearchPayload(vFile1);
-       FileListStruct *File2 = (FileListStruct*) GetSearchPayload(vFile2);
+int CompareFilelistBySizeRev(const void *vFile1, const void *vFile2) {
+       FileListStruct *File1 = (FileListStruct *) GetSearchPayload(vFile1);
+       FileListStruct *File2 = (FileListStruct *) GetSearchPayload(vFile2);
        if (File1->FileSize == File2->FileSize)
                return 0;
        return (File1->FileSize < File2->FileSize);
 }
-int GroupchangeFilelistBySize(const void *vFile1, const void *vFile2)
-{
+int GroupchangeFilelistBySize(const void *vFile1, const void *vFile2) {
        return 0;
 }
 
 
-int CompareFilelistByComment(const void *vFile1, const void *vFile2)
-{
-       FileListStruct *File1 = (FileListStruct*) GetSearchPayload(vFile1);
-       FileListStruct *File2 = (FileListStruct*) GetSearchPayload(vFile2);
+int CompareFilelistByComment(const void *vFile1, const void *vFile2) {
+       FileListStruct *File1 = (FileListStruct *) GetSearchPayload(vFile1);
+       FileListStruct *File2 = (FileListStruct *) GetSearchPayload(vFile2);
        return strcasecmp(ChrPtr(File1->Comment), ChrPtr(File2->Comment));
 }
-int CompareFilelistByCommentRev(const void *vFile1, const void *vFile2)
-{
-       FileListStruct *File1 = (FileListStruct*) GetSearchPayload(vFile1);
-       FileListStruct *File2 = (FileListStruct*) GetSearchPayload(vFile2);
+int CompareFilelistByCommentRev(const void *vFile1, const void *vFile2) {
+       FileListStruct *File1 = (FileListStruct *) GetSearchPayload(vFile1);
+       FileListStruct *File2 = (FileListStruct *) GetSearchPayload(vFile2);
        return strcasecmp(ChrPtr(File2->Comment), ChrPtr(File1->Comment));
 }
-int GroupchangeFilelistByComment(const void *vFile1, const void *vFile2)
-{
-       FileListStruct *File1 = (FileListStruct*) vFile1;
-       FileListStruct *File2 = (FileListStruct*) vFile2;
+int GroupchangeFilelistByComment(const void *vFile1, const void *vFile2) {
+       FileListStruct *File1 = (FileListStruct *) vFile1;
+       FileListStruct *File2 = (FileListStruct *) vFile2;
        return ChrPtr(File1->Comment)[9] != ChrPtr(File2->Comment)[0];
 }
 
 
-int CompareFilelistBySequence(const void *vFile1, const void *vFile2)
-{
-       FileListStruct *File1 = (FileListStruct*) GetSearchPayload(vFile1);
-       FileListStruct *File2 = (FileListStruct*) GetSearchPayload(vFile2);
-       return (File2->Sequence >  File1->Sequence);
+int CompareFilelistBySequence(const void *vFile1, const void *vFile2) {
+       FileListStruct *File1 = (FileListStruct *) GetSearchPayload(vFile1);
+       FileListStruct *File2 = (FileListStruct *) GetSearchPayload(vFile2);
+       return (File2->Sequence > File1->Sequence);
 }
-int GroupchangeFilelistBySequence(const void *vFile1, const void *vFile2)
-{
+int GroupchangeFilelistBySequence(const void *vFile1, const void *vFile2) {
        return 0;
 }
 
 /* -------------------------------------------------------------------------------- */
-HashList* LoadFileList(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *LoadFileList(StrBuf * Target, WCTemplputParams * TP) {
        FileListStruct *Entry;
        StrBuf *Buf;
        HashList *Files;
@@ -191,19 +171,18 @@ HashList* LoadFileList(StrBuf *Target, WCTemplputParams *TP)
        memset(&SubTP, 0, sizeof(WCTemplputParams));
        serv_puts("RDIR");
        serv_getln(buf, sizeof buf);
-       if (buf[0] != '1') return NULL;
+       if (buf[0] != '1')
+               return NULL;
 
-       Buf = NewStrBuf();             
+       Buf = NewStrBuf();
        Files = NewHash(1, NULL);
-       while (!Done && (StrBuf_ServGetln(Buf)>=0)) {
-               if ( (StrLength(Buf)==3) && 
-                   !strcmp(ChrPtr(Buf), "000")) 
-               {
+       while (!Done && (StrBuf_ServGetln(Buf) >= 0)) {
+               if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
                        Done = 1;
                        continue;
                }
 
-               Entry = (FileListStruct*) malloc(sizeof (FileListStruct));
+               Entry = (FileListStruct *) malloc(sizeof(FileListStruct));
                Entry->Filename = NewStrBufPlain(NULL, StrLength(Buf));
                Entry->MimeType = NewStrBufPlain(NULL, StrLength(Buf));
                Entry->Comment = NewStrBufPlain(NULL, StrLength(Buf));
@@ -229,14 +208,13 @@ HashList* LoadFileList(StrBuf *Target, WCTemplputParams *TP)
        SortIt = RetrieveSort(&SubTP, NULL, 0, HKEY("fileunsorted"), 0);
        if (SortIt != NULL)
                SortByPayload(Files, SortIt);
-       else 
+       else
                SortByPayload(Files, CompareFilelistBySequence);
        FreeStrBuf(&Buf);
        return Files;
 }
 
-void display_mime_icon(void)
-{
+void display_mime_icon(void) {
        char FileBuf[SIZ];
        const char *FileName;
        char *MimeType;
@@ -246,14 +224,13 @@ void display_mime_icon(void)
        FileName = GetIconFilename(MimeType, tlen);
 
        if (FileName == NULL)
-               snprintf (FileBuf, SIZ, "%s%s", static_dirs[0], "/webcit_icons/essen/16x16/file.png");
+               snprintf(FileBuf, SIZ, "%s%s", static_dirs[0], "/webcit_icons/essen/16x16/file.png");
        else
-               snprintf (FileBuf, SIZ, "%s%s", static_dirs[3], FileName);
+               snprintf(FileBuf, SIZ, "%s%s", static_dirs[3], FileName);
        output_static(FileBuf);
 }
 
-void download_file(void)
-{
+void download_file(void) {
        wcsession *WCC = WC;
        StrBuf *Buf;
        off_t bytes;
@@ -261,7 +238,7 @@ void download_file(void)
 
        /* Setting to nonzero forces a MIME type of application/octet-stream */
        int force_download = 1;
-       
+
        Buf = NewStrBuf();
        StrBufExtract_token(Buf, WCC->Hdr->HR.ReqLine, 0, '/');
        StrBufUnescape(Buf, 1);
@@ -272,20 +249,20 @@ void download_file(void)
                bytes = StrBufExtract_long(Buf, 0, '|');
                StrBufExtract_token(ContentType, Buf, 3, '|');
 
-               CheckGZipCompressionAllowed (SKEY(ContentType));
+               CheckGZipCompressionAllowed(SKEY(ContentType));
                if (force_download)
                        FlushStrBuf(ContentType);
 
                serv_read_binary_to_http(ContentType, bytes, 0, 0);
                serv_puts("CLOS");
                StrBuf_ServGetln(Buf);
-       } else {
+       }
+       else {
                StrBufCutLeft(Buf, 4);
                hprintf("HTTP/1.1 404 %s\n", ChrPtr(Buf));
                output_headers(0, 0, 0, 0, 0, 0);
                hprintf("Content-Type: text/plain\r\n");
-               wc_printf(_("An error occurred while retrieving this file: %s\n"), 
-                       ChrPtr(Buf));
+               wc_printf(_("An error occurred while retrieving this file: %s\n"), ChrPtr(Buf));
                end_burst();
        }
        FreeStrBuf(&ContentType);
@@ -294,12 +271,11 @@ void download_file(void)
 
 
 
-void delete_file(void)
-{
+void delete_file(void) {
        const StrBuf *MimeType;
        StrBuf *Line;
        char buf[256];
-       
+
        safestrncpy(buf, bstr("file"), sizeof buf);
        unescape_input(buf);
        serv_printf("DELF %s", buf);
@@ -314,24 +290,20 @@ void delete_file(void)
 
 
 
-void upload_file(void)
-{
+void upload_file(void) {
        const StrBuf *RetMimeType;
        const char *MimeType;
        StrBuf *Line;
        long bytes_transmitted = 0;
        long blocksize;
        const StrBuf *Desc;
-       wcsession *WCC = WC;     /* stack this for faster access (WC is a function) */
+       wcsession *WCC = WC;    /* stack this for faster access (WC is a function) */
 
-       MimeType = GuessMimeType(ChrPtr(WCC->upload), WCC->upload_length); 
+       MimeType = GuessMimeType(ChrPtr(WCC->upload), WCC->upload_length);
 
-               Desc = sbstr("description");
+       Desc = sbstr("description");
 
-       serv_printf("UOPN %s|%s|%s", 
-                   ChrPtr(WCC->upload_filename), 
-                   MimeType, 
-                   ChrPtr(Desc));
+       serv_printf("UOPN %s|%s|%s", ChrPtr(WCC->upload_filename), MimeType, ChrPtr(Desc));
        Line = NewStrBuf();
        StrBuf_ServGetln(Line);
        if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
@@ -341,11 +313,9 @@ void upload_file(void)
                return;
        }
 
-       while (bytes_transmitted < WCC->upload_length)
-       {
+       while (bytes_transmitted < WCC->upload_length) {
                blocksize = 4096;
-               if (blocksize > (WCC->upload_length - bytes_transmitted))
-               {
+               if (blocksize > (WCC->upload_length - bytes_transmitted)) {
                        blocksize = (WCC->upload_length - bytes_transmitted);
                }
                serv_printf("WRIT %ld", blocksize);
@@ -373,13 +343,12 @@ void upload_file(void)
  * When the browser requests an image file from the Citadel server,
  * this function is called to transmit it.
  */
-void output_image(void)
-{
+void output_image(void) {
        StrBuf *Buf;
        wcsession *WCC = WC;
        off_t bytes;
        const char *MimeType;
-       
+
        Buf = NewStrBuf();
        serv_printf("OIMG %s|%s", bstr("name"), bstr("parm"));
        StrBuf_ServGetln(Buf);
@@ -389,17 +358,17 @@ void output_image(void)
                bytes = StrBufExtract_long(Buf, 0, '|');
 
                /** Read it from the server */
-               
+
                rc = serv_read_binary(WCC->WBuf, bytes, Buf);
                serv_puts("CLOS");
                StrBuf_ServGetln(Buf);
-               
+
                if (rc > 0) {
-                       MimeType = GuessMimeType (ChrPtr(WCC->WBuf), StrLength(WCC->WBuf));
+                       MimeType = GuessMimeType(ChrPtr(WCC->WBuf), StrLength(WCC->WBuf));
+
                        /** Write it to the browser */
-                       if (!IsEmptyStr(MimeType))
-                       {
-                               CheckGZipCompressionAllowed (MimeType, strlen(MimeType));
+                       if (!IsEmptyStr(MimeType)) {
+                               CheckGZipCompressionAllowed(MimeType, strlen(MimeType));
                                http_transmit_thing(MimeType, 0);
                                FreeStrBuf(&Buf);
                                return;
@@ -407,60 +376,37 @@ void output_image(void)
                }
                /* hm... unknown mimetype? fallback to blank gif */
        }
-       else { 
+       else {
                syslog(LOG_DEBUG, "OIMG failed: %s", ChrPtr(Buf));
        }
 
-       
+
        /*
         * Instead of an ugly 404, send a 1x1 transparent GIF
         * when there's no such image on the server.
         */
-       StrBufPrintf (Buf, "%s%s", static_dirs[0], "/webcit_icons/blank.gif");
+       StrBufPrintf(Buf, "%s%s", static_dirs[0], "/webcit_icons/blank.gif");
        output_static(ChrPtr(Buf));
        FreeStrBuf(&Buf);
 }
 
-void 
-InitModule_DOWNLOAD
-(void)
-{
+void InitModule_DOWNLOAD(void) {
        RegisterCTX(CTX_FILELIST);
 
-       RegisterIterator("ROOM:FILES", 0, NULL, LoadFileList,
-                        NULL, DeleteHash, CTX_FILELIST, CTX_NONE, 
-                        IT_FLAG_DETECT_GROUPCHANGE);
+       RegisterIterator("ROOM:FILES", 0, NULL, LoadFileList, NULL, DeleteHash, CTX_FILELIST, CTX_NONE, IT_FLAG_DETECT_GROUPCHANGE);
 
        RegisterSortFunc(HKEY("filemime"),
-                        NULL, 0,
-                        CompareFilelistByMime,
-                        CompareFilelistByMimeRev,
-                        GroupchangeFilelistByMime,
-                        CTX_FILELIST);
+                        NULL, 0, CompareFilelistByMime, CompareFilelistByMimeRev, GroupchangeFilelistByMime, CTX_FILELIST);
        RegisterSortFunc(HKEY("filename"),
-                        NULL, 0,
-                        CompareFilelistByName,
-                        CompareFilelistByNameRev,
-                        GroupchangeFilelistByName,
-                        CTX_FILELIST);
+                        NULL, 0, CompareFilelistByName, CompareFilelistByNameRev, GroupchangeFilelistByName, CTX_FILELIST);
        RegisterSortFunc(HKEY("filesize"),
-                        NULL, 0,
-                        CompareFilelistBySize,
-                        CompareFilelistBySizeRev,
-                        GroupchangeFilelistBySize,
-                        CTX_FILELIST);
+                        NULL, 0, CompareFilelistBySize, CompareFilelistBySizeRev, GroupchangeFilelistBySize, CTX_FILELIST);
        RegisterSortFunc(HKEY("filesubject"),
                         NULL, 0,
-                        CompareFilelistByComment,
-                        CompareFilelistByCommentRev,
-                        GroupchangeFilelistByComment,
-                        CTX_FILELIST);
+                        CompareFilelistByComment, CompareFilelistByCommentRev, GroupchangeFilelistByComment, CTX_FILELIST);
        RegisterSortFunc(HKEY("fileunsorted"),
                         NULL, 0,
-                        CompareFilelistBySequence,
-                        CompareFilelistBySequence,
-                        GroupchangeFilelistBySequence,
-                        CTX_FILELIST);
+                        CompareFilelistBySequence, CompareFilelistBySequence, GroupchangeFilelistBySequence, CTX_FILELIST);
 
        RegisterNamespace("FILE:NAME", 0, 2, tmplput_FILE_NAME, NULL, CTX_FILELIST);
        RegisterNamespace("FILE:SIZE", 0, 1, tmplput_FILE_SIZE, NULL, CTX_FILELIST);
@@ -470,7 +416,7 @@ InitModule_DOWNLOAD
        RegisterConditional("COND:FILE:ISPIC", 0, Conditional_FILE_ISPIC, CTX_FILELIST);
 
        WebcitAddUrlHandler(HKEY("image"), "", 0, output_image, ANONYMOUS);
-       WebcitAddUrlHandler(HKEY("display_mime_icon"), "", 0, display_mime_icon , ANONYMOUS);
+       WebcitAddUrlHandler(HKEY("display_mime_icon"), "", 0, display_mime_icon, ANONYMOUS);
        WebcitAddUrlHandler(HKEY("download_file"), "", 0, download_file, NEED_URL);
        WebcitAddUrlHandler(HKEY("delete_file"), "", 0, delete_file, NEED_URL);
        WebcitAddUrlHandler(HKEY("upload_file"), "", 0, upload_file, 0);
index d786998ab8ef818c0d5bebf7e15b291c1b04b7e1..c505b10bc7b3ff1b99d1cf3209f6be36a15fce5f 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Editing calendar events.
  *
@@ -21,9 +22,7 @@
  * supplied_vevent     the event to edit
  * msgnum              reference on the citserver
  */
-void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, char *from,
-       int unread, calview *calv)
-{
+void display_edit_individual_event(icalcomponent * supplied_vevent, long msgnum, char *from, int unread, calview * calv) {
        wcsession *WCC = WC;
        icalcomponent *vevent;
        icalproperty *p;
@@ -39,6 +38,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        char buf[SIZ];
        int organizer_is_me = 0;
        int i, j = 0;
+
        /************************************************************
         * Uncomment this to see the UID in calendar events for debugging
        int sequence = 0;
@@ -91,11 +91,12 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        tabnames[2] = _("Recurrence");
 
        get_pref_long("weekstart", &weekstart, 17);
-       if (weekstart > 6) weekstart = 0;
+       if (weekstart > 6)
+               weekstart = 0;
 
        syslog(LOG_DEBUG, "display_edit_individual_event(%ld) calview=%s year=%s month=%s day=%s\n",
-               msgnum, bstr("calview"), bstr("year"), bstr("month"), bstr("day")
-       );
+              msgnum, bstr("calview"), bstr("year"), bstr("month"), bstr("day")
+           );
 
        /* populate the weekday names - begin */
        now = time(NULL);
@@ -104,7 +105,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                now -= 86400L;
                localtime_r(&now, &tm_now);
        }
-       for (i=0; i<7; ++i) {
+       for (i = 0; i < 7; ++i) {
                localtime_r(&now, &tm_now);
                wc_strftime(weekday_labels[i], 32, "%A", &tm_now);
                now += 86400L;
@@ -112,9 +113,9 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        /* populate the weekday names - end */
 
        /* populate the month names - begin */
-       now = 259200L;  /* 1970-jan-04 is the first Sunday ever */
+       now = 259200L;          /* 1970-jan-04 is the first Sunday ever */
        localtime_r(&now, &tm_now);
-       for (i=0; i<12; ++i) {
+       for (i = 0; i < 12; ++i) {
                localtime_r(&now, &tm_now);
                wc_strftime(month_labels[i], 32, "%B", &tm_now);
                now += 2678400L;
@@ -140,11 +141,8 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                 * new one.
                 */
                if (icalcomponent_isa(vevent) == ICAL_VCALENDAR_COMPONENT) {
-                       display_edit_individual_event(
-                               icalcomponent_get_first_component(
-                                       vevent, ICAL_VEVENT_COMPONENT), 
-                               msgnum, from, unread, NULL
-                       );
+                       display_edit_individual_event(icalcomponent_get_first_component(vevent, ICAL_VEVENT_COMPONENT),
+                                                     msgnum, from, unread, NULL);
                        return;
                }
        }
@@ -155,6 +153,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
 
        /* Learn the sequence */
        p = icalcomponent_get_first_property(vevent, ICAL_SEQUENCE_PROPERTY);
+
        /************************************************************
         * Uncomment this to see the UID in calendar events for debugging
        if (p != NULL) {
@@ -189,16 +188,11 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        StrEscAppend(WCC->WBuf, WCC->CurRoom.name, NULL, 0, 0);
        wc_printf("\">\n");
 
-       wc_printf("<input type=\"hidden\" name=\"msgnum\" value=\"%ld\">\n",
-               msgnum);
-       wc_printf("<input type=\"hidden\" name=\"calview\" value=\"%s\">\n",
-               bstr("calview"));
-       wc_printf("<input type=\"hidden\" name=\"year\" value=\"%s\">\n",
-               bstr("year"));
-       wc_printf("<input type=\"hidden\" name=\"month\" value=\"%s\">\n",
-               bstr("month"));
-       wc_printf("<input type=\"hidden\" name=\"day\" value=\"%s\">\n",
-               bstr("day"));
+       wc_printf("<input type=\"hidden\" name=\"msgnum\" value=\"%ld\">\n", msgnum);
+       wc_printf("<input type=\"hidden\" name=\"calview\" value=\"%s\">\n", bstr("calview"));
+       wc_printf("<input type=\"hidden\" name=\"year\" value=\"%s\">\n", bstr("year"));
+       wc_printf("<input type=\"hidden\" name=\"month\" value=\"%s\">\n", bstr("month"));
+       wc_printf("<input type=\"hidden\" name=\"day\" value=\"%s\">\n", bstr("day"));
 
 
        tabbed_dialog(3, tabnames);
@@ -209,23 +203,19 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
 
        wc_printf("<tr><td><b>");
        wc_printf(_("Summary"));
-       wc_printf("</b></td><td>\n"
-               "<input type=\"text\" name=\"summary\" "
-               "maxlength=\"64\" size=\"64\" value=\"");
+       wc_printf("</b></td><td>\n" "<input type=\"text\" name=\"summary\" " "maxlength=\"64\" size=\"64\" value=\"");
        p = icalcomponent_get_first_property(vevent, ICAL_SUMMARY_PROPERTY);
        if (p != NULL) {
-               escputs((char *)icalproperty_get_comment(p));
+               escputs((char *) icalproperty_get_comment(p));
        }
        wc_printf("\"></td></tr>\n");
 
        wc_printf("<tr><td><b>");
        wc_printf(_("Location"));
-       wc_printf("</b></td><td>\n"
-               "<input type=\"text\" name=\"location\" "
-               "maxlength=\"64\" size=\"64\" value=\"");
+       wc_printf("</b></td><td>\n" "<input type=\"text\" name=\"location\" " "maxlength=\"64\" size=\"64\" value=\"");
        p = icalcomponent_get_first_property(vevent, ICAL_LOCATION_PROPERTY);
        if (p != NULL) {
-               escputs((char *)icalproperty_get_comment(p));
+               escputs((char *) icalproperty_get_comment(p));
        }
        wc_printf("\"></td></tr>\n");
 
@@ -259,28 +249,23 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                        tm_now.tm_sec = 0;
                }
 
-               t_start = icaltime_from_timet_with_zone(
-                       mktime(&tm_now),
-                       ((yesbstr("alldayevent")) ? 1 : 0),
-                       icaltimezone_get_utc_timezone()
-               );
+               t_start = icaltime_from_timet_with_zone(mktime(&tm_now),
+                                                       ((yesbstr("alldayevent")) ? 1 : 0), icaltimezone_get_utc_timezone()
+                   );
        }
        display_icaltimetype_as_webform(&t_start, "dtstart", 0);
 
        wc_printf("<input type=\"checkbox\" id=\"alldayevent\" name=\"alldayevent\" "
-               "value=\"yes\" onclick=\"eventEditAllDay();\""
-               " %s >%s",
-               (t_start.is_date ? "checked=\"checked\"" : "" ),
-               _("All day event")
-       );
+                 "value=\"yes\" onclick=\"eventEditAllDay();\""
+                 " %s >%s", (t_start.is_date ? "checked=\"checked\"" : ""), _("All day event")
+           );
 
        wc_printf("</td></tr>\n");
 
        wc_printf("<tr><td><b>");
        wc_printf(_("End"));
        wc_printf("</b></td><td id=\"dtendcell\">\n");
-       p = icalcomponent_get_first_property(vevent,
-                                               ICAL_DTEND_PROPERTY);
+       p = icalcomponent_get_first_property(vevent, ICAL_DTEND_PROPERTY);
        if (p != NULL) {
                t_end = icalproperty_get_dtend(p);
 
@@ -328,13 +313,10 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
 
        wc_printf("<tr><td><b>");
        wc_printf(_("Notes"));
-       wc_printf("</b></td><td>\n"
-               "<textarea name=\"description\" "
-               "rows='5' cols='72' style='width:72'>\n"
-       );
+       wc_printf("</b></td><td>\n" "<textarea name=\"description\" " "rows='5' cols='72' style='width:72'>\n");
        p = icalcomponent_get_first_property(vevent, ICAL_DESCRIPTION_PROPERTY);
        if (p != NULL) {
-               escputs((char *)icalproperty_get_comment(p));
+               escputs((char *) icalproperty_get_comment(p));
        }
        wc_printf("</textarea></td></tr>");
 
@@ -343,11 +325,10 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
         * organizer.  Set this field accordingly.
         */
        if (icalcomponent_get_first_property(vevent, ICAL_ORGANIZER_PROPERTY)
-          == NULL) {
+           == NULL) {
                sprintf(organizer_string, "mailto:%s", ChrPtr(WC->cs_inet_email));
-               icalcomponent_add_property(vevent,
-                       icalproperty_new_organizer(organizer_string)
-               );
+               icalcomponent_add_property(vevent, icalproperty_new_organizer(organizer_string)
+                   );
        }
 
        /*
@@ -438,40 +419,35 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        wc_printf("<table border='0' width='100%%'>\n");        /* same table style as the event tab */
        wc_printf("<tr><td><b>");
        wc_printf(_("Attendees"));
-       wc_printf("</b><br>"
-               "<font size='-2'>");
+       wc_printf("</b><br>" "<font size='-2'>");
        wc_printf(_("(One per line)"));
        wc_printf("</font>\n");
 
        /* Pop open an address book -- begin */
-       wc_printf(
-               "&nbsp;<a href=\"javascript:PopOpenAddressBook('attendees_box|%s');\" "
-               "title=\"%s\">"
-               "<img alt='' align='middle' border='0' width='16' height='16' src=\"static/webcit_icons/essen/16x16/contact.png\">"
-               "</a>",
-               _("Attendees"),
-               _("Contacts")
-       );
+       wc_printf("&nbsp;<a href=\"javascript:PopOpenAddressBook('attendees_box|%s');\" "
+                 "title=\"%s\">"
+                 "<img alt='' align='middle' border='0' width='16' height='16' src=\"static/webcit_icons/essen/16x16/contact.png\">"
+                 "</a>", _("Attendees"), _("Contacts")
+           );
        /* Pop open an address book -- end */
 
        wc_printf("</td><td>"
-               "<textarea %s name=\"attendees\" id=\"attendees_box\" "
-               "onchange=\"EnableOrDisableCheckButton();\" "
-               "onKeyPress=\"EnableOrDisableCheckButton();\" "
-               "rows='10' cols='72' style='width:72'>\n",
-               (organizer_is_me ? "" : "disabled='disabled' ")
-       );
+                 "<textarea %s name=\"attendees\" id=\"attendees_box\" "
+                 "onchange=\"EnableOrDisableCheckButton();\" "
+                 "onKeyPress=\"EnableOrDisableCheckButton();\" "
+                 "rows='10' cols='72' style='width:72'>\n", (organizer_is_me ? "" : "disabled='disabled' ")
+           );
        i = 0;
        for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY);
-           attendee != NULL;
-           attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
+            attendee != NULL; attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
                ch = icalproperty_get_attendee(attendee);
                if ((ch != NULL) && !strncasecmp(ch, "mailto:", 7)) {
 
                        /* screen name or email address */
                        safestrncpy(attendee_string, ch + 7, sizeof(attendee_string));
                        striplt(attendee_string);
-                       if (i++) wc_printf("\n");
+                       if (i++)
+                               wc_printf("\n");
                        escputs(attendee_string);
                        wc_printf(" ");
 
@@ -501,14 +477,12 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        }
 
        wc_printf("<input type=\"checkbox\" id=\"is_recur\" name=\"is_recur\" "
-               "value=\"yes\" "
-               "onclick=\"RecurrenceShowHide();\""
-               " %s >%s",
-               (rrule ? "checked=\"checked\"" : "" ),
-               _("This is a recurring event")
-       );
+                 "value=\"yes\" "
+                 "onclick=\"RecurrenceShowHide();\""
+                 " %s >%s", (rrule ? "checked=\"checked\"" : ""), _("This is a recurring event")
+           );
 
-       wc_printf("<div id=\"rrule_div\">\n");          /* begin 'rrule_div' div */
+       wc_printf("<div id=\"rrule_div\">\n");  /* begin 'rrule_div' div */
 
        wc_printf("<table border='0' cellspacing='10' width='100%%'>\n");
 
@@ -516,21 +490,19 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        wc_printf(_("Recurrence rule"));
        wc_printf("</b></td><td>");
 
-       if ((recur.freq < 0) || (recur.freq > 6)) recur.freq = 4;
+       if ((recur.freq < 0) || (recur.freq > 6))
+               recur.freq = 4;
        wc_printf("%s ", _("Repeats every"));
 
        wc_printf("<input type=\"text\" name=\"interval\" maxlength=\"3\" size=\"3\" ");
        wc_printf("value=\"%d\">&nbsp;", recur.interval);
 
-       wc_printf("<select name=\"freq\" id=\"freq_selector\" size=\"1\" "
-               "onChange=\"RecurrenceShowHide();\">\n");
-       for (i=0; i<(sizeof frequency_units / sizeof(char *)); ++i) {
+       wc_printf("<select name=\"freq\" id=\"freq_selector\" size=\"1\" " "onChange=\"RecurrenceShowHide();\">\n");
+       for (i = 0; i < (sizeof frequency_units / sizeof(char *)); ++i) {
                wc_printf("<option %s%svalue=\"%d\">%s</option>\n",
-                       ((i == recur.freq) ? "selected='selected' " : ""),
-                       (((i == recur.freq) || ((i>=3)&&(i<=6))) ? "" : "disabled='disabled' "),
-                       i,
-                       frequency_units[i]
-               );
+                         ((i == recur.freq) ? "selected='selected' " : ""),
+                         (((i == recur.freq) || ((i >= 3) && (i <= 6))) ? "" : "disabled='disabled' "), i, frequency_units[i]
+                   );
        }
        wc_printf("</select>\n");
 
@@ -539,26 +511,27 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
 
        memset(weekday_is_selected, 0, 7);
 
-       for (i=0; i<ICAL_BY_DAY_SIZE; ++i) {
+       for (i = 0; i < ICAL_BY_DAY_SIZE; ++i) {
                if (recur.by_day[i] == ICAL_RECURRENCE_ARRAY_MAX) {
-                       i = ICAL_RECURRENCE_ARRAY_MAX;                  /* all done */
+                       i = ICAL_RECURRENCE_ARRAY_MAX;  /* all done */
                }
                else {
-                       for (j=0; j<7; ++j) {
-                               if (icalrecurrencetype_day_day_of_week(recur.by_day[i]) == j+1) {
+                       for (j = 0; j < 7; ++j) {
+                               if (icalrecurrencetype_day_day_of_week(recur.by_day[i]) == j + 1) {
                                        weekday_is_selected[j] = 1;
                                }
                        }
                }
        }
 
-       for (j=0; j<7; ++j) {
-               i = ((j + (int)weekstart) % 7);
+       for (j = 0; j < 7; ++j) {
+               i = ((j + (int) weekstart) % 7);
                wc_printf("<input type=\"checkbox\" name=\"weekday%d\" value=\"yes\"", i);
-               if (weekday_is_selected[i]) wc_printf(" checked='checked'");
+               if (weekday_is_selected[i])
+                       wc_printf(" checked='checked'");
                wc_printf(">%s\n", weekday_labels[i]);
        }
-       wc_printf("</div>\n");                          /* end 'weekday_selector' div */
+       wc_printf("</div>\n");  /* end 'weekday_selector' div */
 
 
 
@@ -567,10 +540,9 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        wc_printf("<div id=\"monthday_selector\">");    /* begin 'monthday_selector' div */
 
        wc_printf("<input type=\"radio\" name=\"rrmonthtype\" id=\"rrmonthtype_mday\" "
-               "value=\"rrmonthtype_mday\" "
-               "%s onChange=\"RecurrenceShowHide();\">",
-               ((which_rrmonthtype_is_preselected == 0) ? "checked='checked'" : "")
-       );
+                 "value=\"rrmonthtype_mday\" "
+                 "%s onChange=\"RecurrenceShowHide();\">", ((which_rrmonthtype_is_preselected == 0) ? "checked='checked'" : "")
+           );
 
        rrmday = t_start.day;
        rrmweekday = icaltime_day_of_week(t_start) - 1;
@@ -597,38 +569,30 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        wc_printf("<br>\n");
 
        wc_printf("<input type=\"radio\" name=\"rrmonthtype\" id=\"rrmonthtype_wday\" "
-               "value=\"rrmonthtype_wday\" "
-               "%s onChange=\"RecurrenceShowHide();\">",
-               ((which_rrmonthtype_is_preselected == 1) ? "checked='checked'" : "")
-       );
+                 "value=\"rrmonthtype_wday\" "
+                 "%s onChange=\"RecurrenceShowHide();\">", ((which_rrmonthtype_is_preselected == 1) ? "checked='checked'" : "")
+           );
 
        wc_printf(_("on the "));
-       wc_printf("<select name=\"rrmweek\" id=\"rrmweek\" size=\"1\" "
-               "onChange=\"RecurrenceShowHide();\">\n");
-       for (i=1; i<=5; ++i) {
-               wc_printf("<option %svalue=\"%d\">%s</option>\n",
-                       ((i==rrmweek) ? "selected='selected' " : ""),
-                       i,
-                       ordinals[i]
-               );
+       wc_printf("<select name=\"rrmweek\" id=\"rrmweek\" size=\"1\" " "onChange=\"RecurrenceShowHide();\">\n");
+       for (i = 1; i <= 5; ++i) {
+               wc_printf("<option %svalue=\"%d\">%s</option>\n", ((i == rrmweek) ? "selected='selected' " : ""), i, ordinals[i]
+                   );
        }
        wc_printf("</select> \n");
 
-       wc_printf("<select name=\"rrmweekday\" id=\"rrmweekday\" size=\"1\" "
-               "onChange=\"RecurrenceShowHide();\">\n");
-       for (j=0; j<7; ++j) {
-               i = ((j + (int)weekstart) % 7);
+       wc_printf("<select name=\"rrmweekday\" id=\"rrmweekday\" size=\"1\" " "onChange=\"RecurrenceShowHide();\">\n");
+       for (j = 0; j < 7; ++j) {
+               i = ((j + (int) weekstart) % 7);
                wc_printf("<option %svalue=\"%d\">%s</option>\n",
-                       ((i==rrmweekday) ? "selected='selected' " : ""),
-                       i,
-                       weekday_labels[i]
-               );
+                         ((i == rrmweekday) ? "selected='selected' " : ""), i, weekday_labels[i]
+                   );
        }
        wc_printf("</select>");
 
        wc_printf(" %s<br>\n", _("of the month"));
 
-       wc_printf("</div>\n");                          /* end 'monthday_selector' div */
+       wc_printf("</div>\n");  /* end 'monthday_selector' div */
 
 
        rrymweek = rrmweek;
@@ -636,12 +600,11 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        rrymonth = t_start.month;
        which_rryeartype_is_preselected = 0;
 
-       if (
-               (recur.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX)
-               && (recur.by_day[0] != 0)
-               && (recur.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX)
-               && (recur.by_month[0] != 0)
-       ) {
+       if ((recur.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX)
+           && (recur.by_day[0] != 0)
+           && (recur.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX)
+           && (recur.by_month[0] != 0)
+           ) {
                which_rryeartype_is_preselected = 1;
                rrymweek = icalrecurrencetype_day_position(recur.by_day[0]);
                rrymweekday = icalrecurrencetype_day_day_of_week(recur.by_day[0]) - 1;
@@ -651,82 +614,70 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        wc_printf("<div id=\"yearday_selector\">");     /* begin 'yearday_selector' div */
 
        wc_printf("<input type=\"radio\" name=\"rryeartype\" id=\"rryeartype_ymday\" "
-               "value=\"rryeartype_ymday\" "
-               "%s onChange=\"RecurrenceShowHide();\">",
-               ((which_rryeartype_is_preselected == 0) ? "checked='checked'" : "")
-       );
+                 "value=\"rryeartype_ymday\" "
+                 "%s onChange=\"RecurrenceShowHide();\">", ((which_rryeartype_is_preselected == 0) ? "checked='checked'" : "")
+           );
        wc_printf(_("every "));
        wc_printf("<span id=\"ymday\">%s</span><br>", _("year on this date"));
 
        wc_printf("<input type=\"radio\" name=\"rryeartype\" id=\"rryeartype_ywday\" "
-               "value=\"rryeartype_ywday\" "
-               "%s onChange=\"RecurrenceShowHide();\">",
-               ((which_rryeartype_is_preselected == 1) ? "checked='checked'" : "")
-       );
+                 "value=\"rryeartype_ywday\" "
+                 "%s onChange=\"RecurrenceShowHide();\">", ((which_rryeartype_is_preselected == 1) ? "checked='checked'" : "")
+           );
 
        wc_printf(_("on the "));
-       wc_printf("<select name=\"rrymweek\" id=\"rrymweek\" size=\"1\" "
-               "onChange=\"RecurrenceShowHide();\">\n");
-       for (i=1; i<=5; ++i) {
-               wc_printf("<option %svalue=\"%d\">%s</option>\n",
-                       ((i==rrymweek) ? "selected='selected' " : ""),
-                       i,
-                       ordinals[i]
-               );
+       wc_printf("<select name=\"rrymweek\" id=\"rrymweek\" size=\"1\" " "onChange=\"RecurrenceShowHide();\">\n");
+       for (i = 1; i <= 5; ++i) {
+               wc_printf("<option %svalue=\"%d\">%s</option>\n", ((i == rrymweek) ? "selected='selected' " : ""), i, ordinals[i]
+                   );
        }
        wc_printf("</select> \n");
 
-       wc_printf("<select name=\"rrymweekday\" id=\"rrymweekday\" size=\"1\" "
-               "onChange=\"RecurrenceShowHide();\">\n");
-       for (j=0; j<7; ++j) {
-               i = ((j + (int)weekstart) % 7);
+       wc_printf("<select name=\"rrymweekday\" id=\"rrymweekday\" size=\"1\" " "onChange=\"RecurrenceShowHide();\">\n");
+       for (j = 0; j < 7; ++j) {
+               i = ((j + (int) weekstart) % 7);
                wc_printf("<option %svalue=\"%d\">%s</option>\n",
-                       ((i==rrymweekday) ? "selected='selected' " : ""),
-                       i,
-                       weekday_labels[i]
-               );
+                         ((i == rrymweekday) ? "selected='selected' " : ""), i, weekday_labels[i]
+                   );
        }
        wc_printf("</select>");
 
        wc_printf(" %s ", _("of"));
 
-       wc_printf("<select name=\"rrymonth\" id=\"rrymonth\" size=\"1\" "
-               "onChange=\"RecurrenceShowHide();\">\n");
-       for (i=1; i<=12; ++i) {
+       wc_printf("<select name=\"rrymonth\" id=\"rrymonth\" size=\"1\" " "onChange=\"RecurrenceShowHide();\">\n");
+       for (i = 1; i <= 12; ++i) {
                wc_printf("<option %svalue=\"%d\">%s</option>\n",
-                       ((i==rrymonth) ? "selected='selected' " : ""),
-                       i,
-                       month_labels[i-1]
-               );
+                         ((i == rrymonth) ? "selected='selected' " : ""), i, month_labels[i - 1]
+                   );
        }
        wc_printf("</select>");
        wc_printf("<br>\n");
 
-       wc_printf("</div>\n");                          /* end 'yearday_selector' div */
+       wc_printf("</div>\n");  /* end 'yearday_selector' div */
 
        wc_printf("</td></tr>\n");
 
 
        which_rrend_is_preselected = 0;
-       if (!icaltime_is_null_time(recur.until)) which_rrend_is_preselected = 2;
-       if (recur.count > 0) which_rrend_is_preselected = 1;
+       if (!icaltime_is_null_time(recur.until))
+               which_rrend_is_preselected = 2;
+       if (recur.count > 0)
+               which_rrend_is_preselected = 1;
 
        wc_printf("<tr><td><b>");
        wc_printf(_("Recurrence range"));
        wc_printf("</b></td><td>\n");
 
        wc_printf("<input type=\"radio\" name=\"rrend\" id=\"rrend_none\" "
-               "value=\"rrend_none\" "
-               "%s onChange=\"RecurrenceShowHide();\">",
-               ((which_rrend_is_preselected == 0) ? "checked='checked'" : "")
-       );
+                 "value=\"rrend_none\" "
+                 "%s onChange=\"RecurrenceShowHide();\">", ((which_rrend_is_preselected == 0) ? "checked='checked'" : "")
+           );
        wc_printf("%s<br>\n", _("No ending date"));
 
        wc_printf("<input type=\"radio\" name=\"rrend\" id=\"rrend_count\" "
-               "value=\"rrend_count\" "
-               "%s onChange=\"RecurrenceShowHide();\">",
-               ((which_rrend_is_preselected == 1) ? "checked='checked'" : "")
-       );
+                 "value=\"rrend_count\" "
+                 "%s onChange=\"RecurrenceShowHide();\">", ((which_rrend_is_preselected == 1) ? "checked='checked'" : "")
+           );
        wc_printf(_("Repeat this event"));
        wc_printf(" <input type=\"text\" name=\"rrcount\" id=\"rrcount\" maxlength=\"3\" size=\"3\" ");
        wc_printf("value=\"%d\"> ", recur.count);
@@ -734,10 +685,9 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        wc_printf("<br>\n");
 
        wc_printf("<input type=\"radio\" name=\"rrend\" id=\"rrend_until\" "
-               "value=\"rrend_until\" "
-               "%s onChange=\"RecurrenceShowHide();\">",
-               ((which_rrend_is_preselected == 2) ? "checked='checked'" : "")
-       );
+                 "value=\"rrend_until\" "
+                 "%s onChange=\"RecurrenceShowHide();\">", ((which_rrend_is_preselected == 2) ? "checked='checked'" : "")
+           );
        wc_printf(_("Repeat this event until "));
 
        if (icaltime_is_null_time(recur.until)) {
@@ -749,34 +699,28 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        wc_printf("</td></tr>\n");
 
        wc_printf("</table>\n");
-       wc_printf("</div>\n");                          /* end 'rrule' div */
+       wc_printf("</div>\n");  /* end 'rrule' div */
 
        end_tab(2, 3);
 
        /* submit buttons (common area beneath the tabs) */
        begin_tab(3, 3);
        wc_printf("<center>"
-               "<input type=\"submit\" name=\"save_button\" value=\"%s\">"
-               "&nbsp;&nbsp;"
-               "<input type=\"submit\" name=\"delete_button\" value=\"%s\">\n"
-               "&nbsp;&nbsp;"
-               "<input type=\"submit\" id=\"check_button\" name=\"check_button\" value=\"%s\">\n"
-               "&nbsp;&nbsp;"
-               "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">\n"
-               "</center>\n",
-               _("Save"),
-               _("Delete"),
-               _("Check attendee availability"),
-               _("Cancel")
-       );
+                 "<input type=\"submit\" name=\"save_button\" value=\"%s\">"
+                 "&nbsp;&nbsp;"
+                 "<input type=\"submit\" name=\"delete_button\" value=\"%s\">\n"
+                 "&nbsp;&nbsp;"
+                 "<input type=\"submit\" id=\"check_button\" name=\"check_button\" value=\"%s\">\n"
+                 "&nbsp;&nbsp;"
+                 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">\n"
+                 "</center>\n", _("Save"), _("Delete"), _("Check attendee availability"), _("Cancel")
+           );
        end_tab(3, 3);
        wc_printf("</form>\n");
 
        StrBufAppendPrintf(WC->trailing_javascript,
-               "eventEditAllDay();             \n"
-               "RecurrenceShowHide();          \n"
-               "EnableOrDisableCheckButton();  \n"
-       );
+                          "eventEditAllDay();          \n"
+                          "RecurrenceShowHide();               \n" "EnableOrDisableCheckButton();      \n");
        do_template("addressbook_popup");
 
        wDumpContent(1);
@@ -792,8 +736,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
  * supplied_vevent:    the event to save
  * msgnum:             the index on the citserver
  */
-void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *from,
-                       int unread, calview *calv) {
+void save_individual_event(icalcomponent * supplied_vevent, long msgnum, char *from, int unread, calview * calv) {
        StrBuf *Buf;
        char buf[SIZ];
        icalproperty *prop;
@@ -826,11 +769,8 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                 * new one.
                 */
                if (icalcomponent_isa(vevent) == ICAL_VCALENDAR_COMPONENT) {
-                       save_individual_event(
-                               icalcomponent_get_first_component(
-                                       vevent, ICAL_VEVENT_COMPONENT),
-                               msgnum, from, unread, NULL
-                       );
+                       save_individual_event(icalcomponent_get_first_component(vevent, ICAL_VEVENT_COMPONENT),
+                                             msgnum, from, unread, NULL);
                        return;
                }
        }
@@ -839,51 +779,42 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                created_new_vevent = 1;
        }
 
-       if ( (havebstr("save_button"))
-          || (havebstr("check_button")) ) {
+       if ((havebstr("save_button"))
+           || (havebstr("check_button"))) {
 
                /* Replace values in the component with ones from the form */
 
-               while (prop = icalcomponent_get_first_property(vevent,
-                     ICAL_SUMMARY_PROPERTY), prop != NULL) {
+               while (prop = icalcomponent_get_first_property(vevent, ICAL_SUMMARY_PROPERTY), prop != NULL) {
                        icalcomponent_remove_property(vevent, prop);
                        icalproperty_free(prop);
                }
 
                /* Add NOW() to the calendar object... */
-               icalcomponent_set_dtstamp(vevent,
-                                         icaltime_from_timet_with_zone(
-                                                 time(NULL), 0, icaltimezone_get_utc_timezone()));
-
-               if (havebstr("summary")) {
-                       icalcomponent_add_property(vevent,
-                                       icalproperty_new_summary(bstr("summary")));
-               } else {
-                       icalcomponent_add_property(vevent,
-                                       icalproperty_new_summary(_("Untitled Event")));
-               }
-
-               while (prop = icalcomponent_get_first_property(vevent,
-                                       ICAL_LOCATION_PROPERTY), prop != NULL) {
-                       icalcomponent_remove_property(vevent, prop);
-                       icalproperty_free(prop);
-               }
-               if (havebstr("location")) {
-                       icalcomponent_add_property(vevent,
-                                       icalproperty_new_location(bstr("location")));
-               }
-               while (prop = icalcomponent_get_first_property(vevent,
-                                 ICAL_DESCRIPTION_PROPERTY), prop != NULL) {
-                       icalcomponent_remove_property(vevent, prop);
-                       icalproperty_free(prop);
-               }
-               if (havebstr("description")) {
-                       icalcomponent_add_property(vevent,
-                               icalproperty_new_description(bstr("description")));
-               }
-
-               while (prop = icalcomponent_get_first_property(vevent,
-                     ICAL_DTSTART_PROPERTY), prop != NULL) {
+               icalcomponent_set_dtstamp(vevent, icaltime_from_timet_with_zone(time(NULL), 0, icaltimezone_get_utc_timezone()));
+
+               if (havebstr("summary")) {
+                       icalcomponent_add_property(vevent, icalproperty_new_summary(bstr("summary")));
+               }
+               else {
+                       icalcomponent_add_property(vevent, icalproperty_new_summary(_("Untitled Event")));
+               }
+
+               while (prop = icalcomponent_get_first_property(vevent, ICAL_LOCATION_PROPERTY), prop != NULL) {
+                       icalcomponent_remove_property(vevent, prop);
+                       icalproperty_free(prop);
+               }
+               if (havebstr("location")) {
+                       icalcomponent_add_property(vevent, icalproperty_new_location(bstr("location")));
+               }
+               while (prop = icalcomponent_get_first_property(vevent, ICAL_DESCRIPTION_PROPERTY), prop != NULL) {
+                       icalcomponent_remove_property(vevent, prop);
+                       icalproperty_free(prop);
+               }
+               if (havebstr("description")) {
+                       icalcomponent_add_property(vevent, icalproperty_new_description(bstr("description")));
+               }
+
+               while (prop = icalcomponent_get_first_property(vevent, ICAL_DTSTART_PROPERTY), prop != NULL) {
                        icalcomponent_remove_property(vevent, prop);
                        icalproperty_free(prop);
                }
@@ -909,16 +840,16 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                        icalproperty_set_value(prop, icalvalue_new_date(event_start));
                }
 
-               if (prop) icalcomponent_add_property(vevent, prop);
-               else icalproperty_free(prop);
+               if (prop)
+                       icalcomponent_add_property(vevent, prop);
+               else
+                       icalproperty_free(prop);
 
-               while (prop = icalcomponent_get_first_property(vevent,
-                     ICAL_DTEND_PROPERTY), prop != NULL) {
+               while (prop = icalcomponent_get_first_property(vevent, ICAL_DTEND_PROPERTY), prop != NULL) {
                        icalcomponent_remove_property(vevent, prop);
                        icalproperty_free(prop);
                }
-               while (prop = icalcomponent_get_first_property(vevent,
-                     ICAL_DURATION_PROPERTY), prop != NULL) {
+               while (prop = icalcomponent_get_first_property(vevent, ICAL_DURATION_PROPERTY), prop != NULL) {
                        icalcomponent_remove_property(vevent, prop);
                        icalproperty_free(prop);
                }
@@ -933,10 +864,9 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                        icaltime_from_webform(&t, "dtend");
                }
 
-               icalcomponent_add_property(vevent,
-                       icalproperty_new_dtend(icaltime_normalize(t)
-                       )
-               );
+               icalcomponent_add_property(vevent, icalproperty_new_dtend(icaltime_normalize(t)
+                                          )
+                   );
 
                /* recurrence rules -- begin */
 
@@ -953,60 +883,60 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                        recur.interval = atoi(bstr("interval"));
                        recur.freq = atoi(bstr("freq"));
 
-                       switch(recur.freq) {
+                       switch (recur.freq) {
 
                                /* These can't happen; they're disabled. */
-                               case ICAL_SECONDLY_RECURRENCE:
-                                       break;
-                               case ICAL_MINUTELY_RECURRENCE:
-                                       break;
-                               case ICAL_HOURLY_RECURRENCE:
-                                       break;
+                       case ICAL_SECONDLY_RECURRENCE:
+                               break;
+                       case ICAL_MINUTELY_RECURRENCE:
+                               break;
+                       case ICAL_HOURLY_RECURRENCE:
+                               break;
 
                                /* Daily is valid but there are no further inputs. */
-                               case ICAL_DAILY_RECURRENCE:
-                                       break;
+                       case ICAL_DAILY_RECURRENCE:
+                               break;
 
                                /* These are the real options. */
 
-                               case ICAL_WEEKLY_RECURRENCE:
-                                       j=0;
-                                       for (i=0; i<7; ++i) {
-                                               snprintf(buf, sizeof buf, "weekday%d", i);
-                                               if (YESBSTR(buf)) recur.by_day[j++] =
-                                                       icalrecurrencetype_day_day_of_week(i+1);
-                                       }
-                                       recur.by_day[j++] = ICAL_RECURRENCE_ARRAY_MAX;
-                                       break;
-
-                               case ICAL_MONTHLY_RECURRENCE:
-                                       if (!strcasecmp(bstr("rrmonthtype"), "rrmonthtype_mday")) {
-                                               recur.by_month_day[0] = event_start.day;
-                                               recur.by_month_day[1] = ICAL_RECURRENCE_ARRAY_MAX;
-                                       }
-                                       else if (!strcasecmp(bstr("rrmonthtype"), "rrmonthtype_wday")) {
-                                               recur.by_day[0] = (atoi(bstr("rrmweek")) * 8)
-                                                               + atoi(bstr("rrmweekday")) + 1;
-                                               recur.by_day[1] = ICAL_RECURRENCE_ARRAY_MAX;
-                                       }
-                                       break;
-
-                               case ICAL_YEARLY_RECURRENCE:
-                                       if (!strcasecmp(bstr("rryeartype"), "rryeartype_ymday")) {
-                                               /* no further action is needed here */
-                                       }
-                                       else if (!strcasecmp(bstr("rryeartype"), "rryeartype_ywday")) {
-                                               recur.by_month[0] = atoi(bstr("rrymonth"));
-                                               recur.by_month[1] = ICAL_RECURRENCE_ARRAY_MAX;
-                                               recur.by_day[0] = (atoi(bstr("rrymweek")) * 8)
-                                                               + atoi(bstr("rrymweekday")) + 1;
-                                               recur.by_day[1] = ICAL_RECURRENCE_ARRAY_MAX;
-                                       }
-                                       break;
+                       case ICAL_WEEKLY_RECURRENCE:
+                               j = 0;
+                               for (i = 0; i < 7; ++i) {
+                                       snprintf(buf, sizeof buf, "weekday%d", i);
+                                       if (YESBSTR(buf))
+                                               recur.by_day[j++] = icalrecurrencetype_day_day_of_week(i + 1);
+                               }
+                               recur.by_day[j++] = ICAL_RECURRENCE_ARRAY_MAX;
+                               break;
+
+                       case ICAL_MONTHLY_RECURRENCE:
+                               if (!strcasecmp(bstr("rrmonthtype"), "rrmonthtype_mday")) {
+                                       recur.by_month_day[0] = event_start.day;
+                                       recur.by_month_day[1] = ICAL_RECURRENCE_ARRAY_MAX;
+                               }
+                               else if (!strcasecmp(bstr("rrmonthtype"), "rrmonthtype_wday")) {
+                                       recur.by_day[0] = (atoi(bstr("rrmweek")) * 8)
+                                           + atoi(bstr("rrmweekday")) + 1;
+                                       recur.by_day[1] = ICAL_RECURRENCE_ARRAY_MAX;
+                               }
+                               break;
+
+                       case ICAL_YEARLY_RECURRENCE:
+                               if (!strcasecmp(bstr("rryeartype"), "rryeartype_ymday")) {
+                                       /* no further action is needed here */
+                               }
+                               else if (!strcasecmp(bstr("rryeartype"), "rryeartype_ywday")) {
+                                       recur.by_month[0] = atoi(bstr("rrymonth"));
+                                       recur.by_month[1] = ICAL_RECURRENCE_ARRAY_MAX;
+                                       recur.by_day[0] = (atoi(bstr("rrymweek")) * 8)
+                                           + atoi(bstr("rrymweekday")) + 1;
+                                       recur.by_day[1] = ICAL_RECURRENCE_ARRAY_MAX;
+                               }
+                               break;
 
                                /* This one can't happen either. */
-                               case ICAL_NO_RECURRENCE:
-                                       break;
+                       case ICAL_NO_RECURRENCE:
+                               break;
                        }
 
                        if (!strcasecmp(bstr("rrend"), "rrend_count")) {
@@ -1030,8 +960,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                                formtransp = ICAL_TRANSP_TRANSPARENT;
                        }
 
-                       while (prop = icalcomponent_get_first_property(vevent, ICAL_TRANSP_PROPERTY),
-                             (prop != NULL)) {
+                       while (prop = icalcomponent_get_first_property(vevent, ICAL_TRANSP_PROPERTY), (prop != NULL)) {
                                icalcomponent_remove_property(vevent, prop);
                                icalproperty_free(prop);
                        }
@@ -1040,39 +969,35 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                }
 
                /* Give this event a UID if it doesn't have one. */
-               if (icalcomponent_get_first_property(vevent,
-                  ICAL_UID_PROPERTY) == NULL) {
+               if (icalcomponent_get_first_property(vevent, ICAL_UID_PROPERTY) == NULL) {
                        generate_uuid(buf);
                        icalcomponent_add_property(vevent, icalproperty_new_uid(buf));
                }
 
                /* Increment the sequence ID */
-               while (prop = icalcomponent_get_first_property(vevent,
-                     ICAL_SEQUENCE_PROPERTY), (prop != NULL) ) {
+               while (prop = icalcomponent_get_first_property(vevent, ICAL_SEQUENCE_PROPERTY), (prop != NULL)) {
                        i = icalproperty_get_sequence(prop);
-                       if (i > sequence) sequence = i;
+                       if (i > sequence)
+                               sequence = i;
                        icalcomponent_remove_property(vevent, prop);
                        icalproperty_free(prop);
                }
                ++sequence;
-               icalcomponent_add_property(vevent,
-                       icalproperty_new_sequence(sequence)
-               );
+               icalcomponent_add_property(vevent, icalproperty_new_sequence(sequence)
+                   );
 
                /*
                 * Set the organizer, only if one does not already exist *and*
                 * the form is supplying one
                 */
                strcpy(buf, bstr("organizer"));
-               if ( (icalcomponent_get_first_property(vevent,
-                  ICAL_ORGANIZER_PROPERTY) == NULL)
-                  && (!IsEmptyStr(buf)) ) {
+               if ((icalcomponent_get_first_property(vevent, ICAL_ORGANIZER_PROPERTY) == NULL)
+                   && (!IsEmptyStr(buf))) {
 
                        /* set new organizer */
                        sprintf(organizer_string, "MAILTO:%s", buf);
-                       icalcomponent_add_property(vevent,
-                               icalproperty_new_organizer(organizer_string)
-                       );
+                       icalcomponent_add_property(vevent, icalproperty_new_organizer(organizer_string)
+                           );
 
                }
 
@@ -1082,28 +1007,29 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
 
                /* First, strip out the parenthesized partstats.  */
                strcpy(form_attendees, bstr("attendees"));
-               while ( stripout(form_attendees, '(', ')') != 0);
+               while (stripout(form_attendees, '(', ')') != 0);
 
                /* Next, change any commas to newlines, because we want newline-separated attendees. */
                j = strlen(form_attendees);
-               for (i=0; i<j; ++i) {
+               for (i = 0; i < j; ++i) {
                        if (form_attendees[i] == ',') {
                                form_attendees[i] = '\n';
-                               while (isspace(form_attendees[i+1])) {
-                                       strcpy(&form_attendees[i+1], &form_attendees[i+2]);
+                               while (isspace(form_attendees[i + 1])) {
+                                       strcpy(&form_attendees[i + 1], &form_attendees[i + 2]);
                                }
                        }
                }
 
                /* Now iterate! */
-               for (i=0; i<num_tokens(form_attendees, '\n'); ++i) {
+               for (i = 0; i < num_tokens(form_attendees, '\n'); ++i) {
                        extract_token(buf, form_attendees, i, '\n', sizeof buf);
                        striplt(buf);
                        if (!IsEmptyStr(buf)) {
                                sprintf(attendee_string, "MAILTO:%s", buf);
                                foundit = 0;
 
-                               for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY); attendee != NULL; attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
+                               for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY); attendee != NULL;
+                                    attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
                                        ch = icalproperty_get_attendee(attendee);
                                        if ((ch != NULL) && !strcasecmp(attendee_string, ch))
                                                ++foundit;
@@ -1111,9 +1037,8 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
 
 
                                if (foundit == 0) {
-                                       icalcomponent_add_property(vevent,
-                                                                  icalproperty_new_attendee(attendee_string)
-                                       );
+                                       icalcomponent_add_property(vevent, icalproperty_new_attendee(attendee_string)
+                                           );
                                }
                        }
                }
@@ -1121,16 +1046,18 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                /*
                 * Remove any attendees *not* listed in the web form
                 */
-STARTOVER:     for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY); attendee != NULL; attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
+             STARTOVER:for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY); attendee != NULL;
+                    attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
                        ch = icalproperty_get_attendee(attendee);
                        if ((ch != NULL) && !strncasecmp(ch, "MAILTO:", 7)) {
                                safestrncpy(attendee_string, ch + 7, sizeof(attendee_string));
                                striplt(attendee_string);
                                foundit = 0;
-                               for (i=0; i<num_tokens(form_attendees, '\n'); ++i) {
+                               for (i = 0; i < num_tokens(form_attendees, '\n'); ++i) {
                                        extract_token(buf, form_attendees, i, '\n', sizeof buf);
                                        striplt(buf);
-                                       if (!strcasecmp(buf, attendee_string)) ++foundit;
+                                       if (!strcasecmp(buf, attendee_string))
+                                               ++foundit;
                                }
                                if (foundit == 0) {
                                        icalcomponent_remove_property(vevent, attendee);
@@ -1153,7 +1080,7 @@ STARTOVER:        for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDE
                icalcomponent_set_method(encaps, ICAL_METHOD_PUBLISH);
 
                /* If the user clicked 'Save' then save it to the server. */
-               if ( (encaps != NULL) && (havebstr("save_button")) ) {
+               if ((encaps != NULL) && (havebstr("save_button"))) {
                        serv_puts("ENT0 1|||4|||1|");
                        serv_getln(buf, sizeof buf);
                        switch (buf[0]) {
@@ -1164,24 +1091,25 @@ STARTOVER:      for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDE
                                Buf = NewStrBufPlain(icalcomponent_as_ical_string(encaps), -1);
                                text_to_server_qp(Buf);
                                FreeStrBuf(&Buf);
-//                             serv_puts(icalcomponent_as_ical_string(encaps));
+//                              serv_puts(icalcomponent_as_ical_string(encaps));
                                serv_puts("000");
                        case '4':
-                               while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {}
+                               while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+                               }
                                break;
                        case '2':
-                               AppendImportantMessage(buf + 4, - 1);
+                               AppendImportantMessage(buf + 4, -1);
                                break;
                        default:
                                break;
                        }
-                       icalmemory_free_ring ();
+                       icalmemory_free_ring();
                        icalcomponent_free(encaps);
                        encaps = NULL;
                }
 
                /* Or, check attendee availability if the user asked for that. */
-               if ( (encaps != NULL) && (havebstr("check_button")) ) {
+               if ((encaps != NULL) && (havebstr("check_button"))) {
 
                        /* Call this function, which does the real work */
                        check_attendee_availability(encaps);
@@ -1202,7 +1130,7 @@ STARTOVER:        for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDE
        /*
         * If the user clicked 'Delete' then delete it.
         */
-       if ( (havebstr("delete_button")) && (msgnum > 0L) ) {
+       if ((havebstr("delete_button")) && (msgnum > 0L)) {
                serv_printf("DELE %ld", lbstr("msgnum"));
                serv_getln(buf, sizeof buf);
        }
index 00bc5074f6f31ada34ffe77cdf44066bb25a58ad..ce154c27cc17554f26d9cd29088fb68a2904ef51 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * RSS feed generator (could be adapted in the future to feed both RSS and Atom)
  *
@@ -34,7 +35,8 @@ void feed_rss_one_message(long msgnum) {
        /* Phase 1: read the message into memory */
        serv_printf("MSG4 %ld", msgnum);
        serv_getln(buf, sizeof buf);
-       if (buf[0] != '1') return;
+       if (buf[0] != '1')
+               return;
        StrBuf *ServerResponse = NewStrBuf();
        while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
                StrBufAppendPrintf(ServerResponse, "%s\n", buf);
@@ -42,7 +44,7 @@ void feed_rss_one_message(long msgnum) {
 
        /* Phase 2: help SkyNet become self-aware */
        BufPtr = NULL;
-       while (StrBufSipLine(Line, ServerResponse, &BufPtr), ((BufPtr!=StrBufNOTNULL)&&(BufPtr!=NULL)) ) {
+       while (StrBufSipLine(Line, ServerResponse, &BufPtr), ((BufPtr != StrBufNOTNULL) && (BufPtr != NULL))) {
                if (in_body) {
                        /* do nothing */
                }
@@ -62,7 +64,7 @@ void feed_rss_one_message(long msgnum) {
         * Phase 3: output the message in RSS <item> form
         * (suppress replies [comments] if this is a blog room)
         */
-       if ( (WC->CurRoom.view != VIEW_BLOG) || (is_top_level_post == 1) ) {
+       if ((WC->CurRoom.view != VIEW_BLOG) || (is_top_level_post == 1)) {
                wc_printf("<item>");
                wc_printf("<link>%s/readfwd?go=", ChrPtr(site_prefix));
                urlescputs(ChrPtr(WC->CurRoom.name));
@@ -73,15 +75,15 @@ void feed_rss_one_message(long msgnum) {
                        wc_printf("?start_reading_at=%ld", msgnum);
                }
                wc_printf("</link>");
-       
+
                BufPtr = NULL;
                in_body = 0;
                in_messagetext = 0;
-               while (StrBufSipLine(Line, ServerResponse, &BufPtr), ((BufPtr!=StrBufNOTNULL)&&(BufPtr!=NULL)) ) {
+               while (StrBufSipLine(Line, ServerResponse, &BufPtr), ((BufPtr != StrBufNOTNULL) && (BufPtr != NULL))) {
                        safestrncpy(buf, ChrPtr(Line), sizeof buf);
 
                        /* XML parsers can be picky; strip out nonprintable header characters */
-                       if ((strlen(buf)>=6) && (buf[4]=='=')) {
+                       if ((strlen(buf) >= 6) && (buf[4] == '=')) {
                                char *p = &buf[5];
                                while (*p) {
                                        if (!isprint(*p)) {
@@ -123,18 +125,17 @@ void feed_rss_one_message(long msgnum) {
                                }
                                if (!found_guid) {
                                        wc_printf("<guid isPermaLink=\"false\">%ld@%s</guid>",
-                                               msgnum,
-                                               ChrPtr(WC->serv_info->serv_humannode)
-                                       );
+                                                 msgnum, ChrPtr(WC->serv_info->serv_humannode)
+                                           );
                                }
                                wc_printf("<description>");
                                in_body = 1;
                                messagetext = NewStrBuf();
                        }
                }
-       
+
                if (in_body) {
-                       cdataout((char*)ChrPtr(messagetext));
+                       cdataout((char *) ChrPtr(messagetext));
                        FreeStrBuf(&messagetext);
                        wc_printf("</description>");
                }
@@ -163,11 +164,12 @@ void feed_rss_do_messages(void) {
        Stat.lowest_found = (-1);
        Stat.highest_found = (-1);
        num_msgs = load_msg_ptrs("MSGS ALL", NULL, NULL, &Stat, NULL, NULL, NULL, NULL, 0);
-       if (num_msgs < 1) return;
+       if (num_msgs < 1)
+               return;
 
-       i = num_msgs;                                   /* convention is to feed newest-to-oldest */
+       i = num_msgs;           /* convention is to feed newest-to-oldest */
        while (i > 0) {
-               Msg = GetMessagePtrAt(i-1, WCC->summ);
+               Msg = GetMessagePtrAt(i - 1, WCC->summ);
                if (Msg != NULL) {
                        feed_rss_one_message(Msg->msgnum);
                }
@@ -179,8 +181,7 @@ void feed_rss_do_messages(void) {
 /*
  * Output the room info file of the current room as a <description> for the channel
  */
-void feed_rss_do_room_info_as_description(void)
-{
+void feed_rss_do_room_info_as_description(void) {
        wc_printf("<description>");
        escputs(ChrPtr(WC->CurRoom.name));      /* FIXME use the output of RINF instead */
        wc_printf("</description>\r\n");
@@ -195,18 +196,11 @@ void feed_rss(void) {
 
        output_headers(0, 0, 0, 0, 1, 0);
        hprintf("Content-type: text/xml; charset=utf-8\r\n");
-       hprintf(
-               "Server: %s / %s\r\n"
-               "Connection: close\r\n"
-       ,
-               PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
-       );
+       hprintf("Server: %s / %s\r\n" "Connection: close\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
+           );
        begin_burst();
 
-       wc_printf("<?xml version=\"1.0\"?>"
-               "<rss version=\"2.0\">"
-               "<channel>"
-       );
+       wc_printf("<?xml version=\"1.0\"?>" "<rss version=\"2.0\">" "<channel>");
 
        wc_printf("<title>");
        escputs(ChrPtr(WC->CurRoom.name));
@@ -240,10 +234,7 @@ void feed_rss(void) {
        feed_rss_do_room_info_as_description();
        feed_rss_do_messages();
 
-       wc_printf("</channel>"
-               "</rss>"
-               "\r\n\r\n"
-       );
+       wc_printf("</channel>" "</rss>" "\r\n\r\n");
 
        wDumpContent(0);
 }
@@ -252,25 +243,20 @@ void feed_rss(void) {
 /*
  * Offer the RSS feed meta tag for this room
  */
-void tmplput_rssmeta(StrBuf *Target, WCTemplputParams *TP) 
-{
+void tmplput_rssmeta(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
        char feed_link[1024];
 
        strcpy(feed_link, "/feed_rss?go=");
-       urlesc(&feed_link[20], sizeof(feed_link) - 20, (char *)ChrPtr(WCC->CurRoom.name) );
-       StrBufAppendPrintf(Target,
-               "<link rel=\"alternate\" title=\"RSS\" href=\"%s\" type=\"application/rss+xml\">",
-               feed_link
-       );
+       urlesc(&feed_link[20], sizeof(feed_link) - 20, (char *) ChrPtr(WCC->CurRoom.name));
+       StrBufAppendPrintf(Target, "<link rel=\"alternate\" title=\"RSS\" href=\"%s\" type=\"application/rss+xml\">", feed_link);
 }
 
 
 /*
  * Offer the RSS feed button for this room
  */
-void tmplput_rssbutton(StrBuf *Target, WCTemplputParams *TP) 
-{
+void tmplput_rssbutton(StrBuf * Target, WCTemplputParams * TP) {
        StrBuf *FeedLink = NULL;
 
        FeedLink = NewStrBufPlain(HKEY("/feed_rss?go="));
@@ -284,11 +270,8 @@ void tmplput_rssbutton(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void 
-InitModule_RSS
-(void)
-{
-       WebcitAddUrlHandler(HKEY("feed_rss"), "", 0, feed_rss, ANONYMOUS|COOKIEUNNEEDED);
+void InitModule_RSS(void) {
+       WebcitAddUrlHandler(HKEY("feed_rss"), "", 0, feed_rss, ANONYMOUS | COOKIEUNNEEDED);
        RegisterNamespace("THISROOM:FEED:RSS", 0, 0, tmplput_rssbutton, NULL, CTX_NONE);
        RegisterNamespace("THISROOM:FEED:RSSMETA", 0, 0, tmplput_rssmeta, NULL, CTX_NONE);
 }
index a14c3d5c3026ca60c1a0263689273572bd4a52d7..1d24d87f6c103cd633aa2af8873741588bded70b 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2012 by the citadel.org team
  *
@@ -19,7 +20,8 @@ extern locale_t *wc_locales;
 
 typedef unsigned char byte;
 
-#define FALSE 0 /**< no. */
+#define FALSE 0        /**< no. */
+
 #define TRUE 1 /**< yes. */
 
 /*
@@ -31,8 +33,7 @@ typedef unsigned char byte;
  * format      strftime() format
  * tm          Input date/time
  */
-size_t wc_strftime(char *s, size_t max, const char *format, const struct tm *tm)
-{
+size_t wc_strftime(char *s, size_t max, const char *format, const struct tm *tm) {
 
 #ifdef ENABLE_NLS
 #ifdef HAVE_USELOCALE
@@ -55,15 +56,14 @@ size_t wc_strftime(char *s, size_t max, const char *format, const struct tm *tm)
 /*
  * Format a date/time stamp for output 
  */
-long webcit_fmt_date(char *buf, size_t siz, time_t thetime, int Format)
-{
+long webcit_fmt_date(char *buf, size_t siz, time_t thetime, int Format) {
        long retlen = 0;
        struct tm tm;
        struct tm today_tm;
        time_t today_timet;
        int time_format;
 
-       time_format = get_time_format_cached ();
+       time_format = get_time_format_cached();
        today_timet = time(NULL);
        localtime_r(&today_timet, &today_tm);
 
@@ -72,45 +72,45 @@ long webcit_fmt_date(char *buf, size_t siz, time_t thetime, int Format)
        /*
         * DATEFMT_FULL:      full display 
         * DATEFMT_BRIEF:     if date == today, show only the time
-        *                    otherwise, for messages up to 6 months old, 
+        *                    otherwise, for messages up to 6 months old, 
         *                 show the month and day, and the time
-        *                    older than 6 months, show only the date
+        *                    older than 6 months, show only the date
         * DATEFMT_RAWDATE:   show full date, regardless of age 
         * DATEFMT_LOCALEDATE:   show full date as prefered for the locale
         */
 
        switch (Format) {
-               case DATEFMT_BRIEF:
-                       if ((tm.tm_year == today_tm.tm_year)
-                         &&(tm.tm_mon == today_tm.tm_mon)
-                         &&(tm.tm_mday == today_tm.tm_mday)) {
-                               if (time_format == WC_TIMEFORMAT_24) 
-                                       retlen = wc_strftime(buf, siz, "%k:%M", &tm);
-                               else
-                                       retlen = wc_strftime(buf, siz, "%l:%M%p", &tm);
-                       }
-                       else if (today_timet - thetime < 15552000) {
-                               if (time_format == WC_TIMEFORMAT_24) 
-                                       retlen = wc_strftime(buf, siz, "%b %d %k:%M", &tm);
-                               else
-                                       retlen = wc_strftime(buf, siz, "%b %d %l:%M%p", &tm);
-                       }
-                       else {
-                               retlen = wc_strftime(buf, siz, "%b %d %Y", &tm);
-                       }
-                       break;
-               case DATEFMT_FULL:
+       case DATEFMT_BRIEF:
+               if ((tm.tm_year == today_tm.tm_year)
+                   && (tm.tm_mon == today_tm.tm_mon)
+                   && (tm.tm_mday == today_tm.tm_mday)) {
+                       if (time_format == WC_TIMEFORMAT_24)
+                               retlen = wc_strftime(buf, siz, "%k:%M", &tm);
+                       else
+                               retlen = wc_strftime(buf, siz, "%l:%M%p", &tm);
+               }
+               else if (today_timet - thetime < 15552000) {
                        if (time_format == WC_TIMEFORMAT_24)
-                               retlen = wc_strftime(buf, siz, "%a %b %d %Y %T %Z", &tm);
+                               retlen = wc_strftime(buf, siz, "%b %d %k:%M", &tm);
                        else
-                               retlen = wc_strftime(buf, siz, "%a %b %d %Y %r %Z", &tm);
-                       break;
-               case DATEFMT_RAWDATE:
-                       retlen = wc_strftime(buf, siz, "%a %b %d %Y", &tm);
-                       break;
-               case DATEFMT_LOCALEDATE:
-                       retlen = wc_strftime(buf, siz, "%x", &tm);
-                       break;
+                               retlen = wc_strftime(buf, siz, "%b %d %l:%M%p", &tm);
+               }
+               else {
+                       retlen = wc_strftime(buf, siz, "%b %d %Y", &tm);
+               }
+               break;
+       case DATEFMT_FULL:
+               if (time_format == WC_TIMEFORMAT_24)
+                       retlen = wc_strftime(buf, siz, "%a %b %d %Y %T %Z", &tm);
+               else
+                       retlen = wc_strftime(buf, siz, "%a %b %d %Y %r %Z", &tm);
+               break;
+       case DATEFMT_RAWDATE:
+               retlen = wc_strftime(buf, siz, "%a %b %d %Y", &tm);
+               break;
+       case DATEFMT_LOCALEDATE:
+               retlen = wc_strftime(buf, siz, "%x", &tm);
+               break;
        }
        return retlen;
 }
@@ -124,7 +124,7 @@ long guess_calhourformat(void) {
        struct tm tm;
        memset(&tm, 0, sizeof tm);
        wc_strftime(buf, 64, "%X", &tm);
-       if (buf[strlen(buf)-1] == 'M') {
+       if (buf[strlen(buf) - 1] == 'M') {
                return 12;
        }
        return 24;
@@ -134,13 +134,11 @@ long guess_calhourformat(void) {
 /*
  * learn the users timeformat preference.
  */
-int get_time_format_cached (void)
-{
+int get_time_format_cached(void) {
        long calhourformat;
        int *time_format_cache;
        time_format_cache = &(WC->time_format_cache);
-       if (*time_format_cache == WC_TIMEFORMAT_NONE)
-       {
+       if (*time_format_cache == WC_TIMEFORMAT_NONE) {
                get_pref_long("calhourformat", &calhourformat, 99);
 
                /* If we don't know the user's time format preference yet,
@@ -151,7 +149,7 @@ int get_time_format_cached (void)
                }
 
                /* Now set the preference */
-               if (calhourformat == 24) 
+               if (calhourformat == 24)
                        *time_format_cache = WC_TIMEFORMAT_24;
                else
                        *time_format_cache = WC_TIMEFORMAT_AMPM;
@@ -164,13 +162,12 @@ int get_time_format_cached (void)
  * buf         the output buffer
  * thetime     time to format into buf
  */
-void fmt_time(char *buf, size_t siz, time_t thetime)
-{
+void fmt_time(char *buf, size_t siz, time_t thetime) {
        struct tm *tm;
        int hour;
        int time_format;
-       
-       time_format = get_time_format_cached ();
+
+       time_format = get_time_format_cached();
        buf[0] = 0;
        tm = localtime(&thetime);
        hour = tm->tm_hour;
@@ -180,14 +177,11 @@ void fmt_time(char *buf, size_t siz, time_t thetime)
                hour = hour - 12;
 
        if (time_format == WC_TIMEFORMAT_24) {
-               snprintf(buf, siz, "%d:%02d",
-                       tm->tm_hour, tm->tm_min
-               );
+               snprintf(buf, siz, "%d:%02d", tm->tm_hour, tm->tm_min);
        }
        else {
-               snprintf(buf, siz, "%d:%02d%s",
-                       hour, tm->tm_min, ((tm->tm_hour > 12) ? "pm" : "am")
-               );
+               snprintf(buf, siz, "%d:%02d%s", hour, tm->tm_min, ((tm->tm_hour > 12) ? "pm" : "am")
+                   );
        }
 }
 
@@ -200,17 +194,15 @@ void fmt_time(char *buf, size_t siz, time_t thetime)
  * FIXME won't read asctime
  * Doesn't understand timezone, but we only should be using GMT/UTC anyway
  */
-time_t httpdate_to_timestamp(StrBuf *buf)
-{
+time_t httpdate_to_timestamp(StrBuf * buf) {
        time_t t = 0;
        struct tm tt;
        const char *c;
 
        /** Skip day of week, to number */
-       for (c = ChrPtr(buf); *c != ' '; c++)
-               ;
+       for (c = ChrPtr(buf); *c != ' '; c++);
        c++;
-       
+
        memset(&tt, 0, sizeof(tt));
 
        /* Get day of month */
@@ -220,33 +212,33 @@ time_t httpdate_to_timestamp(StrBuf *buf)
 
        /* Get month */
        switch (*c) {
-       case 'A':       /* April, August */
+       case 'A':               /* April, August */
                tt.tm_mon = (c[1] == 'p') ? 3 : 7;
                break;
-       case 'D':       /* December */
+       case 'D':               /* December */
                tt.tm_mon = 11;
                break;
-       case 'F':       /* February */
+       case 'F':               /* February */
                tt.tm_mon = 1;
                break;
-       case 'M':       /* March, May */
+       case 'M':               /* March, May */
                tt.tm_mon = (c[2] == 'r') ? 2 : 4;
                break;
-       case 'J':       /* January, June, July */
+       case 'J':               /* January, June, July */
                tt.tm_mon = (c[2] == 'n') ? ((c[1] == 'a') ? 0 : 5) : 6;
                break;
-       case 'N':       /* November */
+       case 'N':               /* November */
                tt.tm_mon = 10;
                break;
-       case 'O':       /* October */
+       case 'O':               /* October */
                tt.tm_mon = 9;
                break;
-       case 'S':       /* September */
+       case 'S':               /* September */
                tt.tm_mon = 8;
                break;
        default:
                return 42;
-               break;  /* NOTREACHED */
+               break;          /* NOTREACHED */
        }
        c += 4;
 
@@ -283,30 +275,26 @@ time_t httpdate_to_timestamp(StrBuf *buf)
 #ifdef __FreeBSD__
        tt.tm_sec = tt.tm_sec - tt.tm_gmtoff;
 #else
-       tt.tm_sec = tt.tm_sec - (int)timezone;
+       tt.tm_sec = tt.tm_sec - (int) timezone;
 #endif
        t = mktime(&tt);
        return t;
 }
 
 
-void LoadTimeformatSettingsCache(StrBuf *Preference, long lvalue)
-{
+void LoadTimeformatSettingsCache(StrBuf * Preference, long lvalue) {
        int *time_format_cache;
-       
-        time_format_cache = &(WC->time_format_cache);
-        if (lvalue == 24) 
-                *time_format_cache = WC_TIMEFORMAT_24;
-        else
-                *time_format_cache = WC_TIMEFORMAT_AMPM;
+
+       time_format_cache = &(WC->time_format_cache);
+       if (lvalue == 24)
+               *time_format_cache = WC_TIMEFORMAT_24;
+       else
+               *time_format_cache = WC_TIMEFORMAT_AMPM;
 }
 
 
 
-void 
-InitModule_DATETIME
-(void)
-{
+void InitModule_DATETIME(void) {
        RegisterPreference("calhourformat", _("Time format"), PRF_INT, LoadTimeformatSettingsCache);
 
 
index 1bc40c8f40a5dbe18f08331d85dd8a8ccf46578f..c037f7a654357382bb889e6096e42d3b83d0f85e 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2012 by the citadel.org team
  *
@@ -15,6 +16,7 @@
 #define SEARCH_LANG 20         /* how many langs should we parse? */
 
 #ifdef ENABLE_NLS
+
 /* actual supported locales */
 const char *AvailLang[] = {
        "en_US",
@@ -38,7 +40,7 @@ const char *AvailLang[] = {
        "pt_BR",
        "ru_RU",
        "zh_CN",
-       "he_IL",
+       "he_IL",
        "kk_KK",
        "ro_RO",
        "sl_SL",
@@ -50,16 +52,16 @@ const char **AvailLangLoaded;
 long nLocalesLoaded = 0;
 
 #ifdef HAVE_USELOCALE
-locale_t *wc_locales; /* here we keep the parsed stuff */
+locale_t *wc_locales;          /* here we keep the parsed stuff */
 #endif
 
 /* Keep information about one locale */
 typedef struct _lang_pref {
-       char lang[16];          /* the language locale string */
-       char region[16];        /* the region locale string */
-       long priority;          /* which priority does it have */
-       int availability;       /* do we know it? */
-       int selectedlang;       /* is this the selected language? */
+       char lang[16];          /* the language locale string */
+       char region[16];        /* the region locale string */
+       long priority;          /* which priority does it have */
+       int availability;       /* do we know it? */
+       int selectedlang;       /* is this the selected language? */
 } LangStruct;
 
 /* parse browser locale header 
@@ -73,8 +75,7 @@ typedef struct _lang_pref {
  * Accept-Language: de,en-us;q=0.9,it;q=0.9,de-de;q=0.8,en-ph;q=0.7,de-at;q=0.7,zh-cn;q=0.6,cy;q=0.5,ar-om;q=0.5,en-tt;q=0.4,xh;q=0.3,nl-be;q=0.3,cs;q=0.2,sv;q=0.1,tk;q=0.1 
  */
 
-void httplang_to_locale(StrBuf *LocaleString, wcsession *sess)
-{
+void httplang_to_locale(StrBuf * LocaleString, wcsession * sess) {
        LangStruct wanted_locales[SEARCH_LANG];
        LangStruct *ls;
 
@@ -90,11 +91,10 @@ void httplang_to_locale(StrBuf *LocaleString, wcsession *sess)
        StrBuf *SBuf = NULL;
 
        nParts = StrBufNum_tokens(LocaleString, ',');
-       for (i=0; ((i<nParts) && (i < SEARCH_LANG)); i++)
-        {
+       for (i = 0; ((i < nParts) && (i < SEARCH_LANG)); i++) {
                char lbuf[32];
                int blen;
-                       
+
                if (Buf == NULL) {
                        Buf = NewStrBuf();
                        SBuf = NewStrBuf();
@@ -107,7 +107,7 @@ void httplang_to_locale(StrBuf *LocaleString, wcsession *sess)
                ls = &wanted_locales[i];
 
                StrBufExtract_token(Buf, LocaleString, i, ',');
-               /* we are searching, if this list item has something like ;q=n*/
+               /* we are searching, if this list item has something like ;q=n */
                if (StrBufNum_tokens(Buf, '=') > 1) {
                        int sbuflen, k;
                        StrBufExtract_token(SBuf, Buf, 1, '=');
@@ -127,20 +127,14 @@ void httplang_to_locale(StrBuf *LocaleString, wcsession *sess)
                StrBufExtract_token(SBuf, Buf, 0, ';');
 
                /* get the lang part, which should be allways there */
-               extract_token(ls->lang, 
-                             ChrPtr(SBuf), 
-                             0, '-', 
-                             sizeof(ls->lang));
+               extract_token(ls->lang, ChrPtr(SBuf), 0, '-', sizeof(ls->lang));
 
                /* get the area code if any. */
                if (StrBufNum_tokens(SBuf, '-') > 1) {
-                       extract_token(ls->region, 
-                                     ChrPtr(SBuf), 
-                                     1, '-', 
-                                     sizeof(ls->region)
-                       );
+                       extract_token(ls->region, ChrPtr(SBuf), 1, '-', sizeof(ls->region)
+                           );
                }
-               else { /* no ara code? use lang code */
+               else {          /* no ara code? use lang code */
                        blen = strlen(ls->lang);
                        memcpy(ls->region, ls->lang, blen);
                        ls->region[blen] = '\0';
@@ -148,18 +142,13 @@ void httplang_to_locale(StrBuf *LocaleString, wcsession *sess)
 
                /* area codes are uppercase */
                blen = strlen(&ls->region[0]);
-               for (j = 0; j < blen; j++)
-               {
+               for (j = 0; j < blen; j++) {
                        int chars;
                        chars = toupper(ls->region[j]);
-                       ls->region[j] = (char)chars; /* todo ? */
+                       ls->region[j] = (char) chars;   /* todo ? */
                }
-               snprintf(lbuf,
-                        sizeof(lbuf), 
-                        "%s_%s", 
-                        ls->lang, 
-                        ls->region);
-                       
+               snprintf(lbuf, sizeof(lbuf), "%s_%s", ls->lang, ls->region);
+
                /* check if we have this lang */
                ls->availability = 1;
                ls->selectedlang = -1;
@@ -168,29 +157,29 @@ void httplang_to_locale(StrBuf *LocaleString, wcsession *sess)
                        int result;
                        /* match against the LANG part */
                        result = strncasecmp(ls->lang, AvailLangLoaded[j], len);
-                       if ((result == 0) && (result < ls->availability)){
+                       if ((result == 0) && (result < ls->availability)) {
                                ls->availability = result;
                                ls->selectedlang = j;
                        }
                        /* match against lang and locale */
-                       if (0 == strcasecmp(lbuf, AvailLangLoaded[j])){
+                       if (0 == strcasecmp(lbuf, AvailLangLoaded[j])) {
                                ls->availability = 0;
                                ls->selectedlang = j;
                                j = nLocalesLoaded;
                        }
                }
-        }
-       
+       }
+
        prio = 0;
        av = -1000;
        nBest = -1;
-       for (i = 0; ((i < nParts) && (i<SEARCH_LANG)); i++) {
+       for (i = 0; ((i < nParts) && (i < SEARCH_LANG)); i++) {
                ls = &wanted_locales[i];
-               if (    (ls->availability <= 0)
-                       && (av < ls->availability)
-                       && (prio < ls->priority)
-                       && (ls->selectedlang != -1)
-               ) {
+               if ((ls->availability <= 0)
+                   && (av < ls->availability)
+                   && (prio < ls->priority)
+                   && (ls->selectedlang != -1)
+                   ) {
                        nBest = ls->selectedlang;
                        av = ls->availability;
                        prio = ls->priority;
@@ -198,7 +187,7 @@ void httplang_to_locale(StrBuf *LocaleString, wcsession *sess)
        }
        if (nBest == -1) {
                /* fall back to C */
-               nBest=0;
+               nBest = 0;
        }
        sess->selected_language = nBest;
        syslog(LOG_DEBUG, "language found: %s", AvailLangLoaded[sess->selected_language]);
@@ -212,12 +201,11 @@ void httplang_to_locale(StrBuf *LocaleString, wcsession *sess)
  * depending on the browser locale change the sequence of the 
  * language chooser.
  */
-void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_offer_languages(StrBuf * Target, WCTemplputParams * TP) {
        int i;
 #ifndef HAVE_USELOCALE
        char *Lang = getenv("LANG");
-       
+
        if (Lang == NULL)
                Lang = "C";
 #endif
@@ -229,15 +217,13 @@ void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
 
        wc_printf("<select name=\"language\" id=\"lname\" size=\"1\" onChange=\"switch_to_lang($('lname').value);\">\n");
 
-       for (i=0; i < nLocalesLoaded; ++i) {
+       for (i = 0; i < nLocalesLoaded; ++i) {
 #ifndef HAVE_USELOCALE
                if (strcmp(AvailLangLoaded[i], Lang) == 0)
 #endif
-               wc_printf("<option %s value=%s>%s</option>\n",
-                       ((WC->selected_language == i) ? "selected" : ""),
-                       AvailLangLoaded[i],
-                       AvailLangLoaded[i]
-               );
+                       wc_printf("<option %s value=%s>%s</option>\n",
+                                 ((WC->selected_language == i) ? "selected" : ""), AvailLangLoaded[i], AvailLangLoaded[i]
+                           );
        }
 
        wc_printf("</select>\n");
@@ -249,7 +235,7 @@ void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
 void set_selected_language(const char *lang) {
 #ifdef HAVE_USELOCALE
        int i;
-       for (i = 0; i<nLocalesLoaded; ++i) {
+       for (i = 0; i < nLocalesLoaded; ++i) {
                if (!strcasecmp(lang, AvailLangLoaded[i])) {
                        WC->selected_language = i;
                        break;
@@ -264,17 +250,16 @@ void set_selected_language(const char *lang) {
 void go_selected_language(void) {
 #ifdef HAVE_USELOCALE
        wcsession *WCC = WC;
-       if (WCC->selected_language < 0)
-       {
+       if (WCC->selected_language < 0) {
                httplang_to_locale(WCC->Hdr->HR.browser_language, WCC);
                if (WCC->selected_language < 0)
                        return;
        }
        uselocale(wc_locales[WCC->selected_language]);  /* switch locales */
-       textdomain(textdomain(NULL));                   /* clear the cache */
+       textdomain(textdomain(NULL));   /* clear the cache */
 #else
        char *language;
-       
+
        language = getenv("LANG");
        setlocale(LC_MESSAGES, language);
 #endif
@@ -285,13 +270,13 @@ void go_selected_language(void) {
  */
 void stop_selected_language(void) {
 #ifdef HAVE_USELOCALE
-       uselocale(LC_GLOBAL_LOCALE);                    /* switch locales */
-       textdomain(textdomain(NULL));                   /* clear the cache */
+       uselocale(LC_GLOBAL_LOCALE);    /* switch locales */
+       textdomain(textdomain(NULL));   /* clear the cache */
 #endif
 }
 
 #ifdef HAVE_USELOCALE
-       locale_t Empty_Locale;
+locale_t Empty_Locale;
 #endif
 
 /*
@@ -303,21 +288,22 @@ void initialize_locales(void) {
        char buf[32];
        char *language = NULL;
 
-       nLocales = 0; 
+       nLocales = 0;
        while (!IsEmptyStr(AvailLang[nLocales]))
                nLocales++;
 
        language = getenv("WEBCIT_LANG");
        if ((language) && (!IsEmptyStr(language)) && (strcmp(language, "UNLIMITED") != 0)) {
                syslog(LOG_INFO, "Nailing locale to %s", language);
-       }
-       else language = NULL;
+       }
+       else
+               language = NULL;
 
-       AvailLangLoaded = malloc (sizeof(char*) * nLocales);
-       memset(AvailLangLoaded, 0, sizeof(char*) * nLocales);
+       AvailLangLoaded = malloc(sizeof(char *) * nLocales);
+       memset(AvailLangLoaded, 0, sizeof(char *) * nLocales);
 #ifdef HAVE_USELOCALE
-       wc_locales = malloc (sizeof(locale_t) * nLocales);
-       memset(wc_locales,0, sizeof(locale_t) * nLocales);
+       wc_locales = malloc(sizeof(locale_t) * nLocales);
+       memset(wc_locales, 0, sizeof(locale_t) * nLocales);
        /* create default locale */
        Empty_Locale = newlocale(LC_ALL_MASK, NULL, NULL);
 #endif
@@ -327,17 +313,15 @@ void initialize_locales(void) {
                        continue;
                if (i == 0) {
                        sprintf(buf, "C");      /* locale 0 (C) is ascii, not utf-8 */
-                       
+
                }
                else {
                        sprintf(buf, "%s.UTF8", AvailLang[i]);
                }
 #ifdef HAVE_USELOCALE
-               wc_locales[nLocalesLoaded] = newlocale(
-                       (LC_MESSAGES_MASK|LC_TIME_MASK),
-                       buf,
-                       (((i > 0) && (wc_locales[0] != NULL)) ? wc_locales[0] : Empty_Locale)
-               );
+               wc_locales[nLocalesLoaded] = newlocale((LC_MESSAGES_MASK | LC_TIME_MASK),
+                                                      buf, (((i > 0) && (wc_locales[0] != NULL)) ? wc_locales[0] : Empty_Locale)
+                   );
                if (wc_locales[nLocalesLoaded] == NULL) {
                        syslog(LOG_NOTICE, "locale for %s disabled: %s", buf, strerror(errno));
                }
@@ -363,11 +347,7 @@ void initialize_locales(void) {
        if ((language != NULL) && (nLocalesLoaded == 0)) {
                syslog(LOG_WARNING, "Your selected locale [%s] isn't available on your system. falling back to C", language);
 #ifdef HAVE_USELOCALE
-               wc_locales[0] = newlocale(
-                       (LC_MESSAGES_MASK|LC_TIME_MASK),
-                       AvailLang[0],
-                       Empty_Locale
-               );
+               wc_locales[0] = newlocale((LC_MESSAGES_MASK | LC_TIME_MASK), AvailLang[0], Empty_Locale);
 #else
                setlocale(LC_MESSAGES, AvailLang[0]);
                setenv("LANG", AvailLang[0], 1);
@@ -380,15 +360,12 @@ void initialize_locales(void) {
        setlocale(LC_ALL, "");
        syslog(LOG_DEBUG, "Text domain: %s", textdomain("webcit"));
        syslog(LOG_DEBUG, "Text domain Charset: %s", bind_textdomain_codeset("webcit", "UTF8"));
-       syslog(LOG_DEBUG, "Message catalog directory: %s", bindtextdomain(textdomain(NULL), LOCALEDIR"/locale"));
+       syslog(LOG_DEBUG, "Message catalog directory: %s", bindtextdomain(textdomain(NULL), LOCALEDIR "/locale"));
 #endif
 }
 
 
-void 
-ServerShutdownModule_GETTEXT
-(void)
-{
+void ServerShutdownModule_GETTEXT(void) {
 #ifdef HAVE_USELOCALE
        int i;
        for (i = 0; i < nLocalesLoaded; ++i) {
@@ -401,22 +378,19 @@ ServerShutdownModule_GETTEXT
        free(AvailLangLoaded);
 }
 
-#else  /* ENABLE_NLS */
+#else                          /* ENABLE_NLS */
 const char *AvailLang[] = {
        "C",
        ""
 };
 
 /* dummy for non NLS enabled systems */
-void 
-ServerShutdownModule_GETTEXT
-(void)
-{
+void
+ ServerShutdownModule_GETTEXT(void) {
 }
 
 
-void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_offer_languages(StrBuf * Target, WCTemplputParams * TP) {
        wc_printf("English (US)");
 }
 
@@ -435,10 +409,9 @@ void stop_selected_language(void) {
 void initialize_locales(void) {
 }
 
-#endif /* ENABLE_NLS */
+#endif                         /* ENABLE_NLS */
 
-void TmplGettext(StrBuf *Target, WCTemplputParams *TP)
-{
+void TmplGettext(StrBuf * Target, WCTemplputParams * TP) {
        const char *Text = _(TP->Tokens->Params[0]->Start);
 
        StrBufAppendTemplateStr(Target, TP, Text, 1);
@@ -462,54 +435,39 @@ const char *get_selected_language(void) {
 }
 
 
-void Header_HandleAcceptLanguage(StrBuf *Line, ParsedHttpHdrs *hdr)
-{
+void Header_HandleAcceptLanguage(StrBuf * Line, ParsedHttpHdrs * hdr) {
        hdr->HR.browser_language = Line;
 }
 
 
-void 
-InitModule_GETTEXT
-(void)
-{
+void InitModule_GETTEXT(void) {
        initialize_locales();
-       
-       RegisterHeaderHandler(HKEY("ACCEPT-LANGUAGE"), 
-                             Header_HandleAcceptLanguage);
-                             
-       RegisterNamespace("LANG:SELECT", 0, 0, 
-                         tmplput_offer_languages, NULL, CTX_NONE);
+
+       RegisterHeaderHandler(HKEY("ACCEPT-LANGUAGE"), Header_HandleAcceptLanguage);
+
+       RegisterNamespace("LANG:SELECT", 0, 0, tmplput_offer_languages, NULL, CTX_NONE);
 }
 
 
-void
-SessionNewModule_GETTEXT
-(wcsession *sess)
-{
+void SessionNewModule_GETTEXT(wcsession * sess) {
 #ifdef ENABLE_NLS
-       if (    (sess != NULL)
-               && (!sess->Hdr->HR.Static)
-               && (sess->Hdr->HR.browser_language != NULL)
-       ) {
+       if ((sess != NULL)
+           && (!sess->Hdr->HR.Static)
+           && (sess->Hdr->HR.browser_language != NULL)
+           ) {
                httplang_to_locale(sess->Hdr->HR.browser_language, sess);
        }
 #endif
 }
 
-void
-SessionAttachModule_GETTEXT
-(wcsession *sess)
-{
+void SessionAttachModule_GETTEXT(wcsession * sess) {
 #ifdef ENABLE_NLS
-       go_selected_language();                                 /* set locale */
+       go_selected_language(); /* set locale */
 #endif
 }
 
-void 
-SessionDestroyModule_GETTEXT
-(wcsession *sess)
-{
+void SessionDestroyModule_GETTEXT(wcsession * sess) {
 #ifdef ENABLE_NLS
-       stop_selected_language();                               /* unset locale */
+       stop_selected_language();       /* unset locale */
 #endif
 }
index 8dbad904387810272212b1bcfcc30349dca6646f..25dc451f9d6415cf0af5e918c02d189457a23f2a 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Handles HTTP upload of graphics files into the system.
  *
@@ -14,7 +15,7 @@
 
 #include "webcit.h"
 
-extern void output_static(const charWhat);
+extern void output_static(const char *What);
 
 
 // display the picture (icon, photo, whatever) associated with the current room
@@ -41,8 +42,7 @@ void display_roompic(void) {
 
 
 // upload the picture (icon, photo, whatever) associated with the current room
-void common_code_for_editroompic_and_editpic(char *servcmd)
-{
+void common_code_for_editroompic_and_editpic(char *servcmd) {
        if (havebstr("cancel_button")) {
                AppendImportantMessage(_("Graphics upload has been cancelled."), -1);
                display_main_menu();
@@ -54,8 +54,8 @@ void common_code_for_editroompic_and_editpic(char *servcmd)
                display_main_menu();
                return;
        }
-       
-       serv_printf("%s %ld|%s", servcmd, (long)WC->upload_length, GuessMimeType(ChrPtr(WC->upload), WC->upload_length));
+
+       serv_printf("%s %ld|%s", servcmd, (long) WC->upload_length, GuessMimeType(ChrPtr(WC->upload), WC->upload_length));
        StrBuf *Line = NewStrBuf();
        StrBuf_ServGetln(Line);
        if (GetServerStatusMsg(Line, NULL, 0, 0) == 7) {
@@ -71,22 +71,19 @@ void common_code_for_editroompic_and_editpic(char *servcmd)
 
 
 // upload the picture (icon, photo, whatever) associated with the current room
-void editroompic(void)
-{
+void editroompic(void) {
        common_code_for_editroompic_and_editpic("ULRI");
 }
 
-       
+
 // upload the picture (icon, photo, whatever) associated with the current user
-void editpic(void)
-{
+void editpic(void) {
        common_code_for_editroompic_and_editpic("ULUI");
 }
 
 
 // display the screen for uploading graphics to the server
-void display_graphics_upload(char *filename)
-{
+void display_graphics_upload(char *filename) {
        StrBuf *Line;
 
        Line = NewStrBuf();
@@ -96,8 +93,7 @@ void display_graphics_upload(char *filename)
                display_main_menu();
                return;
        }
-       else
-       {
+       else {
                output_headers(1, 0, 0, 0, 1, 0);
                do_template("files_graphicsupload");
                end_burst();
@@ -106,8 +102,7 @@ void display_graphics_upload(char *filename)
 }
 
 
-void do_graphics_upload(char *filename)
-{
+void do_graphics_upload(char *filename) {
        StrBuf *Line;
        const char *MimeType;
        wcsession *WCC = WC;
@@ -127,7 +122,7 @@ void do_graphics_upload(char *filename)
                display_main_menu();
                return;
        }
-       
+
        MimeType = GuessMimeType(ChrPtr(WCC->upload), bytes_remaining);
        serv_printf("UIMG 1|%s|%s", MimeType, filename);
 
@@ -149,7 +144,7 @@ void do_graphics_upload(char *filename)
                        FreeStrBuf(&Line);
                        return;
                }
-               thisblock = extract_int(ChrPtr(Line) +4, 0);
+               thisblock = extract_int(ChrPtr(Line) + 4, 0);
                serv_write(&ChrPtr(WCC->upload)[pos], thisblock);
                pos += thisblock;
                bytes_remaining -= thisblock;
@@ -159,15 +154,19 @@ void do_graphics_upload(char *filename)
        StrBuf_ServGetln(Line);
        if (*ChrPtr(Line) != 'x') {
                display_success(ChrPtr(Line) + 4);
-       
+
        }
        FreeStrBuf(&Line);
 
 }
 
 
-void edithellopic(void)    { do_graphics_upload("hello"); }
-void editgoodbuyepic(void) { do_graphics_upload("UIMG 1|%s|goodbuye"); }
+void edithellopic(void) {
+       do_graphics_upload("hello");
+}
+void editgoodbuyepic(void) {
+       do_graphics_upload("UIMG 1|%s|goodbuye");
+}
 
 /* The users photo display / upload facility */
 void display_editpic(void) {
@@ -175,6 +174,7 @@ void display_editpic(void) {
        putbstr("__UPLURL", NewStrBufPlain(HKEY("editpic")));
        display_graphics_upload("editpic");
 }
+
 /* room picture dispay / upload facility */
 void display_editroompic(void) {
        putbstr("__PICDESC", NewStrBufPlain(_("the icon for this room"), -1));
@@ -199,10 +199,7 @@ void display_editgoodbyepic(void) {
 }
 
 
-void 
-InitModule_GRAPHICS
-(void)
-{
+void InitModule_GRAPHICS(void) {
        WebcitAddUrlHandler(HKEY("display_editpic"), "", 0, display_editpic, 0);
        WebcitAddUrlHandler(HKEY("editpic"), "", 0, editpic, 0);
        WebcitAddUrlHandler(HKEY("display_editroompic"), "", 0, display_editroompic, 0);
index ca2404385505ff14f1890d9d4114959e6eec9221..c531736fb6e3fb28341e80a63b8bbd791cf0e707 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Output an HTML message, modifying it slightly to make sure it plays nice
  * with the rest of our web framework.
 /*
  * Strip surrounding single or double quotes from a string.
  */
-void stripquotes(char *s)
-{
+void stripquotes(char *s) {
        int len;
 
-       if (!s) return;
+       if (!s)
+               return;
 
        len = strlen(s);
-       if (len < 2) return;
+       if (len < 2)
+               return;
 
-       if ( ( (s[0] == '\"') && (s[len-1] == '\"') ) || ( (s[0] == '\'') && (s[len-1] == '\'') ) ) {
-               s[len-1] = 0;
+       if (((s[0] == '\"') && (s[len - 1] == '\"')) || ((s[0] == '\'') && (s[len - 1] == '\''))) {
+               s[len - 1] = 0;
                strcpy(s, &s[1]);
        }
 }
@@ -43,20 +45,24 @@ void stripquotes(char *s)
  * meta_http_equiv     Content of the "http-equiv" portion of the META tag
  * meta_content                Content of the "content" portion of the META tag
  */
-void extract_charset_from_meta(char *charset, char *meta_http_equiv, char *meta_content)
-{
+void extract_charset_from_meta(char *charset, char *meta_http_equiv, char *meta_content) {
        char *ptr;
        char buf[64];
 
-       if (!charset) return;
-       if (!meta_http_equiv) return;
-       if (!meta_content) return;
+       if (!charset)
+               return;
+       if (!meta_http_equiv)
+               return;
+       if (!meta_content)
+               return;
 
 
-       if (strcasecmp(meta_http_equiv, "Content-type")) return;
+       if (strcasecmp(meta_http_equiv, "Content-type"))
+               return;
 
        ptr = strchr(meta_content, ';');
-       if (!ptr) return;
+       if (!ptr)
+               return;
 
        safestrncpy(buf, ++ptr, sizeof buf);
        striplt(buf);
@@ -75,7 +81,8 @@ void extract_charset_from_meta(char *charset, char *meta_http_equiv, char *meta_
                }
 
                /* Remove wandering punctuation */
-               if ((ptr=strchr(charset, '\"'))) *ptr = 0;
+               if ((ptr = strchr(charset, '\"')))
+                       *ptr = 0;
                striplt(charset);
        }
 }
@@ -88,7 +95,7 @@ void extract_charset_from_meta(char *charset, char *meta_http_equiv, char *meta_
  * Also fixup img src="cid:..." type inline images to fetch the image
  *
  */
-void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, StrBuf *Source, StrBuf *Target) {
+void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, StrBuf * Source, StrBuf * Target) {
        char buf[SIZ];
        char *msg;
        char *ptr;
@@ -108,12 +115,12 @@ void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, St
        char charset[128];
        StrBuf *BodyArea = NULL;
 #ifdef HAVE_ICONV
-       iconv_t ic = (iconv_t)(-1) ;
-       char *ibuf;                   /* Buffer of characters to be converted */
-       char *obuf;                   /* Buffer for converted characters      */
-       size_t ibuflen;               /* Length of input buffer               */
-       size_t obuflen;               /* Length of output buffer              */
-       char *osav;                   /* Saved pointer to output buffer       */
+       iconv_t ic = (iconv_t) (-1);
+       char *ibuf;             /* Buffer of characters to be converted */
+       char *obuf;             /* Buffer for converted characters      */
+       size_t ibuflen;         /* Length of input buffer               */
+       size_t obuflen;         /* Length of output buffer              */
+       char *osav;             /* Saved pointer to output buffer       */
 #endif
        if (Target == NULL)
                Target = WC->WBuf;
@@ -122,32 +129,33 @@ void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, St
        msg = strdup("");
        sprintf(new_window, "<a target=\"%s\" href=", TARGET);
 
-       if (Source == NULL) while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-               line_length = strlen(buf);
-               buffer_length = content_length + line_length + 2;
-               ptr = realloc(msg, buffer_length);
-               if (ptr == NULL) {
-                       StrBufAppendPrintf(Target, "<b>");
-                       StrBufAppendPrintf(Target, _("realloc() error! couldn't get %d bytes: %s"),
-                                       buffer_length + 1,
-                                       strerror(errno));
-                       StrBufAppendPrintf(Target, "</b><br><br>\n");
-                       while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+       if (Source == NULL)
+               while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+                       line_length = strlen(buf);
+                       buffer_length = content_length + line_length + 2;
+                       ptr = realloc(msg, buffer_length);
+                       if (ptr == NULL) {
+                               StrBufAppendPrintf(Target, "<b>");
+                               StrBufAppendPrintf(Target, _("realloc() error! couldn't get %d bytes: %s"),
+                                                  buffer_length + 1, strerror(errno));
+                               StrBufAppendPrintf(Target, "</b><br><br>\n");
+                               while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+
                                /** flush */
+                               }
+                               free(msg);
+                               return;
                        }
-                       free(msg);
-                       return;
+                       msg = ptr;
+                       strcpy(&msg[content_length], buf);
+                       content_length += line_length;
+                       strcpy(&msg[content_length], "\n");
+                       content_length += 1;
                }
-               msg = ptr;
-               strcpy(&msg[content_length], buf);
-               content_length += line_length;
-               strcpy(&msg[content_length], "\n");
-               content_length += 1;
-       }
        else {
                content_length = StrLength(Source);
                free(msg);
-               msg = (char*) ChrPtr(Source);/* TODO: remove cast */
+               msg = (char *) ChrPtr(Source);  /* TODO: remove cast */
                buffer_length = content_length;
        }
 
@@ -160,9 +168,11 @@ void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, St
 
                /** Advance to next tag */
                ptr = strchr(ptr, '<');
-               if ((ptr == NULL) || (ptr >= msgend)) break;
+               if ((ptr == NULL) || (ptr >= msgend))
+                       break;
                ++ptr;
-               if ((ptr == NULL) || (ptr >= msgend)) break;
+               if ((ptr == NULL) || (ptr >= msgend))
+                       break;
 
                /*
                 *  Look for META tags.  Some messages (particularly in
@@ -198,8 +208,7 @@ void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, St
                                                        strcpy(meta_content, &meta_content[8]);
                                                        stripquotes(meta_http_equiv);
                                                        stripquotes(meta_content);
-                                                       extract_charset_from_meta(charset,
-                                                                       meta_http_equiv, meta_content);
+                                                       extract_charset_from_meta(charset, meta_http_equiv, meta_content);
                                                }
                                                free(meta_content);
                                        }
@@ -212,59 +221,56 @@ void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, St
                /*
                 * Any of these tags cause everything up to and including
                 * the tag to be removed.
-                */     
-               if ( (!strncasecmp(ptr, "HTML", 4))
-                               ||(!strncasecmp(ptr, "HEAD", 4))
-                               ||(!strncasecmp(ptr, "/HEAD", 5))
-                               ||(!strncasecmp(ptr, "BODY", 4)) ) {
+                */
+               if ((!strncasecmp(ptr, "HTML", 4))
+                   || (!strncasecmp(ptr, "HEAD", 4))
+                   || (!strncasecmp(ptr, "/HEAD", 5))
+                   || (!strncasecmp(ptr, "BODY", 4))) {
                        char *pBody = NULL;
 
                        if (!strncasecmp(ptr, "BODY", 4)) {
                                pBody = ptr;
                        }
                        ptr = strchr(ptr, '>');
-                       if ((ptr == NULL) || (ptr >= msgend)) break;
+                       if ((ptr == NULL) || (ptr >= msgend))
+                               break;
                        if ((pBody != NULL) && (ptr - pBody > 4)) {
-                               charsrc;
+                               char *src;
                                char *cid_start, *cid_end;
 
                                *ptr = '\0';
-                               pBody += 4; 
+                               pBody += 4;
                                while ((isspace(*pBody)) && (pBody < ptr))
-                                       pBody ++;
-                               BodyArea = NewStrBufPlain(NULL,  ptr - pBody);
+                                       pBody++;
+                               BodyArea = NewStrBufPlain(NULL, ptr - pBody);
 
                                if (pBody < ptr) {
                                        src = strstr(pBody, "cid:");
                                        if (src) {
                                                cid_start = src + 4;
                                                cid_end = cid_start;
-                                               while ((*cid_end != '"') && 
-                                                               !isspace(*cid_end) &&
-                                                               (cid_end < ptr))
-                                                       cid_end ++;
+                                               while ((*cid_end != '"') && !isspace(*cid_end) && (cid_end < ptr))
+                                                       cid_end++;
 
                                                /* copy tag and attributes up to src="cid: */
                                                StrBufAppendBufPlain(BodyArea, pBody, src - pBody, 0);
 
                                                /* add in /webcit/mimepart/<msgno>/CID/ 
                                                   trailing / stops dumb URL filters getting excited */
-                                               StrBufAppendPrintf(BodyArea,
-                                                               "/webcit/mimepart/%d/",msgnum);
+                                               StrBufAppendPrintf(BodyArea, "/webcit/mimepart/%d/", msgnum);
                                                StrBufAppendBufPlain(BodyArea, cid_start, cid_end - cid_start, 0);
 
                                                if (ptr - cid_end > 0)
-                                                       StrBufAppendBufPlain(BodyArea, 
-                                                                       cid_end + 1, 
-                                                                       ptr - cid_end, 0);
+                                                       StrBufAppendBufPlain(BodyArea, cid_end + 1, ptr - cid_end, 0);
                                        }
-                                       else 
+                                       else
                                                StrBufAppendBufPlain(BodyArea, pBody, ptr - pBody, 0);
                                }
                                *ptr = '>';
                        }
                        ++ptr;
-                       if ((ptr == NULL) || (ptr >= msgend)) break;
+                       if ((ptr == NULL) || (ptr >= msgend))
+                               break;
                        msgstart = ptr;
                }
 
@@ -272,8 +278,8 @@ void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, St
                 * Any of these tags cause everything including and following
                 * the tag to be removed.
                 */
-               if ( (!strncasecmp(ptr, "/HTML", 5))
-                               ||(!strncasecmp(ptr, "/BODY", 5)) ) {
+               if ((!strncasecmp(ptr, "/HTML", 5))
+                   || (!strncasecmp(ptr, "/BODY", 5))) {
                        --ptr;
                        msgend = ptr;
                        strcpy(ptr, "");
@@ -292,22 +298,21 @@ void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, St
 
        /** Convert foreign character sets to UTF-8 if necessary. */
 #ifdef HAVE_ICONV
-       if ( (strcasecmp(charset, "us-ascii"))
-                       && (strcasecmp(charset, "UTF-8"))
-                       && (strcasecmp(charset, ""))
-          ) {
+       if ((strcasecmp(charset, "us-ascii"))
+           && (strcasecmp(charset, "UTF-8"))
+           && (strcasecmp(charset, ""))
+           ) {
                syslog(LOG_DEBUG, "Converting %s to UTF-8\n", charset);
                ctdl_iconv_open("UTF-8", charset, &ic);
-               if (ic == (iconv_t)(-1) ) {
-                       syslog(LOG_WARNING, "%s:%d iconv_open() failed: %s\n",
-                                       __FILE__, __LINE__, strerror(errno));
+               if (ic == (iconv_t) (-1)) {
+                       syslog(LOG_WARNING, "%s:%d iconv_open() failed: %s\n", __FILE__, __LINE__, strerror(errno));
                }
        }
-       if  (Source == NULL) {
-               if (ic != (iconv_t)(-1) ) {
+       if (Source == NULL) {
+               if (ic != (iconv_t) (-1)) {
                        ibuf = msg;
                        ibuflen = content_length;
-                       obuflen = content_length + (content_length / 2) ;
+                       obuflen = content_length + (content_length / 2);
                        obuf = (char *) malloc(obuflen);
                        osav = obuf;
                        iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen);
@@ -319,23 +324,23 @@ void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, St
                }
        }
        else {
-               if (ic != (iconv_t)(-1) ) {
+               if (ic != (iconv_t) (-1)) {
                        StrBuf *Buf = NewStrBufPlain(NULL, StrLength(Source) + 8096);;
                        StrBufConvert(Source, Buf, &ic);
                        FreeStrBuf(&Buf);
                        iconv_close(ic);
-                       msg = (char*)ChrPtr(Source); /* TODO: get rid of this. */
+                       msg = (char *) ChrPtr(Source);  /* TODO: get rid of this. */
                }
        }
 
 #endif
 
        /*
-        *      At this point, the message has been stripped down to
-        *      only the content inside the <BODY></BODY> tags, and has
-        *      been converted to UTF-8 if it was originally in a foreign
-        *      character set.  The text is also guaranteed to be null
-        *      terminated now.
+        *      At this point, the message has been stripped down to
+        *      only the content inside the <BODY></BODY> tags, and has
+        *      been converted to UTF-8 if it was originally in a foreign
+        *      character set.  The text is also guaranteed to be null
+        *      terminated now.
         */
 
        if (converted_msg == NULL) {
@@ -344,7 +349,7 @@ void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, St
        }
 
        if (BodyArea != NULL) {
-               StrBufAppendBufPlain(converted_msg, HKEY("<table "), 0);  
+               StrBufAppendBufPlain(converted_msg, HKEY("<table "), 0);
                StrBufAppendBuf(converted_msg, BodyArea, 0);
                StrBufAppendBufPlain(converted_msg, HKEY(" width=\"100%\"><tr><td>"), 0);
        }
@@ -371,29 +376,28 @@ void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, St
                 */
                if (!strncasecmp(ptr, "<a href=\"mailto:", 16)) {
                        content_length += 64;
-                       StrBufAppendPrintf(converted_msg,
-                                       "<a href=\"display_enter?force_room=_MAIL_?recp=");
+                       StrBufAppendPrintf(converted_msg, "<a href=\"display_enter?force_room=_MAIL_?recp=");
                        ptr = &ptr[16];
                        ++alevel;
                        ++brak;
                }
+
                /** Make external links open in a separate window */
                else if (!strncasecmp(ptr, "<a href=\"", 9)) {
                        ++alevel;
                        ++brak;
-                       if ( ((strchr(ptr, ':') < strchr(ptr, '/')))
-                                       &&  ((strchr(ptr, '/') < strchr(ptr, '>'))) 
-                          ) {
+                       if (((strchr(ptr, ':') < strchr(ptr, '/')))
+                           && ((strchr(ptr, '/') < strchr(ptr, '>')))
+                           ) {
                                /* open external links to new window */
                                StrBufAppendPrintf(converted_msg, new_window);
                                ptr = &ptr[8];
                        }
-                       else if (
-                               (treat_as_wiki)
-                               && (strncasecmp(ptr, "<a href=\"wiki?", 14))
-                               && (strncasecmp(ptr, "<a href=\"dotgoto?", 17))
-                               && (strncasecmp(ptr, "<a href=\"knrooms?", 17))
-                       ) {
+                       else if ((treat_as_wiki)
+                                && (strncasecmp(ptr, "<a href=\"wiki?", 14))
+                                && (strncasecmp(ptr, "<a href=\"dotgoto?", 17))
+                                && (strncasecmp(ptr, "<a href=\"knrooms?", 17))
+                           ) {
                                content_length += 64;
                                StrBufAppendPrintf(converted_msg, "<a href=\"wiki?go=");
                                StrBufUrlescAppend(converted_msg, WC->CurRoom.name, NULL);
@@ -405,42 +409,40 @@ void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, St
                                ptr = &ptr[9];
                        }
                }
+
                /** Fixup <img src="cid:... ...> to fetch the mime part */
                else if (!strncasecmp(ptr, "<img ", 5)) {
                        char *cid_start, *cid_end;
-                       char* tag_end=strchr(ptr,'>');
-                       charsrc;
+                       char *tag_end = strchr(ptr, '>');
+                       char *src;
                        /* FIXME - handle this situation (maybe someone opened an <img cid... 
                         * and then ended the message)
                         */
                        if (!tag_end) {
                                syslog(LOG_DEBUG, "tag_end is null and ptr is:\n");
                                syslog(LOG_DEBUG, "%s\n", ptr);
-                               syslog(LOG_DEBUG, "Theoretical bytes remaining: %d\n", (int)(msgend - ptr));
+                               syslog(LOG_DEBUG, "Theoretical bytes remaining: %d\n", (int) (msgend - ptr));
                        }
 
-                       src=strstr(ptr, "src=\"cid:");
+                       src = strstr(ptr, "src=\"cid:");
                        ++brak;
 
-                       if (src
-                           && isspace(*(src-1))
-                               && tag_end
-                               && (cid_start=strchr(src,':'))
-                               && (cid_end=strchr(cid_start,'"'))
-                               && (cid_end < tag_end)
-                       ) {
+                       if (src && isspace(*(src - 1))
+                           && tag_end && (cid_start = strchr(src, ':'))
+                           && (cid_end = strchr(cid_start, '"'))
+                           && (cid_end < tag_end)
+                           ) {
                                /* copy tag and attributes up to src="cid: */
                                StrBufAppendBufPlain(converted_msg, ptr, src - ptr, 0);
                                cid_start++;
 
                                /* add in /webcit/mimepart/<msgno>/CID/ 
                                   trailing / stops dumb URL filters getting excited */
-                               StrBufAppendPrintf(converted_msg,
-                                               " src=\"/webcit/mimepart/%d/",msgnum);
+                               StrBufAppendPrintf(converted_msg, " src=\"/webcit/mimepart/%d/", msgnum);
                                StrBufAppendBufPlain(converted_msg, cid_start, cid_end - cid_start, 0);
                                StrBufAppendBufPlain(converted_msg, "/\"", -1, 0);
 
-                               ptr = cid_end+1;
+                               ptr = cid_end + 1;
                        }
                        StrBufAppendBufPlain(converted_msg, ptr, tag_end - ptr, 0);
                        ptr = tag_end;
@@ -450,45 +452,44 @@ void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, St
                 * Turn anything that looks like a URL into a real link, as long
                 * as it's not inside a tag already
                 */
-               else if ( (brak == 0) && (alevel == 0) &&
-                         ( (!strncasecmp(ptr, "http://", 7)) ||
-                           (!strncasecmp(ptr, "https://", 8)))) {
+               else if ((brak == 0) && (alevel == 0) && ((!strncasecmp(ptr, "http://", 7)) || (!strncasecmp(ptr, "https://", 8)))) {
+
                        /** Find the end of the link */
                        int strlenptr;
                        linklen = 0;
-                               
+
                        strlenptr = strlen(ptr);
-                       for (i=0; i<=strlenptr; ++i) {
-                               if ((ptr[i]==0)
-                                   ||(isspace(ptr[i]))
-                                   ||(ptr[i]==10)
-                                   ||(ptr[i]==13)
-                                   ||(ptr[i]=='(')
-                                   ||(ptr[i]==')')
-                                   ||(ptr[i]=='<')
-                                   ||(ptr[i]=='>')
-                                   ||(ptr[i]=='[')
-                                   ||(ptr[i]==']')
-                                   ||(ptr[i]=='"')
-                                   ||(ptr[i]=='\'')
-                                       ) linklen = i;
+                       for (i = 0; i <= strlenptr; ++i) {
+                               if ((ptr[i] == 0)
+                                   || (isspace(ptr[i]))
+                                   || (ptr[i] == 10)
+                                   || (ptr[i] == 13)
+                                   || (ptr[i] == '(')
+                                   || (ptr[i] == ')')
+                                   || (ptr[i] == '<')
+                                   || (ptr[i] == '>')
+                                   || (ptr[i] == '[')
+                                   || (ptr[i] == ']')
+                                   || (ptr[i] == '"')
+                                   || (ptr[i] == '\'')
+                                   )
+                                       linklen = i;
                                /* did s.b. send us an entity? */
                                if (ptr[i] == '&') {
-                                       if ((ptr[i+2] ==';') ||
-                                           (ptr[i+3] ==';') ||
-                                           (ptr[i+5] ==';') ||
-                                           (ptr[i+6] ==';') ||
-                                           (ptr[i+7] ==';'))
+                                       if ((ptr[i + 2] == ';') ||
+                                           (ptr[i + 3] == ';') ||
+                                           (ptr[i + 5] == ';') || (ptr[i + 6] == ';') || (ptr[i + 7] == ';'))
                                                linklen = i;
                                }
-                               if (linklen > 0) break;
+                               if (linklen > 0)
+                                       break;
                        }
                        if (linklen > 0) {
                                char *ltreviewptr;
                                char *nbspreviewptr;
                                char linkedchar;
                                int len;
-                                       
+
                                len = linklen;
                                linkedchar = ptr[len];
                                ptr[len] = '\0';
@@ -530,38 +531,43 @@ void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, St
                         * so we don't turn things that look like URL's into
                         * links, when they're already links - or image sources.
                         */
-                       if ((ptr > msg) && (*(ptr-1) == '<')) {
+                       if ((ptr > msg) && (*(ptr - 1) == '<')) {
                                ++brak;
                        }
-                       if ((ptr > msg) && (*(ptr-1) == '>')) {
+                       if ((ptr > msg) && (*(ptr - 1) == '>')) {
                                --brak;
                                if ((scriptlevel == 0) && (script_start_pos >= 0)) {
                                        StrBufCutRight(converted_msg, StrLength(converted_msg) - script_start_pos);
                                        script_start_pos = (-1);
                                }
                        }
-                       if (!strncasecmp(ptr, "</A>", 3)) --alevel;
+                       if (!strncasecmp(ptr, "</A>", 3))
+                               --alevel;
                }
        }
 
        if (BodyArea != NULL) {
-               StrBufAppendBufPlain(converted_msg, HKEY("</td></tr></table>"), 0);  
+               StrBufAppendBufPlain(converted_msg, HKEY("</td></tr></table>"), 0);
                FreeStrBuf(&BodyArea);
        }
 
        /**     uncomment these two lines to override conversion        */
+
        /**     memcpy(converted_msg, msg, content_length);             */
+
        /**     output_length = content_length;                         */
 
        /** Output our big pile of markup */
        StrBufAppendBuf(Target, converted_msg, 0);
 
-BAIL:  /** A little trailing vertical whitespace... */
+      BAIL:
+       /** A little trailing vertical whitespace... */
        StrBufAppendPrintf(Target, "<br><br>\n");
 
        /** Now give back the memory */
        FreeStrBuf(&converted_msg);
-       if ((msg != NULL) && (Source == NULL)) free(msg);
+       if ((msg != NULL) && (Source == NULL))
+               free(msg);
 }
 
 
@@ -573,11 +579,10 @@ BAIL:     /** A little trailing vertical whitespace... */
  * Look for URL's embedded in a buffer and make them linkable.  We use a
  * target window in order to keep the Citadel session in its own window.
  */
-void UrlizeText(StrBuf* Target, StrBuf *Source, StrBuf *WrkBuf)
-{
+void UrlizeText(StrBuf * Target, StrBuf * Source, StrBuf * WrkBuf) {
        int len, UrlLen, Offset, TrailerLen;
        const char *start, *end, *pos;
-       
+
        FlushStrBuf(Target);
 
        start = NULL;
@@ -597,25 +602,25 @@ void UrlizeText(StrBuf* Target, StrBuf *Source, StrBuf *WrkBuf)
        FlushStrBuf(WrkBuf);
 
        for (pos = ChrPtr(Source) + len; pos > start; --pos) {
-               if (  (!isprint(*pos))
-                  || (isspace(*pos))
-                  || (*pos == '{')
-                  || (*pos == '}')
-                  || (*pos == '|')
-                  || (*pos == '\\')
-                  || (*pos == '^')
-                  || (*pos == '[')
-                  || (*pos == ']')
-                  || (*pos == '`')
-                  || (*pos == '<')
-                  || (*pos == '>')
-                  || (*pos == '(')
-                  || (*pos == ')')
-               ) {
+               if ((!isprint(*pos))
+                   || (isspace(*pos))
+                   || (*pos == '{')
+                   || (*pos == '}')
+                   || (*pos == '|')
+                   || (*pos == '\\')
+                   || (*pos == '^')
+                   || (*pos == '[')
+                   || (*pos == ']')
+                   || (*pos == '`')
+                   || (*pos == '<')
+                   || (*pos == '>')
+                   || (*pos == '(')
+                   || (*pos == ')')
+                   ) {
                        end = pos;
                }
        }
-       
+
        UrlLen = end - start;
        StrBufAppendBufPlain(WrkBuf, start, UrlLen, 0);
 
@@ -623,8 +628,7 @@ void UrlizeText(StrBuf* Target, StrBuf *Source, StrBuf *WrkBuf)
        if (Offset != 0)
                StrBufAppendBufPlain(Target, ChrPtr(Source), Offset, 0);
        StrBufAppendPrintf(Target, "%ca href=%c%s%c TARGET=%c%s%c%c%s%c/A%c",
-                          LB, QU, ChrPtr(WrkBuf), QU, QU, TARGET, 
-                          QU, RB, ChrPtr(WrkBuf), LB, RB);
+                          LB, QU, ChrPtr(WrkBuf), QU, QU, TARGET, QU, RB, ChrPtr(WrkBuf), LB, RB);
 
        TrailerLen = StrLength(Source) - (end - ChrPtr(Source));
        if (TrailerLen > 0)
@@ -632,8 +636,7 @@ void UrlizeText(StrBuf* Target, StrBuf *Source, StrBuf *WrkBuf)
 }
 
 
-void url(char *buf, size_t bufsize)
-{
+void url(char *buf, size_t bufsize) {
        int len, UrlLen, Offset, TrailerLen, outpos;
        char *start, *end, *pos;
        char urlbuf[SIZ];
@@ -656,28 +659,28 @@ void url(char *buf, size_t bufsize)
        if (start == NULL)
                return;
 
-       for (pos = buf+len; pos > start; --pos) {
-               if (  (!isprint(*pos))
-                  || (isspace(*pos))
-                  || (*pos == '{')
-                  || (*pos == '}')
-                  || (*pos == '|')
-                  || (*pos == '\\')
-                  || (*pos == '^')
-                  || (*pos == '[')
-                  || (*pos == ']')
-                  || (*pos == '`')
-                  || (*pos == '<')
-                  || (*pos == '>')
-                  || (*pos == '(')
-                  || (*pos == ')')
-               ) {
+       for (pos = buf + len; pos > start; --pos) {
+               if ((!isprint(*pos))
+                   || (isspace(*pos))
+                   || (*pos == '{')
+                   || (*pos == '}')
+                   || (*pos == '|')
+                   || (*pos == '\\')
+                   || (*pos == '^')
+                   || (*pos == '[')
+                   || (*pos == ']')
+                   || (*pos == '`')
+                   || (*pos == '<')
+                   || (*pos == '>')
+                   || (*pos == '(')
+                   || (*pos == ')')
+                   ) {
                        end = pos;
                }
        }
-       
+
        UrlLen = end - start;
-       if (UrlLen > sizeof(urlbuf)){
+       if (UrlLen > sizeof(urlbuf)) {
                syslog(LOG_WARNING, "URL: content longer than buffer!");
                return;
        }
@@ -687,9 +690,8 @@ void url(char *buf, size_t bufsize)
        Offset = start - buf;
        if ((Offset != 0) && (Offset < sizeof(outbuf)))
                memcpy(outbuf, buf, Offset);
-       outpos = snprintf(&outbuf[Offset], sizeof(outbuf) - Offset,  
-                         "%ca href=%c%s%c TARGET=%c%s%c%c%s%c/A%c",
-                         LB, QU, urlbuf, QU, QU, TARGET, QU, RB, urlbuf, LB, RB);
+       outpos = snprintf(&outbuf[Offset], sizeof(outbuf) - Offset,
+                         "%ca href=%c%s%c TARGET=%c%s%c%c%s%c/A%c", LB, QU, urlbuf, QU, QU, TARGET, QU, RB, urlbuf, LB, RB);
        if (outpos >= sizeof(outbuf) - Offset) {
                syslog(LOG_WARNING, "URL: content longer than buffer!");
                return;
@@ -702,7 +704,6 @@ void url(char *buf, size_t bufsize)
                syslog(LOG_WARNING, "URL: content longer than buffer!");
                return;
        }
-       memcpy (buf, outbuf, Offset + outpos + TrailerLen);
+       memcpy(buf, outbuf, Offset + outpos + TrailerLen);
        *(buf + Offset + outpos + TrailerLen) = '\0';
 }
-
index d1f6634e3df5c1b16f8d4266ac305d583c8e2f36..d80adf4fe481522cf8209f148dc9f50e04aca5c3 100644 (file)
@@ -1,9 +1,11 @@
 #include "webcit.h"
 
 #ifdef __FreeBSD__
+
 /** I like to believe there is a better way to do this. */
 #define HAVE_STRUCT_TM_TM_GMTOFF
 #endif
+
 /** HTTP Months - do not translate - these are not for human consumption */
 static char *httpdate_months[] = {
        "Jan", "Feb", "Mar", "Apr", "May", "Jun",
@@ -43,27 +45,19 @@ void http_datestring(char *buf, size_t n, time_t xtime) {
                offset = 0L - offset;
                offsign = '-';
        }
-       offset = ( (offset / 3600) * 100 ) + ( offset % 60 );
+       offset = ((offset / 3600) * 100) + (offset % 60);
 
        snprintf(buf, n, "%s, %02d %s %04d %02d:%02d:%02d %c%04ld",
-               httpdate_weekdays[t.tm_wday],
-               t.tm_mday,
-               httpdate_months[t.tm_mon],
-               t.tm_year + 1900,
-               t.tm_hour,
-               t.tm_min,
-               t.tm_sec,
-               offsign, offset
-       );
+                httpdate_weekdays[t.tm_wday],
+                t.tm_mday, httpdate_months[t.tm_mon], t.tm_year + 1900, t.tm_hour, t.tm_min, t.tm_sec, offsign, offset);
 }
 
 
-void tmplput_nowstr(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_nowstr(StrBuf * Target, WCTemplputParams * TP) {
        char buf[64];
        long bufused;
        time_t now;
-       
+
        now = time(NULL);
 #ifdef HAVE_SOLARIS_LOCALTIME_R
        asctime_r(localtime(&now), buf, sizeof(buf));
@@ -73,21 +67,17 @@ void tmplput_nowstr(StrBuf *Target, WCTemplputParams *TP)
        bufused = strlen(buf);
        if ((bufused > 0) && (buf[bufused - 1] == '\n')) {
                buf[bufused - 1] = '\0';
-               bufused --;
+               bufused--;
        }
        StrEscAppend(Target, NULL, buf, 0, 0);
 }
-void tmplput_nowno(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_nowno(StrBuf * Target, WCTemplputParams * TP) {
        time_t now;
        now = time(NULL);
        StrBufAppendPrintf(Target, "%ld", now);
 }
 
-void 
-InitModule_DATE
-(void)
-{
+void InitModule_DATE(void) {
        RegisterNamespace("DATE:NOW:STR", 0, 0, tmplput_nowstr, NULL, CTX_NONE);
        RegisterNamespace("DATE:NOW:NO", 0, 0, tmplput_nowno, NULL, CTX_NONE);
 }
index de444a9d5522a791e5a56083c0195b9de0323dcf..6c1fc9c069d27b7e385ac71b2c39dfc0b7545f1f 100644 (file)
@@ -1,3 +1,4 @@
+
 /* 
  * Function to go through an ical component set and convert all non-UTC
  * date/time properties to UTC.  It also strips out any VTIMEZONE
  */
 icaltimezone *get_default_icaltimezone(void) {
 
-        icaltimezone *zone = NULL;
+       icaltimezone *zone = NULL;
        const char *default_zone_name = ChrPtr(WC->serv_info->serv_default_cal_zone);
 
-        if (!zone) {
-                zone = icaltimezone_get_builtin_timezone(default_zone_name);
-        }
-        if (!zone) {
+       if (!zone) {
+               zone = icaltimezone_get_builtin_timezone(default_zone_name);
+       }
+       if (!zone) {
                syslog(LOG_WARNING, "Unable to load '%s' time zone.  Defaulting to UTC.\n", default_zone_name);
-                zone = icaltimezone_get_utc_timezone();
+               zone = icaltimezone_get_utc_timezone();
        }
        if (!zone) {
                syslog(LOG_ERR, "Unable to load UTC time zone!\n");
        }
-        return zone;
+       return zone;
 }
 
 
@@ -41,9 +42,7 @@ icaltimezone *get_default_icaltimezone(void) {
  * and the property (which will be a DTSTART, DTEND, etc.)
  * which we want to convert to UTC.
  */
-void ical_dezonify_backend(icalcomponent *cal,
-                       icalcomponent *rcal,
-                       icalproperty *prop) {
+void ical_dezonify_backend(icalcomponent * cal, icalcomponent * rcal, icalproperty * prop) {
 
        icaltimezone *t = NULL;
        icalparameter *param;
@@ -52,7 +51,8 @@ void ical_dezonify_backend(icalcomponent *cal,
        int utc_declared_as_tzid = 0;   /* Component declared 'TZID=GMT' instead of using Z syntax */
 
        /* Give me nothing and I will give you nothing in return. */
-       if (cal == NULL) return;
+       if (cal == NULL)
+               return;
 
        /* Hunt for a TZID parameter in this property. */
        param = icalproperty_get_first_parameter(prop, ICAL_TZID_PARAMETER);
@@ -66,7 +66,7 @@ void ical_dezonify_backend(icalcomponent *cal,
 #ifdef DBG_ICAL
                        syslog(LOG_DEBUG, "                * Stringy supplied timezone is: '%s'\n", tzid);
 #endif
-                       if ( (!strcasecmp(tzid, "UTC")) || (!strcasecmp(tzid, "GMT")) ) {
+                       if ((!strcasecmp(tzid, "UTC")) || (!strcasecmp(tzid, "GMT"))) {
                                utc_declared_as_tzid = 1;
 #ifdef DBG_ICAL
                                syslog(LOG_DEBUG, "                * ...and we handle that internally.\n");
@@ -77,8 +77,8 @@ void ical_dezonify_backend(icalcomponent *cal,
                                t = icalcomponent_get_timezone(cal, tzid);
 #ifdef DBG_ICAL
                                syslog(LOG_DEBUG, "                * ...and I %s have tzdata for that zone.\n",
-                                       (t ? "DO" : "DO NOT")
-                               );
+                                      (t ? "DO" : "DO NOT")
+                                   );
 #endif
                                /* then try built-in timezones */
                                if (!t) {
@@ -173,19 +173,16 @@ void ical_dezonify_backend(icalcomponent *cal,
 /*
  * Recursive portion of ical_dezonify()
  */
-void ical_dezonify_recurse(icalcomponent *cal, icalcomponent *rcal) {
+void ical_dezonify_recurse(icalcomponent * cal, icalcomponent * rcal) {
        icalcomponent *c;
        icalproperty *p;
 
        /*
         * Recurse through all subcomponents *except* VTIMEZONE ones.
         */
-       for (c=icalcomponent_get_first_component(
-                                       rcal, ICAL_ANY_COMPONENT);
-               c != NULL;
-               c = icalcomponent_get_next_component(
-                                       rcal, ICAL_ANY_COMPONENT)
-       ) {
+       for (c = icalcomponent_get_first_component(rcal, ICAL_ANY_COMPONENT);
+            c != NULL; c = icalcomponent_get_next_component(rcal, ICAL_ANY_COMPONENT)
+           ) {
                if (icalcomponent_isa(c) != ICAL_VTIMEZONE_COMPONENT) {
                        ical_dezonify_recurse(cal, c);
                }
@@ -194,16 +191,14 @@ void ical_dezonify_recurse(icalcomponent *cal, icalcomponent *rcal) {
        /*
         * Now look for DTSTART and DTEND properties
         */
-       for (p=icalcomponent_get_first_property(rcal, ICAL_ANY_PROPERTY);
-               p != NULL;
-               p = icalcomponent_get_next_property(rcal, ICAL_ANY_PROPERTY)
-       ) {
-               if (
-                       (icalproperty_isa(p) == ICAL_DTSTART_PROPERTY)
-                       || (icalproperty_isa(p) == ICAL_DTEND_PROPERTY)
-                       || (icalproperty_isa(p) == ICAL_DUE_PROPERTY)
-                       || (icalproperty_isa(p) == ICAL_EXDATE_PROPERTY)
-                  ) {
+       for (p = icalcomponent_get_first_property(rcal, ICAL_ANY_PROPERTY);
+            p != NULL; p = icalcomponent_get_next_property(rcal, ICAL_ANY_PROPERTY)
+           ) {
+               if ((icalproperty_isa(p) == ICAL_DTSTART_PROPERTY)
+                   || (icalproperty_isa(p) == ICAL_DTEND_PROPERTY)
+                   || (icalproperty_isa(p) == ICAL_DUE_PROPERTY)
+                   || (icalproperty_isa(p) == ICAL_EXDATE_PROPERTY)
+                   ) {
                        ical_dezonify_backend(cal, rcal, p);
                }
        }
@@ -215,7 +210,7 @@ void ical_dezonify_recurse(icalcomponent *cal, icalcomponent *rcal) {
  * This function will search any VTIMEZONE subcomponents to learn the
  * relevant timezone information.
  */
-void ical_dezonify(icalcomponent *cal) {
+void ical_dezonify(icalcomponent * cal) {
        icalcomponent *vt = NULL;
 
 #ifdef DBG_ICAL
@@ -226,8 +221,7 @@ void ical_dezonify(icalcomponent *cal) {
        ical_dezonify_recurse(cal, cal);
 
        /* Strip out VTIMEZONE subcomponents -- we don't need them anymore */
-       while (vt = icalcomponent_get_first_component(
-                       cal, ICAL_VTIMEZONE_COMPONENT), vt != NULL) {
+       while (vt = icalcomponent_get_first_component(cal, ICAL_VTIMEZONE_COMPONENT), vt != NULL) {
                icalcomponent_remove_component(cal, vt);
                icalcomponent_free(vt);
        }
@@ -236,4 +230,3 @@ void ical_dezonify(icalcomponent *cal) {
        syslog(LOG_DEBUG, "ical_dezonify() completed\n");
 #endif
 }
-
index adb923882994665fdf53883134a02ebc672ccf77..11bf3d4a3eb4b8c33f6f748161a8104d1a1a806b 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2012 by the citadel.org team
  *
@@ -23,8 +24,7 @@ CtxType CTX_ICALTIME = CTX_NONE;
 CtxType CTX_ICALATTENDEE = CTX_NONE;
 CtxType CTX_ICALCONFLICT = CTX_NONE;
 
-void tmplput_ICalItem(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ICalItem(StrBuf * Target, WCTemplputParams * TP) {
        icalcomponent *cal = (icalcomponent *) CTX(CTX_ICAL);
        icalproperty *p;
        icalproperty_kind Kind;
@@ -33,36 +33,32 @@ void tmplput_ICalItem(StrBuf *Target, WCTemplputParams *TP)
        Kind = (icalproperty_kind) GetTemplateTokenNumber(Target, TP, 0, ICAL_ANY_PROPERTY);
        p = icalcomponent_get_first_property(cal, Kind);
        if (p != NULL) {
-               str = icalproperty_get_comment (p);
+               str = icalproperty_get_comment(p);
                StrBufAppendTemplateStr(Target, TP, str, 1);
        }
 }
 
-void tmplput_CtxICalProperty(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_CtxICalProperty(StrBuf * Target, WCTemplputParams * TP) {
        icalproperty *p = (icalproperty *) CTX(CTX_ICALPROPERTY);
        const char *str;
 
-       str = icalproperty_get_comment (p);
+       str = icalproperty_get_comment(p);
        StrBufAppendTemplateStr(Target, TP, str, 0);
 }
 
-int ReleaseIcalSubCtx(StrBuf *Target, WCTemplputParams *TP)
-{
+int ReleaseIcalSubCtx(StrBuf * Target, WCTemplputParams * TP) {
        WCTemplputParams *TPP = TP;
        UnStackContext(TP);
        free(TPP);
        return 0;
 }
-int cond_ICalIsA(StrBuf *Target, WCTemplputParams *TP)
-{
+int cond_ICalIsA(StrBuf * Target, WCTemplputParams * TP) {
        icalcomponent *cal = (icalcomponent *) CTX(CTX_ICAL);
        icalcomponent_kind c = GetTemplateTokenNumber(Target, TP, 2, ICAL_NO_COMPONENT);
        return icalcomponent_isa(cal) == c;
 }
 
-int cond_ICalHaveItem(StrBuf *Target, WCTemplputParams *TP)
-{
+int cond_ICalHaveItem(StrBuf * Target, WCTemplputParams * TP) {
        icalcomponent *cal = (icalcomponent *) CTX(CTX_ICAL);
        icalproperty *p;
        icalproperty_kind Kind;
@@ -71,24 +67,18 @@ int cond_ICalHaveItem(StrBuf *Target, WCTemplputParams *TP)
        p = icalcomponent_get_first_property(cal, Kind);
        if (p != NULL) {
                WCTemplputParams *DynamicTP;
-       
-               DynamicTP = (WCTemplputParams*) malloc(sizeof(WCTemplputParams));
-               StackDynamicContext (TP, 
-                                    DynamicTP, 
-                                    p,
-                                    CTX_ICALPROPERTY,
-                                    0,
-                                    TP->Tokens,
-                                    ReleaseIcalSubCtx,
-                                    TP->Tokens->Params[1]->lvalue);
+
+               DynamicTP = (WCTemplputParams *) malloc(sizeof(WCTemplputParams));
+               StackDynamicContext(TP,
+                                   DynamicTP,
+                                   p, CTX_ICALPROPERTY, 0, TP->Tokens, ReleaseIcalSubCtx, TP->Tokens->Params[1]->lvalue);
 
                return 1;
        }
        return 0;
 }
 
-int ReleaseIcalTimeCtx(StrBuf *Target, WCTemplputParams *TP)
-{
+int ReleaseIcalTimeCtx(StrBuf * Target, WCTemplputParams * TP) {
        WCTemplputParams *TPP = TP;
 
        UnStackContext(TP);
@@ -96,8 +86,7 @@ int ReleaseIcalTimeCtx(StrBuf *Target, WCTemplputParams *TP)
        return 0;
 }
 
-int cond_ICalHaveTimeItem(StrBuf *Target, WCTemplputParams *TP)
-{
+int cond_ICalHaveTimeItem(StrBuf * Target, WCTemplputParams * TP) {
        icalcomponent *cal = (icalcomponent *) CTX(CTX_ICAL);
        icalproperty *p;
        icalproperty_kind Kind;
@@ -109,12 +98,10 @@ int cond_ICalHaveTimeItem(StrBuf *Target, WCTemplputParams *TP)
                struct icaltimetype tt;
                WCTemplputParams *DynamicTP;
 
-               DynamicTP = (WCTemplputParams*) malloc(sizeof(WCTemplputParams) + 
-                                                      sizeof(struct icaltimetype));
+               DynamicTP = (WCTemplputParams *) malloc(sizeof(WCTemplputParams) + sizeof(struct icaltimetype));
                t = (struct icaltimetype *) &DynamicTP[1];
                memset(&tt, 0, sizeof(struct icaltimetype));
-               switch (Kind)
-               {
+               switch (Kind) {
                case ICAL_DTSTART_PROPERTY:
                        tt = icalproperty_get_dtstart(p);
                        break;
@@ -126,14 +113,8 @@ int cond_ICalHaveTimeItem(StrBuf *Target, WCTemplputParams *TP)
                }
                memcpy(t, &tt, sizeof(struct icaltimetype));
 
-               StackDynamicContext (TP, 
-                                    DynamicTP, 
-                                    t,
-                                    CTX_ICALTIME,
-                                    0,
-                                    TP->Tokens,
-                                    ReleaseIcalTimeCtx,
-                                    TP->Tokens->Params[1]->lvalue);
+               StackDynamicContext(TP,
+                                   DynamicTP, t, CTX_ICALTIME, 0, TP->Tokens, ReleaseIcalTimeCtx, TP->Tokens->Params[1]->lvalue);
 
                return 1;
        }
@@ -141,14 +122,12 @@ int cond_ICalHaveTimeItem(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-int cond_ICalTimeIsDate(StrBuf *Target, WCTemplputParams *TP)
-{
+int cond_ICalTimeIsDate(StrBuf * Target, WCTemplputParams * TP) {
        struct icaltimetype *t = (struct icaltimetype *) CTX(CTX_ICALTIME);
        return t->is_date;
 }
 
-void tmplput_ICalTime_Date(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ICalTime_Date(StrBuf * Target, WCTemplputParams * TP) {
        struct tm d_tm;
        long len;
        char buf[256];
@@ -161,20 +140,18 @@ void tmplput_ICalTime_Date(StrBuf *Target, WCTemplputParams *TP)
        len = wc_strftime(buf, sizeof(buf), "%x", &d_tm);
        StrBufAppendBufPlain(Target, buf, len, 0);
 }
-void tmplput_ICalTime_Time(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ICalTime_Time(StrBuf * Target, WCTemplputParams * TP) {
        long len;
        char buf[256];
        struct icaltimetype *t = (struct icaltimetype *) CTX(CTX_ICALTIME);
-        time_t tt;
+       time_t tt;
 
        tt = icaltime_as_timet(*t);
        len = webcit_fmt_date(buf, sizeof(buf), tt, DATEFMT_FULL);
        StrBufAppendBufPlain(Target, buf, len, 0);
 }
 
-void tmplput_ICalDate(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ICalDate(StrBuf * Target, WCTemplputParams * TP) {
        icalcomponent *cal = (icalcomponent *) CTX(CTX_ICAL);
        icalproperty *p;
        icalproperty_kind Kind;
@@ -193,8 +170,7 @@ void tmplput_ICalDate(StrBuf *Target, WCTemplputParams *TP)
        }
 }
 
-void tmplput_CtxICalPropertyDate(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_CtxICalPropertyDate(StrBuf * Target, WCTemplputParams * TP) {
        icalproperty *p = (icalproperty *) CTX(CTX_ICALPROPERTY);
        struct icaltimetype t;
        time_t tt;
@@ -209,15 +185,14 @@ void tmplput_CtxICalPropertyDate(StrBuf *Target, WCTemplputParams *TP)
 
 
 
-void render_MIME_ICS_TPL(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
-{
+void render_MIME_ICS_TPL(StrBuf * Target, WCTemplputParams * TP, StrBuf * FoundCharset) {
        wc_mime_attachment *Mime = CTX(CTX_MIME_ATACH);
        icalproperty_method the_method = ICAL_METHOD_NONE;
        icalproperty *method = NULL;
        icalcomponent *cal = NULL;
        icalcomponent *c = NULL;
-        WCTemplputParams SubTP;
-        WCTemplputParams SuperTP;
+       WCTemplputParams SubTP;
+       WCTemplputParams SuperTP;
 
        static int divcount = 0;
 
@@ -233,41 +208,31 @@ void render_MIME_ICS_TPL(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundChar
                return;
        }
 
-       putlbstr("divname",  ++divcount);
+       putlbstr("divname", ++divcount);
 
 
        putbstr("cal_partnum", NewStrBufDup(Mime->PartNum));
        putlbstr("msgnum", Mime->msgnum);
 
-        memset(&SubTP, 0, sizeof(WCTemplputParams));
-        memset(&SuperTP, 0, sizeof(WCTemplputParams));
+       memset(&SubTP, 0, sizeof(WCTemplputParams));
+       memset(&SuperTP, 0, sizeof(WCTemplputParams));
 
        /*//ical_dezonify(cal); */
 
        /* If the component has subcomponents, recurse through them. */
        c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT);
-        c = (c != NULL) ? c : cal;
+       c = (c != NULL) ? c : cal;
 
        method = icalcomponent_get_first_property(cal, ICAL_METHOD_PROPERTY);
        if (method != NULL) {
                the_method = icalproperty_get_method(method);
        }
 
-       StackContext (TP,
-                     &SuperTP,
-                     &the_method,
-                     CTX_ICALMETHOD,
-                     0,
-                     TP->Tokens);
-
-       StackContext (&SuperTP, 
-                     &SubTP, 
-                     c,
-                     CTX_ICAL,
-                     0,
-                     SuperTP.Tokens);
+       StackContext(TP, &SuperTP, &the_method, CTX_ICALMETHOD, 0, TP->Tokens);
+
+       StackContext(&SuperTP, &SubTP, c, CTX_ICAL, 0, SuperTP.Tokens);
        FlushStrBuf(Mime->Data);
-///    DoTemplate(HKEY("ical_attachment_display"), Mime->Data, &SubTP);
+///     DoTemplate(HKEY("ical_attachment_display"), Mime->Data, &SubTP);
        DoTemplate(HKEY("ical_edit"), Mime->Data, &SubTP);
 
        /*/ cal_process_object(Mime->Data, cal, 0, Mime->msgnum, ChrPtr(Mime->PartNum)); */
@@ -275,35 +240,25 @@ void render_MIME_ICS_TPL(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundChar
        /* Free the memory we obtained from libical's constructor */
        StrBufPlain(Mime->ContentType, HKEY("text/html"));
        StrBufAppendPrintf(WC->trailing_javascript,
-               "eventEditAllDay();             \n"
-               "RecurrenceShowHide();          \n"
-               "EnableOrDisableCheckButton();  \n"
-       );
+                          "eventEditAllDay();          \n"
+                          "RecurrenceShowHide();               \n" "EnableOrDisableCheckButton();      \n");
 
        UnStackContext(&SuperTP);
        UnStackContext(&SubTP);
        icalcomponent_free(cal);
 }
-void CreateIcalComponendKindLookup(void)
-{
+void CreateIcalComponendKindLookup(void) {
        int i = 0;
 
-       IcalComponentMap = NewHash (1, NULL);
+       IcalComponentMap = NewHash(1, NULL);
        while (icalproperty_kind_map[i].NameLen != 0) {
-               RegisterNS(icalproperty_kind_map[i].Name, 
-                          icalproperty_kind_map[i].NameLen, 
-                          0, 
-                          10, 
-                          tmplput_ICalItem,
-                          NULL, 
-                          CTX_ICAL);
-               Put(IcalComponentMap, 
-                   icalproperty_kind_map[i].Name, 
-                   icalproperty_kind_map[i].NameLen, 
-                   &icalproperty_kind_map[i],
-                   reference_free_handler);
-                          
-                          
+               RegisterNS(icalproperty_kind_map[i].Name,
+                          icalproperty_kind_map[i].NameLen, 0, 10, tmplput_ICalItem, NULL, CTX_ICAL);
+               Put(IcalComponentMap,
+                   icalproperty_kind_map[i].Name,
+                   icalproperty_kind_map[i].NameLen, &icalproperty_kind_map[i], reference_free_handler);
+
+
                i++;
        }
 }
@@ -311,8 +266,7 @@ void CreateIcalComponendKindLookup(void)
 
 
 
-int cond_ICalIsMethod(StrBuf *Target, WCTemplputParams *TP)
-{
+int cond_ICalIsMethod(StrBuf * Target, WCTemplputParams * TP) {
        icalproperty_method *the_method = (icalproperty_method *) CTX(CTX_ICALMETHOD);
        icalproperty_method which_method;
 
@@ -321,23 +275,20 @@ int cond_ICalIsMethod(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-typedef struct CalendarConflict
-{
+typedef struct CalendarConflict {
        long is_update;
        long existing_msgnum;
        StrBuf *conflict_event_uid;
        StrBuf *conflict_event_summary;
-}CalendarConflict;
-void DeleteConflict(void *vConflict)
-{
+} CalendarConflict;
+void DeleteConflict(void *vConflict) {
        CalendarConflict *c = (CalendarConflict *) vConflict;
 
        FreeStrBuf(&c->conflict_event_uid);
        FreeStrBuf(&c->conflict_event_summary);
        free(c);
 }
-HashList *iterate_FindConflict(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *iterate_FindConflict(StrBuf * Target, WCTemplputParams * TP) {
        StrBuf *Line;
        HashList *Conflicts = NULL;
        CalendarConflict *Conflict;
@@ -347,16 +298,13 @@ HashList *iterate_FindConflict(StrBuf *Target, WCTemplputParams *TP)
 
        Line = NewStrBuf();
        StrBuf_ServGetln(Line);
-       if (GetServerStatus(Line, NULL) == 1)
-       {
+       if (GetServerStatus(Line, NULL) == 1) {
                const char *Pos = NULL;
                int Done = 0;
                int n = 0;
                Conflicts = NewHash(1, Flathash);
-               while(!Done && (StrBuf_ServGetln(Line) >= 0) )
-                       if ( (StrLength(Line)==3) && 
-                            !strcmp(ChrPtr(Line), "000")) 
-                       {
+               while (!Done && (StrBuf_ServGetln(Line) >= 0))
+                       if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
                                Done = 1;
                        }
                        else {
@@ -382,47 +330,40 @@ HashList *iterate_FindConflict(StrBuf *Target, WCTemplputParams *TP)
 
 
 
-void tmplput_ConflictEventMsgID(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ConflictEventMsgID(StrBuf * Target, WCTemplputParams * TP) {
        CalendarConflict *C = (CalendarConflict *) CTX(CTX_ICALCONFLICT);
        char buf[sizeof(long) * 16];
 
        snprintf(buf, sizeof(buf), "%ld", C->existing_msgnum);
        StrBufAppendTemplateStr(Target, TP, buf, 0);
 }
-void tmplput_ConflictEUID(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ConflictEUID(StrBuf * Target, WCTemplputParams * TP) {
        CalendarConflict *C = (CalendarConflict *) CTX(CTX_ICALCONFLICT);
-       
+
        StrBufAppendTemplate(Target, TP, C->conflict_event_uid, 0);
 }
-void tmplput_ConflictSummary(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ConflictSummary(StrBuf * Target, WCTemplputParams * TP) {
        CalendarConflict *C = (CalendarConflict *) CTX(CTX_ICALCONFLICT);
 
        StrBufAppendTemplate(Target, TP, C->conflict_event_summary, 0);
 }
-int cond_ConflictIsUpdate(StrBuf *Target, WCTemplputParams *TP)
-{
+int cond_ConflictIsUpdate(StrBuf * Target, WCTemplputParams * TP) {
        CalendarConflict *C = (CalendarConflict *) CTX(CTX_ICALCONFLICT);
        return C->is_update;
 }
 
-typedef struct CalAttendee
-{
+typedef struct CalAttendee {
        StrBuf *AttendeeStr;
        icalparameter_partstat partstat;
 } CalAttendee;
 
-void DeleteAtt(void *vAtt)
-{
-       CalAttendee *att = (CalAttendee*) vAtt;
+void DeleteAtt(void *vAtt) {
+       CalAttendee *att = (CalAttendee *) vAtt;
        FreeStrBuf(&att->AttendeeStr);
        free(vAtt);
 }
 
-HashList *iterate_get_ical_attendees(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *iterate_get_ical_attendees(StrBuf * Target, WCTemplputParams * TP) {
        icalcomponent *cal = (icalcomponent *) CTX(CTX_ICAL);
        icalparameter *partstat_param;
        icalproperty *p;
@@ -432,22 +373,18 @@ HashList *iterate_get_ical_attendees(StrBuf *Target, WCTemplputParams *TP)
        int n = 0;
 
        /* If the component has attendees, iterate through them. */
-       for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY); 
-            (p != NULL); 
-            p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) {
+       for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY);
+            (p != NULL); p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) {
                ch = icalproperty_get_attendee(p);
                if ((ch != NULL) && !strncasecmp(ch, "MAILTO:", 7)) {
-                       Att = (CalAttendee*) malloc(sizeof(CalAttendee));
+                       Att = (CalAttendee *) malloc(sizeof(CalAttendee));
 
                        /** screen name or email address */
                        Att->AttendeeStr = NewStrBufPlain(ch + 7, -1);
                        StrBufTrim(Att->AttendeeStr);
 
                        /** participant status */
-                       partstat_param = icalproperty_get_first_parameter(
-                               p,
-                               ICAL_PARTSTAT_PARAMETER
-                               );
+                       partstat_param = icalproperty_get_first_parameter(p, ICAL_PARTSTAT_PARAMETER);
                        if (partstat_param == NULL) {
                                Att->partstat = ICAL_PARTSTAT_X;
                        }
@@ -463,46 +400,43 @@ HashList *iterate_get_ical_attendees(StrBuf *Target, WCTemplputParams *TP)
        return Attendees;
 }
 
-void tmplput_ICalAttendee(StrBuf *Target, WCTemplputParams *TP)
-{
-       CalAttendee *Att = (CalAttendee*) CTX(CTX_ICALATTENDEE);
+void tmplput_ICalAttendee(StrBuf * Target, WCTemplputParams * TP) {
+       CalAttendee *Att = (CalAttendee *) CTX(CTX_ICALATTENDEE);
        StrBufAppendTemplate(Target, TP, Att->AttendeeStr, 0);
 }
-int cond_ICalAttendeeState(StrBuf *Target, WCTemplputParams *TP)
-{
-       CalAttendee *Att = (CalAttendee*) CTX(CTX_ICALATTENDEE);
+int cond_ICalAttendeeState(StrBuf * Target, WCTemplputParams * TP) {
+       CalAttendee *Att = (CalAttendee *) CTX(CTX_ICALATTENDEE);
        icalparameter_partstat which_partstat;
 
        which_partstat = GetTemplateTokenNumber(Target, TP, 2, ICAL_PARTSTAT_X);
        return Att->partstat == which_partstat;
 }
+
        /* If the component has subcomponents, recurse through them. * /
-       for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT);
-            (c != 0);
-            c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)) {
-               // Recursively process subcomponent
-               cal_process_object(Target, c, recursion_level+1, msgnum, cal_partnum);
-       }
-       */
+          for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT);
+          (c != 0);
+          c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)) {
+          // Recursively process subcomponent
+          cal_process_object(Target, c, recursion_level+1, msgnum, cal_partnum);
+          }
+        */
 
 
-void 
-InitModule_ICAL_SUBST
-(void)
-{
+void InitModule_ICAL_SUBST(void) {
        RegisterCTX(CTX_ICAL);
+
 /*
        RegisterMimeRenderer(HKEY("text/calendar"), render_MIME_ICS_TPL, 1, 501);
        RegisterMimeRenderer(HKEY("application/ics"), render_MIME_ICS_TPL, 1, 500);
 */
 
-       CreateIcalComponendKindLookup ();
-       RegisterConditional("COND:ICAL:PROPERTY", 1, cond_ICalHaveItem, CTX_ICAL);
-       RegisterConditional("COND:ICAL:IS:A", 1, cond_ICalIsA, CTX_ICAL);
+       CreateIcalComponendKindLookup();
+       RegisterConditional("COND:ICAL:PROPERTY", 1, cond_ICalHaveItem, CTX_ICAL);
+       RegisterConditional("COND:ICAL:IS:A", 1, cond_ICalIsA, CTX_ICAL);
 
 
-        RegisterIterator("ICAL:CONFLICT", 0, NULL, iterate_FindConflict, 
-                         NULL, DeleteHash, CTX_MIME_ATACH, CTX_ICALCONFLICT, IT_NOFLAG);
+       RegisterIterator("ICAL:CONFLICT", 0, NULL, iterate_FindConflict,
+                        NULL, DeleteHash, CTX_MIME_ATACH, CTX_ICALCONFLICT, IT_NOFLAG);
        RegisterNamespace("ICAL:CONFLICT:MSGID", 0, 1, tmplput_ConflictEventMsgID, NULL, CTX_ICALCONFLICT);
        RegisterNamespace("ICAL:CONFLICT:EUID", 0, 1, tmplput_ConflictEUID, NULL, CTX_ICALCONFLICT);
        RegisterNamespace("ICAL:CONFLICT:SUMMARY", 0, 1, tmplput_ConflictSummary, NULL, CTX_ICALCONFLICT);
@@ -510,10 +444,10 @@ InitModule_ICAL_SUBST
 
 
        RegisterCTX(CTX_ICALATTENDEE);
-        RegisterIterator("ICAL:ATTENDEES", 0, NULL, iterate_get_ical_attendees, 
-                         NULL, DeleteHash, CTX_ICALATTENDEE, CTX_ICAL, IT_NOFLAG);
+       RegisterIterator("ICAL:ATTENDEES", 0, NULL, iterate_get_ical_attendees,
+                        NULL, DeleteHash, CTX_ICALATTENDEE, CTX_ICAL, IT_NOFLAG);
        RegisterNamespace("ICAL:ATTENDEE", 1, 2, tmplput_ICalAttendee, NULL, CTX_ICALATTENDEE);
-       RegisterConditional("COND:ICAL:ATTENDEE", 1, cond_ICalAttendeeState, CTX_ICALATTENDEE);
+       RegisterConditional("COND:ICAL:ATTENDEE", 1, cond_ICalAttendeeState, CTX_ICALATTENDEE);
 
        RegisterCTX(CTX_ICALPROPERTY);
        RegisterNamespace("ICAL:ITEM", 1, 2, tmplput_ICalItem, NULL, CTX_ICAL);
@@ -521,19 +455,16 @@ InitModule_ICAL_SUBST
        RegisterNamespace("ICAL:PROPERTY:DATE", 0, 1, tmplput_CtxICalPropertyDate, NULL, CTX_ICALPROPERTY);
 
        RegisterCTX(CTX_ICALMETHOD);
-       RegisterConditional("COND:ICAL:METHOD", 1, cond_ICalIsMethod, CTX_ICALMETHOD);
+       RegisterConditional("COND:ICAL:METHOD", 1, cond_ICalIsMethod, CTX_ICALMETHOD);
 
 
        RegisterCTX(CTX_ICALTIME);
-       RegisterConditional("COND:ICAL:DT:PROPERTY", 1, cond_ICalHaveTimeItem, CTX_ICAL);
-       RegisterConditional("COND:ICAL:DT:ISDATE", 0, cond_ICalTimeIsDate, CTX_ICALTIME);
+       RegisterConditional("COND:ICAL:DT:PROPERTY", 1, cond_ICalHaveTimeItem, CTX_ICAL);
+       RegisterConditional("COND:ICAL:DT:ISDATE", 0, cond_ICalTimeIsDate, CTX_ICALTIME);
        RegisterNamespace("ICAL:DT:DATE", 0, 1, tmplput_ICalTime_Date, NULL, CTX_ICALTIME);
        RegisterNamespace("ICAL:DT:DATETIME", 0, 1, tmplput_ICalTime_Time, NULL, CTX_ICALTIME);
 }
 
-void 
-ServerShutdownModule_ICAL
-(void)
-{
+void ServerShutdownModule_ICAL(void) {
        DeleteHash(&IcalComponentMap);
 }
index e1ea9b0ec6cd3907d25f4031d314d6d639abe0a0..8f83daa5d8b7ac2b01d28a5ba8e543402c687b5b 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Displays and customizes the iconbar.
  *
 #define IB_PICONLY     1       /* just a picture */
 #define IB_TEXTONLY    2       /* just text */
 
-void DontDeleteThis(void *Data){}
+void DontDeleteThis(void *Data) {
+}
 
 #define IconbarIsEnabled(a, b) IconbarIsENABLED(a, sizeof(a) - 1, b)
 
 
 HashList *IB_Seeting_Order = NULL;
 typedef struct _dflt_IB_Setting {
-       int         DefVal;  /* default value for non-set users */
-       long        n;       /* counter for internal purposes   */
-       const char *Key;     /* Stringvalue */
-       long        len;     /* Length... */
-}dflt_IB_Setting;
+       int DefVal;             /* default value for non-set users */
+       long n;                 /* counter for internal purposes   */
+       const char *Key;        /* Stringvalue */
+       long len;               /* Length... */
+} dflt_IB_Setting;
 
 long nIBV = 0;
 dflt_IB_Setting IconbarDefaults[] = {
-       {0,  0, HKEY("unused")},
-       {0,  1, HKEY("ib_displayas")},
-       {0,  2, HKEY("ib_logo")},
-       {1,  3, HKEY("ib_summary")},
-       {1,  4, HKEY("ib_inbox")},
-       {1,  5, HKEY("ib_calendar")},
-       {1,  6, HKEY("ib_contacts")},
-       {1,  7, HKEY("ib_notes")},
-       {1,  8, HKEY("ib_tasks")},
-       {1,  9, HKEY("ib_rooms")},
-       {1, 10, HKEY("ib_users")},
-       {1, 11, HKEY("ib_chat")},
-       {1, 12, HKEY("ib_advanced")},
-       {1, 13, HKEY("ib_logoff")},
-       {1, 14, HKEY("ib_citadel")},
-       {0, 15, HKEY("")}
+       { 0, 0, HKEY("unused") },
+       { 0, 1, HKEY("ib_displayas") },
+       { 0, 2, HKEY("ib_logo") },
+       { 1, 3, HKEY("ib_summary") },
+       { 1, 4, HKEY("ib_inbox") },
+       { 1, 5, HKEY("ib_calendar") },
+       { 1, 6, HKEY("ib_contacts") },
+       { 1, 7, HKEY("ib_notes") },
+       { 1, 8, HKEY("ib_tasks") },
+       { 1, 9, HKEY("ib_rooms") },
+       { 1, 10, HKEY("ib_users") },
+       { 1, 11, HKEY("ib_chat") },
+       { 1, 12, HKEY("ib_advanced") },
+       { 1, 13, HKEY("ib_logoff") },
+       { 1, 14, HKEY("ib_citadel") },
+       { 0, 15, HKEY("") }
 };
 
 HashList *IBDfl = NULL;
 
 
-long IconbarIsENABLED(long val, const char *key, size_t keylen)
-{
+long IconbarIsENABLED(long val, const char *key, size_t keylen) {
        void *vIBDfl = NULL;
        wcsession *WCC = WC;
 
-       if ((WCC != NULL) && 
-           (WCC->IBSettingsVec != NULL) && 
-           (val < nIBV))
-       {
+       if ((WCC != NULL) && (WCC->IBSettingsVec != NULL) && (val < nIBV)) {
                return WCC->IBSettingsVec[val];
        }
        if (GetHash(IBDfl, key, keylen, &vIBDfl)) {
-               dflt_IB_Setting *Set = (dflt_IB_Setting*)vIBDfl;
+               dflt_IB_Setting *Set = (dflt_IB_Setting *) vIBDfl;
                return Set->DefVal;
        }
-       else 
+       else
                return 1;
 }
 
 #ifdef DBG_ICONBAR_HASH
 static char nbuf[32];
-inline const char *PrintInt(void *Prefstr)
-{
-       snprintf(nbuf, sizeof(nbuf), "%ld", (long)Prefstr);
+inline const char *PrintInt(void *Prefstr) {
+       snprintf(nbuf, sizeof(nbuf), "%ld", (long) Prefstr);
        return nbuf;
 }
 #endif
@@ -88,7 +85,7 @@ inline const char *PrintInt(void *Prefstr)
 */
 
 
-int ConditionalIsActiveStylesheet(StrBuf *Target, WCTemplputParams *TP) {
+int ConditionalIsActiveStylesheet(StrBuf * Target, WCTemplputParams * TP) {
        long testFor;
        long lookAt;
        long ib_displayas;
@@ -99,6 +96,7 @@ int ConditionalIsActiveStylesheet(StrBuf *Target, WCTemplputParams *TP) {
 
 
        ib_displayas = IconbarIsENABLED(lookAt, TKEY(3));
+
 /*
        printf ("%ld == %ld ? %s : %s\n", 
                testFor, 
@@ -110,8 +108,7 @@ int ConditionalIsActiveStylesheet(StrBuf *Target, WCTemplputParams *TP) {
        return (testFor == ib_displayas);
 }
 
-void LoadIconSettings(StrBuf *iconbar, long lvalue)
-{
+void LoadIconSettings(StrBuf * iconbar, long lvalue) {
        void *vIBDfl;
        dflt_IB_Setting *Set;
        const char *pCh = NULL;
@@ -123,9 +120,8 @@ void LoadIconSettings(StrBuf *iconbar, long lvalue)
 
        buf = NewStrBuf();
        key = NewStrBuf();
-       if (WCC->IBSettingsVec == NULL)
-       {
-               WCC->IBSettingsVec = (long*) malloc (nIBV * sizeof(long));
+       if (WCC->IBSettingsVec == NULL) {
+               WCC->IBSettingsVec = (long *) malloc(nIBV * sizeof(long));
        }
        /*
         * The initialized values of these variables also happen to
@@ -134,16 +130,16 @@ void LoadIconSettings(StrBuf *iconbar, long lvalue)
         * configuration somewhere.
         */
 
-       while (StrBufExtract_NextToken(buf, iconbar, &pCh,  ',') >= 0)
-       {
+       while (StrBufExtract_NextToken(buf, iconbar, &pCh, ',') >= 0) {
                StrBufExtract_token(key, buf, 0, '=');
                val = StrBufExtract_long(buf, 1, '=');
 
-               if (!GetHash(IBDfl, SKEY(key), &vIBDfl)) 
+               if (!GetHash(IBDfl, SKEY(key), &vIBDfl))
                        continue;
-               Set = (dflt_IB_Setting*)vIBDfl;
+               Set = (dflt_IB_Setting *) vIBDfl;
 
                WCC->IBSettingsVec[Set->n] = val;
+
 /*             printf("%ld %s %s -> %ld \n", Set->n, Set->Key, IconbarDefaults[Set->n].Key, val);*/
        }
 #ifdef DBG_ICONBAR_HASH
@@ -173,18 +169,12 @@ void commit_iconbar(void) {
        iconbar = NewStrBuf();
        buf = NewStrBuf();
        StrBufPrintf(iconbar, "ib_displayas=%d", ibstr("ib_displayas"));
-       for (i=0; i<(sizeof(IconbarDefaults)/sizeof(dflt_IB_Setting )); ++i) {
+       for (i = 0; i < (sizeof(IconbarDefaults) / sizeof(dflt_IB_Setting)); ++i) {
                char *Val;
-               if (!strcasecmp(Bstr(IconbarDefaults[i].Key,
-                                    IconbarDefaults[i].len),
-                               "yes")) 
-               {
+               if (!strcasecmp(Bstr(IconbarDefaults[i].Key, IconbarDefaults[i].len), "yes")) {
                        Val = "1";
                }
-               else if (!strcasecmp(Bstr(IconbarDefaults[i].Key,
-                                         IconbarDefaults[i].len),
-                                    "yeslist")) 
-               {
+               else if (!strcasecmp(Bstr(IconbarDefaults[i].Key, IconbarDefaults[i].len), "yeslist")) {
                        Val = "2";
                }
                else {
@@ -211,62 +201,46 @@ void commit_iconbar(void) {
  * Display the icon bar as long as we have an active session,
  * and either the user is logged in or the server allows guest mode.
  */
-void tmplput_iconbar(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_iconbar(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
-       
-        if ( (WCC != NULL)     &&
-             ((WCC->logged_in) ||
-             ((WCC->serv_info != NULL) &&
-              (WCC->serv_info->serv_supports_guest))
-                     ) )
-        {
+
+       if ((WCC != NULL) && ((WCC->logged_in) || ((WCC->serv_info != NULL) && (WCC->serv_info->serv_supports_guest))
+           )) {
                DoTemplate(HKEY("iconbar"), NULL, &NoCtx);
        }
 }
 
 
-void 
-ServerShutdownModule_ICONBAR
-(void)
-{
+void ServerShutdownModule_ICONBAR(void) {
        DeleteHash(&IBDfl);
 }
 
 
 
-void
-ServerStartModule_ICONBAR
-(void)
-{
+void ServerStartModule_ICONBAR(void) {
        int i = 1;
        IBDfl = NewHash(1, NULL);
 
-       while (IconbarDefaults[i].len != 0)
-       {
-               Put(IBDfl, 
-                   IconbarDefaults[i].Key, 
-                   IconbarDefaults[i].len, 
-                   &IconbarDefaults[i], 
-                   reference_free_handler);
+       while (IconbarDefaults[i].len != 0) {
+               Put(IBDfl, IconbarDefaults[i].Key, IconbarDefaults[i].len, &IconbarDefaults[i], reference_free_handler);
                i++;
        }
 }
 
 
-int ConditionalWholistExpanded(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalWholistExpanded(StrBuf * Target, WCTemplputParams * TP) {
        int r = 0;
-       if (WC) r = WC->ib_wholist_expanded;
+       if (WC)
+               r = WC->ib_wholist_expanded;
        syslog(LOG_DEBUG, "ConditionalWholistExpanded() returns %d", r);
-       return(r);
+       return (r);
 }
 
 
-int ConditionalRoomlistExpanded(StrBuf *Target, WCTemplputParams *TP)
-{
-       if (WC) return(WC->ib_roomlist_expanded);
-       return(0);
+int ConditionalRoomlistExpanded(StrBuf * Target, WCTemplputParams * TP) {
+       if (WC)
+               return (WC->ib_roomlist_expanded);
+       return (0);
 }
 
 
@@ -305,10 +279,7 @@ void toggle_wholist_expanded_state(void) {
 }
 
 
-void 
-InitModule_ICONBAR
-(void)
-{
+void InitModule_ICONBAR(void) {
        long l;
 
        /*WebcitAddUrlHandler(HKEY("user_iconbar"), "", 0, doUserIconStylesheet, 0); */
@@ -322,22 +293,16 @@ InitModule_ICONBAR
 
        RegisterPreference("iconbar", _("Iconbar Setting"), PRF_STRING, LoadIconSettings);
        l = 1;
-       while (IconbarDefaults[l].len != 0)
-       {
-               RegisterTokenParamDefine(IconbarDefaults[l].Key, 
-                                        IconbarDefaults[l].len, l);
-               l ++;
+       while (IconbarDefaults[l].len != 0) {
+               RegisterTokenParamDefine(IconbarDefaults[l].Key, IconbarDefaults[l].len, l);
+               l++;
        }
        nIBV = l;
 }
 
 
 
-void 
-SessionDestroyModule_ICONBAR
-(wcsession *sess)
-{
+void SessionDestroyModule_ICONBAR(wcsession * sess) {
        if (sess->IBSettingsVec != NULL)
                free(sess->IBSettingsVec);
 }
-
index 28643aedb1dca8ac50d1cb00c4ea526ba808cfa2..bcf79601485d2e824e159eaa1fd1a6572600729a 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Displays and customizes the iconbar.
  *
 HashList *AvailableThemes = NULL;
 
 const StrBuf *DefaultTheme = NULL;
-void LoadIconthemeSettings(StrBuf *icontheme, long lvalue)
-{
+void LoadIconthemeSettings(StrBuf * icontheme, long lvalue) {
        wcsession *WCC = WC;
        void *vTheme;
        const StrBuf *theme;
 
        if (GetHash(AvailableThemes, SKEY(icontheme), &vTheme))
-               theme = (StrBuf*)vTheme;
+               theme = (StrBuf *) vTheme;
        else
                theme = DefaultTheme;
 
-       if (WCC->IconTheme != NULL) 
+       if (WCC->IconTheme != NULL)
                StrBufPlain(WCC->IconTheme, SKEY(theme));
        else
                WCC->IconTheme = NewStrBufDup(theme);
 }
 
 
-void tmplput_icontheme(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_icontheme(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
-       if ( (WCC != NULL)     &&
-            (WCC->IconTheme != NULL))
-       {
-                StrBufAppendTemplate(Target, TP, WCC->IconTheme, 0);
+       if ((WCC != NULL) && (WCC->IconTheme != NULL)) {
+               StrBufAppendTemplate(Target, TP, WCC->IconTheme, 0);
        }
-       else
-       {
-                StrBufAppendTemplate(Target, TP, DefaultTheme, 0);
+       else {
+               StrBufAppendTemplate(Target, TP, DefaultTheme, 0);
        }
 }
 
 
-int LoadThemeDir(const char *DirName)
-{
+int LoadThemeDir(const char *DirName) {
        StrBuf *Dir = NULL;
        DIR *filedir = NULL;
        struct dirent *d;
        struct dirent *filedir_entry;
        int d_type = 0;
-        int d_namelen;
-               
-       filedir = opendir (DirName);
+       int d_namelen;
+
+       filedir = opendir(DirName);
        if (filedir == NULL) {
                return 0;
        }
 
-       d = (struct dirent *)malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1);
+       d = (struct dirent *) malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1);
        if (d == NULL) {
                return 0;
        }
 
-       while ((readdir_r(filedir, d, &filedir_entry) == 0) &&
-              (filedir_entry != NULL))
-       {
+       while ((readdir_r(filedir, d, &filedir_entry) == 0) && (filedir_entry != NULL)) {
 #ifdef _DIRENT_HAVE_D_NAMELEN
                d_namelen = filedir_entry->d_namlen;
                d_type = filedir_entry->d_type;
@@ -101,37 +94,31 @@ int LoadThemeDir(const char *DirName)
                d_type = DT_UNKNOWN;
 #endif
                if ((d_namelen > 1) && filedir_entry->d_name[d_namelen - 1] == '~')
-                       continue; /* Ignore backup files... */
+                       continue;       /* Ignore backup files... */
 
-               if ((d_namelen == 1) && 
-                   (filedir_entry->d_name[0] == '.'))
+               if ((d_namelen == 1) && (filedir_entry->d_name[0] == '.'))
                        continue;
 
-               if ((d_namelen == 2) && 
-                   (filedir_entry->d_name[0] == '.') &&
-                   (filedir_entry->d_name[1] == '.'))
+               if ((d_namelen == 2) && (filedir_entry->d_name[0] == '.') && (filedir_entry->d_name[1] == '.'))
                        continue;
 
                if (d_type == DT_UNKNOWN) {
                        struct stat s;
                        char path[PATH_MAX];
-                       snprintf(path, PATH_MAX, "%s/%s", 
-                               DirName, filedir_entry->d_name);
+                       snprintf(path, PATH_MAX, "%s/%s", DirName, filedir_entry->d_name);
                        if (stat(path, &s) == 0) {
                                d_type = IFTODT(s.st_mode);
                        }
                }
 
-               switch (d_type)
-               {
-               case DT_LNK: /* TODO: check whether its a file or a directory */
+               switch (d_type) {
+               case DT_LNK:    /* TODO: check whether its a file or a directory */
                case DT_DIR:
                        /* Skip directories we are not interested in... */
-                       if ((strcmp(filedir_entry->d_name, ".svn") == 0) ||
-                           (strcmp(filedir_entry->d_name, "t") == 0))
+                       if ((strcmp(filedir_entry->d_name, ".svn") == 0) || (strcmp(filedir_entry->d_name, "t") == 0))
                                break;
-                       
-                       Dir = NewStrBufPlain (filedir_entry->d_name, d_namelen);
+
+                       Dir = NewStrBufPlain(filedir_entry->d_name, d_namelen);
                        if (DefaultTheme == NULL)
                                DefaultTheme = Dir;
                        Put(AvailableThemes, SKEY(Dir), Dir, HFreeStrBuf);
@@ -149,20 +136,15 @@ int LoadThemeDir(const char *DirName)
        return 1;
 }
 
-HashList *GetValidThemeHash(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *GetValidThemeHash(StrBuf * Target, WCTemplputParams * TP) {
        return AvailableThemes;
 }
-void 
-ServerStartModule_ICONTHEME
-(void)
-{
+
+void ServerStartModule_ICONTHEME(void) {
        AvailableThemes = NewHash(1, NULL);
 }
-void 
-InitModule_ICONTHEME
-(void)
-{
+
+void InitModule_ICONTHEME(void) {
        StrBuf *Themes = NewStrBufPlain(static_dirs[0], -1);
 
        StrBufAppendBufPlain(Themes, HKEY("/"), 0);
@@ -173,21 +155,13 @@ InitModule_ICONTHEME
        RegisterPreference("icontheme", _("Icon Theme"), PRF_STRING, LoadIconthemeSettings);
        RegisterNamespace("ICONTHEME", 0, 0, tmplput_icontheme, NULL, CTX_NONE);
 
-       RegisterIterator("PREF:VALID:THEME", 0, NULL, 
-                        GetValidThemeHash, NULL, NULL, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
+       RegisterIterator("PREF:VALID:THEME", 0, NULL, GetValidThemeHash, NULL, NULL, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
 }
 
-void 
-ServerShutdownModule_ICONTHEME
-(void)
-{
+void ServerShutdownModule_ICONTHEME(void) {
        DeleteHash(&AvailableThemes);
 }
 
-void 
-SessionDestroyModule_ICONTHEME
-(wcsession *sess)
-{
+void SessionDestroyModule_ICONTHEME(wcsession * sess) {
        FreeStrBuf(&sess->IconTheme);
 }
-
index 265f3f6bd1f61fc177eef28bd72c247fb0df1ca5..138cc03e095b27e80e45ca04cb3f2ad8bf177f4a 100644 (file)
@@ -1,3 +1,4 @@
+
 /* 
  * Functions which handle Internet domain configuration etc.
  */
@@ -33,21 +34,20 @@ ConstStr CfgNames[] = {
        { HKEY("notify") }
 };
 
-       
+
 
 
 /*
  * display the inet config dialog 
  */
-void load_inetconf(void)
-{
+void load_inetconf(void) {
        wcsession *WCC = WC;
        StrBuf *Buf, *CfgToken, *Value;
        void *vHash;
        HashList *Hash;
        char nnn[64];
        int i, len, nUsed;
-       
+
        WCC->InetCfg = NewHash(1, NULL);
 
        for (i = 0; i < (sizeof(CfgNames) / sizeof(ConstStr)); i++) {
@@ -58,11 +58,10 @@ void load_inetconf(void)
        serv_printf("CONF GETSYS|application/x-citadel-internet-config");
        Buf = NewStrBuf();
        StrBuf_ServGetln(Buf);
-               
+
        if (GetServerStatus(Buf, NULL) == 1) {
                CfgToken = NewStrBuf();
-               while ((len = StrBuf_ServGetln(Buf), ((len >= 0) && ((len != 3) || strcmp(ChrPtr(Buf), "000")))))
-               {
+               while ((len = StrBuf_ServGetln(Buf), ((len >= 0) && ((len != 3) || strcmp(ChrPtr(Buf), "000"))))) {
                        Value = NewStrBuf();
                        StrBufExtract_token(CfgToken, Buf, 1, '|');
 
@@ -74,15 +73,15 @@ void load_inetconf(void)
 
                        StrBufExtract_token(Value, Buf, 0, '|');
                        GetHash(WCC->InetCfg, ChrPtr(CfgToken), StrLength(CfgToken), &vHash);
-                       Hash = (HashList*) vHash;
+                       Hash = (HashList *) vHash;
                        if (Hash == NULL) {
                                syslog(LOG_WARNING, "ERROR Loading inet config line: [%s]", ChrPtr(Buf));
                                FreeStrBuf(&Value);
                                continue;
                        }
                        nUsed = GetCount(Hash);
-                       nUsed = snprintf(nnn, sizeof(nnn), "%d", nUsed+1);
-                       Put(Hash, nnn, nUsed, Value, HFreeStrBuf); 
+                       nUsed = snprintf(nnn, sizeof(nnn), "%d", nUsed + 1);
+                       Put(Hash, nnn, nUsed, Value, HFreeStrBuf);
                }
                FreeStrBuf(&CfgToken);
        }
@@ -107,7 +106,7 @@ void new_save_inetconf(void) {
        eType = sbstr("etype");
 
        GetHash(WCC->InetCfg, ChrPtr(eType), StrLength(eType), &vHash);
-       Hash = (HashList*) vHash;
+       Hash = (HashList *) vHash;
        if (Hash == NULL) {
                AppendImportantMessage(_("Invalid Parameter"), -1);
                url_do_template();
@@ -116,17 +115,16 @@ void new_save_inetconf(void) {
 
        if (strcasecmp(bstr("oper"), "delete") == 0) {
                eNum = sbstr("ename");
-               if (!GetHash(Hash, ChrPtr(eNum), StrLength(eNum), &vStr) ||
-                   (vStr == NULL)) {
+               if (!GetHash(Hash, ChrPtr(eNum), StrLength(eNum), &vStr) || (vStr == NULL)) {
                        AppendImportantMessage(_("Invalid Parameter"), -1);
                        url_do_template();
                        return;
                }
 
-               Str = (StrBuf*)vStr;
+               Str = (StrBuf *) vStr;
                AppendImportantMessage(SKEY(Str));
                AppendImportantMessage(_(" has been deleted."), -1);
-               FlushStrBuf(Str);       
+               FlushStrBuf(Str);
        }
        else if (!strcasecmp(bstr("oper"), "add")) {
                StrBuf *name;
@@ -138,12 +136,12 @@ void new_save_inetconf(void) {
                }
 
                nUsed = GetCount(Hash);
-               nUsed = snprintf(nnn, sizeof(nnn), "%d", nUsed+1);
+               nUsed = snprintf(nnn, sizeof(nnn), "%d", nUsed + 1);
                name = NewStrBufDup(eName);
                StrBufTrim(name);
-               Put(Hash, nnn, nUsed, name, HFreeStrBuf); 
+               Put(Hash, nnn, nUsed, name, HFreeStrBuf);
                AppendImportantMessage(SKEY(eName));
-               AppendImportantMessage( /*<domain> added status message*/ _(" added."), -1); 
+               AppendImportantMessage( /*<domain> added status message */ _(" added."), -1);
        }
 
        Buf = NewStrBuf();
@@ -156,7 +154,7 @@ void new_save_inetconf(void) {
                        long KeyLen;
 
                        GetHash(WCC->InetCfg, CKEY(CfgNames[i]), &vHash);
-                       Hash = (HashList*) vHash;
+                       Hash = (HashList *) vHash;
                        if (Hash == NULL) {
                                AppendImportantMessage(_("Invalid Parameter"), -1);
                                url_do_template();
@@ -165,12 +163,12 @@ void new_save_inetconf(void) {
                        if (GetCount(Hash) > 0) {
                                where = GetNewHashPos(Hash, 0);
                                while (GetNextHashPos(Hash, where, &KeyLen, &Key, &vStr)) {
-                                       Str = (StrBuf*) vStr;
-                                       if ((Str!= NULL) && (StrLength(Str) > 0))
-                                               serv_printf("%s|%s", ChrPtr(Str), CfgNames[i].Key); 
+                                       Str = (StrBuf *) vStr;
+                                       if ((Str != NULL) && (StrLength(Str) > 0))
+                                               serv_printf("%s|%s", ChrPtr(Str), CfgNames[i].Key);
                                }
                                DeleteHashPos(&where);
-                       }                       
+                       }
                }
                serv_puts("000");
                DeleteHash(&WCC->InetCfg);
@@ -180,8 +178,7 @@ void new_save_inetconf(void) {
 }
 
 
-void DeleteInetConfHash(StrBuf *Target, WCTemplputParams *TP)
-{
+void DeleteInetConfHash(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
        if (WCC->InetCfg != NULL)
@@ -190,8 +187,7 @@ void DeleteInetConfHash(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-HashList *GetInetConfHash(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *GetInetConfHash(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
        void *vHash;
 
@@ -203,35 +199,27 @@ HashList *GetInetConfHash(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-HashList *GetValidDomainNames(StrBuf *Target, WCTemplputParams *TP) 
-{
+HashList *GetValidDomainNames(StrBuf * Target, WCTemplputParams * TP) {
        StrBuf *Line;
        HashList *ValidDomainNames = NULL;
        long State;
        int gvdnlevel = 0;
-       
+
        serv_printf("GVDN %d", gvdnlevel);
        Line = NewStrBuf();
        StrBuf_ServGetln(Line);
-       if (GetServerStatus(Line, &State) == 1) 
-       {
+       if (GetServerStatus(Line, &State) == 1) {
                int Done = 0;
                int n = 0;
 
                ValidDomainNames = NewHash(1, NULL);
-               while(!Done && (StrBuf_ServGetln(Line) >= 0))
-                       if ( (StrLength(Line)==3) && 
-                            !strcmp(ChrPtr(Line), "000"))
-                       {
+               while (!Done && (StrBuf_ServGetln(Line) >= 0))
+                       if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
                                Done = 1;
                        }
-                       else
-                       {
-                               Put(ValidDomainNames, 
-                                   IKEY(n),
-                                   NewStrBufDup(Line), 
-                                   HFreeStrBuf);
-                               n++; /* #0 is the type... */
+                       else {
+                               Put(ValidDomainNames, IKEY(n), NewStrBufDup(Line), HFreeStrBuf);
+                               n++;    /* #0 is the type... */
                        }
        }
        else if (State == 550)
@@ -244,12 +232,10 @@ HashList *GetValidDomainNames(StrBuf *Target, WCTemplputParams *TP)
 
 
 
-void 
-InitModule_INETCONF
-(void)
-{
+void InitModule_INETCONF(void) {
        WebcitAddUrlHandler(HKEY("save_inetconf"), "", 0, new_save_inetconf, 0);
        RegisterIterator("SERVCFG:INET", 1, NULL, GetInetConfHash, NULL, NULL, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
-       RegisterNamespace("SERVCFG:FLUSHINETCFG",0, 0, DeleteInetConfHash, NULL, CTX_NONE);
-       RegisterIterator("ITERATE:VALID:DOMAINNAMES", 1, NULL, GetValidDomainNames, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
+       RegisterNamespace("SERVCFG:FLUSHINETCFG", 0, 0, DeleteInetConfHash, NULL, CTX_NONE);
+       RegisterIterator("ITERATE:VALID:DOMAINNAMES", 1, NULL, GetValidDomainNames, NULL, DeleteHash, CTX_STRBUF, CTX_NONE,
+                        IT_NOFLAG);
 }
index 5a097b0a433406a2d70b00a4cd9814276a8e9f7e..a7669e03a12b6e9887138c61412fb8220def5781 100644 (file)
@@ -2,32 +2,25 @@
 #include "webserver.h"
 #include "dav.h"
 
-int json_GetParamsGetServerCall(SharedMessageStatus *Stat, 
-                               void **ViewSpecific, 
-                               long oper, 
-                               char *cmd, 
-                               long len,
-                               char *filter,
-                               long flen)
-{
+int json_GetParamsGetServerCall(SharedMessageStatus * Stat,
+                               void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen) {
        Stat->defaultsortorder = 2;
        Stat->sortit = 1;
        Stat->load_seen = 1;
        /* Generally using maxmsgs|startmsg is not required
           in mailbox view, but we have a 'safemode' for clients
           (*cough* Exploder) that simply can't handle too many */
-       if (havebstr("maxmsgs"))  Stat->maxmsgs  = ibstr("maxmsgs");
-       else                      Stat->maxmsgs  = 9999999;
-       if (havebstr("startmsg")) Stat->startmsg = lbstr("startmsg");
-       snprintf(cmd, len, "MSGS %s|%s||1",
-                (oper == do_search) ? "SEARCH" : "ALL",
-                (oper == do_search) ? bstr("query") : ""
-               );
+       if (havebstr("maxmsgs"))
+               Stat->maxmsgs = ibstr("maxmsgs");
+       else
+               Stat->maxmsgs = 9999999;
+       if (havebstr("startmsg"))
+               Stat->startmsg = lbstr("startmsg");
+       snprintf(cmd, len, "MSGS %s|%s||1", (oper == do_search) ? "SEARCH" : "ALL", (oper == do_search) ? bstr("query") : "");
 
        return 200;
 }
-int json_MessageListHdr(SharedMessageStatus *Stat, void **ViewSpecific) 
-{
+int json_MessageListHdr(SharedMessageStatus * Stat, void **ViewSpecific) {
        /* TODO: make a generic function */
        hprintf("HTTP/1.1 200 OK\r\n");
        hprintf("Content-type: application/json; charset=utf-8\r\n");
@@ -38,17 +31,13 @@ int json_MessageListHdr(SharedMessageStatus *Stat, void **ViewSpecific)
        return 0;
 }
 
-int json_RenderView_or_Tail(SharedMessageStatus *Stat, 
-                           void **ViewSpecific, 
-                           long oper)
-{
-       DoTemplate(HKEY("mailsummary_json"),NULL, NULL);
-       
+int json_RenderView_or_Tail(SharedMessageStatus * Stat, void **ViewSpecific, long oper) {
+       DoTemplate(HKEY("mailsummary_json"), NULL, NULL);
+
        return 0;
 }
 
-int json_Cleanup(void **ViewSpecific)
-{
+int json_Cleanup(void **ViewSpecific) {
        /* Note: wDumpContent() will output one additional </div> tag. */
        /* We ought to move this out into template */
        end_burst();
@@ -56,19 +45,8 @@ int json_Cleanup(void **ViewSpecific)
        return 0;
 }
 
-void 
-InitModule_JSONRENDERER
-(void)
-{
-       RegisterReadLoopHandlerset(
-               VIEW_JSON_LIST,
-               json_GetParamsGetServerCall,
-               json_MessageListHdr,
-               NULL, /* TODO: is this right? */
-               ParseMessageListHeaders_Detail,
-               NULL,
-               json_RenderView_or_Tail,
-               json_Cleanup,
-               NULL);
+void InitModule_JSONRENDERER(void) {
+       RegisterReadLoopHandlerset(VIEW_JSON_LIST, json_GetParamsGetServerCall, json_MessageListHdr, NULL,      /* TODO: is this right? */
+                                  ParseMessageListHeaders_Detail, NULL, json_RenderView_or_Tail, json_Cleanup, NULL);
 
 }
index 95f9ecfdbf47344ef60955bf0fa09cfc21c8da05..38b42a10b9f3b0f8f7fc0d1c2da6ef14f38e7f60 100644 (file)
@@ -13,7 +13,7 @@
 #include "webcit.h"
 
 // List subscription handling
-int Conditional_LISTSUB_EXECUTE_SUBSCRIBE(StrBuf *Target, WCTemplputParams *TP) {
+int Conditional_LISTSUB_EXECUTE_SUBSCRIBE(StrBuf * Target, WCTemplputParams * TP) {
        int rc;
        StrBuf *Line;
        const char *ImpMsg;
@@ -48,7 +48,7 @@ int Conditional_LISTSUB_EXECUTE_SUBSCRIBE(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-int Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE(StrBuf *Target, WCTemplputParams *TP) {
+int Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE(StrBuf * Target, WCTemplputParams * TP) {
        int rc;
        StrBuf *Line;
        const char *ImpMsg;
@@ -83,7 +83,7 @@ int Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE(StrBuf *Target, WCTemplputParams *TP
 }
 
 
-int confirm_sub_or_unsub(char *cmd, StrBuf *Target, WCTemplputParams *TP) {
+int confirm_sub_or_unsub(char *cmd, StrBuf * Target, WCTemplputParams * TP) {
        int rc;
        StrBuf *Line;
 
@@ -99,19 +99,19 @@ int confirm_sub_or_unsub(char *cmd, StrBuf *Target, WCTemplputParams *TP) {
 }
 
 
-int Conditional_LISTSUB_EXECUTE_CONFIRMSUBSCRIBE(StrBuf *Target, WCTemplputParams *TP) {
+int Conditional_LISTSUB_EXECUTE_CONFIRMSUBSCRIBE(StrBuf * Target, WCTemplputParams * TP) {
        if (strcmp(bstr("cmd"), "confirm_subscribe")) {
                return 0;
        }
-       return(confirm_sub_or_unsub("confirm_subscribe", Target, TP));
+       return (confirm_sub_or_unsub("confirm_subscribe", Target, TP));
 }
 
 
-int Conditional_LISTSUB_EXECUTE_CONFIRMUNSUBSCRIBE(StrBuf *Target, WCTemplputParams *TP) {
+int Conditional_LISTSUB_EXECUTE_CONFIRMUNSUBSCRIBE(StrBuf * Target, WCTemplputParams * TP) {
        if (strcmp(bstr("cmd"), "confirm_unsubscribe")) {
                return 0;
        }
-       return(confirm_sub_or_unsub("confirm_unsubscribe", Target, TP));
+       return (confirm_sub_or_unsub("confirm_unsubscribe", Target, TP));
 }
 
 
@@ -125,13 +125,10 @@ void do_listsub(void) {
 }
 
 
-void 
-InitModule_LISTSUB
-(void)
-{
-       RegisterConditional("COND:LISTSUB:EXECUTE:SUBSCRIBE", 0, Conditional_LISTSUB_EXECUTE_SUBSCRIBE,  CTX_NONE);
-       RegisterConditional("COND:LISTSUB:EXECUTE:UNSUBSCRIBE", 0, Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE,  CTX_NONE);
+void InitModule_LISTSUB(void) {
+       RegisterConditional("COND:LISTSUB:EXECUTE:SUBSCRIBE", 0, Conditional_LISTSUB_EXECUTE_SUBSCRIBE, CTX_NONE);
+       RegisterConditional("COND:LISTSUB:EXECUTE:UNSUBSCRIBE", 0, Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE, CTX_NONE);
        RegisterConditional("COND:LISTSUB:EXECUTE:CONFIRMSUBSCRIBE", 0, Conditional_LISTSUB_EXECUTE_CONFIRMSUBSCRIBE, CTX_NONE);
        RegisterConditional("COND:LISTSUB:EXECUTE:CONFIRMUNSUBSCRIBE", 0, Conditional_LISTSUB_EXECUTE_CONFIRMUNSUBSCRIBE, CTX_NONE);
-       WebcitAddUrlHandler(HKEY("listsub"), "", 0, do_listsub, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
+       WebcitAddUrlHandler(HKEY("listsub"), "", 0, do_listsub, ANONYMOUS | COOKIEUNNEEDED | FORCE_SESSIONCLOSE);
 }
index d015f53f54ab1e6df2e7186a0f346ef2e5e297a5..58047f1f46d99fa0deb4bbab18cceb801073ed97 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Given a socket, supply the name of the host at the other end.
  *
 /*
  * IPv4/IPv6 locate_host()
  */
-void locate_host(StrBuf *tbuf, int client_socket)
-{
+void locate_host(StrBuf * tbuf, int client_socket) {
        struct sockaddr_in6 clientaddr;
        unsigned int addrlen = sizeof(clientaddr);
        char clienthost[NI_MAXHOST] = "";
 
-       getpeername(client_socket, (struct sockaddr *)&clientaddr, &addrlen);
-       getnameinfo((struct sockaddr *)&clientaddr, addrlen, clienthost, sizeof(clienthost), NULL, 0, 0);
-        StrBufAppendBufPlain(tbuf, clienthost, -1, 0);
+       getpeername(client_socket, (struct sockaddr *) &clientaddr, &addrlen);
+       getnameinfo((struct sockaddr *) &clientaddr, addrlen, clienthost, sizeof(clienthost), NULL, 0, 0);
+       StrBufAppendBufPlain(tbuf, clienthost, -1, 0);
        syslog(LOG_DEBUG, "Client is at %s\n", clienthost);
 }
index 309095130ac6e8d842b496aee4a974dc6eb06753..0d741c7cb6ea3d4c99d9d454a28b5240bbe47b80 100644 (file)
@@ -2,20 +2,15 @@
 #include "webserver.h"
 #include "dav.h"
 
-static inline void CheckConvertBufs(struct wcsession *WCC)
-{
+static inline void CheckConvertBufs(struct wcsession *WCC) {
        if (WCC->ConvertBuf1 == NULL)
                WCC->ConvertBuf1 = NewStrBuf();
        if (WCC->ConvertBuf2 == NULL)
                WCC->ConvertBuf2 = NewStrBuf();
 }
 
-int ParseMessageListHeaders_Detail(StrBuf *Line, 
-                                  const char **pos, 
-                                  message_summary *Msg, 
-                                  StrBuf *ConversionBuffer,
-                                  void **ViewSpecific)
-{
+int ParseMessageListHeaders_Detail(StrBuf * Line,
+                                  const char **pos, message_summary * Msg, StrBuf * ConversionBuffer, void **ViewSpecific) {
        wcsession *WCC = WC;
        long len;
        long totallen;
@@ -27,27 +22,20 @@ int ParseMessageListHeaders_Detail(StrBuf *Line,
        len = StrBufExtract_NextToken(ConversionBuffer, Line, pos, '|');
        if (len > 0) {
                /* Handle senders with RFC2047 encoding */
-               StrBuf_RFC822_2_Utf8(Msg->from, 
-                                    ConversionBuffer, 
-                                    WCC->DefaultCharset, 
-                                    NULL, 
-                                    WCC->ConvertBuf1,
-                                    WCC->ConvertBuf2);
+               StrBuf_RFC822_2_Utf8(Msg->from, ConversionBuffer, WCC->DefaultCharset, NULL, WCC->ConvertBuf1, WCC->ConvertBuf2);
        }
-                       
+
        /* node name */
        len = StrBufExtract_NextToken(ConversionBuffer, Line, pos, '|');
-       if ((len > 0 ) &&
-           ( ((WCC->CurRoom.QRFlags & QR_NETWORK)
-              || ((strcasecmp(ChrPtr(ConversionBuffer), ChrPtr(WCC->serv_info->serv_nodename))
-                   && (strcasecmp(ChrPtr(ConversionBuffer), ChrPtr(WCC->serv_info->serv_fqdn))))))))
-       {
+       if ((len > 0) && (((WCC->CurRoom.QRFlags & QR_NETWORK)
+                          || ((strcasecmp(ChrPtr(ConversionBuffer), ChrPtr(WCC->serv_info->serv_nodename))
+                               && (strcasecmp(ChrPtr(ConversionBuffer), ChrPtr(WCC->serv_info->serv_fqdn)))))))) {
                StrBufAppendBufPlain(Msg->from, HKEY(" @ "), 0);
                StrBufAppendBuf(Msg->from, ConversionBuffer, 0);
        }
 
        /* Internet address (not used)
-        *      StrBufExtract_token(Msg->inetaddr, Line, 4, '|');
+        *      StrBufExtract_token(Msg->inetaddr, Line, 4, '|');
         */
        StrBufSkip_NTokenS(Line, pos, '|', 1);
        Msg->subj = NewStrBufPlain(NULL, totallen);
@@ -56,48 +44,35 @@ int ParseMessageListHeaders_Detail(StrBuf *Line,
        /* we assume the subject is the last parameter inside of the list; 
         * thus we don't use the tokenizer to fetch it, since it will hick up 
         * on tokenizer chars inside of the subjects
-       StrBufExtract_NextToken(ConversionBuffer,  Line, pos, '|');
-       */
+        StrBufExtract_NextToken(ConversionBuffer,  Line, pos, '|');
+        */
        len = 0;
        if (*pos != StrBufNOTNULL) {
                len = totallen - (*pos - ChrPtr(Line));
                StrBufPlain(ConversionBuffer, *pos, len);
                *pos = StrBufNOTNULL;
-               if ((len > 0) &&
-                   (*(ChrPtr(ConversionBuffer) + len - 1) == '|'))
+               if ((len > 0) && (*(ChrPtr(ConversionBuffer) + len - 1) == '|'))
                        StrBufCutRight(ConversionBuffer, 1);
        }
 
        if (len == 0)
-               StrBufAppendBufPlain(Msg->subj, _("(no subject)"), -1,0);
+               StrBufAppendBufPlain(Msg->subj, _("(no subject)"), -1, 0);
        else {
-               StrBuf_RFC822_2_Utf8(Msg->subj, 
-                                    ConversionBuffer, 
-                                    WCC->DefaultCharset, 
-                                    NULL,
-                                    WCC->ConvertBuf1,
-                                    WCC->ConvertBuf2);
+               StrBuf_RFC822_2_Utf8(Msg->subj, ConversionBuffer, WCC->DefaultCharset, NULL, WCC->ConvertBuf1, WCC->ConvertBuf2);
        }
 
        return 1;
 }
 
 
-int mailview_GetParamsGetServerCall(SharedMessageStatus *Stat, 
-                                   void **ViewSpecific, 
-                                   long oper, 
-                                   char *cmd, 
-                                   long len,
-                                   char *filter,
-                                   long flen)
-{
-       DoTemplate(HKEY("msg_listview"),NULL,&NoCtx);
+int mailview_GetParamsGetServerCall(SharedMessageStatus * Stat,
+                                   void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen) {
+       DoTemplate(HKEY("msg_listview"), NULL, &NoCtx);
 
        return 200;
 }
 
-int mailview_Cleanup(void **ViewSpecific)
-{
+int mailview_Cleanup(void **ViewSpecific) {
        /* Note: wDumpContent() will output one additional </div> tag. */
        /* We ought to move this out into template */
        wDumpContent(1);
@@ -105,20 +80,9 @@ int mailview_Cleanup(void **ViewSpecific)
        return 0;
 }
 
-void 
-InitModule_MAILVIEW_RENDERERS
-(void)
-{
+void InitModule_MAILVIEW_RENDERERS(void) {
        RegisterCTX(CTX_MIME_ATACH);
-       RegisterReadLoopHandlerset(
-               VIEW_MAILBOX,
-               mailview_GetParamsGetServerCall,
-               NULL, /* TODO: is this right? */
-               NULL,
-               ParseMessageListHeaders_Detail,
-               NULL,
-               NULL,
-               mailview_Cleanup,
-               NULL);
+       RegisterReadLoopHandlerset(VIEW_MAILBOX, mailview_GetParamsGetServerCall, NULL, /* TODO: is this right? */
+                                  NULL, ParseMessageListHeaders_Detail, NULL, NULL, mailview_Cleanup, NULL);
 
 }
index 2c326e001650e4756e7184f4b939966c8798cc6e..3ec377c1624e814ab9d93b6d0307131129d7f424 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * The main menu and other things
  *
@@ -36,14 +37,14 @@ void display_aide_menu(void) {
 
 // Handle generic server commands, possibly entered from a screen, possibly set up as a way to avoid custom code
 void do_generic(void) {
-        WCTemplputParams SubTP;
+       WCTemplputParams SubTP;
        int Done = 0;
        StrBuf *Buf;
        StrBuf *LineBuf;
        char *junk;
        size_t len;
 
-       if ( (!havebstr("sc_button")) && (!havebstr("ok_button")) && (!havebstr("cancel_button")) ) {
+       if ((!havebstr("sc_button")) && (!havebstr("ok_button")) && (!havebstr("cancel_button"))) {
                display_main_menu();
                return;
        }
@@ -56,12 +57,11 @@ void do_generic(void) {
                Buf = NewStrBuf();
                serv_puts(bstr("g_cmd"));
                StrBuf_ServGetln(Buf);
-               
+
                switch (GetServerStatus(Buf, NULL)) {
                case 8:
                        serv_puts("\n\n000");
-                       if ( (StrLength(Buf)==3) && 
-                       !strcmp(ChrPtr(Buf), "000")) {
+                       if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
                                StrBufAppendBufPlain(Buf, HKEY("\000"), 0);
                                break;
                        }
@@ -71,8 +71,7 @@ void do_generic(void) {
                        while (!Done) {
                                if (StrBuf_ServGetln(LineBuf) < 0)
                                        break;
-                               if ( (StrLength(LineBuf)==3) && 
-                               !strcmp(ChrPtr(LineBuf), "000")) {
+                               if ((StrLength(LineBuf) == 3) && !strcmp(ChrPtr(LineBuf), "000")) {
                                        Done = 1;
                                }
                                StrBufAppendBuf(Buf, LineBuf, 0);
@@ -100,7 +99,7 @@ void do_generic(void) {
                }
                FreeStrBuf(&Buf);
        }
-       
+
        // We may have been supplied with instructions regarding the location
        // to which we must return after posting.  If found, go there.
        if (havebstr("return_to")) {
@@ -112,13 +111,13 @@ void do_generic(void) {
        else {
                begin_burst();
                output_headers(1, 0, 0, 0, 1, 0);
-       
+
                StackContext(NULL, &SubTP, Buf, CTX_STRBUF, 0, NULL);
                {
                        DoTemplate(HKEY("aide_display_generic_result"), NULL, &SubTP);
                }
                UnStackContext(&SubTP);
-               wDumpContent(1);
+               wDumpContent(1);
        }
 
 }
@@ -128,10 +127,10 @@ void do_generic(void) {
 void display_shutdown(void) {
        StrBuf *Line;
        char *when;
-       
+
        Line = NewStrBuf();
-       when=bstr("when");
-       if (strcmp(when, "now") == 0){
+       when = bstr("when");
+       if (strcmp(when, "now") == 0) {
                serv_printf("DOWN 1");
                StrBuf_ServGetln(Line);
                GetServerStatusMsg(Line, NULL, 1, 5);
@@ -147,17 +146,15 @@ void display_shutdown(void) {
        }
        else if (strcmp(when, "page") == 0) {
                char *message;
-              
+
                message = bstr("message");
-               if ((message == NULL) || (IsEmptyStr(message)))
-               {
+               if ((message == NULL) || (IsEmptyStr(message))) {
                        begin_burst();
                        output_headers(1, 0, 0, 0, 1, 0);
                        DoTemplate(HKEY("aide_display_serverrestart_page"), NULL, &NoCtx);
                        end_burst();
                }
-               else
-               {
+               else {
                        serv_printf("SEXP broadcast|%s", message);
                        StrBuf_ServGetln(Line);
                        GetServerStatusMsg(Line, NULL, 1, 0);
@@ -165,7 +162,7 @@ void display_shutdown(void) {
                        begin_burst();
                        output_headers(1, 0, 0, 0, 1, 0);
                        DoTemplate(HKEY("aide_display_serverrestart_page"), NULL, &NoCtx);
-                       end_burst();                    
+                       end_burst();
                }
        }
        else if (!strcmp(when, "idle")) {
@@ -176,16 +173,13 @@ void display_shutdown(void) {
                begin_burst();
                output_headers(1, 0, 0, 0, 1, 0);
                DoTemplate(HKEY("aide_display_menu"), NULL, &NoCtx);
-               end_burst();                    
+               end_burst();
        }
        FreeStrBuf(&Line);
 }
 
 
-void 
-InitModule_MAINMENU
-(void)
-{
+void InitModule_MAINMENU(void) {
        WebcitAddUrlHandler(HKEY("display_aide_menu"), "", 0, display_aide_menu, 0);
        WebcitAddUrlHandler(HKEY("server_shutdown"), "", 0, display_shutdown, 0);
        WebcitAddUrlHandler(HKEY("display_main_menu"), "", 0, display_main_menu, 0);
index 7031d264309cf01101e3d923d89b12e74b537b35..43cb762524bc841f8eb78dbeeac0f90d35c606d9 100644 (file)
@@ -4,8 +4,7 @@
 /*
  * Free a session's march list
  */
-void free_march_list(wcsession *wcf)
-{
+void free_march_list(wcsession * wcf) {
        struct march *mptr;
 
        while (wcf->march != NULL) {
@@ -20,8 +19,7 @@ void free_march_list(wcsession *wcf)
 /*
  * remove a room from the march list
  */
-void remove_march(const StrBuf *aaa)
-{
+void remove_march(const StrBuf * aaa) {
        struct march *mptr, *mptr2;
 
        if (WC->march == NULL)
@@ -39,7 +37,8 @@ void remove_march(const StrBuf *aaa)
                        mptr2->next = mptr->next;
                        free(mptr);
                        mptr = mptr2;
-               } else {
+               }
+               else {
                        mptr2 = mptr;
                }
        }
@@ -54,8 +53,7 @@ void remove_march(const StrBuf *aaa)
  * \param desired_floor the room number on the citadel server
  * \return the roomname
  */
-char *pop_march(int desired_floor)
-{
+char *pop_march(int desired_floor) {
        static char TheRoom[128];
        int TheWeight = 0;
        int weight;
@@ -78,6 +76,7 @@ char *pop_march(int desired_floor)
                if (weight > TheWeight) {
                        TheWeight = weight;
                        strcpy(TheRoom, mptr->march_name);
+
 /* TODOO: and now????
                        TheFloor = mptr->march_floor;
                        TheOrder = mptr->march_order;
@@ -98,8 +97,7 @@ char *pop_march(int desired_floor)
  * We start the search in the current room rather than the beginning to prevent
  * two or more concurrent users from dragging each other back to the same room.
  */
-void gotonext(void)
-{
+void gotonext(void) {
        char buf[256];
        struct march *mptr = NULL;
        struct march *mptr2 = NULL;
@@ -126,8 +124,8 @@ void gotonext(void)
                                                return;
                                        if (ELoop % 100 == 0)
                                                sleeeeeeeeeep(1);
-                                       ELoop ++;
-                                       continue;                                       
+                                       ELoop++;
+                                       continue;
                                }
                                extract_token(room_name, buf, 0, '|', sizeof room_name);
                                if (strcasecmp(room_name, ChrPtr(WC->CurRoom.name))) {
@@ -136,9 +134,9 @@ void gotonext(void)
                                        safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
                                        mptr->march_floor = extract_int(buf, 2);
                                        mptr->march_order = extract_int(buf, 3);
-                                       if (WC->march == NULL) 
+                                       if (WC->march == NULL)
                                                WC->march = mptr;
-                                       else 
+                                       else
                                                mptr2->next = mptr;
                                        mptr2 = mptr;
                                }
@@ -151,11 +149,12 @@ void gotonext(void)
                mptr = (struct march *) malloc(sizeof(struct march));
                mptr->next = NULL;
                mptr->march_order = 0;
-               mptr->march_floor = 0;
+               mptr->march_floor = 0;
                strcpy(mptr->march_name, "_BASEROOM_");
                if (WC->march == NULL) {
                        WC->march = mptr;
-               } else {
+               }
+               else {
                        mptr2 = WC->march;
                        while (mptr2->next != NULL)
                                mptr2 = mptr2->next;
@@ -168,9 +167,10 @@ void gotonext(void)
                remove_march(WC->CurRoom.name);
        }
        if (WC->march != NULL) {
-               next_room = NewStrBufPlain(pop_march(-1), -1);/*TODO: migrate march to strbuf */
+               next_room = NewStrBufPlain(pop_march(-1), -1);  /*TODO: migrate march to strbuf */
                putlbstr("gotonext", 1);
-       } else {
+       }
+       else {
                next_room = NewStrBufPlain(HKEY("_BASEROOM_"));
        }
 
@@ -182,8 +182,7 @@ void gotonext(void)
 /*
  * un-goto the previous room
  */
-void ungoto(void)
-{
+void ungoto(void) {
        StrBuf *Buf;
 
        if (havebstr("startmsg")) {
@@ -216,12 +215,10 @@ void ungoto(void)
 
 
 
-void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ungoto(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
-       if ((WCC!=NULL) && 
-           (!IsEmptyStr(WCC->ugname)))
+       if ((WCC != NULL) && (!IsEmptyStr(WCC->ugname)))
                StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
 }
 
@@ -233,20 +230,14 @@ void _gotonext(void) {
 
 
 
-int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalHaveUngoto(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
-       
-       return ((WCC!=NULL) && 
-               (!IsEmptyStr(WCC->ugname)) && 
-               (strcasecmp(WCC->ugname, ChrPtr(WCC->CurRoom.name)) == 0));
+
+       return ((WCC != NULL) && (!IsEmptyStr(WCC->ugname)) && (strcasecmp(WCC->ugname, ChrPtr(WCC->CurRoom.name)) == 0));
 }
 
 
-void 
-InitModule_MARCHLIST
-(void)
-{
+void InitModule_MARCHLIST(void) {
        RegisterConditional("COND:UNGOTO", 0, ConditionalHaveUngoto, CTX_NONE);
        RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, NULL, CTX_NONE);
 
index d0ad4d67c9451f927af3835e41af3ba421def87c..6c478dcf3c2144e283930b985f4b5dae73b43b18 100644 (file)
@@ -39,12 +39,12 @@ void fixview() {
 }
 
 
-int load_message(message_summary *Msg, StrBuf *FoundCharset, StrBuf **Error) {
+int load_message(message_summary * Msg, StrBuf * FoundCharset, StrBuf ** Error) {
        StrBuf *Buf;
        StrBuf *HdrToken;
        char buf[SIZ];
        int Done = 0;
-       int state=0;
+       int state = 0;
        int rc;
 
        Buf = NewStrBuf();
@@ -67,10 +67,8 @@ int load_message(message_summary *Msg, StrBuf *FoundCharset, StrBuf **Error) {
 
        /* begin everythingamundo table */
        HdrToken = NewStrBuf();
-       while (!Done && StrBuf_ServGetln(Buf)>=0) {
-               if ( (StrLength(Buf)==3) && 
-                   !strcmp(ChrPtr(Buf), "000")) 
-               {
+       while (!Done && StrBuf_ServGetln(Buf) >= 0) {
+               if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
                        Done = 1;
                        if (state < 2) {
                                if (Msg->MsgBody->Data == NULL)
@@ -84,53 +82,52 @@ int load_message(message_summary *Msg, StrBuf *FoundCharset, StrBuf **Error) {
                        break;
                }
                switch (state) {
-               case 0:/* Citadel Message Headers */
+               case 0: /* Citadel Message Headers */
                        if (StrLength(Buf) == 0) {
-                               state ++;
+                               state++;
                                break;
                        }
                        StrBufExtract_token(HdrToken, Buf, 0, '=');
                        StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
-                       
+
                        /* look up one of the examine_* functions to parse the content */
-                       rc =  EvaluateMsgHdr(SKEY(HdrToken), Msg, Buf, FoundCharset);
+                       rc = EvaluateMsgHdr(SKEY(HdrToken), Msg, Buf, FoundCharset);
                        if (rc == 1) {
                                state++;
                        }
                        /* TODO: 
-                       else LogError(Target, 
-                                     __FUNCTION__,  
-                                     "don't know how to handle message header[%s]\n", 
-                                     ChrPtr(HdrToken));
+                          else LogError(Target, 
+                          __FUNCTION__,  
+                          "don't know how to handle message header[%s]\n", 
+                          ChrPtr(HdrToken));
                         */
                        break;
-               case 1:/* Message Mime Header */
+               case 1: /* Message Mime Header */
                        if (StrLength(Buf) == 0) {
                                state++;
                                if (Msg->MsgBody->ContentType == NULL)
-                                       /* end of header or no header? */
+                                       /* end of header or no header? */
                                        Msg->MsgBody->ContentType = NewStrBufPlain(HKEY("text/plain"));
-                                /* usual end of mime header */
+                               /* usual end of mime header */
                        }
-                       else
-                       {
+                       else {
                                StrBufExtract_token(HdrToken, Buf, 0, ':');
                                if (StrLength(HdrToken) > 0) {
                                        StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
                                        /* the examine*'s know how to do with mime headers too... */
                                        EvaluateMsgHdr(SKEY(HdrToken), Msg, Buf, FoundCharset);
-                                       
+
                                        break;
                                }
                        }
-               case 2: /* Message Body */
-                       
+               case 2: /* Message Body */
+
                        if (Msg->MsgBody->size_known > 0) {
                                StrBuf_ServGetBLOBBuffered(Msg->MsgBody->Data, Msg->MsgBody->length);
-                               state ++;
+                               state++;
                                /*/ todo: check next line, if not 000, append following lines */
                        }
-                       else if (1){
+                       else if (1) {
                                if (StrLength(Msg->MsgBody->Data) > 0)
                                        StrBufAppendBufPlain(Msg->MsgBody->Data, "\n", 1, 0);
                                StrBufAppendBuf(Msg->MsgBody->Data, Buf, 0);
@@ -143,10 +140,10 @@ int load_message(message_summary *Msg, StrBuf *FoundCharset, StrBuf **Error) {
        }
 
        if (Msg->AllAttach == NULL)
-               Msg->AllAttach = NewHash(1,NULL);
+               Msg->AllAttach = NewHash(1, NULL);
        /* now we put the body mimepart we read above into the mimelist */
        Put(Msg->AllAttach, SKEY(Msg->MsgBody->PartNum), Msg->MsgBody, DestroyMime);
-       
+
        FreeStrBuf(&Buf);
        FreeStrBuf(&HdrToken);
        return 1;
@@ -160,10 +157,11 @@ int load_message(message_summary *Msg, StrBuf *FoundCharset, StrBuf **Error) {
  * printable_view      Nonzero to display a printable view
  * section             Optional for encapsulated message/rfc822 submessage
  */
-int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, const StrBuf *PartNum, const StrBuf **OutMime, WCTemplputParams *TP) {
+int read_message(StrBuf * Target, const char *tmpl, long tmpllen, long msgnum, const StrBuf * PartNum, const StrBuf ** OutMime,
+                WCTemplputParams * TP) {
        StrBuf *Buf;
        StrBuf *FoundCharset;
-       HashPos  *it;
+       HashPos *it;
        void *vMime;
        message_summary *Msg = NULL;
        void *vHdr;
@@ -178,14 +176,14 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, co
 
        Buf = NewStrBuf();
        FoundCharset = NewStrBuf();
-       Msg = (message_summary *)malloc(sizeof(message_summary));
+       Msg = (message_summary *) malloc(sizeof(message_summary));
        if (!Msg) {
                syslog(LOG_DEBUG, "malloc() error");
        }
        memset(Msg, 0, sizeof(message_summary));
        Msg->msgnum = msgnum;
        Msg->PartNum = PartNum;
-       Msg->MsgBody =  (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
+       Msg->MsgBody = (wc_mime_attachment *) malloc(sizeof(wc_mime_attachment));
        if (!Msg->MsgBody) {
                syslog(LOG_DEBUG, "malloc() error");
        }
@@ -205,33 +203,31 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, co
        StackContext(TP, &SuperTP, Msg, CTX_MAILSUM, 0, NULL);
        {
                /* Locate a renderer capable of converting this MIME part into HTML */
-               if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
-                   (vHdr != NULL)) {
+               if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) && (vHdr != NULL)) {
                        RenderMimeFuncStruct *Render;
-                       
+
                        StackContext(&SuperTP, &SubTP, Msg->MsgBody, CTX_MIME_ATACH, 0, NULL);
                        {
-                               Render = (RenderMimeFuncStruct*)vHdr;
+                               Render = (RenderMimeFuncStruct *) vHdr;
                                Render->f(Target, &SubTP, FoundCharset);
                        }
                        UnStackContext(&SubTP);
                }
-               
-               if (StrLength(Msg->reply_references)> 0) {
+
+               if (StrLength(Msg->reply_references) > 0) {
                        /* Trim down excessively long lists of thread references.  We eliminate the
                         * second one in the list so that the thread root remains intact.
                         */
                        int rrtok = num_tokens(ChrPtr(Msg->reply_references), '|');
                        int rrlen = StrLength(Msg->reply_references);
-                       if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
+                       if (((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10)) {
                                StrBufRemove_token(Msg->reply_references, 1, '|');
                        }
                }
 
                /* now check if we need to translate some mimeparts, and remove the duplicate */
                it = GetNewHashPos(Msg->AllAttach, 0);
-               while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) && 
-                      (vMime != NULL)) {
+               while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) && (vMime != NULL)) {
                        StackContext(&SuperTP, &SubTP, vMime, CTX_MIME_ATACH, 0, NULL);
                        {
                                evaluate_mime_part(Target, &SubTP);
@@ -252,20 +248,18 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, co
 
 long HttpStatus(long CitadelStatus) {
        long httpstatus = 502;
-       
-       switch (MAJORCODE(CitadelStatus))
-       {
+
+       switch (MAJORCODE(CitadelStatus)) {
        case LISTING_FOLLOWS:
        case CIT_OK:
                httpstatus = 201;
                break;
        case ERROR:
-               switch (MINORCODE(CitadelStatus))
-               {
+               switch (MINORCODE(CitadelStatus)) {
                case INTERNAL_ERROR:
                        httpstatus = 403;
                        break;
-                       
+
                case TOO_BIG:
                case ILLEGAL_VALUE:
                case HIGHER_ACCESS_REQUIRED:
@@ -309,7 +303,7 @@ long HttpStatus(long CitadelStatus) {
        case ASYNC_MSG:
        case MORE_DATA:
        case SEND_LISTING:
-               httpstatus = 502; /* aeh... whut? */
+               httpstatus = 502;       /* aeh... whut? */
                break;
        }
 
@@ -341,23 +335,22 @@ void handle_one_message(void) {
        msgnum = atol(pMsg + 1);
        StrBufCutAt(WC->Hdr->HR.ReqLine, 0, pMsg);
        gotoroom(WC->Hdr->HR.ReqLine);
-       switch (WC->Hdr->HR.eReqType)
-       {
+       switch (WC->Hdr->HR.eReqType) {
        case eGET:
        case ePOST:
                Tmpl = sbstr("template");
-               if (StrLength(Tmpl) > 0) 
+               if (StrLength(Tmpl) > 0)
                        read_message(WC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime, NULL);
-               else 
+               else
                        read_message(WC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime, NULL);
                http_transmit_thing(ChrPtr(Mime), 0);
                break;
        case eDELETE:
-               CmdBuf = NewStrBuf ();
+               CmdBuf = NewStrBuf();
                if ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0) {  /* Delete from Trash is a real delete */
-                       serv_printf("DELE %ld", msgnum);        
+                       serv_printf("DELE %ld", msgnum);
                }
-               else {                  /* Otherwise move it to Trash */
+               else {          /* Otherwise move it to Trash */
                        serv_printf("MOVE %ld|_TRASH_|0", msgnum);
                }
                StrBuf_ServGetln(CmdBuf);
@@ -367,9 +360,8 @@ void handle_one_message(void) {
        case eCOPY:
                CopyMessage = 1;
        case eMOVE:
-               if (GetHash(WC->Hdr->HTTPHeaders, HKEY("DESTINATION"), &vLine) &&
-                   (vLine!=NULL)) {
-                       Destination = (StrBuf*) vLine;
+               if (GetHash(WC->Hdr->HTTPHeaders, HKEY("DESTINATION"), &vLine) && (vLine != NULL)) {
+                       Destination = (StrBuf *) vLine;
                        serv_printf("MOVE %ld|%s|%d", msgnum, ChrPtr(Destination), CopyMessage);
                        StrBuf_ServGetln(CmdBuf);
                        GetServerStatusMsg(CmdBuf, NULL, 1, 0);
@@ -397,25 +389,25 @@ void embed_message(void) {
        StrBuf *CmdBuf = NULL;
 
        msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
-       if (msgnum <= 0) return;
+       if (msgnum <= 0)
+               return;
 
-       switch (WC->Hdr->HR.eReqType)
-       {
+       switch (WC->Hdr->HR.eReqType) {
        case eGET:
        case ePOST:
                Tmpl = sbstr("template");
-               if (StrLength(Tmpl) > 0) 
+               if (StrLength(Tmpl) > 0)
                        read_message(WC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime, NULL);
-               else 
+               else
                        read_message(WC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime, NULL);
                http_transmit_thing(ChrPtr(Mime), 0);
                break;
        case eDELETE:
-               CmdBuf = NewStrBuf ();
+               CmdBuf = NewStrBuf();
                if ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0) {  /* Delete from Trash is a real delete */
-                       serv_printf("DELE %ld", msgnum);        
+                       serv_printf("DELE %ld", msgnum);
                }
-               else {                  /* Otherwise move it to Trash */
+               else {          /* Otherwise move it to Trash */
                        serv_printf("MOVE %ld|_TRASH_|0", msgnum);
                }
                StrBuf_ServGetln(CmdBuf);
@@ -438,9 +430,7 @@ void print_message(void) {
        msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
        output_headers(0, 0, 0, 0, 0, 0);
 
-       hprintf("Content-type: text/html\r\n"
-               "Server: " PACKAGE_STRING "\r\n"
-               "Connection: close\r\n");
+       hprintf("Content-type: text/html\r\n" "Server: " PACKAGE_STRING "\r\n" "Connection: close\r\n");
 
        begin_burst();
 
@@ -460,10 +450,7 @@ void display_headers(void) {
        msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
        output_headers(0, 0, 0, 0, 0, 0);
 
-       hprintf("Content-type: text/plain\r\n"
-               "Server: %s\r\n"
-               "Connection: close\r\n",
-               PACKAGE_STRING);
+       hprintf("Content-type: text/plain\r\n" "Server: %s\r\n" "Connection: close\r\n", PACKAGE_STRING);
        begin_burst();
 
        serv_printf("MSG2 %ld|1", msgnum);
@@ -485,14 +472,10 @@ void display_headers(void) {
  */
 int load_msg_ptrs(const char *servcmd,
                  const char *filter,
-                 StrBuf *FoundCharset,
-                 SharedMessageStatus *Stat, 
+                 StrBuf * FoundCharset,
+                 SharedMessageStatus * Stat,
                  void **ViewSpecific,
-                 load_msg_ptrs_detailheaders LH,
-                 StrBuf *FetchMessageList,
-                 eMessageField *MessageFieldList,
-                 long HeaderCount)
-{
+                 load_msg_ptrs_detailheaders LH, StrBuf * FetchMessageList, eMessageField * MessageFieldList, long HeaderCount) {
        message_summary *Msg;
        StrBuf *Buf, *Buf2;
        long len;
@@ -508,7 +491,7 @@ int load_msg_ptrs(const char *servcmd,
                DeleteHash(&WC->summ);
        }
        WC->summ = NewHash(1, Flathash);
-       
+
        Buf = NewStrBuf();
        serv_puts(servcmd);
        StrBuf_ServGetln(Buf);
@@ -519,7 +502,7 @@ int load_msg_ptrs(const char *servcmd,
        case 8:
                if (filter != NULL) {
                        serv_puts(filter);
-                        serv_puts("000");
+                       serv_puts("000");
                        break;
                }
                else if (FetchMessageList != NULL) {
@@ -535,11 +518,11 @@ int load_msg_ptrs(const char *servcmd,
                return (Stat->nummsgs);
        }
        Buf2 = NewStrBuf();
-       while (len = StrBuf_ServGetln(Buf), ((len >= 0) && ((len != 3) || strcmp(ChrPtr(Buf), "000")!= 0))) {
+       while (len = StrBuf_ServGetln(Buf), ((len >= 0) && ((len != 3) || strcmp(ChrPtr(Buf), "000") != 0))) {
                if (Stat->nummsgs < Stat->maxload) {
                        skipit = 0;
                        Ptr = NULL;
-                       Msg = (message_summary*)malloc(sizeof(message_summary));
+                       Msg = (message_summary *) malloc(sizeof(message_summary));
                        if (!Msg) {
                                syslog(LOG_DEBUG, "malloc() error");
                        }
@@ -577,17 +560,17 @@ int load_msg_ptrs(const char *servcmd,
                         */
                        if (Msg->date == 0) {
                                Msg->date = Stat->nummsgs;
-                               if (StrLength(Buf) < 32) 
+                               if (StrLength(Buf) < 32)
                                        skipit = 1;
                        }
                        if ((!skipit) && (LH != NULL)) {
-                               if (!LH(Buf, &Ptr, Msg, Buf2, ViewSpecific)){
+                               if (!LH(Buf, &Ptr, Msg, Buf2, ViewSpecific)) {
                                        free(Msg);
                                        continue;
-                               }                                       
+                               }
                        }
                        n = Msg->msgnum;
-                       Put(WC->summ, (const char *)&n, sizeof(n), Msg, DestroyMessageSummary);
+                       Put(WC->summ, (const char *) &n, sizeof(n), Msg, DestroyMessageSummary);
                }
                Stat->nummsgs++;
        }
@@ -603,7 +586,7 @@ int load_msg_ptrs(const char *servcmd,
  * MatchMSet:   MSet we want to flag
  * FlagToSet:   Flag to set on each BasicMsgStruct->Flags if in MSet
  */
-long SetFlagsFromMSet(HashList *ScanMe, MSet *MatchMSet, int FlagToSet, int Reverse) {
+long SetFlagsFromMSet(HashList * ScanMe, MSet * MatchMSet, int FlagToSet, int Reverse) {
        const char *HashKey;
        long HKLen;
        long count = 0;
@@ -614,7 +597,7 @@ long SetFlagsFromMSet(HashList *ScanMe, MSet *MatchMSet, int FlagToSet, int Reve
        at = GetNewHashPos(ScanMe, 0);
        while (GetNextHashPos(ScanMe, at, &HKLen, &HashKey, &vMsg)) {
                /* Are you a new message, or an old message? */
-               Msg = (message_summary*) vMsg;
+               Msg = (message_summary *) vMsg;
                if (Reverse && IsInMSetList(MatchMSet, Msg->msgnum)) {
                        Msg->Flags = Msg->Flags | FlagToSet;
                        count++;
@@ -645,8 +628,7 @@ long load_seen_flags(void) {
                return 0;
        }
 
-       if (ParseMSet(&MatchMSet, OldMsg))
-       {
+       if (ParseMSet(&MatchMSet, OldMsg)) {
                count = SetFlagsFromMSet(WC->summ, MatchMSet, MSGFLAG_READ, 0);
        }
        DeleteMSet(&MatchMSet);
@@ -656,11 +638,11 @@ long load_seen_flags(void) {
 
 extern readloop_struct rlid[];
 
-typedef struct _RoomRenderer{
+typedef struct _RoomRenderer {
        int RoomType;
 
        GetParamsGetServerCall_func GetParamsGetServerCall;
-       
+
        PrintViewHeader_func PrintPageHeader;
        PrintViewHeader_func PrintViewHeader;
        LoadMsgFromServer_func LoadMsgFromServer;
@@ -707,41 +689,36 @@ void readloop(long oper, eCustomRoomRenderer ForceRenderer) {
        Stat.highest_found = (-1);
        if (ForceRenderer == eUseDefault)
                GetHash(ReadLoopHandler, IKEY(WC->CurRoom.view), &vViewMsg);
-       else 
+       else
                GetHash(ReadLoopHandler, IKEY(ForceRenderer), &vViewMsg);
        if (vViewMsg == NULL) {
                WC->CurRoom.view = VIEW_BBS;
                GetHash(ReadLoopHandler, IKEY(WC->CurRoom.view), &vViewMsg);
        }
        if (vViewMsg == NULL) {
-               return;                 /* TODO: print message */
+               return;         /* TODO: print message */
        }
 
-       ViewMsg = (RoomRenderer*) vViewMsg;
+       ViewMsg = (RoomRenderer *) vViewMsg;
        if (ViewMsg->PrintPageHeader == NULL)
                output_headers(1, 1, 1, 0, 0, 0);
-       else 
+       else
                ViewMsg->PrintPageHeader(&Stat, ViewSpecific);
 
        if (ViewMsg->GetParamsGetServerCall != NULL) {
-               r = ViewMsg->GetParamsGetServerCall(
-                      &Stat,
-                      &ViewSpecific,
-                      oper,
-                      cmd, sizeof(cmd),
-                      filter, sizeof(filter)
-               );
-       } else {
+               r = ViewMsg->GetParamsGetServerCall(&Stat, &ViewSpecific, oper, cmd, sizeof(cmd), filter, sizeof(filter)
+                   );
+       }
+       else {
                r = 0;
        }
 
-       switch(r)
-       {
+       switch (r) {
        case 400:
        case 404:
 
                return;
-       case 300: /* the callback hook should do the work for us here, since he knows what to do. */
+       case 300:               /* the callback hook should do the work for us here, since he knows what to do. */
                return;
        case 200:
        default:
@@ -760,9 +737,7 @@ void readloop(long oper, eCustomRoomRenderer ForceRenderer) {
                                             &Stat,
                                             &ViewSpecific,
                                             ViewMsg->LHParse,
-                                            ViewMsg->FetchMessageList,
-                                            ViewMsg->MessageFieldList,
-                                            ViewMsg->HeaderCount);
+                                            ViewMsg->FetchMessageList, ViewMsg->MessageFieldList, ViewMsg->HeaderCount);
                FreeStrBuf(&FoundCharset);
        }
 
@@ -770,44 +745,42 @@ void readloop(long oper, eCustomRoomRenderer ForceRenderer) {
                CompareFunc SortIt;
                StackContext(NULL, &SubTP, NULL, CTX_MAILSUM, 0, NULL);
                {
-                       SortIt =  RetrieveSort(&SubTP,
-                                              NULL, 0,
-                                              HKEY("date"),
-                                              Stat.defaultsortorder);
+                       SortIt = RetrieveSort(&SubTP, NULL, 0, HKEY("date"), Stat.defaultsortorder);
                }
                UnStackContext(&SubTP);
                if (SortIt != NULL)
                        SortByPayload(WC->summ, SortIt);
        }
        if (Stat.startmsg < 0) {
-               Stat.startmsg =  0;
+               Stat.startmsg = 0;
        }
 
-       if (Stat.load_seen) Stat.numNewmsgs = load_seen_flags();
-       
-        /*
+       if (Stat.load_seen)
+               Stat.numNewmsgs = load_seen_flags();
+
+       /*
         * Print any inforation above the message list...
         */
        if (ViewMsg->PrintViewHeader != NULL)
                ViewMsg->PrintViewHeader(&Stat, &ViewSpecific);
 
-       WC->startmsg =  Stat.startmsg;
+       WC->startmsg = Stat.startmsg;
        WC->maxmsgs = Stat.maxmsgs;
        WC->num_displayed = 0;
 
        /* Put some helpful data in vars for mailsummary_json */
        {
                StrBuf *Foo;
-               
-               Foo = NewStrBuf ();
+
+               Foo = NewStrBuf();
                StrBufPrintf(Foo, "%ld", Stat.nummsgs);
-               PutBstr(HKEY("__READLOOP:TOTALMSGS"), NewStrBufDup(Foo)); /* keep Foo! */
+               PutBstr(HKEY("__READLOOP:TOTALMSGS"), NewStrBufDup(Foo));       /* keep Foo! */
 
                StrBufPrintf(Foo, "%ld", Stat.numNewmsgs);
-               PutBstr(HKEY("__READLOOP:NEWMSGS"), NewStrBufDup(Foo)); /* keep Foo! */
+               PutBstr(HKEY("__READLOOP:NEWMSGS"), NewStrBufDup(Foo)); /* keep Foo! */
 
                StrBufPrintf(Foo, "%ld", Stat.startmsg);
-               PutBstr(HKEY("__READLOOP:STARTMSG"), Foo); /* store Foo elsewhere, descope it here. */
+               PutBstr(HKEY("__READLOOP:STARTMSG"), Foo);      /* store Foo elsewhere, descope it here. */
        }
 
        /*
@@ -817,15 +790,11 @@ void readloop(long oper, eCustomRoomRenderer ForceRenderer) {
        if ((ViewMsg->LoadMsgFromServer != NULL) && (!IsEmptyStr(cmd))) {
                at = GetNewHashPos(WC->summ, 0);
                Stat.num_displayed = i = 0;
-               while ( GetNextHashPos(WC->summ, at, &HKLen, &HashKey, &vMsg)) {
-                       Msg = (message_summary*) vMsg;          
+               while (GetNextHashPos(WC->summ, at, &HKLen, &HashKey, &vMsg)) {
+                       Msg = (message_summary *) vMsg;
                        if ((Msg->msgnum >= Stat.startmsg) && (Stat.num_displayed <= Stat.maxmsgs)) {
-                               ViewMsg->LoadMsgFromServer(&Stat, 
-                                                          &ViewSpecific, 
-                                                          Msg, 
-                                                          (Msg->Flags & MSGFLAG_READ) != 0, 
-                                                          i);
-                       } 
+                               ViewMsg->LoadMsgFromServer(&Stat, &ViewSpecific, Msg, (Msg->Flags & MSGFLAG_READ) != 0, i);
+                       }
                        i++;
                }
                DeleteHashPos(&at);
@@ -862,16 +831,8 @@ void post_mime_to_server(void) {
        char *txtmail = NULL;
        int include_text_alt = 0;       /* Set to nonzero to include multipart/alternative text/plain */
 
-       sprintf(top_boundary, "Citadel--Multipart--%s--%04x--%04x",
-               ChrPtr(WC->serv_info->serv_fqdn),
-               getpid(),
-               ++seq
-       );
-       sprintf(alt_boundary, "Citadel--Multipart--%s--%04x--%04x",
-               ChrPtr(WC->serv_info->serv_fqdn),
-               getpid(),
-               ++seq
-       );
+       sprintf(top_boundary, "Citadel--Multipart--%s--%04x--%04x", ChrPtr(WC->serv_info->serv_fqdn), getpid(), ++seq);
+       sprintf(alt_boundary, "Citadel--Multipart--%s--%04x--%04x", ChrPtr(WC->serv_info->serv_fqdn), getpid(), ++seq);
 
        /* RFC2045 requires this, and some clients look for it... */
        serv_puts("MIME-Version: 1.0");
@@ -907,9 +868,9 @@ void post_mime_to_server(void) {
                serv_puts("");
                txtmail = html_to_ascii(bstr("msgtext"), 0, 80);
                Buf = NewStrBufPlain(txtmail, -1);
-               free(txtmail);
+               free(txtmail);
 
-               text_to_server_qp(Buf);     /* Transmit message in quoted-printable encoding */
+               text_to_server_qp(Buf); /* Transmit message in quoted-printable encoding */
                FreeStrBuf(&Buf);
                serv_printf("\n--%s", alt_boundary);
        }
@@ -924,17 +885,17 @@ void post_mime_to_server(void) {
        if (include_text_alt) {
                serv_printf("--%s--", alt_boundary);
        }
-       
+
        if (is_multipart) {
                long len;
-               const char *Key; 
+               const char *Key;
                void *vAtt;
-               HashPos  *it;
+               HashPos *it;
 
                /* Add in the attachments */
                it = GetNewHashPos(WC->attachments, 0);
                while (GetNextHashPos(WC->attachments, it, &len, &Key, &vAtt)) {
-                       att = (wc_mime_attachment *)vAtt;
+                       att = (wc_mime_attachment *) vAtt;
                        if (att->length == 0)
                                continue;
 
@@ -987,7 +948,7 @@ void post_message(void) {
        int is_anonymous = 0;
        const StrBuf *display_name = NULL;
        StrBuf *Buf;
-       
+
        if (havebstr("force_room")) {
                gotoroom(sbstr("force_room"));
        }
@@ -1002,13 +963,13 @@ void post_message(void) {
 
        if (!strcasecmp(bstr("submit_action"), "cancel")) {
                AppendImportantMessage(_("Cancelled.  Message was not posted."), -1);
-       } else if (lbstr("postseq") == dont_post) {
-               AppendImportantMessage(
-                       _("Automatically cancelled because you have already "
-                         "saved this message."), -1);
-       else {
+       }
+       else if (lbstr("postseq") == dont_post) {
+               AppendImportantMessage(_("Automatically cancelled because you have already " "saved this message."), -1);
+       }
+       else {
                const char CMD[] = "ENT0 1|%s|%d|4|%s|%s||%s|%s|%s|%s|%s";
-               StrBuf *Recp = NULL; 
+               StrBuf *Recp = NULL;
                StrBuf *Cc = NULL;
                StrBuf *Bcc = NULL;
                StrBuf *wikipage = NULL;
@@ -1022,8 +983,8 @@ void post_message(void) {
                Buf = NewStrBuf();
 
                if (saving_to_drafts) {
-                       /* temporarily change to the drafts room */
-                       serv_puts("GOTO _DRAFTS_");
+                       /* temporarily change to the drafts room */
+                       serv_puts("GOTO _DRAFTS_");
                        StrBuf_ServGetln(Buf);
                        if (GetServerStatusMsg(Buf, NULL, 1, 2) != 2) {
                                /* You probably don't even have a dumb Drafts folder */
@@ -1035,8 +996,7 @@ void post_message(void) {
                        }
                }
 
-               if (havebstr("references"))
-               {
+               if (havebstr("references")) {
                        const StrBuf *ref = sbstr("references");
                        references = NewStrBufDup(ref);
                        if (*ChrPtr(references) == '|') {       /* remove leading '|' if present */
@@ -1051,7 +1011,7 @@ void post_message(void) {
                         * plus the QP header 
                         */
                        Subj = sbstr("subject");
-                       
+
                        StrBufRFC2047encode(&encoded_subject, Subj);
                }
                UserName = NewStrBuf();
@@ -1069,38 +1029,29 @@ void post_message(void) {
                wikipage = NewStrBufDup(sbstr("page"));
                str_wiki_index(wikipage);
                my_email_addr = sbstr("my_email_addr");
-               
-               HeaderLen = StrLength(Recp) + 
-                       StrLength(encoded_subject) +
-                       StrLength(Cc) +
-                       StrLength(Bcc) + 
-                       StrLength(wikipage) +
-                       StrLength(my_email_addr) + 
-                       StrLength(references);
-               CmdBuf = NewStrBufPlain(NULL, sizeof (CMD) + HeaderLen);
-               StrBufPrintf(CmdBuf, 
+
+               HeaderLen = StrLength(Recp) +
+                   StrLength(encoded_subject) +
+                   StrLength(Cc) + StrLength(Bcc) + StrLength(wikipage) + StrLength(my_email_addr) + StrLength(references);
+               CmdBuf = NewStrBufPlain(NULL, sizeof(CMD) + HeaderLen);
+               StrBufPrintf(CmdBuf,
                             CMD,
-                            saving_to_drafts?"":ChrPtr(Recp),
+                            saving_to_drafts ? "" : ChrPtr(Recp),
                             is_anonymous,
                             ChrPtr(encoded_subject),
                             ChrPtr(display_name),
-                            saving_to_drafts?"":ChrPtr(Cc),
-                            saving_to_drafts?"":ChrPtr(Bcc),
-                            ChrPtr(wikipage),
-                            ChrPtr(my_email_addr),
-                            ChrPtr(references));
+                            saving_to_drafts ? "" : ChrPtr(Cc),
+                            saving_to_drafts ? "" : ChrPtr(Bcc), ChrPtr(wikipage), ChrPtr(my_email_addr), ChrPtr(references));
                FreeStrBuf(&references);
                FreeStrBuf(&encoded_subject);
                free(wikipage);
 
-               if ((HeaderLen + StrLength(sbstr("msgtext")) < 10) && 
-                   (GetCount(WC->attachments) == 0)){
+               if ((HeaderLen + StrLength(sbstr("msgtext")) < 10) && (GetCount(WC->attachments) == 0)) {
                        AppendImportantMessage(_("Refusing to post empty message.\n"), -1);
                        FreeStrBuf(&CmdBuf);
-                               
+
                }
-               else 
-               {
+               else {
                        syslog(LOG_DEBUG, "%s\n", ChrPtr(CmdBuf));
                        serv_puts(ChrPtr(CmdBuf));
                        FreeStrBuf(&CmdBuf);
@@ -1108,14 +1059,15 @@ void post_message(void) {
                        StrBuf_ServGetln(Buf);
                        if (GetServerStatus(Buf, NULL) == 4) {
                                if (saving_to_drafts) {
-                                       if (  (havebstr("recp"))
-                                             || (havebstr("cc"  ))
-                                             || (havebstr("bcc" )) ) {
+                                       if ((havebstr("recp"))
+                                           || (havebstr("cc"))
+                                           || (havebstr("bcc"))) {
                                                /* save recipient headers or room to post to */
                                                serv_printf("To: %s", ChrPtr(Recp));
                                                serv_printf("Cc: %s", ChrPtr(Cc));
                                                serv_printf("Bcc: %s", ChrPtr(Bcc));
-                                       } else {
+                                       }
+                                       else {
                                                serv_printf("X-Citadel-Room: %s", ChrPtr(WC->CurRoom.name));
                                        }
                                }
@@ -1127,21 +1079,24 @@ void post_message(void) {
                                        readloop(readnew, eUseDefault);
                                        FreeStrBuf(&Buf);
                                        return;
-                               } else if (  (havebstr("recp"))
-                                            || (havebstr("cc"  ))
-                                            || (havebstr("bcc" ))
-                                       ) {
+                               }
+                               else if ((havebstr("recp"))
+                                        || (havebstr("cc"))
+                                        || (havebstr("bcc"))
+                                   ) {
                                        AppendImportantMessage(_("Message has been sent.\n"), -1);
                                }
                                else {
                                        AppendImportantMessage(_("Message has been posted.\n"), -1);
                                }
                                dont_post = lbstr("postseq");
-                       } else {
+                       }
+                       else {
                                syslog(LOG_DEBUG, "%s:%d: server post error: %s", __FILE__, __LINE__, ChrPtr(Buf) + 4);
                                AppendImportantMessage(ChrPtr(Buf) + 4, StrLength(Buf) - 4);
                                display_enter();
-                               if (saving_to_drafts) gotoroom(WC->CurRoom.name);
+                               if (saving_to_drafts)
+                                       gotoroom(WC->CurRoom.name);
                                FreeStrBuf(&Recp);
                                FreeStrBuf(&Buf);
                                FreeStrBuf(&Cc);
@@ -1223,11 +1178,11 @@ void upload_attachment(void) {
                wc_printf("Client is uploading %d bytes<br>\n", WC->upload_length);
        }
 
-       att = (wc_mime_attachment*)malloc(sizeof(wc_mime_attachment));
+       att = (wc_mime_attachment *) malloc(sizeof(wc_mime_attachment));
        if (!att) {
                syslog(LOG_DEBUG, "malloc() error");
        }
-       memset(att, 0, sizeof(wc_mime_attachment ));
+       memset(att, 0, sizeof(wc_mime_attachment));
        att->length = WC->upload_length;
        att->ContentType = NewStrBufPlain(WC->upload_content_type, -1);
        att->FileName = NewStrBufDup(WC->upload_filename);
@@ -1247,8 +1202,8 @@ void upload_attachment(void) {
 
        /* And add it to the list. */
        n = 0;
-       if ((GetCount(WC->attachments) > 0) && GetHashAt(WC->attachments, GetCount(WC->attachments) -1, &newnlen, &newn, &v)) {
-               n = *((int*) newn) + 1;
+       if ((GetCount(WC->attachments) > 0) && GetHashAt(WC->attachments, GetCount(WC->attachments) - 1, &newnlen, &newn, &v)) {
+               n = *((int *) newn) + 1;
        }
        Put(WC->attachments, IKEY(n), att, DestroyMime);
 
@@ -1273,8 +1228,9 @@ void upload_attachment(void) {
        att->Data = WC->upload;
        WC->upload = NULL;
        WC->upload_length = 0;
-       
-       if (Tmpl) MimeType = DoTemplate(SKEY(Tmpl), NULL, &NoCtx);
+
+       if (Tmpl)
+               MimeType = DoTemplate(SKEY(Tmpl), NULL, &NoCtx);
        http_transmit_thing(ChrPtr(MimeType), 0);
 }
 
@@ -1291,7 +1247,7 @@ void remove_attachment(void) {
        StrBuf *WhichAttachment;
        HashPos *at;
        long len;
-       int found=0;
+       int found = 0;
        const char *key;
 
        WhichAttachment = NewStrBufDup(sbstr("which_attachment"));
@@ -1303,16 +1259,13 @@ void remove_attachment(void) {
                vAtt = NULL;
                GetHashPos(WC->attachments, at, &len, &key, &vAtt);
 
-               att = (wc_mime_attachment*) vAtt;
+               att = (wc_mime_attachment *) vAtt;
                if ((att != NULL) &&
-                   (
-                           !strcmp(ChrPtr(WhichAttachment), ChrPtr(att->FileName)) ||
-                   ((att->PartNum != NULL) &&
-                    !strcmp(ChrPtr(WhichAttachment), ChrPtr(att->PartNum)))
-                           ))
-               {
+                   (!strcmp(ChrPtr(WhichAttachment), ChrPtr(att->FileName)) ||
+                    ((att->PartNum != NULL) && !strcmp(ChrPtr(WhichAttachment), ChrPtr(att->PartNum)))
+                   )) {
                        DeleteEntryFromHash(WC->attachments, at);
-                       found=1;
+                       found = 1;
                        break;
                }
        }
@@ -1323,16 +1276,17 @@ void remove_attachment(void) {
 }
 
 
-const char *ReplyToModeStrings [3] = {
+const char *ReplyToModeStrings[3] = {
        "reply",
        "replyall",
        "forward"
 };
+
 typedef enum _eReplyToNodes {
        eReply,
        eReplyAll,
        eForward
-}eReplyToNodes;
+} eReplyToNodes;
 
 
 /*
@@ -1369,10 +1323,10 @@ void display_enter(void) {
        StrBuf_ServGetln(Line);
        rc = GetServerStatusMsg(Line, &Result, 0, 2);
 
-       if (Result == 570) {            /* 570 means that we need a recipient here */
+       if (Result == 570) {    /* 570 means that we need a recipient here */
                recipient_required = 1;
        }
-       else if (rc != 2) {             /* Any other error means that we cannot continue */
+       else if (rc != 2) {     /* Any other error means that we cannot continue */
                rc = GetServerStatusMsg(Line, &Result, 0, 2);
                fixview();
                readloop(readnew, eUseDefault);
@@ -1390,7 +1344,7 @@ void display_enter(void) {
         * message" command really means "add new entry."
         */
        if (WC->CurRoom.defview == VIEW_ADDRESSBOOK) {
-               do_edit_vcard(-1, "", NULL, NULL, "",  ChrPtr(WC->CurRoom.name));
+               do_edit_vcard(-1, "", NULL, NULL, "", ChrPtr(WC->CurRoom.name));
                FreeStrBuf(&Line);
                return;
        }
@@ -1440,77 +1394,76 @@ void display_enter(void) {
                StrBuf *replyto = NULL;
                StrBuf *nvto = NULL;
                int message_originated_locally = 0;
-               serv_printf("MSG0 %ld|1", replying_to); 
+               serv_printf("MSG0 %ld|1", replying_to);
 
                StrBuf_ServGetln(Line);
                if (GetServerStatusMsg(Line, NULL, 0, 0) == 1)
                        while (len = StrBuf_ServGetln(Line), (len >= 0) && ((len != 3) || strcmp(ChrPtr(Line), "000"))) {
                                eMessageField which;
-                               if ((StrLength(Line) > 4) && (ChrPtr(Line)[4] == '=') && GetFieldFromMnemonic(&which, ChrPtr(Line))) switch (which) {
-                                       case eMsgSubject: {
-                                               StrBuf *subj = NewStrBuf();
-                                               StrBuf *FlatSubject;
-
-                                               if (ReplyMode == eForward) {
-                                                       if (strncasecmp(ChrPtr(Line) + 5, "Fw:", 3)) {
-                                                               StrBufAppendBufPlain(subj, HKEY("Fw: "), 0);
+                               if ((StrLength(Line) > 4) && (ChrPtr(Line)[4] == '=') && GetFieldFromMnemonic(&which, ChrPtr(Line)))
+                                       switch (which) {
+                                       case eMsgSubject:{
+                                                       StrBuf *subj = NewStrBuf();
+                                                       StrBuf *FlatSubject;
+
+                                                       if (ReplyMode == eForward) {
+                                                               if (strncasecmp(ChrPtr(Line) + 5, "Fw:", 3)) {
+                                                                       StrBufAppendBufPlain(subj, HKEY("Fw: "), 0);
+                                                               }
                                                        }
-                                               }
-                                               else {
-                                                       if (strncasecmp(ChrPtr(Line) + 5, "Re:", 3)) {
-                                                               StrBufAppendBufPlain(subj, HKEY("Re: "), 0);
+                                                       else {
+                                                               if (strncasecmp(ChrPtr(Line) + 5, "Re:", 3)) {
+                                                                       StrBufAppendBufPlain(subj, HKEY("Re: "), 0);
+                                                               }
                                                        }
-                                               }
-                                               StrBufAppendBufPlain(subj, 
-                                                                    ChrPtr(Line) + 5, 
-                                                                    StrLength(Line) - 5, 0);
-                                               FlatSubject = NewStrBufPlain(NULL, StrLength(subj));
-                                               StrBuf_RFC822_to_Utf8(FlatSubject, subj, NULL, NULL);
+                                                       StrBufAppendBufPlain(subj, ChrPtr(Line) + 5, StrLength(Line) - 5, 0);
+                                                       FlatSubject = NewStrBufPlain(NULL, StrLength(subj));
+                                                       StrBuf_RFC822_to_Utf8(FlatSubject, subj, NULL, NULL);
 
-                                               PutBstr(HKEY("subject"), FlatSubject);
-                                       }
+                                                       PutBstr(HKEY("subject"), FlatSubject);
+                                               }
                                                break;
 
-                                       case eIsLocal: {
-                                               message_originated_locally = 1;
-                                               break;
-                                       }
+                                       case eIsLocal:{
+                                                       message_originated_locally = 1;
+                                                       break;
+                                               }
 
                                        case eWeferences:
-                                       {
-                                               int rrtok;
-                                               int rrlen;
-
-                                               wefw = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
-                                       
-                                               /* Trim down excessively long lists of thread references.  We eliminate the
-                                                * second one in the list so that the thread root remains intact.
-                                                */
-                                               rrtok = num_tokens(ChrPtr(wefw), '|');
-                                               rrlen = StrLength(wefw);
-                                               if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
-                                                       StrBufRemove_token(wefw, 1, '|');
+                                               {
+                                                       int rrtok;
+                                                       int rrlen;
+
+                                                       wefw = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+
+                                                       /* Trim down excessively long lists of thread references.  We eliminate the
+                                                        * second one in the list so that the thread root remains intact.
+                                                        */
+                                                       rrtok = num_tokens(ChrPtr(wefw), '|');
+                                                       rrlen = StrLength(wefw);
+                                                       if (((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10)) {
+                                                               StrBufRemove_token(wefw, 1, '|');
+                                                       }
+                                                       break;
                                                }
-                                               break;
-                                       }
 
                                        case emessageId:
                                                msgn = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
                                                break;
 
-                                       case eAuthor: {
-                                               StrBuf *FlatFrom;
-                                               from = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
-                                               FlatFrom = NewStrBufPlain(NULL, StrLength(from));
-                                               StrBuf_RFC822_to_Utf8(FlatFrom, from, NULL, NULL);
-                                               FreeStrBuf(&from);
-                                               from = FlatFrom;
-                                               for (i=0; i<StrLength(from); ++i) {
-                                                       if (ChrPtr(from)[i] == ',')
-                                                               StrBufPeek(from, NULL, i, ' ');
+                                       case eAuthor:{
+                                                       StrBuf *FlatFrom;
+                                                       from = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+                                                       FlatFrom = NewStrBufPlain(NULL, StrLength(from));
+                                                       StrBuf_RFC822_to_Utf8(FlatFrom, from, NULL, NULL);
+                                                       FreeStrBuf(&from);
+                                                       from = FlatFrom;
+                                                       for (i = 0; i < StrLength(from); ++i) {
+                                                               if (ChrPtr(from)[i] == ',')
+                                                                       StrBufPeek(from, NULL, i, ' ');
+                                                       }
+                                                       break;
                                                }
-                                               break;
-                                       }
                                        case eRecipient:
                                                rcpt = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
                                                break;
@@ -1520,15 +1473,15 @@ void display_enter(void) {
                                        case eReplyTo:
                                                replyto = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
                                                break;
-                                       case erFc822Addr: {
-                                               StrBuf *FlatRFCA;
-                                               rfca = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
-                                               FlatRFCA = NewStrBufPlain(NULL, StrLength(rfca));
-                                               StrBuf_RFC822_to_Utf8(FlatRFCA, rfca, NULL, NULL);
-                                               FreeStrBuf(&rfca);
-                                               rfca = FlatRFCA;
-                                               break;
-                                       }
+                                       case erFc822Addr:{
+                                                       StrBuf *FlatRFCA;
+                                                       rfca = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+                                                       FlatRFCA = NewStrBufPlain(NULL, StrLength(rfca));
+                                                       StrBuf_RFC822_to_Utf8(FlatRFCA, rfca, NULL, NULL);
+                                                       FreeStrBuf(&rfca);
+                                                       rfca = FlatRFCA;
+                                                       break;
+                                               }
                                        case eenVelopeTo:
                                                nvto = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
                                                putbstr("nvto", nvto);
@@ -1556,9 +1509,7 @@ void display_enter(void) {
                        if (StrLength(wefw) > 0) {
                                StrBufAppendBuf(refs, wefw, 0);
                        }
-                       if ( (StrLength(wefw) > 0) && 
-                            (StrLength(msgn) > 0) ) 
-                       {
+                       if ((StrLength(wefw) > 0) && (StrLength(msgn) > 0)) {
                                StrBufAppendBufPlain(refs, HKEY("|"), 0);
                        }
                        if (StrLength(msgn) > 0) {
@@ -1578,7 +1529,7 @@ void display_enter(void) {
                                StrBufAppendBuf(to_rcpt, replyto, 0);
                        }
 
-                       else if ( (StrLength(rfca) > 0) && (message_originated_locally == 0) ) {
+                       else if ((StrLength(rfca) > 0) && (message_originated_locally == 0)) {
                                to_rcpt = NewStrBuf();
                                StrBufAppendBuf(to_rcpt, from, 0);
                                StrBufAppendBufPlain(to_rcpt, HKEY(" <"), 0);
@@ -1587,7 +1538,7 @@ void display_enter(void) {
                        }
 
                        else {
-                               to_rcpt =  from;
+                               to_rcpt = from;
                                from = NULL;
                        }
                        PutBstr(HKEY("recp"), to_rcpt);
@@ -1600,7 +1551,7 @@ void display_enter(void) {
                        StrBuf *cc_rcpt = rcpt;
                        rcpt = NULL;
                        if ((StrLength(cccc) > 0) && (StrLength(replyto) == 0)) {
-                               if (cc_rcpt != NULL)  {
+                               if (cc_rcpt != NULL) {
                                        StrBufAppendPrintf(cc_rcpt, ", ");
                                        StrBufAppendBuf(cc_rcpt, cccc, 0);
                                }
@@ -1623,7 +1574,7 @@ void display_enter(void) {
                syslog(LOG_DEBUG, "cccc = %s", ChrPtr(cccc));
                syslog(LOG_DEBUG, "replyto = %s", ChrPtr(replyto));
                syslog(LOG_DEBUG, "nvto = %s", ChrPtr(nvto));
-               syslog(LOG_DEBUG, "local = %d" , message_originated_locally);
+               syslog(LOG_DEBUG, "local = %d", message_originated_locally);
 
                FreeStrBuf(&wefw);
                FreeStrBuf(&msgn);
@@ -1639,45 +1590,36 @@ void display_enter(void) {
         * Do a custom room banner with no navbar...
         */
        if (recipient_required) {
-               const StrBuf *Recp = NULL; 
+               const StrBuf *Recp = NULL;
                const StrBuf *Cc = NULL;
                const StrBuf *Bcc = NULL;
                StrBuf *wikipage = NULL;
                StrBuf *CmdBuf = NULL;
                const char CMD[] = "ENT0 0|%s|%d|0||%s||%s|%s|%s";
-               
+
                Recp = sbstr("recp");
                Cc = sbstr("cc");
                Bcc = sbstr("bcc");
                wikipage = NewStrBufDup(sbstr("page"));
                str_wiki_index(wikipage);
-               
-               CmdBuf = NewStrBufPlain(NULL, 
-                                       sizeof (CMD) + 
-                                       StrLength(Recp) + 
-                                       StrLength(display_name) +
-                                       StrLength(Cc) +
-                                       StrLength(Bcc) + 
-                                       StrLength(wikipage));
-
-               StrBufPrintf(CmdBuf, 
-                            CMD,
-                            ChrPtr(Recp), 
-                            is_anonymous,
-                            ChrPtr(display_name),
-                            ChrPtr(Cc), 
-                            ChrPtr(Bcc), 
-                            ChrPtr(wikipage)
-               );
+
+               CmdBuf = NewStrBufPlain(NULL,
+                                       sizeof(CMD) +
+                                       StrLength(Recp) +
+                                       StrLength(display_name) + StrLength(Cc) + StrLength(Bcc) + StrLength(wikipage));
+
+               StrBufPrintf(CmdBuf,
+                            CMD, ChrPtr(Recp), is_anonymous, ChrPtr(display_name), ChrPtr(Cc), ChrPtr(Bcc), ChrPtr(wikipage)
+                   );
                serv_puts(ChrPtr(CmdBuf));
                StrBuf_ServGetln(CmdBuf);
                free(wikipage);
 
                rc = GetServerStatusMsg(CmdBuf, &Result, 0, 0);
 
-               if (    (Result == 570)         /* invalid or missing recipient(s) */
-                       || (Result == 550)      /* higher access required to send Internet mail */
-               ) {
+               if ((Result == 570)     /* invalid or missing recipient(s) */
+                   ||(Result == 550)   /* higher access required to send Internet mail */
+                   ) {
                        /* These errors will have been displayed and are excusable */
                }
                else if (rc != 2) {     /* Any other error means that we cannot continue */
@@ -1709,11 +1651,11 @@ void display_enter(void) {
 void delete_msg(void) {
        long msgid;
        StrBuf *Line;
-       
+
        msgid = lbstr("msgid");
        Line = NewStrBuf();
        if ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0) {  /* Delete from Trash is a real delete */
-               serv_printf("DELE %ld", msgid); 
+               serv_printf("DELE %ld", msgid);
        }
        else {                  /* Otherwise move it to Trash */
                serv_printf("MOVE %ld|_TRASH_|0", msgid);
@@ -1743,7 +1685,8 @@ void move_msg(void) {
                StrBuf_ServGetln(Line);
                GetServerStatusMsg(Line, NULL, 1, 0);
                FreeStrBuf(&Line);
-       } else {
+       }
+       else {
                AppendImportantMessage(_("The message was not moved."), -1);
        }
 
@@ -1760,16 +1703,15 @@ void move_msg(void) {
  * filename            Fake filename to give
  * force_download      Nonzero to force set the Content-Type: header to "application/octet-stream"
  */
-void postpart(StrBuf *partnum, StrBuf *filename, int force_download) {
+void postpart(StrBuf * partnum, StrBuf * filename, int force_download) {
        void *vPart;
        StrBuf *content_type;
        wc_mime_attachment *part;
        int i;
 
        i = StrToi(partnum);
-       if (GetHash(WC->attachments, IKEY(i), &vPart) &&
-           (vPart != NULL)) {
-               part = (wc_mime_attachment*) vPart;
+       if (GetHash(WC->attachments, IKEY(i), &vPart) && (vPart != NULL)) {
+               part = (wc_mime_attachment *) vPart;
                if (force_download) {
                        content_type = NewStrBufPlain(HKEY("application/octet-stream"));
                }
@@ -1778,13 +1720,13 @@ void postpart(StrBuf *partnum, StrBuf *filename, int force_download) {
                }
                StrBufAppendBuf(WC->WBuf, part->Data, 0);
                http_transmit_thing(ChrPtr(content_type), 0);
-       } else {
+       }
+       else {
                hprintf("HTTP/1.1 404 %s\n", ChrPtr(partnum));
                output_headers(0, 0, 0, 0, 0, 0);
                hprintf("Content-Type: text/plain\r\n");
                begin_burst();
-               wc_printf(_("An error occurred while retrieving this part: %s/%s\n"), 
-                       ChrPtr(partnum), ChrPtr(filename));
+               wc_printf(_("An error occurred while retrieving this part: %s/%s\n"), ChrPtr(partnum), ChrPtr(filename));
                end_burst();
        }
        FreeStrBuf(&content_type);
@@ -1794,9 +1736,9 @@ void postpart(StrBuf *partnum, StrBuf *filename, int force_download) {
 // Generic function to output an arbitrary MIME part from an arbitrary
 // message number on the server.
 //
-// msgnum              message number on the citadel server
-// partnum             MIME part number to be output
-// force_download      Nonzero to force set the Content-Type: header to "application/octet-stream"
+// msgnum               message number on the citadel server
+// partnum              MIME part number to be output
+// force_download       Nonzero to force set the Content-Type: header to "application/octet-stream"
 
 void view_or_download_mimepart(int force_download) {
        long msgnum;
@@ -1818,11 +1760,7 @@ void view_or_download_mimepart(int force_download) {
        if (GetServerStatus(Buf, NULL) != 6) {
                FreeStrBuf(&Buf);
                hprintf("HTTP/1.1 500 error\r\n"
-                       "Pragma: no-cache\r\n"
-                       "Cache-Control: no-store\r\n"
-                       "Expires: -1\r\n"
-                       "Content-Type: text/plain\r\n"
-               );
+                       "Pragma: no-cache\r\n" "Cache-Control: no-store\r\n" "Expires: -1\r\n" "Content-Type: text/plain\r\n");
                begin_burst();
                wc_printf(_("An error occurred while retrieving this part: %s\n"), "--");
                return;
@@ -1856,7 +1794,7 @@ void view_or_download_mimepart(int force_download) {
 StrBuf *load_mimepart(long msgnum, char *partnum) {
        off_t bytes;
        StrBuf *Buf;
-       
+
        Buf = NewStrBuf();
        serv_printf("DLAT %ld|%s", msgnum, partnum);
        StrBuf_ServGetln(Buf);
@@ -1866,11 +1804,11 @@ StrBuf *load_mimepart(long msgnum, char *partnum) {
                FreeStrBuf(&Buf);
                Buf = NewStrBuf();
                StrBuf_ServGetBLOBBuffered(Buf, bytes);
-               return(Buf);
+               return (Buf);
        }
        else {
                FreeStrBuf(&Buf);
-               return(NULL);
+               return (NULL);
        }
 }
 
@@ -1878,7 +1816,7 @@ StrBuf *load_mimepart(long msgnum, char *partnum) {
 /*
  * Read any MIME part of a message, from the server, into memory.
  */
-void MimeLoadData(wc_mime_attachment *Mime) {
+void MimeLoadData(wc_mime_attachment * Mime) {
        StrBuf *Buf;
        const char *Ptr;
        off_t bytes;
@@ -1889,10 +1827,11 @@ void MimeLoadData(wc_mime_attachment *Mime) {
        if (GetServerStatus(Buf, NULL) == 6) {
                Ptr = &(ChrPtr(Buf)[4]);
                bytes = StrBufExtractNext_long(Buf, &Ptr, '|');
-               StrBufSkip_NTokenS(Buf, &Ptr, '|', 3);  /* filename, cbtype, mimetype */
-               if (Mime->Charset == NULL) Mime->Charset = NewStrBuf();
+               StrBufSkip_NTokenS(Buf, &Ptr, '|', 3);  /* filename, cbtype, mimetype */
+               if (Mime->Charset == NULL)
+                       Mime->Charset = NewStrBuf();
                StrBufExtract_NextToken(Mime->Charset, Buf, &Ptr, '|');
-               
+
                if (Mime->Data == NULL) {
                        Mime->Data = NewStrBufPlain(NULL, bytes);
                }
@@ -1948,13 +1887,27 @@ void show_num_attachments(void) {
 }
 
 
-void h_readnew(void) { readloop(readnew, eUseDefault);}
-void h_readold(void) { readloop(readold, eUseDefault);}
-void h_readfwd(void) { readloop(readfwd, eUseDefault);}
-void h_headers(void) { readloop(headers, eUseDefault);}
-void h_do_search(void) { readloop(do_search, eUseDefault);}
-void h_readgt(void) { readloop(readgt, eUseDefault);}
-void h_readlt(void) { readloop(readlt, eUseDefault);}
+void h_readnew(void) {
+       readloop(readnew, eUseDefault);
+}
+void h_readold(void) {
+       readloop(readold, eUseDefault);
+}
+void h_readfwd(void) {
+       readloop(readfwd, eUseDefault);
+}
+void h_headers(void) {
+       readloop(headers, eUseDefault);
+}
+void h_do_search(void) {
+       readloop(do_search, eUseDefault);
+}
+void h_readgt(void) {
+       readloop(readgt, eUseDefault);
+}
+void h_readlt(void) {
+       readloop(readlt, eUseDefault);
+}
 
 
 /* Output message list in JSON format */
@@ -1963,7 +1916,7 @@ void jsonMessageList(void) {
        const StrBuf *room = sbstr("room");
        long oper = (havebstr("query")) ? do_search : readnew;
        StrBufPrintf(View, "%d", VIEW_JSON_LIST);
-       putbstr("view", View);; 
+       putbstr("view", View);;
        gotoroom(room);
        readloop(oper, eUseDefault);
 }
@@ -1979,23 +1932,19 @@ void FreeReadLoopHandlerSet(void *v) {
 }
 
 
-void RegisterReadLoopHandlerset(
-       int RoomType,
-       GetParamsGetServerCall_func GetParamsGetServerCall,
-       PrintViewHeader_func PrintPageHeader,
-       PrintViewHeader_func PrintViewHeader,
-       load_msg_ptrs_detailheaders LH,
-       LoadMsgFromServer_func LoadMsgFromServer,
-       RenderView_or_Tail_func RenderView_or_Tail,
-       View_Cleanup_func ViewCleanup,
-       const char **browseListFields
-       )
-{
+void RegisterReadLoopHandlerset(int RoomType,
+                               GetParamsGetServerCall_func GetParamsGetServerCall,
+                               PrintViewHeader_func PrintPageHeader,
+                               PrintViewHeader_func PrintViewHeader,
+                               load_msg_ptrs_detailheaders LH,
+                               LoadMsgFromServer_func LoadMsgFromServer,
+                               RenderView_or_Tail_func RenderView_or_Tail,
+                               View_Cleanup_func ViewCleanup, const char **browseListFields) {
        long count = 0;
        long i = 0;
        RoomRenderer *Handler;
 
-       Handler = (RoomRenderer*) malloc(sizeof(RoomRenderer));
+       Handler = (RoomRenderer *) malloc(sizeof(RoomRenderer));
 
        Handler->RoomType = RoomType;
        Handler->GetParamsGetServerCall = GetParamsGetServerCall;
@@ -2008,10 +1957,10 @@ void RegisterReadLoopHandlerset(
 
        if (browseListFields != NULL) {
                while (browseListFields[count] != NULL) {
-                       count ++;
+                       count++;
                }
                Handler->HeaderCount = count;
-               Handler->MessageFieldList = (eMessageField*) malloc(sizeof(eMessageField) * count);
+               Handler->MessageFieldList = (eMessageField *) malloc(sizeof(eMessageField) * count);
                Handler->FetchMessageList = NewStrBufPlain(NULL, 5 * count + 4 + 5);
                StrBufPlain(Handler->FetchMessageList, HKEY("time\n"));
                for (i = 0; i < count; i++) {
@@ -2032,61 +1981,44 @@ void RegisterReadLoopHandlerset(
        Put(ReadLoopHandler, IKEY(RoomType), Handler, FreeReadLoopHandlerSet);
 }
 
-void 
-InitModule_MSG
-(void)
-{
-       RegisterPreference("use_sig",
-                          _("Attach signature to email messages?"), 
-                          PRF_YESNO, 
-                          NULL);
+void InitModule_MSG(void) {
+       RegisterPreference("use_sig", _("Attach signature to email messages?"), PRF_YESNO, NULL);
        RegisterPreference("signature", _("Use this signature:"), PRF_QP_STRING, NULL);
-       RegisterPreference("default_header_charset",
-                          _("Default character set for email headers:"), 
-                          PRF_STRING, 
-                          NULL);
+       RegisterPreference("default_header_charset", _("Default character set for email headers:"), PRF_STRING, NULL);
        RegisterPreference("defaultfrom", _("Preferred email address"), PRF_STRING, NULL);
-       RegisterPreference("defaultname", 
-                          _("Preferred display name for email messages"), 
-                          PRF_STRING, 
-                          NULL);
-       RegisterPreference("defaulthandle", 
-                          _("Preferred display name for bulletin board posts"), 
-                          PRF_STRING, 
-                          NULL);
-       RegisterPreference("mailbox",_("Mailbox view mode"), PRF_STRING, NULL);
-
-       WebcitAddUrlHandler(HKEY("readnew"), "", 0, h_readnew, ANONYMOUS|NEED_URL);
-       WebcitAddUrlHandler(HKEY("readold"), "", 0, h_readold, ANONYMOUS|NEED_URL);
-       WebcitAddUrlHandler(HKEY("readfwd"), "", 0, h_readfwd, ANONYMOUS|NEED_URL);
+       RegisterPreference("defaultname", _("Preferred display name for email messages"), PRF_STRING, NULL);
+       RegisterPreference("defaulthandle", _("Preferred display name for bulletin board posts"), PRF_STRING, NULL);
+       RegisterPreference("mailbox", _("Mailbox view mode"), PRF_STRING, NULL);
+
+       WebcitAddUrlHandler(HKEY("readnew"), "", 0, h_readnew, ANONYMOUS | NEED_URL);
+       WebcitAddUrlHandler(HKEY("readold"), "", 0, h_readold, ANONYMOUS | NEED_URL);
+       WebcitAddUrlHandler(HKEY("readfwd"), "", 0, h_readfwd, ANONYMOUS | NEED_URL);
        WebcitAddUrlHandler(HKEY("headers"), "", 0, h_headers, NEED_URL);
-       WebcitAddUrlHandler(HKEY("readgt"), "", 0, h_readgt, ANONYMOUS|NEED_URL);
-       WebcitAddUrlHandler(HKEY("readlt"), "", 0, h_readlt, ANONYMOUS|NEED_URL);
+       WebcitAddUrlHandler(HKEY("readgt"), "", 0, h_readgt, ANONYMOUS | NEED_URL);
+       WebcitAddUrlHandler(HKEY("readlt"), "", 0, h_readlt, ANONYMOUS | NEED_URL);
        WebcitAddUrlHandler(HKEY("do_search"), "", 0, h_do_search, 0);
        WebcitAddUrlHandler(HKEY("display_enter"), "", 0, display_enter, 0);
        WebcitAddUrlHandler(HKEY("post"), "", 0, post_message, PROHIBIT_STARTPAGE);
        WebcitAddUrlHandler(HKEY("move_msg"), "", 0, move_msg, PROHIBIT_STARTPAGE);
        WebcitAddUrlHandler(HKEY("delete_msg"), "", 0, delete_msg, PROHIBIT_STARTPAGE);
        WebcitAddUrlHandler(HKEY("msg"), "", 0, embed_message, NEED_URL);
-       WebcitAddUrlHandler(HKEY("message"), "", 0, handle_one_message, NEED_URL|XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
+       WebcitAddUrlHandler(HKEY("message"), "", 0, handle_one_message,
+                           NEED_URL | XHTTP_COMMANDS | COOKIEUNNEEDED | FORCE_SESSIONCLOSE);
        WebcitAddUrlHandler(HKEY("printmsg"), "", 0, print_message, NEED_URL);
        WebcitAddUrlHandler(HKEY("msgheaders"), "", 0, display_headers, NEED_URL);
 
        WebcitAddUrlHandler(HKEY("mimepart"), "", 0, view_mimepart, NEED_URL);
        WebcitAddUrlHandler(HKEY("mimepart_download"), "", 0, download_mimepart, NEED_URL);
-       WebcitAddUrlHandler(HKEY("postpart"), "", 0, view_postpart, NEED_URL|PROHIBIT_STARTPAGE);
-       WebcitAddUrlHandler(HKEY("postpart_download"), "", 0, download_postpart, NEED_URL|PROHIBIT_STARTPAGE);
+       WebcitAddUrlHandler(HKEY("postpart"), "", 0, view_postpart, NEED_URL | PROHIBIT_STARTPAGE);
+       WebcitAddUrlHandler(HKEY("postpart_download"), "", 0, download_postpart, NEED_URL | PROHIBIT_STARTPAGE);
        WebcitAddUrlHandler(HKEY("upload_attachment"), "", 0, upload_attachment, AJAX);
        WebcitAddUrlHandler(HKEY("remove_attachment"), "", 0, remove_attachment, AJAX);
        WebcitAddUrlHandler(HKEY("show_num_attachments"), "", 0, show_num_attachments, AJAX);
 
        /* json */
-       WebcitAddUrlHandler(HKEY("roommsgs"), "", 0, jsonMessageList,0);
+       WebcitAddUrlHandler(HKEY("roommsgs"), "", 0, jsonMessageList, 0);
 }
 
-void
-SessionDetachModule_MSG
-(wcsession *sess)
-{
+void SessionDetachModule_MSG(wcsession * sess) {
        DeleteHash(&sess->summ);
 }
index def0899a4978f57a5560b05a03003621d69c2714..fa5fff29fa389734e273507b277042fb92bc0b64 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2020 by the citadel.org team
  *
@@ -17,7 +18,7 @@ extern CtxType CTX_MIME_ATACH;
 extern HashList *MimeRenderHandler;
 extern HashList *ReadLoopHandler;
 typedef struct wc_mime_attachment wc_mime_attachment;
-typedef void (*RenderMimeFunc)(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset);
+typedef void (*RenderMimeFunc)(StrBuf * Target, WCTemplputParams * TP, StrBuf * FoundCharset);
 typedef struct _RenderMimeFuncStruct {
        RenderMimeFunc f;
 } RenderMimeFuncStruct;
@@ -42,15 +43,15 @@ void DestroyMime(void *vMime);
 #define MSGFLAG_READ (1<<0)
 
 typedef struct _message_summary {
-       long msgnum;                            // the message number on the citadel server
+       long msgnum;            // the message number on the citadel server
        int Flags;
-       time_t date;                            // its creation date
+       time_t date;            // its creation date
        int nhdr;
        int format_type;
        StrBuf *euid;
-       StrBuf *from;                           // display name of message author
-       StrBuf *to;                             // the recipient
-       StrBuf *subj;                           // title / subject
+       StrBuf *from;           // display name of message author
+       StrBuf *to;             // the recipient
+       StrBuf *subj;           // title / subject
        StrBuf *reply_inreplyto;
        long reply_inreplyto_hash;
        StrBuf *reply_references;
@@ -59,16 +60,16 @@ typedef struct _message_summary {
        StrBuf *cccc;
        StrBuf *AllRcpt;
        StrBuf *Room;
-       StrBuf *Rfca;                           // UPN or email address of message author
+       StrBuf *Rfca;           // UPN or email address of message author
        StrBuf *EnvTo;
        const StrBuf *PartNum;
-       HashList *Attachments;                  // list of attachments
+       HashList *Attachments;  // list of attachments
        HashList *Submessages;
        HashList *AttachLinks;
        HashList *AllAttach;
        int hasattachments;
-       int is_local;                           // nonzero if the message originated on the local system
-       wc_mime_attachment *MsgBody;            // the MIME part of the message
+       int is_local;           // nonzero if the message originated on the local system
+       wc_mime_attachment *MsgBody;    // the MIME part of the message
 } message_summary;
 
 void DestroyMessageSummary(void *vMsg);
@@ -104,14 +105,14 @@ typedef enum _eMessageField {
        eLastHeader
 } eMessageField;
 
-extern const charfieldMnemonics[];
+extern const char *fieldMnemonics[];
 
-int GetFieldFromMnemonic(eMessageField *f, const char* c);
-int EvaluateMsgHdr(const char *HeaderName, long HdrNLen, message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
-int EvaluateMsgHdrEnum(eMessageField f, message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
+int GetFieldFromMnemonic(eMessageField * f, const char *c);
+int EvaluateMsgHdr(const char *HeaderName, long HdrNLen, message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset);
+int EvaluateMsgHdrEnum(eMessageField f, message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset);
 
 
-static inline message_summary* GetMessagePtrAt(int n, HashList *Summ) {
+static inline message_summary *GetMessagePtrAt(int n, HashList * Summ) {
        const char *Key;
        long HKLen;
        void *vMsg;
@@ -120,15 +121,15 @@ static inline message_summary* GetMessagePtrAt(int n, HashList *Summ) {
                return NULL;
        }
        GetHashAt(Summ, n, &HKLen, &Key, &vMsg);
-       return (message_summary*) vMsg;
+       return (message_summary *) vMsg;
 }
 
 
-typedef void (*ExamineMsgHeaderFunc)(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
-void evaluate_mime_part(StrBuf *Target, WCTemplputParams *TP);
+typedef void (*ExamineMsgHeaderFunc)(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset);
+void evaluate_mime_part(StrBuf * Target, WCTemplputParams * TP);
 
 typedef enum _eCustomRoomRenderer {
-       eUseDefault = VIEW_JOURNAL + 100, 
+       eUseDefault = VIEW_JOURNAL + 100,
        eReadEUIDS
 } eCustomRoomRenderer;
 
@@ -150,11 +151,8 @@ enum {
  * @param ViewSpecific your view specific context data
  * @returns 0: failure, trash this message. 1: all right, store it
  */
-typedef int (*load_msg_ptrs_detailheaders) (StrBuf *Line, 
-                                           const char **pos, 
-                                           message_summary *Msg, 
-                                           StrBuf *ConversionBuffer,
-                                           void **ViewSpecific);
+typedef int (*load_msg_ptrs_detailheaders)(StrBuf * Line,
+                                          const char **pos, message_summary * Msg, StrBuf * ConversionBuffer, void **ViewSpecific);
 
 typedef void (*readloop_servcmd)(char *buf, long bufsize);
 
@@ -166,73 +164,55 @@ typedef struct _readloopstruct {
 extern readloop_struct rlid[];
 
 void readloop(long oper, eCustomRoomRenderer ForceRenderer);
-int read_message(StrBuf *Target, 
-                const char *tmpl, long tmpllen, 
-                long msgnum, 
-                const StrBuf *section, 
-                const StrBuf **OutMime,
-                WCTemplputParams *TP);
-int load_message(message_summary *Msg, 
-                StrBuf *FoundCharset,
-                StrBuf **Error);
+int read_message(StrBuf * Target,
+                const char *tmpl, long tmpllen,
+                long msgnum, const StrBuf * section, const StrBuf ** OutMime, WCTemplputParams * TP);
+int load_message(message_summary * Msg, StrBuf * FoundCharset, StrBuf ** Error);
 
 
 
 
 typedef struct _SharedMessageStatus {
-       long load_seen;        /* should read information be loaded */
-       long sortit;           /* should we sort it using the standard sort API? */
-       long defaultsortorder; /* if we should sort it, which direction should be the default? */
+       long load_seen;         /* should read information be loaded */
+       long sortit;            /* should we sort it using the standard sort API? */
+       long defaultsortorder;  /* if we should sort it, which direction should be the default? */
 
-       long maxload;          /* how many headers should we accept from the server? defaults to 10k */
-       long maxmsgs;          /* how many message bodies do you want to load at most?*/
+       long maxload;           /* how many headers should we accept from the server? defaults to 10k */
+       long maxmsgs;           /* how many message bodies do you want to load at most? */
 
-       long startmsg;         /* which is the start message? */
-       long nummsgs;          /* How many messages are available to your view? */
-       long numNewmsgs;       /* if you load the seen-status, this is the count of them. */
-       long num_displayed;    /* counted up for LoadMsgFromServer */ /* TODO: unclear who should access this and why */
+       long startmsg;          /* which is the start message? */
+       long nummsgs;           /* How many messages are available to your view? */
+       long numNewmsgs;        /* if you load the seen-status, this is the count of them. */
+       long num_displayed;     /* counted up for LoadMsgFromServer *//* TODO: unclear who should access this and why */
 
-       long lowest_found;     /* smallest Message ID found;  */
-       long highest_found;    /* highest Message ID found;  */
+       long lowest_found;      /* smallest Message ID found;  */
+       long highest_found;     /* highest Message ID found;  */
 
 } SharedMessageStatus;
 
 int load_msg_ptrs(const char *servcmd,
                  const char *filter,
-                 StrBuf *FoundCharset,
-                 SharedMessageStatus *Stat,
+                 StrBuf * FoundCharset,
+                 SharedMessageStatus * Stat,
                  void **ViewSpecific,
-                 load_msg_ptrs_detailheaders LH,
-                 StrBuf *FetchMessageList,
-                 eMessageField *MessageFieldList,
-                 long HeaderCount);
-
-typedef int (*GetParamsGetServerCall_func)(SharedMessageStatus *Stat, 
-                                          void **ViewSpecific, 
-                                          long oper, 
-                                          char *cmd, 
-                                          long len,
-                                          char *filter,
-                                          long flen);
-
-typedef int (*PrintViewHeader_func)(SharedMessageStatus *Stat, void **ViewSpecific);
-
-typedef int (*LoadMsgFromServer_func)(SharedMessageStatus *Stat, 
-                                     void **ViewSpecific, 
-                                     message_summary* Msg, 
-                                     int is_new, 
-                                     int i);
-
-typedef int (*RenderView_or_Tail_func)(SharedMessageStatus *Stat, 
-                                      void **ViewSpecific, 
-                                      long oper);
+                 load_msg_ptrs_detailheaders LH, StrBuf * FetchMessageList, eMessageField * MessageFieldList, long HeaderCount);
+
+typedef int (*GetParamsGetServerCall_func)(SharedMessageStatus * Stat,
+                                          void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen);
+
+typedef int (*PrintViewHeader_func)(SharedMessageStatus * Stat, void **ViewSpecific);
+
+typedef int (*LoadMsgFromServer_func)(SharedMessageStatus * Stat, void **ViewSpecific, message_summary * Msg, int is_new, int i);
+
+typedef int (*RenderView_or_Tail_func)(SharedMessageStatus * Stat, void **ViewSpecific, long oper);
 typedef int (*View_Cleanup_func)(void **ViewSpecific);
 
 void RegisterReadLoopHandlerset(
+
        /**
         * RoomType: which View definition are you going to be called for
         */
-       int RoomType,
+                                      int RoomType,
 
        /**
         * GetParamsGetServerCall should do the following:
@@ -244,27 +224,27 @@ void RegisterReadLoopHandlerset(
         *      is skipped.
         *  * influence the behaviour by presetting values on SharedMessageStatus
         */
-       GetParamsGetServerCall_func GetParamsGetServerCall,
+                                      GetParamsGetServerCall_func GetParamsGetServerCall,
 
        /**
         * PrintpageHeader prints the surrounding information like iconbar, header etc.
         * by default, output_headers() is called.
         *
         */
-       PrintViewHeader_func PrintPageHeader,
+                                      PrintViewHeader_func PrintPageHeader,
 
        /**
         * PrintViewHeader is here to print informations infront of your messages.
         * The message list is already loaded & sorted (if) so you can evaluate 
         * its result on the SharedMessageStatus struct.
         */
-       PrintViewHeader_func PrintViewHeader,
+                                      PrintViewHeader_func PrintViewHeader,
 
        /**
         * LH is the function, you specify if you want to load more than just message
         * numbers from the server during the listing fetch operation.
         */
-       load_msg_ptrs_detailheaders LH,
+                                      load_msg_ptrs_detailheaders LH,
 
        /**
         * LoadMsgFromServer is called for every message in the message list:
@@ -275,7 +255,7 @@ void RegisterReadLoopHandlerset(
         *  * depending on your needs you might want to print your message here...
         *  * if cmd was empty, its skipped alltogether.
         */
-       LoadMsgFromServer_func LoadMsgFromServer,
+                                      LoadMsgFromServer_func LoadMsgFromServer,
 
        /**
         * RenderView_or_Tail is called last; 
@@ -283,20 +263,21 @@ void RegisterReadLoopHandlerset(
         *    trailing information here
         *  * if you just pre-loaded your messages, put your render code here.
         */
-       RenderView_or_Tail_func RenderView_or_Tail,
+                                      RenderView_or_Tail_func RenderView_or_Tail,
 
        /**
         * ViewCleanup should just clear your private data so all your mem can go back to 
         * VALgrindHALLA.
         * it also should release the content for delivery via end_burst() or wDumpContent(1);
         */
-       View_Cleanup_func ViewCleanup,
+                                      View_Cleanup_func ViewCleanup,
+
        /**
         * brofwseListFields schould be a NULL-terminated list of message field mnemonics
         * that will be the browse vector for the message header list.
         */
-       const char **browseListFields
-       );
+                                      const char **browseListFields);
+
 /*
 GetParamsGetServerCall
 
@@ -308,11 +289,8 @@ RenderView_or_Tail
 */
 
 
-int ParseMessageListHeaders_Detail(StrBuf *Line, 
-                                  const char **pos, 
-                                  message_summary *Msg, 
-                                  StrBuf *ConversionBuffer,
-                                  void **ViewSpecific);
+int ParseMessageListHeaders_Detail(StrBuf * Line,
+                                  const char **pos, message_summary * Msg, StrBuf * ConversionBuffer, void **ViewSpecific);
 
 /**
  * @brief function to register the availability to render a specific message
@@ -321,10 +299,7 @@ int ParseMessageListHeaders_Detail(StrBuf *Line,
  * @param InlineRenderable Should we announce to citserver that we want to receive these mimeparts immediately?
  * @param Priority if multipart/alternative; which mimepart/Renderer should be prefered? (only applies if InlineRenderable)
  */
-void RegisterMimeRenderer(const char *HeaderName, long HdrNLen, 
-                         RenderMimeFunc MimeRenderer,
-                         int InlineRenderable,
-                         int Priority);
+void RegisterMimeRenderer(const char *HeaderName, long HdrNLen, RenderMimeFunc MimeRenderer, int InlineRenderable, int Priority);
 
 
 /**
@@ -333,6 +308,6 @@ void RegisterMimeRenderer(const char *HeaderName, long HdrNLen,
  * @param FoundCharset buffer with the prefered charset of the headers
  * @param buf linebuffer used to buffer citserver replies
  */
-int ReadOneMessageSummary(message_summary *Msg, StrBuf *FoundCharset, StrBuf *Buf);
+int ReadOneMessageSummary(message_summary * Msg, StrBuf * FoundCharset, StrBuf * Buf);
 
 #endif
index eef21cfc70eff6d1ae6a87a9fb7b4effcec45d6f..a4784b39f0fe3cf632fddec1b6eff219ee993496 100644 (file)
@@ -10,8 +10,7 @@ HashList *DflMsgHeaderHandler = NULL;
 HashList *DflEnumMsgHeaderHandler = NULL;
 
 
-static inline void CheckConvertBufs(struct wcsession *WCC)
-{
+static inline void CheckConvertBufs(struct wcsession *WCC) {
        if (WCC->ConvertBuf1 == NULL)
                WCC->ConvertBuf1 = NewStrBuf();
        if (WCC->ConvertBuf2 == NULL)
@@ -23,8 +22,7 @@ static inline void CheckConvertBufs(struct wcsession *WCC)
  */
 
 
-void DestroyMimeParts(wc_mime_attachment *Mime)
-{
+void DestroyMimeParts(wc_mime_attachment * Mime) {
        FreeStrBuf(&Mime->Name);
        FreeStrBuf(&Mime->FileName);
        FreeStrBuf(&Mime->PartNum);
@@ -34,16 +32,14 @@ void DestroyMimeParts(wc_mime_attachment *Mime)
        FreeStrBuf(&Mime->Data);
 }
 
-void DestroyMime(void *vMime)
-{
-       wc_mime_attachment *Mime = (wc_mime_attachment*)vMime;
+void DestroyMime(void *vMime) {
+       wc_mime_attachment *Mime = (wc_mime_attachment *) vMime;
        DestroyMimeParts(Mime);
        free(Mime);
 }
 
-void DestroyMessageSummary(void *vMsg)
-{
-       message_summary *Msg = (message_summary*) vMsg;
+void DestroyMessageSummary(void *vMsg) {
+       message_summary *Msg = (message_summary *) vMsg;
 
        FreeStrBuf(&Msg->from);
        FreeStrBuf(&Msg->to);
@@ -63,13 +59,11 @@ void DestroyMessageSummary(void *vMsg)
        free(Msg);
 }
 
-int EvaluateMsgHdrEnum(eMessageField f, message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
-{
+int EvaluateMsgHdrEnum(eMessageField f, message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        void *vHdr;
-       headereval* Hdr = NULL;
-       if (GetHash(DflEnumMsgHeaderHandler, IKEY(f), &vHdr) &&
-           (vHdr != NULL)) {
-               Hdr = (headereval*)vHdr;
+       headereval *Hdr = NULL;
+       if (GetHash(DflEnumMsgHeaderHandler, IKEY(f), &vHdr) && (vHdr != NULL)) {
+               Hdr = (headereval *) vHdr;
        }
        if (Hdr == NULL)
                return -1;
@@ -77,19 +71,16 @@ int EvaluateMsgHdrEnum(eMessageField f, message_summary *Msg, StrBuf *HdrLine, S
        return Hdr->Type;
 }
 
-int EvaluateMsgHdr(const char *HeaderName, long HdrNLen, message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
-{
+int EvaluateMsgHdr(const char *HeaderName, long HdrNLen, message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        void *vHdr;
-       headerevalHdr = NULL;
+       headereval *Hdr = NULL;
        if (HdrNLen == 4) {
-               if (GetHash(DflMsgHeaderHandler, HeaderName, HdrNLen, &vHdr) &&
-                   (vHdr != NULL)) {
-                       Hdr = (headereval*)vHdr;
+               if (GetHash(DflMsgHeaderHandler, HeaderName, HdrNLen, &vHdr) && (vHdr != NULL)) {
+                       Hdr = (headereval *) vHdr;
                }
        }
-       if (Hdr == NULL && GetHash(MsgHeaderHandler, HeaderName, HdrNLen, &vHdr) &&
-           (vHdr != NULL)) {
-               Hdr = (headereval*)vHdr;
+       if (Hdr == NULL && GetHash(MsgHeaderHandler, HeaderName, HdrNLen, &vHdr) && (vHdr != NULL)) {
+               Hdr = (headereval *) vHdr;
        }
        if (Hdr == NULL)
                return -1;
@@ -97,10 +88,9 @@ int EvaluateMsgHdr(const char *HeaderName, long HdrNLen, message_summary *Msg, S
        return Hdr->Type;
 }
 
-void RegisterMsgHdr(const char *HeaderName, long HdrNLen, ExamineMsgHeaderFunc evaluator, int type)
-{
+void RegisterMsgHdr(const char *HeaderName, long HdrNLen, ExamineMsgHeaderFunc evaluator, int type) {
        headereval *ev;
-       ev = (headereval*) malloc(sizeof(headereval));
+       ev = (headereval *) malloc(sizeof(headereval));
        ev->evaluator = evaluator;
        ev->Type = type;
 
@@ -115,14 +105,10 @@ void RegisterMsgHdr(const char *HeaderName, long HdrNLen, ExamineMsgHeaderFunc e
        Put(MsgHeaderHandler, HeaderName, HdrNLen, ev, NULL);
 }
 
-void RegisterMimeRenderer(const char *HeaderName, long HdrNLen, 
-                         RenderMimeFunc MimeRenderer,
-                         int InlineRenderable,
-                         int Priority)
-{
+void RegisterMimeRenderer(const char *HeaderName, long HdrNLen, RenderMimeFunc MimeRenderer, int InlineRenderable, int Priority) {
        RenderMimeFuncStruct *f;
 
-       f = (RenderMimeFuncStruct*) malloc(sizeof(RenderMimeFuncStruct));
+       f = (RenderMimeFuncStruct *) malloc(sizeof(RenderMimeFuncStruct));
        f->f = MimeRenderer;
        Put(MimeRenderHandler, HeaderName, HdrNLen, f, NULL);
        if (InlineRenderable)
@@ -138,12 +124,14 @@ int longcmp_r(const void *s1, const void *s2) {
        long l1;
        long l2;
 
-       l1 = *(long *)GetSearchPayload(s1);
-       l2 = *(long *)GetSearchPayload(s2);
+       l1 = *(long *) GetSearchPayload(s1);
+       l2 = *(long *) GetSearchPayload(s2);
 
-       if (l1 > l2) return(-1);
-       if (l1 < l2) return(+1);
-       return(0);
+       if (l1 > l2)
+               return (-1);
+       if (l1 < l2)
+               return (+1);
+       return (0);
 }
 
 /*
@@ -153,21 +141,23 @@ int qlongcmp_r(const void *s1, const void *s2) {
        long l1 = (long) s1;
        long l2 = (long) s2;
 
-       if (l1 > l2) return(-1);
-       if (l1 < l2) return(+1);
-       return(0);
+       if (l1 > l2)
+               return (-1);
+       if (l1 < l2)
+               return (+1);
+       return (0);
 }
 
+
 /*
  * comparator for message summary structs by ascending subject.
  */
 int summcmp_subj(const void *s1, const void *s2) {
        message_summary *summ1;
        message_summary *summ2;
-       
-       summ1 = (message_summary *)GetSearchPayload(s1);
-       summ2 = (message_summary *)GetSearchPayload(s2);
+
+       summ1 = (message_summary *) GetSearchPayload(s1);
+       summ2 = (message_summary *) GetSearchPayload(s2);
        return strcasecmp(ChrPtr(summ1->subj), ChrPtr(summ2->subj));
 }
 
@@ -177,20 +167,21 @@ int summcmp_subj(const void *s1, const void *s2) {
 int summcmp_rsubj(const void *s1, const void *s2) {
        message_summary *summ1;
        message_summary *summ2;
-       
-       summ1 = (message_summary *)GetSearchPayload(s1);
-       summ2 = (message_summary *)GetSearchPayload(s2);
+
+       summ1 = (message_summary *) GetSearchPayload(s1);
+       summ2 = (message_summary *) GetSearchPayload(s2);
        return strcasecmp(ChrPtr(summ2->subj), ChrPtr(summ1->subj));
 }
+
 /*
  * comparator for message summary structs by descending subject.
  */
 int groupchange_subj(const void *s1, const void *s2) {
        message_summary *summ1;
        message_summary *summ2;
-       
-       summ1 = (message_summary *)s1;
-       summ2 = (message_summary *)s2;
+
+       summ1 = (message_summary *) s1;
+       summ2 = (message_summary *) s2;
        return ChrPtr(summ2->subj)[0] != ChrPtr(summ1->subj)[0];
 }
 
@@ -200,9 +191,9 @@ int groupchange_subj(const void *s1, const void *s2) {
 int summcmp_sender(const void *s1, const void *s2) {
        message_summary *summ1;
        message_summary *summ2;
-       
-       summ1 = (message_summary *)GetSearchPayload(s1);
-       summ2 = (message_summary *)GetSearchPayload(s2);
+
+       summ1 = (message_summary *) GetSearchPayload(s1);
+       summ2 = (message_summary *) GetSearchPayload(s2);
        return strcasecmp(ChrPtr(summ1->from), ChrPtr(summ2->from));
 }
 
@@ -212,20 +203,21 @@ int summcmp_sender(const void *s1, const void *s2) {
 int summcmp_rsender(const void *s1, const void *s2) {
        message_summary *summ1;
        message_summary *summ2;
-       
-       summ1 = (message_summary *)GetSearchPayload(s1);
-       summ2 = (message_summary *)GetSearchPayload(s2);
+
+       summ1 = (message_summary *) GetSearchPayload(s1);
+       summ2 = (message_summary *) GetSearchPayload(s2);
        return strcasecmp(ChrPtr(summ2->from), ChrPtr(summ1->from));
 }
+
 /*
  * comparator for message summary structs by descending sender.
  */
 int groupchange_sender(const void *s1, const void *s2) {
        message_summary *summ1;
        message_summary *summ2;
-       
-       summ1 = (message_summary *)s1;
-       summ2 = (message_summary *)s2;
+
+       summ1 = (message_summary *) s1;
+       summ2 = (message_summary *) s2;
        return strcasecmp(ChrPtr(summ2->from), ChrPtr(summ1->from)) != 0;
 
 }
@@ -236,13 +228,16 @@ int groupchange_sender(const void *s1, const void *s2) {
 int summcmp_date(const void *s1, const void *s2) {
        message_summary *summ1;
        message_summary *summ2;
-       
-       summ1 = (message_summary *)GetSearchPayload(s1);
-       summ2 = (message_summary *)GetSearchPayload(s2);
 
-       if (summ1->date < summ2->date) return -1;
-       else if (summ1->date > summ2->date) return +1;
-       else return 0;
+       summ1 = (message_summary *) GetSearchPayload(s1);
+       summ2 = (message_summary *) GetSearchPayload(s2);
+
+       if (summ1->date < summ2->date)
+               return -1;
+       else if (summ1->date > summ2->date)
+               return +1;
+       else
+               return 0;
 }
 
 /*
@@ -251,13 +246,16 @@ int summcmp_date(const void *s1, const void *s2) {
 int summcmp_rdate(const void *s1, const void *s2) {
        message_summary *summ1;
        message_summary *summ2;
-       
-       summ1 = (message_summary *)GetSearchPayload(s1);
-       summ2 = (message_summary *)GetSearchPayload(s2);
 
-       if (summ1->date < summ2->date) return +1;
-       else if (summ1->date > summ2->date) return -1;
-       else return 0;
+       summ1 = (message_summary *) GetSearchPayload(s1);
+       summ2 = (message_summary *) GetSearchPayload(s2);
+
+       if (summ1->date < summ2->date)
+               return +1;
+       else if (summ1->date > summ2->date)
+               return -1;
+       else
+               return 0;
 }
 
 /*
@@ -267,91 +265,77 @@ const long DAYSECONDS = 24 * 60 * 60;
 int groupchange_date(const void *s1, const void *s2) {
        message_summary *summ1;
        message_summary *summ2;
-       
-       summ1 = (message_summary *)s1;
-       summ2 = (message_summary *)s2;
 
-       return (summ1->date % DAYSECONDS) != (summ2->date %DAYSECONDS);
+       summ1 = (message_summary *) s1;
+       summ2 = (message_summary *) s2;
+
+       return (summ1->date % DAYSECONDS) != (summ2->date % DAYSECONDS);
 }
 
 
 /* Stub handlers for MIME parser */
-void examine_pref(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {return;}
-void examine_suff(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {return;}
-void examine_path(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {return;}
+void examine_pref(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
+       return;
+}
+void examine_suff(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
+       return;
+}
+void examine_path(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
+       return;
+}
+
+void examine_content_encoding(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
 
-void examine_content_encoding(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
-{
 /* nothing to do here */
 }
 
 
-void examine_exti(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
-{
+void examine_exti(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
+
 /* nothing to do here */
 }
 
-void examine_nhdr(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
-{
+void examine_nhdr(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        Msg->nhdr = 0;
        if (!strncasecmp(ChrPtr(HdrLine), "yes", 8))
                Msg->nhdr = 1;
 }
-int Conditional_ANONYMOUS_MESSAGE(StrBuf *Target, WCTemplputParams *TP)
-{
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+int Conditional_ANONYMOUS_MESSAGE(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        return Msg->nhdr != 0;
 }
 
-void examine_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
-{
+void examine_type(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        Msg->format_type = StrToi(HdrLine);
-                       
+
 }
 
-void examine_from(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
-{
+void examine_from(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        CheckConvertBufs(WC);
        FreeStrBuf(&Msg->from);
        Msg->from = NewStrBufPlain(NULL, StrLength(HdrLine));
-       StrBuf_RFC822_2_Utf8(Msg->from, 
-                            HdrLine, 
-                            WC->DefaultCharset, 
-                            FoundCharset,
-                            WC->ConvertBuf1,
-                            WC->ConvertBuf2);
-}
-void tmplput_MAIL_SUMM_FROM(StrBuf *Target, WCTemplputParams *TP)
-{
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+       StrBuf_RFC822_2_Utf8(Msg->from, HdrLine, WC->DefaultCharset, FoundCharset, WC->ConvertBuf1, WC->ConvertBuf2);
+}
+void tmplput_MAIL_SUMM_FROM(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        StrBufAppendTemplate(Target, TP, Msg->from, 0);
 }
 
-void examine_subj(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
-{
+void examine_subj(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        CheckConvertBufs(WC);
        FreeStrBuf(&Msg->subj);
        Msg->subj = NewStrBufPlain(NULL, StrLength(HdrLine));
-       StrBuf_RFC822_2_Utf8(Msg->subj, 
-                            HdrLine, 
-                            WC->DefaultCharset, 
-                            FoundCharset,
-                            WC->ConvertBuf1,
-                            WC->ConvertBuf2);
-}
-void tmplput_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP)
-{
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
-
-       if (TP->Tokens->nParameters == 4)
-       {
+       StrBuf_RFC822_2_Utf8(Msg->subj, HdrLine, WC->DefaultCharset, FoundCharset, WC->ConvertBuf1, WC->ConvertBuf2);
+}
+void tmplput_MAIL_SUMM_SUBJECT(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
+
+       if (TP->Tokens->nParameters == 4) {
                const char *pch;
                long len;
-               
+
                GetTemplateTokenString(Target, TP, 3, &pch, &len);
-               if ((len > 0)&&
-                   (strstr(ChrPtr(Msg->subj), pch) == NULL))
-               {
+               if ((len > 0) && (strstr(ChrPtr(Msg->subj), pch) == NULL)) {
                        GetTemplateTokenString(Target, TP, 2, &pch, &len);
                        StrBufAppendBufPlain(Target, pch, len, 0);
                }
@@ -362,8 +346,8 @@ void tmplput_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP)
 /*
  * Conditional returns true if the message has a Subject and it is nonzero in length
  */
-int Conditional_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP) {
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+int Conditional_MAIL_SUMM_SUBJECT(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        return StrLength(Msg->subj) > 0;
 }
 
@@ -371,13 +355,13 @@ int Conditional_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP) {
 /*
  * Conditional returns true if the message originated on the local system
  */
-int Conditional_MAIL_LOCAL(StrBuf *Target, WCTemplputParams *TP) {
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+int Conditional_MAIL_LOCAL(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        return (Msg->is_local ? 1 : 0);
 }
 
 
-void examine_msgn(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {
+void examine_msgn(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        long Offset = 0;
        const char *pOffset;
 
@@ -389,28 +373,23 @@ void examine_msgn(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {
                Offset = pOffset - ChrPtr(HdrLine);
        }
        Msg->reply_inreplyto_hash = ThreadIdHashOffset(HdrLine, Offset);
-       StrBuf_RFC822_2_Utf8(Msg->reply_inreplyto, 
-                            HdrLine, 
-                            WC->DefaultCharset,
-                            FoundCharset,
-                            WC->ConvertBuf1,
-                            WC->ConvertBuf2);
+       StrBuf_RFC822_2_Utf8(Msg->reply_inreplyto, HdrLine, WC->DefaultCharset, FoundCharset, WC->ConvertBuf1, WC->ConvertBuf2);
 }
 
 
-void tmplput_MAIL_SUMM_INREPLYTO(StrBuf *Target, WCTemplputParams *TP) {
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+void tmplput_MAIL_SUMM_INREPLYTO(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        StrBufAppendTemplate(Target, TP, Msg->reply_inreplyto, 0);
 }
 
 
-int Conditional_MAIL_SUMM_UNREAD(StrBuf *Target, WCTemplputParams *TP) {
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+int Conditional_MAIL_SUMM_UNREAD(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        return (Msg->Flags & MSGFLAG_READ) != 0;
 }
 
 
-void examine_wefw(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {
+void examine_wefw(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        wcsession *WCC = WC;
        long Offset = 0;
        const char *pOffset;
@@ -423,33 +402,23 @@ void examine_wefw(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {
                Offset = pOffset - ChrPtr(HdrLine);
        }
        Msg->reply_references_hash = ThreadIdHashOffset(HdrLine, Offset);
-       StrBuf_RFC822_2_Utf8(Msg->reply_references, 
-                            HdrLine, 
-                            WCC->DefaultCharset, 
-                            FoundCharset,
-                            WCC->ConvertBuf1,
-                            WCC->ConvertBuf2);
+       StrBuf_RFC822_2_Utf8(Msg->reply_references, HdrLine, WCC->DefaultCharset, FoundCharset, WCC->ConvertBuf1, WCC->ConvertBuf2);
 }
 
 
-void tmplput_MAIL_SUMM_REFIDS(StrBuf *Target, WCTemplputParams *TP) {
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+void tmplput_MAIL_SUMM_REFIDS(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        StrBufAppendTemplate(Target, TP, Msg->reply_references, 0);
 }
 
 
-void examine_replyto(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {
+void examine_replyto(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        wcsession *WCC = WC;
 
        CheckConvertBufs(WCC);
        FreeStrBuf(&Msg->ReplyTo);
        Msg->ReplyTo = NewStrBufPlain(NULL, StrLength(HdrLine));
-       StrBuf_RFC822_2_Utf8(Msg->ReplyTo, 
-                            HdrLine, 
-                            WCC->DefaultCharset, 
-                            FoundCharset,
-                            WCC->ConvertBuf1,
-                            WCC->ConvertBuf2);
+       StrBuf_RFC822_2_Utf8(Msg->ReplyTo, HdrLine, WCC->DefaultCharset, FoundCharset, WCC->ConvertBuf1, WCC->ConvertBuf2);
        if (Msg->AllRcpt == NULL)
                Msg->AllRcpt = NewStrBufPlain(NULL, StrLength(HdrLine));
        if (StrLength(Msg->AllRcpt) > 0) {
@@ -459,24 +428,19 @@ void examine_replyto(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset
 }
 
 
-void tmplput_MAIL_SUMM_REPLYTO(StrBuf *Target, WCTemplputParams *TP) {
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+void tmplput_MAIL_SUMM_REPLYTO(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        StrBufAppendTemplate(Target, TP, Msg->ReplyTo, 0);
 }
 
 
-void examine_cccc(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {
+void examine_cccc(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        wcsession *WCC = WC;
 
        CheckConvertBufs(WCC);
        FreeStrBuf(&Msg->cccc);
        Msg->cccc = NewStrBufPlain(NULL, StrLength(HdrLine));
-       StrBuf_RFC822_2_Utf8(Msg->cccc, 
-                            HdrLine, 
-                            WCC->DefaultCharset, 
-                            FoundCharset,
-                            WCC->ConvertBuf1,
-                            WCC->ConvertBuf2);
+       StrBuf_RFC822_2_Utf8(Msg->cccc, HdrLine, WCC->DefaultCharset, FoundCharset, WCC->ConvertBuf1, WCC->ConvertBuf2);
        if (Msg->AllRcpt == NULL)
                Msg->AllRcpt = NewStrBufPlain(NULL, StrLength(HdrLine));
        if (StrLength(Msg->AllRcpt) > 0) {
@@ -486,89 +450,78 @@ void examine_cccc(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {
 }
 
 
-void tmplput_MAIL_SUMM_CCCC(StrBuf *Target, WCTemplputParams *TP) {
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+void tmplput_MAIL_SUMM_CCCC(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        StrBufAppendTemplate(Target, TP, Msg->cccc, 0);
 }
 
 
-void examine_room(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {
-       if ((StrLength(HdrLine) > 0) &&
-           (strcasecmp(ChrPtr(HdrLine), ChrPtr(WC->CurRoom.name)))) {
+void examine_room(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
+       if ((StrLength(HdrLine) > 0) && (strcasecmp(ChrPtr(HdrLine), ChrPtr(WC->CurRoom.name)))) {
                FreeStrBuf(&Msg->Room);
-               Msg->Room = NewStrBufDup(HdrLine);              
+               Msg->Room = NewStrBufDup(HdrLine);
        }
 }
 
 
-void tmplput_MAIL_SUMM_ORGROOM(StrBuf *Target, WCTemplputParams *TP) {
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+void tmplput_MAIL_SUMM_ORGROOM(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        StrBufAppendTemplate(Target, TP, Msg->Room, 0);
 }
 
 
-void examine_rfca(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {
+void examine_rfca(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        FreeStrBuf(&Msg->Rfca);
        Msg->Rfca = NewStrBufDup(HdrLine);
 }
 
 
-void examine_locl(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {
+void examine_locl(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        Msg->is_local = 1;
 }
 
 
-void tmplput_MAIL_SUMM_RFCA(StrBuf *Target, WCTemplputParams *TP) {
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+void tmplput_MAIL_SUMM_RFCA(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        StrBufAppendTemplate(Target, TP, Msg->Rfca, 0);
 }
 
 
-int Conditional_MAIL_SUMM_RFCA(StrBuf *Target, WCTemplputParams *TP) {
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+int Conditional_MAIL_SUMM_RFCA(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        return StrLength(Msg->Rfca) > 0;
 }
 
 
-int Conditional_MAIL_SUMM_CCCC(StrBuf *Target, WCTemplputParams *TP) {
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+int Conditional_MAIL_SUMM_CCCC(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        return StrLength(Msg->cccc) > 0;
 }
 
 
-int Conditional_MAIL_SUMM_REPLYTO(StrBuf *Target, WCTemplputParams *TP) {
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+int Conditional_MAIL_SUMM_REPLYTO(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        return StrLength(Msg->ReplyTo) > 0;
 }
 
 
-void examine_nvto(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {
+void examine_nvto(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        wcsession *WCC = WC;
 
        CheckConvertBufs(WCC);
        FreeStrBuf(&Msg->EnvTo);
        Msg->EnvTo = NewStrBufPlain(NULL, StrLength(HdrLine));
-       StrBuf_RFC822_2_Utf8(Msg->EnvTo, 
-                            HdrLine, 
-                            WCC->DefaultCharset, 
-                            FoundCharset,
-                            WCC->ConvertBuf1,
-                            WCC->ConvertBuf2);
+       StrBuf_RFC822_2_Utf8(Msg->EnvTo, HdrLine, WCC->DefaultCharset, FoundCharset, WCC->ConvertBuf1, WCC->ConvertBuf2);
 }
 
 
-void examine_rcpt(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {
+void examine_rcpt(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        wcsession *WCC = WC;
 
        CheckConvertBufs(WCC);
        FreeStrBuf(&Msg->to);
        Msg->to = NewStrBufPlain(NULL, StrLength(HdrLine));
-       StrBuf_RFC822_2_Utf8(Msg->to, 
-                            HdrLine, 
-                            WCC->DefaultCharset, 
-                            FoundCharset,
-                            WCC->ConvertBuf1,
-                            WCC->ConvertBuf2);
+       StrBuf_RFC822_2_Utf8(Msg->to, HdrLine, WCC->DefaultCharset, FoundCharset, WCC->ConvertBuf1, WCC->ConvertBuf2);
        if (Msg->AllRcpt == NULL)
                Msg->AllRcpt = NewStrBufPlain(NULL, StrLength(HdrLine));
        if (StrLength(Msg->AllRcpt) > 0) {
@@ -578,84 +531,80 @@ void examine_rcpt(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {
 }
 
 
-void tmplput_MAIL_SUMM_TO(StrBuf *Target, WCTemplputParams *TP) {
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+void tmplput_MAIL_SUMM_TO(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        StrBufAppendTemplate(Target, TP, Msg->to, 0);
 }
 
 
-int Conditional_MAIL_SUMM_TO(StrBuf *Target, WCTemplputParams *TP) {
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+int Conditional_MAIL_SUMM_TO(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        return StrLength(Msg->to) != 0;
 }
 
 
-int Conditional_MAIL_SUMM_SUBJ(StrBuf *Target, WCTemplputParams *TP) {
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+int Conditional_MAIL_SUMM_SUBJ(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        return StrLength(Msg->subj) != 0;
 }
 
 
-void tmplput_MAIL_SUMM_ALLRCPT(StrBuf *Target, WCTemplputParams *TP) {
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+void tmplput_MAIL_SUMM_ALLRCPT(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        StrBufAppendTemplate(Target, TP, Msg->AllRcpt, 0);
 }
 
 
-void tmplput_SUMM_COUNT(StrBuf *Target, WCTemplputParams *TP) {
-       StrBufAppendPrintf(Target, "%d", GetCount( WC->summ));
+void tmplput_SUMM_COUNT(StrBuf * Target, WCTemplputParams * TP) {
+       StrBufAppendPrintf(Target, "%d", GetCount(WC->summ));
 }
 
 
-HashList *iterate_get_mailsumm_All(StrBuf *Target, WCTemplputParams *TP) {
+HashList *iterate_get_mailsumm_All(StrBuf * Target, WCTemplputParams * TP) {
        return WC->summ;
 }
 
 
-void examine_time(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {
+void examine_time(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        Msg->date = StrTol(HdrLine);
 }
 
 
-void tmplput_MAIL_SUMM_DATE_BRIEF(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_MAIL_SUMM_DATE_BRIEF(StrBuf * Target, WCTemplputParams * TP) {
        char datebuf[64];
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        webcit_fmt_date(datebuf, 64, Msg->date, DATEFMT_BRIEF);
        StrBufAppendBufPlain(Target, datebuf, -1, 0);
 }
 
-void tmplput_MAIL_SUMM_EUID(StrBuf *Target, WCTemplputParams *TP)
-{
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+void tmplput_MAIL_SUMM_EUID(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        StrBufAppendTemplate(Target, TP, Msg->euid, 0);
 }
 
-void tmplput_MAIL_SUMM_DATE_FULL(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_MAIL_SUMM_DATE_FULL(StrBuf * Target, WCTemplputParams * TP) {
        char datebuf[64];
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        webcit_fmt_date(datebuf, 64, Msg->date, DATEFMT_FULL);
        StrBufAppendBufPlain(Target, datebuf, -1, 0);
 }
-void tmplput_MAIL_SUMM_DATE_NO(StrBuf *Target, WCTemplputParams *TP)
-{
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+void tmplput_MAIL_SUMM_DATE_NO(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        StrBufAppendPrintf(Target, "%ld", Msg->date, 0);
 }
 
 
 
-void render_MAIL(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
-{
+void render_MAIL(StrBuf * Target, WCTemplputParams * TP, StrBuf * FoundCharset) {
        wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
        const StrBuf *TemplateMime;
 
-       if (Mime->Data == NULL) 
+       if (Mime->Data == NULL)
                Mime->Data = NewStrBufPlain(NULL, Mime->length);
-       else 
+       else
                FlushStrBuf(Mime->Data);
        read_message(Mime->Data, HKEY("view_submessage"), Mime->msgnum, Mime->PartNum, &TemplateMime, TP);
+
 /*
        if ( (!IsEmptyStr(mime_submessages)) && (!section[0]) ) {
                for (i=0; i<num_tokens(mime_submessages, '|'); ++i) {
@@ -669,8 +618,7 @@ void render_MAIL(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
 */
 }
 
-void render_MIME_ICS(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
-{
+void render_MIME_ICS(StrBuf * Target, WCTemplputParams * TP, StrBuf * FoundCharset) {
        wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
        if (StrLength(Mime->Data) == 0) {
                MimeLoadData(Mime);
@@ -682,43 +630,32 @@ void render_MIME_ICS(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
 
 
 
-void examine_mime_part(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
-{
+void examine_mime_part(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        const char *Ptr = NULL;
        wc_mime_attachment *Mime;
        StrBuf *Buf;
        wcsession *WCC = WC;
 
-       CheckConvertBufs(WCC);  
-       Mime = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
+       CheckConvertBufs(WCC);
+       Mime = (wc_mime_attachment *) malloc(sizeof(wc_mime_attachment));
        memset(Mime, 0, sizeof(wc_mime_attachment));
        Mime->msgnum = Msg->msgnum;
        Buf = NewStrBuf();
 
        Mime->Name = NewStrBuf();
        StrBufExtract_NextToken(Buf, HdrLine, &Ptr, '|');
-       StrBuf_RFC822_2_Utf8(Mime->Name, 
-                            Buf, 
-                            WCC->DefaultCharset, 
-                            FoundCharset,
-                            WCC->ConvertBuf1,
-                            WCC->ConvertBuf2);
+       StrBuf_RFC822_2_Utf8(Mime->Name, Buf, WCC->DefaultCharset, FoundCharset, WCC->ConvertBuf1, WCC->ConvertBuf2);
        StrBufTrim(Mime->Name);
 
        StrBufExtract_NextToken(Buf, HdrLine, &Ptr, '|');
        Mime->FileName = NewStrBuf();
-       StrBuf_RFC822_2_Utf8(Mime->FileName, 
-                            Buf, 
-                            WCC->DefaultCharset, 
-                            FoundCharset,
-                            WCC->ConvertBuf1,
-                            WCC->ConvertBuf2);
+       StrBuf_RFC822_2_Utf8(Mime->FileName, Buf, WCC->DefaultCharset, FoundCharset, WCC->ConvertBuf1, WCC->ConvertBuf2);
        StrBufTrim(Mime->FileName);
 
        Mime->PartNum = NewStrBuf();
        StrBufExtract_NextToken(Mime->PartNum, HdrLine, &Ptr, '|');
        StrBufTrim(Mime->PartNum);
-       if (strchr(ChrPtr(Mime->PartNum), '.') != NULL) 
+       if (strchr(ChrPtr(Mime->PartNum), '.') != NULL)
                Mime->level = 2;
        else
                Mime->level = 1;
@@ -731,19 +668,18 @@ void examine_mime_part(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundChars
        StrBufTrim(Mime->ContentType);
        StrBufLowerCase(Mime->ContentType);
        if (!strcmp(ChrPtr(Mime->ContentType), "application/octet-stream")) {
-               StrBufPlain(Mime->ContentType, 
-                           GuessMimeByFilename(SKEY(Mime->FileName)), -1);
+               StrBufPlain(Mime->ContentType, GuessMimeByFilename(SKEY(Mime->FileName)), -1);
        }
 
        Mime->length = StrBufExtractNext_int(HdrLine, &Ptr, '|');
 
-       StrBufSkip_NTokenS(HdrLine, &Ptr, '|', 1);  /* cbid?? */
+       StrBufSkip_NTokenS(HdrLine, &Ptr, '|', 1);      /* cbid?? */
 
        Mime->Charset = NewStrBuf();
        StrBufExtract_NextToken(Mime->Charset, HdrLine, &Ptr, '|');
 
 
-       if ( (StrLength(Mime->FileName) == 0) && (StrLength(Mime->Name) > 0) ) {
+       if ((StrLength(Mime->FileName) == 0) && (StrLength(Mime->Name) > 0)) {
                StrBufAppendBuf(Mime->FileName, Mime->Name, 0);
        }
 
@@ -756,85 +692,69 @@ void examine_mime_part(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundChars
        }
 
        if (Msg->AllAttach == NULL)
-               Msg->AllAttach = NewHash(1,NULL);
+               Msg->AllAttach = NewHash(1, NULL);
        Put(Msg->AllAttach, SKEY(Mime->PartNum), Mime, DestroyMime);
        FreeStrBuf(&Buf);
 }
 
 
-void evaluate_mime_part(StrBuf *Target, WCTemplputParams *TP)
-{
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+void evaluate_mime_part(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
        void *vMimeRenderer;
 
        /* just print the root-node */
-       if ((Mime->level >= 1) &&
-           GetHash(MimeRenderHandler, SKEY(Mime->ContentType), &vMimeRenderer) &&
-           vMimeRenderer != NULL)
-       {
-               Mime->Renderer = (RenderMimeFuncStruct*) vMimeRenderer;
+       if ((Mime->level >= 1) && GetHash(MimeRenderHandler, SKEY(Mime->ContentType), &vMimeRenderer) && vMimeRenderer != NULL) {
+               Mime->Renderer = (RenderMimeFuncStruct *) vMimeRenderer;
                if (Msg->Submessages == NULL)
-                       Msg->Submessages = NewHash(1,NULL);
+                       Msg->Submessages = NewHash(1, NULL);
                Put(Msg->Submessages, SKEY(Mime->PartNum), Mime, reference_free_handler);
        }
-       else if ((Mime->level >= 1) &&
-                (!strcasecmp(ChrPtr(Mime->Disposition), "inline"))
-                && (!strncasecmp(ChrPtr(Mime->ContentType), "image/", 6)) ){
+       else if ((Mime->level >= 1) && (!strcasecmp(ChrPtr(Mime->Disposition), "inline"))
+                && (!strncasecmp(ChrPtr(Mime->ContentType), "image/", 6))) {
                if (Msg->AttachLinks == NULL)
-                       Msg->AttachLinks = NewHash(1,NULL);
+                       Msg->AttachLinks = NewHash(1, NULL);
                Put(Msg->AttachLinks, SKEY(Mime->PartNum), Mime, reference_free_handler);
        }
-       else if ((Mime->level >= 1) &&
-                (StrLength(Mime->ContentType) > 0) &&
-                 ( (!strcasecmp(ChrPtr(Mime->Disposition), "attachment")) 
-                   || (!strcasecmp(ChrPtr(Mime->Disposition), "inline"))
-                   || (!strcasecmp(ChrPtr(Mime->Disposition), ""))))
-       {               
+       else if ((Mime->level >= 1) && (StrLength(Mime->ContentType) > 0) && ((!strcasecmp(ChrPtr(Mime->Disposition), "attachment"))
+                                                                             || (!strcasecmp(ChrPtr(Mime->Disposition), "inline"))
+                                                                             || (!strcasecmp(ChrPtr(Mime->Disposition), "")))) {
                if (Msg->AttachLinks == NULL)
-                       Msg->AttachLinks = NewHash(1,NULL);
+                       Msg->AttachLinks = NewHash(1, NULL);
                Put(Msg->AttachLinks, SKEY(Mime->PartNum), Mime, reference_free_handler);
-               if ((strcasecmp(ChrPtr(Mime->ContentType), "application/octet-stream") == 0) && 
-                   (StrLength(Mime->FileName) > 0)) {
+               if ((strcasecmp(ChrPtr(Mime->ContentType), "application/octet-stream") == 0) && (StrLength(Mime->FileName) > 0)) {
                        FlushStrBuf(Mime->ContentType);
-                       StrBufAppendBufPlain(Mime->ContentType,
-                                            GuessMimeByFilename(SKEY(Mime->FileName)),
-                                            -1, 0);
+                       StrBufAppendBufPlain(Mime->ContentType, GuessMimeByFilename(SKEY(Mime->FileName)), -1, 0);
                }
        }
 }
 
-void tmplput_MAIL_SUMM_NATTACH(StrBuf *Target, WCTemplputParams *TP)
-{
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+void tmplput_MAIL_SUMM_NATTACH(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        StrBufAppendPrintf(Target, "%ld", GetCount(Msg->Attachments));
 }
 
-void examine_text(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
-{
+void examine_text(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        if (Msg->MsgBody->Data == NULL)
                Msg->MsgBody->Data = NewStrBufPlain(NULL, SIZ);
        else
                FlushStrBuf(Msg->MsgBody->Data);
 }
 
-void examine_msg4_partnum(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
-{
+void examine_msg4_partnum(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        Msg->MsgBody->PartNum = NewStrBufDup(HdrLine);
        StrBufTrim(Msg->MsgBody->PartNum);
 }
 
-void examine_content_lengh(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
-{
+void examine_content_lengh(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        Msg->MsgBody->length = StrTol(HdrLine);
        Msg->MsgBody->size_known = 1;
 }
 
-void examine_content_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
-{
+void examine_content_type(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        StrBuf *Token;
        StrBuf *Value;
-       const charsem;
+       const char *sem;
        const char *eq;
        int len;
        StrBufTrim(HdrLine);
@@ -848,7 +768,7 @@ void examine_content_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCh
                StrBufCutAt(Msg->MsgBody->ContentType, len, NULL);
                while (sem != NULL) {
                        while (isspace(*(sem + 1)))
-                               sem ++;
+                               sem++;
                        StrBufCutLeft(HdrLine, sem - ChrPtr(HdrLine));
                        sem = strchr(ChrPtr(HdrLine), ';');
                        if (sem != NULL)
@@ -861,7 +781,7 @@ void examine_content_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCh
                        eq = strchr(ChrPtr(Token), '=');
                        if (eq != NULL) {
                                len = eq - ChrPtr(Token);
-                               StrBufAppendBufPlain(Value, eq + 1, StrLength(Token) - len - 1, 0); 
+                               StrBufAppendBufPlain(Value, eq + 1, StrLength(Token) - len - 1, 0);
                                StrBufCutAt(Token, len, NULL);
                                StrBufTrim(Value);
                        }
@@ -876,45 +796,38 @@ void examine_content_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCh
 }
 
 
-int ReadOneMessageSummary(message_summary *Msg, StrBuf *FoundCharset, StrBuf *Buf)
-{
+int ReadOneMessageSummary(message_summary * Msg, StrBuf * FoundCharset, StrBuf * Buf) {
        const char *buf;
        const char *ebuf;
        int nBuf;
        long len;
-       
+
        serv_printf("MSG0 %ld|1", Msg->msgnum); /* ask for headers only */
-       
+
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) != 1) {
                return 0;
        }
 
-       while (len = StrBuf_ServGetln(Buf),
-              (len >= 0) && 
-              ((len != 3)  ||
-               strcmp(ChrPtr(Buf), "000")))
-       {
+       while (len = StrBuf_ServGetln(Buf), (len >= 0) && ((len != 3) || strcmp(ChrPtr(Buf), "000"))) {
                buf = ChrPtr(Buf);
                ebuf = strchr(ChrPtr(Buf), '=');
                nBuf = ebuf - buf;
-               
+
                if (EvaluateMsgHdr(buf, nBuf, Msg, Buf, FoundCharset) < 0)
                        syslog(LOG_INFO, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf));
        }
        return 1;
 }
 
-void tmplput_MAIL_SUMM_N(StrBuf *Target, WCTemplputParams *TP)
-{
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+void tmplput_MAIL_SUMM_N(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        StrBufAppendPrintf(Target, "%ld", Msg->msgnum);
 }
 
 
-void tmplput_MAIL_SUMM_PERMALINK(StrBuf *Target, WCTemplputParams *TP)
-{
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+void tmplput_MAIL_SUMM_PERMALINK(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        StrBuf *perma_link;
        const StrBuf *View;
 
@@ -932,34 +845,29 @@ void tmplput_MAIL_SUMM_PERMALINK(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-int Conditional_MAIL_MIME_ALL(StrBuf *Target, WCTemplputParams *TP)
-{
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+int Conditional_MAIL_MIME_ALL(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        return GetCount(Msg->Attachments) > 0;
 }
 
-int Conditional_MAIL_MIME_SUBMESSAGES(StrBuf *Target, WCTemplputParams *TP)
-{
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+int Conditional_MAIL_MIME_SUBMESSAGES(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        return GetCount(Msg->Submessages) > 0;
 }
 
-int Conditional_MAIL_MIME_ATTACHLINKS(StrBuf *Target, WCTemplputParams *TP)
-{
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+int Conditional_MAIL_MIME_ATTACHLINKS(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        return GetCount(Msg->AttachLinks) > 0;
 }
 
-int Conditional_MAIL_MIME_ATTACH(StrBuf *Target, WCTemplputParams *TP)
-{
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+int Conditional_MAIL_MIME_ATTACH(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        return GetCount(Msg->AllAttach) > 0;
 }
 
-void tmplput_QUOTED_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_QUOTED_MAIL_BODY(StrBuf * Target, WCTemplputParams * TP) {
        const StrBuf *Mime;
-        long MsgNum;
+       long MsgNum;
        StrBuf *Buf;
 
        MsgNum = LBstr(TKEY(0));
@@ -969,10 +877,9 @@ void tmplput_QUOTED_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
        FreeStrBuf(&Buf);
 }
 
-void tmplput_EDIT_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_EDIT_MAIL_BODY(StrBuf * Target, WCTemplputParams * TP) {
        const StrBuf *Mime;
-        long MsgNum;
+       long MsgNum;
        StrBuf *Buf;
 
        MsgNum = LBstr(TKEY(0));
@@ -982,10 +889,9 @@ void tmplput_EDIT_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
        FreeStrBuf(&Buf);
 }
 
-void tmplput_EDIT_WIKI_BODY(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_EDIT_WIKI_BODY(StrBuf * Target, WCTemplputParams * TP) {
        const StrBuf *Mime;
-        long msgnum;
+       long msgnum;
        StrBuf *Buf;
 
        /* Insert the existing content of the wiki page into the editor.  But we only want
@@ -1007,15 +913,13 @@ void tmplput_EDIT_WIKI_BODY(StrBuf *Target, WCTemplputParams *TP)
        }
 }
 
-void tmplput_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
-{
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+void tmplput_MAIL_BODY(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        StrBufAppendTemplate(Target, TP, Msg->MsgBody->Data, 0);
 }
 
 
-void render_MAIL_variformat(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
-{
+void render_MAIL_variformat(StrBuf * Target, WCTemplputParams * TP, StrBuf * FoundCharset) {
        /* Messages in legacy Citadel variformat get handled thusly... */
        wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
        StrBuf *TTarget = NewStrBufPlain(NULL, StrLength(Mime->Data));
@@ -1024,8 +928,7 @@ void render_MAIL_variformat(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundC
        Mime->Data = TTarget;
 }
 
-void render_MAIL_text_plain(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
-{
+void render_MAIL_text_plain(StrBuf * Target, WCTemplputParams * TP, StrBuf * FoundCharset) {
        wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
        const char *ptr, *pte;
        const char *BufPtr = NULL;
@@ -1042,7 +945,7 @@ void render_MAIL_text_plain(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundC
 #ifdef HAVE_ICONV
        StrBuf *cs = NULL;
        int ConvertIt = 1;
-       iconv_t ic = (iconv_t)(-1) ;
+       iconv_t ic = (iconv_t) (-1);
 #endif
 
        if ((StrLength(Mime->Data) == 0) && (Mime->length > 0)) {
@@ -1069,9 +972,9 @@ void render_MAIL_text_plain(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundC
                }
                else {
                        ctdl_iconv_open("UTF-8", ChrPtr(cs), &ic);
-                       if (ic == (iconv_t)(-1) ) {
+                       if (ic == (iconv_t) (-1)) {
                                syslog(LOG_WARNING, "%s:%d iconv_open(UTF-8, %s) failed: %s\n",
-                                       __FILE__, __LINE__, ChrPtr(Mime->Charset), strerror(errno));
+                                      __FILE__, __LINE__, ChrPtr(Mime->Charset), strerror(errno));
                        }
                }
        }
@@ -1082,39 +985,36 @@ void render_MAIL_text_plain(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundC
        TTarget = NewStrBufPlain(NULL, StrLength(Mime->Data));
        Linecount = 0;
        nEmptyLines = 0;
-       if (StrLength(Mime->Data) > 0) 
-               do 
-               {
+       if (StrLength(Mime->Data) > 0)
+               do {
                        StrBufSipLine(Line, Mime->Data, &BufPtr);
                        bq = 0;
                        i = 0;
                        ptr = ChrPtr(Line);
                        len = StrLength(Line);
                        pte = ptr + len;
-               
-                       while ((ptr < pte) &&
-                              ((*ptr == '>') ||
-                               isspace(*ptr)))
-                       {
+
+                       while ((ptr < pte) && ((*ptr == '>') || isspace(*ptr))) {
                                if (*ptr == '>')
                                        bq++;
-                               ptr ++;
+                               ptr++;
                                i++;
                        }
-                       if (i > 0) StrBufCutLeft(Line, i);
-               
+                       if (i > 0)
+                               StrBufCutLeft(Line, i);
+
                        if (StrLength(Line) == 0) {
                                if (Linecount == 0)
                                        continue;
                                StrBufAppendBufPlain(TTarget, HKEY("<tt></tt><br>\n"), 0);
 
-                               nEmptyLines ++;
+                               nEmptyLines++;
                                continue;
                        }
                        nEmptyLines = 0;
-                       for (i = bn; i < bq; i++)                               
+                       for (i = bn; i < bq; i++)
                                StrBufAppendBufPlain(TTarget, HKEY("<blockquote>"), 0);
-                       for (i = bq; i < bn; i++)                               
+                       for (i = bq; i < bn; i++)
                                StrBufAppendBufPlain(TTarget, HKEY("</blockquote>"), 0);
 #ifdef HAVE_ICONV
                        if (ConvertIt) {
@@ -1127,19 +1027,18 @@ void render_MAIL_text_plain(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundC
                        StrEscAppend(TTarget, Line1, NULL, 0, 0);
                        StrBufAppendBufPlain(TTarget, HKEY("</tt><br>\n"), 0);
                        bn = bq;
-                       Linecount ++;
+                       Linecount++;
                }
-       while ((BufPtr != StrBufNOTNULL) &&
-              (BufPtr != NULL));
+               while ((BufPtr != StrBufNOTNULL) && (BufPtr != NULL));
 
        if (nEmptyLines > 0)
-               StrBufCutRight(TTarget, nEmptyLines * (sizeof ("<tt></tt><br>\n") - 1));
-       for (i = 0; i < bn; i++)                                
+               StrBufCutRight(TTarget, nEmptyLines * (sizeof("<tt></tt><br>\n") - 1));
+       for (i = 0; i < bn; i++)
                StrBufAppendBufPlain(TTarget, HKEY("</blockquote>"), 0);
 
        StrBufAppendBufPlain(TTarget, HKEY("</i><br>"), 0);
 #ifdef HAVE_ICONV
-       if (ic != (iconv_t)(-1) ) {
+       if (ic != (iconv_t) (-1)) {
                iconv_close(ic);
        }
 #endif
@@ -1155,8 +1054,7 @@ void render_MAIL_text_plain(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundC
        FreeStrBuf(&Line2);
 }
 
-void render_MAIL_html(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
-{
+void render_MAIL_html(StrBuf * Target, WCTemplputParams * TP, StrBuf * FoundCharset) {
        wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
        StrBuf *Buf;
 
@@ -1166,17 +1064,13 @@ void render_MAIL_html(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset
        Buf = NewStrBufPlain(NULL, StrLength(Mime->Data));
 
        /* HTML is fun, but we've got to strip it first */
-       output_html(ChrPtr(Mime->Charset), 
-                   (WC->CurRoom.view == VIEW_WIKI ? 1 : 0), 
-                   Mime->msgnum,
-                   Mime->Data, Buf);
+       output_html(ChrPtr(Mime->Charset), (WC->CurRoom.view == VIEW_WIKI ? 1 : 0), Mime->msgnum, Mime->Data, Buf);
        FreeStrBuf(&Mime->Data);
        Mime->Data = Buf;
 }
 
 
-void render_MAIL_UNKNOWN(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
-{
+void render_MAIL_UNKNOWN(StrBuf * Target, WCTemplputParams * TP, StrBuf * FoundCharset) {
        wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
        /* Unknown weirdness */
        FlushStrBuf(Mime->Data);
@@ -1186,173 +1080,148 @@ void render_MAIL_UNKNOWN(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundChar
 }
 
 
-HashList *iterate_get_mime_All(StrBuf *Target, WCTemplputParams *TP)
-{
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+HashList *iterate_get_mime_All(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        return Msg->Attachments;
 }
-HashList *iterate_get_mime_Submessages(StrBuf *Target, WCTemplputParams *TP)
-{
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+HashList *iterate_get_mime_Submessages(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        return Msg->Submessages;
 }
-HashList *iterate_get_mime_AttachLinks(StrBuf *Target, WCTemplputParams *TP)
-{
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+HashList *iterate_get_mime_AttachLinks(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        return Msg->AttachLinks;
 }
-HashList *iterate_get_mime_Attachments(StrBuf *Target, WCTemplputParams *TP)
-{
-       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+HashList *iterate_get_mime_Attachments(StrBuf * Target, WCTemplputParams * TP) {
+       message_summary *Msg = (message_summary *) CTX(CTX_MAILSUM);
        return Msg->AllAttach;
 }
 
-void tmplput_MIME_Name(StrBuf *Target, WCTemplputParams *TP)
-{
-       wc_mime_attachment *mime = (wc_mime_attachment*) CTX(CTX_MIME_ATACH);
+void tmplput_MIME_Name(StrBuf * Target, WCTemplputParams * TP) {
+       wc_mime_attachment *mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
        StrBufAppendTemplate(Target, TP, mime->Name, 0);
 }
 
-void tmplput_MIME_FileName(StrBuf *Target, WCTemplputParams *TP)
-{
-       wc_mime_attachment *mime = (wc_mime_attachment*) CTX(CTX_MIME_ATACH);
+void tmplput_MIME_FileName(StrBuf * Target, WCTemplputParams * TP) {
+       wc_mime_attachment *mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
        StrBufAppendTemplate(Target, TP, mime->FileName, 0);
 }
 
-void tmplput_MIME_PartNum(StrBuf *Target, WCTemplputParams *TP)
-{
-       wc_mime_attachment *mime = (wc_mime_attachment*) CTX(CTX_MIME_ATACH);
+void tmplput_MIME_PartNum(StrBuf * Target, WCTemplputParams * TP) {
+       wc_mime_attachment *mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
        StrBufAppendTemplate(Target, TP, mime->PartNum, 0);
 }
 
-void tmplput_MIME_MsgNum(StrBuf *Target, WCTemplputParams *TP)
-{
-       wc_mime_attachment *mime = (wc_mime_attachment*) CTX(CTX_MIME_ATACH);
+void tmplput_MIME_MsgNum(StrBuf * Target, WCTemplputParams * TP) {
+       wc_mime_attachment *mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
        StrBufAppendPrintf(Target, "%ld", mime->msgnum);
 }
 
-void tmplput_MIME_Disposition(StrBuf *Target, WCTemplputParams *TP)
-{
-       wc_mime_attachment *mime = (wc_mime_attachment*) CTX(CTX_MIME_ATACH);
+void tmplput_MIME_Disposition(StrBuf * Target, WCTemplputParams * TP) {
+       wc_mime_attachment *mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
        StrBufAppendTemplate(Target, TP, mime->Disposition, 0);
 }
 
-void tmplput_MIME_ContentType(StrBuf *Target, WCTemplputParams *TP)
-{
-       wc_mime_attachment *mime = (wc_mime_attachment*) CTX(CTX_MIME_ATACH);
+void tmplput_MIME_ContentType(StrBuf * Target, WCTemplputParams * TP) {
+       wc_mime_attachment *mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
        StrBufAppendTemplate(Target, TP, mime->ContentType, 0);
 }
 
-void examine_charset(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
-{
+void examine_charset(message_summary * Msg, StrBuf * HdrLine, StrBuf * FoundCharset) {
        Msg->MsgBody->Charset = NewStrBufDup(HdrLine);
 }
 
-void tmplput_MIME_Charset(StrBuf *Target, WCTemplputParams *TP)
-{
-       wc_mime_attachment *mime = (wc_mime_attachment*) CTX(CTX_MIME_ATACH);
+void tmplput_MIME_Charset(StrBuf * Target, WCTemplputParams * TP) {
+       wc_mime_attachment *mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
        StrBufAppendTemplate(Target, TP, mime->Charset, 0);
 }
 
-void tmplput_MIME_Data(StrBuf *Target, WCTemplputParams *TP)
-{
-       wc_mime_attachment *mime = (wc_mime_attachment*) CTX(CTX_MIME_ATACH);
+void tmplput_MIME_Data(StrBuf * Target, WCTemplputParams * TP) {
+       wc_mime_attachment *mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
        if (mime->Renderer != NULL)
                mime->Renderer->f(Target, TP, NULL);
        StrBufAppendTemplate(Target, TP, mime->Data, 0);
        /* TODO: check whether we need to load it now? */
 }
 
-void tmplput_MIME_LoadData(StrBuf *Target, WCTemplputParams *TP)
-{
-       wcsession *WCC = WC;    
-       wc_mime_attachment *mime = (wc_mime_attachment*) CTX(CTX_MIME_ATACH);
+void tmplput_MIME_LoadData(StrBuf * Target, WCTemplputParams * TP) {
+       wcsession *WCC = WC;
+       wc_mime_attachment *mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
        wc_mime_attachment *att;
-       
-       if (( (!strcasecmp(ChrPtr(mime->Disposition), "inline"))||
-             (!strcasecmp(ChrPtr(mime->Disposition), "attachment"))) && 
-           (strcasecmp(ChrPtr(mime->ContentType), "application/ms-tnef")!=0))
-       {
-               
-               int n;
-               char N[64];
-               /* steal this mime part... */
-               att = malloc(sizeof(wc_mime_attachment));
-               memcpy(att, mime, sizeof(wc_mime_attachment));
-               memset(mime, 0, sizeof(wc_mime_attachment));
-
-               if (att->Data == NULL) 
+
+       if (((!strcasecmp(ChrPtr(mime->Disposition), "inline")) ||
+            (!strcasecmp(ChrPtr(mime->Disposition), "attachment"))) &&
+           (strcasecmp(ChrPtr(mime->ContentType), "application/ms-tnef") != 0)) {
+
+               int n;
+               char N[64];
+               /* steal this mime part... */
+               att = malloc(sizeof(wc_mime_attachment));
+               memcpy(att, mime, sizeof(wc_mime_attachment));
+               memset(mime, 0, sizeof(wc_mime_attachment));
+
+               if (att->Data == NULL)
                        MimeLoadData(att);
 
-               if (WCC->attachments == NULL)
-                       WCC->attachments = NewHash(1, NULL);
-               /* And add it to the list. */
-               n = snprintf(N, sizeof N, "%d", GetCount(WCC->attachments) + 1);
-               Put(WCC->attachments, N, n, att, DestroyMime);
-       }
+               if (WCC->attachments == NULL)
+                       WCC->attachments = NewHash(1, NULL);
+               /* And add it to the list. */
+               n = snprintf(N, sizeof N, "%d", GetCount(WCC->attachments) + 1);
+               Put(WCC->attachments, N, n, att, DestroyMime);
+       }
 }
 
-void tmplput_MIME_Length(StrBuf *Target, WCTemplputParams *TP)
-{
-       wc_mime_attachment *mime = (wc_mime_attachment*) CTX(CTX_MIME_ATACH);
+void tmplput_MIME_Length(StrBuf * Target, WCTemplputParams * TP) {
+       wc_mime_attachment *mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
        StrBufAppendPrintf(Target, "%ld", mime->length);
 }
 
-HashList *iterate_get_registered_Attachments(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *iterate_get_registered_Attachments(StrBuf * Target, WCTemplputParams * TP) {
        return WC->attachments;
 }
 
-void get_registered_Attachments_Count(StrBuf *Target, WCTemplputParams *TP)
-{
-       StrBufAppendPrintf(Target, "%ld", GetCount (WC->attachments));
+void get_registered_Attachments_Count(StrBuf * Target, WCTemplputParams * TP) {
+       StrBufAppendPrintf(Target, "%ld", GetCount(WC->attachments));
 }
 
-void servcmd_do_search(char *buf, long bufsize)
-{
+void servcmd_do_search(char *buf, long bufsize) {
        snprintf(buf, bufsize, "MSGS SEARCH|%s", bstr("query"));
 }
 
-void servcmd_headers(char *buf, long bufsize)
-{
+void servcmd_headers(char *buf, long bufsize) {
        snprintf(buf, bufsize, "MSGS ALL");
 }
 
-void servcmd_readfwd(char *buf, long bufsize)
-{
+void servcmd_readfwd(char *buf, long bufsize) {
        snprintf(buf, bufsize, "MSGS ALL");
 }
 
-void servcmd_readgt(char *buf, long bufsize)
-{
+void servcmd_readgt(char *buf, long bufsize) {
        snprintf(buf, bufsize, "MSGS GT|%s", bstr("gt"));
 }
 
-void servcmd_readlt(char *buf, long bufsize)
-{
+void servcmd_readlt(char *buf, long bufsize) {
        snprintf(buf, bufsize, "MSGS LT|%s", bstr("lt"));
 }
 
-void servcmd_readnew(char *buf, long bufsize)
-{
+void servcmd_readnew(char *buf, long bufsize) {
        snprintf(buf, bufsize, "MSGS NEW");
 }
 
-void servcmd_readold(char *buf, long bufsize)
-{
+void servcmd_readold(char *buf, long bufsize) {
        snprintf(buf, bufsize, "MSGS OLD");
 }
 
 
 /* DO NOT REORDER OR REMOVE ANY OF THESE */
 readloop_struct rlid[] = {
-       { {HKEY("do_search")},  servcmd_do_search       },
-       { {HKEY("headers")},    servcmd_headers         },
-       { {HKEY("readfwd")},    servcmd_readfwd         },
-       { {HKEY("readnew")},    servcmd_readnew         },
-       { {HKEY("readold")},    servcmd_readold         },
-       { {HKEY("readgt")},     servcmd_readgt          },
-       { {HKEY("readlt")},     servcmd_readlt          }
+       { { HKEY("do_search")}, servcmd_do_search },
+       { { HKEY("headers")}, servcmd_headers },
+       { { HKEY("readfwd")}, servcmd_readfwd },
+       { { HKEY("readnew")}, servcmd_readnew },
+       { { HKEY("readold")}, servcmd_readold },
+       { { HKEY("readgt")}, servcmd_readgt },
+       { { HKEY("readlt")}, servcmd_readlt }
 };
 
 
@@ -1361,32 +1230,33 @@ readloop_struct rlid[] = {
  * TODO: figure out who did this and beat them with a wet noodle.
  */
 const char *fieldMnemonics[] = {
-       "from", /* A -> eAuthor       */
-       "exti", /* E -> eXclusivID    */
-       "rfca", /* F -> erFc822Addr   */
-       "msgn", /* I -> emessageId    */
-       "jrnl", /* J -> eJournal      */
-       "rep2", /* K -> eReplyTo      */
-       "list", /* L -> eListID       */
-       "text", /* M -> eMesageText   */
-       "locl", /*      eIsLocal      */
-       "path", /* P -> eMessagePath  */
-       "rcpt", /* R -> eRecipient    */
-       "spec", /* S -> eSpecialField */
-       "time", /* T -> eTimestamp    */
-       "subj", /* U -> eMsgSubject   */
-       "nvto", /* V -> eenVelopeTo   */
-       "wefw", /* W -> eWeferences   */
-       "cccc", /* Y -> eCarbonCopY   */
-       "nhdr", /*      eHeaderOnly   */
-       "type", /*      eFormatType   */
-       "part", /*      eMessagePart  */
-       "suff"  /*      eSubFolder    */
+       "from",                 /* A -> eAuthor       */
+       "exti",                 /* E -> eXclusivID    */
+       "rfca",                 /* F -> erFc822Addr   */
+       "msgn",                 /* I -> emessageId    */
+       "jrnl",                 /* J -> eJournal      */
+       "rep2",                 /* K -> eReplyTo      */
+       "list",                 /* L -> eListID       */
+       "text",                 /* M -> eMesageText   */
+       "locl",                 /*      eIsLocal      */
+       "path",                 /* P -> eMessagePath  */
+       "rcpt",                 /* R -> eRecipient    */
+       "spec",                 /* S -> eSpecialField */
+       "time",                 /* T -> eTimestamp    */
+       "subj",                 /* U -> eMsgSubject   */
+       "nvto",                 /* V -> eenVelopeTo   */
+       "wefw",                 /* W -> eWeferences   */
+       "cccc",                 /* Y -> eCarbonCopY   */
+       "nhdr",                 /*      eHeaderOnly   */
+       "type",                 /*      eFormatType   */
+       "part",                 /*      eMessagePart  */
+       "suff"                  /*      eSubFolder    */
 };
+
 HashList *msgKeyLookup = NULL;
 
 
-int GetFieldFromMnemonic(eMessageField *f, const char *c) {
+int GetFieldFromMnemonic(eMessageField * f, const char *c) {
        void *v = NULL;
        if (GetHash(msgKeyLookup, c, 4, &v)) {
                *f = (eMessageField) v;
@@ -1399,70 +1269,52 @@ int GetFieldFromMnemonic(eMessageField *f, const char *c) {
 void FillMsgKeyLookupTable(void) {
        long i = 0;
 
-       msgKeyLookup = NewHash (1, FourHash);
-       for (i=0; i<eLastHeader; ++i) {
+       msgKeyLookup = NewHash(1, FourHash);
+       for (i = 0; i < eLastHeader; ++i) {
                if (fieldMnemonics[i] != NULL) {
-                       Put(msgKeyLookup, fieldMnemonics[i], 4, (void*)i, reference_free_handler);
+                       Put(msgKeyLookup, fieldMnemonics[i], 4, (void *) i, reference_free_handler);
                }
        }
 }
 
 
-void 
-InitModule_MSGRENDERERS
-(void)
-{
+void InitModule_MSGRENDERERS(void) {
        RegisterCTX(CTX_MAILSUM);
        RegisterCTX(CTX_MIME_ATACH);
 
-       RegisterSortFunc(HKEY("date"), 
-                        NULL, 0,
-                        summcmp_date,
-                        summcmp_rdate,
-                        groupchange_date,
-                        CTX_MAILSUM);
-       RegisterSortFunc(HKEY("subject"), 
-                        NULL, 0,
-                        summcmp_subj,
-                        summcmp_rsubj,
-                        groupchange_subj,
-                        CTX_MAILSUM);
-       RegisterSortFunc(HKEY("sender"),
-                        NULL, 0,
-                        summcmp_sender,
-                        summcmp_rsender,
-                        groupchange_sender,
-                        CTX_MAILSUM);
+       RegisterSortFunc(HKEY("date"), NULL, 0, summcmp_date, summcmp_rdate, groupchange_date, CTX_MAILSUM);
+       RegisterSortFunc(HKEY("subject"), NULL, 0, summcmp_subj, summcmp_rsubj, groupchange_subj, CTX_MAILSUM);
+       RegisterSortFunc(HKEY("sender"), NULL, 0, summcmp_sender, summcmp_rsender, groupchange_sender, CTX_MAILSUM);
 
        RegisterNamespace("SUMM:COUNT", 0, 0, tmplput_SUMM_COUNT, NULL, CTX_NONE);
 
        /* iterate over all known mails in WC->summ */
-       RegisterIterator("MAIL:SUMM:MSGS", 0, NULL, iterate_get_mailsumm_All, NULL,NULL, CTX_MAILSUM, CTX_NONE, IT_NOFLAG);
+       RegisterIterator("MAIL:SUMM:MSGS", 0, NULL, iterate_get_mailsumm_All, NULL, NULL, CTX_MAILSUM, CTX_NONE, IT_NOFLAG);
 
        RegisterNamespace("MAIL:SUMM:EUID", 0, 1, tmplput_MAIL_SUMM_EUID, NULL, CTX_MAILSUM);
        RegisterNamespace("MAIL:SUMM:DATEBRIEF", 0, 0, tmplput_MAIL_SUMM_DATE_BRIEF, NULL, CTX_MAILSUM);
        RegisterNamespace("MAIL:SUMM:DATEFULL", 0, 0, tmplput_MAIL_SUMM_DATE_FULL, NULL, CTX_MAILSUM);
-       RegisterNamespace("MAIL:SUMM:DATENO",  0, 0, tmplput_MAIL_SUMM_DATE_NO,  NULL, CTX_MAILSUM);
-       RegisterNamespace("MAIL:SUMM:N",       0, 0, tmplput_MAIL_SUMM_N,        NULL, CTX_MAILSUM);
+       RegisterNamespace("MAIL:SUMM:DATENO", 0, 0, tmplput_MAIL_SUMM_DATE_NO, NULL, CTX_MAILSUM);
+       RegisterNamespace("MAIL:SUMM:N", 0, 0, tmplput_MAIL_SUMM_N, NULL, CTX_MAILSUM);
        RegisterNamespace("MAIL:SUMM:PERMALINK", 0, 0, tmplput_MAIL_SUMM_PERMALINK, NULL, CTX_MAILSUM);
-       RegisterNamespace("MAIL:SUMM:FROM",    0, 2, tmplput_MAIL_SUMM_FROM,     NULL, CTX_MAILSUM);
-       RegisterNamespace("MAIL:SUMM:TO",      0, 2, tmplput_MAIL_SUMM_TO,       NULL, CTX_MAILSUM);
-       RegisterNamespace("MAIL:SUMM:SUBJECT", 0, 4, tmplput_MAIL_SUMM_SUBJECT,  NULL, CTX_MAILSUM);
-       RegisterNamespace("MAIL:SUMM:NTATACH", 0, 0, tmplput_MAIL_SUMM_NATTACH,  NULL, CTX_MAILSUM);
+       RegisterNamespace("MAIL:SUMM:FROM", 0, 2, tmplput_MAIL_SUMM_FROM, NULL, CTX_MAILSUM);
+       RegisterNamespace("MAIL:SUMM:TO", 0, 2, tmplput_MAIL_SUMM_TO, NULL, CTX_MAILSUM);
+       RegisterNamespace("MAIL:SUMM:SUBJECT", 0, 4, tmplput_MAIL_SUMM_SUBJECT, NULL, CTX_MAILSUM);
+       RegisterNamespace("MAIL:SUMM:NTATACH", 0, 0, tmplput_MAIL_SUMM_NATTACH, NULL, CTX_MAILSUM);
        RegisterNamespace("MAIL:SUMM:CCCC", 0, 2, tmplput_MAIL_SUMM_CCCC, NULL, CTX_MAILSUM);
        RegisterNamespace("MAIL:SUMM:REPLYTO", 0, 2, tmplput_MAIL_SUMM_REPLYTO, NULL, CTX_MAILSUM);
-       RegisterNamespace("MAIL:SUMM:ALLRCPT", 0, 2, tmplput_MAIL_SUMM_ALLRCPT,  NULL, CTX_MAILSUM);
-       RegisterNamespace("MAIL:SUMM:ORGROOM", 0, 2, tmplput_MAIL_SUMM_ORGROOM,  NULL, CTX_MAILSUM);
+       RegisterNamespace("MAIL:SUMM:ALLRCPT", 0, 2, tmplput_MAIL_SUMM_ALLRCPT, NULL, CTX_MAILSUM);
+       RegisterNamespace("MAIL:SUMM:ORGROOM", 0, 2, tmplput_MAIL_SUMM_ORGROOM, NULL, CTX_MAILSUM);
        RegisterNamespace("MAIL:SUMM:RFCA", 0, 2, tmplput_MAIL_SUMM_RFCA, NULL, CTX_MAILSUM);
-       RegisterNamespace("MAIL:SUMM:REFIDS", 0, 1, tmplput_MAIL_SUMM_REFIDS,  NULL, CTX_MAILSUM);
-       RegisterNamespace("MAIL:SUMM:INREPLYTO", 0, 2, tmplput_MAIL_SUMM_INREPLYTO,  NULL, CTX_MAILSUM);
-       RegisterNamespace("MAIL:BODY", 0, 2, tmplput_MAIL_BODY,  NULL, CTX_MAILSUM);
-       RegisterNamespace("MAIL:QUOTETEXT", 1, 2, tmplput_QUOTED_MAIL_BODY,  NULL, CTX_NONE);
-       RegisterNamespace("MAIL:EDITTEXT", 1, 2, tmplput_EDIT_MAIL_BODY,  NULL, CTX_NONE);
-       RegisterNamespace("MAIL:EDITWIKI", 1, 2, tmplput_EDIT_WIKI_BODY,  NULL, CTX_NONE);
-       RegisterConditional("COND:MAIL:SUMM:RFCA", 0, Conditional_MAIL_SUMM_RFCA,  CTX_MAILSUM);
-       RegisterConditional("COND:MAIL:SUMM:CCCC", 0, Conditional_MAIL_SUMM_CCCC,  CTX_MAILSUM);
-       RegisterConditional("COND:MAIL:SUMM:REPLYTO", 0, Conditional_MAIL_SUMM_REPLYTO,  CTX_MAILSUM);
+       RegisterNamespace("MAIL:SUMM:REFIDS", 0, 1, tmplput_MAIL_SUMM_REFIDS, NULL, CTX_MAILSUM);
+       RegisterNamespace("MAIL:SUMM:INREPLYTO", 0, 2, tmplput_MAIL_SUMM_INREPLYTO, NULL, CTX_MAILSUM);
+       RegisterNamespace("MAIL:BODY", 0, 2, tmplput_MAIL_BODY, NULL, CTX_MAILSUM);
+       RegisterNamespace("MAIL:QUOTETEXT", 1, 2, tmplput_QUOTED_MAIL_BODY, NULL, CTX_NONE);
+       RegisterNamespace("MAIL:EDITTEXT", 1, 2, tmplput_EDIT_MAIL_BODY, NULL, CTX_NONE);
+       RegisterNamespace("MAIL:EDITWIKI", 1, 2, tmplput_EDIT_WIKI_BODY, NULL, CTX_NONE);
+       RegisterConditional("COND:MAIL:SUMM:RFCA", 0, Conditional_MAIL_SUMM_RFCA, CTX_MAILSUM);
+       RegisterConditional("COND:MAIL:SUMM:CCCC", 0, Conditional_MAIL_SUMM_CCCC, CTX_MAILSUM);
+       RegisterConditional("COND:MAIL:SUMM:REPLYTO", 0, Conditional_MAIL_SUMM_REPLYTO, CTX_MAILSUM);
        RegisterConditional("COND:MAIL:SUMM:UNREAD", 0, Conditional_MAIL_SUMM_UNREAD, CTX_MAILSUM);
        RegisterConditional("COND:MAIL:SUMM:SUBJECT", 0, Conditional_MAIL_SUMM_SUBJECT, CTX_MAILSUM);
        RegisterConditional("COND:MAIL:ANON", 0, Conditional_ANONYMOUS_MESSAGE, CTX_MAILSUM);
@@ -1476,9 +1328,12 @@ InitModule_MSGRENDERERS
        RegisterConditional("COND:MAIL:MIME:ATTACH:LINKS", 0, Conditional_MAIL_MIME_ATTACHLINKS, CTX_MAILSUM);
        RegisterConditional("COND:MAIL:MIME:ATTACH:ATT", 0, Conditional_MAIL_MIME_ATTACH, CTX_MAILSUM);
        RegisterIterator("MAIL:MIME:ATTACH", 0, NULL, iterate_get_mime_All, NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
-       RegisterIterator("MAIL:MIME:ATTACH:SUBMESSAGES", 0, NULL, iterate_get_mime_Submessages, NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
-       RegisterIterator("MAIL:MIME:ATTACH:LINKS", 0, NULL, iterate_get_mime_AttachLinks, NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
-       RegisterIterator("MAIL:MIME:ATTACH:ATT", 0, NULL, iterate_get_mime_Attachments, NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
+       RegisterIterator("MAIL:MIME:ATTACH:SUBMESSAGES", 0, NULL, iterate_get_mime_Submessages, NULL, NULL, CTX_MIME_ATACH,
+                        CTX_MAILSUM, IT_NOFLAG);
+       RegisterIterator("MAIL:MIME:ATTACH:LINKS", 0, NULL, iterate_get_mime_AttachLinks, NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM,
+                        IT_NOFLAG);
+       RegisterIterator("MAIL:MIME:ATTACH:ATT", 0, NULL, iterate_get_mime_Attachments, NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM,
+                        IT_NOFLAG);
 
        /* Parts of a mime attachent */
        RegisterNamespace("MAIL:MIME:NAME", 0, 2, tmplput_MIME_Name, NULL, CTX_MIME_ATACH);
@@ -1495,8 +1350,9 @@ InitModule_MSGRENDERERS
        RegisterNamespace("MAIL:MIME:LOADDATA", 0, 0, tmplput_MIME_LoadData, NULL, CTX_MIME_ATACH);
 
        /* iterate the WC->attachments; use the above tokens for their contents */
-       RegisterIterator("MSG:ATTACHNAMES", 0, NULL, iterate_get_registered_Attachments, NULL, NULL, CTX_MIME_ATACH, CTX_NONE, IT_NOFLAG);
-       RegisterNamespace("MSG:NATTACH", 0, 0, get_registered_Attachments_Count,  NULL, CTX_NONE);
+       RegisterIterator("MSG:ATTACHNAMES", 0, NULL, iterate_get_registered_Attachments, NULL, NULL, CTX_MIME_ATACH, CTX_NONE,
+                        IT_NOFLAG);
+       RegisterNamespace("MSG:NATTACH", 0, 0, get_registered_Attachments_Count, NULL, CTX_NONE);
 
        /* mime renderers translate an attachment into webcit viewable html text */
        RegisterMimeRenderer(HKEY("message/rfc822"), render_MAIL, 0, 150);
@@ -1534,7 +1390,7 @@ InitModule_MSGRENDERERS
        RegisterMsgHdr(HKEY("X-Citadel-MSG4-Partnum"), examine_msg4_partnum, 0);
        RegisterMsgHdr(HKEY("Content-type"), examine_content_type, 0);
        RegisterMsgHdr(HKEY("Content-length"), examine_content_lengh, 0);
-       RegisterMsgHdr(HKEY("Content-transfer-encoding"), examine_content_encoding, 0); /* do we care? */
+       RegisterMsgHdr(HKEY("Content-transfer-encoding"), examine_content_encoding, 0); /* do we care? */
        RegisterMsgHdr(HKEY("charset"), examine_charset, 0);
 
        /* Don't care about these... */
@@ -1543,29 +1399,21 @@ InitModule_MSGRENDERERS
        RegisterMsgHdr(HKEY("path"), examine_path, 0);
 }
 
-void 
-InitModule2_MSGRENDERERS
-(void)
-{
+void InitModule2_MSGRENDERERS(void) {
        /* and finalize the anouncement to the server... */
        CreateMimeStr();
 }
-void 
-ServerStartModule_MSGRENDERERS
-(void)
-{
-       DflMsgHeaderHandler = NewHash (1, FourHash);
-       DflEnumMsgHeaderHandler = NewHash (1, Flathash);
+
+void ServerStartModule_MSGRENDERERS(void) {
+       DflMsgHeaderHandler = NewHash(1, FourHash);
+       DflEnumMsgHeaderHandler = NewHash(1, Flathash);
        MsgHeaderHandler = NewHash(1, NULL);
        MimeRenderHandler = NewHash(1, NULL);
        ReadLoopHandler = NewHash(1, NULL);
        FillMsgKeyLookupTable();
 }
 
-void 
-ServerShutdownModule_MSGRENDERERS
-(void)
-{
+void ServerShutdownModule_MSGRENDERERS(void) {
        DeleteHash(&DflMsgHeaderHandler);
        DeleteHash(&DflEnumMsgHeaderHandler);
 
@@ -1576,10 +1424,7 @@ ServerShutdownModule_MSGRENDERERS
        DeleteHash(&msgKeyLookup);
 }
 
-void 
-SessionDestroyModule_MSGRENDERERS
-(wcsession *sess)
-{
+void SessionDestroyModule_MSGRENDERERS(wcsession * sess) {
        DeleteHash(&sess->attachments);
        FreeStrBuf(&sess->ConvertBuf1);
        FreeStrBuf(&sess->ConvertBuf2);
index 83c391429c95aa0d7a4b10fed5706fa6facda289..2082499035809ae66409caa04f8497df697ce3df 100644 (file)
@@ -3,8 +3,11 @@
 void display_netconf(void);
 
 CtxType CTX_NODECONF = CTX_NONE;
+
 /*----------------------------------------------------------------------*/
+
 /*              Business Logic                                          */
+
 /*----------------------------------------------------------------------*/
 
 typedef struct _nodeconf {
@@ -13,11 +16,10 @@ typedef struct _nodeconf {
        StrBuf *Secret;
        StrBuf *Host;
        StrBuf *Port;
-}NodeConf;
+} NodeConf;
 
-void DeleteNodeConf(void *vNode)
-{
-       NodeConf *Node = (NodeConf*) vNode;
+void DeleteNodeConf(void *vNode) {
+       NodeConf *Node = (NodeConf *) vNode;
        FreeStrBuf(&Node->NodeName);
        FreeStrBuf(&Node->Secret);
        FreeStrBuf(&Node->Host);
@@ -25,33 +27,29 @@ void DeleteNodeConf(void *vNode)
        free(Node);
 }
 
-NodeConf *NewNode(StrBuf *SerializedNode)
-{
+NodeConf *NewNode(StrBuf * SerializedNode) {
        NodeConf *Node;
 
-       if (StrLength(SerializedNode) < 8) 
+       if (StrLength(SerializedNode) < 8)
+
                return NULL; /** we need at least 4 pipes and some other text so its invalid. */
        Node = (NodeConf *) malloc(sizeof(NodeConf));
        Node->DeleteMe = 0;
-       Node->NodeName=NewStrBuf();
+       Node->NodeName = NewStrBuf();
        StrBufExtract_token(Node->NodeName, SerializedNode, 0, '|');
-       Node->Secret=NewStrBuf();
+       Node->Secret = NewStrBuf();
        StrBufExtract_token(Node->Secret, SerializedNode, 1, '|');
-       Node->Host=NewStrBuf();
+       Node->Host = NewStrBuf();
        StrBufExtract_token(Node->Host, SerializedNode, 2, '|');
-       Node->Port=NewStrBuf();
+       Node->Port = NewStrBuf();
        StrBufExtract_token(Node->Port, SerializedNode, 3, '|');
        return Node;
 }
 
-NodeConf *HttpGetNewNode(void)
-{
+NodeConf *HttpGetNewNode(void) {
        NodeConf *Node;
 
-       if (!havebstr("node") || 
-           !havebstr("secret")||
-           !havebstr("host")||
-           !havebstr("port"))
+       if (!havebstr("node") || !havebstr("secret") || !havebstr("host") || !havebstr("port"))
                return NULL;
 
        Node = (NodeConf *) malloc(sizeof(NodeConf));
@@ -63,18 +61,12 @@ NodeConf *HttpGetNewNode(void)
        return Node;
 }
 
-void SerializeNode(NodeConf *Node, StrBuf *Buf)
-{
-       StrBufPrintf(Buf, "%s|%s|%s|%s", 
-                    ChrPtr(Node->NodeName),
-                    ChrPtr(Node->Secret),
-                    ChrPtr(Node->Host),
-                    ChrPtr(Node->Port));
+void SerializeNode(NodeConf * Node, StrBuf * Buf) {
+       StrBufPrintf(Buf, "%s|%s|%s|%s", ChrPtr(Node->NodeName), ChrPtr(Node->Secret), ChrPtr(Node->Host), ChrPtr(Node->Port));
 }
 
 
-HashList *load_netconf(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *load_netconf(StrBuf * Target, WCTemplputParams * TP) {
        StrBuf *Buf;
        HashList *Hash;
        char nnn[64];
@@ -92,8 +84,8 @@ HashList *load_netconf(StrBuf *Target, WCTemplputParams *TP)
                        Node = NewNode(Buf);
                        if (Node != NULL) {
                                nUsed = GetCount(Hash);
-                               nUsed = snprintf(nnn, sizeof(nnn), "%d", nUsed+1);
-                               Put(Hash, nnn, nUsed, Node, DeleteNodeConf); 
+                               nUsed = snprintf(nnn, sizeof(nnn), "%d", nUsed + 1);
+                               Put(Hash, nnn, nUsed, Node, DeleteNodeConf);
                        }
                }
                FreeStrBuf(&Buf);
@@ -104,8 +96,7 @@ HashList *load_netconf(StrBuf *Target, WCTemplputParams *TP)
 
 
 
-void save_net_conf(HashList *Nodelist)
-{
+void save_net_conf(HashList * Nodelist) {
        char buf[SIZ];
        StrBuf *Buf;
        HashPos *where;
@@ -121,8 +112,8 @@ void save_net_conf(HashList *Nodelist)
                        where = GetNewHashPos(Nodelist, 0);
                        Buf = NewStrBuf();
                        while (GetNextHashPos(Nodelist, where, &KeyLen, &Key, &vNode)) {
-                               Node = (NodeConf*) vNode;
-                               if (Node->DeleteMe==0) { 
+                               Node = (NodeConf *) vNode;
+                               if (Node->DeleteMe == 0) {
                                        SerializeNode(Node, Buf);
                                        serv_putbuf(Buf);
                                }
@@ -137,7 +128,9 @@ void save_net_conf(HashList *Nodelist)
 
 
 /*----------------------------------------------------------------------*/
+
 /*              WEB Handlers                                            */
+
 /*----------------------------------------------------------------------*/
 
 
@@ -152,13 +145,13 @@ void edit_node(void) {
 
        if (havebstr("ok_button")) {
                Index = sbstr("index");
-               NewNode = HttpGetNewNode();
+               NewNode = HttpGetNewNode();
                if ((NewNode == NULL) || (Index == NULL)) {
                        AppendImportantMessage(_("Invalid Parameter"), -1);
                        url_do_template();
                        return;
                }
-                       
+
                NodeConfig = load_netconf(NULL, &NoCtx);
                Put(NodeConfig, ChrPtr(Index), StrLength(Index), NewNode, DeleteNodeConf);
                save_net_conf(NodeConfig);
@@ -171,8 +164,7 @@ void edit_node(void) {
 /*
  * modify an existing node
  */
-void display_edit_node(void)
-{
+void display_edit_node(void) {
        WCTemplputParams SubTP;
        HashList *NodeConfig;
        const StrBuf *Index;
@@ -187,8 +179,7 @@ void display_edit_node(void)
        }
 
        NodeConfig = load_netconf(NULL, &NoCtx);
-       if (!GetHash(NodeConfig, ChrPtr(Index), StrLength(Index), &vNode) || 
-           (vNode == NULL)) {
+       if (!GetHash(NodeConfig, ChrPtr(Index), StrLength(Index), &vNode) || (vNode == NULL)) {
                AppendImportantMessage(_("Invalid Parameter"), -1);
                url_do_template();
                DeleteHash(&NodeConfig);
@@ -204,23 +195,21 @@ void display_edit_node(void)
        }
        UnStackContext(&SubTP);
        DeleteHash(&NodeConfig);
-       
+
 }
 
 
 /*
  * display all configured nodes
  */
-void display_netconf(void)
-{
+void display_netconf(void) {
        wDumpContent(1);
 }
 
 /*
  * display the dialog to verify the deletion
  */
-void display_confirm_delete_node(void)
-{
+void display_confirm_delete_node(void) {
        wDumpContent(1);
 }
 
@@ -228,8 +217,7 @@ void display_confirm_delete_node(void)
 /*
  * actually delete the node
  */
-void delete_node(void)
-{
+void delete_node(void) {
        HashList *NodeConfig;
        const StrBuf *Index;
        NodeConf *Node;
@@ -243,8 +231,7 @@ void delete_node(void)
        }
 
        NodeConfig = load_netconf(NULL, &NoCtx);
-       if (!GetHash(NodeConfig, ChrPtr(Index), StrLength(Index), &vNode) || 
-           (vNode == NULL)) {
+       if (!GetHash(NodeConfig, ChrPtr(Index), StrLength(Index), &vNode) || (vNode == NULL)) {
                AppendImportantMessage(_("Invalid Parameter"), -1);
                url_do_template();
                DeleteHash(&NodeConfig);
@@ -252,42 +239,35 @@ void delete_node(void)
        }
        Node = (NodeConf *) vNode;
        Node->DeleteMe = 1;
-               save_net_conf(NodeConfig);
+       save_net_conf(NodeConfig);
        DeleteHash(&NodeConfig);
-       
+
        url_do_template();
 
 }
 
 
-void tmplput_NodeName(StrBuf *Target, WCTemplputParams *TP)
-{
-       NodeConf *Node = (NodeConf*) CTX(CTX_NODECONF); 
+void tmplput_NodeName(StrBuf * Target, WCTemplputParams * TP) {
+       NodeConf *Node = (NodeConf *) CTX(CTX_NODECONF);
        StrBufAppendTemplate(Target, TP, Node->NodeName, 0);
 }
 
-void tmplput_Secret(StrBuf *Target, WCTemplputParams *TP)
-{
-       NodeConf *Node = (NodeConf*) CTX(CTX_NODECONF);
+void tmplput_Secret(StrBuf * Target, WCTemplputParams * TP) {
+       NodeConf *Node = (NodeConf *) CTX(CTX_NODECONF);
        StrBufAppendTemplate(Target, TP, Node->Secret, 0);
 }
 
-void tmplput_Host(StrBuf *Target, WCTemplputParams *TP) 
-{
-       NodeConf *Node= (NodeConf*) CTX(CTX_NODECONF);
+void tmplput_Host(StrBuf * Target, WCTemplputParams * TP) {
+       NodeConf *Node = (NodeConf *) CTX(CTX_NODECONF);
        StrBufAppendTemplate(Target, TP, Node->Host, 0);
 }
 
-void tmplput_Port(StrBuf *Target, WCTemplputParams *TP)
-{
-       NodeConf *Node= (NodeConf*) CTX(CTX_NODECONF);
+void tmplput_Port(StrBuf * Target, WCTemplputParams * TP) {
+       NodeConf *Node = (NodeConf *) CTX(CTX_NODECONF);
        StrBufAppendTemplate(Target, TP, Node->Port, 0);
 }
 
-void 
-InitModule_NETCONF
-(void)
-{
+void InitModule_NETCONF(void) {
        RegisterCTX(CTX_NODECONF);
        WebcitAddUrlHandler(HKEY("display_edit_node"), "", 0, display_edit_node, 0);
 
@@ -296,11 +276,11 @@ InitModule_NETCONF
        WebcitAddUrlHandler(HKEY("display_confirm_delete_node"), "", 0, display_confirm_delete_node, 0);
        WebcitAddUrlHandler(HKEY("delete_node"), "", 0, delete_node, 0);
 
-                                                                                          
-        RegisterNamespace("CFG:IGNET:NODE", 0, 1, tmplput_NodeName, NULL, CTX_NODECONF);
-        RegisterNamespace("CFG:IGNET:SECRET", 0, 1, tmplput_Secret, NULL, CTX_NODECONF);
-        RegisterNamespace("CFG:IGNET:HOST", 0, 1, tmplput_Host, NULL, CTX_NODECONF);
-        RegisterNamespace("CFG:IGNET:PORT", 0, 1, tmplput_Port, NULL, CTX_NODECONF);
+
+       RegisterNamespace("CFG:IGNET:NODE", 0, 1, tmplput_NodeName, NULL, CTX_NODECONF);
+       RegisterNamespace("CFG:IGNET:SECRET", 0, 1, tmplput_Secret, NULL, CTX_NODECONF);
+       RegisterNamespace("CFG:IGNET:HOST", 0, 1, tmplput_Host, NULL, CTX_NODECONF);
+       RegisterNamespace("CFG:IGNET:PORT", 0, 1, tmplput_Port, NULL, CTX_NODECONF);
 
        RegisterIterator("NODECONFIG", 0, NULL, load_netconf, NULL, DeleteHash, CTX_NODECONF, CTX_NONE, IT_NOFLAG);
 }
index 079bb960b687d7b49e463e3bd5a2138841e4805c..91b6ffcb64a76c60678c05e028cb17f8984a39d7 100644 (file)
@@ -21,8 +21,7 @@ int pastel_palette[9][3] = {
 /*
  * Fetch a message from the server and extract a vNote from it
  */
-struct vnote *vnote_new_from_msg(long msgnum,int unread) 
-{
+struct vnote *vnote_new_from_msg(long msgnum, int unread) {
        StrBuf *Buf;
        StrBuf *Data = NULL;
        const char *bptr;
@@ -33,24 +32,23 @@ struct vnote *vnote_new_from_msg(long msgnum,int unread)
        char mime_content_type[256];
        char mime_disposition[256];
        char relevant_partnum[256];
-       int phase = 0;                          /* 0 = citadel headers, 1 = mime headers, 2 = body */
+       int phase = 0;          /* 0 = citadel headers, 1 = mime headers, 2 = body */
        char msg4_content_type[256] = "";
        char msg4_content_encoding[256] = "";
        int msg4_content_length = 0;
        struct vnote *vnote_from_body = NULL;
-       int vnote_inline = 0;                   /* 1 = MSG4 gave us a text/x-vnote top level */
+       int vnote_inline = 0;   /* 1 = MSG4 gave us a text/x-vnote top level */
 
        relevant_partnum[0] = '\0';
        serv_printf("MSG4 %ld", msgnum);        /* we need the mime headers */
        Buf = NewStrBuf();
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) != 1) {
-               FreeStrBuf (&Buf);
+               FreeStrBuf(&Buf);
                return NULL;
        }
-       while ((StrBuf_ServGetln(Buf)>=0) && !Done) {
-               if ( (StrLength(Buf)==3) && 
-                    !strcmp(ChrPtr(Buf), "000")) {
+       while ((StrBuf_ServGetln(Buf) >= 0) && !Done) {
+               if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
                        Done = 1;
                        break;
                }
@@ -73,7 +71,7 @@ struct vnote *vnote_new_from_msg(long msgnum,int unread)
                        else if ((phase == 0) && (!strncasecmp(bptr, "text", 4))) {
                                phase = 1;
                        }
-               break;
+                       break;
                case 1:
                        if (!IsEmptyStr(bptr)) {
                                if (!strncasecmp(bptr, "Content-type: ", 14)) {
@@ -92,9 +90,9 @@ struct vnote *vnote_new_from_msg(long msgnum,int unread)
                        else {
                                phase++;
                                if ((msg4_content_length > 0)
-                                   && ( !strcasecmp(msg4_content_encoding, "7bit"))
+                                   && (!strcasecmp(msg4_content_encoding, "7bit"))
                                    && (!strcasecmp(msg4_content_type, "text/vnote"))
-                               ) { 
+                                   ) {
                                        vnote_inline = 1;
                                }
                        }
@@ -103,7 +101,7 @@ struct vnote *vnote_new_from_msg(long msgnum,int unread)
                                Data = NewStrBufPlain(NULL, msg4_content_length * 2);
                                if (msg4_content_length > 0) {
                                        StrBuf_ServGetBLOBBuffered(Data, msg4_content_length);
-                                       phase ++;
+                                       phase++;
                                }
                                else {
                                        StrBufAppendBuf(Data, Buf, 0);
@@ -141,10 +139,10 @@ struct vnote *vnote_new_from_msg(long msgnum,int unread)
                }
                else {
                        char *Buf = SmashStrBuf(&Data);
-                       
+
                        struct vnote *v = vnote_new_from_str(Buf);
                        free(Buf);
-                       return(v);
+                       return (v);
                }
        }
        return NULL;
@@ -155,34 +153,29 @@ struct vnote *vnote_new_from_msg(long msgnum,int unread)
 /*
  * Serialize a vnote and write it to the server
  */
-void write_vnote_to_server(struct vnote *v) 
-{
+void write_vnote_to_server(struct vnote *v) {
        char buf[1024];
        char *pch;
        char boundary[256];
        static int seq = 0;
 
        snprintf(boundary, sizeof boundary, "Citadel--Multipart--%s--%04x--%04x",
-               ChrPtr(WC->serv_info->serv_fqdn),
-               getpid(),
-               ++seq
-       );
+                ChrPtr(WC->serv_info->serv_fqdn), getpid(), ++seq);
 
        serv_puts("ENT0 1|||4");
        serv_getln(buf, sizeof buf);
        if (buf[0] == '4') {
                /* Remember, serv_printf() appends an extra newline */
-               serv_printf("Content-type: multipart/alternative; "
-                       "boundary=\"%s\"\n", boundary);
+               serv_printf("Content-type: multipart/alternative; " "boundary=\"%s\"\n", boundary);
                serv_printf("This is a multipart message in MIME format.\n");
                serv_printf("--%s", boundary);
-       
+
                serv_puts("Content-type: text/plain; charset=utf-8");
                serv_puts("Content-Transfer-Encoding: 7bit");
                serv_puts("");
                serv_puts(v->body);
                serv_puts("");
-       
+
                serv_printf("--%s", boundary);
                serv_puts("Content-type: text/vnote");
                serv_puts("Content-Transfer-Encoding: 7bit");
@@ -207,7 +200,7 @@ void ajax_update_note(void) {
        int msgnum;
        struct vnote *v = NULL;
 
-        if (!havebstr("note_uid")) {
+       if (!havebstr("note_uid")) {
                begin_ajax_response();
                wc_printf("Received ajax_update_note() request without a note UID.");
                end_ajax_response();
@@ -223,7 +216,7 @@ void ajax_update_note(void) {
                return;
        }
        msgnum = atol(&buf[4]);
-       
+
        /* Was this request a delete operation?  If so, nuke it... */
        if (havebstr("deletenote")) {
                if (!strcasecmp(bstr("deletenote"), "yes")) {
@@ -246,29 +239,30 @@ void ajax_update_note(void) {
        }
 
        /* Make any requested changes */
-        if (havebstr("top")) {
+       if (havebstr("top")) {
                v->pos_top = atoi(bstr("top"));
        }
-        if (havebstr("left")) {
+       if (havebstr("left")) {
                v->pos_left = atoi(bstr("left"));
        }
-        if (havebstr("height")) {
+       if (havebstr("height")) {
                v->pos_height = atoi(bstr("height"));
        }
-        if (havebstr("width")) {
+       if (havebstr("width")) {
                v->pos_width = atoi(bstr("width"));
        }
-        if (havebstr("red")) {
+       if (havebstr("red")) {
                v->color_red = atoi(bstr("red"));
        }
-        if (havebstr("green")) {
+       if (havebstr("green")) {
                v->color_green = atoi(bstr("green"));
        }
-        if (havebstr("blue")) {
+       if (havebstr("blue")) {
                v->color_blue = atoi(bstr("blue"));
        }
-        if (havebstr("value")) {       /* I would have preferred 'body' but InPlaceEditor hardcodes 'value' */
-               if (v->body) free(v->body);
+       if (havebstr("value")) {        /* I would have preferred 'body' but InPlaceEditor hardcodes 'value' */
+               if (v->body)
+                       free(v->body);
                v->body = strdup(bstr("value"));
        }
 
@@ -292,13 +286,9 @@ void ajax_update_note(void) {
  *
  * msgnum = Message number on the local server of the note to be displayed
  */
+
 /*TODO: wrong hook */
-int notes_LoadMsgFromServer(SharedMessageStatus *Stat, 
-                           void **ViewSpecific, 
-                           message_summary* Msg, 
-                           int is_new, 
-                           int i)
-{
+int notes_LoadMsgFromServer(SharedMessageStatus * Stat, void **ViewSpecific, message_summary * Msg, int is_new, int i) {
        struct vnote *v;
        WCTemplputParams TP;
 
@@ -307,20 +297,19 @@ int notes_LoadMsgFromServer(SharedMessageStatus *Stat,
        v = vnote_new_from_msg(Msg->msgnum, is_new);
        if (v) {
                TP.Context = v;
-               DoTemplate(HKEY("vnoteitem"),
-                          WC->WBuf, &TP);
-                       
+               DoTemplate(HKEY("vnoteitem"), WC->WBuf, &TP);
+
 
                /* uncomment these lines to see ugly debugging info 
-               StrBufAppendPrintf(WC->trailing_javascript,
-                       "document.write('L: ' + $('note-%s').style.left + '; ');", v->uid);
-               StrBufAppendPrintf(WC->trailing_javascript,
-                       "document.write('T: ' + $('note-%s').style.top + '; ');", v->uid);
-               StrBufAppendPrintf(WC->trailing_javascript,
-                       "document.write('W: ' + $('note-%s').style.width + '; ');", v->uid);
-               StrBufAppendPrintf(WC->trailing_javascript,
-                       "document.write('H: ' + $('note-%s').style.height + '<br>');", v->uid);
-               */
+                  StrBufAppendPrintf(WC->trailing_javascript,
+                  "document.write('L: ' + $('note-%s').style.left + '; ');", v->uid);
+                  StrBufAppendPrintf(WC->trailing_javascript,
+                  "document.write('T: ' + $('note-%s').style.top + '; ');", v->uid);
+                  StrBufAppendPrintf(WC->trailing_javascript,
+                  "document.write('W: ' + $('note-%s').style.width + '; ');", v->uid);
+                  StrBufAppendPrintf(WC->trailing_javascript,
+                  "document.write('H: ' + $('note-%s').style.height + '<br>');", v->uid);
+                */
 
                vnote_free(v);
        }
@@ -346,67 +335,57 @@ void add_new_note(void) {
                write_vnote_to_server(v);
                vnote_free(v);
        }
-       
+
        readloop(readfwd, eUseDefault);
 }
 
 
-void tmpl_vcard_put_posleft(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_vcard_put_posleft(StrBuf * Target, WCTemplputParams * TP) {
        struct vnote *v = (struct vnote *) CTX(CTX_VNOTE);
        StrBufAppendPrintf(Target, "%d", v->pos_left);
 }
 
-void tmpl_vcard_put_postop(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_vcard_put_postop(StrBuf * Target, WCTemplputParams * TP) {
        struct vnote *v = (struct vnote *) CTX(CTX_VNOTE);
        StrBufAppendPrintf(Target, "%d", v->pos_top);
 }
 
-void tmpl_vcard_put_poswidth(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_vcard_put_poswidth(StrBuf * Target, WCTemplputParams * TP) {
        struct vnote *v = (struct vnote *) CTX(CTX_VNOTE);
        StrBufAppendPrintf(Target, "%d", v->pos_width);
 }
 
-void tmpl_vcard_put_posheight(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_vcard_put_posheight(StrBuf * Target, WCTemplputParams * TP) {
        struct vnote *v = (struct vnote *) CTX(CTX_VNOTE);
        StrBufAppendPrintf(Target, "%d", v->pos_height);
 }
 
-void tmpl_vcard_put_posheight2(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_vcard_put_posheight2(StrBuf * Target, WCTemplputParams * TP) {
        struct vnote *v = (struct vnote *) CTX(CTX_VNOTE);
        StrBufAppendPrintf(Target, "%d", (v->pos_height / 16) - 5);
 }
 
-void tmpl_vcard_put_width2(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_vcard_put_width2(StrBuf * Target, WCTemplputParams * TP) {
        struct vnote *v = (struct vnote *) CTX(CTX_VNOTE);
        StrBufAppendPrintf(Target, "%d", (v->pos_width / 9) - 1);
 }
 
-void tmpl_vcard_put_color(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_vcard_put_color(StrBuf * Target, WCTemplputParams * TP) {
        struct vnote *v = (struct vnote *) CTX(CTX_VNOTE);
        StrBufAppendPrintf(Target, "%02X%02X%02X", v->color_red, v->color_green, v->color_blue);
 }
 
-void tmpl_vcard_put_bgcolor(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_vcard_put_bgcolor(StrBuf * Target, WCTemplputParams * TP) {
        struct vnote *v = (struct vnote *) CTX(CTX_VNOTE);
-       StrBufAppendPrintf(Target, "%02X%02X%02X", v->color_red/2, v->color_green/2, v->color_blue/2);
+       StrBufAppendPrintf(Target, "%02X%02X%02X", v->color_red / 2, v->color_green / 2, v->color_blue / 2);
 }
 
-void tmpl_vcard_put_message(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_vcard_put_message(StrBuf * Target, WCTemplputParams * TP) {
        struct vnote *v = (struct vnote *) CTX(CTX_VNOTE);
-       StrEscAppend(Target, NULL, v->body, 0, 0); /*TODO?*/
+       StrEscAppend(Target, NULL, v->body, 0, 0);      /*TODO? */
 }
 
-void tmpl_vcard_put_uid(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_vcard_put_uid(StrBuf * Target, WCTemplputParams * TP) {
        struct vnote *v = (struct vnote *) CTX(CTX_VNOTE);
        StrBufAppendBufPlain(Target, v->uid, -1, 0);
 }
@@ -414,14 +393,8 @@ void tmpl_vcard_put_uid(StrBuf *Target, WCTemplputParams *TP)
 
 
 
-int notes_GetParamsGetServerCall(SharedMessageStatus *Stat, 
-                                void **ViewSpecific, 
-                                long oper, 
-                                char *cmd, 
-                                long len,
-                                char *filter,
-                                long flen)
-{
+int notes_GetParamsGetServerCall(SharedMessageStatus * Stat,
+                                void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen) {
        strcpy(cmd, "MSGS ALL");
        Stat->maxmsgs = 32767;
        wc_printf("<div id=\"new_notes_here\"></div>\n");
@@ -429,14 +402,12 @@ int notes_GetParamsGetServerCall(SharedMessageStatus *Stat,
 
 }
 
-int notes_Cleanup(void **ViewSpecific)
-{
+int notes_Cleanup(void **ViewSpecific) {
        wDumpContent(1);
        return 0;
 }
 
-void render_MIME_VNote(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
-{
+void render_MIME_VNote(StrBuf * Target, WCTemplputParams * TP, StrBuf * FoundCharset) {
        wc_mime_attachment *Mime = CTX(CTX_MIME_ATACH);
 
        if (StrLength(Mime->Data) == 0)
@@ -449,16 +420,15 @@ void render_MIME_VNote(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharse
                Buf = NewStrBuf();
                vcard = SmashStrBuf(&Mime->Data);
                v = vnote_new_from_str(vcard);
-               free (vcard);
+               free(vcard);
                if (v) {
                        WCTemplputParams TP;
-                       
+
                        memset(&TP, 0, sizeof(WCTemplputParams));
                        TP.Filter.ContextType = CTX_VNOTE;
                        TP.Context = v;
-                       DoTemplate(HKEY("mail_vnoteitem"),
-                                  Buf, &TP);
-                       
+                       DoTemplate(HKEY("mail_vnoteitem"), Buf, &TP);
+
                        vnote_free(v);
                        Mime->Data = Buf;
                }
@@ -473,22 +443,12 @@ void render_MIME_VNote(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharse
 
 
 
-void 
-InitModule_NOTES
-(void)
-{
+void InitModule_NOTES(void) {
        RegisterCTX(CTX_VNOTE);
 
-       RegisterReadLoopHandlerset(
-               VIEW_NOTES,
-               notes_GetParamsGetServerCall,
-               NULL,
-               NULL,
-               NULL,
-               notes_LoadMsgFromServer,
-               NULL,
-               notes_Cleanup,
-               NULL);
+       RegisterReadLoopHandlerset(VIEW_NOTES,
+                                  notes_GetParamsGetServerCall,
+                                  NULL, NULL, NULL, notes_LoadMsgFromServer, NULL, notes_Cleanup, NULL);
 
        WebcitAddUrlHandler(HKEY("add_new_note"), "", 0, add_new_note, 0);
        WebcitAddUrlHandler(HKEY("ajax_update_note"), "", 0, ajax_update_note, 0);
@@ -500,7 +460,7 @@ InitModule_NOTES
        RegisterNamespace("VNOTE:POS:HEIGHT2", 0, 0, tmpl_vcard_put_posheight2, NULL, CTX_VNOTE);
        RegisterNamespace("VNOTE:POS:WIDTH2", 0, 0, tmpl_vcard_put_width2, NULL, CTX_VNOTE);
        RegisterNamespace("VNOTE:COLOR", 0, 0, tmpl_vcard_put_color, NULL, CTX_VNOTE);
-       RegisterNamespace("VNOTE:BGCOLOR", 0, 0,tmpl_vcard_put_bgcolor, NULL, CTX_VNOTE);
+       RegisterNamespace("VNOTE:BGCOLOR", 0, 0, tmpl_vcard_put_bgcolor, NULL, CTX_VNOTE);
        RegisterNamespace("VNOTE:MSG", 0, 1, tmpl_vcard_put_message, NULL, CTX_VNOTE);
        RegisterNamespace("VNOTE:UID", 0, 0, tmpl_vcard_put_uid, NULL, CTX_VNOTE);
 
index ca71d6793c51ab72ebae517599022a92d599e618..221b25e9e1d7b03c7dc2d07311fdf52c85cfd79e 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2012 by the citadel.org team
  *
@@ -16,8 +17,7 @@
 /*
  * Display the OpenIDs associated with an account
  */
-void display_openids(void)
-{
+void display_openids(void) {
        wcsession *WCC = WC;
        char buf[1024];
        int bg = 0;
@@ -31,31 +31,30 @@ void display_openids(void)
        if (WCC->serv_info->serv_supports_openid) {
 
                wc_printf("<table class=\"altern\">");
-       
+
                serv_puts("OIDL");
                serv_getln(buf, sizeof buf);
-               if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-                       bg = 1 - bg;
-                       wc_printf("<tr class=\"%s\">", (bg ? "even" : "odd"));
-                       wc_printf("<td><img src=\"static/webcit_icons/openid-small.gif\"></td><td>");
-                       escputs(buf);
-                       wc_printf("</td><td>");
-                       wc_printf("<a href=\"openid_detach?id_to_detach=");
-                       urlescputs(buf);
-                       wc_printf("\" onClick=\"return confirm('%s');\">",
-                               _("Do you really want to delete this OpenID?"));
-                       wc_printf("%s</a>", _("(delete)"));
-                       wc_printf("</td></tr>\n");
-               }
-       
+               if (buf[0] == '1')
+                       while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+                               bg = 1 - bg;
+                               wc_printf("<tr class=\"%s\">", (bg ? "even" : "odd"));
+                               wc_printf("<td><img src=\"static/webcit_icons/openid-small.gif\"></td><td>");
+                               escputs(buf);
+                               wc_printf("</td><td>");
+                               wc_printf("<a href=\"openid_detach?id_to_detach=");
+                               urlescputs(buf);
+                               wc_printf("\" onClick=\"return confirm('%s');\">", _("Do you really want to delete this OpenID?"));
+                               wc_printf("%s</a>", _("(delete)"));
+                               wc_printf("</td></tr>\n");
+                       }
+
                wc_printf("</table><br>\n");
-       
-               wc_printf("<form method=\"POST\" action=\"openid_attach\">\n");
+
+               wc_printf("<form method=\"POST\" action=\"openid_attach\">\n");
                wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WCC->nonce);
                wc_printf(_("Add an OpenID: "));
-               wc_printf("<input type=\"text\" name=\"openid_url\" class=\"openid_urlarea\" size=\"40\">\n");
-               wc_printf("<input type=\"submit\" name=\"attach_button\" value=\"%s\">"
-                       "</form></center>\n", _("Attach"));
+               wc_printf("<input type=\"text\" name=\"openid_url\" class=\"openid_urlarea\" size=\"40\">\n");
+               wc_printf("<input type=\"submit\" name=\"attach_button\" value=\"%s\">" "</form></center>\n", _("Attach"));
        }
 
        else {
@@ -78,11 +77,9 @@ void openid_attach(void) {
                syslog(LOG_DEBUG, "Attempting to attach %s\n", bstr("openid_url"));
 
                snprintf(buf, sizeof buf,
-                       "OIDS %s|%s/finalize_openid_login?attach_existing=1|%s",
-                       bstr("openid_url"),
-                       ChrPtr(site_prefix),
-                       ChrPtr(site_prefix)
-               );
+                        "OIDS %s|%s/finalize_openid_login?attach_existing=1|%s",
+                        bstr("openid_url"), ChrPtr(site_prefix), ChrPtr(site_prefix)
+                   );
 
                serv_puts(buf);
                serv_getln(buf, sizeof buf);
@@ -118,10 +115,7 @@ void openid_detach(void) {
        display_openids();
 }
 
-void 
-InitModule_OPENID
-(void)
-{
+void InitModule_OPENID(void) {
        WebcitAddUrlHandler(HKEY("display_openids"), "", 0, display_openids, 0);
        WebcitAddUrlHandler(HKEY("openid_attach"), "", 0, openid_attach, 0);
        WebcitAddUrlHandler(HKEY("openid_detach"), "", 0, openid_detach, 0);
index 4b3dc217a716983c01875f6c31fbf74fd74741b6..a4fa2665c27ede70d7fc2847dfb06877cc274c13 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * This module handles instant message related functions.
  *
 /*
  * display the form for paging (x-messaging) another user
  */
-void display_page(void)
-{
+void display_page(void) {
        char recp[SIZ];
 
        strcpy(recp, bstr("recp"));
 
-        output_headers(1, 1, 1, 0, 0, 0);
-        wc_printf("<div id=\"room_banner_override\">\n");
-        wc_printf("<h1>");
+       output_headers(1, 1, 1, 0, 0, 0);
+       wc_printf("<div id=\"room_banner_override\">\n");
+       wc_printf("<h1>");
        wc_printf(_("Send instant message"));
        wc_printf("</h1>");
-        wc_printf("</div>\n");
+       wc_printf("</div>\n");
 
        wc_printf("<div id=\"content\" class=\"service\">\n");
 
@@ -51,8 +51,7 @@ void display_page(void)
        wc_printf(_("Enter message text:"));
        wc_printf("<br>");
 
-       wc_printf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=5 COLS=40 "
-               "WIDTH=40></TEXTAREA>\n");
+       wc_printf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=5 COLS=40 " "WIDTH=40></TEXTAREA>\n");
 
        wc_printf("</TD></TR></TABLE><br>\n");
 
@@ -67,8 +66,7 @@ void display_page(void)
 /*
  * page another user
  */
-void page_user(void)
-{
+void page_user(void) {
        char recp[256];
        StrBuf *Line;
 
@@ -76,7 +74,8 @@ void page_user(void)
 
        if (!havebstr("send_button")) {
                AppendImportantMessage(_("Message was not sent."), -1);
-       } else {
+       }
+       else {
                Line = NewStrBuf();
                serv_printf("SEXP %s|-", recp);
                StrBuf_ServGetln(Line);
@@ -100,12 +99,12 @@ void page_user(void)
  * If there are instant messages waiting, and we notice that we haven't checked them in
  * a while, it probably means that we need to open the instant messenger window.
  */
-int Conditional_PAGE_WAITING(StrBuf *Target, WCTemplputParams *TP)
-{
+int Conditional_PAGE_WAITING(StrBuf * Target, WCTemplputParams * TP) {
        int len;
        char buf[SIZ];
 
        /** JavaScript function to alert the user that popups are probably blocked */
+
        /** First, do the check as part of our page load. */
        serv_puts("NOOP");
        len = serv_getln(buf, sizeof buf);
@@ -133,14 +132,11 @@ void ajax_send_instant_message(void) {
                serv_puts("000");
        }
 
-       escputs(buf);   /* doesn't really matter what we return - the client ignores it */
+       escputs(buf);           /* doesn't really matter what we return - the client ignores it */
 }
 
 
-void 
-InitModule_PAGING
-(void)
-{
+void InitModule_PAGING(void) {
        WebcitAddUrlHandler(HKEY("display_page"), "", 0, display_page, 0);
        WebcitAddUrlHandler(HKEY("page_user"), "", 0, page_user, 0);
        WebcitAddUrlHandler(HKEY("ajax_send_instant_message"), "", 0, ajax_send_instant_message, AJAX);
@@ -148,9 +144,6 @@ InitModule_PAGING
 }
 
 
-void 
-SessionDestroyModule_PAGING
-(wcsession *sess)
-{
+void SessionDestroyModule_PAGING(wcsession * sess) {
        /* nothing here anymore */
 }
index 1e07fcfb3aa018440580b65670c9061555d5b77c..027a960c44a70e2bff3ed7f93c9944b25e129684 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * parse urlparts and post data
  *
 #include "webserver.h"
 
 /* uncomment to see all parameters sent to the server by the browser. */
+
 /* #define DEBUG_URLSTRINGS */
 
 
-void free_url(void *U)
-{
-       urlcontent *u = (urlcontent*) U;
+void free_url(void *U) {
+       urlcontent *u = (urlcontent *) U;
        FreeStrBuf(&u->url_data);
        if (u->sub != NULL) {
                DeleteHash(&u->sub);
@@ -29,27 +30,25 @@ void free_url(void *U)
        free(u);
 }
 
-void PutSubstructUrlKey(HashList *list, urlcontent *u, char **keys, long *lengths, int max, int which){
+void PutSubstructUrlKey(HashList * list, urlcontent * u, char **keys, long *lengths, int max, int which) {
        void *vUrl;
        urlcontent *subu;
        HashList *thisList = list;
-       if (GetHash(list, keys[which], lengths[which], &vUrl) &&
-           (vUrl != NULL))
-       {
-               subu = (urlcontent*) vUrl;
+       if (GetHash(list, keys[which], lengths[which], &vUrl) && (vUrl != NULL)) {
+               subu = (urlcontent *) vUrl;
                if (subu->sub == NULL) {
                        subu->sub = NewHash(1, NULL);
                }
                thisList = subu->sub;
-       } 
+       }
        else if (which < max) {
                subu = (urlcontent *) malloc(sizeof(urlcontent));
-               
+
                memcpy(subu->url_key, keys[which], lengths[which]);
                subu->klen = lengths[which];
                subu->url_data = NULL;
                subu->sub = NewHash(1, NULL);
-               
+
                Put(list, subu->url_key, subu->klen, subu, free_url);
                thisList = subu->sub;
        }
@@ -61,7 +60,7 @@ void PutSubstructUrlKey(HashList *list, urlcontent *u, char **keys, long *length
        }
 }
 
-void PutUrlKey(HashList *urlstrings, urlcontent *u, int have_colons) {
+void PutUrlKey(HashList * urlstrings, urlcontent * u, int have_colons) {
        if (have_colons == 0) {
                Put(urlstrings, u->url_key, u->klen, u, free_url);
        }
@@ -79,12 +78,8 @@ void PutUrlKey(HashList *urlstrings, urlcontent *u, int have_colons) {
                pche = u->url_key + u->klen;
                while ((i < 10) && (pch <= pche)) {
                        if ((have_colons == 2) &&
-                           (*pch == '%') &&
-                           (*(pch + 1) == '3') && 
-                           ((*(pch + 2) == 'A') ||
-                            (*(pch + 1) == 'a')
-                                   ))
-                       {
+                           (*pch == '%') && (*(pch + 1) == '3') && ((*(pch + 2) == 'A') || (*(pch + 1) == 'a')
+                           )) {
                                *pch = '\0';
 
                                if (i == 0) {
@@ -101,8 +96,7 @@ void PutUrlKey(HashList *urlstrings, urlcontent *u, int have_colons) {
                                pchs = pch;
                                i++;
                        }
-                       else if ((have_colons == 1) &&
-                                (*pch == ':')) {
+                       else if ((have_colons == 1) && (*pch == ':')) {
                                *pch = '\0';
                                if (i == 0) {
                                        /* Separate the toplevel key : */
@@ -111,12 +105,12 @@ void PutUrlKey(HashList *urlstrings, urlcontent *u, int have_colons) {
                                /* sub-section: */
                                keys[i] = pchs;
                                lengths[i] = pch - pchs;
-                       
+
                                pch++;
                                pchs = pch;
                                i++;
                        }
-                       else if (pch == pche){
+                       else if (pch == pche) {
                                /* sub-section: */
                                keys[i] = pchs;
                                lengths[i] = pch - pchs;
@@ -124,10 +118,10 @@ void PutUrlKey(HashList *urlstrings, urlcontent *u, int have_colons) {
                                break;
                        }
                        else {
-                               pch ++;
+                               pch++;
                        }
                }
-               
+
                PutSubstructUrlKey(urlstrings, u, keys, lengths, i - 1, 0);
        }
 }
@@ -135,8 +129,7 @@ void PutUrlKey(HashList *urlstrings, urlcontent *u, int have_colons) {
 /*
  * Extract variables from the URL.
  */
-void ParseURLParams(StrBuf *url)
-{
+void ParseURLParams(StrBuf * url) {
        const char *aptr, *bptr, *eptr, *up = NULL;
        int len, keylen = 0;
        urlcontent *u = NULL;
@@ -154,12 +147,8 @@ void ParseURLParams(StrBuf *url)
                        if (*aptr == ':') {
                                have_colon = 1;
                        }
-                       else if ((*aptr == '%') &&
-                                (*(aptr + 1) == '3') && 
-                                ((*(aptr + 2) == 'A') ||
-                                 (*(aptr + 1) == 'a')
-                                        ))
-                       {
+                       else if ((*aptr == '%') && (*(aptr + 1) == '3') && ((*(aptr + 2) == 'A') || (*(aptr + 1) == 'a')
+                                )) {
                                have_colon = 2;
                        }
                        aptr++;
@@ -170,14 +159,14 @@ void ParseURLParams(StrBuf *url)
                aptr++;
                bptr = aptr;
                while ((bptr < eptr) && (*bptr != '\0')
-                     && (*bptr != '&') && (*bptr != '?') && (*bptr != ' ')) {
+                      && (*bptr != '&') && (*bptr != '?') && (*bptr != ' ')) {
                        bptr++;
                }
-               keylen = aptr - up - 1; /* -1 -> '=' */
+               keylen = aptr - up - 1; /* -1 -> '=' */
                if (keylen > sizeof(u->url_key)) {
                        syslog(LOG_WARNING, "%s:%d: invalid url_key of size %d in string size %ld",
-                               __FILE__, __LINE__, keylen, (long)sizeof(u->url_key)
-                       );
+                              __FILE__, __LINE__, keylen, (long) sizeof(u->url_key)
+                           );
                        free(u);
                        return;
                }
@@ -187,23 +176,19 @@ void ParseURLParams(StrBuf *url)
                        free(u);
                        return;
                }
-               
+
                u = (urlcontent *) malloc(sizeof(urlcontent));
                memcpy(u->url_key, up, keylen);
                u->url_key[keylen] = '\0';
                u->klen = keylen;
                u->sub = NULL;
 
-               if (strncmp(u->url_key, "__", 2) != 0)
-               {
+               if (strncmp(u->url_key, "__", 2) != 0) {
                        len = bptr - aptr;
                        u->url_data = NewStrBufPlain(aptr, len);
                        StrBufUnescape(u->url_data, 1);
 #ifdef DEBUG_URLSTRINGS
-                       syslog(LOG_DEBUG, "%s = [%d]  %s\n", 
-                               u->url_key, 
-                               StrLength(u->url_data), 
-                               ChrPtr(u->url_data)); 
+                       syslog(LOG_DEBUG, "%s = [%d]  %s\n", u->url_key, StrLength(u->url_data), ChrPtr(u->url_data));
 #endif
                        PutUrlKey(WCC->Hdr->urlstrings, u, have_colon);
                }
@@ -211,11 +196,9 @@ void ParseURLParams(StrBuf *url)
                        len = bptr - aptr;
                        u->url_data = NewStrBufPlain(aptr, len);
                        StrBufUnescape(u->url_data, 1);
-                       syslog(LOG_WARNING, "REJECTED because of __ is internal only: %s = [%d]  %s\n", 
-                               u->url_key, 
-                               StrLength(u->url_data), 
-                               ChrPtr(u->url_data)); 
-                       
+                       syslog(LOG_WARNING, "REJECTED because of __ is internal only: %s = [%d]  %s\n",
+                              u->url_key, StrLength(u->url_data), ChrPtr(u->url_data));
+
                        free_url(u);
                }
                up = bptr;
@@ -226,8 +209,7 @@ void ParseURLParams(StrBuf *url)
 /*
  * free urlstring memory
  */
-void free_urls(void)
-{
+void free_urls(void) {
        DeleteHash(&WC->Hdr->urlstrings);
 }
 
@@ -235,18 +217,17 @@ void free_urls(void)
  * Diagnostic function to display the contents of all variables
  */
 
-void dump_vars(void)
-{
+void dump_vars(void) {
        wcsession *WCC = WC;
        urlcontent *u;
        void *U;
        long HKLen;
        const char *HKey;
        HashPos *Cursor;
-       
-       Cursor = GetNewHashPos (WCC->Hdr->urlstrings, 0);
+
+       Cursor = GetNewHashPos(WCC->Hdr->urlstrings, 0);
        while (GetNextHashPos(WCC->Hdr->urlstrings, Cursor, &HKLen, &HKey, &U)) {
-               u = (urlcontent*) U;
+               u = (urlcontent *) U;
                wc_printf("%38s = %s\n", u->url_key, ChrPtr(u->url_data));
        }
 }
@@ -255,14 +236,12 @@ void dump_vars(void)
  * Return the value of a variable supplied to the current web page (from the url or a form)
  */
 
-const char *XBstr(const char *key, size_t keylen, size_t *len)
-{
+const char *XBstr(const char *key, size_t keylen, size_t *len) {
        void *U;
 
-       if ((WC->Hdr->urlstrings != NULL) && 
-           GetHash(WC->Hdr->urlstrings, key, keylen, &U)) {
-               *len = StrLength(((urlcontent *)U)->url_data);
-               return ChrPtr(((urlcontent *)U)->url_data);
+       if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, keylen, &U)) {
+               *len = StrLength(((urlcontent *) U)->url_data);
+               return ChrPtr(((urlcontent *) U)->url_data);
        }
        else {
                *len = 0;
@@ -270,14 +249,12 @@ const char *XBstr(const char *key, size_t keylen, size_t *len)
        }
 }
 
-const char *XBSTR(const char *key, size_t *len)
-{
+const char *XBSTR(const char *key, size_t *len) {
        void *U;
 
-       if ((WC->Hdr->urlstrings != NULL) &&
-           GetHash(WC->Hdr->urlstrings, key, strlen (key), &U)){
-               *len = StrLength(((urlcontent *)U)->url_data);
-               return ChrPtr(((urlcontent *)U)->url_data);
+       if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, strlen(key), &U)) {
+               *len = StrLength(((urlcontent *) U)->url_data);
+               return ChrPtr(((urlcontent *) U)->url_data);
        }
        else {
                *len = 0;
@@ -286,113 +263,93 @@ const char *XBSTR(const char *key, size_t *len)
 }
 
 
-const char *BSTR(const char *key)
-{
+const char *BSTR(const char *key) {
        void *U;
 
-       if ((WC->Hdr->urlstrings != NULL) &&
-           GetHash(WC->Hdr->urlstrings, key, strlen (key), &U))
-               return ChrPtr(((urlcontent *)U)->url_data);
-       else    
+       if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
+               return ChrPtr(((urlcontent *) U)->url_data);
+       else
                return ("");
 }
 
-const char *Bstr(const char *key, size_t keylen)
-{
+const char *Bstr(const char *key, size_t keylen) {
        void *U;
 
-       if ((WC->Hdr->urlstrings != NULL) && 
-           GetHash(WC->Hdr->urlstrings, key, keylen, &U))
-               return ChrPtr(((urlcontent *)U)->url_data);
-       else    
+       if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, keylen, &U))
+               return ChrPtr(((urlcontent *) U)->url_data);
+       else
                return ("");
 }
 
-const StrBuf *SBSTR(const char *key)
-{
+const StrBuf *SBSTR(const char *key) {
        void *U;
 
-       if ((WC->Hdr->urlstrings != NULL) &&
-           GetHash(WC->Hdr->urlstrings, key, strlen (key), &U))
-               return ((urlcontent *)U)->url_data;
-       else    
+       if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
+               return ((urlcontent *) U)->url_data;
+       else
                return NULL;
 }
 
-const StrBuf *SBstr(const char *key, size_t keylen)
-{
+const StrBuf *SBstr(const char *key, size_t keylen) {
        void *U;
 
-       if ((WC->Hdr->urlstrings != NULL) && 
-           GetHash(WC->Hdr->urlstrings, key, keylen, &U))
-               return ((urlcontent *)U)->url_data;
-       else    
+       if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, keylen, &U))
+               return ((urlcontent *) U)->url_data;
+       else
                return NULL;
 }
 
-long LBstr(const char *key, size_t keylen)
-{
+long LBstr(const char *key, size_t keylen) {
        void *U;
 
-       if ((WC->Hdr->urlstrings != NULL) && 
-           GetHash(WC->Hdr->urlstrings, key, keylen, &U))
-               return StrTol(((urlcontent *)U)->url_data);
-       else    
+       if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, keylen, &U))
+               return StrTol(((urlcontent *) U)->url_data);
+       else
                return (0);
 }
 
-int IBstr(const char *key, size_t keylen)
-{
+int IBstr(const char *key, size_t keylen) {
        void *U;
 
-       if ((WC->Hdr->urlstrings != NULL) && 
-           GetHash(WC->Hdr->urlstrings, key, keylen, &U))
-               return StrTol(((urlcontent *)U)->url_data);
-       else    
+       if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, keylen, &U))
+               return StrTol(((urlcontent *) U)->url_data);
+       else
                return (0);
 }
 
-int IBSTR(const char *key)
-{
+int IBSTR(const char *key) {
        void *U;
 
-       if ((WC->Hdr->urlstrings != NULL) && 
-           GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
-               return StrToi(((urlcontent *)U)->url_data);
-       else    
+       if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
+               return StrToi(((urlcontent *) U)->url_data);
+       else
                return (0);
 }
 
-int HaveBstr(const char *key, size_t keylen)
-{
+int HaveBstr(const char *key, size_t keylen) {
        void *U;
 
-       if ((WC->Hdr->urlstrings != NULL) && 
-           GetHash(WC->Hdr->urlstrings, key, keylen, &U))
-               return (StrLength(((urlcontent *)U)->url_data) != 0);
-       else    
+       if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, keylen, &U))
+               return (StrLength(((urlcontent *) U)->url_data) != 0);
+       else
                return (0);
 }
 
-int YesBstr(const char *key, size_t keylen)
-{
+int YesBstr(const char *key, size_t keylen) {
        void *U;
 
-       if ((WC->Hdr->urlstrings != NULL) && 
-           GetHash(WC->Hdr->urlstrings, key, keylen, &U))
-               return strcmp( ChrPtr(((urlcontent *)U)->url_data), "yes") == 0;
-       else    
+       if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, keylen, &U))
+               return strcmp(ChrPtr(((urlcontent *) U)->url_data), "yes") == 0;
+       else
                return (0);
 }
 
-int YESBSTR(const char *key)
-{
+int YESBSTR(const char *key) {
        void *U;
 
-       if ((WC->Hdr->urlstrings != NULL) && 
-           GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
-               return strcmp( ChrPtr(((urlcontent *)U)->url_data), "yes") == 0;
-       else    
+       if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
+               return strcmp(ChrPtr(((urlcontent *) U)->url_data), "yes") == 0;
+       else
                return (0);
 }
 
@@ -400,14 +357,12 @@ int YESBSTR(const char *key)
 /*
  * Return a sub array that was separated by a colon:
  */
-HashList* getSubStruct(const char *key, size_t keylen)
-{
+HashList *getSubStruct(const char *key, size_t keylen) {
        void *U;
 
-       if ((WC->Hdr->urlstrings != NULL) && 
-           GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
-               return ((urlcontent *)U)->sub;
-       else    
+       if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
+               return ((urlcontent *) U)->sub;
+       else
                return NULL;
 }
 
@@ -415,14 +370,12 @@ HashList* getSubStruct(const char *key, size_t keylen)
 /*
  * Return the value of a variable of a substruct provided by getSubStruct
  */
-const char *XSubBstr(HashList *sub, const char *key, size_t keylen, size_t *len)
-{
+const char *XSubBstr(HashList * sub, const char *key, size_t keylen, size_t *len) {
        void *U;
 
-       if ((sub != NULL) && 
-           GetHash(sub, key, keylen, &U)) {
-               *len = StrLength(((urlcontent *)U)->url_data);
-               return ChrPtr(((urlcontent *)U)->url_data);
+       if ((sub != NULL) && GetHash(sub, key, keylen, &U)) {
+               *len = StrLength(((urlcontent *) U)->url_data);
+               return ChrPtr(((urlcontent *) U)->url_data);
        }
        else {
                *len = 0;
@@ -430,75 +383,63 @@ const char *XSubBstr(HashList *sub, const char *key, size_t keylen, size_t *len)
        }
 }
 
-const char *SubBstr(HashList *sub, const char *key, size_t keylen)
-{
+const char *SubBstr(HashList * sub, const char *key, size_t keylen) {
        void *U;
 
-       if ((sub != NULL) && 
-           GetHash(sub, key, keylen, &U)) {
-               return ChrPtr(((urlcontent *)U)->url_data);
+       if ((sub != NULL) && GetHash(sub, key, keylen, &U)) {
+               return ChrPtr(((urlcontent *) U)->url_data);
        }
-       else    
+       else
                return ("");
 }
 
-const StrBuf *SSubBstr(HashList *sub, const char *key, size_t keylen)
-{
+const StrBuf *SSubBstr(HashList * sub, const char *key, size_t keylen) {
        void *U;
 
-       if ((sub != NULL) && 
-           GetHash(sub, key, keylen, &U)) {
-               return ((urlcontent *)U)->url_data;
+       if ((sub != NULL) && GetHash(sub, key, keylen, &U)) {
+               return ((urlcontent *) U)->url_data;
        }
-       else    
+       else
                return NULL;
 }
 
-long LSubBstr(HashList *sub, const char *key, size_t keylen)
-{
+long LSubBstr(HashList * sub, const char *key, size_t keylen) {
        void *U;
 
-       if ((sub != NULL) && 
-           GetHash(sub, key, keylen, &U)) {
-               return StrTol(((urlcontent *)U)->url_data);
+       if ((sub != NULL) && GetHash(sub, key, keylen, &U)) {
+               return StrTol(((urlcontent *) U)->url_data);
        }
-       else    
+       else
                return (0);
 }
 
-int ISubBstr(HashList *sub, const char *key, size_t keylen)
-{
+int ISubBstr(HashList * sub, const char *key, size_t keylen) {
        void *U;
 
-       if ((sub != NULL) && 
-           GetHash(sub, key, keylen, &U)) {
-               return StrTol(((urlcontent *)U)->url_data);
+       if ((sub != NULL) && GetHash(sub, key, keylen, &U)) {
+               return StrTol(((urlcontent *) U)->url_data);
        }
-       else    
+       else
                return (0);
 }
 
-int HaveSubBstr(HashList *sub, const char *key, size_t keylen)
-{
+int HaveSubBstr(HashList * sub, const char *key, size_t keylen) {
        void *U;
 
-       if ((sub != NULL) && 
-           GetHash(sub, key, keylen, &U)) {
-               return (StrLength(((urlcontent *)U)->url_data) != 0);
+       if ((sub != NULL) && GetHash(sub, key, keylen, &U)) {
+               return (StrLength(((urlcontent *) U)->url_data) != 0);
        }
-       else    
+       else
                return (0);
 }
 
-int YesSubBstr(HashList *sub, const char *key, size_t keylen)
-{
+int YesSubBstr(HashList * sub, const char *key, size_t keylen) {
        void *U;
 
-       if ((sub != NULL) && 
-           GetHash(sub, key, keylen, &U)) {
-               return strcmp( ChrPtr(((urlcontent *)U)->url_data), "yes") == 0;
+       if ((sub != NULL) && GetHash(sub, key, keylen, &U)) {
+               return strcmp(ChrPtr(((urlcontent *) U)->url_data), "yes") == 0;
        }
-       else    
+       else
                return (0);
 }
 
@@ -521,80 +462,70 @@ int YesSubBstr(HashList *sub, const char *key, size_t keylen)
  * userdata    Not used here
  */
 void upload_handler(char *name, char *filename, char *partnum, char *disp,
-                       void *content, char *cbtype, char *cbcharset,
-                       size_t length, char *encoding, char *cbid, void *userdata)
-{
+                   void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, char *cbid, void *userdata) {
        wcsession *WCC = WC;
        urlcontent *u;
        long keylen;
 
 #ifdef DEBUG_URLSTRINGS
-       syslog(LOG_DEBUG, "upload_handler() name=%s, type=%s, len="SIZE_T_FMT, name, cbtype, length);
+       syslog(LOG_DEBUG, "upload_handler() name=%s, type=%s, len=" SIZE_T_FMT, name, cbtype, length);
 #endif
        if (WCC->Hdr->urlstrings == NULL)
                WCC->Hdr->urlstrings = NewHash(1, NULL);
 
        /* Form fields */
-       if ( (length > 0) && (IsEmptyStr(cbtype)) ) {
+       if ((length > 0) && (IsEmptyStr(cbtype))) {
                u = (urlcontent *) malloc(sizeof(urlcontent));
-               
+
                keylen = safestrncpy(u->url_key, name, sizeof(u->url_key));
                u->url_data = NewStrBufPlain(content, length);
                u->klen = keylen;
                u->sub = NULL;
-               
-               if (strncmp(u->url_key, "__", 2) != 0)
-               {
+
+               if (strncmp(u->url_key, "__", 2) != 0) {
                        PutUrlKey(WCC->Hdr->urlstrings, u, (strchr(u->url_key, ':') != NULL));
                }
                else {
-                       syslog(LOG_INFO, "REJECTED because of __ is internal only: %s = [%d]  %s\n", 
-                               u->url_key, 
-                               StrLength(u->url_data), 
-                               ChrPtr(u->url_data)); 
-                       
+                       syslog(LOG_INFO, "REJECTED because of __ is internal only: %s = [%d]  %s\n",
+                              u->url_key, StrLength(u->url_data), ChrPtr(u->url_data));
+
                        free_url(u);
                }
 #ifdef DEBUG_URLSTRINGS
-               syslog(LOG_DEBUG, "Key: <%s> len: [%d] Data: <%s>", 
-                       u->url_key, 
-                       StrLength(u->url_data), 
-                       ChrPtr(u->url_data));
+               syslog(LOG_DEBUG, "Key: <%s> len: [%d] Data: <%s>", u->url_key, StrLength(u->url_data), ChrPtr(u->url_data));
 #endif
        }
 
        /* Uploaded files */
-       if ( (length > 0) && (!IsEmptyStr(cbtype)) ) {
+       if ((length > 0) && (!IsEmptyStr(cbtype))) {
                WCC->upload = NewStrBufPlain(content, length);
                WCC->upload_length = length;
                WCC->upload_filename = NewStrBufPlain(filename, -1);
                safestrncpy(WCC->upload_content_type, cbtype, sizeof(WC->upload_content_type));
 #ifdef DEBUG_URLSTRINGS
-               syslog(LOG_DEBUG, "File: <%s> len: [%ld]", filename, (long int)length);
+               syslog(LOG_DEBUG, "File: <%s> len: [%ld]", filename, (long int) length);
 #endif
-               
+
        }
 
 }
 
-void PutBstr(const char *key, long keylen, StrBuf *Value)
-{
+void PutBstr(const char *key, long keylen, StrBuf * Value) {
        urlcontent *u;
 
-       if(keylen >= sizeof(u->url_key)) {
+       if (keylen >= sizeof(u->url_key)) {
                syslog(LOG_WARNING, "%s:%d: invalid url_key of size %ld", __FILE__, __LINE__, keylen);
                FreeStrBuf(&Value);
                return;
        }
-       u = (urlcontent*)malloc(sizeof(urlcontent));
+       u = (urlcontent *) malloc(sizeof(urlcontent));
        memcpy(u->url_key, key, keylen + 1);
        u->klen = keylen;
        u->url_data = Value;
        u->sub = NULL;
        Put(WC->Hdr->urlstrings, u->url_key, keylen, u, free_url);
 }
-void PutlBstr(const char *key, long keylen, long Value)
-{
+void PutlBstr(const char *key, long keylen, long Value) {
        StrBuf *Buf;
 
        Buf = NewStrBufPlain(NULL, sizeof(long) * 16);
@@ -604,53 +535,45 @@ void PutlBstr(const char *key, long keylen, long Value)
 
 
 
-int ConditionalBstr(StrBuf *Target, WCTemplputParams *TP)
-{
-       if(TP->Tokens->nParameters == 3)
+int ConditionalBstr(StrBuf * Target, WCTemplputParams * TP) {
+       if (TP->Tokens->nParameters == 3)
                return HaveBstr(TKEY(2));
        else {
-               if (IS_NUMBER(TP->Tokens->Params[3]->Type))
-               {
-                       return LBstr(TKEY(2)) == 
-                               GetTemplateTokenNumber(Target, 
-                                                      TP, 
-                                                      3, 
-                                                      0);
+               if (IS_NUMBER(TP->Tokens->Params[3]->Type)) {
+                       return LBstr(TKEY(2)) == GetTemplateTokenNumber(Target, TP, 3, 0);
                }
                else {
                        const char *pch;
                        long len;
 
-                       GetTemplateTokenString (Target, TP, 3, &pch, &len);
+                       GetTemplateTokenString(Target, TP, 3, &pch, &len);
                        return strcmp(Bstr(TKEY(2)), pch) == 0;
                }
        }
 }
 
-void tmplput_bstr(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_bstr(StrBuf * Target, WCTemplputParams * TP) {
        const StrBuf *Buf = SBstr(TKEY(0));
        if (Buf != NULL)
                StrBufAppendTemplate(Target, TP, Buf, 1);
 }
 
 
-void tmplput_bstrforward(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_bstrforward(StrBuf * Target, WCTemplputParams * TP) {
        const StrBuf *Buf = SBstr(TKEY(0));
        if (Buf != NULL) {
-               StrBufAppendBufPlain(Target, HKEY("?"), 0);             
+               StrBufAppendBufPlain(Target, HKEY("?"), 0);
                StrBufAppendBufPlain(Target, TKEY(0), 0);
-               StrBufAppendBufPlain(Target, HKEY("="), 0);             
+               StrBufAppendBufPlain(Target, HKEY("="), 0);
                StrBufAppendTemplate(Target, TP, Buf, 1);
        }
 }
 
-void diagnostics(void)
-{
+void diagnostics(void) {
        output_headers(1, 1, 1, 0, 0, 0);
        wc_printf("Session: %d<hr />\n", WC->wc_session);
        wc_printf("Command: <br><PRE>\n");
+
 /*     
 StrEscAppend(WC->WBuf, NULL, WC->UrlFragment1, 0, 0);
        wc_printf("<br>\n");
@@ -666,12 +589,11 @@ StrEscAppend(WC->WBuf, NULL, WC->UrlFragment3, 0, 0);
 }
 
 
-void tmplput_url_part(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_url_part(StrBuf * Target, WCTemplputParams * TP) {
        StrBuf *Name = NULL;
        StrBuf *UrlBuf = NULL;
        wcsession *WCC = WC;
-       
+
        if (WCC != NULL) {
                long n;
 
@@ -689,44 +611,41 @@ void tmplput_url_part(StrBuf *Target, WCTemplputParams *TP)
                        StrBufExtract_token(UrlBuf, WCC->Hdr->HR.ReqLine, 1, '/');
                }
 
-               if (UrlBuf == NULL)  {
+               if (UrlBuf == NULL) {
                        LogTemplateError(Target, "urlbuf", ERR_PARM1, TP, "not set.");
                }
                StrBufAppendTemplate(Target, TP, UrlBuf, 2);
-               if (Name == NULL) FreeStrBuf(&UrlBuf);
+               if (Name == NULL)
+                       FreeStrBuf(&UrlBuf);
        }
 }
 
 typedef struct __BstrPair {
        StrBuf *x;
        StrBuf *y;
-}BstrPair;
+} BstrPair;
 CtxType CTX_BSTRPAIRS = CTX_NONE;
-void HFreeBstrPair(void *pv)
-{
-       BstrPair *p = (BstrPair*) pv;
+void HFreeBstrPair(void *pv) {
+       BstrPair *p = (BstrPair *) pv;
        FreeStrBuf(&p->x);
        FreeStrBuf(&p->y);
        free(pv);
 }
 
-HashList *iterate_GetBstrPairs(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *iterate_GetBstrPairs(StrBuf * Target, WCTemplputParams * TP) {
        StrBuf *X, *Y;
-        const char *ch = NULL;
-        long len;
+       const char *ch = NULL;
+       long len;
        const StrBuf *TheBStr;
        BstrPair *OnePair;
-        HashList *List;
+       HashList *List;
        const char *Pos = NULL;
        int i = 0;
 
-       if (HaveTemplateTokenString(NULL, TP, 2, &ch, &len))
-        {
-                GetTemplateTokenString(Target, TP, 2, &ch, &len);
-        }
-       else 
-       {
+       if (HaveTemplateTokenString(NULL, TP, 2, &ch, &len)) {
+               GetTemplateTokenString(Target, TP, 2, &ch, &len);
+       }
+       else {
                return NULL;
        }
 
@@ -734,8 +653,7 @@ HashList *iterate_GetBstrPairs(StrBuf *Target, WCTemplputParams *TP)
        if ((TheBStr == NULL) || (StrLength(TheBStr) == 0))
                return NULL;
        List = NewHash(1, NULL);
-       while (Pos != StrBufNOTNULL)
-       {
+       while (Pos != StrBufNOTNULL) {
                X = NewStrBufPlain(NULL, StrLength(TheBStr));
                StrBufExtract_NextToken(X, TheBStr, &Pos, '|');
                if (Pos == StrBufNOTNULL) {
@@ -745,7 +663,7 @@ HashList *iterate_GetBstrPairs(StrBuf *Target, WCTemplputParams *TP)
                }
                Y = NewStrBufPlain(NULL, StrLength(TheBStr));
                StrBufExtract_NextToken(Y, TheBStr, &Pos, '|');
-               OnePair = (BstrPair*)malloc(sizeof(BstrPair));
+               OnePair = (BstrPair *) malloc(sizeof(BstrPair));
                OnePair->x = X;
                OnePair->y = Y;
                Put(List, IKEY(i), OnePair, HFreeBstrPair);
@@ -755,22 +673,20 @@ HashList *iterate_GetBstrPairs(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void tmplput_bstr_pair(StrBuf *Target, WCTemplputParams *TP, int XY)
-{
-       BstrPair *Pair = (BstrPair*) CTX(CTX_BSTRPAIRS);
+void tmplput_bstr_pair(StrBuf * Target, WCTemplputParams * TP, int XY) {
+       BstrPair *Pair = (BstrPair *) CTX(CTX_BSTRPAIRS);
 
-       StrBufAppendTemplate(Target, TP, (XY)?Pair->y:Pair->x, 0);
+       StrBufAppendTemplate(Target, TP, (XY) ? Pair->y : Pair->x, 0);
 }
 
-void tmplput_bstr_pair_x(StrBuf *Target, WCTemplputParams *TP)
-{      tmplput_bstr_pair(Target, TP, 0); }
-void tmplput_bstr_pair_y(StrBuf *Target, WCTemplputParams *TP)
-{      tmplput_bstr_pair(Target, TP, 1); }
+void tmplput_bstr_pair_x(StrBuf * Target, WCTemplputParams * TP) {
+       tmplput_bstr_pair(Target, TP, 0);
+}
+void tmplput_bstr_pair_y(StrBuf * Target, WCTemplputParams * TP) {
+       tmplput_bstr_pair(Target, TP, 1);
+}
 
-void 
-InitModule_PARAMHANDLING
-(void)
-{
+void InitModule_PARAMHANDLING(void) {
        RegisterCTX(CTX_BSTRPAIRS);
        WebcitAddUrlHandler(HKEY("diagnostics"), "", 0, diagnostics, NEED_URL);
 
@@ -785,17 +701,11 @@ InitModule_PARAMHANDLING
 }
 
 
-void
-SessionAttachModule_PARAMHANDLING
-(wcsession *sess)
-{
-       sess->Hdr->urlstrings = NewHash(1,NULL);
+void SessionAttachModule_PARAMHANDLING(wcsession * sess) {
+       sess->Hdr->urlstrings = NewHash(1, NULL);
 }
 
-void
-SessionDetachModule_PARAMHANDLING
-(wcsession *sess)
-{
+void SessionDetachModule_PARAMHANDLING(wcsession * sess) {
        DeleteHash(&sess->Hdr->urlstrings);
        FreeStrBuf(&sess->upload_filename);
 }
index 1b2f62d02e65730acad3a972aa568c5d1f4e24e7..bcfc909e806d90e6750ea4eff3bc75b1d3695b03 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2013 by the citadel.org team
  *
 
 /* URL / Mime Post parsing -> paramhandling.c */
 void upload_handler(char *name, char *filename, char *partnum, char *disp,
-                   void *content, char *cbtype, char *cbcharset,
-                   size_t length, char *encoding, char *cbid, void *userdata);
+                   void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, char *cbid, void *userdata);
 
-void ParseURLParams(StrBuf *url);
+void ParseURLParams(StrBuf * url);
 
 
 /* These may return NULL if not foud */
@@ -41,27 +41,27 @@ int HaveBstr(const char *key, size_t keylen);
 int YesBstr(const char *key, size_t keylen);
 int YESBSTR(const char *key);
 
-HashListgetSubStruct(const char *key, size_t keylen);
+HashList *getSubStruct(const char *key, size_t keylen);
 
 /* These may return NULL if not foud */
 #define ssubbstr(s, a) SSubBstr(s, a, sizeof(a) - 1)
-const StrBuf *SSubBstr(HashList *sub, const char *key, size_t keylen);
+const StrBuf *SSubBstr(HashList * sub, const char *key, size_t keylen);
 
 #define xsubbstr(s, a, b) (char*) XSubBstr(s, a, sizeof(a) - 1, b)
-const char *XSubBstr(HashList *sub, const char *key, size_t keylen, size_t *len);
+const char *XSubBstr(HashList * sub, const char *key, size_t keylen, size_t *len);
 
 #define lsubbstr(s, a) LSubBstr(s, a, sizeof(a) - 1)
-long LSubBstr(HashList *sub, const char *key, size_t keylen);
+long LSubBstr(HashList * sub, const char *key, size_t keylen);
 
 #define isubbstr(s, a) ISubBstr(s, a, sizeof(a) - 1)
 #define isubbcstr(s, a) ISubBstr(s, a.Key, a.len)
-int ISubBstr(HashList *sub, const char *key, size_t keylen);
+int ISubBstr(HashList * sub, const char *key, size_t keylen);
 
 #define havesubbstr(s, a) HaveSubBstr(s, a, sizeof(a) - 1)
-int HaveSubBstr(HashList *sub, const char *key, size_t keylen);
+int HaveSubBstr(HashList * sub, const char *key, size_t keylen);
 
 #define yessubbstr(s, a) YesSubBstr(s, a, sizeof(a) - 1)
-int YesSubBstr(HashList *sub, const char *key, size_t keylen);
+int YesSubBstr(HashList * sub, const char *key, size_t keylen);
 
 
 
@@ -70,10 +70,10 @@ int YesSubBstr(HashList *sub, const char *key, size_t keylen);
 #define bstr(a) (char*) Bstr(a, sizeof(a) - 1)
 const char *BSTR(const char *key);
 const char *Bstr(const char *key, size_t keylen);
+
 /* if you want to ease some parts by just parametring yourself... */
 #define putbstr(a, b) PutBstr(a, sizeof(a) - 1, b)
-void PutBstr(const char *key, long keylen, StrBuf *Value);
+void PutBstr(const char *key, long keylen, StrBuf * Value);
 
 #define putlbstr(a, b) PutlBstr(a, sizeof(a) - 1, b)
 void PutlBstr(const char *key, long keylen, long Value);
-
index ae381cc1e5b45afe68b9246c695f154a51b872a9..244be7ffcd56ed7760ba510138c7c2aa191f3405 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Manage user preferences with a little help from the Citadel server.
  *
@@ -39,17 +40,15 @@ typedef struct _Preference {
        StrBuf *DeQPed;
 } Preference;
 
-void DestroyPrefDef(void *vPrefDef)
-{
-       PrefDef *Prefdef = (PrefDef*) vPrefDef;
+void DestroyPrefDef(void *vPrefDef) {
+       PrefDef *Prefdef = (PrefDef *) vPrefDef;
        FreeStrBuf(&Prefdef->Setting);
        FreeStrBuf(&Prefdef->OnLoadName);
        free(Prefdef);
 }
 
-void DestroyPreference(void *vPref)
-{
-       Preference *Pref = (Preference*) vPref;
+void DestroyPreference(void *vPref) {
+       Preference *Pref = (Preference *) vPref;
        FreeStrBuf(&Pref->Key);
        FreeStrBuf(&Pref->Val);
        FreeStrBuf(&Pref->DeQPed);
@@ -57,13 +56,9 @@ void DestroyPreference(void *vPref)
 
 }
 
-void _RegisterPreference(const char *Setting, long SettingLen, 
-                        const char *PrefStr, 
-                        ePrefType Type, 
-                        PrefEvalFunc OnLoad, 
-                        const char *OnLoadName)
-{
-       PrefDef *Newpref = (PrefDef*) malloc(sizeof(PrefDef));
+void _RegisterPreference(const char *Setting, long SettingLen,
+                        const char *PrefStr, ePrefType Type, PrefEvalFunc OnLoad, const char *OnLoadName) {
+       PrefDef *Newpref = (PrefDef *) malloc(sizeof(PrefDef));
        Newpref->Setting = NewStrBufPlain(Setting, SettingLen);
        Newpref->PrefStr = PrefStr;
        Newpref->eType = Type;
@@ -76,11 +71,10 @@ void _RegisterPreference(const char *Setting, long SettingLen,
        Put(PreferenceHooks, Setting, SettingLen, Newpref, DestroyPrefDef);
 }
 
-const char *PrefGetLocalStr(const char *Setting, long len)
-{
+const char *PrefGetLocalStr(const char *Setting, long len) {
        void *hash_value;
        if (GetHash(PreferenceHooks, Setting, len, &hash_value) != 0) {
-               PrefDef *Newpref = (PrefDef*) hash_value;
+               PrefDef *Newpref = (PrefDef *) hash_value;
                return _(Newpref->PrefStr);
 
        }
@@ -88,18 +82,16 @@ const char *PrefGetLocalStr(const char *Setting, long len)
 }
 
 #ifdef DBG_PREFS_HASH
-inline const char *PrintPref(void *vPref)
-{
-       Preference *Pref = (Preference*) vPref;
+inline const char *PrintPref(void *vPref) {
+       Preference *Pref = (Preference *) vPref;
        if (Pref->DeQPed != NULL)
                return ChrPtr(Pref->DeQPed);
-       else 
+       else
                return ChrPtr(Pref->Val);
 }
 #endif
 
-void GetPrefTypes(HashList *List)
-{
+void GetPrefTypes(HashList * List) {
        HashPos *It;
        long len;
        const char *Key;
@@ -109,24 +101,18 @@ void GetPrefTypes(HashList *List)
        PrefDef *PrefType;
 
        It = GetNewHashPos(List, 0);
-       while (GetNextHashPos(List, It, &len, &Key, &vSetting)) 
-       {
-               Pref = (Preference*) vSetting;
-               if (GetHash(PreferenceHooks, SKEY(Pref->Key), &vPrefDef) && 
-                   (vPrefDef != NULL)) 
-               {
-                       PrefType = (PrefDef*) vPrefDef;
+       while (GetNextHashPos(List, It, &len, &Key, &vSetting)) {
+               Pref = (Preference *) vSetting;
+               if (GetHash(PreferenceHooks, SKEY(Pref->Key), &vPrefDef) && (vPrefDef != NULL)) {
+                       PrefType = (PrefDef *) vPrefDef;
                        Pref->Type = PrefType;
                        Pref->eFlatPrefType = Pref->Type->eType;
 
                        syslog(LOG_DEBUG, "Loading [%s]with type [%d] [\"%s\"]\n",
-                               ChrPtr(Pref->Key),
-                               Pref->Type->eType,
-                               ChrPtr(Pref->Val));
+                              ChrPtr(Pref->Key), Pref->Type->eType, ChrPtr(Pref->Val));
 
-                       switch (Pref->Type->eType)
-                       {
-                       case PRF_UNSET: /* WHUT? */
+                       switch (Pref->Type->eType) {
+                       case PRF_UNSET: /* WHUT? */
                                break;
                        case PRF_STRING:
                                break;
@@ -145,12 +131,10 @@ void GetPrefTypes(HashList *List)
                                break;
                        }
 
-                       if (PrefType->OnLoad != NULL){
+                       if (PrefType->OnLoad != NULL) {
 
                                syslog(LOG_DEBUG, "Loading with: -> %s(\"%s\", %ld)\n",
-                                       ChrPtr(PrefType->OnLoadName),
-                                       ChrPtr(Pref->Val),
-                                       Pref->lval);
+                                      ChrPtr(PrefType->OnLoadName), ChrPtr(Pref->Val), Pref->lval);
                                PrefType->OnLoad(Pref->Val, Pref->lval);
                        }
                }
@@ -158,23 +142,20 @@ void GetPrefTypes(HashList *List)
        DeleteHashPos(&It);
 }
 
-void ParsePref(HashList **List, StrBuf *ReadBuf)
-{
+void ParsePref(HashList ** List, StrBuf * ReadBuf) {
        int Done = 0;
        Preference *Data = NULL;
        Preference *LastData = NULL;
-                               
+
        while (!Done) {
                if (StrBuf_ServGetln(ReadBuf) < 0)
                        break;
-               if ( (StrLength(ReadBuf)==3) && 
-                    !strcmp(ChrPtr(ReadBuf), "000")) {
+               if ((StrLength(ReadBuf) == 3) && !strcmp(ChrPtr(ReadBuf), "000")) {
                        Done = 1;
                        break;
                }
 
-               if ((ChrPtr(ReadBuf)[0] == ' ') &&
-                   (LastData != NULL)) {
+               if ((ChrPtr(ReadBuf)[0] == ' ') && (LastData != NULL)) {
                        StrBufAppendBuf(LastData->Val, ReadBuf, 1);
                }
                else {
@@ -189,27 +170,21 @@ void ParsePref(HashList **List, StrBuf *ReadBuf)
 
                        /* some users might still have this start page configured, which now breaks */
 
-                       if (    (!strcasecmp(ChrPtr(Data->Key), "startpage"))
-                               && (!strcasecmp(ChrPtr(Data->Val), "/do_template?template=summary_page"))
-                       ) {
+                       if ((!strcasecmp(ChrPtr(Data->Key), "startpage"))
+                           && (!strcasecmp(ChrPtr(Data->Val), "/do_template?template=summary_page"))
+                           ) {
                                FreeStrBuf(&Data->Val);
                                Data->Val = NewStrBufPlain(HKEY("/summary"));
                        }
 
                        /******************* END VILE SLEAZY HACK ************************/
 
-                       if (!IsEmptyStr(ChrPtr(Data->Key)))
-                       {
-                               Put(*List, 
-                                   SKEY(Data->Key),
-                                   Data, 
-                                   DestroyPreference);
+                       if (!IsEmptyStr(ChrPtr(Data->Key))) {
+                               Put(*List, SKEY(Data->Key), Data, DestroyPreference);
                        }
-                       else 
-                       {
+                       else {
                                StrBufTrim(ReadBuf);
-                               syslog(LOG_INFO, "ignoring spurious preference line: [%s]\n", 
-                                       ChrPtr(ReadBuf));
+                               syslog(LOG_INFO, "ignoring spurious preference line: [%s]\n", ChrPtr(ReadBuf));
                                DestroyPreference(Data);
                                LastData = NULL;
                        }
@@ -223,21 +198,20 @@ void ParsePref(HashList **List, StrBuf *ReadBuf)
 /*
  * display preferences dialog
  */
-void load_preferences(void) 
-{
+void load_preferences(void) {
        folder Room;
        wcsession *WCC = WC;
        int Done = 0;
        StrBuf *ReadBuf;
        long msgnum = 0L;
-       
+
        memset(&Room, 0, sizeof(folder));
        ReadBuf = NewStrBufPlain(NULL, SIZ * 4);
        if (goto_config_room(ReadBuf, &Room) != 0) {
                FreeStrBuf(&ReadBuf);
                FlushFolder(&Room);
 
-               return; /* oh well. */
+               return;         /* oh well. */
        }
 
        serv_puts("MSGS ALL|0|1");
@@ -247,7 +221,7 @@ void load_preferences(void)
                serv_puts("000");
        }
        while (!Done && (StrBuf_ServGetln(ReadBuf) >= 0)) {
-               if ( (StrLength(ReadBuf)==3) && !strcmp(ChrPtr(ReadBuf), "000")) {
+               if ((StrLength(ReadBuf) == 3) && !strcmp(ChrPtr(ReadBuf), "000")) {
                        Done = 1;
                        break;
                }
@@ -258,10 +232,10 @@ void load_preferences(void)
                serv_printf("MSG0 %ld", msgnum);
                StrBuf_ServGetln(ReadBuf);
                if (GetServerStatus(ReadBuf, NULL) == 1) {
-                       while ( (StrBuf_ServGetln(ReadBuf) >= 0)
-                               && (strcmp(ChrPtr(ReadBuf), "text")
-                               && strcmp(ChrPtr(ReadBuf), "000"))
-                       ) {
+                       while ((StrBuf_ServGetln(ReadBuf) >= 0)
+                              && (strcmp(ChrPtr(ReadBuf), "text")
+                                  && strcmp(ChrPtr(ReadBuf), "000"))
+                           ) {
                                /* flush */
                        }
                        if (!strcmp(ChrPtr(ReadBuf), "text")) {
@@ -285,8 +259,7 @@ void load_preferences(void)
  * Go to the user's configuration room, creating it if necessary.
  * returns 0 on success or nonzero upon failure.
  */
-int goto_config_room(StrBuf *Buf, folder *Room) 
-{
+int goto_config_room(StrBuf * Buf, folder * Room) {
        serv_printf("GOTO %s", USERCONFIGROOM);
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) != 2) {  /* try to create the config room if not there */
@@ -297,15 +270,14 @@ int goto_config_room(StrBuf *Buf, folder *Room)
                serv_printf("GOTO %s", USERCONFIGROOM);
                StrBuf_ServGetln(Buf);
                if (GetServerStatus(Buf, NULL) != 2) {
-                       return(1);
+                       return (1);
                }
        }
        ParseGoto(Room, Buf);
-       return(0);
+       return (0);
 }
 
-void WritePrefsToServer(HashList *Hash)
-{
+void WritePrefsToServer(HashList * Hash) {
        wcsession *WCC = WC;
        long len;
        HashPos *HashPos;
@@ -313,20 +285,19 @@ void WritePrefsToServer(HashList *Hash)
        const char *Key;
        Preference *Pref;
        StrBuf *SubBuf = NULL;
-       
+
        Hash = WCC->hash_prefs;
 #ifdef DBG_PREFS_HASH
        dbg_PrintHash(Hash, PrintPref, NULL);
 #endif
        HashPos = GetNewHashPos(Hash, 0);
-       while (GetNextHashPos(Hash, HashPos, &len, &Key, &vPref)!=0)
-       {
+       while (GetNextHashPos(Hash, HashPos, &len, &Key, &vPref) != 0) {
                size_t nchars;
                if (vPref == NULL)
                        continue;
-               Pref = (Preference*) vPref;
+               Pref = (Preference *) vPref;
                nchars = StrLength(Pref->Val);
-               if (nchars > 80){
+               if (nchars > 80) {
                        int n = 0;
                        size_t offset, nchars;
                        if (SubBuf == NULL)
@@ -336,28 +307,28 @@ void WritePrefsToServer(HashList *Hash)
                        while (nchars > 0) {
                                if (n == 0)
                                        nchars = 70;
-                               else 
+                               else
                                        nchars = 80;
-                               
+
                                nchars = StrBufSub(SubBuf, Pref->Val, offset, nchars);
-                               
+
                                if (n == 0) {
                                        serv_printf("%s|%s", ChrPtr(Pref->Key), ChrPtr(SubBuf));
                                }
                                else {
                                        serv_printf(" %s", ChrPtr(SubBuf));
                                }
-                               
+
                                offset += nchars;
                                nchars = StrLength(Pref->Val) - offset;
                                n++;
                        }
-                       
+
                }
                else {
                        serv_printf("%s|%s", ChrPtr(Pref->Key), ChrPtr(Pref->Val));
                }
-               
+
        }
        FreeStrBuf(&SubBuf);
        DeleteHashPos(&HashPos);
@@ -366,21 +337,20 @@ void WritePrefsToServer(HashList *Hash)
 /*
  * save the modifications
  */
-void save_preferences(void) 
-{
+void save_preferences(void) {
        folder Room;
        wcsession *WCC = WC;
        int Done = 0;
        StrBuf *ReadBuf;
        long msgnum = 0L;
-       
+
        ReadBuf = NewStrBuf();
        memset(&Room, 0, sizeof(folder));
        if (goto_config_room(ReadBuf, &Room) != 0) {
                FreeStrBuf(&ReadBuf);
                FlushFolder(&Room);
 
-               return; /* oh well. */
+               return;         /* oh well. */
        }
 
        /* make shure the config room has the right type, else it might reject our config */
@@ -393,7 +363,7 @@ void save_preferences(void)
                else if (goto_config_room(ReadBuf, &Room) != 0) {
                        FreeStrBuf(&ReadBuf);
                        FlushFolder(&Room);
-                       
+
                        return; /* oh well. */
                }
        }
@@ -405,7 +375,7 @@ void save_preferences(void)
                serv_puts("000");
        }
        while (!Done && (StrBuf_ServGetln(ReadBuf) >= 0)) {
-               if ( (StrLength(ReadBuf)==3) && !strcmp(ChrPtr(ReadBuf), "000")) {
+               if ((StrLength(ReadBuf) == 3) && !strcmp(ChrPtr(ReadBuf), "000")) {
                        Done = 1;
                        break;
                }
@@ -445,8 +415,7 @@ void save_preferences(void)
  * value       StrBuf-value to the key to get
  * returns:    found?
  */
-int get_pref_backend(const char *key, size_t keylen, Preference **Pref)
-{
+int get_pref_backend(const char *key, size_t keylen, Preference ** Pref) {
        void *hash_value = NULL;
 #ifdef DBG_PREFS_HASH
        dbg_PrintHash(WC->hash_prefs, PrintPref, NULL);
@@ -456,13 +425,12 @@ int get_pref_backend(const char *key, size_t keylen, Preference **Pref)
                return 0;
        }
        else {
-               *Pref = (Preference*) hash_value;
+               *Pref = (Preference *) hash_value;
                return 1;
        }
 }
 
-int get_PREFERENCE(const char *key, size_t keylen, StrBuf **value)
-{
+int get_PREFERENCE(const char *key, size_t keylen, StrBuf ** value) {
        Preference *Pref;
        int Ret;
 
@@ -482,8 +450,7 @@ int get_PREFERENCE(const char *key, size_t keylen, StrBuf **value)
  * value               value to set
  * save_to_server      1 = flush all data to the server, 0 = cache it for now
  */
-long compare_preference(const Preference *PrefA, const Preference *PrefB)
-{
+long compare_preference(const Preference * PrefA, const Preference * PrefB) {
        ePrefType TypeA, TypeB;
 
        if (PrefA->Type != NULL) {
@@ -500,14 +467,14 @@ long compare_preference(const Preference *PrefA, const Preference *PrefB)
                TypeB = PrefB->eFlatPrefType;
        }
 
-       if (    (TypeA != PRF_UNSET)
-               && (TypeB != PRF_UNSET)
-               && (TypeA != TypeB)
-       ) {
+       if ((TypeA != PRF_UNSET)
+           && (TypeB != PRF_UNSET)
+           && (TypeA != TypeB)
+           ) {
                if (TypeA > TypeB) {
                        return 1;
                }
-               else {  /* (PrefA->Type < PrefB->Type) */
+               else {          /* (PrefA->Type < PrefB->Type) */
                        return -1;
                }
        }
@@ -515,9 +482,8 @@ long compare_preference(const Preference *PrefA, const Preference *PrefB)
        if (TypeB == PRF_UNSET) {
                TypeA = PRF_UNSET;
        }
-                   
-       switch (TypeA)
-       {
+
+       switch (TypeA) {
        default:
        case PRF_UNSET:
        case PRF_STRING:
@@ -531,8 +497,7 @@ long compare_preference(const Preference *PrefA, const Preference *PrefB)
                else
                        return -1;
        case PRF_QP_STRING:
-               return strcmp(ChrPtr(PrefA->DeQPed), 
-                             ChrPtr(PrefB->DeQPed));
+               return strcmp(ChrPtr(PrefA->DeQPed), ChrPtr(PrefB->DeQPed));
        }
 }
 
@@ -545,37 +510,28 @@ long compare_preference(const Preference *PrefA, const Preference *PrefB)
  * value               value to set
  * save_to_server      1 = flush all data to the server, 0 = cache it for now
  */
-void set_preference_backend(const char *key, size_t keylen, 
-                           long lvalue, 
-                           StrBuf *value, 
-                           long lPrefType,
-                           int save_to_server, 
-                           PrefDef *PrefType) 
-{
+void set_preference_backend(const char *key, size_t keylen,
+                           long lvalue, StrBuf * value, long lPrefType, int save_to_server, PrefDef * PrefType) {
        wcsession *WCC = WC;
        void *vPrefDef;
        void *vPrefB;
        Preference *Pref;
 
-       Pref = (Preference*) malloc(sizeof(Preference));
+       Pref = (Preference *) malloc(sizeof(Preference));
        memset(Pref, 0, sizeof(Preference));
        Pref->Key = NewStrBufPlain(key, keylen);
 
-       if ((PrefType == NULL) &&
-           GetHash(PreferenceHooks, SKEY(Pref->Key), &vPrefDef) && 
-           (vPrefDef != NULL))
-               PrefType = (PrefDef*) vPrefDef;
+       if ((PrefType == NULL) && GetHash(PreferenceHooks, SKEY(Pref->Key), &vPrefDef) && (vPrefDef != NULL))
+               PrefType = (PrefDef *) vPrefDef;
 
-       if (PrefType != NULL)
-       {
+       if (PrefType != NULL) {
                Pref->Type = PrefType;
                Pref->eFlatPrefType = PrefType->eType;
                if (Pref->Type->eType != lPrefType)
                        syslog(LOG_WARNING, "warning: saving preference with wrong type [%s] %d != %ld \n",
-                               key, Pref->Type->eType, lPrefType);
-               switch (Pref->Type->eType)
-               {
-               case PRF_UNSET: /* default to string... */
+                              key, Pref->Type->eType, lPrefType);
+               switch (Pref->Type->eType) {
+               case PRF_UNSET: /* default to string... */
                case PRF_STRING:
                        Pref->Val = value;
                        Pref->decoded = 1;
@@ -596,7 +552,7 @@ void set_preference_backend(const char *key, size_t keylen,
                        break;
                case PRF_YESNO:
                        Pref->lval = lvalue;
-                       if (lvalue) 
+                       if (lvalue)
                                Pref->Val = NewStrBufPlain(HKEY("yes"));
                        else
                                Pref->Val = NewStrBufPlain(HKEY("no"));
@@ -608,8 +564,7 @@ void set_preference_backend(const char *key, size_t keylen,
        }
        else {
                Pref->eFlatPrefType = lPrefType;
-               switch (lPrefType)
-               {
+               switch (lPrefType) {
                case PRF_STRING:
                        Pref->Val = value;
                        Pref->decoded = 1;
@@ -630,7 +585,7 @@ void set_preference_backend(const char *key, size_t keylen,
                        break;
                case PRF_YESNO:
                        Pref->lval = lvalue;
-                       if (lvalue) 
+                       if (lvalue)
                                Pref->Val = NewStrBufPlain(HKEY("yes"));
                        else
                                Pref->Val = NewStrBufPlain(HKEY("no"));
@@ -639,24 +594,21 @@ void set_preference_backend(const char *key, size_t keylen,
                }
        }
 
-       if ((save_to_server != 0) && 
-           GetHash(WCC->hash_prefs, key, keylen, &vPrefB) && 
-           (vPrefB != NULL) && 
-           (compare_preference (Pref, vPrefB) == 0))
+       if ((save_to_server != 0) &&
+           GetHash(WCC->hash_prefs, key, keylen, &vPrefB) && (vPrefB != NULL) && (compare_preference(Pref, vPrefB) == 0))
                save_to_server = 0;
 
        Put(WCC->hash_prefs, key, keylen, Pref, DestroyPreference);
-       
-       if (save_to_server) WCC->SavePrefsToServer = 1;
+
+       if (save_to_server)
+               WCC->SavePrefsToServer = 1;
 }
 
-void set_PREFERENCE(const char *key, size_t keylen, StrBuf *value, int save_to_server) 
-{
+void set_PREFERENCE(const char *key, size_t keylen, StrBuf * value, int save_to_server) {
        set_preference_backend(key, keylen, 0, value, PRF_STRING, save_to_server, NULL);
 }
 
-int get_PREF_LONG(const char *key, size_t keylen, long *value, long Default)
-{
+int get_PREF_LONG(const char *key, size_t keylen, long *value, long Default) {
        Preference *Pref;
        int Ret;
 
@@ -676,13 +628,11 @@ int get_PREF_LONG(const char *key, size_t keylen, long *value, long Default)
 }
 
 
-void set_PREF_LONG(const char *key, size_t keylen, long value, int save_to_server)
-{
+void set_PREF_LONG(const char *key, size_t keylen, long value, int save_to_server) {
        set_preference_backend(key, keylen, value, NULL, PRF_INT, save_to_server, NULL);
 }
 
-int get_PREF_YESNO(const char *key, size_t keylen, int *value, int Default)
-{
+int get_PREF_YESNO(const char *key, size_t keylen, int *value, int Default) {
        Preference *Pref;
        int Ret;
 
@@ -701,18 +651,15 @@ int get_PREF_YESNO(const char *key, size_t keylen, int *value, int Default)
        return Ret;
 }
 
-void set_PREF_YESNO(const char *key, size_t keylen, long value, int save_to_server)
-{
+void set_PREF_YESNO(const char *key, size_t keylen, long value, int save_to_server) {
        set_preference_backend(key, keylen, value, NULL, PRF_YESNO, save_to_server, NULL);
 }
 
-int get_room_prefs_backend(const char *key, size_t keylen, 
-                          Preference **Pref)
-{
+int get_room_prefs_backend(const char *key, size_t keylen, Preference ** Pref) {
        StrBuf *pref_name;
        int Ret;
 
-       pref_name = NewStrBufPlain (HKEY("ROOM:"));
+       pref_name = NewStrBufPlain(HKEY("ROOM:"));
        StrBufAppendBuf(pref_name, WC->CurRoom.name, 0);
        StrBufAppendBufPlain(pref_name, HKEY(":"), 0);
        StrBufAppendBufPlain(pref_name, key, keylen, 0);
@@ -722,14 +669,12 @@ int get_room_prefs_backend(const char *key, size_t keylen,
        return Ret;
 }
 
-const StrBuf *get_X_PREFS(const char *key, size_t keylen, 
-                         const char *xkey, size_t xkeylen)
-{
+const StrBuf *get_X_PREFS(const char *key, size_t keylen, const char *xkey, size_t xkeylen) {
        int ret;
        StrBuf *pref_name;
        Preference *Prf;
-       
-       pref_name = NewStrBufPlain (HKEY("XPREF:"));
+
+       pref_name = NewStrBufPlain(HKEY("XPREF:"));
        StrBufAppendBufPlain(pref_name, xkey, xkeylen, 0);
        StrBufAppendBufPlain(pref_name, HKEY(":"), 0);
        StrBufAppendBufPlain(pref_name, key, keylen, 0);
@@ -739,14 +684,14 @@ const StrBuf *get_X_PREFS(const char *key, size_t keylen,
 
        if (ret)
                return Prf->Val;
-       else return NULL;
+       else
+               return NULL;
 }
 
-void set_X_PREFS(const char *key, size_t keylen, const char *xkey, size_t xkeylen, StrBuf *value, int save_to_server)
-{
+void set_X_PREFS(const char *key, size_t keylen, const char *xkey, size_t xkeylen, StrBuf * value, int save_to_server) {
        StrBuf *pref_name;
-       
-       pref_name = NewStrBufPlain (HKEY("XPREF:"));
+
+       pref_name = NewStrBufPlain(HKEY("XPREF:"));
        StrBufAppendBufPlain(pref_name, xkey, xkeylen, 0);
        StrBufAppendBufPlain(pref_name, HKEY(":"), 0);
        StrBufAppendBufPlain(pref_name, key, keylen, 0);
@@ -756,8 +701,7 @@ void set_X_PREFS(const char *key, size_t keylen, const char *xkey, size_t xkeyle
 }
 
 
-long get_ROOM_PREFS_LONG(const char *key, size_t keylen, long *value, long Default)
-{
+long get_ROOM_PREFS_LONG(const char *key, size_t keylen, long *value, long Default) {
        Preference *Pref;
        int Ret;
 
@@ -778,8 +722,7 @@ long get_ROOM_PREFS_LONG(const char *key, size_t keylen, long *value, long Defau
 }
 
 
-StrBuf *get_ROOM_PREFS(const char *key, size_t keylen)
-{
+StrBuf *get_ROOM_PREFS(const char *key, size_t keylen) {
        Preference *Pref;
        int Ret;
 
@@ -788,15 +731,14 @@ StrBuf *get_ROOM_PREFS(const char *key, size_t keylen)
        if (Ret == 0) {
                return NULL;
        }
-       else 
+       else
                return Pref->Val;
 }
 
-void set_ROOM_PREFS(const char *key, size_t keylen, StrBuf *value, int save_to_server)
-{
+void set_ROOM_PREFS(const char *key, size_t keylen, StrBuf * value, int save_to_server) {
        StrBuf *pref_name;
-       
-       pref_name = NewStrBufPlain (HKEY("ROOM:"));
+
+       pref_name = NewStrBufPlain(HKEY("ROOM:"));
        StrBufAppendBuf(pref_name, WC->CurRoom.name, 0);
        StrBufAppendBufPlain(pref_name, HKEY(":"), 0);
        StrBufAppendBufPlain(pref_name, key, keylen, 0);
@@ -805,9 +747,8 @@ void set_ROOM_PREFS(const char *key, size_t keylen, StrBuf *value, int save_to_s
 }
 
 
-void GetPreferences(HashList *Setting)
-{
-        wcsession *WCC = WC;
+void GetPreferences(HashList * Setting) {
+       wcsession *WCC = WC;
        HashPos *It;
        long len;
        const char *Key;
@@ -822,7 +763,7 @@ void GetPreferences(HashList *Setting)
 
        It = GetNewHashPos(PreferenceHooks, 0);
        while (GetNextHashPos(PreferenceHooks, It, &len, &Key, &vSetting)) {
-               PrefType = (PrefDef*) vSetting;
+               PrefType = (PrefDef *) vSetting;
 
                if (!HaveBstr(SKEY(PrefType->Setting)))
                        continue;
@@ -830,39 +771,19 @@ void GetPreferences(HashList *Setting)
                case PRF_UNSET:
                case PRF_STRING:
                        Buf = NewStrBufDup(SBstr(SKEY(PrefType->Setting)));
-                       set_preference_backend(SKEY(PrefType->Setting),
-                                              0, 
-                                              Buf, 
-                                              PRF_STRING,
-                                              1, 
-                                              PrefType);
+                       set_preference_backend(SKEY(PrefType->Setting), 0, Buf, PRF_STRING, 1, PrefType);
                        break;
                case PRF_INT:
                        lval = LBstr(SKEY(PrefType->Setting));
-                       set_preference_backend(SKEY(PrefType->Setting),
-                                              lval, 
-                                              NULL, 
-                                              PRF_INT,
-                                              1, 
-                                              PrefType);
+                       set_preference_backend(SKEY(PrefType->Setting), lval, NULL, PRF_INT, 1, PrefType);
                        break;
                case PRF_QP_STRING:
                        Buf = NewStrBufDup(SBstr(SKEY(PrefType->Setting)));
-                       set_preference_backend(SKEY(PrefType->Setting),
-                                              0, 
-                                              Buf, 
-                                              PRF_QP_STRING,
-                                              1, 
-                                              PrefType);
+                       set_preference_backend(SKEY(PrefType->Setting), 0, Buf, PRF_QP_STRING, 1, PrefType);
                        break;
                case PRF_YESNO:
                        lval = YesBstr(SKEY(PrefType->Setting));
-                       set_preference_backend(SKEY(PrefType->Setting),
-                                              lval, 
-                                              NULL, 
-                                              PRF_YESNO,
-                                              1, 
-                                              PrefType);
+                       set_preference_backend(SKEY(PrefType->Setting), lval, NULL, PRF_YESNO, 1, PrefType);
                        break;
                }
        }
@@ -874,8 +795,7 @@ void GetPreferences(HashList *Setting)
 /*
  * Commit new preferences and settings
  */
-void set_preferences(void)
-{      
+void set_preferences(void) {
        if (!havebstr("change_button")) {
                AppendImportantMessage(_("Cancelled.  No settings were changed."), -1);
                display_main_menu();
@@ -886,17 +806,14 @@ void set_preferences(void)
 }
 
 
-void tmplput_CFG_Value(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_CFG_Value(StrBuf * Target, WCTemplputParams * TP) {
        Preference *Pref;
-       if (get_pref_backend(TKEY(0), &Pref))
-       {
+       if (get_pref_backend(TKEY(0), &Pref)) {
                if (Pref->Type == NULL) {
                        StrBufAppendTemplate(Target, TP, Pref->Val, 1);
                }
-               switch (Pref->Type->eType)
-               {
-               case PRF_UNSET: /* default to string... */
+               switch (Pref->Type->eType) {
+               case PRF_UNSET: /* default to string... */
                case PRF_STRING:
                        StrBufAppendTemplate(Target, TP, Pref->Val, 1);
                        break;
@@ -913,7 +830,7 @@ void tmplput_CFG_Value(StrBuf *Target, WCTemplputParams *TP)
                        if (Pref->decoded != 1) {
                                if (Pref->DeQPed == NULL)
                                        Pref->DeQPed = NewStrBufPlain(NULL, StrLength(Pref->Val));
-                                       
+
                                StrBufEUid_unescapize(Pref->DeQPed, Pref->Val);
                                Pref->decoded = 1;
                        }
@@ -930,15 +847,13 @@ void tmplput_CFG_Value(StrBuf *Target, WCTemplputParams *TP)
        }
 }
 
-void tmplput_CFG_Descr(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_CFG_Descr(StrBuf * Target, WCTemplputParams * TP) {
        const char *SettingStr;
        SettingStr = PrefGetLocalStr(TKEY(0));
-       if (SettingStr != NULL) 
+       if (SettingStr != NULL)
                StrBufAppendBufPlain(Target, SettingStr, -1, 0);
 }
-void tmplput_CFG_RoomValueLong(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_CFG_RoomValueLong(StrBuf * Target, WCTemplputParams * TP) {
        long lvalue;
        long defval = 0;
 
@@ -947,55 +862,46 @@ void tmplput_CFG_RoomValueLong(StrBuf *Target, WCTemplputParams *TP)
        get_ROOM_PREFS_LONG(TKEY(0), &lvalue, defval);
        StrBufAppendPrintf(Target, "%ld", lvalue);
 }
-void tmplput_CFG_RoomValue(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_CFG_RoomValue(StrBuf * Target, WCTemplputParams * TP) {
        StrBuf *pref = get_ROOM_PREFS(TKEY(0));
-       if (pref != NULL) 
+       if (pref != NULL)
                StrBufAppendBuf(Target, pref, 0);
 }
-int ConditionalHasRoomPreference(StrBuf *Target, WCTemplputParams *TP) 
-{
-       if (get_ROOM_PREFS(TP->Tokens->Params[0]->Start, 
-                          TP->Tokens->Params[0]->len) != NULL) 
+int ConditionalHasRoomPreference(StrBuf * Target, WCTemplputParams * TP) {
+       if (get_ROOM_PREFS(TP->Tokens->Params[0]->Start, TP->Tokens->Params[0]->len) != NULL)
                return 1;
-  
+
        return 0;
 }
 
-int ConditionalPreference(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalPreference(StrBuf * Target, WCTemplputParams * TP) {
        StrBuf *Pref;
 
-       if (!get_PREFERENCE(TKEY(2), &Pref)) 
+       if (!get_PREFERENCE(TKEY(2), &Pref))
                return 0;
-       
+
        if (!HAVE_PARAM(3)) {
                return 1;
        }
-       else if (IS_NUMBER(TP->Tokens->Params[3]->Type))
-       {
-               return StrTol(Pref) == GetTemplateTokenNumber (Target, TP, 3, 0);
+       else if (IS_NUMBER(TP->Tokens->Params[3]->Type)) {
+               return StrTol(Pref) == GetTemplateTokenNumber(Target, TP, 3, 0);
        }
-       else 
-       {
+       else {
                const char *pch;
                long len;
-               
+
                GetTemplateTokenString(Target, TP, 3, &pch, &len);
-               
-               return ((len == StrLength(Pref)) &&
-                       (strcmp(pch, ChrPtr(Pref)) == 0));
+
+               return ((len == StrLength(Pref)) && (strcmp(pch, ChrPtr(Pref)) == 0));
        }
 }
 
-int ConditionalHasPreference(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalHasPreference(StrBuf * Target, WCTemplputParams * TP) {
        StrBuf *Pref;
 
-       if (!get_PREFERENCE(TKEY(2), &Pref) || 
-           (Pref == NULL)) 
+       if (!get_PREFERENCE(TKEY(2), &Pref) || (Pref == NULL))
                return 0;
-       else 
+       else
                return 1;
 }
 
@@ -1007,26 +913,22 @@ CtxType CTX_VEA = CTX_NONE;
 typedef struct __ValidEmailAddress {
        StrBuf *Address;
        int IsDefault;
-}ValidEmailAddress;
+} ValidEmailAddress;
 
-void DeleteValidEmailAddress(void *v)
-{
-       ValidEmailAddress *VEA = (ValidEmailAddress*)v;
+void DeleteValidEmailAddress(void *v) {
+       ValidEmailAddress *VEA = (ValidEmailAddress *) v;
        FreeStrBuf(&VEA->Address);
        free(VEA);
 }
-void tmplput_VEA(StrBuf *Target, WCTemplputParams *TP)
-{
-       ValidEmailAddress* VEA = (ValidEmailAddress*) CTX((CTX_VEA));
+void tmplput_VEA(StrBuf * Target, WCTemplputParams * TP) {
+       ValidEmailAddress *VEA = (ValidEmailAddress *) CTX((CTX_VEA));
        StrBufAppendTemplate(Target, TP, VEA->Address, 0);
 }
-int ConditionalPreferenceIsDefaulVEA(StrBuf *Target, WCTemplputParams *TP)
-{
-       ValidEmailAddress* VEA = (ValidEmailAddress*) CTX((CTX_VEA));
+int ConditionalPreferenceIsDefaulVEA(StrBuf * Target, WCTemplputParams * TP) {
+       ValidEmailAddress *VEA = (ValidEmailAddress *) CTX((CTX_VEA));
        return VEA->IsDefault;
 }
-HashList *GetGVEAHash(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *GetGVEAHash(StrBuf * Target, WCTemplputParams * TP) {
        StrBuf *Rcp;
        HashList *List = NULL;
        int Done = 0;
@@ -1044,14 +946,12 @@ HashList *GetGVEAHash(StrBuf *Target, WCTemplputParams *TP)
        if (GetServerStatus(Rcp, NULL) == 1) {
                FlushStrBuf(Rcp);
                List = NewHash(1, NULL);
-               while (!Done && (StrBuf_ServGetln(Rcp)>=0)) {
-                       if ( (StrLength(Rcp)==3) && 
-                            !strcmp(ChrPtr(Rcp), "000")) 
-                       {
+               while (!Done && (StrBuf_ServGetln(Rcp) >= 0)) {
+                       if ((StrLength(Rcp) == 3) && !strcmp(ChrPtr(Rcp), "000")) {
                                Done = 1;
                        }
                        else {
-                               VEA = (ValidEmailAddress*) malloc(sizeof(ValidEmailAddress));
+                               VEA = (ValidEmailAddress *) malloc(sizeof(ValidEmailAddress));
                                i = snprintf(N, sizeof(N), "%d", n);
                                StrBufTrim(Rcp);
                                VEA->Address = Rcp;
@@ -1071,13 +971,11 @@ HashList *GetGVEAHash(StrBuf *Target, WCTemplputParams *TP)
        FreeStrBuf(&Rcp);
        return List;
 }
-void DeleteGVEAHash(HashList **KillMe)
-{
+void DeleteGVEAHash(HashList ** KillMe) {
        DeleteHash(KillMe);
 }
 
-HashList *GetGVSNHash(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *GetGVSNHash(StrBuf * Target, WCTemplputParams * TP) {
        StrBuf *Rcp;
        HashList *List = NULL;
        int Done = 0;
@@ -1090,10 +988,8 @@ HashList *GetGVSNHash(StrBuf *Target, WCTemplputParams *TP)
        if (GetServerStatus(Rcp, NULL) == 1) {
                FlushStrBuf(Rcp);
                List = NewHash(1, NULL);
-               while (!Done && (StrBuf_ServGetln(Rcp)>=0)) {
-                       if ( (StrLength(Rcp)==3) && 
-                            !strcmp(ChrPtr(Rcp), "000")) 
-                       {
+               while (!Done && (StrBuf_ServGetln(Rcp) >= 0)) {
+                       if ((StrLength(Rcp) == 3) && !strcmp(ChrPtr(Rcp), "000")) {
                                Done = 1;
                        }
                        else {
@@ -1108,8 +1004,7 @@ HashList *GetGVSNHash(StrBuf *Target, WCTemplputParams *TP)
        FreeStrBuf(&Rcp);
        return List;
 }
-void DeleteGVSNHash(HashList **KillMe)
-{
+void DeleteGVSNHash(HashList ** KillMe) {
        DeleteHash(KillMe);
 }
 
@@ -1119,8 +1014,7 @@ void DeleteGVSNHash(HashList **KillMe)
 /*
  * Offer to make any page the user's "start page" (only if logged in)
  */
-void offer_start_page(StrBuf *Target, WCTemplputParams *TP)
-{
+void offer_start_page(StrBuf * Target, WCTemplputParams * TP) {
        if (WC->logged_in) {
                wc_printf("<a href=\"change_start_page?startpage=");
                urlescputs(ChrPtr(WC->Hdr->this_page));
@@ -1134,8 +1028,7 @@ void offer_start_page(StrBuf *Target, WCTemplputParams *TP)
 /*
  * Change the user's start page
  */
-void change_start_page(void) 
-{
+void change_start_page(void) {
        const char *pch;
        void *vHandler;
        int ProhibitSave = 0;
@@ -1144,24 +1037,13 @@ void change_start_page(void)
        if (pStartPage != NULL) {
                pch = strchr(ChrPtr(pStartPage), '?');
 
-               if ((pch != NULL) && (
-                           GetHash(HandlerHash, ChrPtr(pStartPage), pch - ChrPtr(pStartPage), &vHandler), 
-                           (vHandler != NULL) &&
-                           ((((WebcitHandler*)vHandler)->Flags & PROHIBIT_STARTPAGE) != 0)))
-               { /* OK, This handler doesn't want to be set as start page, prune it. */
+               if ((pch != NULL) && (GetHash(HandlerHash, ChrPtr(pStartPage), pch - ChrPtr(pStartPage), &vHandler), (vHandler != NULL) && ((((WebcitHandler *) vHandler)->Flags & PROHIBIT_STARTPAGE) != 0))) {        /* OK, This handler doesn't want to be set as start page, prune it. */
                        ProhibitSave = 1;
                }
        }
 
-       if ((pStartPage == NULL) || 
-           (ProhibitSave == 1))
-       {
-               set_preference_backend(HKEY("startpage"), 
-                                      0, 
-                                      NewStrBufPlain(HKEY("")),
-                                      PRF_STRING,
-                                      1, 
-                                      NULL);
+       if ((pStartPage == NULL) || (ProhibitSave == 1)) {
+               set_preference_backend(HKEY("startpage"), 0, NewStrBufPlain(HKEY("")), PRF_STRING, 1, NULL);
                if (ProhibitSave == 1)
                        AppendImportantMessage(_("This isn't allowed to become the start page."), -1);
                else
@@ -1172,12 +1054,7 @@ void change_start_page(void)
 
 
 
-       set_preference_backend(HKEY("startpage"), 
-                              0, 
-                              NewStrBufDup(pStartPage),
-                              PRF_STRING,
-                              1, 
-                              NULL);
+       set_preference_backend(HKEY("startpage"), 0, NewStrBufDup(pStartPage), PRF_STRING, 1, NULL);
 
        output_headers(1, 1, 0, 0, 0, 0);
        do_template("newstartpage");
@@ -1185,8 +1062,7 @@ void change_start_page(void)
 }
 
 
-void LoadStartpage(StrBuf *URL, long lvalue)
-{
+void LoadStartpage(StrBuf * URL, long lvalue) {
        const char *pch;
        void *vHandler;
        pch = strchr(ChrPtr(URL), '?');
@@ -1198,20 +1074,14 @@ void LoadStartpage(StrBuf *URL, long lvalue)
                        WC->SavePrefsToServer = 1;
                }
        }
-       else if (GetHash(HandlerHash, ChrPtr(URL), pch - ChrPtr(URL), &vHandler), 
-                (vHandler != NULL) &&
-                ((((WebcitHandler*)vHandler)->Flags & PROHIBIT_STARTPAGE) != 0))
-       { /* OK, This handler doesn't want to be set as start page, prune it. */
+       else if (GetHash(HandlerHash, ChrPtr(URL), pch - ChrPtr(URL), &vHandler), (vHandler != NULL) && ((((WebcitHandler *) vHandler)->Flags & PROHIBIT_STARTPAGE) != 0)) {    /* OK, This handler doesn't want to be set as start page, prune it. */
                FlushStrBuf(URL);
                WC->SavePrefsToServer = 1;
        }
 }
 
 
-void 
-InitModule_PREFERENCES
-(void)
-{
+void InitModule_PREFERENCES(void) {
        RegisterCTX(CTX_VEA);
 
        WebcitAddUrlHandler(HKEY("set_preferences"), "", 0, set_preferences, 0);
@@ -1220,63 +1090,46 @@ InitModule_PREFERENCES
        RegisterPreference("startpage", _("Prefered startpage"), PRF_STRING, LoadStartpage);
 
        RegisterNamespace("OFFERSTARTPAGE", 0, 0, offer_start_page, NULL, CTX_NONE);
-       RegisterNamespace("PREF:ROOM:VALUE", 1, 2, tmplput_CFG_RoomValue,  NULL, CTX_NONE);
-       RegisterNamespace("PREF:ROOM:VALUE:INT", 1, 2, tmplput_CFG_RoomValueLong,  NULL, CTX_NONE);
+       RegisterNamespace("PREF:ROOM:VALUE", 1, 2, tmplput_CFG_RoomValue, NULL, CTX_NONE);
+       RegisterNamespace("PREF:ROOM:VALUE:INT", 1, 2, tmplput_CFG_RoomValueLong, NULL, CTX_NONE);
        RegisterNamespace("PREF:VALUE", 1, 2, tmplput_CFG_Value, NULL, CTX_NONE);
-       
+
        RegisterNamespace("PREF:DESCR", 1, 1, tmplput_CFG_Descr, NULL, CTX_NONE);
 
        RegisterConditional("COND:PREF", 4, ConditionalPreference, CTX_NONE);
        RegisterConditional("COND:PREF:SET", 4, ConditionalHasPreference, CTX_NONE);
        RegisterConditional("COND:ROOM:SET", 4, ConditionalHasRoomPreference, CTX_NONE);
-       
-       RegisterIterator("PREF:VALID:EMAIL:ADDR", 0, NULL, 
-                        GetGVEAHash, NULL, DeleteGVEAHash, CTX_VEA, CTX_NONE, IT_NOFLAG);
+
+       RegisterIterator("PREF:VALID:EMAIL:ADDR", 0, NULL, GetGVEAHash, NULL, DeleteGVEAHash, CTX_VEA, CTX_NONE, IT_NOFLAG);
        RegisterNamespace("PREF:VALID:EMAIL:ADDR:STR", 1, 1, tmplput_VEA, NULL, CTX_VEA);
        RegisterConditional("COND:PREF:VALID:EMAIL:ADDR:STR", 4, ConditionalPreferenceIsDefaulVEA, CTX_VEA);
 
-       RegisterIterator("PREF:VALID:EMAIL:NAME", 0, NULL, 
-                        GetGVSNHash, NULL, DeleteGVSNHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
+       RegisterIterator("PREF:VALID:EMAIL:NAME", 0, NULL, GetGVSNHash, NULL, DeleteGVSNHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
 
 }
 
 
-void 
-ServerStartModule_PREFERENCES
-(void)
-{
+void ServerStartModule_PREFERENCES(void) {
        PreferenceHooks = NewHash(1, NULL);
 }
 
 
 
-void 
-ServerShutdownModule_PREFERENCES
-(void)
-{
+void ServerShutdownModule_PREFERENCES(void) {
        DeleteHash(&PreferenceHooks);
 }
 
-void
-SessionDetachModule__PREFERENCES
-(wcsession *sess)
-{
+void SessionDetachModule__PREFERENCES(wcsession * sess) {
        if (sess->SavePrefsToServer) {
                save_preferences();
                sess->SavePrefsToServer = 0;
        }
 }
 
-void
-SessionNewModule_PREFERENCES
-(wcsession *sess)
-{
-       sess->hash_prefs = NewHash(1,NULL);
+void SessionNewModule_PREFERENCES(wcsession * sess) {
+       sess->hash_prefs = NewHash(1, NULL);
 }
 
-void 
-SessionDestroyModule_PREFERENCES
-(wcsession *sess)
-{
+void SessionDestroyModule_PREFERENCES(wcsession * sess) {
        DeleteHash(&sess->hash_prefs);
 }
index 7a30a7bbde56a33d5aee5088b0775594ebc881ef..e1f9a084143a7264f3ef27484b2e7664b3ea5b53 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2013 by the citadel.org team
  *
@@ -11,7 +12,7 @@
  */
 
 
-typedef enum _ePrefType{
+typedef enum _ePrefType {
        PRF_UNSET = 0,
        PRF_STRING = 1,
        PRF_INT = 2,
@@ -20,13 +21,10 @@ typedef enum _ePrefType{
 } ePrefType;
 
 
-typedef void (*PrefEvalFunc)(StrBuf *Preference, long lvalue); 
+typedef void (*PrefEvalFunc)(StrBuf * Preference, long lvalue);
 
-void _RegisterPreference(const char *Setting, long SettingLen, 
-                        const char *PrefStr, 
-                        ePrefType Type, 
-                        PrefEvalFunc OnLoad, 
-                        const char *OnLoadName);
+void _RegisterPreference(const char *Setting, long SettingLen,
+                        const char *PrefStr, ePrefType Type, PrefEvalFunc OnLoad, const char *OnLoadName);
 
 #define RegisterPreference(a, b, c, d) _RegisterPreference(a, sizeof(a) -1, b, c, d, #d)
 
@@ -34,10 +32,10 @@ void load_preferences(void);
 void save_preferences(void);
 #define get_preference(a, b) get_PREFERENCE(a, sizeof(a) - 1, b)
 #define get_pref(a, b)       get_PREFERENCE(SKEY(a), b)
-int get_PREFERENCE(const char *key, size_t keylen, StrBuf **value);
+int get_PREFERENCE(const char *key, size_t keylen, StrBuf ** value);
 #define set_preference(a, b, c) set_PREFERENCE(a, sizeof(a) - 1, b, c)
 #define set_pref(a, b, c)       set_PREFERENCE(SKEY(a), b, c)
-void set_PREFERENCE(const char *key, size_t keylen, StrBuf *value, int save_to_server);
+void set_PREFERENCE(const char *key, size_t keylen, StrBuf * value, int save_to_server);
 
 #define get_pref_long(a, b, c) get_PREF_LONG(a, sizeof(a) - 1, b, c)
 int get_PREF_LONG(const char *key, size_t keylen, long *value, long Default);
@@ -53,16 +51,15 @@ void set_PREF_YESNO(const char *key, size_t keylen, long value, int save_to_serv
 StrBuf *get_ROOM_PREFS(const char *key, size_t keylen);
 
 #define set_room_pref(a, b, c) set_ROOM_PREFS(a, sizeof(a) - 1, b, c)
-void set_ROOM_PREFS(const char *key, size_t keylen, StrBuf *value, int save_to_server);
+void set_ROOM_PREFS(const char *key, size_t keylen, StrBuf * value, int save_to_server);
 #define get_room_pref_long(a, b, c) get_ROOM_PREFS_LONG(a, sizeof(a) - 1, b, c)
 long get_ROOM_PREFS_LONG(const char *key, size_t keylen, long *value, long Default);
 
 
 #define get_x_pref(a, b) get_ROOM_PREFS(a, sizeof(a) - 1, b, sizeof(b) - 1)
-const StrBuf *get_X_PREFS(const char *key, size_t keylen, 
-                         const char *xkey, size_t xkeylen);
+const StrBuf *get_X_PREFS(const char *key, size_t keylen, const char *xkey, size_t xkeylen);
 
 #define set_x_pref(a, b, c) set_ROOM_PREFS(a, sizeof(a) - 1, b, sizeof(b) - 1, c, d)
-void set_X_PREFS(const char *key, size_t keylen, const char *xkey, size_t xkeylen, StrBuf *value, int save_to_server);
+void set_X_PREFS(const char *key, size_t keylen, const char *xkey, size_t xkeylen, StrBuf * value, int save_to_server);
 
-int goto_config_room(StrBuf *Buf, folder *room);
+int goto_config_room(StrBuf * Buf, folder * room);
index 92fd026b13d5f45fb9975252db923598f4f428d8..e3abeb698c3eeadd4ec39433ff49a168e51af413 100644 (file)
@@ -1,22 +1,22 @@
+
 /*
  * Edits a users push email settings 
  * Author: Mathew McBride <matt@mcbridematt.dhs.org>
  */
 #include "webcit.h"
 
-void display_pushemail(void) 
-{
+void display_pushemail(void) {
        folder Room;
        int Done = 0;
        StrBuf *Buf;
-       long vector[8] = {8, 0, 0, 1, 2, 3, 4, 5};
+       long vector[8] = { 8, 0, 0, 1, 2, 3, 4, 5 };
        WCTemplputParams SubTP;
        char mobnum[20];
 
        StackContext(NULL, &SubTP, &vector, CTX_LONGVECTOR, 0, NULL);
        vector[0] = 16;
 
-       /* Find any existing settings*/
+       /* Find any existing settings */
        Buf = NewStrBuf();
        memset(&Room, 0, sizeof(folder));
        if (goto_config_room(Buf, &Room) == 0) {
@@ -26,10 +26,8 @@ void display_pushemail(void)
                if (GetServerStatus(Buf, NULL) == 8) {
                        serv_puts("subj|__ Push email settings __");
                        serv_puts("000");
-                       while (!Done &&
-                              StrBuf_ServGetln(Buf) >= 0) {
-                               if ( (StrLength(Buf)==3) && 
-                                    !strcmp(ChrPtr(Buf), "000")) {
+                       while (!Done && StrBuf_ServGetln(Buf) >= 0) {
+                               if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
                                        Done = 1;
                                        break;
                                }
@@ -37,48 +35,47 @@ void display_pushemail(void)
                        }
                }
                if (msgnum > 0L) {
-               serv_printf("MSG0 %d", msgnum);
-               StrBuf_ServGetln(Buf);
-               if (GetServerStatus(Buf, NULL) == 1) {
-                       int i =0;
-                       Done = 0;
-                       while (!Done &&
-                              StrBuf_ServGetln(Buf) >= 0) {
-                               if (( (StrLength(Buf)==3) && 
-                                     !strcmp(ChrPtr(Buf), "000"))||
-                                   ((StrLength(Buf)==4) && 
-                                    !strcmp(ChrPtr(Buf), "text")))
-                               {
-                                       Done = 1;
-                                       break;
-                               }
-                       }
-                       if (!strcmp(ChrPtr(Buf), "text")) {
+                       serv_printf("MSG0 %d", msgnum);
+                       StrBuf_ServGetln(Buf);
+                       if (GetServerStatus(Buf, NULL) == 1) {
+                               int i = 0;
                                Done = 0;
-                               while (!Done &&
-                                      StrBuf_ServGetln(Buf) >= 0) {
-                                       if ( (StrLength(Buf)==3) && 
-                                            !strcmp(ChrPtr(Buf), "000")) {
+                               while (!Done && StrBuf_ServGetln(Buf) >= 0) {
+                                       if (((StrLength(Buf) == 3) &&
+                                            !strcmp(ChrPtr(Buf), "000")) ||
+                                           ((StrLength(Buf) == 4) && !strcmp(ChrPtr(Buf), "text"))) {
                                                Done = 1;
                                                break;
                                        }
-                                       if (strncasecmp(ChrPtr(Buf), "none", 4) == 0) {
-                                               vector[1] = 0;
-                                       } else if (strncasecmp(ChrPtr(Buf), "textmessage", 11) == 0) {
-                                               vector[1] = 1;
-                                               i++;
-                                       } else if (strncasecmp(ChrPtr(Buf), "funambol", 8) == 0) {
-                                               vector[1] = 2;
-                                       } else if (strncasecmp(ChrPtr(Buf), "httpmessage", 12) == 0) {
-                                               vector[1] = 3;
-                                       } else if (i == 1) {
-                                               strncpy(mobnum, ChrPtr(Buf), 20);
-                                               i++;
+                               }
+                               if (!strcmp(ChrPtr(Buf), "text")) {
+                                       Done = 0;
+                                       while (!Done && StrBuf_ServGetln(Buf) >= 0) {
+                                               if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
+                                                       Done = 1;
+                                                       break;
+                                               }
+                                               if (strncasecmp(ChrPtr(Buf), "none", 4) == 0) {
+                                                       vector[1] = 0;
+                                               }
+                                               else if (strncasecmp(ChrPtr(Buf), "textmessage", 11) == 0) {
+                                                       vector[1] = 1;
+                                                       i++;
+                                               }
+                                               else if (strncasecmp(ChrPtr(Buf), "funambol", 8) == 0) {
+                                                       vector[1] = 2;
+                                               }
+                                               else if (strncasecmp(ChrPtr(Buf), "httpmessage", 12) == 0) {
+                                                       vector[1] = 3;
+                                               }
+                                               else if (i == 1) {
+                                                       strncpy(mobnum, ChrPtr(Buf), 20);
+                                                       i++;
+                                               }
                                        }
-                               }       
+                               }
                        }
                }
-               }
                serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
                StrBuf_ServGetln(Buf);
                GetServerStatus(Buf, NULL);
@@ -91,8 +88,7 @@ void display_pushemail(void)
        FreeStrBuf(&Buf);
 }
 
-void save_pushemail(void) 
-{
+void save_pushemail(void) {
        folder Room;
        int Done = 0;
        StrBuf *Buf;
@@ -109,7 +105,7 @@ void save_pushemail(void)
        if (goto_config_room(Buf, &Room) != 0) {
                FreeStrBuf(&Buf);
                FlushFolder(&Room);
-               return; /* oh well. */
+               return;         /* oh well. */
        }
        FlushFolder(&Room);
 
@@ -118,16 +114,15 @@ void save_pushemail(void)
        if (GetServerStatus(Buf, NULL) == 8) {
                serv_puts("subj|__ Push email settings __");
                serv_puts("000");
-       } else {
+       }
+       else {
                printf("Junk in save_pushemail buffer!: %s\n", buf);
                FreeStrBuf(&Buf);
                return;
        }
 
-       while (!Done &&
-              StrBuf_ServGetln(Buf) >= 0) {
-               if ( (StrLength(Buf)==3) && 
-                    !strcmp(ChrPtr(Buf), "000")) {
+       while (!Done && StrBuf_ServGetln(Buf) >= 0) {
+               if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
                        Done = 1;
                        break;
                }
@@ -145,8 +140,8 @@ void save_pushemail(void)
        if (GetServerStatus(Buf, NULL) == 4) {
                serv_puts(pushsetting);
                if (sms != NULL) {
-               serv_puts(sms);
-               } 
+                       serv_puts(sms);
+               }
                serv_puts("");
                serv_puts("000");
        }
@@ -159,10 +154,7 @@ void save_pushemail(void)
        FreeStrBuf(&Buf);
 }
 
-void 
-InitModule_PUSHMAIL
-(void)
-{
+void InitModule_PUSHMAIL(void) {
        WebcitAddUrlHandler(HKEY("display_pushemail"), "", 0, display_pushemail, 0);
        WebcitAddUrlHandler(HKEY("save_pushemail"), "", 0, save_pushemail, 0);
 }
index 3b0091e441a3d55799b1ce56e836c03705990eb7..21c27f7f8d45e57303c1eafb6a1370c0170918d7 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * This module handles multiuser chat.
  *
@@ -18,8 +19,7 @@
 /*
  * Display the screen containing multiuser chat for a room.
  */
-void do_chat(void)
-{
+void do_chat(void) {
        char buf[256];
 
        WC->last_chat_seq = 0;
@@ -141,15 +141,12 @@ void chat_exit(void) {
        char buf[1024];
 
        serv_puts("RCHT exit");
-       serv_getln(buf, sizeof buf);            /* Throw away the server reply */
+       serv_getln(buf, sizeof buf);    /* Throw away the server reply */
 }
 
 
 
-void 
-InitModule_ROOMCHAT
-(void)
-{
+void InitModule_ROOMCHAT(void) {
        WebcitAddUrlHandler(HKEY("chat"), "", 0, do_chat, 0);
        WebcitAddUrlHandler(HKEY("chat_recv"), "", 0, chat_recv, AJAX);
        WebcitAddUrlHandler(HKEY("chat_rwho"), "", 0, chat_rwho, AJAX);
@@ -158,9 +155,6 @@ InitModule_ROOMCHAT
 }
 
 
-void 
-SessionDestroyModule_ROOMCHAT
-(wcsession *sess)
-{
+void SessionDestroyModule_ROOMCHAT(wcsession * sess) {
        /* nothing here anymore */
 }
index b9f967ce6cd6fd988e9897130c2d931c9b1fdd81..695a7a01a06e4e9a1e2f189f50798c00a7f2ec9c 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * room listings and filters.
  */
@@ -9,10 +10,9 @@ typedef enum __eRoomParamType {
        eNotSet,
        eDomain,
        eAlias
-}eRoomParamType;
+} eRoomParamType;
 
-HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *GetWhoKnowsHash(StrBuf * Target, WCTemplputParams * TP) {
        StrBuf *Line;
        StrBuf *Token;
        long State;
@@ -23,26 +23,19 @@ HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
        serv_puts("WHOK");
        Line = NewStrBuf();
        StrBuf_ServGetln(Line);
-       if (GetServerStatus(Line, &State) == 1) 
-       {
+       if (GetServerStatus(Line, &State) == 1) {
                Whok = NewHash(1, Flathash);
-               while(!Done && (StrBuf_ServGetln(Line) >= 0) )
-                       if ( (StrLength(Line)==3) && 
-                            !strcmp(ChrPtr(Line), "000")) 
-                       {
+               while (!Done && (StrBuf_ServGetln(Line) >= 0))
+                       if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
                                Done = 1;
                        }
-                       else
-                       {
-                       
+                       else {
+
                                const char *Pos = NULL;
-                               Token = NewStrBufPlain (NULL, StrLength(Line));
+                               Token = NewStrBufPlain(NULL, StrLength(Line));
                                StrBufExtract_NextToken(Token, Line, &Pos, '|');
 
-                               Put(Whok, 
-                                   IKEY(n),
-                                   Token, 
-                                   HFreeStrBuf);
+                               Put(Whok, IKEY(n), Token, HFreeStrBuf);
                                n++;
                        }
        }
@@ -55,19 +48,17 @@ HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void DeleteFloor(void *vFloor)
-{
+void DeleteFloor(void *vFloor) {
        Floor *pFloor;
-       pFloor = (Floor*) vFloor;
+       pFloor = (Floor *) vFloor;
        FreeStrBuf(&pFloor->Name);
        free(pFloor);
 }
 
-int SortFloorsByNameOrder(const void *vfloor1, const void *vfloor2) 
-{
-       Floor *f1 = (Floor*) GetSearchPayload(vfloor1);
-       Floor *f2 = (Floor*) GetSearchPayload(vfloor2);
-       
+int SortFloorsByNameOrder(const void *vfloor1, const void *vfloor2) {
+       Floor *f1 = (Floor *) GetSearchPayload(vfloor1);
+       Floor *f2 = (Floor *) GetSearchPayload(vfloor2);
+
        /* prefer My floor over alpabetical sort */
        if (f1->ID == VIRTUAL_MY_FLOOR)
                return 1;
@@ -77,8 +68,7 @@ int SortFloorsByNameOrder(const void *vfloor1, const void *vfloor2)
        return strcmp(ChrPtr(f1->Name), ChrPtr(f2->Name));
 }
 
-HashList *GetFloorListHash(StrBuf *Target, WCTemplputParams *TP) 
-{
+HashList *GetFloorListHash(StrBuf * Target, WCTemplputParams * TP) {
        int Done = 0;
        const char *Err;
        StrBuf *Buf;
@@ -100,30 +90,26 @@ HashList *GetFloorListHash(StrBuf *Target, WCTemplputParams *TP)
        WCC->FloorsByName = floorsbyname = NewHash(1, NULL);
        Buf = NewStrBuf();
 
-       pFloor = (Floor*) malloc(sizeof(Floor));
+       pFloor = (Floor *) malloc(sizeof(Floor));
        pFloor->ID = VIRTUAL_MY_FLOOR;
        pFloor->Name = NewStrBufPlain(_("My Folders"), -1);
        pFloor->NRooms = 0;
-       
+
        Put(floors, IKEY(pFloor->ID), pFloor, DeleteFloor);
        Put(floorsbyname, SKEY(pFloor->Name), pFloor, reference_free_handler);
 
-       serv_puts("LFLR"); /* get floors */
-       StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err); /* '100', we hope */
-       if (GetServerStatus(Buf, NULL) == 1) 
-       {
-               while(!Done && StrBuf_ServGetln(Buf) >= 0)
-                       if ( (StrLength(Buf)==3) && 
-                            !strcmp(ChrPtr(Buf), "000")) 
-                       {
+       serv_puts("LFLR");      /* get floors */
+       StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);      /* '100', we hope */
+       if (GetServerStatus(Buf, NULL) == 1) {
+               while (!Done && StrBuf_ServGetln(Buf) >= 0)
+                       if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
                                Done = 1;
                        }
-                       else
-                       {
-                       
+                       else {
+
                                Pos = NULL;
 
-                               pFloor = (Floor*) malloc(sizeof(Floor));
+                               pFloor = (Floor *) malloc(sizeof(Floor));
                                pFloor->ID = StrBufExtractNext_int(Buf, &Pos, '|');
                                pFloor->Name = NewStrBufPlain(NULL, StrLength(Buf));
                                StrBufExtract_NextToken(pFloor->Name, Buf, &Pos, '|');
@@ -134,21 +120,20 @@ HashList *GetFloorListHash(StrBuf *Target, WCTemplputParams *TP)
                        }
        }
        FreeStrBuf(&Buf);
-       
+
        /* now lets pre-sort them alphabeticaly. */
        i = 1;
        SortByPayload(floors, SortFloorsByNameOrder);
        it = GetNewHashPos(floors, 0);
-       while ( GetNextHashPos(floors, it, &HKLen, &HashKey, &vFloor)) 
-               ((Floor*) vFloor)->AlphaN = i++;
+       while (GetNextHashPos(floors, it, &HKLen, &HashKey, &vFloor))
+               ((Floor *) vFloor)->AlphaN = i++;
        DeleteHashPos(&it);
        SortByHashKeyStr(floors);
 
        return floors;
 }
 
-HashList *GetZappedRoomListHash(StrBuf *Target, WCTemplputParams *TP) 
-{
+HashList *GetZappedRoomListHash(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
        if (WCC->Floors == NULL)
@@ -156,32 +141,27 @@ HashList *GetZappedRoomListHash(StrBuf *Target, WCTemplputParams *TP)
        serv_puts("LZRM -1");
        return GetRoomListHash(Target, TP);
 }
-HashList *GetRoomListHashLKRA(StrBuf *Target, WCTemplputParams *TP) 
-{
+HashList *GetRoomListHashLKRA(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
        if (WCC->Floors == NULL)
                GetFloorListHash(Target, TP);
-       if (WCC->Rooms == NULL) 
-       {
+       if (WCC->Rooms == NULL) {
                serv_puts("LKRA");
-               WCC->Rooms =  GetRoomListHash(Target, TP);
+               WCC->Rooms = GetRoomListHash(Target, TP);
        }
        return WCC->Rooms;
 }
 
-HashList *GetRoomListHashLPRM(StrBuf *Target, WCTemplputParams *TP) 
-{
+HashList *GetRoomListHashLPRM(StrBuf * Target, WCTemplputParams * TP) {
        serv_puts("LPRM");
        return GetRoomListHash(Target, TP);
 }
 
 
-void FlushIgnetCfgs(folder *room)
-{
+void FlushIgnetCfgs(folder * room) {
        int i;
-       if (room->IgnetCfgs[maxRoomNetCfg] == (HashList*) StrBufNOTNULL)
-       {
+       if (room->IgnetCfgs[maxRoomNetCfg] == (HashList *) StrBufNOTNULL) {
                for (i = ignet_push_share; i < maxRoomNetCfg; i++)
                        DeleteHash(&room->IgnetCfgs[i]);
        }
@@ -190,8 +170,7 @@ void FlushIgnetCfgs(folder *room)
 
 }
 
-void FlushFolder(folder *room)
-{
+void FlushFolder(folder * room) {
        int i;
 
        FreeStrBuf(&room->XAPass);
@@ -204,28 +183,25 @@ void FlushFolder(folder *room)
 
        FlushIgnetCfgs(room);
 
-       if (room->RoomNameParts != NULL)
-       {
-               for (i=0; i < room->nRoomNameParts; i++)
+       if (room->RoomNameParts != NULL) {
+               for (i = 0; i < room->nRoomNameParts; i++)
                        FreeStrBuf(&room->RoomNameParts[i]);
                free(room->RoomNameParts);
        }
        memset(room, 0, sizeof(folder));
 }
 
-void vDeleteFolder(void *vFolder)
-{
+void vDeleteFolder(void *vFolder) {
        folder *room;
 
-       room = (folder*) vFolder;
+       room = (folder *) vFolder;
        FlushFolder(room);
 
        free(room);
 }
 
 
-HashList *GetRoomListHash(StrBuf *Target, WCTemplputParams *TP) 
-{
+HashList *GetRoomListHash(StrBuf * Target, WCTemplputParams * TP) {
        int Done = 0;
        HashList *rooms;
        folder *room;
@@ -239,18 +215,14 @@ HashList *GetRoomListHash(StrBuf *Target, WCTemplputParams *TP)
        Buf = NewStrBuf();
        rooms = NewHash(1, NULL);
        StrBuf_ServGetln(Buf);
-       if (GetServerStatus(Buf, NULL) == 1) 
-       {
-               while(!Done && (StrBuf_ServGetln(Buf) >= 0))
-                       if ( (StrLength(Buf)==3) && 
-                            !strcmp(ChrPtr(Buf), "000")) 
-                       {
+       if (GetServerStatus(Buf, NULL) == 1) {
+               while (!Done && (StrBuf_ServGetln(Buf) >= 0))
+                       if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
                                Done = 1;
                        }
-                       else
-                       {                               
+                       else {
                                Pos = NULL;
-                               room = (folder*) malloc (sizeof(folder));
+                               room = (folder *) malloc(sizeof(folder));
                                memset(room, 0, sizeof(folder));
 
                                /* Load the base data from the server reply */
@@ -277,37 +249,30 @@ HashList *GetRoomListHash(StrBuf *Target, WCTemplputParams *TP)
                                /* Evaluate the Server sent data for later use */
                                /* find out, whether we are in a sub-room */
                                room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
-                               if (room->nRoomNameParts > 1)
-                               {
+                               if (room->nRoomNameParts > 1) {
                                        int i;
 
                                        Pos = NULL;
-                                       room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
-                                       memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
-                                       for (i=0; i < room->nRoomNameParts; i++)
-                                       {
+                                       room->RoomNameParts = malloc(sizeof(StrBuf *) * (room->nRoomNameParts + 1));
+                                       memset(room->RoomNameParts, 0, sizeof(StrBuf *) * (room->nRoomNameParts + 1));
+                                       for (i = 0; i < room->nRoomNameParts; i++) {
                                                room->RoomNameParts[i] = NewStrBuf();
-                                               StrBufExtract_NextToken(room->RoomNameParts[i],
-                                                                       room->name, &Pos, '\\');
+                                               StrBufExtract_NextToken(room->RoomNameParts[i], room->name, &Pos, '\\');
                                        }
                                }
 
                                /* Private mailboxes on the main floor get remapped to the personal folder */
-                               if ((room->QRFlags & QR_MAILBOX) && 
-                                   (room->floorid == 0))
-                               {
+                               if ((room->QRFlags & QR_MAILBOX) && (room->floorid == 0)) {
                                        room->floorid = VIRTUAL_MY_FLOOR;
-                                       if ((room->nRoomNameParts == 1) && 
-                                           (StrLength(room->name) == 4) && 
-                                           (strcmp(ChrPtr(room->name), "Mail") == 0))
-                                       {
+                                       if ((room->nRoomNameParts == 1) &&
+                                           (StrLength(room->name) == 4) && (strcmp(ChrPtr(room->name), "Mail") == 0)) {
                                                room->is_inbox = 1;
                                        }
 
                                }
                                /* get a pointer to the floor we're on: */
                                GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
-                               room->Floor = (const Floor*) vFloor;
+                               room->Floor = (const Floor *) vFloor;
 
 
 
@@ -320,14 +285,13 @@ HashList *GetRoomListHash(StrBuf *Target, WCTemplputParams *TP)
        SortIt = RetrieveSort(&SubTP, NULL, 0, HKEY("fileunsorted"), 0);
        if (SortIt != NULL)
                SortByPayload(rooms, SortIt);
-       else 
+       else
                SortByPayload(rooms, SortRoomsByListOrder);
        FreeStrBuf(&Buf);
        return rooms;
 }
 
-HashList *GetThisRoomMAlias(StrBuf *Target, WCTemplputParams *TP) 
-{
+HashList *GetThisRoomMAlias(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
        StrBuf *Line;
        StrBuf *Token;
@@ -336,24 +300,20 @@ HashList *GetThisRoomMAlias(StrBuf *Target, WCTemplputParams *TP)
        long aliaslen;
        long locallen;
        long State;
-       
-       serv_puts("GNET "FILE_MAILALIAS);
+
+       serv_puts("GNET " FILE_MAILALIAS);
        Line = NewStrBuf();
        StrBuf_ServGetln(Line);
-       if (GetServerStatus(Line, &State) == 1) 
-       {
+       if (GetServerStatus(Line, &State) == 1) {
                int Done = 0;
                int n = 0;
 
                Aliases = NewHash(1, NULL);
-               while(!Done && (StrBuf_ServGetln(Line) >= 0))
-                       if ( (StrLength(Line)==3) && 
-                            !strcmp(ChrPtr(Line), "000"))
-                       {
+               while (!Done && (StrBuf_ServGetln(Line) >= 0))
+                       if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
                                Done = 1;
                        }
-                       else
-                       {
+                       else {
                                pComma = strchr(ChrPtr(Line), ',');
                                if (pComma == NULL)
                                        continue;
@@ -367,10 +327,7 @@ HashList *GetThisRoomMAlias(StrBuf *Target, WCTemplputParams *TP)
                                if (strcasecmp(pComma + 6, ChrPtr(WCC->CurRoom.name)) != 0)
                                        continue;
                                Token = NewStrBufPlain(ChrPtr(Line), aliaslen);
-                               Put(Aliases, 
-                                   IKEY(n),
-                                   Token, 
-                                   HFreeStrBuf);
+                               Put(Aliases, IKEY(n), Token, HFreeStrBuf);
                                n++;
                        }
        }
@@ -383,15 +340,9 @@ HashList *GetThisRoomMAlias(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void AppendPossibleAliasWithDomain(
-       HashList *PossibleAliases,
-       long *nPossibleAliases,
-       const HashList *Domains, 
-       const char *prefix,
-       long len,
-       const char* Alias,
-       long AliasLen)
-{
+void AppendPossibleAliasWithDomain(HashList * PossibleAliases,
+                                  long *nPossibleAliases,
+                                  const HashList * Domains, const char *prefix, long len, const char *Alias, long AliasLen) {
        const StrBuf *OneDomain;
        StrBuf *Line;
        HashPos *It = NULL;
@@ -402,34 +353,29 @@ void AppendPossibleAliasWithDomain(
 
        It = GetNewHashPos(Domains, 1);
        n = *nPossibleAliases;
-       while (GetNextHashPos(Domains, It, &KLen, &Key, &pV))
-       {
-               OneDomain = (const StrBuf*) pV;
+       while (GetNextHashPos(Domains, It, &KLen, &Key, &pV)) {
+               OneDomain = (const StrBuf *) pV;
                Line = NewStrBuf();
                StrBufAppendBufPlain(Line, prefix, len, 0);
                StrBufAppendBufPlain(Line, Alias, AliasLen, 0);
                StrBufAppendBufPlain(Line, HKEY("@"), 0);
                StrBufAppendBuf(Line, OneDomain, 0);
 
-               Put(PossibleAliases, 
-                   IKEY(n),
-                   Line, 
-                   HFreeStrBuf);
+               Put(PossibleAliases, IKEY(n), Line, HFreeStrBuf);
                n++;
        }
        DeleteHashPos(&It);
        *nPossibleAliases = n;
 }
 
-HashList *GetThisRoomPossibleMAlias(StrBuf *Target, WCTemplputParams *TP) 
-{
+HashList *GetThisRoomPossibleMAlias(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
        HashList *Domains;
        StrBuf *Line;
        StrBuf *Token;
        StrBuf *RoomName;
        HashList *PossibleAliases = NULL;
-       
+
        const char *pComma;
        const char *pAt;
        long aliaslen;
@@ -450,27 +396,19 @@ HashList *GetThisRoomPossibleMAlias(StrBuf *Target, WCTemplputParams *TP)
        StrBufAsciify(RoomName, '_');
        StrBufReplaceChars(RoomName, ' ', '_');
 
-       AppendPossibleAliasWithDomain(PossibleAliases,
-                                     &n,
-                                     Domains,
-                                     HKEY("room_"),
-                                     SKEY(RoomName));
+       AppendPossibleAliasWithDomain(PossibleAliases, &n, Domains, HKEY("room_"), SKEY(RoomName));
 
 
-       serv_puts("GNET "FILE_MAILALIAS);
+       serv_puts("GNET " FILE_MAILALIAS);
        StrBuf_ServGetln(Line);
-       if (GetServerStatus(Line, &State) == 1) 
-       {
+       if (GetServerStatus(Line, &State) == 1) {
                int Done = 0;
 
-               while(!Done && (StrBuf_ServGetln(Line) >= 0))
-                       if ( (StrLength(Line)==3) && 
-                            !strcmp(ChrPtr(Line), "000"))
-                       {
+               while (!Done && (StrBuf_ServGetln(Line) >= 0))
+                       if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
                                Done = 1;
                        }
-                       else
-                       {
+                       else {
                                pComma = strchr(ChrPtr(Line), ',');
                                if (pComma == NULL)
                                        continue;
@@ -484,24 +422,15 @@ HashList *GetThisRoomPossibleMAlias(StrBuf *Target, WCTemplputParams *TP)
                                if (strcasecmp(pComma + 6, ChrPtr(WCC->CurRoom.name)) != 0)
                                        continue;
                                pAt = strchr(ChrPtr(Line), '@');
-                               if ((pAt == NULL) || (pAt > pComma))
-                               {
+                               if ((pAt == NULL) || (pAt > pComma)) {
                                        AppendPossibleAliasWithDomain(PossibleAliases,
-                                                                     &n,
-                                                                     Domains,
-                                                                     HKEY(""),
-                                                                     ChrPtr(Line),
-                                                                     aliaslen);
+                                                                     &n, Domains, HKEY(""), ChrPtr(Line), aliaslen);
                                        n++;
                                }
-                               else
-                               {
-                                       
+                               else {
+
                                        Token = NewStrBufPlain(ChrPtr(Line), aliaslen);
-                                       Put(PossibleAliases,
-                                           IKEY(n),
-                                           Token,
-                                           HFreeStrBuf);
+                                       Put(PossibleAliases, IKEY(n), Token, HFreeStrBuf);
                                        n++;
                                }
                        }
@@ -515,8 +444,7 @@ HashList *GetThisRoomPossibleMAlias(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-HashList *GetNetConfigHash(StrBuf *Target, WCTemplputParams *TP) 
-{
+HashList *GetNetConfigHash(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
        StrBuf *Line;
        StrBuf *Token;
@@ -524,65 +452,51 @@ HashList *GetNetConfigHash(StrBuf *Target, WCTemplputParams *TP)
        long WantThisOne;
        long PutTo;
        long State;
-       
+
        WantThisOne = GetTemplateTokenNumber(Target, TP, 5, -1);
        if ((WantThisOne < 0) || (WantThisOne > maxRoomNetCfg))
                return NULL;
-       if (WCC->CurRoom.IgnetCfgs[maxRoomNetCfg] == (HashList*) StrBufNOTNULL)
+       if (WCC->CurRoom.IgnetCfgs[maxRoomNetCfg] == (HashList *) StrBufNOTNULL)
                return WCC->CurRoom.IgnetCfgs[WantThisOne];
 
-       WCC->CurRoom.IgnetCfgs[maxRoomNetCfg] = (HashList*) StrBufNOTNULL;
+       WCC->CurRoom.IgnetCfgs[maxRoomNetCfg] = (HashList *) StrBufNOTNULL;
        serv_puts("GNET");
        Line = NewStrBuf();
        Token = NewStrBuf();
        StrBuf_ServGetln(Line);
-       if (GetServerStatus(Line, &State) == 1) 
-       {
+       if (GetServerStatus(Line, &State) == 1) {
                const char *Pos = NULL;
                int Done = 0;
                int HaveRoomMailAlias = 0;
 
-               while(!Done && (StrBuf_ServGetln(Line) >= 0))
-               {
+               while (!Done && (StrBuf_ServGetln(Line) >= 0)) {
                        if (StrLength(Line) == 0)
                                continue;
-                       if ( (StrLength(Line)==3) && 
-                            !strcmp(ChrPtr(Line), "000"))
-                       {
+                       if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
                                Done = 1;
                        }
-                       else
-                       {
+                       else {
                                StrBufExtract_NextToken(Token, Line, &Pos, '|');
                                PutTo = GetTokenDefine(SKEY(Token), -1);
-                               if (PutTo == roommailalias)
-                               {
+                               if (PutTo == roommailalias) {
                                        if (HaveRoomMailAlias > 0)
-                                               continue; /* Only ONE alias possible! */
+                                               continue;       /* Only ONE alias possible! */
                                        HaveRoomMailAlias++;
                                }
-                               if ((PutTo >= 0) && 
-                                   (PutTo < maxRoomNetCfg) &&
-                                   (Pos != StrBufNOTNULL))
-                               {
+                               if ((PutTo >= 0) && (PutTo < maxRoomNetCfg) && (Pos != StrBufNOTNULL)) {
                                        int n;
                                        HashList *SubH;
-                                       
-                                       if (WCC->CurRoom.IgnetCfgs[PutTo] == NULL)
-                                       {
+
+                                       if (WCC->CurRoom.IgnetCfgs[PutTo] == NULL) {
                                                n = 0;
                                                WCC->CurRoom.IgnetCfgs[PutTo] = NewHash(1, NULL);
                                        }
-                                       else 
-                                       {
+                                       else {
                                                n = GetCount(WCC->CurRoom.IgnetCfgs[PutTo]);
                                        }
                                        SubH = NewHash(1, NULL);
-                                       Put(WCC->CurRoom.IgnetCfgs[PutTo], 
-                                           IKEY(n),
-                                           SubH, 
-                                           HDeleteHash);
-                                       n = 1; /* #0 is the type... */
+                                       Put(WCC->CurRoom.IgnetCfgs[PutTo], IKEY(n), SubH, HDeleteHash);
+                                       n = 1;  /* #0 is the type... */
                                        while (Pos != StrBufNOTNULL) {
                                                Content = NewStrBuf();
                                                StrBufExtract_NextToken(Content, Line, &Pos, '|');
@@ -590,10 +504,7 @@ HashList *GetNetConfigHash(StrBuf *Target, WCTemplputParams *TP)
                                                if ((PutTo == roommailalias) && n == 1)
                                                        WCC->CurRoom.RoomAlias = Content;
 
-                                               Put(SubH, 
-                                                   IKEY(n),
-                                                   Content, 
-                                                   HFreeStrBuf);
+                                               Put(SubH, IKEY(n), Content, HFreeStrBuf);
                                                n++;
                                        }
                                }
@@ -611,30 +522,29 @@ HashList *GetNetConfigHash(StrBuf *Target, WCTemplputParams *TP)
 }
 
 /** Unused function that orders rooms by the listorder flag */
-int SortRoomsByListOrder(const void *room1, const void *room2) 
-{
-       folder *r1 = (folder*) GetSearchPayload(room1);
-       folder *r2 = (folder*) GetSearchPayload(room2);
-  
-       if (r1->Order == r2->Order) return 0;
-       if (r1->Order > r2->Order) return 1;
+int SortRoomsByListOrder(const void *room1, const void *room2) {
+       folder *r1 = (folder *) GetSearchPayload(room1);
+       folder *r2 = (folder *) GetSearchPayload(room2);
+
+       if (r1->Order == r2->Order)
+               return 0;
+       if (r1->Order > r2->Order)
+               return 1;
        return -1;
 }
 
-int CompareRoomListByFloorRoomPrivFirst(const void *room1, const void *room2) 
-{
-       folder *r1 = (folder*) GetSearchPayload(room1);
-       folder *r2 = (folder*) GetSearchPayload(room2);
-  
-       if ((r1->Floor == NULL)  ||
-           (r2->Floor == NULL))
+int CompareRoomListByFloorRoomPrivFirst(const void *room1, const void *room2) {
+       folder *r1 = (folder *) GetSearchPayload(room1);
+       folder *r2 = (folder *) GetSearchPayload(room2);
+
+       if ((r1->Floor == NULL) || (r2->Floor == NULL))
                return 0;
-               
+
        /**
         * are we on the same floor? else sort by floor.
         */
-       if (r1->Floor != r2->Floor)
-       {
+       if (r1->Floor != r2->Floor) {
+
                /**
                 * the private rooms are first in any case.
                 */
@@ -642,10 +552,11 @@ int CompareRoomListByFloorRoomPrivFirst(const void *room1, const void *room2)
                        return -1;
                if (r2->Floor->ID == VIRTUAL_MY_FLOOR)
                        return 1;
+
                /**
                 * else decide alpaheticaly by floorname
                 */
-               return (r1->Floor->AlphaN > r2->Floor->AlphaN)? 1 : -1;
+               return (r1->Floor->AlphaN > r2->Floor->AlphaN) ? 1 : -1;
        }
 
        /**
@@ -653,22 +564,17 @@ int CompareRoomListByFloorRoomPrivFirst(const void *room1, const void *room2)
         * we want the toplevel to be first, regardless of sort
         * sequence.
         */
-       if (((r1->nRoomNameParts > 1) || 
-           (r2->nRoomNameParts > 1)    )&&
-           (r1->nRoomNameParts != r2->nRoomNameParts))
-       {
+       if (((r1->nRoomNameParts > 1) || (r2->nRoomNameParts > 1)) && (r1->nRoomNameParts != r2->nRoomNameParts)) {
                int i, ret;
-               int nparts = (r1->nRoomNameParts > r2->nRoomNameParts)?
-                       r2->nRoomNameParts : r1->nRoomNameParts;
+               int nparts = (r1->nRoomNameParts > r2->nRoomNameParts) ? r2->nRoomNameParts : r1->nRoomNameParts;
+
+               for (i = 0; i < nparts; i++) {
+                       ret = strcmp(ChrPtr(r1->name), ChrPtr(r2->name));
 
-               for (i=0; i < nparts; i++)
-               {
-                       ret = strcmp (ChrPtr(r1->name), 
-                                     ChrPtr(r2->name));
                        /**
                         * Deltas in common parts? exit here.
                         */
-                       if (ret != 0) 
+                       if (ret != 0)
                                return ret;
                }
 
@@ -685,24 +591,21 @@ int CompareRoomListByFloorRoomPrivFirst(const void *room1, const void *room2)
        /**
         * else just sort alphabeticaly.
         */
-       return strcmp (ChrPtr(r1->name), 
-                      ChrPtr(r2->name));
+       return strcmp(ChrPtr(r1->name), ChrPtr(r2->name));
 }
 
-int CompareRoomListByFloorRoomPrivFirstRev(const void *room1, const void *room2) 
-{
-       folder *r1 = (folder*) GetSearchPayload(room1);
-       folder *r2 = (folder*) GetSearchPayload(room2);
+int CompareRoomListByFloorRoomPrivFirstRev(const void *room1, const void *room2) {
+       folder *r1 = (folder *) GetSearchPayload(room1);
+       folder *r2 = (folder *) GetSearchPayload(room2);
 
-       if ((r1->Floor == NULL)  ||
-           (r2->Floor == NULL))
+       if ((r1->Floor == NULL) || (r2->Floor == NULL))
                return 0;
 
        /**
         * are we on the same floor? else sort by floor.
         */
-       if (r2->Floor != r1->Floor)
-       {
+       if (r2->Floor != r1->Floor) {
+
                /**
                 * the private rooms are first in any case.
                 */
@@ -710,11 +613,12 @@ int CompareRoomListByFloorRoomPrivFirstRev(const void *room1, const void *room2)
                        return -1;
                if (r2->Floor->ID == VIRTUAL_MY_FLOOR)
                        return 1;
+
                /**
                 * else decide alpaheticaly by floorname
                 */
 
-               return (r1->Floor->AlphaN < r2->Floor->AlphaN)? 1 : -1;
+               return (r1->Floor->AlphaN < r2->Floor->AlphaN) ? 1 : -1;
        }
 
        /**
@@ -722,32 +626,26 @@ int CompareRoomListByFloorRoomPrivFirstRev(const void *room1, const void *room2)
         * we want the toplevel to be first, regardless of sort
         * sequence.
         */
-       if (((r1->nRoomNameParts > 1) || 
-           (r2->nRoomNameParts > 1)    )&&
-           (r1->nRoomNameParts != r2->nRoomNameParts))
-       {
+       if (((r1->nRoomNameParts > 1) || (r2->nRoomNameParts > 1)) && (r1->nRoomNameParts != r2->nRoomNameParts)) {
                int i, ret;
-               int nparts = (r1->nRoomNameParts > r2->nRoomNameParts)?
-                       r2->nRoomNameParts : r1->nRoomNameParts;
+               int nparts = (r1->nRoomNameParts > r2->nRoomNameParts) ? r2->nRoomNameParts : r1->nRoomNameParts;
+
+               for (i = 0; i < nparts; i++) {
 
-               for (i=0; i < nparts; i++)
-               {
                        /**
                         * special cases if one room is top-level...
                         */
                        if (r2->nRoomNameParts == 1)
-                               ret = strcmp (ChrPtr(r2->name), 
-                                             ChrPtr(r1->RoomNameParts[i]));
+                               ret = strcmp(ChrPtr(r2->name), ChrPtr(r1->RoomNameParts[i]));
                        else if (r1->nRoomNameParts == 1)
-                               ret = strcmp (ChrPtr(r2->RoomNameParts[i]),
-                                             ChrPtr(r1->name));
-                       else 
-                               ret = strcmp (ChrPtr(r2->RoomNameParts[i]), 
-                                             ChrPtr(r1->RoomNameParts[i]));
+                               ret = strcmp(ChrPtr(r2->RoomNameParts[i]), ChrPtr(r1->name));
+                       else
+                               ret = strcmp(ChrPtr(r2->RoomNameParts[i]), ChrPtr(r1->RoomNameParts[i]));
+
                        /**
                         * Deltas in common parts? exit here.
                         */
-                       if (ret != 0) 
+                       if (ret != 0)
                                return ret;
                }
 
@@ -760,71 +658,64 @@ int CompareRoomListByFloorRoomPrivFirstRev(const void *room1, const void *room2)
                        return -1;
        }
 
-       return strcmp (ChrPtr(r2->name), 
-                      ChrPtr(r1->name));
+       return strcmp(ChrPtr(r2->name), ChrPtr(r1->name));
 }
 
-int GroupchangeRoomListByFloorRoomPrivFirst(const void *room1, const void *room2) 
-{
-       folder *r1 = (folder*) room1;
-       folder *r2 = (folder*) room2;
-  
+int GroupchangeRoomListByFloorRoomPrivFirst(const void *room1, const void *room2) {
+       folder *r1 = (folder *) room1;
+       folder *r2 = (folder *) room2;
 
-       if ((r1->Floor == NULL)  ||
-           (r2->Floor == NULL))
+
+       if ((r1->Floor == NULL) || (r2->Floor == NULL))
                return 0;
-               
+
        if (r1->Floor == r2->Floor)
                return 0;
-       else 
-       {
+       else {
                wcsession *WCC = WC;
                static int columns = 3;
                int boxes_per_column = 0;
                int nf;
 
                nf = GetCount(WCC->Floors);
-               while (nf % columns != 0) ++nf;
+               while (nf % columns != 0)
+                       ++nf;
                boxes_per_column = (nf / columns);
                if (boxes_per_column < 1)
                        boxes_per_column = 1;
                if (r1->Floor->AlphaN % boxes_per_column == 0)
                        return 2;
-               else 
+               else
                        return 1;
        }
 }
 
 
-int CompareRooms(const folder *room1, const folder *room2) 
-{
+int CompareRooms(const folder * room1, const folder * room2) {
        if ((room1 == NULL) || (room2 == NULL))
                return -1;
        return CompareRoomListByFloorRoomPrivFirst(room1, room2);
 }
 
-int ConditionalThisRoomIsStrBufContextAlias(StrBuf *Target, WCTemplputParams *TP)
-{
-       wcsession       *WCC = WC;
-       const char      *pVal;
-       long             len;
-       eRoomParamType   ParamType;
+int ConditionalThisRoomIsStrBufContextAlias(StrBuf * Target, WCTemplputParams * TP) {
+       wcsession *WCC = WC;
+       const char *pVal;
+       long len;
+       eRoomParamType ParamType;
 
        ParamType = GetTemplateTokenNumber(Target, TP, 2, eNotSet);
        GetTemplateTokenString(Target, TP, 3, &pVal, &len);
 
-       if (ParamType == eNotSet)
-       {
+       if (ParamType == eNotSet) {
                return StrLength(WCC->CurRoom.RoomAlias) == 0;
        }
-       else if (ParamType == eDomain)
-       {
-               const StrBuf *CtxStr = (const StrBuf*) CTX(CTX_STRBUF);
+       else if (ParamType == eDomain) {
+               const StrBuf *CtxStr = (const StrBuf *) CTX(CTX_STRBUF);
                const char *pAt;
 
-               if (CtxStr == NULL) 
+               if (CtxStr == NULL)
                        return 0;
-               
+
                if (StrLength(WCC->CurRoom.RoomAlias) == 0)
                        return 0;
 
@@ -836,36 +727,32 @@ int ConditionalThisRoomIsStrBufContextAlias(StrBuf *Target, WCTemplputParams *TP
                        return 0;
                return strcmp(pAt + 1, ChrPtr(CtxStr)) == 0;
        }
-       else if (ParamType == eAlias)
-       {
-               const StrBuf *CtxStr = (const StrBuf*) CTX(CTX_STRBUF);
+       else if (ParamType == eAlias) {
+               const StrBuf *CtxStr = (const StrBuf *) CTX(CTX_STRBUF);
 
-               if (CtxStr == NULL) 
+               if (CtxStr == NULL)
                        return 0;
-               
+
                if (StrLength(WCC->CurRoom.RoomAlias) == 0)
                        return 0;
 
                return strcmp(ChrPtr(WCC->CurRoom.RoomAlias), ChrPtr(CtxStr)) == 0;
        }
-       else
-       {
-               LogTemplateError(Target, "TokenParameter", 2, TP, 
-                                "Invalid paramtype; need one of [eNotSet|eDomain|eAlias]");
+       else {
+               LogTemplateError(Target, "TokenParameter", 2, TP, "Invalid paramtype; need one of [eNotSet|eDomain|eAlias]");
                return 0;
        }
 
 }
 
-int ConditionalRoomIsRESTSubRoom(StrBuf *Target, WCTemplputParams *TP)
-{
-       wcsession  *WCC = WC;
-       folder     *Folder = (folder *)CTX(CTX_ROOMS);
-       HashPos    *it;
-       StrBuf     * Dir;
-       void       *vDir;
-       long        len;
-        const char *Key;
+int ConditionalRoomIsRESTSubRoom(StrBuf * Target, WCTemplputParams * TP) {
+       wcsession *WCC = WC;
+       folder *Folder = (folder *) CTX(CTX_ROOMS);
+       HashPos *it;
+       StrBuf *Dir;
+       void *vDir;
+       long len;
+       const char *Key;
        int i, j, urlp;
        int delta;
 
@@ -877,10 +764,7 @@ int ConditionalRoomIsRESTSubRoom(StrBuf *Target, WCTemplputParams *TP)
        urlp = GetCount(WCC->Directory);
        delta = Folder->nRoomNameParts - urlp + 1;
 
-       syslog(LOG_DEBUG, "\n->%s: %d - %ld ", 
-              ChrPtr(Folder->name), 
-              urlp, 
-              Folder->nRoomNameParts);
+       syslog(LOG_DEBUG, "\n->%s: %d - %ld ", ChrPtr(Folder->name), urlp, Folder->nRoomNameParts);
        /* list only the floors which are in relation to the dav_depth header */
        if (WCC->Hdr->HR.dav_depth != delta) {
                syslog(LOG_DEBUG, "1\n");
@@ -892,24 +776,16 @@ int ConditionalRoomIsRESTSubRoom(StrBuf *Target, WCTemplputParams *TP)
        /* Fast forward the floorname we checked above... */
        GetNextHashPos(WCC->Directory, it, &len, &Key, &vDir);
 
-       if (Folder->nRoomNameParts > 1) {               
-               for (i = 0, j = 1; 
-                    (i > Folder->nRoomNameParts) && (j > urlp); 
-                    i++, j++)
-               {
-                       if (!GetNextHashPos(WCC->Directory, 
-                                           it, &len, &Key, &vDir) ||
-                           (vDir == NULL))
-                       {
+       if (Folder->nRoomNameParts > 1) {
+               for (i = 0, j = 1; (i > Folder->nRoomNameParts) && (j > urlp); i++, j++) {
+                       if (!GetNextHashPos(WCC->Directory, it, &len, &Key, &vDir) || (vDir == NULL)) {
                                DeleteHashPos(&it);
 
                                syslog(LOG_DEBUG, "3\n");
                                return 0;
                        }
-                       Dir = (StrBuf*) vDir;
-                       if (strcmp(ChrPtr(Folder->RoomNameParts[i]), 
-                                  ChrPtr(Dir)) != 0)
-                       {
+                       Dir = (StrBuf *) vDir;
+                       if (strcmp(ChrPtr(Folder->RoomNameParts[i]), ChrPtr(Dir)) != 0) {
                                DeleteHashPos(&it);
                                syslog(LOG_DEBUG, "4\n");
                                return 0;
@@ -919,20 +795,16 @@ int ConditionalRoomIsRESTSubRoom(StrBuf *Target, WCTemplputParams *TP)
                return 1;
        }
        else {
-               if (!GetNextHashPos(WCC->Directory, 
-                                   it, &len, &Key, &vDir) ||
-                   (vDir == NULL))
-               {
+               if (!GetNextHashPos(WCC->Directory, it, &len, &Key, &vDir) || (vDir == NULL)) {
                        DeleteHashPos(&it);
-                       
+
                        syslog(LOG_DEBUG, "5\n");
                        return WCC->Hdr->HR.dav_depth == 1;
                }
                DeleteHashPos(&it);
-               Dir = (StrBuf*) vDir;
+               Dir = (StrBuf *) vDir;
                if (WCC->Hdr->HR.dav_depth == 0) {
-                       return (strcmp(ChrPtr(Folder->name), 
-                                      ChrPtr(Dir))
+                       return (strcmp(ChrPtr(Folder->name), ChrPtr(Dir))
                                == 0);
 
                }
@@ -941,10 +813,7 @@ int ConditionalRoomIsRESTSubRoom(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void 
-InitModule_ROOMLIST
-(void)
-{
+void InitModule_ROOMLIST(void) {
        /* we duplicate this, just to be shure its already done. */
        RegisterCTX(CTX_ROOMS);
        RegisterCTX(CTX_FLOORS);
@@ -952,7 +821,8 @@ InitModule_ROOMLIST
        RegisterIterator("ITERATE:THISROOM:WHO_KNOWS", 0, NULL, GetWhoKnowsHash, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
        RegisterIterator("ITERATE:THISROOM:GNET", 1, NULL, GetNetConfigHash, NULL, NULL, CTX_STRBUFARR, CTX_NONE, IT_NOFLAG);
        RegisterIterator("ITERATE:THISROOM:MALIAS", 1, NULL, GetThisRoomMAlias, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
-       RegisterIterator("ITERATE:THISROOM:POSSIBLE:MALIAS", 1, NULL, GetThisRoomPossibleMAlias, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
+       RegisterIterator("ITERATE:THISROOM:POSSIBLE:MALIAS", 1, NULL, GetThisRoomPossibleMAlias, NULL, DeleteHash, CTX_STRBUF,
+                        CTX_NONE, IT_NOFLAG);
 
        RegisterIterator("LFLR", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_FLAG_DETECT_GROUPCHANGE);
        RegisterIterator("LKRA", 0, NULL, GetRoomListHashLKRA, NULL, NULL, CTX_ROOMS, CTX_NONE, IT_FLAG_DETECT_GROUPCHANGE);
@@ -972,8 +842,6 @@ InitModule_ROOMLIST
        RegisterSortFunc(HKEY("byfloorroom"),
                         NULL, 0,
                         CompareRoomListByFloorRoomPrivFirst,
-                        CompareRoomListByFloorRoomPrivFirstRev,
-                        GroupchangeRoomListByFloorRoomPrivFirst,
-                        CTX_ROOMS);
+                        CompareRoomListByFloorRoomPrivFirstRev, GroupchangeRoomListByFloorRoomPrivFirst, CTX_ROOMS);
 
 }
index be4c628da140f31453327beb6f3d20f0e55fd88f..d9a8f18db954c4ec3198a9d76bfac486db1c2a6f 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Lots of different room-related operations.
  *
 #include "webserver.h"
 
 ConstStr QRFlagList[] = {
-       {HKEY(strof(QR_PERMANENT))},
-       {HKEY(strof(QR_INUSE))},
-       {HKEY(strof(QR_PRIVATE))},
-       {HKEY(strof(QR_PASSWORDED))},
-       {HKEY(strof(QR_GUESSNAME))},
-       {HKEY(strof(QR_DIRECTORY))},
-       {HKEY(strof(QR_UPLOAD))},
-       {HKEY(strof(QR_DOWNLOAD))},
-       {HKEY(strof(QR_VISDIR))},
-       {HKEY(strof(QR_ANONONLY))},
-       {HKEY(strof(QR_ANONOPT))},
-       {HKEY(strof(QR_NETWORK))},
-       {HKEY(strof(QR_PREFONLY))},
-       {HKEY(strof(QR_READONLY))},
-       {HKEY(strof(QR_MAILBOX))}
+       { HKEY(strof(QR_PERMANENT)) },
+       { HKEY(strof(QR_INUSE)) },
+       { HKEY(strof(QR_PRIVATE)) },
+       { HKEY(strof(QR_PASSWORDED)) },
+       { HKEY(strof(QR_GUESSNAME)) },
+       { HKEY(strof(QR_DIRECTORY)) },
+       { HKEY(strof(QR_UPLOAD)) },
+       { HKEY(strof(QR_DOWNLOAD)) },
+       { HKEY(strof(QR_VISDIR)) },
+       { HKEY(strof(QR_ANONONLY)) },
+       { HKEY(strof(QR_ANONOPT)) },
+       { HKEY(strof(QR_NETWORK)) },
+       { HKEY(strof(QR_PREFONLY)) },
+       { HKEY(strof(QR_READONLY)) },
+       { HKEY(strof(QR_MAILBOX)) }
 };
+
 ConstStr QR2FlagList[] = {
-       {HKEY(strof(QR2_SYSTEM))},
-       {HKEY(strof(QR2_SELFLIST))},
-       {HKEY(strof(QR2_COLLABDEL))},
-       {HKEY(strof(QR2_SUBJECTREQ))},
-       {HKEY(strof(QR2_SMTP_PUBLIC))},
-       {HKEY(strof(QR2_MODERATED))},
-       {HKEY(strof(QR2_NOUPLMSG))}, 
-       {HKEY("")}, 
-       {HKEY("")}, 
-       {HKEY("")}, 
-       {HKEY("")}, 
-       {HKEY("")}, 
-       {HKEY("")}, 
-       {HKEY("")}, 
-       {HKEY("")}
+       { HKEY(strof(QR2_SYSTEM)) },
+       { HKEY(strof(QR2_SELFLIST)) },
+       { HKEY(strof(QR2_COLLABDEL)) },
+       { HKEY(strof(QR2_SUBJECTREQ)) },
+       { HKEY(strof(QR2_SMTP_PUBLIC)) },
+       { HKEY(strof(QR2_MODERATED)) },
+       { HKEY(strof(QR2_NOUPLMSG)) },
+       { HKEY("") },
+       { HKEY("") },
+       { HKEY("") },
+       { HKEY("") },
+       { HKEY("") },
+       { HKEY("") },
+       { HKEY("") },
+       { HKEY("") }
 };
 
-void _DBG_QR(long QR)
-{
+void _DBG_QR(long QR) {
        int i = 1;
-       int j=0;
+       int j = 0;
        StrBuf *QRVec;
 
        QRVec = NewStrBufPlain(NULL, 256);
-       while (i != 0)
-       {
+       while (i != 0) {
                if ((QR & i) != 0) {
                        if (StrLength(QRVec) > 0)
                                StrBufAppendBufPlain(QRVec, HKEY(" | "), 0);
@@ -73,15 +73,13 @@ void _DBG_QR(long QR)
 
 
 
-void _DBG_QR2(long QR2)
-{
+void _DBG_QR2(long QR2) {
        int i = 1;
-       int j=0;
+       int j = 0;
        StrBuf *QR2Vec;
 
        QR2Vec = NewStrBufPlain(NULL, 256);
-       while (i != 0)
-       {
+       while (i != 0) {
                if ((QR2 & i) != 0) {
                        if (StrLength(QR2Vec) > 0)
                                StrBufAppendBufPlain(QR2Vec, HKEY(" | "), 0);
@@ -127,7 +125,7 @@ void dotgoto(void) {
 /*
  * goto next room
  */
-void smart_goto(const StrBuf *next_room) {
+void smart_goto(const StrBuf * next_room) {
        if (gotoroom(next_room) / 100 == 2)
                readloop(readnew, eUseDefault);
        else
@@ -137,8 +135,7 @@ void smart_goto(const StrBuf *next_room) {
 /*
  * goto a private room
  */
-void goto_private(void)
-{
+void goto_private(void) {
        char hold_rm[SIZ];
        StrBuf *Buf;
        const StrBuf *gr_name;
@@ -151,11 +148,9 @@ void goto_private(void)
        gr_name = sbstr("gr_name");
        Buf = NewStrBuf();
        strcpy(hold_rm, ChrPtr(WC->CurRoom.name));
-       serv_printf("GOTO %s|%s",
-                   ChrPtr(gr_name),
-                   bstr("gr_pass"));
+       serv_printf("GOTO %s|%s", ChrPtr(gr_name), bstr("gr_pass"));
        StrBuf_ServGetln(Buf);
-       if  (GetServerStatus(Buf, &err) == 2) {
+       if (GetServerStatus(Buf, &err) == 2) {
                FlushRoomlist();
                smart_goto(gr_name);
                FreeStrBuf(&Buf);
@@ -167,7 +162,7 @@ void goto_private(void)
                return;
        }
        StrBufCutLeft(Buf, 4);
-       AppendImportantMessage (SKEY(Buf));
+       AppendImportantMessage(SKEY(Buf));
        Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
        smart_goto(Buf);
        FreeStrBuf(&Buf);
@@ -177,8 +172,7 @@ void goto_private(void)
 /*
  * back end routine to take the session to a new room
  */
-long gotoroom(const StrBuf *gname)
-{
+long gotoroom(const StrBuf * gname) {
        wcsession *WCC = WC;
        StrBuf *Buf;
        static long ls = (-1L);
@@ -212,7 +206,7 @@ long gotoroom(const StrBuf *gname)
                serv_printf("GOTO 00000000000000000000");
        }
        StrBuf_ServGetln(Buf);
-       if  (GetServerStatus(Buf, &err) != 2) {
+       if (GetServerStatus(Buf, &err) != 2) {
                if (failvisibly) {
                        FreeStrBuf(&Buf);
                        return err;
@@ -245,8 +239,7 @@ long gotoroom(const StrBuf *gname)
 
 
 
-void ParseGoto(folder *room, StrBuf *Line)
-{
+void ParseGoto(folder * room, StrBuf * Line) {
        wcsession *WCC = WC;
        const char *Pos;
        int flag;
@@ -256,20 +249,19 @@ void ParseGoto(folder *room, StrBuf *Line)
        if (StrLength(Line) < 4) {
                return;
        }
-       
+
        /* ignore the commandstate... */
        Pos = ChrPtr(Line) + 4;
 
-       if (room->RoomNameParts != NULL)
-       {
+       if (room->RoomNameParts != NULL) {
                int i;
-               for (i=0; i < room->nRoomNameParts; i++)
+               for (i = 0; i < room->nRoomNameParts; i++)
                        FreeStrBuf(&room->RoomNameParts[i]);
                free(room->RoomNameParts);
                room->RoomNameParts = NULL;
        }
 
-       pBuf = room->name;  
+       pBuf = room->name;
        if (pBuf == NULL)
                pBuf = NewStrBufPlain(NULL, StrLength(Line));
        else
@@ -279,14 +271,14 @@ void ParseGoto(folder *room, StrBuf *Line)
 
        StrBufExtract_NextToken(room->name, Line, &Pos, '|');
 
-       room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|'); 
+       room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
        if (room->nNewMessages > 0)
                room->RAFlags |= UA_HASNEWMSGS;
 
        room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
 
-       room->ShowInfo =  StrBufExtractNext_long(Line, &Pos, '|');
-       
+       room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
+
        room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|');
 
        DBG_QR(room->QRFlags);
@@ -318,62 +310,51 @@ void ParseGoto(folder *room, StrBuf *Line)
 
        /* find out, whether we are in a sub-room */
        room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
-       if (room->nRoomNameParts > 1)
-       {
+       if (room->nRoomNameParts > 1) {
                int i;
-               
+
                Pos = NULL;
-               room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
-               memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
-               for (i=0; i < room->nRoomNameParts; i++)
-               {
+               room->RoomNameParts = malloc(sizeof(StrBuf *) * (room->nRoomNameParts + 1));
+               memset(room->RoomNameParts, 0, sizeof(StrBuf *) * (room->nRoomNameParts + 1));
+               for (i = 0; i < room->nRoomNameParts; i++) {
                        room->RoomNameParts[i] = NewStrBuf();
-                       StrBufExtract_NextToken(room->RoomNameParts[i],
-                                               room->name, &Pos, '\\');
+                       StrBufExtract_NextToken(room->RoomNameParts[i], room->name, &Pos, '\\');
                }
        }
 
        /* Private mailboxes on the main floor get remapped to the personal folder */
-       if ((room->QRFlags & QR_MAILBOX) && 
-           (room->floorid == 0))
-       {
+       if ((room->QRFlags & QR_MAILBOX) && (room->floorid == 0)) {
                room->floorid = VIRTUAL_MY_FLOOR;
-               if ((room->nRoomNameParts == 1) && 
-                   (StrLength(room->name) == 4) && 
-                   (strcmp(ChrPtr(room->name), "Mail") == 0))
-               {
+               if ((room->nRoomNameParts == 1) && (StrLength(room->name) == 4) && (strcmp(ChrPtr(room->name), "Mail") == 0)) {
                        room->is_inbox = 1;
                }
-               
+
        }
        /* get a pointer to the floor we're on: */
        if (WCC->Floors == NULL)
                GetFloorListHash(NULL, NULL);
 
        GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
-       room->Floor = (const Floor*) vFloor;
+       room->Floor = (const Floor *) vFloor;
 }
 
 /*
  * Delete the current room
  */
-void delete_room(void)
-{
+void delete_room(void) {
        StrBuf *Line = NewStrBuf();
        const StrBuf *GoBstr;
-       
+
        GoBstr = sbstr("go");
 
-       if (GoBstr != NULL)
-       {
-               if (gotoroom(GoBstr) == 200)
-               {
+       if (GoBstr != NULL) {
+               if (gotoroom(GoBstr) == 200) {
                        serv_puts("KILL 1");
                        StrBuf_ServGetln(Line);
                        if (GetServerStatusMsg(Line, NULL, 1, 2) == 2) {
                                StrBuf *Buf;
-                               
-                               FlushRoomlist ();
+
+                               FlushRoomlist();
                                Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
                                smart_goto(Buf);
                                FreeStrBuf(&Buf);
@@ -389,8 +370,7 @@ void delete_room(void)
 /*
  * zap a room
  */
-void zap(void)
-{
+void zap(void) {
        char buf[SIZ];
        StrBuf *final_destination;
 
@@ -411,7 +391,7 @@ void zap(void)
                                StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
                        }
                }
-               FlushRoomlist ();
+               FlushRoomlist();
        }
        smart_goto(final_destination);
        FreeStrBuf(&final_destination);
@@ -421,8 +401,7 @@ void zap(void)
 /*
  * mark all messages in current room as having been read
  */
-void slrp_highest(void)
-{
+void slrp_highest(void) {
        char buf[256];
 
        serv_puts("SLRP HIGHEST");
@@ -450,11 +429,10 @@ void slrp_highest(void)
 
 
 
-void LoadRoomAide(void)
-{
+void LoadRoomAide(void) {
        wcsession *WCC = WC;
        StrBuf *Buf;
-       
+
        if (WCC->CurRoom.RoomAideLoaded)
                return;
 
@@ -464,30 +442,29 @@ void LoadRoomAide(void)
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) != 2) {
                FlushStrBuf(WCC->CurRoom.RoomAide);
-               AppendImportantMessage (ChrPtr(Buf) + 4, 
-                                       StrLength(Buf) - 4);
-       else {
+               AppendImportantMessage(ChrPtr(Buf) + 4, StrLength(Buf) - 4);
+       }
+       else {
                const char *Pos;
 
                Pos = ChrPtr(Buf) + 4;
 
                FreeStrBuf(&WCC->CurRoom.RoomAide);
-               WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
+               WCC->CurRoom.RoomAide = NewStrBufPlain(NULL, StrLength(Buf));
 
-               StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|'); 
+               StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
        }
-       FreeStrBuf (&Buf);
+       FreeStrBuf(&Buf);
 }
 
-int SaveRoomAide(folder *Room)
-{
+int SaveRoomAide(folder * Room) {
        StrBuf *Buf;
-       Buf = NewStrBuf ();
+       Buf = NewStrBuf();
        serv_printf("SETA %s", ChrPtr(Room->RoomAide));
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) != 2) {
                StrBufCutLeft(Buf, 4);
-               AppendImportantMessage (SKEY(Buf));
+               AppendImportantMessage(SKEY(Buf));
                FreeStrBuf(&Buf);
                return 0;
        }
@@ -496,8 +473,7 @@ int SaveRoomAide(folder *Room)
 }
 
 
-int GetCurrentRoomFlags(folder *Room, int CareForStatusMessage)
-{
+int GetCurrentRoomFlags(folder * Room, int CareForStatusMessage) {
        StrBuf *Buf;
 
        Buf = NewStrBuf();
@@ -508,11 +484,12 @@ int GetCurrentRoomFlags(folder *Room, int CareForStatusMessage)
                FlushStrBuf(Room->Directory);
                StrBufCutLeft(Buf, 4);
                if (CareForStatusMessage)
-                       AppendImportantMessage (SKEY(Buf));
+                       AppendImportantMessage(SKEY(Buf));
                FreeStrBuf(&Buf);
                Room->XALoaded = 2;
                return 0;
-       } else {
+       }
+       else {
                const char *Pos;
 
                Pos = ChrPtr(Buf) + 4;
@@ -520,30 +497,29 @@ int GetCurrentRoomFlags(folder *Room, int CareForStatusMessage)
                FreeStrBuf(&Room->XAPass);
                FreeStrBuf(&Room->Directory);
 
-               Room->XAPass = NewStrBufPlain (NULL, StrLength (Buf));
-               Room->Directory = NewStrBufPlain (NULL, StrLength (Buf));
+               Room->XAPass = NewStrBufPlain(NULL, StrLength(Buf));
+               Room->Directory = NewStrBufPlain(NULL, StrLength(Buf));
 
                FreeStrBuf(&Room->name);
                Room->name = NewStrBufPlain(NULL, StrLength(Buf));
-               StrBufExtract_NextToken(Room->name, Buf, &Pos, '|'); 
-                                       
-               StrBufExtract_NextToken(Room->XAPass, Buf, &Pos, '|'); 
-               StrBufExtract_NextToken(Room->Directory, Buf, &Pos, '|'); 
-               
+               StrBufExtract_NextToken(Room->name, Buf, &Pos, '|');
+
+               StrBufExtract_NextToken(Room->XAPass, Buf, &Pos, '|');
+               StrBufExtract_NextToken(Room->Directory, Buf, &Pos, '|');
+
                Room->QRFlags = StrBufExtractNext_long(Buf, &Pos, '|');
                Room->floorid = StrBufExtractNext_long(Buf, &Pos, '|');
                Room->Order = StrBufExtractNext_long(Buf, &Pos, '|');
                Room->defview = StrBufExtractNext_long(Buf, &Pos, '|');
                Room->QRFlags2 = StrBufExtractNext_long(Buf, &Pos, '|');
-               FreeStrBuf (&Buf);
+               FreeStrBuf(&Buf);
                Room->XALoaded = 1;
                return 1;
        }
 }
 
 
-int SetCurrentRoomFlags(folder *Room)
-{
+int SetCurrentRoomFlags(folder * Room) {
        StrBuf *Buf;
 
        Buf = NewStrBuf();
@@ -554,29 +530,24 @@ int SetCurrentRoomFlags(folder *Room)
                    ChrPtr(Room->name),
                    ChrPtr(Room->XAPass),
                    ChrPtr(Room->Directory),
-                   Room->QRFlags, 
-                   Room->BumpUsers,
-                   Room->floorid, 
-                   Room->Order,
-                   Room->defview,
-                   Room->QRFlags2);
+                   Room->QRFlags, Room->BumpUsers, Room->floorid, Room->Order, Room->defview, Room->QRFlags2);
 
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) != 2) {
                StrBufCutLeft(Buf, 4);
-               AppendImportantMessage (SKEY(Buf));
+               AppendImportantMessage(SKEY(Buf));
                FreeStrBuf(&Buf);
                return 0;
-       } else {
+       }
+       else {
                FreeStrBuf(&Buf);
                return 1;
        }
 }
 
-void LoadRoomXA (void)
-{
+void LoadRoomXA(void) {
        wcsession *WCC = WC;
-               
+
        if (WCC->CurRoom.XALoaded > 0)
                return;
 
@@ -584,12 +555,11 @@ void LoadRoomXA (void)
 }
 
 
-void LoadXRoomPic(void)
-{
+void LoadXRoomPic(void) {
        wcsession *WCC = WC;
        StrBuf *Buf;
        off_t bytes;
-       
+
        if (WCC->CurRoom.XHaveRoomPicLoaded) {
                return;
        }
@@ -602,20 +572,20 @@ void LoadXRoomPic(void)
                StrBufCutLeft(Buf, 4);
                bytes = StrBufExtract_long(Buf, 0, '|');
                WCC->CurRoom.XHaveRoomPic = 1;
-               StrBuf_ServGetBLOBBuffered(Buf, bytes);         // discard the data
-       } else {
+               StrBuf_ServGetBLOBBuffered(Buf, bytes); // discard the data
+       }
+       else {
                WCC->CurRoom.XHaveRoomPic = 0;
        }
-       FreeStrBuf (&Buf);
+       FreeStrBuf(&Buf);
 }
 
 
-void LoadXRoomInfoText(void)
-{
+void LoadXRoomInfoText(void) {
        wcsession *WCC = WC;
        StrBuf *Buf;
        int Done = 0;
-       
+
        if (WCC->CurRoom.XHaveInfoTextLoaded) {
                return;
        }
@@ -627,13 +597,12 @@ void LoadXRoomInfoText(void)
 
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) == 1) {
-               WCC->CurRoom.XInfoText = NewStrBuf ();
-               
-               while (!Done && StrBuf_ServGetln(Buf)>=0) {
-                       if ( (StrLength(Buf)==3) && 
-                            !strcmp(ChrPtr(Buf), "000")) 
+               WCC->CurRoom.XInfoText = NewStrBuf();
+
+               while (!Done && StrBuf_ServGetln(Buf) >= 0) {
+                       if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000"))
                                Done = 1;
-                       else 
+                       else
                                StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0);
                }
        }
@@ -642,12 +611,11 @@ void LoadXRoomInfoText(void)
 }
 
 
-void LoadXRoomXCountFiles(void)
-{
+void LoadXRoomXCountFiles(void) {
        wcsession *WCC = WC;
        StrBuf *Buf;
        int Done = 0;
-       
+
        if (WCC->CurRoom.XHaveDownloadCount)
                return;
 
@@ -657,17 +625,16 @@ void LoadXRoomXCountFiles(void)
        serv_puts("RDIR");
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) == 1) {
-               
-               while (!Done && StrBuf_ServGetln(Buf)>=0) {
-                       if ( (StrLength(Buf)==3) && 
-                            !strcmp(ChrPtr(Buf), "000")) 
+
+               while (!Done && StrBuf_ServGetln(Buf) >= 0) {
+                       if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000"))
                                Done = 1;
-                       else 
+                       else
                                WCC->CurRoom.XDownloadCount++;
                }
        }
 
-       FreeStrBuf (&Buf);
+       FreeStrBuf(&Buf);
 }
 
 
@@ -677,31 +644,31 @@ void LoadXRoomXCountFiles(void)
 void toggle_self_service(void) {
        wcsession *WCC = WC;
 
-       if (GetCurrentRoomFlags (&WCC->CurRoom, 1) == 0)
+       if (GetCurrentRoomFlags(&WCC->CurRoom, 1) == 0)
                return;
 
-       if (yesbstr("QR2_SelfList")) 
+       if (yesbstr("QR2_SelfList"))
                WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SELFLIST;
-       else 
+       else
                WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SELFLIST;
 
-       if (yesbstr("QR2_SMTP_PUBLIC")) 
+       if (yesbstr("QR2_SMTP_PUBLIC"))
                WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SMTP_PUBLIC;
        else
                WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SMTP_PUBLIC;
 
-       if (yesbstr("QR2_Moderated")) 
+       if (yesbstr("QR2_Moderated"))
                WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_MODERATED;
        else
                WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_MODERATED;
-       if (yesbstr("QR2_SubsOnly")) 
+       if (yesbstr("QR2_SubsOnly"))
                WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SMTP_PUBLIC;
        else
                WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SMTP_PUBLIC;
 
-       SetCurrentRoomFlags (&WCC->CurRoom);
+       SetCurrentRoomFlags(&WCC->CurRoom);
 
-       output_headers(1, 1, 1, 0, 0, 0);       
+       output_headers(1, 1, 1, 0, 0, 0);
        do_template("room_edit");
        wDumpContent(1);
 }
@@ -711,8 +678,7 @@ void toggle_self_service(void) {
 /*
  * save new parameters for a room
  */
-void editroom(void)
-{
+void editroom(void) {
        wcsession *WCC = WC;
        const StrBuf *Ptr;
        const StrBuf *er_name;
@@ -727,27 +693,27 @@ void editroom(void)
                putlbstr("success", 0);
                AppendImportantMessage(_("Cancelled.  Changes were not saved."), -1);
                if (templ != NULL) {
-                       output_headers(1, 0, 0, 0, 0, 0);       
+                       output_headers(1, 0, 0, 0, 0, 0);
                        DoTemplate(SKEY(templ), NULL, &NoCtx);
                        end_burst();
                }
                else {
-                       output_headers(1, 1, 1, 0, 0, 0);       
+                       output_headers(1, 1, 1, 0, 0, 0);
                        do_template("room_edit");
                        wDumpContent(1);
                }
                return;
        }
 
-       if (GetCurrentRoomFlags (&WCC->CurRoom, 1) == 0) {
+       if (GetCurrentRoomFlags(&WCC->CurRoom, 1) == 0) {
                putlbstr("success", 0);
                if (templ != NULL) {
-                       output_headers(1, 0, 0, 0, 0, 0);       
+                       output_headers(1, 0, 0, 0, 0, 0);
                        DoTemplate(SKEY(templ), NULL, &NoCtx);
                        end_burst();
                }
                else {
-                       output_headers(1, 1, 1, 0, 0, 0);       
+                       output_headers(1, 1, 1, 0, 0, 0);
                        do_template("room_edit");
                        wDumpContent(1);
                }
@@ -769,73 +735,85 @@ void editroom(void)
        }
        if (!strcmp(ChrPtr(Ptr), "personal")) {
                WCC->CurRoom.QRFlags |= QR_MAILBOX;
-       } else {
+       }
+       else {
                WCC->CurRoom.QRFlags &= ~QR_MAILBOX;
        }
 
        if (yesbstr("prefonly")) {
                WCC->CurRoom.QRFlags |= QR_PREFONLY;
-       } else {
+       }
+       else {
                WCC->CurRoom.QRFlags &= ~QR_PREFONLY;
        }
 
        if (yesbstr("readonly")) {
                WCC->CurRoom.QRFlags |= QR_READONLY;
-       } else {
+       }
+       else {
                WCC->CurRoom.QRFlags &= ~QR_READONLY;
        }
 
        if (yesbstr("collabdel")) {
                WCC->CurRoom.QRFlags2 |= QR2_COLLABDEL;
-       } else {
+       }
+       else {
                WCC->CurRoom.QRFlags2 &= ~QR2_COLLABDEL;
        }
 
        if (yesbstr("permanent")) {
                WCC->CurRoom.QRFlags |= QR_PERMANENT;
-       } else {
+       }
+       else {
                WCC->CurRoom.QRFlags &= ~QR_PERMANENT;
        }
 
        if (yesbstr("subjectreq")) {
                WCC->CurRoom.QRFlags2 |= QR2_SUBJECTREQ;
-       } else {
+       }
+       else {
                WCC->CurRoom.QRFlags2 &= ~QR2_SUBJECTREQ;
        }
 
        if (yesbstr("network")) {
                WCC->CurRoom.QRFlags |= QR_NETWORK;
-       } else {
+       }
+       else {
                WCC->CurRoom.QRFlags &= ~QR_NETWORK;
        }
 
        if (yesbstr("directory")) {
                WCC->CurRoom.QRFlags |= QR_DIRECTORY;
-       } else {
+       }
+       else {
                WCC->CurRoom.QRFlags &= ~QR_DIRECTORY;
        }
 
        if (yesbstr("ulallowed")) {
                WCC->CurRoom.QRFlags |= QR_UPLOAD;
-       } else {
+       }
+       else {
                WCC->CurRoom.QRFlags &= ~QR_UPLOAD;
        }
 
        if (yesbstr("dlallowed")) {
                WCC->CurRoom.QRFlags |= QR_DOWNLOAD;
-       } else {
+       }
+       else {
                WCC->CurRoom.QRFlags &= ~QR_DOWNLOAD;
        }
 
        if (yesbstr("ulmsg")) {
                WCC->CurRoom.QRFlags2 |= QR2_NOUPLMSG;
-       } else {
+       }
+       else {
                WCC->CurRoom.QRFlags2 &= ~QR2_NOUPLMSG;
        }
 
        if (yesbstr("visdir")) {
                WCC->CurRoom.QRFlags |= QR_VISDIR;
-       } else {
+       }
+       else {
                WCC->CurRoom.QRFlags &= ~QR_VISDIR;
        }
 
@@ -847,8 +825,8 @@ void editroom(void)
        if (!strcmp(ChrPtr(Ptr), "anon2"))
                WCC->CurRoom.QRFlags |= QR_ANONOPT;
 
-       er_name     = sbstr("er_name");
-       er_dirname  = sbstr("er_dirname");
+       er_name = sbstr("er_name");
+       er_dirname = sbstr("er_dirname");
        er_roomaide = sbstr("er_roomaide");
        er_password = sbstr("er_password");
 
@@ -870,22 +848,22 @@ void editroom(void)
 
        succ1 = SetCurrentRoomFlags(&WCC->CurRoom);
 
-       succ2 = SaveRoomAide (&WCC->CurRoom);
-       
+       succ2 = SaveRoomAide(&WCC->CurRoom);
+
        if (succ1 + succ2 == 0) {
                putlbstr("success", 1);
-               AppendImportantMessage (_("Your changes have been saved."), -1);
+               AppendImportantMessage(_("Your changes have been saved."), -1);
        }
        else {
                putlbstr("success", 0);
        }
        if (templ != NULL) {
-               output_headers(1, 0, 0, 0, 0, 0);       
+               output_headers(1, 0, 0, 0, 0, 0);
                DoTemplate(SKEY(templ), NULL, &NoCtx);
                end_burst();
        }
        else {
-               output_headers(1, 1, 1, 0, 0, 0);       
+               output_headers(1, 1, 1, 0, 0, 0);
                do_template("room_edit");
                wDumpContent(1);
        }
@@ -897,16 +875,14 @@ void editroom(void)
 /*
  * Display form for Invite, Kick, and show Who Knows a room
  */
-void do_invt_kick(void) 
-{
+void do_invt_kick(void) {
        StrBuf *Buf, *User;
        const StrBuf *UserNames;
        int Kick, Invite;
        wcsession *WCC = WC;
 
 
-       if (GetCurrentRoomFlags(&WCC->CurRoom, 1) == 1)
-       {
+       if (GetCurrentRoomFlags(&WCC->CurRoom, 1) == 1) {
                const char *Pos;
                UserNames = sbstr("username");
                Kick = havebstr("kick_button");
@@ -914,50 +890,46 @@ void do_invt_kick(void)
 
                User = NewStrBufPlain(NULL, StrLength(UserNames));
                Buf = NewStrBuf();
-               
+
                Pos = ChrPtr(UserNames);
-               while (Pos != StrBufNOTNULL)
-               {
+               while (Pos != StrBufNOTNULL) {
                        StrBufExtract_NextToken(User, UserNames, &Pos, ',');
                        StrBufTrim(User);
-                       if ((StrLength(User) > 0) && (Kick))
-                       {
+                       if ((StrLength(User) > 0) && (Kick)) {
                                serv_printf("KICK %s", ChrPtr(User));
                                if (StrBuf_ServGetln(Buf) < 0)
                                        break;
                                if (GetServerStatus(Buf, NULL) != 2) {
                                        StrBufCutLeft(Buf, 4);
                                        AppendImportantMessage(SKEY(Buf));
-                               } else {
-                                       StrBufPrintf(Buf, 
-                                                    _("User '%s' kicked out of room '%s'."), 
-                                                    ChrPtr(User), 
-                                                    ChrPtr(WCC->CurRoom.name)
-                                               );
+                               }
+                               else {
+                                       StrBufPrintf(Buf,
+                                                    _("User '%s' kicked out of room '%s'."),
+                                                    ChrPtr(User), ChrPtr(WCC->CurRoom.name)
+                                           );
                                        AppendImportantMessage(SKEY(Buf));
                                }
                        }
-                       else if ((StrLength(User) > 0) && (Invite))
-                       {
+                       else if ((StrLength(User) > 0) && (Invite)) {
                                serv_printf("INVT %s", ChrPtr(User));
                                if (StrBuf_ServGetln(Buf) < 0)
                                        break;
                                if (GetServerStatus(Buf, NULL) != 2) {
                                        StrBufCutLeft(Buf, 4);
                                        AppendImportantMessage(SKEY(Buf));
-                               } else {
-                                       StrBufPrintf(Buf, 
-                                                    _("User '%s' invited to room '%s'."), 
-                                                    ChrPtr(User), 
-                                                    ChrPtr(WCC->CurRoom.name)
-                                               );
+                               }
+                               else {
+                                       StrBufPrintf(Buf,
+                                                    _("User '%s' invited to room '%s'."), ChrPtr(User), ChrPtr(WCC->CurRoom.name)
+                                           );
                                        AppendImportantMessage(SKEY(Buf));
                                }
                        }
-                }
-        }
+               }
+       }
 
-       output_headers(1, 1, 1, 0, 0, 0);       
+       output_headers(1, 1, 1, 0, 0, 0);
        do_template("room_edit");
        wDumpContent(1);
 }
@@ -966,8 +938,7 @@ void do_invt_kick(void)
 /*
  * Create a new room
  */
-void entroom(void)
-{
+void entroom(void) {
        StrBuf *Line;
        const StrBuf *er_name;
        const StrBuf *er_type;
@@ -983,7 +954,7 @@ void entroom(void)
                putlbstr("success", 0);
                AppendImportantMessage(_("Cancelled.  No new room was created."), -1);
                if (template != NULL) {
-                       output_headers(1, 0, 0, 0, 0, 0);       
+                       output_headers(1, 0, 0, 0, 0, 0);
                        DoTemplate(SKEY(template), NULL, &NoCtx);
                        end_burst();
                }
@@ -1008,13 +979,7 @@ void entroom(void)
        else if (!strcmp(ChrPtr(er_type), "personal"))
                er_num_type = 4;
 
-       serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d", 
-                   ChrPtr(er_name), 
-                   er_num_type, 
-                   ChrPtr(er_password), 
-                   er_floor, 
-                   0, 
-                   er_view);
+       serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d", ChrPtr(er_name), er_num_type, ChrPtr(er_password), er_floor, 0, er_view);
 
        Line = NewStrBuf();
        StrBuf_ServGetln(Line);
@@ -1022,7 +987,7 @@ void entroom(void)
                putlbstr("success", 0);
                FreeStrBuf(&Line);
                if (template != NULL) {
-                       output_headers(1, 0, 0, 0, 0, 0);       
+                       output_headers(1, 0, 0, 0, 0, 0);
                        DoTemplate(SKEY(template), NULL, &NoCtx);
                        end_burst();
                }
@@ -1031,25 +996,27 @@ void entroom(void)
                }
                return;
        }
+
        /** TODO: Room created, now update the left hand icon bar for this user */
        gotoroom(er_name);
 
        serv_printf("VIEW %d", er_view);
        StrBuf_ServGetln(Line);
-       FreeStrBuf(&Line); /* TODO: should we care about errors? */
+       FreeStrBuf(&Line);      /* TODO: should we care about errors? */
        WCC->CurRoom.view = er_view;
 
        putlbstr("success", 1);
        if (template != NULL) {
-               output_headers(1, 0, 0, 0, 0, 0);       
+               output_headers(1, 0, 0, 0, 0, 0);
                DoTemplate(SKEY(template), NULL, &NoCtx);
                end_burst();
        }
-       else if ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) {
-               output_headers(1, 1, 1, 0, 0, 0);       
+       else if ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) {
+               output_headers(1, 1, 1, 0, 0, 0);
                do_template("room_edit");
                wDumpContent(1);
-       } else {
+       }
+       else {
                smart_goto(WCC->CurRoom.name);
        }
        FreeStrBuf(&Line);
@@ -1083,7 +1050,7 @@ void set_room_policy(void) {
 
        if (!havebstr("ok_button")) {
                AppendImportantMessage(_("Cancelled.  Changes were not saved."), -1);
-               output_headers(1, 1, 1, 0, 0, 0);       
+               output_headers(1, 1, 1, 0, 0, 0);
                do_template("room_edit");
                wDumpContent(1);
                return;
@@ -1102,7 +1069,7 @@ void set_room_policy(void) {
        FreeStrBuf(&Line);
        ReloadCurrentRoom();
 
-       output_headers(1, 1, 1, 0, 0, 0);       
+       output_headers(1, 1, 1, 0, 0, 0);
        do_template("room_edit");
        wDumpContent(1);
 }
@@ -1128,8 +1095,8 @@ void netedit(void) {
        int Done;
 
        line[0] = '\0';
-        if (havebstr("force_room")) {
-                gotoroom(sbstr("force_room"));
+       if (havebstr("force_room")) {
+               gotoroom(sbstr("force_room"));
        }
        /*/ TODO: do line dynamic! */
        if (havebstr("line_pop3host")) {
@@ -1140,9 +1107,9 @@ void netedit(void) {
                strcat(line, "|");
                strcat(line, bstr("line_pop3pass"));
                strcat(line, "|");
-               strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
+               strcat(line, ibstr("line_pop3keep") ? "1" : "0");
                strcat(line, "|");
-               sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
+               sprintf(&line[strlen(line)], "%ld", lbstr("line_pop3int"));
                strcat(line, bstr("suffix"));
        }
        else if (havebstr("line")) {
@@ -1153,19 +1120,16 @@ void netedit(void) {
        else if (havebstr("alias")) {
                const char *domain;
                domain = bstr("aliasdomain");
-               if ((domain == NULL) || IsEmptyStr(domain))
-               {
+               if ((domain == NULL) || IsEmptyStr(domain)) {
                        malias_set_default = 1;
                        strcpy(line, bstr("prefix"));
                        strcat(line, bstr("default_aliasdomain"));
                }
-               else
-               {
+               else {
                        malias = 1;
                        sepchar = ',';
                        strcat(line, bstr("prefix"));
-                       if (!IsEmptyStr(domain))
-                       {
+                       if (!IsEmptyStr(domain)) {
                                strcat(line, "@");
                                strcat(line, domain);
                        }
@@ -1175,7 +1139,7 @@ void netedit(void) {
                }
        }
        else {
-               output_headers(1, 1, 1, 0, 0, 0);       
+               output_headers(1, 1, 1, 0, 0, 0);
                do_template("room_edit");
                wDumpContent(1);
                return;
@@ -1184,14 +1148,14 @@ void netedit(void) {
        Line = NewStrBuf();
        TmpBuf = NewStrBuf();
        if (malias)
-               serv_puts("GNET "FILE_MAILALIAS);
+               serv_puts("GNET " FILE_MAILALIAS);
        else
                serv_puts("GNET");
        StrBuf_ServGetln(Line);
-       if  (GetServerStatus(Line, NULL) != 1) {
-               AppendImportantMessage(SRV_STATUS_MSG(Line));   
+       if (GetServerStatus(Line, NULL) != 1) {
+               AppendImportantMessage(SRV_STATUS_MSG(Line));
                FreeStrBuf(&Line);
-               output_headers(1, 1, 1, 0, 0, 0);       
+               output_headers(1, 1, 1, 0, 0, 0);
                do_template("room_edit");
                wDumpContent(1);
                return;
@@ -1201,31 +1165,24 @@ void netedit(void) {
        Done = 0;
        extract_token(cmpb0, line, 0, sepchar, sizeof cmpb0);
        extract_token(cmpb1, line, 1, sepchar, sizeof cmpb1);
-       while (!Done && StrBuf_ServGetln(Line)>=0) {
-               if ( (StrLength(Line)==3) && 
-                    !strcmp(ChrPtr(Line), "000")) 
-               {
+       while (!Done && StrBuf_ServGetln(Line) >= 0) {
+               if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
                        Done = 1;
                }
-               else
-               {
+               else {
                        if (StrLength(Line) == 0)
                                continue;
 
-                       if (malias_set_default)
-                       {
-                               if (strncasecmp(ChrPtr(Line), HKEY("roommailalias|")) != 0)
-                               {
+                       if (malias_set_default) {
+                               if (strncasecmp(ChrPtr(Line), HKEY("roommailalias|")) != 0) {
                                        StrBufAppendBufPlain(Line, HKEY("\n"), 0);
                                        StrBufAppendBuf(TmpBuf, Line, 0);
                                }
                        }
-                       else
-                       {
+                       else {
                                extract_token(cmpa0, ChrPtr(Line), 0, sepchar, sizeof cmpa0);
                                extract_token(cmpa1, ChrPtr(Line), 1, sepchar, sizeof cmpa1);
-                               if ( (strcasecmp(cmpa0, cmpb0)) || (strcasecmp(cmpa1, cmpb1)) )
-                               {
+                               if ((strcasecmp(cmpa0, cmpb0)) || (strcasecmp(cmpa1, cmpb1))) {
                                        StrBufAppendBufPlain(Line, HKEY("\n"), 0);
                                        StrBufAppendBuf(TmpBuf, Line, 0);
                                }
@@ -1234,14 +1191,14 @@ void netedit(void) {
        }
 
        if (malias)
-               serv_puts("SNET "FILE_MAILALIAS);
+               serv_puts("SNET " FILE_MAILALIAS);
        else
                serv_puts("SNET");
        StrBuf_ServGetln(Line);
-       if  (GetServerStatus(Line, NULL) != 4) {
+       if (GetServerStatus(Line, NULL) != 4) {
 
-               AppendImportantMessage(SRV_STATUS_MSG(Line));   
-               output_headers(1, 1, 1, 0, 0, 0);       
+               AppendImportantMessage(SRV_STATUS_MSG(Line));
+               output_headers(1, 1, 1, 0, 0, 0);
                do_template("room_edit");
                wDumpContent(1);
                FreeStrBuf(&Line);
@@ -1260,7 +1217,7 @@ void netedit(void) {
                }
                else {
                        /* adding multiple addresses separated by commas */
-                       for (i=0; i<num_addrs; ++i) {
+                       for (i = 0; i < num_addrs; ++i) {
                                strcpy(line, bstr("prefix"));
                                extract_token(buf, bstr("line"), i, ',', sizeof buf);
                                striplt(buf);
@@ -1274,16 +1231,16 @@ void netedit(void) {
        serv_puts("000");
        serv_puts("NOOP");
        StrBuf_ServGetln(Line);
-       if  (GetServerStatus(Line, NULL) != 2) { /* WHOOOPS? ERROR? */
-               AppendImportantMessage(SRV_STATUS_MSG(Line));   
-               StrBuf_ServGetln(Line); /* resync... */
+       if (GetServerStatus(Line, NULL) != 2) { /* WHOOOPS? ERROR? */
+               AppendImportantMessage(SRV_STATUS_MSG(Line));
+               StrBuf_ServGetln(Line); /* resync... */
        }
 
 
        FlushIgnetCfgs(&WC->CurRoom);
        FreeStrBuf(&Line);
 
-       output_headers(1, 1, 1, 0, 0, 0);       
+       output_headers(1, 1, 1, 0, 0, 0);
        do_template("room_edit");
        wDumpContent(1);
 }
@@ -1291,10 +1248,9 @@ void netedit(void) {
 /*
  * Known rooms list (box style)
  */
-void knrooms(void)
-{
+void knrooms(void) {
        DeleteHash(&WC->Rooms);
-       output_headers(1, 1, 1, 0, 0, 0); 
+       output_headers(1, 1, 1, 0, 0, 0);
        do_template("knrooms");
        wDumpContent(1);
 }
@@ -1329,20 +1285,20 @@ void delete_floor(void) {
        int floornum;
        StrBuf *Buf;
        const char *Err;
-               
+
        floornum = ibstr("floornum");
        Buf = NewStrBuf();
        serv_printf("KFLR %d|1", floornum);
-       
+
        StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
 
        if (GetServerStatus(Buf, NULL) == 2) {
-               StrBufPlain(Buf, _("Floor has been deleted."),-1);
+               StrBufPlain(Buf, _("Floor has been deleted."), -1);
        }
        else {
                StrBufCutLeft(Buf, 4);
        }
-       AppendImportantMessage (SKEY(Buf));
+       AppendImportantMessage(SKEY(Buf));
 
        FlushRoomlist();
        http_transmit_thing(ChrPtr(do_template("floors")), 0);
@@ -1361,12 +1317,12 @@ void create_floor(void) {
        StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
 
        if (GetServerStatus(Buf, NULL) == 2) {
-               StrBufPlain(Buf, _("New floor has been created."),-1);
+               StrBufPlain(Buf, _("New floor has been created."), -1);
        }
        else {
                StrBufCutLeft(Buf, 4);
        }
-       AppendImportantMessage (SKEY(Buf));
+       AppendImportantMessage(SKEY(Buf));
        FlushRoomlist();
        http_transmit_thing(ChrPtr(do_template("floors")), 0);
        FreeStrBuf(&Buf);
@@ -1386,7 +1342,7 @@ void rename_floor(void) {
        StrBuf_ServGetln(Buf);
 
        StrBufCutLeft(Buf, 4);
-       AppendImportantMessage (SKEY(Buf));
+       AppendImportantMessage(SKEY(Buf));
 
        http_transmit_thing(ChrPtr(do_template("floors")), 0);
        FreeStrBuf(&Buf);
@@ -1394,8 +1350,7 @@ void rename_floor(void) {
 
 
 
-void jsonRoomFlr(void) 
-{
+void jsonRoomFlr(void) {
        /* Send as our own (application/json) content type */
        hprintf("HTTP/1.1 200 OK\r\n");
        hprintf("Content-type: application/json; charset=utf-8\r\n");
@@ -1403,12 +1358,11 @@ void jsonRoomFlr(void)
        hprintf("Connection: close\r\n");
        hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n");
        begin_burst();
-       DoTemplate(HKEY("json_roomflr"),NULL,&NoCtx);
-       end_burst(); 
+       DoTemplate(HKEY("json_roomflr"), NULL, &NoCtx);
+       end_burst();
 }
 
-void _FlushRoomList(wcsession *WCC)
-{
+void _FlushRoomList(wcsession * WCC) {
        free_march_list(WCC);
        DeleteHash(&WCC->Floors);
        DeleteHash(&WCC->Rooms);
@@ -1416,8 +1370,7 @@ void _FlushRoomList(wcsession *WCC)
        FlushFolder(&WCC->CurRoom);
 }
 
-void ReloadCurrentRoom(void)
-{
+void ReloadCurrentRoom(void) {
        wcsession *WCC = WC;
        StrBuf *CurRoom;
 
@@ -1428,22 +1381,15 @@ void ReloadCurrentRoom(void)
        FreeStrBuf(&CurRoom);
 }
 
-void FlushRoomlist(void)
-{
+void FlushRoomlist(void) {
        wcsession *WCC = WC;
        _FlushRoomList(WCC);
 }
 
 
-void 
-InitModule_ROOMOPS
-(void)
-{
-       RegisterPreference("roomlistview",
-                           _("Room list view"),
-                           PRF_STRING,
-                           NULL);
-        RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
+void InitModule_ROOMOPS(void) {
+       RegisterPreference("roomlistview", _("Room list view"), PRF_STRING, NULL);
+       RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
 
        WebcitAddUrlHandler(HKEY("json_roomflr"), "", 0, jsonRoomFlr, 0);
 
@@ -1459,7 +1405,7 @@ InitModule_ROOMOPS
        WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
        WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
        WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
-       
+
        WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
        WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
        WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
@@ -1517,12 +1463,12 @@ InitModule_ROOMOPS
        REGISTERTokenParamDefine(US_USER_SET);
 
        REGISTERTokenParamDefine(VIEW_BBS);
-       REGISTERTokenParamDefine(VIEW_MAILBOX); 
+       REGISTERTokenParamDefine(VIEW_MAILBOX);
        REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
-       REGISTERTokenParamDefine(VIEW_CALENDAR);        
-       REGISTERTokenParamDefine(VIEW_TASKS);   
-       REGISTERTokenParamDefine(VIEW_NOTES);           
-       REGISTERTokenParamDefine(VIEW_WIKI);            
+       REGISTERTokenParamDefine(VIEW_CALENDAR);
+       REGISTERTokenParamDefine(VIEW_TASKS);
+       REGISTERTokenParamDefine(VIEW_NOTES);
+       REGISTERTokenParamDefine(VIEW_WIKI);
        REGISTERTokenParamDefine(VIEW_CALBRIEF);
        REGISTERTokenParamDefine(VIEW_JOURNAL);
        REGISTERTokenParamDefine(VIEW_BLOG);
@@ -1535,14 +1481,14 @@ InitModule_ROOMOPS
        REGISTERTokenParamDefine(lastsent);
 
        REGISTERTokenParamDefine(ignet_push_share);
-       { /* these are the parts of an IGNET push config */
+       {                       /* these are the parts of an IGNET push config */
                REGISTERTokenParamDefine(GNET_IGNET_NODE);
                REGISTERTokenParamDefine(GNET_IGNET_ROOM);
        }
        REGISTERTokenParamDefine(listrecp);
        REGISTERTokenParamDefine(digestrecp);
        REGISTERTokenParamDefine(pop3client);
-       { /* These are the parts of a pop3 client line... */
+       {                       /* These are the parts of a pop3 client line... */
                REGISTERTokenParamDefine(GNET_POP3_HOST);
                REGISTERTokenParamDefine(GNET_POP3_USER);
                REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
@@ -1557,10 +1503,6 @@ InitModule_ROOMOPS
 }
 
 
-void 
-SessionDestroyModule_ROOMOPS
-(wcsession *sess)
-{
-       _FlushRoomList (sess);
+void SessionDestroyModule_ROOMOPS(wcsession * sess) {
+       _FlushRoomList(sess);
 }
-
index fd1f60e4ae62686a1bf9606569bc96722cf73097..e4403e07efb8e3e1c6b8a95e9d0b54fc0fe4a6c5 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2013 by the citadel.org team
  *
  * This struct holds a list of rooms for "Goto" operations.
  */
 struct march {
-       struct march *next;       /* pointer to next in linked list */
-       char march_name[128];     /* name of room */
-       int march_floor;          /* floor number of room */
-       int march_order;          /* sequence in which we are to visit this room */
+       struct march *next;     /* pointer to next in linked list */
+       char march_name[128];   /* name of room */
+       int march_floor;        /* floor number of room */
+       int march_order;        /* sequence in which we are to visit this room */
 };
 
 /*
@@ -29,10 +30,10 @@ struct march {
 struct roomlisting {
        struct roomlisting *lnext;      /* pointer to 'left' tree node */
        struct roomlisting *rnext;      /* pointer to 'right' tree node */
-       char rlname[128];               /* name of room */
-       unsigned rlflags;               /* room flags */
-       int rlfloor;                    /* the floor it resides on */
-       int rlorder;                    /* room listing order */
+       char rlname[128];       /* name of room */
+       unsigned rlflags;       /* room flags */
+       int rlfloor;            /* the floor it resides on */
+       int rlorder;            /* room listing order */
 };
 
 
@@ -50,14 +51,14 @@ typedef struct _floor {
  * Data structure for roomlist-to-folderlist conversion 
  */
 struct __ofolder {
-       int floor;      /* which floor is it on */
-       char room[SIZ]; /* which roomname ??? */
-       char name[SIZ]; /* which is its own name??? */
-       int hasnewmsgs; /* are there unread messages inside */
-       int is_mailbox; /* is it a mailbox?  */
-       int selectable; /* can we select it ??? */
-       int view;       /* whats its default view? inbox/calendar.... */
-       int num_rooms;  /* If this is a floor, how many rooms does it have */
+       int floor;              /* which floor is it on */
+       char room[SIZ];         /* which roomname ??? */
+       char name[SIZ];         /* which is its own name??? */
+       int hasnewmsgs;         /* are there unread messages inside */
+       int is_mailbox;         /* is it a mailbox?  */
+       int selectable;         /* can we select it ??? */
+       int view;               /* whats its default view? inbox/calendar.... */
+       int num_rooms;          /* If this is a floor, how many rooms does it have */
 };
 
 
@@ -67,30 +68,30 @@ struct __ofolder {
  */
 typedef struct _folder {
        /* Data citserver tells us about the room */
-       long QRFlags;    /* roomflags */
-       long QRFlags2;    /* Bitbucket NO2 */
+       long QRFlags;           /* roomflags */
+       long QRFlags2;          /* Bitbucket NO2 */
        long RAFlags;
 
-       int view;       /* whats its default view? inbox/calendar.... */
+       int view;               /* whats its default view? inbox/calendar.... */
        long defview;
-       long lastchange; /* todo... */
+       long lastchange;        /* todo... */
 
        /* later evaluated data from the serverdata */
-       StrBuf *name;   /* the full name of the room we're talking about */
+       StrBuf *name;           /* the full name of the room we're talking about */
        long nRoomNameParts;
        StrBuf **RoomNameParts;
 
-       int floorid;      /* which floor is it on */
-       const Floor *Floor;   /* point to the floor we're on.. */
+       int floorid;            /* which floor is it on */
+       const Floor *Floor;     /* point to the floor we're on.. */
 
-       int hasnewmsgs; /* are there unread messages inside */
-       int is_inbox;   /* is it a mailbox?  */
+       int hasnewmsgs;         /* are there unread messages inside */
+       int is_inbox;           /* is it a mailbox?  */
 
        int RoomAideLoaded;
        StrBuf *RoomAide;
 
 /* only available if GNET contains this */
-       const StrBuf* RoomAlias; /* by what mail will this room send mail? */
+       const StrBuf *RoomAlias;        /* by what mail will this room send mail? */
 
 /* only available if GETR was run */
        int XALoaded;
@@ -104,8 +105,9 @@ typedef struct _folder {
        long LastMessageRead;
        long HighestRead;
        int ShowInfo;
-       int UsersNewMAilboxMessages; /* should we notify the user about new messages? */
+       int UsersNewMAilboxMessages;    /* should we notify the user about new messages? */
        int IsTrash;
+
 /* Only available if certain other commands ran */
        int XHaveRoomPic;
        int XHaveRoomPicLoaded;
@@ -115,44 +117,44 @@ typedef struct _folder {
 
        int XHaveDownloadCount;
        int XDownloadCount;
-       
-       int BumpUsers; /* if SETR set to 1 to make all users who knew this room to forget about it. */
+
+       int BumpUsers;          /* if SETR set to 1 to make all users who knew this room to forget about it. */
 
        HashList *IgnetCfgs[maxRoomNetCfg + 1];
 } folder;
 
-HashList *GetFloorListHash(StrBuf *Target, WCTemplputParams *TP);
+HashList *GetFloorListHash(StrBuf * Target, WCTemplputParams * TP);
 void vDeleteFolder(void *vFolder);
-void FlushFolder(folder *room);
-void FlushIgnetCfgs(folder *room);
-void ParseGoto(folder *proom, StrBuf *Line);
-void FlushRoomlist(void); /* release our caches, so a deleted / zapped room disapears */
-void ReloadCurrentRoom(void); /* Flush cache; reload current state */
-
-HashList *GetFloorListHash(StrBuf *Target, WCTemplputParams *TP);
-HashList *GetRoomListHash(StrBuf *Target, WCTemplputParams *TP);
+void FlushFolder(folder * room);
+void FlushIgnetCfgs(folder * room);
+void ParseGoto(folder * proom, StrBuf * Line);
+void FlushRoomlist(void);      /* release our caches, so a deleted / zapped room disapears */
+void ReloadCurrentRoom(void);  /* Flush cache; reload current state */
+
+HashList *GetFloorListHash(StrBuf * Target, WCTemplputParams * TP);
+HashList *GetRoomListHash(StrBuf * Target, WCTemplputParams * TP);
 int SortRoomsByListOrder(const void *room1, const void *room2);
-void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP);
+void tmplput_roombanner(StrBuf * Target, WCTemplputParams * TP);
 
 
 void LoadRoomAide(void);
-void LoadRoomXA (void);
+void LoadRoomXA(void);
 void LoadXRoomPic(void);
 void LoadXRoomInfoText(void);
 void LoadXRoomXCountFiles(void);
 
-long gotoroom(const StrBuf *gname);
+long gotoroom(const StrBuf * gname);
 
 void slrp_highest(void);
-void remove_march(const StrBuf *aaa);
+void remove_march(const StrBuf * aaa);
 void dotskip(void);
-void smart_goto(const StrBuf *next_room);
-void free_march_list(wcsession *wcf);
+void smart_goto(const StrBuf * next_room);
+void free_march_list(wcsession * wcf);
 
 /*
  * wrapper around usual sort-comparator; private rooms will allways be prefered, -1 if one of them NULL
  */
-int CompareRooms(const folder *room1, const folder *room2);
+int CompareRooms(const folder * room1, const folder * room2);
 
 
 #define REST_TOPLEVEL 0
index 199cc3c1edd14466d650a9aad99d4541550a805d..31b9eb94bff622837bc56e972df158fdb606de41 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Lots of different room-related operations.
  *
@@ -24,20 +25,17 @@ CtxType CTX_FLOORS = CTX_NONE;
  * got                 The information returned from a GOTO server command
  * navbar_style        Determines which navigation buttons to display
  */
-void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_roombanner(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
-       
+
        /* Refresh current room states.  Doesn't work? gotoroom(NULL); */
 
        wc_printf("<div id=\"banner\">\n");
 
        /* The browser needs some information for its own use */
        wc_printf("<script type=\"text/javascript\">    \n"
-                 "     room_is_trash = %d;             \n"
-                 "</script>\n",
-                 ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0)
-       );
+                 "     room_is_trash = %d;             \n" "</script>\n", ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0)
+           );
 
        /*
         * If the user happens to select the "make this my start page" link,
@@ -61,24 +59,21 @@ void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
  *******************************************************************************/
 
 
-void tmplput_FLOOR_ID(StrBuf *Target, WCTemplputParams *TP) 
-{
-       Floor *myFloor = (Floor *)CTX(CTX_FLOORS);
+void tmplput_FLOOR_ID(StrBuf * Target, WCTemplputParams * TP) {
+       Floor *myFloor = (Floor *) CTX(CTX_FLOORS);
 
        StrBufAppendPrintf(Target, "%d", myFloor->ID);
 }
 
 
-void tmplput_ROOM_FLOORID(StrBuf *Target, WCTemplputParams *TP) 
-{
-       folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_FLOORID(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) CTX(CTX_ROOMS);
        StrBufAppendPrintf(Target, "%d", Folder->floorid);
 }
 
 
-void tmplput_ROOM_FLOOR_ID(StrBuf *Target, WCTemplputParams *TP) 
-{
-       folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_FLOOR_ID(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) CTX(CTX_ROOMS);
        const Floor *pFloor = Folder->Floor;
 
        if (pFloor == NULL)
@@ -88,9 +83,8 @@ void tmplput_ROOM_FLOOR_ID(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void tmplput_ROOM_FLOOR_NAME(StrBuf *Target, WCTemplputParams *TP) 
-{
-       folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_FLOOR_NAME(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) CTX(CTX_ROOMS);
        const Floor *pFloor = Folder->Floor;
 
        if (pFloor == NULL)
@@ -100,8 +94,7 @@ void tmplput_ROOM_FLOOR_NAME(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void tmplput_ThisRoomFloorName(StrBuf *Target, WCTemplputParams *TP) 
-{
+void tmplput_ThisRoomFloorName(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
        folder *Folder = &WCC->CurRoom;
        const Floor *pFloor;
@@ -117,25 +110,22 @@ void tmplput_ThisRoomFloorName(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void tmplput_FLOOR_NAME(StrBuf *Target, WCTemplputParams *TP) 
-{
-       Floor *myFloor = (Floor *)CTX(CTX_FLOORS);
+void tmplput_FLOOR_NAME(StrBuf * Target, WCTemplputParams * TP) {
+       Floor *myFloor = (Floor *) CTX(CTX_FLOORS);
 
        StrBufAppendTemplate(Target, TP, myFloor->Name, 0);
 }
 
 
-void tmplput_FLOOR_NROOMS(StrBuf *Target, WCTemplputParams *TP) 
-{
-       Floor *myFloor = (Floor *)CTX(CTX_FLOORS);
+void tmplput_FLOOR_NROOMS(StrBuf * Target, WCTemplputParams * TP) {
+       Floor *myFloor = (Floor *) CTX(CTX_FLOORS);
 
        StrBufAppendPrintf(Target, "%d", myFloor->NRooms);
 }
 
 
-void tmplput_ROOM_FLOOR_NROOMS(StrBuf *Target, WCTemplputParams *TP) 
-{
-       folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_FLOOR_NROOMS(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) CTX(CTX_ROOMS);
        const Floor *pFloor = Folder->Floor;
 
        if (pFloor == NULL)
@@ -144,9 +134,8 @@ void tmplput_ROOM_FLOOR_NROOMS(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-int ConditionalFloorHaveNRooms(StrBuf *Target, WCTemplputParams *TP)
-{
-       Floor *MyFloor = (Floor *)CTX(CTX_FLOORS);
+int ConditionalFloorHaveNRooms(StrBuf * Target, WCTemplputParams * TP) {
+       Floor *MyFloor = (Floor *) CTX(CTX_FLOORS);
        int HaveN;
 
        HaveN = GetTemplateTokenNumber(Target, TP, 0, 0);
@@ -155,30 +144,27 @@ int ConditionalFloorHaveNRooms(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-int ConditionalFloorIsRESTSubFloor(StrBuf *Target, WCTemplputParams *TP)
-{
-       wcsession  *WCC = WC;
-       Floor *MyFloor = (Floor *)CTX(CTX_FLOORS);
+int ConditionalFloorIsRESTSubFloor(StrBuf * Target, WCTemplputParams * TP) {
+       wcsession *WCC = WC;
+       Floor *MyFloor = (Floor *) CTX(CTX_FLOORS);
+
        /** if we have dav_depth the client just wants the subfloors */
-       if ((WCC->Hdr->HR.dav_depth == 1) && 
-           (GetCount(WCC->Directory) == 0))
+       if ((WCC->Hdr->HR.dav_depth == 1) && (GetCount(WCC->Directory) == 0))
                return 1;
        return WCC->CurrentFloor == MyFloor;
 }
 
 
-int ConditionalFloorIsSUBROOM(StrBuf *Target, WCTemplputParams *TP)
-{
-       wcsession  *WCC = WC;
-       Floor *MyFloor = (Floor *)CTX(CTX_FLOORS);
+int ConditionalFloorIsSUBROOM(StrBuf * Target, WCTemplputParams * TP) {
+       wcsession *WCC = WC;
+       Floor *MyFloor = (Floor *) CTX(CTX_FLOORS);
 
        return WCC->CurRoom.floorid == MyFloor->ID;
 }
 
 
-int ConditionalFloorIsVirtual(StrBuf *Target, WCTemplputParams *TP)
-{
-       Floor *MyFloor = (Floor *)CTX(CTX_FLOORS);
+int ConditionalFloorIsVirtual(StrBuf * Target, WCTemplputParams * TP) {
+       Floor *MyFloor = (Floor *) CTX(CTX_FLOORS);
 
        return MyFloor->ID == VIRTUAL_MY_FLOOR;
 }
@@ -187,51 +173,43 @@ int ConditionalFloorIsVirtual(StrBuf *Target, WCTemplputParams *TP)
 /*******************************************************************************
  ********************** ROOM Tokens ********************************************
  *******************************************************************************/
+
 /**** Name ******/
 
-void tmplput_ThisRoom(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ThisRoom(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
        if (WCC != NULL) {
-               StrBufAppendTemplate(Target, TP, 
-                    WCC->CurRoom.name, 
-                    0
-               );
+               StrBufAppendTemplate(Target, TP, WCC->CurRoom.name, 0);
        }
 }
 
 
-void tmplput_ROOM_NAME(StrBuf *Target, WCTemplputParams *TP) 
-{
-       folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_NAME(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) CTX(CTX_ROOMS);
 
        StrBufAppendTemplate(Target, TP, Folder->name, 0);
 }
 
 
-void tmplput_ROOM_BASENAME(StrBuf *Target, WCTemplputParams *TP) 
-{
-       folder *room = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_BASENAME(StrBuf * Target, WCTemplputParams * TP) {
+       folder *room = (folder *) CTX(CTX_ROOMS);
 
        if (room->nRoomNameParts > 1)
-               StrBufAppendTemplate(Target, TP, 
-                                     room->RoomNameParts[room->nRoomNameParts - 1], 0);
-       else 
+               StrBufAppendTemplate(Target, TP, room->RoomNameParts[room->nRoomNameParts - 1], 0);
+       else
                StrBufAppendTemplate(Target, TP, room->name, 0);
 }
 
 
-void tmplput_ROOM_LEVEL_N_TIMES(StrBuf *Target, WCTemplputParams *TP) 
-{
-       folder *room = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_LEVEL_N_TIMES(StrBuf * Target, WCTemplputParams * TP) {
+       folder *room = (folder *) CTX(CTX_ROOMS);
        int i;
-        const char *AppendMe;
-        long AppendMeLen;
+       const char *AppendMe;
+       long AppendMeLen;
 
 
-       if (room->nRoomNameParts > 1)
-       {
+       if (room->nRoomNameParts > 1) {
                GetTemplateTokenString(Target, TP, 0, &AppendMe, &AppendMeLen);
                for (i = 0; i < room->nRoomNameParts; i++)
                        StrBufAppendBufPlain(Target, AppendMe, AppendMeLen, 0);
@@ -239,23 +217,19 @@ void tmplput_ROOM_LEVEL_N_TIMES(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-int ConditionalRoomIsInbox(StrBuf *Target, WCTemplputParams *TP)
-{
-       folder *Folder = (folder *)CTX(CTX_ROOMS);
+int ConditionalRoomIsInbox(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) CTX(CTX_ROOMS);
        return Folder->is_inbox;
 }
 
-int ConditionalRoomIsType(StrBuf *Target, WCTemplputParams *TP)
-{
-       folder *Folder = (folder *)CTX(CTX_ROOMS);
+int ConditionalRoomIsType(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) CTX(CTX_ROOMS);
 
        if (Folder == NULL)
                return 0;
 
-       if ((TP->Tokens->nParameters < 3))
-       {
-               return ((Folder->view < VIEW_BBS) || 
-                       (Folder->view > VIEW_MAX));
+       if ((TP->Tokens->nParameters < 3)) {
+               return ((Folder->view < VIEW_BBS) || (Folder->view > VIEW_MAX));
        }
 
        return Folder->view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
@@ -264,87 +238,78 @@ int ConditionalRoomIsType(StrBuf *Target, WCTemplputParams *TP)
 
 
 /****** Properties ******/
-int ConditionalRoom_MayEdit(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalRoom_MayEdit(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
-       LoadRoomXA ();
+       LoadRoomXA();
 
        return WCC->CurRoom.XALoaded == 1;
 }
 
-int ConditionalThisRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalThisRoomHas_QRFlag(StrBuf * Target, WCTemplputParams * TP) {
        long QR_CheckFlag;
        wcsession *WCC = WC;
-       
+
        QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
        if (QR_CheckFlag == 0)
                LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
                                 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
-       
+
        if (WCC == NULL)
                return 0;
 
-       if ((TP->Tokens->Params[2]->MaskBy == eOR) ||
-           (TP->Tokens->Params[2]->MaskBy == eNO))
+       if ((TP->Tokens->Params[2]->MaskBy == eOR) || (TP->Tokens->Params[2]->MaskBy == eNO))
                return (WCC->CurRoom.QRFlags & QR_CheckFlag) != 0;
        else
                return (WCC->CurRoom.QRFlags & QR_CheckFlag) == QR_CheckFlag;
 }
 
 
-int ConditionalRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalRoomHas_QRFlag(StrBuf * Target, WCTemplputParams * TP) {
        long QR_CheckFlag;
-       folder *Folder = (folder *)(TP->Context);
+       folder *Folder = (folder *) (TP->Context);
 
        QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
        if (QR_CheckFlag == 0)
                LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
                                 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
 
-       if ((TP->Tokens->Params[2]->MaskBy == eOR) ||
-           (TP->Tokens->Params[2]->MaskBy == eNO))
+       if ((TP->Tokens->Params[2]->MaskBy == eOR) || (TP->Tokens->Params[2]->MaskBy == eNO))
                return (Folder->QRFlags & QR_CheckFlag) != 0;
        else
                return (Folder->QRFlags & QR_CheckFlag) == QR_CheckFlag;
 }
 
 
-void tmplput_ROOM_QRFLAGS(StrBuf *Target, WCTemplputParams *TP) 
-{
-       folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_QRFLAGS(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) CTX(CTX_ROOMS);
        StrBufAppendPrintf(Target, "%d", Folder->QRFlags);
 }
 
 
-int ConditionalThisRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalThisRoomHas_QRFlag2(StrBuf * Target, WCTemplputParams * TP) {
        long QR2_CheckFlag;
        wcsession *WCC = WC;
-       
+
        QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
        if (QR2_CheckFlag == 0)
                LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
                                 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
 
-       
+
        if (WCC == NULL)
                return 0;
 
-       if ((TP->Tokens->Params[2]->MaskBy == eOR) ||
-           (TP->Tokens->Params[2]->MaskBy == eNO))
+       if ((TP->Tokens->Params[2]->MaskBy == eOR) || (TP->Tokens->Params[2]->MaskBy == eNO))
                return (WCC->CurRoom.QRFlags2 & QR2_CheckFlag) != 0;
        else
                return (WCC->CurRoom.QRFlags2 & QR2_CheckFlag) == QR2_CheckFlag;
 }
 
 
-int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalRoomHas_QRFlag2(StrBuf * Target, WCTemplputParams * TP) {
        long QR2_CheckFlag;
-       folder *Folder = (folder *)(TP->Context);
+       folder *Folder = (folder *) (TP->Context);
 
        QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
        if (QR2_CheckFlag == 0)
@@ -354,11 +319,10 @@ int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-int ConditionalRoomHas_UAFlag(StrBuf *Target, WCTemplputParams *TP)
-{
-       folder *Folder = (folder *)(TP->Context);
+int ConditionalRoomHas_UAFlag(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) (TP->Context);
        long UA_CheckFlag;
-               
+
        UA_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
        if (UA_CheckFlag == 0)
                LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
@@ -368,23 +332,20 @@ int ConditionalRoomHas_UAFlag(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void tmplput_ROOM_ACL(StrBuf *Target, WCTemplputParams *TP) 
-{
-       folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_ACL(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) CTX(CTX_ROOMS);
 
        StrBufAppendPrintf(Target, "%ld", Folder->RAFlags, 0);
 }
 
 
-void tmplput_ROOM_RAFLAGS(StrBuf *Target, WCTemplputParams *TP) 
-{
-       folder *Folder = (folder *)(TP->Context);
+void tmplput_ROOM_RAFLAGS(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) (TP->Context);
        StrBufAppendPrintf(Target, "%d", Folder->RAFlags);
 }
 
 
-void tmplput_ThisRoomAide(StrBuf *Target, WCTemplputParams *TP) 
-{
+void tmplput_ThisRoomAide(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
        LoadRoomAide();
@@ -393,41 +354,33 @@ void tmplput_ThisRoomAide(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-int ConditionalRoomAide(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalRoomAide(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
-       return (WCC != NULL)? 
-               ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) : 0;
+       return (WCC != NULL) ? ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) : 0;
 }
 
 
-int ConditionalRoomAcessDelete(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalRoomAcessDelete(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
-       return (WCC == NULL)? 0 : 
-               ( ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
-                  (WCC->CurRoom.is_inbox) || 
-                  (WCC->CurRoom.QRFlags2 & QR2_COLLABDEL) );
+       return (WCC == NULL) ? 0 :
+           (((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) || (WCC->CurRoom.is_inbox) || (WCC->CurRoom.QRFlags2 & QR2_COLLABDEL));
 }
 
 
-int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalHaveRoomeditRights(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
-       return (        (WCC != NULL)
-                       && (WCC->logged_in)
-                       && (
-                               (WCC->axlevel >= 6)
-                               || ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0)
-                               || (WCC->CurRoom.is_inbox)
-                       )
-               );
+       return ((WCC != NULL)
+               && (WCC->logged_in)
+               && ((WCC->axlevel >= 6)
+                   || ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0)
+                   || (WCC->CurRoom.is_inbox)
+               )
+           );
 }
 
 
-void tmplput_ThisRoomPass(StrBuf *Target, WCTemplputParams *TP) 
-{
+void tmplput_ThisRoomPass(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
        LoadRoomXA();
@@ -435,24 +388,21 @@ void tmplput_ThisRoomPass(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void tmplput_ThisRoom_nNewMessages(StrBuf *Target, WCTemplputParams *TP) 
-{
+void tmplput_ThisRoom_nNewMessages(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
        StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nNewMessages);
 }
 
 
-void tmplput_ThisRoom_nTotalMessages(StrBuf *Target, WCTemplputParams *TP) 
-{
+void tmplput_ThisRoom_nTotalMessages(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
        StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nTotalMessages);
 }
 
 
-void tmplput_ThisRoomOrder(StrBuf *Target, WCTemplputParams *TP) 
-{
+void tmplput_ThisRoomOrder(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
        LoadRoomXA();
@@ -461,8 +411,7 @@ void tmplput_ThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalThisRoomOrder(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
        long CheckThis;
 
@@ -476,17 +425,15 @@ int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void tmplput_ROOM_LISTORDER(StrBuf *Target, WCTemplputParams *TP) 
-{
-       folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_LISTORDER(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) CTX(CTX_ROOMS);
        StrBufAppendPrintf(Target, "%d", Folder->Order);
 }
 
 
-int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalThisRoomXHavePic(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
-       
+
        if (WCC == NULL)
                return 0;
 
@@ -494,30 +441,27 @@ int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
        return WCC->CurRoom.XHaveRoomPic == 1;
 }
 
-int ConditionalThisRoomIsEdit(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalThisRoomIsEdit(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
        if (WCC == NULL)
                return 0;
-       return ((WCC->CurRoom.nRoomNameParts > 1) && 
+       return ((WCC->CurRoom.nRoomNameParts > 1) &&
                (strcmp(ChrPtr(WCC->CurRoom.RoomNameParts[WCC->CurRoom.nRoomNameParts]), "edit") == 0));
 }
 
-int ConditionalThisRoomXHaveInfoText(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalThisRoomXHaveInfoText(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
-       
+
        if (WCC == NULL)
                return 0;
 
        LoadXRoomInfoText();
-       return (StrLength(WCC->CurRoom.XInfoText)>0);
+       return (StrLength(WCC->CurRoom.XInfoText) > 0);
 }
 
 
-void tmplput_ThisRoomInfoText(StrBuf *Target, WCTemplputParams *TP) 
-{
+void tmplput_ThisRoomInfoText(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
        long nchars = 0;
 
@@ -542,15 +486,13 @@ void tmplput_ThisRoomInfoText(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void tmplput_ROOM_LASTCHANGE(StrBuf *Target, WCTemplputParams *TP) 
-{
-       folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_LASTCHANGE(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) CTX(CTX_ROOMS);
        StrBufAppendPrintf(Target, "%d", Folder->lastchange);
 }
 
 
-void tmplput_ThisRoomDirectory(StrBuf *Target, WCTemplputParams *TP) 
-{
+void tmplput_ThisRoomDirectory(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
        LoadRoomXA();
@@ -559,8 +501,7 @@ void tmplput_ThisRoomDirectory(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void tmplput_ThisRoomXNFiles(StrBuf *Target, WCTemplputParams *TP) 
-{
+void tmplput_ThisRoomXNFiles(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
        LoadXRoomXCountFiles();
@@ -569,8 +510,7 @@ void tmplput_ThisRoomXNFiles(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void tmplput_ThisRoomX_FileString(StrBuf *Target, WCTemplputParams *TP) 
-{
+void tmplput_ThisRoomX_FileString(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
        LoadXRoomXCountFiles();
@@ -582,9 +522,8 @@ void tmplput_ThisRoomX_FileString(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-int ConditionalIsThisThatRoom(StrBuf *Target, WCTemplputParams *TP)
-{
-       folder *Folder = (folder *)CTX(CTX_ROOMS);
+int ConditionalIsThisThatRoom(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) CTX(CTX_ROOMS);
        wcsession *WCC = WC;
 
        if (WCC == NULL)
@@ -593,11 +532,10 @@ int ConditionalIsThisThatRoom(StrBuf *Target, WCTemplputParams *TP)
        return Folder == WCC->ThisRoom;
 }
 
-int ConditionalRoomIsName(StrBuf *Target, WCTemplputParams *TP)
-{
-       folder *Folder = (folder *)CTX(CTX_ROOMS);
-        const char *CheckRoomName = NULL;
-        long CheckRoomNameLen;
+int ConditionalRoomIsName(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) CTX(CTX_ROOMS);
+       const char *CheckRoomName = NULL;
+       long CheckRoomNameLen;
 
        GetTemplateTokenString(Target, TP, 3, &CheckRoomName, &CheckRoomNameLen);
        if (CheckRoomName == NULL)
@@ -606,10 +544,7 @@ int ConditionalRoomIsName(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void 
-InitModule_ROOMTOKENS
-(void)
-{
+void InitModule_ROOMTOKENS(void) {
        /* we duplicate this, just to be shure its already done. */
        RegisterCTX(CTX_ROOMS);
        RegisterCTX(CTX_FLOORS);
@@ -633,7 +568,8 @@ InitModule_ROOMTOKENS
        RegisterConditional("COND:FLOOR:ISVIRTUAL", 0, ConditionalFloorIsVirtual, CTX_FLOORS);
 
        /**** Room... ******/
-        /**** Name ******/
+
+       /**** Name ******/
        RegisterNamespace("THISROOM:NAME", 0, 1, tmplput_ThisRoom, NULL, CTX_NONE);
 
        RegisterNamespace("ROOM:INFO:NAME", 0, 1, tmplput_ROOM_NAME, NULL, CTX_ROOMS);
index 18563000db4ebc8062d6d7c76d42627c2d4319d2..6364049c8905e021b7694856e418fc56dec1b19c 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Lots of different room-related operations.
  */
@@ -12,18 +13,18 @@ char *viewdefs[VIEW_MAX];
  * default view for a room at the time of its creation.
  */
 int allowed_default_views[VIEW_MAX] = {
-       1, /* VIEW_BBS          Bulletin board */
-       1, /* VIEW_MAILBOX      Mailbox summary */
-       1, /* VIEW_ADDRESSBOOK  Address book */
-       1, /* VIEW_CALENDAR     Calendar */
-       1, /* VIEW_TASKS        Tasks */
-       1, /* VIEW_NOTES        Notes */
-       1, /* VIEW_WIKI         Wiki */
-       0, /* VIEW_CALBRIEF     Brief Calendar */
-       0, /* VIEW_JOURNAL      Journal */
-       0, /* VIEW_DRAFTS       Drafts */
-       1, /* VIEW_BLOG         Blog */
-       0  /* VIEW_QUEUE        Mail Queue */
+       1,                      /* VIEW_BBS          Bulletin board */
+       1,                      /* VIEW_MAILBOX      Mailbox summary */
+       1,                      /* VIEW_ADDRESSBOOK  Address book */
+       1,                      /* VIEW_CALENDAR     Calendar */
+       1,                      /* VIEW_TASKS        Tasks */
+       1,                      /* VIEW_NOTES        Notes */
+       1,                      /* VIEW_WIKI         Wiki */
+       0,                      /* VIEW_CALBRIEF     Brief Calendar */
+       0,                      /* VIEW_JOURNAL      Journal */
+       0,                      /* VIEW_DRAFTS       Drafts */
+       1,                      /* VIEW_BLOG         Blog */
+       0                       /* VIEW_QUEUE        Mail Queue */
 };
 
 /*
@@ -48,25 +49,24 @@ ROOM_VIEWS exchangeable_views[VIEW_MAX][VIEW_MAX] = {
  * Initialize the viewdefs with localized strings
  */
 void initialize_viewdefs(void) {
-       viewdefs[VIEW_BBS]              = _("Bulletin Board");
-       viewdefs[VIEW_MAILBOX]          = _("Mail Folder");
-       viewdefs[VIEW_ADDRESSBOOK]      = _("Address Book");
-       viewdefs[VIEW_CALENDAR]         = _("Calendar");
-       viewdefs[VIEW_TASKS]            = _("Task List");
-       viewdefs[VIEW_NOTES]            = _("Notes List");
-       viewdefs[VIEW_WIKI]             = _("Wiki");
-       viewdefs[VIEW_CALBRIEF]         = _("Calendar List");
-       viewdefs[VIEW_JOURNAL]          = _("Journal");
-       viewdefs[VIEW_DRAFTS]           = _("Drafts");
-       viewdefs[VIEW_BLOG]             = _("Blog");
+       viewdefs[VIEW_BBS] = _("Bulletin Board");
+       viewdefs[VIEW_MAILBOX] = _("Mail Folder");
+       viewdefs[VIEW_ADDRESSBOOK] = _("Address Book");
+       viewdefs[VIEW_CALENDAR] = _("Calendar");
+       viewdefs[VIEW_TASKS] = _("Task List");
+       viewdefs[VIEW_NOTES] = _("Notes List");
+       viewdefs[VIEW_WIKI] = _("Wiki");
+       viewdefs[VIEW_CALBRIEF] = _("Calendar List");
+       viewdefs[VIEW_JOURNAL] = _("Journal");
+       viewdefs[VIEW_DRAFTS] = _("Drafts");
+       viewdefs[VIEW_BLOG] = _("Blog");
 }
 
 
-void tmplput_ROOM_COLLECTIONTYPE(StrBuf *Target, WCTemplputParams *TP) 
-{
-       folder *Folder = (folder *)CTX(CTX_ROOMS);
-       
-       switch(Folder->view) {
+void tmplput_ROOM_COLLECTIONTYPE(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) CTX(CTX_ROOMS);
+
+       switch (Folder->view) {
        case VIEW_CALENDAR:
                StrBufAppendBufPlain(Target, HKEY("vevent"), 0);
                break;
@@ -90,50 +90,37 @@ void tmplput_ROOM_COLLECTIONTYPE(StrBuf *Target, WCTemplputParams *TP)
 
 
 
-int ConditionalRoomHasGroupdavContent(StrBuf *Target, WCTemplputParams *TP)
-{
-       folder *Folder = (folder *)CTX(CTX_ROOMS);
+int ConditionalRoomHasGroupdavContent(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) CTX(CTX_ROOMS);
 
        syslog(LOG_DEBUG, "-> %s: %d\n", ChrPtr(Folder->name), Folder->view);
 
-       return ((Folder->view == VIEW_CALENDAR) || 
-               (Folder->view == VIEW_TASKS) || 
-               (Folder->view == VIEW_ADDRESSBOOK) ||
-               (Folder->view == VIEW_NOTES) ||
-               (Folder->view == VIEW_JOURNAL) );
+       return ((Folder->view == VIEW_CALENDAR) ||
+               (Folder->view == VIEW_TASKS) ||
+               (Folder->view == VIEW_ADDRESSBOOK) || (Folder->view == VIEW_NOTES) || (Folder->view == VIEW_JOURNAL));
 }
 
 
 
 
-int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalIsRoomtype(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
-       if ((WCC == NULL) ||
-           (TP->Tokens->nParameters < 3))
-       {
-               return ((WCC->CurRoom.view < VIEW_BBS) || 
-                       (WCC->CurRoom.view > VIEW_MAX));
+       if ((WCC == NULL) || (TP->Tokens->nParameters < 3)) {
+               return ((WCC->CurRoom.view < VIEW_BBS) || (WCC->CurRoom.view > VIEW_MAX));
        }
 
        return WCC->CurRoom.view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
 }
 
 
-void tmplput_CurrentRoomViewString(StrBuf *Target, WCTemplputParams *TP) 
-{
+void tmplput_CurrentRoomViewString(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
        StrBuf *Buf;
 
-       if ((WCC == NULL) ||
-           (WCC->CurRoom.defview >= VIEW_MAX) || 
-           (WCC->CurRoom.defview < VIEW_BBS))
-       {
+       if ((WCC == NULL) || (WCC->CurRoom.defview >= VIEW_MAX) || (WCC->CurRoom.defview < VIEW_BBS)) {
                LogTemplateError(Target, "Token", ERR_PARM2, TP,
-                                "Roomview [%ld] not valid\n", 
-                                (WCC != NULL)? 
-                                WCC->CurRoom.defview : -1);
+                                "Roomview [%ld] not valid\n", (WCC != NULL) ? WCC->CurRoom.defview : -1);
                return;
        }
 
@@ -142,17 +129,13 @@ void tmplput_CurrentRoomViewString(StrBuf *Target, WCTemplputParams *TP)
        FreeStrBuf(&Buf);
 }
 
-void tmplput_RoomViewString(StrBuf *Target, WCTemplputParams *TP) 
-{
+void tmplput_RoomViewString(StrBuf * Target, WCTemplputParams * TP) {
        long CheckThis;
        StrBuf *Buf;
 
        CheckThis = GetTemplateTokenNumber(Target, TP, 0, 0);
-       if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
-       {
-               LogTemplateError(Target, "Token", ERR_PARM2, TP,
-                                "Roomview [%ld] not valid\n", 
-                                CheckThis);
+       if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS)) {
+               LogTemplateError(Target, "Token", ERR_PARM2, TP, "Roomview [%ld] not valid\n", CheckThis);
                return;
        }
 
@@ -163,28 +146,23 @@ void tmplput_RoomViewString(StrBuf *Target, WCTemplputParams *TP)
 
 
 
-int ConditionalIsAllowedDefaultView(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalIsAllowedDefaultView(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
        long CheckThis;
-       
+
        if (WCC == NULL)
                return 0;
 
        CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
-       if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
-       {
-               LogTemplateError(Target, "Conditional", ERR_PARM2, TP,
-                                "Roomview [%ld] not valid\n", 
-                                CheckThis);
+       if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS)) {
+               LogTemplateError(Target, "Conditional", ERR_PARM2, TP, "Roomview [%ld] not valid\n", CheckThis);
                return 0;
        }
 
        return allowed_default_views[CheckThis] != 0;
 }
 
-int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalThisRoomDefView(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
        long CheckThis;
 
@@ -195,8 +173,7 @@ int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
        return CheckThis == WCC->CurRoom.defview;
 }
 
-int ConditionalThisRoomCurrView(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalThisRoomCurrView(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
        long CheckThis;
 
@@ -207,49 +184,39 @@ int ConditionalThisRoomCurrView(StrBuf *Target, WCTemplputParams *TP)
        return CheckThis == WCC->CurRoom.view;
 }
 
-int ConditionalThisRoomHaveView(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalThisRoomHaveView(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
        long CheckThis;
-       
+
        if (WCC == NULL)
                return 0;
 
        CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
-       if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
-       {
-               LogTemplateError(Target, "Conditional", ERR_PARM2, TP,
-                                "Roomview [%ld] not valid\n", 
-                                CheckThis);
+       if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS)) {
+               LogTemplateError(Target, "Conditional", ERR_PARM2, TP, "Roomview [%ld] not valid\n", CheckThis);
                return 0;
        }
 
-       return exchangeable_views [WCC->CurRoom.defview][CheckThis] ;
+       return exchangeable_views[WCC->CurRoom.defview][CheckThis];
 }
 
-void tmplput_ROOM_VIEW(StrBuf *Target, WCTemplputParams *TP) 
-{
-       folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_VIEW(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) CTX(CTX_ROOMS);
        StrBufAppendPrintf(Target, "%d", Folder->view);
 }
-void tmplput_ROOM_DEFVIEW(StrBuf *Target, WCTemplputParams *TP) 
-{
-       folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_DEFVIEW(StrBuf * Target, WCTemplputParams * TP) {
+       folder *Folder = (folder *) CTX(CTX_ROOMS);
        StrBufAppendPrintf(Target, "%d", Folder->defview);
 }
 
 
-void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP) 
-{
+void tmplput_CurrentRoomDefView(StrBuf * Target, WCTemplputParams * TP) {
        wcsession *WCC = WC;
 
        StrBufAppendPrintf(Target, "%d", WCC->CurRoom.defview);
 }
 
-void 
-InitModule_ROOMVIEWS
-(void)
-{
+void InitModule_ROOMVIEWS(void) {
        /* we duplicate this, just to be shure its already done. */
        RegisterCTX(CTX_ROOMS);
        RegisterCTX(CTX_FLOORS);
index 88af2024f5c8d6dcc6d4324c2f6af25b0ec01c22..709266de768e3951fdd67342cf18e3d25a7e1dac 100644 (file)
@@ -24,7 +24,7 @@ void SetInlinMimeRenderers(void) {
 }
 
 
-void DeleteServInfo(ServInfo **FreeMe) {
+void DeleteServInfo(ServInfo ** FreeMe) {
        if (*FreeMe == NULL)
                return;
        FreeStrBuf(&(*FreeMe)->serv_nodename);
@@ -45,7 +45,7 @@ void DeleteServInfo(ServInfo **FreeMe) {
  * browser_host                the citadel we want to connect to
  * user_agent          which browser uses our client?
  */
-ServInfo *get_serv_info(StrBuf *browser_host, StrBuf *user_agent) {
+ServInfo *get_serv_info(StrBuf * browser_host, StrBuf * user_agent) {
        ServInfo *info;
        StrBuf *Buf;
        int a;
@@ -54,17 +54,11 @@ ServInfo *get_serv_info(StrBuf *browser_host, StrBuf *user_agent) {
        Buf = NewStrBuf();
 
        /* Tell the server what kind of client is connecting */
-       serv_printf("IDEN %d|%d|%d|%s|%s",
-                   DEVELOPER_ID,
-                   CLIENT_ID,
-                   CLIENT_VERSION,
-                   ChrPtr(user_agent),
-                   ChrPtr(browser_host)
-       );
+       serv_printf("IDEN %d|%d|%d|%s|%s", DEVELOPER_ID, CLIENT_ID, CLIENT_VERSION, ChrPtr(user_agent), ChrPtr(browser_host)
+           );
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) != 2) {
-               syslog(LOG_WARNING, "get_serv_info(IDEN): unexpected answer [%s]\n",
-                       ChrPtr(Buf));
+               syslog(LOG_WARNING, "get_serv_info(IDEN): unexpected answer [%s]\n", ChrPtr(Buf));
                FreeStrBuf(&Buf);
                return NULL;
        }
@@ -77,8 +71,7 @@ ServInfo *get_serv_info(StrBuf *browser_host, StrBuf *user_agent) {
        serv_puts("ICAL sgi|1");
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) != 2) {
-               syslog(LOG_WARNING, "get_serv_info(ICAL sgi|1): unexpected answer [%s]\n",
-                       ChrPtr(Buf));
+               syslog(LOG_WARNING, "get_serv_info(ICAL sgi|1): unexpected answer [%s]\n", ChrPtr(Buf));
                FreeStrBuf(&Buf);
                return NULL;
        }
@@ -87,20 +80,15 @@ ServInfo *get_serv_info(StrBuf *browser_host, StrBuf *user_agent) {
        serv_puts("INFO");
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) != 1) {
-               syslog(LOG_WARNING, "get_serv_info(INFO sgi|1): unexpected answer [%s]\n",
-                       ChrPtr(Buf));
+               syslog(LOG_WARNING, "get_serv_info(INFO sgi|1): unexpected answer [%s]\n", ChrPtr(Buf));
                FreeStrBuf(&Buf);
                return NULL;
        }
 
-       info = (ServInfo*)malloc(sizeof(ServInfo));
+       info = (ServInfo *) malloc(sizeof(ServInfo));
        memset(info, 0, sizeof(ServInfo));
        a = 0;
-       while (rc = StrBuf_ServGetln(Buf),
-              (rc >= 0) &&
-              ((rc != 3) || 
-               strcmp(ChrPtr(Buf), "000")))
-       {
+       while (rc = StrBuf_ServGetln(Buf), (rc >= 0) && ((rc != 3) || strcmp(ChrPtr(Buf), "000"))) {
                switch (a) {
                case 0:
                        info->serv_pid = StrToi(Buf);
@@ -158,7 +146,7 @@ ServInfo *get_serv_info(StrBuf *browser_host, StrBuf *user_agent) {
        return info;
 }
 
-int GetConnected (void) {
+int GetConnected(void) {
        StrBuf *Buf;
 
        if (WC->ReadBuf == NULL) {
@@ -170,7 +158,7 @@ int GetConnected (void) {
                snprintf(serv_sock_name, sizeof serv_sock_name, "%s/citadel.socket", ctdl_dir);
        }
        WC->serv_sock = connect_to_citadel(serv_sock_name);
-       
+
        if (WC->serv_sock < 0) {
                WC->connected = 0;
                FreeStrBuf(&WC->ReadBuf);
@@ -190,13 +178,12 @@ int GetConnected (void) {
                        if (Status == 551) {
                                hprintf("HTTP/1.1 503 Service Unavailable\r\n");
                                hprintf("Content-type: text/plain; charset=utf-8\r\n");
-                               wc_printf(_("This server is already serving its maximum number of users and cannot accept any additional logins at this time.  Please try again later or contact your system administrator."));
+                               wc_printf(_
+                                         ("This server is already serving its maximum number of users and cannot accept any additional logins at this time.  Please try again later or contact your system administrator."));
                        }
                        else {
-                               wc_printf("%ld %s\n",
-                                       Status,
-                                       _("Received unexpected answer from Citadel server; bailing out.")
-                               );
+                               wc_printf("%ld %s\n", Status, _("Received unexpected answer from Citadel server; bailing out.")
+                                   );
                                hprintf("HTTP/1.1 502 Bad Gateway\r\n");
                                hprintf("Content-type: text/plain; charset=utf-8\r\n");
                        }
@@ -211,18 +198,17 @@ int GetConnected (void) {
                 * unless we are following X-Forwarded-For: headers
                 * and such a header has already turned up something.
                 */
-               if ( (!follow_xff) || (StrLength(WC->Hdr->HR.browser_host) == 0) ) {
+               if ((!follow_xff) || (StrLength(WC->Hdr->HR.browser_host) == 0)) {
                        if (WC->Hdr->HR.browser_host == NULL) {
                                WC->Hdr->HR.browser_host = NewStrBuf();
-                               Put(WC->Hdr->HTTPHeaders, HKEY("FreeMeWithTheOtherHeaders"), 
-                                   WC->Hdr->HR.browser_host, HFreeStrBuf);
+                               Put(WC->Hdr->HTTPHeaders, HKEY("FreeMeWithTheOtherHeaders"), WC->Hdr->HR.browser_host, HFreeStrBuf);
                        }
                        locate_host(WC->Hdr->HR.browser_host, WC->Hdr->http_sock);
                }
                if (WC->serv_info == NULL) {
                        WC->serv_info = get_serv_info(WC->Hdr->HR.browser_host, WC->Hdr->HR.user_agent);
                }
-               if (WC->serv_info == NULL){
+               if (WC->serv_info == NULL) {
                        begin_burst();
                        wc_printf(_("Received unexpected answer from Citadel server; bailing out."));
                        hprintf("HTTP/1.1 502 Bad Gateway\r\n");
@@ -234,15 +220,10 @@ int GetConnected (void) {
                if (WC->serv_info->serv_rev_level < MINIMUM_CIT_VERSION) {
                        begin_burst();
                        wc_printf(_("You are connected to a Citadel "
-                                 "server running Citadel %d.%02d. \n"
-                                 "In order to run this version of WebCit "
-                                 "you must also have Citadel %d.%02d or"
-                                 " newer.\n\n\n"),
-                               WC->serv_info->serv_rev_level,
-                               0,
-                               MINIMUM_CIT_VERSION,
-                               0
-                               );
+                                   "server running Citadel %d.%02d. \n"
+                                   "In order to run this version of WebCit "
+                                   "you must also have Citadel %d.%02d or"
+                                   " newer.\n\n\n"), WC->serv_info->serv_rev_level, 0, MINIMUM_CIT_VERSION, 0);
                        hprintf("HTTP/1.1 200 OK\r\n");
                        hprintf("Content-type: text/plain; charset=utf-8\r\n");
                        end_burst();
@@ -255,7 +236,7 @@ int GetConnected (void) {
 }
 
 
-void FmOut(StrBuf *Target, const char *align, const StrBuf *Source) {
+void FmOut(StrBuf * Target, const char *align, const StrBuf * Source) {
        const char *ptr, *pte;
        const char *BufPtr = NULL;
        StrBuf *Line = NewStrBufPlain(NULL, SIZ);
@@ -269,9 +250,8 @@ void FmOut(StrBuf *Target, const char *align, const StrBuf *Source) {
 
        StrBufAppendPrintf(Target, "<div class=\"fmout-%s\">\n", align);
 
-       if (StrLength(Source) > 0) 
-               do 
-               {
+       if (StrLength(Source) > 0)
+               do {
                        StrBufSipLine(Line, Source, &BufPtr);
                        bq = 0;
                        i = 0;
@@ -283,27 +263,26 @@ void FmOut(StrBuf *Target, const char *align, const StrBuf *Source) {
                                StrBufAppendBufPlain(Target, HKEY("<br>"), 0);
                        }
                        intext = 1;
-                       if (isspace(*ptr)) while ((ptr < pte) &&
-                                                 ((*ptr == '>') ||
-                                                  isspace(*ptr)))
-                                          {
-                                                  if (*ptr == '>')
-                                                          bq++;
-                                                  ptr ++;
-                                                  i++;
-                                          }
+                       if (isspace(*ptr))
+                               while ((ptr < pte) && ((*ptr == '>') || isspace(*ptr))) {
+                                       if (*ptr == '>')
+                                               bq++;
+                                       ptr++;
+                                       i++;
+                               }
 
                        /*
                         * Quoted text should be displayed in italics and in a
                         * different colour.  This code understands Citadel-style
                         * " >" quotes and will convert to <BLOCKQUOTE> tags.
                         */
-                       if (i > 0) StrBufCutLeft(Line, i);
-               
+                       if (i > 0)
+                               StrBufCutLeft(Line, i);
+
 
-                       for (i = bn; i < bq; i++)                               
+                       for (i = bn; i < bq; i++)
                                StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
-                       for (i = bq; i < bn; i++)                               
+                       for (i = bq; i < bn; i++)
                                StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
                        bn = bq;
 
@@ -317,8 +296,7 @@ void FmOut(StrBuf *Target, const char *align, const StrBuf *Source) {
 
                        StrBufAppendBufPlain(Target, HKEY("\n"), 0);
                }
-               while ((BufPtr != StrBufNOTNULL) &&
-                      (BufPtr != NULL));
+               while ((BufPtr != StrBufNOTNULL) && (BufPtr != NULL));
 
        for (i = 0; i < bn; i++) {
                StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
@@ -348,14 +326,16 @@ void text_to_server(char *ptr) {
                }
                else if (ch == 10) {
                        len = strlen(buf);
-                       while ( (isspace(buf[len - 1]))
-                               && (buf[0] !=  '\0') 
-                               && (buf[1] !=  '\0') )
+                       while ((isspace(buf[len - 1]))
+                              && (buf[0] != '\0')
+                              && (buf[1] != '\0'))
                                buf[--len] = 0;
                        serv_puts(buf);
                        buf[0] = 0;
-                       if (ptr[pos] != 0) strcat(buf, " ");
-               } else {
+                       if (ptr[pos] != 0)
+                               strcat(buf, " ");
+               }
+               else {
                        a = strlen(buf);
                        buf[a + 1] = 0;
                        buf[a] = ch;
@@ -377,7 +357,7 @@ void text_to_server(char *ptr) {
 /*
  * Transmit message text (in memory) to the server, converting to Quoted-Printable encoding as we go.
  */
-void text_to_server_qp(const StrBuf *SendMeEncoded) {
+void text_to_server_qp(const StrBuf * SendMeEncoded) {
        StrBuf *ServBuf;
 
        ServBuf = StrBufRFC2047encodeMessage(SendMeEncoded);
@@ -413,22 +393,20 @@ void server_to_text() {
  * usual 000 terminator is found.  Caller is responsible for freeing
  * the returned pointer.
  */
-int read_server_text(StrBuf *Buf, long *nLines) {
+int read_server_text(StrBuf * Buf, long *nLines) {
        StrBuf *ReadBuf;
        long nRead;
        long nTotal = 0;
        long nlines;
-       
+
        nlines = 0;
        ReadBuf = NewStrBuf();
-       while ((WC->serv_sock!=-1) &&
-              (nRead = StrBuf_ServGetln(ReadBuf), (nRead >= 0) &&
-               ((nRead != 3)||(strcmp(ChrPtr(ReadBuf), "000") != 0))))
-       {
+       while ((WC->serv_sock != -1) &&
+              (nRead = StrBuf_ServGetln(ReadBuf), (nRead >= 0) && ((nRead != 3) || (strcmp(ChrPtr(ReadBuf), "000") != 0)))) {
                StrBufAppendBuf(Buf, ReadBuf, 0);
                StrBufAppendBufPlain(Buf, HKEY("\n"), 0);
                nTotal += nRead;
-               nlines ++;
+               nlines++;
        }
        FreeStrBuf(&ReadBuf);
        *nLines = nlines;
@@ -436,14 +414,12 @@ int read_server_text(StrBuf *Buf, long *nLines) {
 }
 
 
-int GetServerStatusMsg(StrBuf *Line, long* FullState, int PutImportantMessage, int MajorOK) {
+int GetServerStatusMsg(StrBuf * Line, long *FullState, int PutImportantMessage, int MajorOK) {
        int rc;
        if (FullState != NULL)
                *FullState = StrTol(Line);
        rc = ChrPtr(Line)[0] - 48;
-       if ((!PutImportantMessage) || 
-           (MajorOK == rc)||
-           (StrLength(Line) <= 4))
+       if ((!PutImportantMessage) || (MajorOK == rc) || (StrLength(Line) <= 4))
                return rc;
 
        AppendImportantMessage(ChrPtr(Line) + 4, StrLength(Line) - 4);
@@ -451,81 +427,82 @@ int GetServerStatusMsg(StrBuf *Line, long* FullState, int PutImportantMessage, i
 }
 
 
-void tmplput_serv_ip(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_serv_ip(StrBuf * Target, WCTemplputParams * TP) {
        StrBufAppendPrintf(Target, "%d", WC->ctdl_pid);
 }
 
-void tmplput_serv_admin(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_serv_admin(StrBuf * Target, WCTemplputParams * TP) {
        if (WC->serv_info == NULL)
                return;
        StrBufAppendTemplate(Target, TP, WC->serv_info->serv_sysadm, 0);
 }
 
-void tmplput_serv_nodename(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_serv_nodename(StrBuf * Target, WCTemplputParams * TP) {
        if (WC->serv_info == NULL)
                return;
        StrBufAppendTemplate(Target, TP, WC->serv_info->serv_nodename, 0);
 }
 
-void tmplput_serv_humannode(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_serv_humannode(StrBuf * Target, WCTemplputParams * TP) {
        if (WC->serv_info == NULL)
                return;
        StrBufAppendTemplate(Target, TP, WC->serv_info->serv_humannode, 0);
 }
 
-void tmplput_serv_fqdn(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_serv_fqdn(StrBuf * Target, WCTemplputParams * TP) {
        if (WC->serv_info == NULL)
                return;
        StrBufAppendTemplate(Target, TP, WC->serv_info->serv_fqdn, 0);
 }
 
-void tmplput_serv_software(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_serv_software(StrBuf * Target, WCTemplputParams * TP) {
        if (WC->serv_info == NULL)
                return;
        StrBufAppendTemplate(Target, TP, WC->serv_info->serv_software, 0);
 }
 
-void tmplput_serv_rev_level(StrBuf *Target, WCTemplputParams *TP) {
-       if (WC->serv_info == NULL) return;
+void tmplput_serv_rev_level(StrBuf * Target, WCTemplputParams * TP) {
+       if (WC->serv_info == NULL)
+               return;
        StrBufAppendPrintf(Target, "%d", WC->serv_info->serv_rev_level);
 }
-int conditional_serv_newuser_disabled(StrBuf *Target, WCTemplputParams *TP) {
+int conditional_serv_newuser_disabled(StrBuf * Target, WCTemplputParams * TP) {
        if (WC->serv_info == NULL)
                return 0;
        return WC->serv_info->serv_newuser_disabled != 0;
 }
 
-int conditional_serv_supports_guest(StrBuf *Target, WCTemplputParams *TP) {
-        if (WC->serv_info == NULL)
+int conditional_serv_supports_guest(StrBuf * Target, WCTemplputParams * TP) {
+       if (WC->serv_info == NULL)
                return 0;
-        return WC->serv_info->serv_supports_guest != 0;
+       return WC->serv_info->serv_supports_guest != 0;
 }
 
-int conditional_serv_supports_openid(StrBuf *Target, WCTemplputParams *TP) {
+int conditional_serv_supports_openid(StrBuf * Target, WCTemplputParams * TP) {
        if (WC->serv_info == NULL)
                return 0;
        return WC->serv_info->serv_supports_openid != 0;
 }
 
-int conditional_serv_fulltext_enabled(StrBuf *Target, WCTemplputParams *TP) {
+int conditional_serv_fulltext_enabled(StrBuf * Target, WCTemplputParams * TP) {
        if (WC->serv_info == NULL)
                return 0;
        return WC->serv_info->serv_fulltext_enabled != 0;
 }
 
-int conditional_serv_ldap_enabled(StrBuf *Target, WCTemplputParams *TP) {
+int conditional_serv_ldap_enabled(StrBuf * Target, WCTemplputParams * TP) {
        if (WC->serv_info == NULL)
                return 0;
        return WC->serv_info->serv_supports_ldap != 0;
 }
 
-void tmplput_serv_bbs_city(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_serv_bbs_city(StrBuf * Target, WCTemplputParams * TP) {
        if (WC->serv_info == NULL)
                return;
        StrBufAppendTemplate(Target, TP, WC->serv_info->serv_bbs_city, 0);
 }
 
-void tmplput_mesg(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_mesg(StrBuf * Target, WCTemplputParams * TP) {
        int n = 0;
        int Done = 0;
        StrBuf *Line;
@@ -537,19 +514,17 @@ void tmplput_mesg(StrBuf *Target, WCTemplputParams *TP) {
 
        StrBuf_ServGetln(Line);
        if (GetServerStatus(Line, NULL) == 1) {
-               while (!Done &&  (StrBuf_ServGetln(Line)>=0)) {
-                       if ( (StrLength(Line)==3) && 
-                            !strcmp(ChrPtr(Line), "000")) 
+               while (!Done && (StrBuf_ServGetln(Line) >= 0)) {
+                       if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000"))
                                Done = 1;
-                       else
-                       {
+                       else {
                                if (n > 0)
                                        StrBufAppendBufPlain(Buf, "\n", 1, 0);
                                StrBufAppendBuf(Buf, Line, 0);
                        }
                        n++;
                }
-       
+
                FlushStrBuf(Line);
                FmOut(Line, "center", Buf);
                StrBufAppendTemplate(Target, TP, Line, 1);
@@ -558,7 +533,7 @@ void tmplput_mesg(StrBuf *Target, WCTemplputParams *TP) {
        FreeStrBuf(&Line);
 }
 
-void tmplput_site_prefix(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_site_prefix(StrBuf * Target, WCTemplputParams * TP) {
        if ((WC != NULL) && (WC->Hdr->HostHeader != NULL)) {
                StrBufAppendTemplate(Target, TP, WC->Hdr->HostHeader, 0);
        }
@@ -571,54 +546,44 @@ void RegisterEmbeddableMimeType(const char *MimeType, long MTLen, int Priority)
 }
 
 void CreateMimeStr(void) {
-       HashPos  *it;
+       HashPos *it;
        void *vMime;
        long len = 0;
        const char *Key;
 
        it = GetNewHashPos(EmbeddableMimes, 0);
-       while (GetNextHashPos(EmbeddableMimes, it, &len, &Key, &vMime) &&
-               (vMime != NULL)) {
+       while (GetNextHashPos(EmbeddableMimes, it, &len, &Key, &vMime) && (vMime != NULL)) {
                if (StrLength(EmbeddableMimeStrs) > 0)
                        StrBufAppendBufPlain(EmbeddableMimeStrs, HKEY("|"), 0);
-               else 
+               else
                        StrBufAppendBufPlain(EmbeddableMimeStrs, HKEY("MSGP "), 0);
-               StrBufAppendBuf(EmbeddableMimeStrs, (StrBuf*) vMime, 0);
+               StrBufAppendBuf(EmbeddableMimeStrs, (StrBuf *) vMime, 0);
        }
        DeleteHashPos(&it);
 }
 
-void
-ServerStartModule_SERV_FUNC
-(void)
-{
+void ServerStartModule_SERV_FUNC(void) {
        EmbeddableMimes = NewHash(1, Flathash);
        EmbeddableMimeStrs = NewStrBuf();
 }
 
 
-void
-ServerShutdownModule_SERV_FUNC
-(void)
-{
+void ServerShutdownModule_SERV_FUNC(void) {
        FreeStrBuf(&EmbeddableMimeStrs);
        DeleteHash(&EmbeddableMimes);
 }
 
-void 
-InitModule_SERVFUNC
-(void)
-{
+void InitModule_SERVFUNC(void) {
        RegisterConditional("COND:SERV:OPENID", 2, conditional_serv_supports_openid, CTX_NONE);
        RegisterConditional("COND:SERV:NEWU", 2, conditional_serv_newuser_disabled, CTX_NONE);
        RegisterConditional("COND:SERV:FULLTEXT_ENABLED", 2, conditional_serv_fulltext_enabled, CTX_NONE);
        RegisterConditional("COND:SERV:LDAP_ENABLED", 2, conditional_serv_ldap_enabled, CTX_NONE);
-        RegisterConditional("COND:SERV:SUPPORTS_GUEST", 2, conditional_serv_supports_guest, CTX_NONE);
+       RegisterConditional("COND:SERV:SUPPORTS_GUEST", 2, conditional_serv_supports_guest, CTX_NONE);
        RegisterNamespace("SERV:PID", 0, 0, tmplput_serv_ip, NULL, CTX_NONE);
        RegisterNamespace("SERV:NODENAME", 0, 1, tmplput_serv_nodename, NULL, CTX_NONE);
        RegisterNamespace("SERV:HUMANNODE", 0, 1, tmplput_serv_humannode, NULL, CTX_NONE);
        RegisterNamespace("SERV:FQDN", 0, 1, tmplput_serv_fqdn, NULL, CTX_NONE);
-       
+
        RegisterNamespace("SERV:SOFTWARE", 0, 1, tmplput_serv_software, NULL, CTX_NONE);
        RegisterNamespace("SERV:REV_LEVEL", 0, 0, tmplput_serv_rev_level, NULL, CTX_NONE);
        RegisterNamespace("SERV:BBS_CITY", 0, 1, tmplput_serv_bbs_city, NULL, CTX_NONE);
@@ -632,9 +597,6 @@ InitModule_SERVFUNC
 
 
 
-void 
-SessionDestroyModule_SERVFUNC
-(wcsession *sess)
-{
+void SessionDestroyModule_SERVFUNC(wcsession * sess) {
        DeleteServInfo(&sess->serv_info);
 }
index 2e3d615853b4f09c68964856ed41ba3b2c358b03..528009ef3f1ebb3f9899175d6aa427631308e28d 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2020 by the citadel.org team
  *
@@ -48,19 +49,20 @@ void parse_fields_from_rule_editor(void) {
        char rule[2048];
        char encoded_rule[4096];
        char my_addresses[4096];
-       
+
        /* Enumerate my email addresses in case they are needed for a vacation rule */
        my_addresses[0] = 0;
        serv_puts("GVEA");
        serv_getln(buf, sizeof buf);
-       if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-               if (!IsEmptyStr(my_addresses)) {
-                       strcat(my_addresses, ",\n");
+       if (buf[0] == '1')
+               while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+                       if (!IsEmptyStr(my_addresses)) {
+                               strcat(my_addresses, ",\n");
+                       }
+                       strcat(my_addresses, "\"");
+                       strcat(my_addresses, buf);
+                       strcat(my_addresses, "\"");
                }
-               strcat(my_addresses, "\"");
-               strcat(my_addresses, buf);
-               strcat(my_addresses, "\"");
-       }
 
        /* Now generate the script and write it to the Citadel server */
        serv_printf("PIBR");
@@ -69,51 +71,49 @@ void parse_fields_from_rule_editor(void) {
                return;
        }
 
-       for (i=0; i<MAX_RULES; ++i) {
-               
+       for (i = 0; i < MAX_RULES; ++i) {
+
                strcpy(rule, "");
 
                sprintf(fname, "active%d", i);
-               active = !strcasecmp(BSTR(fname), "on") ;
+               active = !strcasecmp(BSTR(fname), "on");
 
                if (active) {
 
                        sprintf(fname, "hfield%d", i);
                        safestrncpy(hfield, BSTR(fname), sizeof hfield);
-       
+
                        sprintf(fname, "compare%d", i);
                        safestrncpy(compare, BSTR(fname), sizeof compare);
-       
+
                        sprintf(fname, "htext%d", i);
                        safestrncpy(htext, BSTR(fname), sizeof htext);
-       
+
                        sprintf(fname, "sizecomp%d", i);
                        safestrncpy(sizecomp, BSTR(fname), sizeof sizecomp);
-       
+
                        sprintf(fname, "sizeval%d", i);
                        sizeval = IBSTR(fname);
-       
+
                        sprintf(fname, "action%d", i);
                        safestrncpy(action, BSTR(fname), sizeof action);
-       
+
                        sprintf(fname, "fileinto%d", i);
                        safestrncpy(fileinto, BSTR(fname), sizeof fileinto);
-       
+
                        sprintf(fname, "redirect%d", i);
                        safestrncpy(redirect, BSTR(fname), sizeof redirect);
-       
+
                        sprintf(fname, "automsg%d", i);
                        safestrncpy(automsg, BSTR(fname), sizeof automsg);
-       
+
                        sprintf(fname, "final%d", i);
                        safestrncpy(final, BSTR(fname), sizeof final);
-       
+
                        snprintf(rule, sizeof rule, "%d|%s|%s|%s|%s|%d|%s|%s|%s|%s|%s",
-                               active, hfield, compare, htext, sizecomp, sizeval, action, fileinto,
-                               redirect, automsg, final
-                       );
-       
-                       size_t len = CtdlEncodeBase64(encoded_rule, rule, strlen(rule)+1, BASE64_NO_LINEBREAKS);
+                                active, hfield, compare, htext, sizecomp, sizeval, action, fileinto, redirect, automsg, final);
+
+                       size_t len = CtdlEncodeBase64(encoded_rule, rule, strlen(rule) + 1, BASE64_NO_LINEBREAKS);
                        if (encoded_rule[len - 1] == '\n') {
                                encoded_rule[len - 1] = '\0';
                        }
@@ -171,43 +171,37 @@ typedef struct __SieveListing {
        StrBuf *Content;
 } SieveListing;
 
-int ConditionalSieveScriptIsActive(StrBuf *Target, WCTemplputParams *TP)
-{
-       SieveListing     *SieveList = (SieveListing *)CTX(CTX_SIEVELIST);
+int ConditionalSieveScriptIsActive(StrBuf * Target, WCTemplputParams * TP) {
+       SieveListing *SieveList = (SieveListing *) CTX(CTX_SIEVELIST);
        return SieveList->IsActive;
 }
-int ConditionalSieveScriptIsRulesScript(StrBuf *Target, WCTemplputParams *TP)
-{
-       SieveListing     *SieveList = (SieveListing *)CTX(CTX_SIEVELIST);
+int ConditionalSieveScriptIsRulesScript(StrBuf * Target, WCTemplputParams * TP) {
+       SieveListing *SieveList = (SieveListing *) CTX(CTX_SIEVELIST);
        return SieveList->IsActive;
 }
-void tmplput_SieveScriptName(StrBuf *Target, WCTemplputParams *TP) 
-{
-       SieveListing     *SieveList = (SieveListing *)CTX(CTX_SIEVELIST);
+void tmplput_SieveScriptName(StrBuf * Target, WCTemplputParams * TP) {
+       SieveListing *SieveList = (SieveListing *) CTX(CTX_SIEVELIST);
        StrBufAppendTemplate(Target, TP, SieveList->Name, 0);
 }
-void tmplput_SieveScriptContent(StrBuf *Target, WCTemplputParams *TP) 
-{
-       SieveListing     *SieveList = (SieveListing *)CTX(CTX_SIEVELIST);
+void tmplput_SieveScriptContent(StrBuf * Target, WCTemplputParams * TP) {
+       SieveListing *SieveList = (SieveListing *) CTX(CTX_SIEVELIST);
        StrBufAppendTemplate(Target, TP, SieveList->Content, 0);
 }
-void FreeSieveListing(void *vSieveListing)
-{
-       SieveListing *List = (SieveListing*) vSieveListing;
+void FreeSieveListing(void *vSieveListing) {
+       SieveListing *List = (SieveListing *) vSieveListing;
 
        FreeStrBuf(&List->Name);
        free(List);
 }
 
-HashList *GetSieveScriptListing(StrBuf *Target, WCTemplputParams *TP)
-{
-        wcsession *WCC = WC;
+HashList *GetSieveScriptListing(StrBuf * Target, WCTemplputParams * TP) {
+       wcsession *WCC = WC;
        StrBuf *Line;
        int num_scripts = 0;
        int rules_script_active = 0;
        int have_rules_script = 0;
        const char *pch;
-       HashPos  *it;
+       HashPos *it;
        int Done = 0;
        SieveListing *Ruleset;
 
@@ -218,31 +212,25 @@ HashList *GetSieveScriptListing(StrBuf *Target, WCTemplputParams *TP)
        serv_puts("MSIV listscripts");
        Line = NewStrBuf();
        StrBuf_ServGetln(Line);
-       if (GetServerStatus(Line, NULL) == 1) 
-       {
+       if (GetServerStatus(Line, NULL) == 1) {
                WCC->KnownSieveScripts = NewHash(1, Flathash);
 
-               while(!Done && (StrBuf_ServGetln(Line) >= 0) )
-                       if ( (StrLength(Line)==3) && 
-                            !strcmp(ChrPtr(Line), "000")) 
-                       {
+               while (!Done && (StrBuf_ServGetln(Line) >= 0))
+                       if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
                                Done = 1;
                        }
-                       else
-                       {
+                       else {
                                pch = NULL;
                                Ruleset = (SieveListing *) malloc(sizeof(SieveListing));
                                Ruleset->Name = NewStrBufPlain(NULL, StrLength(Line));
                                StrBufExtract_NextToken(Ruleset->Name, Line, &pch, '|');
-                               Ruleset->IsActive = StrBufExtractNext_int(Line, &pch, '|'); 
+                               Ruleset->IsActive = StrBufExtractNext_int(Line, &pch, '|');
                                Ruleset->Content = NULL;
 
-                               if (!strcasecmp(ChrPtr(Ruleset->Name), RULES_SCRIPT))
-                               {
+                               if (!strcasecmp(ChrPtr(Ruleset->Name), RULES_SCRIPT)) {
                                        Ruleset->IsRulesScript = 1;
                                        have_rules_script = 1;
-                                       if (Ruleset->IsActive)
-                                       {
+                                       if (Ruleset->IsActive) {
                                                rules_script_active = 1;
                                                PutBstr(HKEY("__SIEVE:RULESSCRIPT"), NewStrBufPlain(HKEY("1")));
                                        }
@@ -257,8 +245,7 @@ HashList *GetSieveScriptListing(StrBuf *Target, WCTemplputParams *TP)
                PutBstr(HKEY("__SIEVE:EXTERNAL_SCRIPT"), NewStrBufPlain(HKEY("1")));
        }
 
-       if (num_scripts > have_rules_script)
-       {
+       if (num_scripts > have_rules_script) {
                long rc = 0;
                long len;
                const char *Key;
@@ -270,29 +257,24 @@ HashList *GetSieveScriptListing(StrBuf *Target, WCTemplputParams *TP)
                PutBstr(HKEY("__SIEVE:HAVE_EXTERNAL_SCRIPT"), NewStrBufPlain(HKEY("1")));
 
                it = GetNewHashPos(WCC->KnownSieveScripts, 0);
-               while (GetNextHashPos(WCC->KnownSieveScripts, it, &len, &Key, &vRuleset) && 
-                      (vRuleset != NULL))
-               {
+               while (GetNextHashPos(WCC->KnownSieveScripts, it, &len, &Key, &vRuleset) && (vRuleset != NULL)) {
                        Ruleset = (SieveListing *) vRuleset;
                        serv_printf("MSIV getscript|%s", ChrPtr(Ruleset->Name));
                        StrBuf_ServGetln(Line);
-                       if (GetServerStatus(Line, NULL) == 1) 
-                       {
+                       if (GetServerStatus(Line, NULL) == 1) {
                                Ruleset->Content = NewStrBuf();
                                Done = 0;
-                               while(!Done && (rc = StrBuf_ServGetln(Line), rc >= 0) )
-                                       if ( (StrLength(Line)==3) && 
-                                            !strcmp(ChrPtr(Line), "000")) 
-                                       {
+                               while (!Done && (rc = StrBuf_ServGetln(Line), rc >= 0))
+                                       if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
                                                Done = 1;
                                        }
-                                       else
-                                       {
-                                               if (StrLength(Ruleset->Content)>0)
+                                       else {
+                                               if (StrLength(Ruleset->Content) > 0)
                                                        StrBufAppendBufPlain(Ruleset->Content, HKEY("\n"), 0);
                                                StrBufAppendBuf(Ruleset->Content, Line, 0);
                                        }
-                               if (rc < 0) break;
+                               if (rc < 0)
+                                       break;
                        }
                }
        }
@@ -301,22 +283,21 @@ HashList *GetSieveScriptListing(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-typedef enum __eSieveHfield 
-{
-       from,           
-       tocc,           
-       subject,        
-       replyto,        
-       sender, 
-       resentfrom,     
-       resentto,       
-       envfrom,        
-       envto,  
-       xmailer,        
-       xspamflag,      
-       xspamstatus,    
-       listid, 
-       size,           
+typedef enum __eSieveHfield {
+       from,
+       tocc,
+       subject,
+       replyto,
+       sender,
+       resentfrom,
+       resentto,
+       envfrom,
+       envto,
+       xmailer,
+       xspamflag,
+       xspamstatus,
+       listid,
+       size,
        all
 } eSieveHfield;
 
@@ -362,128 +343,89 @@ typedef struct __SieveRule {
        StrBuf *redirect;
        StrBuf *automsg;
        eSieveFinal final;
-}SieveRule;
+} SieveRule;
 
 
 
-int ConditionalSieveRule_hfield(StrBuf *Target, WCTemplputParams *TP)
-{
-       SieveRule     *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
-       
-        return GetTemplateTokenNumber(Target, 
-                                      TP, 
-                                      3, 
-                                      from)
-                ==
-                Rule->hfield;
+int ConditionalSieveRule_hfield(StrBuf * Target, WCTemplputParams * TP) {
+       SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
+
+       return GetTemplateTokenNumber(Target, TP, 3, from)
+           == Rule->hfield;
 }
-int ConditionalSieveRule_compare(StrBuf *Target, WCTemplputParams *TP)
-{
-       SieveRule     *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
-        return GetTemplateTokenNumber(Target, 
-                                      TP, 
-                                      3, 
-                                      contains)
-                ==
-               Rule->compare;
+int ConditionalSieveRule_compare(StrBuf * Target, WCTemplputParams * TP) {
+       SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
+       return GetTemplateTokenNumber(Target, TP, 3, contains)
+           == Rule->compare;
 }
-int ConditionalSieveRule_action(StrBuf *Target, WCTemplputParams *TP)
-{
-       SieveRule     *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
-        return GetTemplateTokenNumber(Target, 
-                                      TP, 
-                                      3, 
-                                      keep)
-                ==
-               Rule->Action; 
+int ConditionalSieveRule_action(StrBuf * Target, WCTemplputParams * TP) {
+       SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
+       return GetTemplateTokenNumber(Target, TP, 3, keep)
+           == Rule->Action;
 }
-int ConditionalSieveRule_sizecomp(StrBuf *Target, WCTemplputParams *TP)
-{
-       SieveRule     *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
-        return GetTemplateTokenNumber(Target, 
-                                      TP, 
-                                      3, 
-                                      larger)
-                ==
-               Rule->sizecomp;
+int ConditionalSieveRule_sizecomp(StrBuf * Target, WCTemplputParams * TP) {
+       SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
+       return GetTemplateTokenNumber(Target, TP, 3, larger)
+           == Rule->sizecomp;
 }
-int ConditionalSieveRule_final(StrBuf *Target, WCTemplputParams *TP)
-{
-       SieveRule     *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
-        return GetTemplateTokenNumber(Target, 
-                                      TP, 
-                                      3, 
-                                      econtinue)
-                ==
-               Rule->final;
+int ConditionalSieveRule_final(StrBuf * Target, WCTemplputParams * TP) {
+       SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
+       return GetTemplateTokenNumber(Target, TP, 3, econtinue)
+           == Rule->final;
 }
-int ConditionalSieveRule_ThisRoom(StrBuf *Target, WCTemplputParams *TP)
-{
-       SieveRule     *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
-        return GetTemplateTokenNumber(Target, 
-                                      TP, 
-                                      3, 
-                                      econtinue)
-                ==
-               Rule->final;
+int ConditionalSieveRule_ThisRoom(StrBuf * Target, WCTemplputParams * TP) {
+       SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
+       return GetTemplateTokenNumber(Target, TP, 3, econtinue)
+           == Rule->final;
 }
-int ConditionalSieveRule_Active(StrBuf *Target, WCTemplputParams *TP)
-{
-       SieveRule     *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
-        return Rule->active;
+int ConditionalSieveRule_Active(StrBuf * Target, WCTemplputParams * TP) {
+       SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
+       return Rule->active;
 }
-void tmplput_SieveRule_htext(StrBuf *Target, WCTemplputParams *TP) 
-{
-       SieveRule     *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
+void tmplput_SieveRule_htext(StrBuf * Target, WCTemplputParams * TP) {
+       SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
        StrBufAppendTemplate(Target, TP, Rule->htext, 0);
 }
-void tmplput_SieveRule_fileinto(StrBuf *Target, WCTemplputParams *TP) 
-{
-       SieveRule     *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
+void tmplput_SieveRule_fileinto(StrBuf * Target, WCTemplputParams * TP) {
+       SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
        StrBufAppendTemplate(Target, TP, Rule->fileinto, 0);
 }
-void tmplput_SieveRule_redirect(StrBuf *Target, WCTemplputParams *TP) 
-{
-       SieveRule     *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
+void tmplput_SieveRule_redirect(StrBuf * Target, WCTemplputParams * TP) {
+       SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
        StrBufAppendTemplate(Target, TP, Rule->redirect, 0);
 }
-void tmplput_SieveRule_automsg(StrBuf *Target, WCTemplputParams *TP) 
-{
-       SieveRule     *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
+void tmplput_SieveRule_automsg(StrBuf * Target, WCTemplputParams * TP) {
+       SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
        StrBufAppendTemplate(Target, TP, Rule->automsg, 0);
 }
-void tmplput_SieveRule_sizeval(StrBuf *Target, WCTemplputParams *TP) 
-{
-       SieveRule     *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
+void tmplput_SieveRule_sizeval(StrBuf * Target, WCTemplputParams * TP) {
+       SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
        StrBufAppendPrintf(Target, "%d", Rule->sizeval);
 }
 
-void tmplput_SieveRule_lookup_FileIntoRoom(StrBuf *Target, WCTemplputParams *TP) 
-{
+void tmplput_SieveRule_lookup_FileIntoRoom(StrBuf * Target, WCTemplputParams * TP) {
        void *vRoom;
-       SieveRule     *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
-        wcsession *WCC = WC;
+       SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
+       wcsession *WCC = WC;
        HashList *Rooms = GetRoomListHashLKRA(Target, TP);
 
        GetHash(Rooms, SKEY(Rule->fileinto), &vRoom);
-       WCC->ThisRoom = (folder*) vRoom;
+       WCC->ThisRoom = (folder *) vRoom;
 }
 
-void FreeSieveRule(void *vRule)
-{
-       SieveRule *Rule = (SieveRule*) vRule;
+void FreeSieveRule(void *vRule) {
+       SieveRule *Rule = (SieveRule *) vRule;
 
        FreeStrBuf(&Rule->htext);
        FreeStrBuf(&Rule->fileinto);
        FreeStrBuf(&Rule->redirect);
        FreeStrBuf(&Rule->automsg);
-       
+
        free(Rule);
 }
 
 #define WC_RULE_HEADER "rule|"
-HashList *GetSieveRules(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *GetSieveRules(StrBuf * Target, WCTemplputParams * TP) {
        StrBuf *Line = NULL;
        StrBuf *EncodedRule = NULL;
        int n = 0;
@@ -497,38 +439,34 @@ HashList *GetSieveRules(StrBuf *Target, WCTemplputParams *TP)
        Line = NewStrBuf();
        EncodedRule = NewStrBuf();
        StrBuf_ServGetln(Line);
-       if (GetServerStatus(Line, NULL) == 1) 
-       {
-               while(!Done && (StrBuf_ServGetln(Line) >= 0) )
-                       if ( (StrLength(Line)==3) && 
-                            !strcmp(ChrPtr(Line), "000")) 
-                       {
+       if (GetServerStatus(Line, NULL) == 1) {
+               while (!Done && (StrBuf_ServGetln(Line) >= 0))
+                       if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
                                Done = 1;
                        }
-                       else
-                       {
+                       else {
                                pch = NULL;
                                /* We just care for our encoded header and skip everything else */
-                               if ((StrLength(Line) > sizeof(WC_RULE_HEADER) - 1) && (!strncasecmp(ChrPtr(Line), HKEY(WC_RULE_HEADER))))
-                               {
+                               if ((StrLength(Line) > sizeof(WC_RULE_HEADER) - 1)
+                                   && (!strncasecmp(ChrPtr(Line), HKEY(WC_RULE_HEADER)))) {
                                        StrBufSkip_NTokenS(Line, &pch, '|', 1);
-                                       n = StrBufExtractNext_int(Line, &pch, '|'); 
+                                       n = StrBufExtractNext_int(Line, &pch, '|');
                                        StrBufExtract_NextToken(EncodedRule, Line, &pch, '|');
                                        StrBufDecodeBase64(EncodedRule);
 
-                                       Rule = (SieveRule*) malloc(sizeof(SieveRule));
+                                       Rule = (SieveRule *) malloc(sizeof(SieveRule));
 
-                                       Rule->htext = NewStrBufPlain (NULL, StrLength(EncodedRule));
+                                       Rule->htext = NewStrBufPlain(NULL, StrLength(EncodedRule));
 
-                                       Rule->fileinto = NewStrBufPlain (NULL, StrLength(EncodedRule));
-                                       Rule->redirect = NewStrBufPlain (NULL, StrLength(EncodedRule));
-                                       Rule->automsg = NewStrBufPlain (NULL, StrLength(EncodedRule));
+                                       Rule->fileinto = NewStrBufPlain(NULL, StrLength(EncodedRule));
+                                       Rule->redirect = NewStrBufPlain(NULL, StrLength(EncodedRule));
+                                       Rule->automsg = NewStrBufPlain(NULL, StrLength(EncodedRule));
 
                                        /* Grab our existing values to populate */
                                        pch = NULL;
                                        Rule->active = StrBufExtractNext_int(EncodedRule, &pch, '|');
                                        StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
-                                       
+
                                        Rule->hfield = (eSieveHfield) GetTokenDefine(SKEY(Line), tocc);
                                        StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
                                        Rule->compare = (eSieveCompare) GetTokenDefine(SKEY(Line), contains);
@@ -550,10 +488,10 @@ HashList *GetSieveRules(StrBuf *Target, WCTemplputParams *TP)
        }
 
        while (n < MAX_RULES) {
-               Rule = (SieveRule*) malloc(sizeof(SieveRule));
+               Rule = (SieveRule *) malloc(sizeof(SieveRule));
                memset(Rule, 0, sizeof(SieveRule));
                Put(SieveRules, IKEY(n), Rule, FreeSieveRule);
-           
+
                n++;
        }
 
@@ -563,33 +501,27 @@ HashList *GetSieveRules(StrBuf *Target, WCTemplputParams *TP)
        return SieveRules;
 }
 
-void
-SessionDetachModule_SIEVE
-(wcsession *sess)
-{
+void SessionDetachModule_SIEVE(wcsession * sess) {
        DeleteHash(&sess->KnownSieveScripts);
 }
 
-void 
-InitModule_SIEVE
-(void)
-{
+void InitModule_SIEVE(void) {
        RegisterCTX(CTX_SIEVELIST);
        RegisterCTX(CTX_SIEVESCRIPT);
-       REGISTERTokenParamDefine(from);         
-       REGISTERTokenParamDefine(tocc);         
-       REGISTERTokenParamDefine(subject);      
-       REGISTERTokenParamDefine(replyto);      
-       REGISTERTokenParamDefine(sender);       
-       REGISTERTokenParamDefine(resentfrom);   
-       REGISTERTokenParamDefine(resentto);     
-       REGISTERTokenParamDefine(envfrom);      
-       REGISTERTokenParamDefine(envto);        
-       REGISTERTokenParamDefine(xmailer);      
-       REGISTERTokenParamDefine(xspamflag);    
-       REGISTERTokenParamDefine(xspamstatus);  
-       REGISTERTokenParamDefine(listid);       
-       REGISTERTokenParamDefine(size);         
+       REGISTERTokenParamDefine(from);
+       REGISTERTokenParamDefine(tocc);
+       REGISTERTokenParamDefine(subject);
+       REGISTERTokenParamDefine(replyto);
+       REGISTERTokenParamDefine(sender);
+       REGISTERTokenParamDefine(resentfrom);
+       REGISTERTokenParamDefine(resentto);
+       REGISTERTokenParamDefine(envfrom);
+       REGISTERTokenParamDefine(envto);
+       REGISTERTokenParamDefine(xmailer);
+       REGISTERTokenParamDefine(xspamflag);
+       REGISTERTokenParamDefine(xspamstatus);
+       REGISTERTokenParamDefine(listid);
+       REGISTERTokenParamDefine(size);
        REGISTERTokenParamDefine(all);
 
        REGISTERTokenParamDefine(contains);
@@ -620,7 +552,7 @@ InitModule_SIEVE
        RegisterNamespace("SIEVE:SCRIPT:NAME", 0, 1, tmplput_SieveScriptName, NULL, CTX_SIEVELIST);
        RegisterNamespace("SIEVE:SCRIPT:CONTENT", 0, 1, tmplput_SieveScriptContent, NULL, CTX_SIEVELIST);
 
+
        RegisterIterator("SIEVE:RULES", 0, NULL, GetSieveRules, NULL, DeleteHash, CTX_SIEVESCRIPT, CTX_NONE, IT_NOFLAG);
 
        RegisterConditional("COND:SIEVE:ACTIVE", 1, ConditionalSieveRule_Active, CTX_SIEVESCRIPT);
index b82b0d2ab4440618aef0df10f6fe829ad7e0819a..11dcb102d0923066dd147fc3a08dd8141f9d1c44 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Administrative screen for site-wide configuration
  *
 /*
  * Expiry policy for the autopurger
  */
-#define EXPIRE_NEXTLEVEL        0       /* Inherit expiration policy    */
-#define EXPIRE_MANUAL           1       /* Don't expire messages at all */
-#define EXPIRE_NUMMSGS          2       /* Keep only latest n messages  */
-#define EXPIRE_AGE              3       /* Expire messages after n days */
+#define EXPIRE_NEXTLEVEL        0      /* Inherit expiration policy    */
+#define EXPIRE_MANUAL           1      /* Don't expire messages at all */
+#define EXPIRE_NUMMSGS          2      /* Keep only latest n messages  */
+#define EXPIRE_AGE              3      /* Expire messages after n days */
 
 CtxType CTX_SRVLOG = CTX_NONE;
 
 HashList *ZoneHash = NULL;
 
-ConstStr ExpirePolicyString = {CStrOf(roompolicy)     };
+ConstStr ExpirePolicyString = { CStrOf(roompolicy) };
 
 ConstStr ExpirePolicyStrings[][2] = {
-       { { CStrOf(roompolicy)     } , { strof(roompolicy)     "_value", sizeof(strof(roompolicy)     "_value") - 1 } },
-       { { CStrOf(floorpolicy)    } , { strof(floorpolicy)    "_value", sizeof(strof(floorpolicy)    "_value") - 1 } },
-       { { CStrOf(sitepolicy)     } , { strof(sitepolicy)     "_value", sizeof(strof(sitepolicy)     "_value") - 1 } },
-       { { CStrOf(mailboxespolicy)} , { strof(mailboxespolicy)"_value", sizeof(strof(mailboxespolicy)"_value") - 1 } }
+       { { CStrOf(roompolicy)}, { strof(roompolicy) "_value", sizeof(strof(roompolicy) "_value") - 1}
+         },
+       { { CStrOf(floorpolicy)}, { strof(floorpolicy) "_value", sizeof(strof(floorpolicy) "_value") - 1}
+         },
+       { { CStrOf(sitepolicy)}, { strof(sitepolicy) "_value", sizeof(strof(sitepolicy) "_value") - 1}
+         },
+       { { CStrOf(mailboxespolicy)}, { strof(mailboxespolicy) "_value", sizeof(strof(mailboxespolicy) "_value") - 1}
+         }
 };
 
 
@@ -60,10 +65,9 @@ void SaveExpirePolicyFromHTTP(GPEXWhichPolicy which) {
        StrBuf *Buf;
        long State;
 
-       serv_printf("SPEX %s|%d|%d", 
-                           ExpirePolicyStrings[which][0].Key,
-                   ibcstr( ExpirePolicyStrings[which][1] ),
-                   ibcstr( ExpirePolicyStrings[which][1] )  );
+       serv_printf("SPEX %s|%d|%d",
+                   ExpirePolicyStrings[which][0].Key,
+                   ibcstr(ExpirePolicyStrings[which][1]), ibcstr(ExpirePolicyStrings[which][1]));
 
        Buf = NewStrBuf();
        StrBuf_ServGetln(Buf);
@@ -74,7 +78,7 @@ void SaveExpirePolicyFromHTTP(GPEXWhichPolicy which) {
 }
 
 
-int ConditionalExpire(StrBuf *Target, WCTemplputParams *TP) {
+int ConditionalExpire(StrBuf * Target, WCTemplputParams * TP) {
        GPEXWhichPolicy which;
        int CompareWith;
 
@@ -82,23 +86,23 @@ int ConditionalExpire(StrBuf *Target, WCTemplputParams *TP) {
        CompareWith = GetTemplateTokenNumber(Target, TP, 3, 0);
 
        LoadExpirePolicy(which);
-       
+
        return WC->Policy[which].expire_mode == CompareWith;
 }
 
 
-void tmplput_ExpireValue(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_ExpireValue(StrBuf * Target, WCTemplputParams * TP) {
        GPEXWhichPolicy which;
-               
+
        which = GetTemplateTokenNumber(Target, TP, 0, 0);
        LoadExpirePolicy(which);
        StrBufAppendPrintf(Target, "%d", WC->Policy[which].expire_value);
 }
 
 
-void tmplput_ExpireMode(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_ExpireMode(StrBuf * Target, WCTemplputParams * TP) {
        GPEXWhichPolicy which;
-               
+
        which = GetTemplateTokenNumber(Target, TP, 2, 0);
        LoadExpirePolicy(which);
        StrBufAppendPrintf(Target, "%d", WC->Policy[which].expire_mode);
@@ -111,16 +115,16 @@ void LoadZoneFiles(void) {
        long len;
        const char *this_zone;
        StrBuf *ZName;
-       
+
        ZoneHash = NewHash(1, NULL);
        ZName = NewStrBufPlain(HKEY("UTC"));
        Put(ZoneHash, HKEY("UTC"), ZName, HFreeStrBuf);
        zones = icaltimezone_get_builtin_timezones();
        for (z = 0; z < zones->num_elements; ++z) {
                /* syslog(LOG_DEBUG, "Location: %-40s tzid: %s\n",
-                       icaltimezone_get_location(icalarray_element_at(zones, z)),
-                       icaltimezone_get_tzid(icalarray_element_at(zones, z))
-               ); */
+                  icaltimezone_get_location(icalarray_element_at(zones, z)),
+                  icaltimezone_get_tzid(icalarray_element_at(zones, z))
+                  ); */
                this_zone = icaltimezone_get_location(icalarray_element_at(zones, z));
                len = strlen(this_zone);
                ZName = NewStrBufPlain(this_zone, len);
@@ -145,78 +149,78 @@ typedef struct _CfgMapping {
 #define CFG_INT 4
 
 CfgMapping ServerConfig[] = {
-       {CFG_STR, 0, 0, "", HKEY("c_nodename")},
-       {CFG_STR, 0, 0, "", HKEY("c_fqdn")},
-       {CFG_STR, 0, 0, "", HKEY("c_humannode")},
-       {CFG_STR, 0, 0, "", HKEY("c_phonenum")},
-       {CFG_YES, 0, 0, "", HKEY("c_creataide")},
-       {CFG_STR, 0, 0, "", HKEY("c_sleeping")},
-       {CFG_STR, 0, 0, "", HKEY("c_initax")},
-       {CFG_YES, 0, 0, "", HKEY("c_regiscall")},
-       {CFG_YES, 0, 0, "", HKEY("c_twitdetect")},
-       {CFG_STR, 0, 0, "", HKEY("c_twitroom")},
-       {CFG_STR, 0, 0, "", HKEY("c_moreprompt")},
-       {CFG_YES, 0, 0, "", HKEY("c_restrict")},
-       {CFG_STR, 0, 0, "", HKEY("c_bbs_city")},
-       {CFG_STR, 0, 0, "", HKEY("c_sysadm")},
-       {CFG_STR, 0, 0, "", HKEY("c_maxsessions")},
-       {CFG_STR, 0, 0, "", HKEY("reserved1")},
-       {CFG_STR, 0, 0, "", HKEY("c_userpurge")},
-       {CFG_STR, 0, 0, "", HKEY("c_roompurge")},
-       {CFG_STR, 0, 0, "", HKEY("c_logpages")},
-       {CFG_STR, 0, 0, "", HKEY("c_createax")},
-       {CFG_STR, 0, 0, "", HKEY("c_maxmsglen")},
-       {CFG_STR, 0, 0, "", HKEY("c_min_workers")},
-       {CFG_STR, 0, 0, "", HKEY("c_max_workers")},
-       {CFG_STR, 0, 0, "", HKEY("c_pop3_port")},
-       {CFG_STR, 0, 0, "", HKEY("c_smtp_port")},
-       {CFG_INT, CFG_SMTP_FROM_FILTERALL, CFG_SMTP_FROM_REJECT, "0", HKEY("c_rfc822_strict_from")},    
-       {CFG_YES, 0, 0, "", HKEY("c_aide_zap")},
-       {CFG_STR, 0, 0, "", HKEY("c_imap_port")},
-       {CFG_STR, 0, 0, "", HKEY("c_net_freq")},
-       {CFG_YES, 0, 0, "", HKEY("c_disable_newu")},
-       {CFG_STR, 0, 0, "", HKEY("reserved2")},
-       {CFG_STR, 0, 0, "", HKEY("c_purge_hour")},
-       {CFG_STR, 0, 0, "", HKEY("c_ldap_host")},
-       {CFG_STR, 0, 0, "", HKEY("c_ldap_port")},
-       {CFG_STR, 0, 0, "", HKEY("c_ldap_base_dn")},
-       {CFG_STR, 0, 0, "", HKEY("c_ldap_bind_dn")},
-       {CFG_STR, 0, 0, "", HKEY("c_ldap_bind_pw")},
-       {CFG_STR, 0, 0, "", HKEY("c_ip_addr")},
-       {CFG_STR, 0, 0, "", HKEY("c_msa_port")},
-       {CFG_STR, 0, 0, "", HKEY("c_imaps_port")},
-       {CFG_STR, 0, 0, "", HKEY("c_pop3s_port")},
-       {CFG_STR, 0, 0, "", HKEY("c_smtps_port")},
-       {CFG_YES, 0, 0, "", HKEY("c_enable_fulltext")},
-       {CFG_YES, 0, 0, "", HKEY("c_auto_cull")},
-       {CFG_YES, 0, 0, "", HKEY("reserved3")},
-       {CFG_YES, 0, 0, "", HKEY("c_allow_spoofing")},
-       {CFG_YES, 0, 0, "", HKEY("c_journal_email")},
-       {CFG_YES, 0, 0, "", HKEY("c_journal_pubmsgs")},
-       {CFG_STR, 0, 0, "", HKEY("c_journal_dest")},
-       {CFG_STR, 0, 0, "", HKEY("c_default_cal_zone")},
-       {CFG_STR, 0, 0, "", HKEY("c_pftcpdict_port")},
-       {CFG_STR, 0, 0, "", HKEY("c_mgesve_port")},
-       {CFG_STR, 0, 0, "", HKEY("c_auth_mode")},
-       {CFG_STR, 0, 0, "", HKEY("c_funambol_host")},
-       {CFG_STR, 0, 0, "", HKEY("c_funambol_port")},
-       {CFG_STR, 0, 0, "", HKEY("c_funambol_source")},
-       {CFG_STR, 0, 0, "", HKEY("c_funambol_auth")},
-       {CFG_YES, 0, 0, "", HKEY("c_rbl_at_greeting")},
-       {CFG_STR, 0, 0, "", HKEY("c_master_user")},
-       {CFG_STR, 0, 0, "", HKEY("c_master_pass")},
-       {CFG_STR, 0, 0, "", HKEY("c_pager_program")},
-       {CFG_YES, 0, 0, "", HKEY("c_imap_keep_from")},
-       {CFG_STR, 0, 0, "", HKEY("c_xmpp_c2s_port")},
-       {CFG_STR, 0, 0, "", HKEY("c_xmpp_s2s_port")},
-       {CFG_STR, 0, 0, "", HKEY("c_pop3_fetch")},
-       {CFG_STR, 0, 0, "", HKEY("c_pop3_fastest")},
-       {CFG_YES, 0, 0, "", HKEY("c_spam_flag_only")},
-       {CFG_YES, 0, 0, "", HKEY("c_guest_logins")},
-       {CFG_STR, 0, 0, "", HKEY("c_port_number")},
-       {CFG_STR, 0, 0, "", HKEY("c_ctdluid")},
-       {CFG_STR, 0, 0, "", HKEY("c_nntp_port")},
-       {CFG_STR, 0, 0, "", HKEY("c_nntps_port")}
+       { CFG_STR, 0, 0, "", HKEY("c_nodename") },
+       { CFG_STR, 0, 0, "", HKEY("c_fqdn") },
+       { CFG_STR, 0, 0, "", HKEY("c_humannode") },
+       { CFG_STR, 0, 0, "", HKEY("c_phonenum") },
+       { CFG_YES, 0, 0, "", HKEY("c_creataide") },
+       { CFG_STR, 0, 0, "", HKEY("c_sleeping") },
+       { CFG_STR, 0, 0, "", HKEY("c_initax") },
+       { CFG_YES, 0, 0, "", HKEY("c_regiscall") },
+       { CFG_YES, 0, 0, "", HKEY("c_twitdetect") },
+       { CFG_STR, 0, 0, "", HKEY("c_twitroom") },
+       { CFG_STR, 0, 0, "", HKEY("c_moreprompt") },
+       { CFG_YES, 0, 0, "", HKEY("c_restrict") },
+       { CFG_STR, 0, 0, "", HKEY("c_bbs_city") },
+       { CFG_STR, 0, 0, "", HKEY("c_sysadm") },
+       { CFG_STR, 0, 0, "", HKEY("c_maxsessions") },
+       { CFG_STR, 0, 0, "", HKEY("reserved1") },
+       { CFG_STR, 0, 0, "", HKEY("c_userpurge") },
+       { CFG_STR, 0, 0, "", HKEY("c_roompurge") },
+       { CFG_STR, 0, 0, "", HKEY("c_logpages") },
+       { CFG_STR, 0, 0, "", HKEY("c_createax") },
+       { CFG_STR, 0, 0, "", HKEY("c_maxmsglen") },
+       { CFG_STR, 0, 0, "", HKEY("c_min_workers") },
+       { CFG_STR, 0, 0, "", HKEY("c_max_workers") },
+       { CFG_STR, 0, 0, "", HKEY("c_pop3_port") },
+       { CFG_STR, 0, 0, "", HKEY("c_smtp_port") },
+       { CFG_INT, CFG_SMTP_FROM_FILTERALL, CFG_SMTP_FROM_REJECT, "0", HKEY("c_rfc822_strict_from") },
+       { CFG_YES, 0, 0, "", HKEY("c_aide_zap") },
+       { CFG_STR, 0, 0, "", HKEY("c_imap_port") },
+       { CFG_STR, 0, 0, "", HKEY("c_net_freq") },
+       { CFG_YES, 0, 0, "", HKEY("c_disable_newu") },
+       { CFG_STR, 0, 0, "", HKEY("reserved2") },
+       { CFG_STR, 0, 0, "", HKEY("c_purge_hour") },
+       { CFG_STR, 0, 0, "", HKEY("c_ldap_host") },
+       { CFG_STR, 0, 0, "", HKEY("c_ldap_port") },
+       { CFG_STR, 0, 0, "", HKEY("c_ldap_base_dn") },
+       { CFG_STR, 0, 0, "", HKEY("c_ldap_bind_dn") },
+       { CFG_STR, 0, 0, "", HKEY("c_ldap_bind_pw") },
+       { CFG_STR, 0, 0, "", HKEY("c_ip_addr") },
+       { CFG_STR, 0, 0, "", HKEY("c_msa_port") },
+       { CFG_STR, 0, 0, "", HKEY("c_imaps_port") },
+       { CFG_STR, 0, 0, "", HKEY("c_pop3s_port") },
+       { CFG_STR, 0, 0, "", HKEY("c_smtps_port") },
+       { CFG_YES, 0, 0, "", HKEY("c_enable_fulltext") },
+       { CFG_YES, 0, 0, "", HKEY("c_auto_cull") },
+       { CFG_YES, 0, 0, "", HKEY("reserved3") },
+       { CFG_YES, 0, 0, "", HKEY("c_allow_spoofing") },
+       { CFG_YES, 0, 0, "", HKEY("c_journal_email") },
+       { CFG_YES, 0, 0, "", HKEY("c_journal_pubmsgs") },
+       { CFG_STR, 0, 0, "", HKEY("c_journal_dest") },
+       { CFG_STR, 0, 0, "", HKEY("c_default_cal_zone") },
+       { CFG_STR, 0, 0, "", HKEY("c_pftcpdict_port") },
+       { CFG_STR, 0, 0, "", HKEY("c_mgesve_port") },
+       { CFG_STR, 0, 0, "", HKEY("c_auth_mode") },
+       { CFG_STR, 0, 0, "", HKEY("c_funambol_host") },
+       { CFG_STR, 0, 0, "", HKEY("c_funambol_port") },
+       { CFG_STR, 0, 0, "", HKEY("c_funambol_source") },
+       { CFG_STR, 0, 0, "", HKEY("c_funambol_auth") },
+       { CFG_YES, 0, 0, "", HKEY("c_rbl_at_greeting") },
+       { CFG_STR, 0, 0, "", HKEY("c_master_user") },
+       { CFG_STR, 0, 0, "", HKEY("c_master_pass") },
+       { CFG_STR, 0, 0, "", HKEY("c_pager_program") },
+       { CFG_YES, 0, 0, "", HKEY("c_imap_keep_from") },
+       { CFG_STR, 0, 0, "", HKEY("c_xmpp_c2s_port") },
+       { CFG_STR, 0, 0, "", HKEY("c_xmpp_s2s_port") },
+       { CFG_STR, 0, 0, "", HKEY("c_pop3_fetch") },
+       { CFG_STR, 0, 0, "", HKEY("c_pop3_fastest") },
+       { CFG_YES, 0, 0, "", HKEY("c_spam_flag_only") },
+       { CFG_YES, 0, 0, "", HKEY("c_guest_logins") },
+       { CFG_STR, 0, 0, "", HKEY("c_port_number") },
+       { CFG_STR, 0, 0, "", HKEY("c_ctdluid") },
+       { CFG_STR, 0, 0, "", HKEY("c_nntp_port") },
+       { CFG_STR, 0, 0, "", HKEY("c_nntps_port") }
 };
 
 
@@ -228,7 +232,7 @@ void load_siteconfig(void) {
        HashList *Cfg;
        long len;
        int i, j;
-       
+
        if (WC->ServCfg == NULL)
                WC->ServCfg = NewHash(1, NULL);
        Cfg = WC->ServCfg;
@@ -242,26 +246,19 @@ void load_siteconfig(void) {
                AppendImportantMessage(SKEY(Buf));
                FreeStrBuf(&Buf);
                return;
-               
+
        }
        j = i = 0;
-       while (len = StrBuf_ServGetln(Buf),
-              (len >= 0) && 
-              ((len != 3) || strcmp(ChrPtr(Buf), "000")))
-       {
-               if (i < (sizeof(ServerConfig) / sizeof(CfgMapping)))
-               {
-                       Put(Cfg,
-                           ServerConfig[i].Key, 
-                           ServerConfig[i].len, 
-                           Buf, 
-                           HFreeStrBuf);
+       while (len = StrBuf_ServGetln(Buf), (len >= 0) && ((len != 3) || strcmp(ChrPtr(Buf), "000"))) {
+               if (i < (sizeof(ServerConfig) / sizeof(CfgMapping))) {
+                       Put(Cfg, ServerConfig[i].Key, ServerConfig[i].len, Buf, HFreeStrBuf);
                        i++;
                        Buf = NewStrBuf();
                }
                else {
                        if (j == 0) {
-                               syslog(LOG_WARNING, "The server sent more configuration data than this version of webcit is capable of changing.  Unknown configuration values will remain unchanged.");
+                               syslog(LOG_WARNING,
+                                      "The server sent more configuration data than this version of webcit is capable of changing.  Unknown configuration values will remain unchanged.");
                        }
                        j++;
                }
@@ -297,34 +294,27 @@ void siteconfig(void) {
 
        FreeStrBuf(&Line);
 
-       for (i=0; i < (sizeof(ServerConfig) / sizeof(CfgMapping)); i ++)
-       {
+       for (i = 0; i < (sizeof(ServerConfig) / sizeof(CfgMapping)); i++) {
                switch (ServerConfig[i].type) {
                default:
                case CFG_STR:
                        serv_putbuf(SBstr(ServerConfig[i].Key, ServerConfig[i].len));
                        break;
                case CFG_YES:
-                       serv_puts(YesBstr(ServerConfig[i].Key, 
-                                         ServerConfig[i].len) ?
-                                 "1" : "0");
+                       serv_puts(YesBstr(ServerConfig[i].Key, ServerConfig[i].len) ? "1" : "0");
                        break;
                case CFG_NO:
-                       serv_puts(YesBstr(ServerConfig[i].Key, 
-                                         ServerConfig[i].len) ?
-                                 "0" : "1");
+                       serv_puts(YesBstr(ServerConfig[i].Key, ServerConfig[i].len) ? "0" : "1");
                        break;
                case CFG_INT:
-                       value = IBstr(ServerConfig[i].Key, 
-                                     ServerConfig[i].len);
-                       if ((value < ServerConfig[i].min) ||
-                           (value > ServerConfig[i].max))
+                       value = IBstr(ServerConfig[i].Key, ServerConfig[i].len);
+                       if ((value < ServerConfig[i].min) || (value > ServerConfig[i].max))
                                value = atol(ServerConfig[i].defval);
                        serv_printf("%d", value);
                        break;
                }
        }
-        serv_puts("000");
+       serv_puts("000");
 
        SaveExpirePolicyFromHTTP(sitepolicy);
        SaveExpirePolicyFromHTTP(mailboxespolicy);
@@ -339,7 +329,7 @@ void siteconfig(void) {
 
 
 // if WebCit Classic wasn't obsolete we would replace this with a "CONF GETVAL" type of thing
-void tmplput_servcfg(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_servcfg(StrBuf * Target, WCTemplputParams * TP) {
        void *vBuf;
        StrBuf *Buf;
 
@@ -347,13 +337,13 @@ void tmplput_servcfg(StrBuf *Target, WCTemplputParams *TP) {
                if (WC->ServCfg == NULL)
                        load_siteconfig();
                GetHash(WC->ServCfg, TKEY(0), &vBuf);
-               Buf = (StrBuf*) vBuf;
+               Buf = (StrBuf *) vBuf;
                StrBufAppendTemplate(Target, TP, Buf, 1);
        }
 }
 
 
-int ConditionalServCfg(StrBuf *Target, WCTemplputParams *TP) {
+int ConditionalServCfg(StrBuf * Target, WCTemplputParams * TP) {
        void *vBuf;
        StrBuf *Buf;
 
@@ -361,43 +351,45 @@ int ConditionalServCfg(StrBuf *Target, WCTemplputParams *TP) {
                if (WC->ServCfg == NULL)
                        load_siteconfig();
                GetHash(WC->ServCfg, TKEY(2), &vBuf);
-               if (vBuf == NULL) return 0;
-               Buf = (StrBuf*) vBuf;
+               if (vBuf == NULL)
+                       return 0;
+               Buf = (StrBuf *) vBuf;
                if (TP->Tokens->nParameters == 3) {
                        return 1;
                }
                else if (IS_NUMBER(TP->Tokens->Params[3]->Type))
-                       return (StrTol(Buf) == GetTemplateTokenNumber (Target, TP, 3, 0));
-               else
-               {
+                       return (StrTol(Buf) == GetTemplateTokenNumber(Target, TP, 3, 0));
+               else {
                        const char *pch;
                        long len;
-                       
+
                        GetTemplateTokenString(Target, TP, 3, &pch, &len);
-               
-                       return ((len == StrLength(Buf)) &&
-                               (strcmp(pch, ChrPtr(Buf)) == 0));
+
+                       return ((len == StrLength(Buf)) && (strcmp(pch, ChrPtr(Buf)) == 0));
                }
 
        }
-       else return 0;
+       else
+               return 0;
 }
 
-int ConditionalServCfgCTXStrBuf(StrBuf *Target, WCTemplputParams *TP) {
+int ConditionalServCfgCTXStrBuf(StrBuf * Target, WCTemplputParams * TP) {
        void *vBuf;
        StrBuf *Buf;
-       StrBuf *ZoneToCheck = (StrBuf*) CTX(CTX_STRBUF);
+       StrBuf *ZoneToCheck = (StrBuf *) CTX(CTX_STRBUF);
 
        if ((WC->is_aide) || (ZoneToCheck == NULL)) {
                if (WC->ServCfg == NULL)
                        load_siteconfig();
                GetHash(WC->ServCfg, TKEY(2), &vBuf);
-               if (vBuf == NULL) return 0;
-               Buf = (StrBuf*) vBuf;
+               if (vBuf == NULL)
+                       return 0;
+               Buf = (StrBuf *) vBuf;
 
                return strcmp(ChrPtr(Buf), ChrPtr(ZoneToCheck)) == 0;
        }
-       else return 0;
+       else
+               return 0;
 }
 
 /*----------------------------------------------------------------------------*
@@ -406,33 +398,29 @@ int ConditionalServCfgCTXStrBuf(StrBuf *Target, WCTemplputParams *TP) {
 typedef struct __LogStatusStruct {
        int Enable;
        StrBuf *Name;
-}LogStatusStruct;
+} LogStatusStruct;
 
-void DeleteLogStatusStruct(void *v)
-{
-       LogStatusStruct *Stat = (LogStatusStruct*)v;
+void DeleteLogStatusStruct(void *v) {
+       LogStatusStruct *Stat = (LogStatusStruct *) v;
 
        FreeStrBuf(&Stat->Name);
        free(Stat);
 }
 
-void tmplput_servcfg_LogName(StrBuf *Target, WCTemplputParams *TP)
-{
-        LogStatusStruct *Stat = (LogStatusStruct*) CTX(CTX_SRVLOG);
+void tmplput_servcfg_LogName(StrBuf * Target, WCTemplputParams * TP) {
+       LogStatusStruct *Stat = (LogStatusStruct *) CTX(CTX_SRVLOG);
        StrBufAppendTemplate(Target, TP, Stat->Name, 1);
 }
 
 
 
-int ConditionalServCfgThisLogEnabled(StrBuf *Target, WCTemplputParams *TP)
-{
-        LogStatusStruct *Stat = (LogStatusStruct*) CTX(CTX_SRVLOG);
+int ConditionalServCfgThisLogEnabled(StrBuf * Target, WCTemplputParams * TP) {
+       LogStatusStruct *Stat = (LogStatusStruct *) CTX(CTX_SRVLOG);
        return Stat->Enable;
 }
 
-HashList *iterate_GetSrvLogEnable(StrBuf *Target, WCTemplputParams *TP)
-{
-        HashList *Hash = NULL;
+HashList *iterate_GetSrvLogEnable(StrBuf * Target, WCTemplputParams * TP) {
+       HashList *Hash = NULL;
        StrBuf *Buf;
        LogStatusStruct *Stat;
        const char *Pos;
@@ -440,39 +428,33 @@ HashList *iterate_GetSrvLogEnable(StrBuf *Target, WCTemplputParams *TP)
        long len;
        int num_logs = 0;
 
-        serv_puts("LOGP");
-        Buf = NewStrBuf();
-        StrBuf_ServGetln(Buf);
-        if (GetServerStatus(Buf, NULL) == 1) {
-                Hash = NewHash(1, Flathash);
-                while (!Done) {
-                        len = StrBuf_ServGetln(Buf);
-                        if ((len <0) || 
-                            ((len == 3) &&
-                             !strcmp(ChrPtr(Buf), "000")))
-                        {
-                                Done = 1;
-                                break;
-                        }
-                       Stat = (LogStatusStruct*) malloc (sizeof(LogStatusStruct));
+       serv_puts("LOGP");
+       Buf = NewStrBuf();
+       StrBuf_ServGetln(Buf);
+       if (GetServerStatus(Buf, NULL) == 1) {
+               Hash = NewHash(1, Flathash);
+               while (!Done) {
+                       len = StrBuf_ServGetln(Buf);
+                       if ((len < 0) || ((len == 3) && !strcmp(ChrPtr(Buf), "000"))) {
+                               Done = 1;
+                               break;
+                       }
+                       Stat = (LogStatusStruct *) malloc(sizeof(LogStatusStruct));
                        Pos = NULL;
                        Stat->Name = NewStrBufPlain(NULL, len);
-                        StrBufExtract_NextToken(Stat->Name, Buf, &Pos, '|');
-                        Stat->Enable = StrBufExtractNext_int(Buf, &Pos, '|');
+                       StrBufExtract_NextToken(Stat->Name, Buf, &Pos, '|');
+                       Stat->Enable = StrBufExtractNext_int(Buf, &Pos, '|');
 
-                        Put(Hash, IKEY(num_logs), Stat, DeleteLogStatusStruct); 
+                       Put(Hash, IKEY(num_logs), Stat, DeleteLogStatusStruct);
                        num_logs++;
-                }
+               }
        }
        FreeStrBuf(&Buf);
        return Hash;
 }
 
 
-void 
-InitModule_SITECONFIG
-(void)
-{
+void InitModule_SITECONFIG(void) {
        RegisterCTX(CTX_SRVLOG);
        WebcitAddUrlHandler(HKEY("siteconfig"), "", 0, siteconfig, CTX_NONE);
 
@@ -504,24 +486,15 @@ InitModule_SITECONFIG
        RegisterNamespace("SERVCFG:LOGNAME", 0, 1, tmplput_servcfg_LogName, NULL, CTX_SRVLOG);
 }
 
-void 
-ServerStartModule_SITECONFIG
-(void)
-{
+void ServerStartModule_SITECONFIG(void) {
        LoadZoneFiles();
 }
 
-void 
-ServerShutdownModule_SITECONFIG
-(void)
-{
+void ServerShutdownModule_SITECONFIG(void) {
        DeleteHash(&ZoneHash);
 }
 
 
-void 
-SessionDestroyModule_SITECONFIG
-(wcsession *sess)
-{
+void SessionDestroyModule_SITECONFIG(wcsession * sess) {
        DeleteHash(&sess->ServCfg);
 }
index 50618e63608ef2609b10d20b45b911c21707f9b1..34b92f46e4e912d3777af2d7b2e9709b766b1ede 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * XML sitemap generator
  *
@@ -30,9 +31,10 @@ void sitemap_do_bbs(void) {
        Stat.lowest_found = (-1);
        Stat.highest_found = (-1);
        num_msgs = load_msg_ptrs("MSGS ALL", NULL, NULL, &Stat, NULL, NULL, NULL, NULL, 0);
-       if (num_msgs < 1) return;
+       if (num_msgs < 1)
+               return;
 
-       for (i=0; i<num_msgs; i+=20) {
+       for (i = 0; i < num_msgs; i += 20) {
                Msg = GetMessagePtrAt(i, WC->summ);
                if (Msg != NULL) {
                        wc_printf("<url><loc>%s/readfwd", ChrPtr(site_prefix));
@@ -60,25 +62,27 @@ void sitemap_do_wiki(void) {
        Stat.lowest_found = (-1);
        Stat.highest_found = (-1);
        num_msgs = load_msg_ptrs("MSGS ALL", NULL, NULL, &Stat, NULL, NULL, NULL, NULL, 0);
-       if (num_msgs < 1) return;
+       if (num_msgs < 1)
+               return;
 
-       for (i=0; i<num_msgs; ++i) {
+       for (i = 0; i < num_msgs; ++i) {
                Msg = GetMessagePtrAt(i, WC->summ);
                if (Msg != NULL) {
 
                        serv_printf("MSG0 %ld|3", Msg->msgnum);
                        serv_getln(buf, sizeof buf);
-                       if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-                               if (    (!strncasecmp(buf, "exti=", 5))
-                                       && (!bmstrcasestr(buf, "_HISTORY_"))
-                               ) {
-                                       wc_printf("<url><loc>%s/wiki", ChrPtr(site_prefix));
-                                       wc_printf("?go=");
-                                       urlescputs(ChrPtr(WC->CurRoom.name));
-                                       wc_printf("?page=%s", &buf[5]);
-                                       wc_printf("</loc></url>\r\n");
+                       if (buf[0] == '1')
+                               while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+                                       if ((!strncasecmp(buf, "exti=", 5))
+                                           && (!bmstrcasestr(buf, "_HISTORY_"))
+                                           ) {
+                                               wc_printf("<url><loc>%s/wiki", ChrPtr(site_prefix));
+                                               wc_printf("?go=");
+                                               urlescputs(ChrPtr(WC->CurRoom.name));
+                                               wc_printf("?page=%s", &buf[5]);
+                                               wc_printf("</loc></url>\r\n");
+                                       }
                                }
-                       }
                }
        }
 }
@@ -101,16 +105,17 @@ struct sitemap_room_list *sitemap_load_roomlist(void) {
 
        serv_puts("LKRA");
        serv_getln(buf, sizeof buf);
-       if (buf[0] == '1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-               struct sitemap_room_list *ptr = malloc(sizeof(struct sitemap_room_list));
-               extract_token(roomname_plain, buf, 0, '|', sizeof roomname_plain);
-               ptr->roomname = NewStrBufPlain(roomname_plain, -1);
-               ptr->defview = extract_int(buf, 6);
-               ptr->next = roomlist;
-               roomlist = ptr;
-       }
+       if (buf[0] == '1')
+               while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+                       struct sitemap_room_list *ptr = malloc(sizeof(struct sitemap_room_list));
+                       extract_token(roomname_plain, buf, 0, '|', sizeof roomname_plain);
+                       ptr->roomname = NewStrBufPlain(roomname_plain, -1);
+                       ptr->defview = extract_int(buf, 6);
+                       ptr->next = roomlist;
+                       roomlist = ptr;
+               }
 
-       return(roomlist);
+       return (roomlist);
 }
 
 extern void sitemap_do_blog(void);
@@ -122,12 +127,8 @@ void sitemap(void) {
        struct sitemap_room_list *roomlist = NULL;
        output_headers(0, 0, 0, 0, 1, 0);
        hprintf("Content-type: text/xml\r\n");
-       hprintf(
-               "Server: %s / %s\r\n"
-               "Connection: close\r\n"
-       ,
-               PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
-       );
+       hprintf("Server: %s / %s\r\n" "Connection: close\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
+           );
        begin_burst();
 
        wc_printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
@@ -135,14 +136,13 @@ void sitemap(void) {
 
        roomlist = sitemap_load_roomlist();
 
-       while (roomlist != NULL)
-       {
+       while (roomlist != NULL) {
                struct sitemap_room_list *ptr;
 
                gotoroom(roomlist->roomname);
 
                /* Output the messages in this room only if it's a room type we can make sense of */
-               switch(roomlist->defview) {
+               switch (roomlist->defview) {
                case VIEW_BBS:
                        sitemap_do_bbs();
                        break;
@@ -167,10 +167,7 @@ void sitemap(void) {
 }
 
 
-void 
-InitModule_SITEMAP
-(void)
-{
-       WebcitAddUrlHandler(HKEY("sitemap"), "", 0, sitemap, ANONYMOUS|COOKIEUNNEEDED);
-       WebcitAddUrlHandler(HKEY("sitemap.xml"), "", 0, sitemap, ANONYMOUS|COOKIEUNNEEDED);
+void InitModule_SITEMAP(void) {
+       WebcitAddUrlHandler(HKEY("sitemap"), "", 0, sitemap, ANONYMOUS | COOKIEUNNEEDED);
+       WebcitAddUrlHandler(HKEY("sitemap.xml"), "", 0, sitemap, ANONYMOUS | COOKIEUNNEEDED);
 }
index b5c750a311a1b4106a9072b8ae20f3e51db4996a..7168d6fa4fae75dd68a053c637ae546f153ed602 100644 (file)
@@ -1,3 +1,4 @@
+
 /* 
  * Display the outbound SMTP queue
  */
@@ -13,6 +14,7 @@ typedef struct _mailq_entry {
        StrBuf *Recipient;
        StrBuf *StatusMessage;
        int Status;
+
        /**<
         * 0 = No delivery has yet been attempted
         * 2 = Delivery was successful
@@ -25,7 +27,7 @@ typedef struct _mailq_entry {
 
        int n;
        int Active;
-}MailQEntry;
+} MailQEntry;
 
 typedef struct queueitem {
        long MessageID;
@@ -33,6 +35,7 @@ typedef struct queueitem {
        long Submitted;
        int FailNow;
        HashList *MailQEntries;
+
 /* copy of the currently parsed item in the MailQEntries list;
  * if null add a new one.
  */
@@ -49,28 +52,25 @@ typedef struct queueitem {
 } OneQueItem;
 
 
-typedef void (*QItemHandler)(OneQueItem *Item, StrBuf *Line, const char **Pos);
+typedef void (*QItemHandler)(OneQueItem * Item, StrBuf * Line, const char **Pos);
 
 typedef struct __QItemHandlerStruct {
        QItemHandler H;
 } QItemHandlerStruct;
 
-void RegisterQItemHandler(const char *Key, long Len, QItemHandler H)
-{
-       QItemHandlerStruct *HS = (QItemHandlerStruct*)malloc(sizeof(QItemHandlerStruct));
+void RegisterQItemHandler(const char *Key, long Len, QItemHandler H) {
+       QItemHandlerStruct *HS = (QItemHandlerStruct *) malloc(sizeof(QItemHandlerStruct));
        HS->H = H;
        Put(QItemHandlers, Key, Len, HS, NULL);
 }
 
-void FreeMailQEntry(void *qv)
-{
+void FreeMailQEntry(void *qv) {
        MailQEntry *Q = qv;
        FreeStrBuf(&Q->Recipient);
        FreeStrBuf(&Q->StatusMessage);
        free(Q);
 }
-void FreeQueItem(OneQueItem **Item)
-{
+void FreeQueItem(OneQueItem ** Item) {
        DeleteHash(&(*Item)->MailQEntries);
        FreeStrBuf(&(*Item)->EnvelopeFrom);
        FreeStrBuf(&(*Item)->BounceTo);
@@ -79,20 +79,18 @@ void FreeQueItem(OneQueItem **Item)
        free(*Item);
        Item = NULL;
 }
-void HFreeQueItem(void *Item)
-{
-       FreeQueItem((OneQueItem**)&Item);
+void HFreeQueItem(void *Item) {
+       FreeQueItem((OneQueItem **) & Item);
 }
 
 
-OneQueItem *DeserializeQueueItem(StrBuf *RawQItem, long QueMsgID)
-{
+OneQueItem *DeserializeQueueItem(StrBuf * RawQItem, long QueMsgID) {
        OneQueItem *Item;
        const char *pLine = NULL;
        StrBuf *Line;
        StrBuf *Token;
-       
-       Item = (OneQueItem*)malloc(sizeof(OneQueItem));
+
+       Item = (OneQueItem *) malloc(sizeof(OneQueItem));
        memset(Item, 0, sizeof(OneQueItem));
        Item->Retry = 0;
        Item->MessageID = -1;
@@ -105,77 +103,69 @@ OneQueItem *DeserializeQueueItem(StrBuf *RawQItem, long QueMsgID)
                void *vHandler;
 
                StrBufExtract_NextToken(Line, RawQItem, &pLine, '\n');
-               if (StrLength(Line) == 0) continue;
+               if (StrLength(Line) == 0)
+                       continue;
                StrBufExtract_NextToken(Token, Line, &pItemPart, '|');
-               if (GetHash(QItemHandlers, SKEY(Token), &vHandler))
-               {
+               if (GetHash(QItemHandlers, SKEY(Token), &vHandler)) {
                        QItemHandlerStruct *HS;
-                       HS = (QItemHandlerStruct*) vHandler;
+                       HS = (QItemHandlerStruct *) vHandler;
                        HS->H(Item, Line, &pItemPart);
                }
        }
        FreeStrBuf(&Line);
        FreeStrBuf(&Token);
+
 /*
        Put(ActiveQItems,
            LKEY(Item->MessageID),
            Item,
            HFreeQueItem);
-*/     
+*/
 
        return Item;
 }
 
-void tmplput_MailQID(StrBuf *Target, WCTemplputParams *TP)
-{
-       OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
+void tmplput_MailQID(StrBuf * Target, WCTemplputParams * TP) {
+       OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
        StrBufAppendPrintf(Target, "%ld", Item->QueMsgID);;
 }
-void tmplput_MailQPayloadID(StrBuf *Target, WCTemplputParams *TP)
-{
-       OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
+void tmplput_MailQPayloadID(StrBuf * Target, WCTemplputParams * TP) {
+       OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
        StrBufAppendPrintf(Target, "%ld", Item->MessageID);
 }
-void tmplput_MailQBounceTo(StrBuf *Target, WCTemplputParams *TP)
-{
-       OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
+void tmplput_MailQBounceTo(StrBuf * Target, WCTemplputParams * TP) {
+       OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
        StrBufAppendTemplate(Target, TP, Item->BounceTo, 0);
 }
-void tmplput_MailQAttempted(StrBuf *Target, WCTemplputParams *TP)
-{
-        char datebuf[64];
-       OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
-        webcit_fmt_date(datebuf, 64, Item->ReattemptWhen, DATEFMT_BRIEF);
-        StrBufAppendBufPlain(Target, datebuf, -1, 0);
-}
-void tmplput_MailQSubmitted(StrBuf *Target, WCTemplputParams *TP)
-{
-        char datebuf[64];
-       OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
-        webcit_fmt_date(datebuf, 64, Item->Submitted, DATEFMT_BRIEF);
-        StrBufAppendBufPlain(Target, datebuf, -1, 0);
-}
-void tmplput_MailQEnvelopeFrom(StrBuf *Target, WCTemplputParams *TP)
-{
-       OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
+void tmplput_MailQAttempted(StrBuf * Target, WCTemplputParams * TP) {
+       char datebuf[64];
+       OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
+       webcit_fmt_date(datebuf, 64, Item->ReattemptWhen, DATEFMT_BRIEF);
+       StrBufAppendBufPlain(Target, datebuf, -1, 0);
+}
+void tmplput_MailQSubmitted(StrBuf * Target, WCTemplputParams * TP) {
+       char datebuf[64];
+       OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
+       webcit_fmt_date(datebuf, 64, Item->Submitted, DATEFMT_BRIEF);
+       StrBufAppendBufPlain(Target, datebuf, -1, 0);
+}
+void tmplput_MailQEnvelopeFrom(StrBuf * Target, WCTemplputParams * TP) {
+       OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
        StrBufAppendTemplate(Target, TP, Item->EnvelopeFrom, 0);
 }
-void tmplput_MailQSourceRoom(StrBuf *Target, WCTemplputParams *TP)
-{
-       OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
+void tmplput_MailQSourceRoom(StrBuf * Target, WCTemplputParams * TP) {
+       OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
        StrBufAppendTemplate(Target, TP, Item->SenderRoom, 0);
 }
 
-int Conditional_MailQ_HaveSourceRoom(StrBuf *Target, WCTemplputParams *TP)
-{
-       OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
+int Conditional_MailQ_HaveSourceRoom(StrBuf * Target, WCTemplputParams * TP) {
+       OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
        return StrLength(Item->SenderRoom) > 0;
 }
 
-void tmplput_MailQRetry(StrBuf *Target, WCTemplputParams *TP)
-{
-        char datebuf[64];
-       OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
+void tmplput_MailQRetry(StrBuf * Target, WCTemplputParams * TP) {
+       char datebuf[64];
+       OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
 
        if (Item->Retry == 0) {
                StrBufAppendBufPlain(Target, _("First Attempt pending"), -1, 0);
@@ -186,77 +176,64 @@ void tmplput_MailQRetry(StrBuf *Target, WCTemplputParams *TP)
        }
 }
 
-void tmplput_MailQRCPT(StrBuf *Target, WCTemplputParams *TP)
-{
-       MailQEntry *Entry = (MailQEntry*) CTX(CTX_MAILQ_RCPT);
+void tmplput_MailQRCPT(StrBuf * Target, WCTemplputParams * TP) {
+       MailQEntry *Entry = (MailQEntry *) CTX(CTX_MAILQ_RCPT);
        StrBufAppendTemplate(Target, TP, Entry->Recipient, 0);
 }
-void tmplput_MailQRCPTStatus(StrBuf *Target, WCTemplputParams *TP)
-{
-       MailQEntry *Entry = (MailQEntry*) CTX(CTX_MAILQ_RCPT);
+void tmplput_MailQRCPTStatus(StrBuf * Target, WCTemplputParams * TP) {
+       MailQEntry *Entry = (MailQEntry *) CTX(CTX_MAILQ_RCPT);
        StrBufAppendPrintf(Target, "%ld", Entry->Status);
 }
-void tmplput_MailQStatusMsg(StrBuf *Target, WCTemplputParams *TP)
-{
-       MailQEntry *Entry = (MailQEntry*) CTX(CTX_MAILQ_RCPT);
+void tmplput_MailQStatusMsg(StrBuf * Target, WCTemplputParams * TP) {
+       MailQEntry *Entry = (MailQEntry *) CTX(CTX_MAILQ_RCPT);
        StrBufAppendTemplate(Target, TP, Entry->StatusMessage, 0);
 }
 
-HashList *iterate_get_Recipients(StrBuf *Target, WCTemplputParams *TP)
-{
-       OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
+HashList *iterate_get_Recipients(StrBuf * Target, WCTemplputParams * TP) {
+       OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
        return Item->MailQEntries;
 }
 
 
-void NewMailQEntry(OneQueItem *Item)
-{
-       Item->Current = (MailQEntry*) malloc(sizeof(MailQEntry));
+void NewMailQEntry(OneQueItem * Item) {
+       Item->Current = (MailQEntry *) malloc(sizeof(MailQEntry));
        memset(Item->Current, 0, sizeof(MailQEntry));
 
        if (Item->MailQEntries == NULL)
                Item->MailQEntries = NewHash(1, Flathash);
        Item->Current->StatusMessage = NewStrBuf();
        Item->Current->n = GetCount(Item->MailQEntries);
-       Put(Item->MailQEntries,
-           IKEY(Item->Current->n),
-           Item->Current,
-           FreeMailQEntry);
+       Put(Item->MailQEntries, IKEY(Item->Current->n), Item->Current, FreeMailQEntry);
 }
 
-void QItem_Handle_MsgID(OneQueItem *Item, StrBuf *Line, const char **Pos)
-{
+void QItem_Handle_MsgID(OneQueItem * Item, StrBuf * Line, const char **Pos) {
        Item->MessageID = StrBufExtractNext_long(Line, Pos, '|');
 }
 
-void QItem_Handle_EnvelopeFrom(OneQueItem *Item, StrBuf *Line, const char **Pos)
-{
+void QItem_Handle_EnvelopeFrom(OneQueItem * Item, StrBuf * Line, const char **Pos) {
        if (Item->EnvelopeFrom == NULL)
                Item->EnvelopeFrom = NewStrBufPlain(NULL, StrLength(Line));
        StrBufExtract_NextToken(Item->EnvelopeFrom, Line, Pos, '|');
 }
 
-void QItem_Handle_BounceTo(OneQueItem *Item, StrBuf *Line, const char **Pos)
-{
+void QItem_Handle_BounceTo(OneQueItem * Item, StrBuf * Line, const char **Pos) {
        if (Item->BounceTo == NULL)
                Item->BounceTo = NewStrBufPlain(NULL, StrLength(Line));
        StrBufExtract_NextToken(Item->BounceTo, Line, Pos, '|');
 }
 
-void QItem_Handle_SenderRoom(OneQueItem *Item, StrBuf *Line, const char **Pos)
-{
+void QItem_Handle_SenderRoom(OneQueItem * Item, StrBuf * Line, const char **Pos) {
        if (Item->SenderRoom == NULL)
                Item->SenderRoom = NewStrBufPlain(NULL, StrLength(Line));
        StrBufExtract_NextToken(Item->SenderRoom, Line, Pos, '|');
 }
 
-void QItem_Handle_Recipient(OneQueItem *Item, StrBuf *Line, const char **Pos)
-{
+void QItem_Handle_Recipient(OneQueItem * Item, StrBuf * Line, const char **Pos) {
        const char *pch;
        if (Item->Current == NULL)
                NewMailQEntry(Item);
        if (Item->Current->Recipient == NULL)
-               Item->Current->Recipient=NewStrBufPlain(NULL, StrLength(Line));
+               Item->Current->Recipient = NewStrBufPlain(NULL, StrLength(Line));
        StrBufExtract_NextToken(Item->Current->Recipient, Line, Pos, '|');
        Item->Current->Status = StrBufExtractNext_int(Line, Pos, '|');
        StrBufExtract_NextToken(Item->Current->StatusMessage, Line, Pos, '|');
@@ -265,42 +242,37 @@ void QItem_Handle_Recipient(OneQueItem *Item, StrBuf *Line, const char **Pos)
        while ((pch != NULL) && (*pch != '\0')) {
                pch = strchr(pch, ';');
                if (pch != NULL) {
-                       pch ++;
+                       pch++;
                        if (*pch == ' ') {
-                               StrBufPeek(Item->Current->StatusMessage,
-                                          pch, -1, '\n');
+                               StrBufPeek(Item->Current->StatusMessage, pch, -1, '\n');
                        }
                }
        }
-       Item->Current = NULL; // TODO: is this always right?
+       Item->Current = NULL;   // TODO: is this always right?
 }
 
 
-void QItem_Handle_retry(OneQueItem *Item, StrBuf *Line, const char **Pos)
-{
+void QItem_Handle_retry(OneQueItem * Item, StrBuf * Line, const char **Pos) {
        Item->Retry = StrBufExtractNext_int(Line, Pos, '|');
 }
 
 
-void QItem_Handle_Submitted(OneQueItem *Item, StrBuf *Line, const char **Pos)
-{
+void QItem_Handle_Submitted(OneQueItem * Item, StrBuf * Line, const char **Pos) {
        Item->Submitted = atol(*Pos);
 
 }
 
-void QItem_Handle_Attempted(OneQueItem *Item, StrBuf *Line, const char **Pos)
-{
+void QItem_Handle_Attempted(OneQueItem * Item, StrBuf * Line, const char **Pos) {
        Item->ReattemptWhen = StrBufExtractNext_int(Line, Pos, '|');
 }
 
 
 
 
-void render_QUEUE(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
-{
+void render_QUEUE(StrBuf * Target, WCTemplputParams * TP, StrBuf * FoundCharset) {
        wc_mime_attachment *Mime = CTX(CTX_MIME_ATACH);
        WCTemplputParams SubTP;
-       OneQueItemContext;
+       OneQueItem *Context;
 
        Context = DeserializeQueueItem(Mime->Data, Mime->msgnum);
        StackContext(TP, &SubTP, Context, CTX_MAILQITEM, 0, TP->Tokens);
@@ -309,24 +281,18 @@ void render_QUEUE(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
        }
        UnStackContext(&SubTP);
 
-       FreeQueItem (&Context);
+       FreeQueItem(&Context);
 }
 
-void
-ServerShutdownModule_SMTP_QUEUE
-(void)
-{
+void ServerShutdownModule_SMTP_QUEUE(void) {
        DeleteHash(&QItemHandlers);
 }
-void
-ServerStartModule_SMTP_QUEUE
-(void)
-{
+
+void ServerStartModule_SMTP_QUEUE(void) {
        QItemHandlers = NewHash(0, NULL);
 }
 
-int qview_PrintPageHeader(SharedMessageStatus *Stat, void **ViewSpecific)
-{
+int qview_PrintPageHeader(SharedMessageStatus * Stat, void **ViewSpecific) {
        if (yesbstr("ListOnly"))
                output_headers(1, 0, 0, 0, 0, 0);
        else
@@ -334,16 +300,9 @@ int qview_PrintPageHeader(SharedMessageStatus *Stat, void **ViewSpecific)
        return 0;
 }
 
-int qview_GetParamsGetServerCall(SharedMessageStatus *Stat,
-                                void **ViewSpecific,
-                                long oper,
-                                char *cmd,
-                                long len,
-                                char *filter,
-                                long flen)
-{
-       if (!WC->is_aide)
-       {
+int qview_GetParamsGetServerCall(SharedMessageStatus * Stat,
+                                void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen) {
+       if (!WC->is_aide) {
                DoTemplate(HKEY("aide_required"), NULL, NULL);
                end_burst();
 
@@ -363,64 +322,51 @@ int qview_GetParamsGetServerCall(SharedMessageStatus *Stat,
 /*
  * Display task view
  */
-int qview_LoadMsgFromServer(SharedMessageStatus *Stat, 
-                            void **ViewSpecific, 
-                            message_summary* Msg, 
-                            int is_new, 
-                            int i)
-{
+int qview_LoadMsgFromServer(SharedMessageStatus * Stat, void **ViewSpecific, message_summary * Msg, int is_new, int i) {
        wcsession *WCC = WC;
        const StrBuf *Mime;
 
-        /* Not (yet?) needed here? calview *c = (calview *) *ViewSpecific; */
+       /* Not (yet?) needed here? calview *c = (calview *) *ViewSpecific; */
        read_message(WCC->WBuf, HKEY("view_mailq_message_bearer"), Msg->msgnum, NULL, &Mime, NULL);
 
-        return 0;
+       return 0;
 }
 
 
-int qview_RenderView_or_Tail(SharedMessageStatus *Stat, 
-                            void **ViewSpecific, 
-                            long oper)
-{
+int qview_RenderView_or_Tail(SharedMessageStatus * Stat, void **ViewSpecific, long oper) {
        wcsession *WCC = WC;
        WCTemplputParams SubTP;
 
        memset(&SubTP, 0, sizeof(WCTemplputParams));
        if (yesbstr("ListOnly"))
-               DoTemplate(HKEY("view_mailq_footer_listonly"),NULL, &SubTP);
-       else
-       {
+               DoTemplate(HKEY("view_mailq_footer_listonly"), NULL, &SubTP);
+       else {
                if (GetCount(WCC->summ) == 0)
-                       DoTemplate(HKEY("view_mailq_footer_empty"),NULL, &SubTP);
+                       DoTemplate(HKEY("view_mailq_footer_empty"), NULL, &SubTP);
                else
-                       DoTemplate(HKEY("view_mailq_footer"),NULL, &SubTP);
+                       DoTemplate(HKEY("view_mailq_footer"), NULL, &SubTP);
        }
 
        return 0;
 }
-int qview_Cleanup(void **ViewSpecific)
-{
-       
-       wDumpContent(yesbstr("ListOnly")?0:1);
+int qview_Cleanup(void **ViewSpecific) {
+
+       wDumpContent(yesbstr("ListOnly") ? 0 : 1);
        return 0;
 }
 
-void 
-InitModule_SMTP_QUEUE
-(void)
-{
+void InitModule_SMTP_QUEUE(void) {
        RegisterCTX(CTX_MAILQITEM);
        RegisterCTX(CTX_MAILQ_RCPT);
 
-       RegisterQItemHandler(HKEY("msgid"),             QItem_Handle_MsgID);
-       RegisterQItemHandler(HKEY("envelope_from"),     QItem_Handle_EnvelopeFrom);
-       RegisterQItemHandler(HKEY("retry"),             QItem_Handle_retry);
-       RegisterQItemHandler(HKEY("attempted"),         QItem_Handle_Attempted);
-       RegisterQItemHandler(HKEY("remote"),            QItem_Handle_Recipient);
-       RegisterQItemHandler(HKEY("bounceto"),          QItem_Handle_BounceTo);
-       RegisterQItemHandler(HKEY("source_room"),       QItem_Handle_SenderRoom);
-       RegisterQItemHandler(HKEY("submitted"),         QItem_Handle_Submitted);
+       RegisterQItemHandler(HKEY("msgid"), QItem_Handle_MsgID);
+       RegisterQItemHandler(HKEY("envelope_from"), QItem_Handle_EnvelopeFrom);
+       RegisterQItemHandler(HKEY("retry"), QItem_Handle_retry);
+       RegisterQItemHandler(HKEY("attempted"), QItem_Handle_Attempted);
+       RegisterQItemHandler(HKEY("remote"), QItem_Handle_Recipient);
+       RegisterQItemHandler(HKEY("bounceto"), QItem_Handle_BounceTo);
+       RegisterQItemHandler(HKEY("source_room"), QItem_Handle_SenderRoom);
+       RegisterQItemHandler(HKEY("submitted"), QItem_Handle_Submitted);
        RegisterMimeRenderer(HKEY("application/x-citadel-delivery-list"), render_QUEUE, 1, 9000);
        RegisterNamespace("MAILQ:ID", 0, 0, tmplput_MailQID, NULL, CTX_MAILQITEM);
        RegisterNamespace("MAILQ:PAYLOAD:ID", 0, 0, tmplput_MailQPayloadID, NULL, CTX_MAILQITEM);
@@ -429,26 +375,17 @@ InitModule_SMTP_QUEUE
        RegisterNamespace("MAILQ:SUBMITTED", 0, 0, tmplput_MailQSubmitted, NULL, CTX_MAILQITEM);
        RegisterNamespace("MAILQ:ENVELOPEFROM", 0, 1, tmplput_MailQEnvelopeFrom, NULL, CTX_MAILQITEM);
        RegisterNamespace("MAILQ:SRCROOM", 0, 1, tmplput_MailQSourceRoom, NULL, CTX_MAILQITEM);
-       RegisterConditional("COND:MAILQ:HAVESRCROOM", 0, Conditional_MailQ_HaveSourceRoom,  CTX_MAILQITEM);
+       RegisterConditional("COND:MAILQ:HAVESRCROOM", 0, Conditional_MailQ_HaveSourceRoom, CTX_MAILQITEM);
        RegisterNamespace("MAILQ:RETRY", 0, 0, tmplput_MailQRetry, NULL, CTX_MAILQITEM);
 
        RegisterNamespace("MAILQ:RCPT:ADDR", 0, 1, tmplput_MailQRCPT, NULL, CTX_MAILQ_RCPT);
        RegisterNamespace("MAILQ:RCPT:STATUS", 0, 0, tmplput_MailQRCPTStatus, NULL, CTX_MAILQ_RCPT);
        RegisterNamespace("MAILQ:RCPT:STATUSMSG", 0, 1, tmplput_MailQStatusMsg, NULL, CTX_MAILQ_RCPT);
 
-       RegisterIterator("MAILQ:RCPT", 0, NULL, iterate_get_Recipients, 
-                        NULL, NULL, CTX_MAILQ_RCPT, CTX_MAILQITEM, IT_NOFLAG);
+       RegisterIterator("MAILQ:RCPT", 0, NULL, iterate_get_Recipients, NULL, NULL, CTX_MAILQ_RCPT, CTX_MAILQITEM, IT_NOFLAG);
 
 
-       RegisterReadLoopHandlerset(
-               VIEW_QUEUE,
-               qview_GetParamsGetServerCall,
-               qview_PrintPageHeader,
-               NULL, /* TODO: is this right? */
-               NULL,
-               qview_LoadMsgFromServer,
-               qview_RenderView_or_Tail,
-               qview_Cleanup,
-               NULL);
+       RegisterReadLoopHandlerset(VIEW_QUEUE, qview_GetParamsGetServerCall, qview_PrintPageHeader, NULL,       /* TODO: is this right? */
+                                  NULL, qview_LoadMsgFromServer, qview_RenderView_or_Tail, qview_Cleanup, NULL);
 
 }
index 57ca654668c15c587e7dcd96f8964ab70c9ce791..0971a748686784fa056a1cf98f20d2b2a31049e6 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1987-2021 by the citadel.org team
  *
@@ -18,7 +19,7 @@
 #include "webcit.h"
 #include "webserver.h"
 
-long MaxRead = -1; /* should we do READ scattered or all at once? */
+long MaxRead = -1;             /* should we do READ scattered or all at once? */
 
 /*
  * register the timeout
@@ -43,13 +44,13 @@ int connect_to_citadel(char *sockpath) {
        s = socket(AF_UNIX, SOCK_STREAM, 0);
        if (s < 0) {
                syslog(LOG_WARNING, "Can't create socket [%s]: %s\n", sockpath, strerror(errno));
-               return(-1);
+               return (-1);
        }
 
        if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
                syslog(LOG_WARNING, "Can't connect [%s]: %s\n", sockpath, strerror(errno));
                close(s);
-               return(-1);
+               return (-1);
        }
        return s;
 }
@@ -76,33 +77,26 @@ int serv_getln(char *strbuf, int bufsize) {
 }
 
 
-int StrBuf_ServGetln(StrBuf *buf) {
+int StrBuf_ServGetln(StrBuf * buf) {
        const char *ErrStr = NULL;
        int rc;
-       
+
        if (!WC->connected)
                return -1;
 
        FlushStrBuf(buf);
-       rc = StrBufTCP_read_buffered_line_fast(buf, 
-                                              WC->ReadBuf, 
-                                              &WC->ReadPos, 
-                                              &WC->serv_sock, 
-                                              5, 1, 
-                                              &ErrStr);
-       if (rc < 0)
-       {
-               syslog(LOG_INFO, "StrBuf_ServGetln(): Server connection broken: %s\n",
-                       (ErrStr)?ErrStr:"");
+       rc = StrBufTCP_read_buffered_line_fast(buf, WC->ReadBuf, &WC->ReadPos, &WC->serv_sock, 5, 1, &ErrStr);
+       if (rc < 0) {
+               syslog(LOG_INFO, "StrBuf_ServGetln(): Server connection broken: %s\n", (ErrStr) ? ErrStr : "");
                wc_backtrace(LOG_INFO);
-               if (WC->serv_sock > 0) close(WC->serv_sock);
+               if (WC->serv_sock > 0)
+                       close(WC->serv_sock);
                WC->serv_sock = (-1);
                WC->connected = 0;
                WC->logged_in = 0;
        }
 #ifdef SERV_TRACE
-       else 
-       {
+       else {
                long pos = 0;
                if (WC->ReadPos != NULL)
                        pos = WC->ReadPos - ChrPtr(WC->ReadBuf);
@@ -112,60 +106,53 @@ int StrBuf_ServGetln(StrBuf *buf) {
        return rc;
 }
 
-int StrBuf_ServGetBLOBBuffered(StrBuf *buf, long BlobSize) {
+int StrBuf_ServGetBLOBBuffered(StrBuf * buf, long BlobSize) {
        const char *ErrStr;
        int rc;
-       
-       rc = StrBufReadBLOBBuffered(buf, 
-                                   WC->ReadBuf, 
-                                   &WC->ReadPos,
-                                   &WC->serv_sock, 
-                                   1, 
-                                   BlobSize, 
-                                   NNN_TERM,
-                                   &ErrStr);
+
+       rc = StrBufReadBLOBBuffered(buf, WC->ReadBuf, &WC->ReadPos, &WC->serv_sock, 1, BlobSize, NNN_TERM, &ErrStr);
        if (rc < 0) {
-               syslog(LOG_INFO, "StrBuf_ServGetBLOBBuffered(): Server connection broken: %s\n",
-                       (ErrStr)?ErrStr:"");
+               syslog(LOG_INFO, "StrBuf_ServGetBLOBBuffered(): Server connection broken: %s\n", (ErrStr) ? ErrStr : "");
                wc_backtrace(LOG_INFO);
-               if (WC->serv_sock > 0) close(WC->serv_sock);
+               if (WC->serv_sock > 0)
+                       close(WC->serv_sock);
                WC->serv_sock = (-1);
                WC->connected = 0;
                WC->logged_in = 0;
        }
 #ifdef SERV_TRACE
-        else
-                syslog(LOG_DEBUG, "%3d<<<BLOB: %d bytes\n", WC->serv_sock, StrLength(buf));
+       else
+               syslog(LOG_DEBUG, "%3d<<<BLOB: %d bytes\n", WC->serv_sock, StrLength(buf));
 #endif
 
        return rc;
 }
 
-int StrBuf_ServGetBLOB(StrBuf *buf, long BlobSize) {
+int StrBuf_ServGetBLOB(StrBuf * buf, long BlobSize) {
        const char *ErrStr;
        int rc;
-       
+
        WC->ReadPos = NULL;
        rc = StrBufReadBLOB(buf, &WC->serv_sock, 1, BlobSize, &ErrStr);
        if (rc < 0) {
-               syslog(LOG_INFO, "StrBuf_ServGetBLOB(): Server connection broken: %s\n",
-                       (ErrStr)?ErrStr:"");
+               syslog(LOG_INFO, "StrBuf_ServGetBLOB(): Server connection broken: %s\n", (ErrStr) ? ErrStr : "");
                wc_backtrace(LOG_INFO);
-               if (WC->serv_sock > 0) close(WC->serv_sock);
+               if (WC->serv_sock > 0)
+                       close(WC->serv_sock);
                WC->serv_sock = (-1);
                WC->connected = 0;
                WC->logged_in = 0;
        }
 #ifdef SERV_TRACE
-        else
-                syslog(LOG_DEBUG, "%3d<<<BLOB: %d bytes\n", WC->serv_sock, StrLength(buf));
+       else
+               syslog(LOG_DEBUG, "%3d<<<BLOB: %d bytes\n", WC->serv_sock, StrLength(buf));
 #endif
 
        return rc;
 }
 
 
-void FlushReadBuf (void) {
+void FlushReadBuf(void) {
        long len;
        const char *pch;
        const char *pche;
@@ -176,16 +163,13 @@ void FlushReadBuf (void) {
                pche = pch + len;
                if (WC->ReadPos != pche) {
                        syslog(LOG_ERR,
-                               "ERROR: somebody didn't eat his soup! Remaing Chars: %ld [%s]\n", 
-                               (long)(pche - WC->ReadPos),
-                               pche
-                       );
-                       syslog(LOG_ERR, 
-                               "--------------------------------------------------------------------------------\n"
-                               "Whole buf: [%s]\n"
-                               "--------------------------------------------------------------------------------\n", 
-                               pch);
-                       AppendImportantMessage(HKEY("Suppenkasper alert! watch your webcit logfile and get connected to your favourite opensource Crew."));
+                              "ERROR: somebody didn't eat his soup! Remaing Chars: %ld [%s]\n", (long) (pche - WC->ReadPos), pche);
+                       syslog(LOG_ERR,
+                              "--------------------------------------------------------------------------------\n"
+                              "Whole buf: [%s]\n"
+                              "--------------------------------------------------------------------------------\n", pch);
+                       AppendImportantMessage(HKEY
+                                              ("Suppenkasper alert! watch your webcit logfile and get connected to your favourite opensource Crew."));
                }
        }
 
@@ -210,8 +194,9 @@ int serv_write(const char *buf, int nbytes) {
                retval = write(WC->serv_sock, &buf[bytes_written], nbytes - bytes_written);
                if (retval < 1) {
                        const char *ErrStr = strerror(errno);
-                       syslog(LOG_INFO, "serv_write(): Server connection broken: %s\n", (ErrStr)?ErrStr:"");
-                       if (WC->serv_sock > 0) close(WC->serv_sock);
+                       syslog(LOG_INFO, "serv_write(): Server connection broken: %s\n", (ErrStr) ? ErrStr : "");
+                       if (WC->serv_sock > 0)
+                               close(WC->serv_sock);
                        WC->serv_sock = (-1);
                        WC->connected = 0;
                        WC->logged_in = 0;
@@ -242,7 +227,7 @@ int serv_puts(const char *string) {
  *  send line to server
  *  string the line to send to the citadel server
  */
-int serv_putbuf(const StrBuf *string) {
+int serv_putbuf(const StrBuf * string) {
 #ifdef SERV_TRACE
        syslog(LOG_DEBUG, "%3d>>>%s\n", WC->serv_sock, ChrPtr(string));
 #endif
@@ -259,7 +244,7 @@ int serv_putbuf(const StrBuf *string) {
  *  format the formatstring
  *  ... the entities to insert into format 
  */
-int serv_printf(const char *format,...) {
+int serv_printf(const char *format, ...) {
        va_list arg_ptr;
        char buf[SIZ];
        size_t len;
@@ -286,7 +271,7 @@ int serv_printf(const char *format,...) {
  * Read binary data from server into memory using a series of server READ commands.
  * returns the read content as StrBuf
  */
-int serv_read_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf) {
+int serv_read_binary(StrBuf * Ret, size_t total_len, StrBuf * Buf) {
        size_t bytes_read = 0;
        size_t this_block = 0;
        int rc = 6;
@@ -298,13 +283,13 @@ int serv_read_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf) {
 
        while ((bytes_read < total_len) && (ServerRc == 6)) {
 
-               if (WC->serv_sock==-1) {
-                       FlushStrBuf(Ret); 
-                       return -1; 
+               if (WC->serv_sock == -1) {
+                       FlushStrBuf(Ret);
+                       return -1;
                }
 
-               serv_printf("READ "SIZE_T_FMT"|"SIZE_T_FMT, bytes_read, total_len-bytes_read);
-               if ( (rc = StrBuf_ServGetln(Buf) > 0) && (ServerRc = GetServerStatus(Buf, NULL), ServerRc == 6) ) {
+               serv_printf("READ " SIZE_T_FMT "|" SIZE_T_FMT, bytes_read, total_len - bytes_read);
+               if ((rc = StrBuf_ServGetln(Buf) > 0) && (ServerRc = GetServerStatus(Buf, NULL), ServerRc == 6)) {
                        if (rc < 0)
                                return rc;
                        StrBufCutLeft(Buf, 4);
@@ -313,7 +298,8 @@ int serv_read_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf) {
                        if (rc < 0) {
                                syslog(LOG_INFO, "Server connection broken during download\n");
                                wc_backtrace(LOG_INFO);
-                               if (WC->serv_sock > 0) close(WC->serv_sock);
+                               if (WC->serv_sock > 0)
+                                       close(WC->serv_sock);
                                WC->serv_sock = (-1);
                                WC->connected = 0;
                                WC->logged_in = 0;
@@ -327,12 +313,12 @@ int serv_read_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf) {
 }
 
 
-int client_write(StrBuf *ThisBuf) {
-        const char *ptr, *eptr;
-        long count;
+int client_write(StrBuf * ThisBuf) {
+       const char *ptr, *eptr;
+       long count;
        ssize_t res = 0;
-        fd_set wset;
-        int fdflags;
+       fd_set wset;
+       int fdflags;
 
        ptr = ChrPtr(ThisBuf);
        count = StrLength(ThisBuf);
@@ -340,34 +326,34 @@ int client_write(StrBuf *ThisBuf) {
 
        fdflags = fcntl(WC->Hdr->http_sock, F_GETFL);
 
-        while ((ptr < eptr) && (WC->Hdr->http_sock != -1)) {
-                if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
-                        FD_ZERO(&wset);
-                        FD_SET(WC->Hdr->http_sock, &wset);
-                        if (select(WC->Hdr->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
-                                syslog(LOG_INFO, "client_write: Socket select failed (%s)\n", strerror(errno));
-                                return -1;
-                        }
-                }
-
-                if ((WC->Hdr->http_sock == -1) || ((res = write(WC->Hdr->http_sock, ptr, count)), (res == -1))) {
-                        syslog(LOG_INFO, "client_write: Socket write failed (%s)\n", strerror(errno));
+       while ((ptr < eptr) && (WC->Hdr->http_sock != -1)) {
+               if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
+                       FD_ZERO(&wset);
+                       FD_SET(WC->Hdr->http_sock, &wset);
+                       if (select(WC->Hdr->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
+                               syslog(LOG_INFO, "client_write: Socket select failed (%s)\n", strerror(errno));
+                               return -1;
+                       }
+               }
+
+               if ((WC->Hdr->http_sock == -1) || ((res = write(WC->Hdr->http_sock, ptr, count)), (res == -1))) {
+                       syslog(LOG_INFO, "client_write: Socket write failed (%s)\n", strerror(errno));
                        wc_backtrace(LOG_INFO);
-                        return -1;
-                }
-                count -= res;
+                       return -1;
+               }
+               count -= res;
                ptr += res;
-        }
+       }
        return 0;
 }
 
 
-int read_serv_chunk( StrBuf *Buf, size_t total_len, size_t *bytes_read) {
+int read_serv_chunk(StrBuf * Buf, size_t total_len, size_t *bytes_read) {
        int rc;
        int ServerRc;
 
-       serv_printf("READ "SIZE_T_FMT"|"SIZE_T_FMT, *bytes_read, total_len-(*bytes_read));
-       if ( (rc = StrBuf_ServGetln(Buf) > 0) && (ServerRc = GetServerStatus(Buf, NULL), ServerRc == 6) ) {
+       serv_printf("READ " SIZE_T_FMT "|" SIZE_T_FMT, *bytes_read, total_len - (*bytes_read));
+       if ((rc = StrBuf_ServGetln(Buf) > 0) && (ServerRc = GetServerStatus(Buf, NULL), ServerRc == 6)) {
                size_t this_block = 0;
 
                if (rc < 0)
@@ -379,7 +365,8 @@ int read_serv_chunk( StrBuf *Buf, size_t total_len, size_t *bytes_read) {
                if (rc < 0) {
                        syslog(LOG_INFO, "Server connection broken during download\n");
                        wc_backtrace(LOG_INFO);
-                       if (WC->serv_sock > 0) close(WC->serv_sock);
+                       if (WC->serv_sock > 0)
+                               close(WC->serv_sock);
                        WC->serv_sock = (-1);
                        WC->connected = 0;
                        WC->logged_in = 0;
@@ -390,7 +377,7 @@ int read_serv_chunk( StrBuf *Buf, size_t total_len, size_t *bytes_read) {
        return 6;
 }
 
-static inline int send_http(StrBuf *Buf) {
+static inline int send_http(StrBuf * Buf) {
 #ifdef HAVE_OPENSSL
        if (is_https)
                return client_write_ssl(Buf);
@@ -398,11 +385,12 @@ static inline int send_http(StrBuf *Buf) {
 #endif
                return client_write(Buf);
 }
+
 /*
  * Read binary data from server into memory using a series of server READ commands.
  * returns the read content as StrBuf
  */
-void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static, int detect_mime) {
+void serv_read_binary_to_http(StrBuf * MimeType, size_t total_len, int is_static, int detect_mime) {
        int ServerRc = 6;
        size_t bytes_read = 0;
        int first = 1;
@@ -416,7 +404,7 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
        vStreamT *SC = NULL;
        IOBuffer ReadBuffer;
        IOBuffer WriteBuffer;
-       
+
 
        Buf = NewStrBuf();
 
@@ -424,13 +412,13 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
                WC->Hdr->HaveRange++;
                WC->Hdr->TotalBytes = total_len;
                /* open range? or beyound file border? correct the numbers. */
-               if ((WC->Hdr->RangeTil == -1) || (WC->Hdr->RangeTil>= total_len))
+               if ((WC->Hdr->RangeTil == -1) || (WC->Hdr->RangeTil >= total_len))
                        WC->Hdr->RangeTil = total_len - 1;
                bytes_read = WC->Hdr->RangeStart;
                total_len = WC->Hdr->RangeTil;
        }
        else
-               chunked = total_len > SIZ * 10; /* TODO: disallow for HTTP / 1.0 */
+               chunked = total_len > SIZ * 10; /* TODO: disallow for HTTP / 1.0 */
 
        if (chunked) {
                BufHeader = NewStrBuf();
@@ -441,13 +429,9 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
                size_t bytes_read = 0;
                const char *CT;
 
-               ServerRc = read_serv_chunk(
-                       Buf,
-                       total_len,
-                       &bytes_read);
+               ServerRc = read_serv_chunk(Buf, total_len, &bytes_read);
 
-               if (ServerRc != 6)
-               {
+               if (ServerRc != 6) {
                        FreeStrBuf(&BufHeader);
                        FreeStrBuf(&Buf);
                        return;
@@ -463,7 +447,7 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
        memset(&WriteBuffer, 0, sizeof(IOBuffer));
        if (chunked && !DisableGzip && WC->Hdr->HR.gzip_ok) {
                is_gzip = 1;
-               SC = StrBufNewStreamContext (eZLibEncode, &Err);
+               SC = StrBufNewStreamContext(eZLibEncode, &Err);
                if (SC == NULL) {
                        syslog(LOG_ERR, "Error while initializing stream context: %s", Err);
                        FreeStrBuf(&Buf);
@@ -473,7 +457,7 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
                memset(&ReadBuffer, 0, sizeof(IOBuffer));
                ReadBuffer.Buf = WC->WBuf;
 
-               WriteBuffer.Buf = NewStrBufPlain(NULL, SIZ*2);;
+               WriteBuffer.Buf = NewStrBufPlain(NULL, SIZ * 2);;
                pBuf = WriteBuffer.Buf;
        }
        else {
@@ -482,7 +466,7 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
 
        if (!detect_mime) {
                http_transmit_headers(ChrPtr(MimeType), is_static, chunked, is_gzip);
-               
+
                if (send_http(WC->HBuf) < 0) {
                        FreeStrBuf(&Buf);
                        FreeStrBuf(&WriteBuffer.Buf);
@@ -496,8 +480,8 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
 
        while ((bytes_read < total_len) && (ServerRc == 6) && (client_con_state == 0)) {
 
-               if (WC->serv_sock==-1) {
-                       FlushStrBuf(WC->WBuf); 
+               if (WC->serv_sock == -1) {
+                       FlushStrBuf(WC->WBuf);
                        FreeStrBuf(&Buf);
                        FreeStrBuf(&WriteBuffer.Buf);
                        FreeStrBuf(&BufHeader);
@@ -508,17 +492,14 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
                        return;
                }
 
-               ServerRc = read_serv_chunk(
-                       Buf,
-                       total_len,
-                       &bytes_read);
+               ServerRc = read_serv_chunk(Buf, total_len, &bytes_read);
                if (ServerRc != 6)
                        break;
 
                if (detect_mime) {
                        const char *CT;
                        detect_mime = 0;
-                       
+
                        CT = GuessMimeType(SKEY(WC->WBuf));
                        StrBufPlain(MimeType, CT, -1);
                        if (is_gzip) {
@@ -526,7 +507,7 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
                                is_gzip = WC->Hdr->HR.gzip_ok;
                        }
                        http_transmit_headers(ChrPtr(MimeType), is_static, chunked, is_gzip);
-                       
+
                        client_con_state = send_http(WC->HBuf);
                }
 
@@ -536,12 +517,11 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
                                int rc;
 
                                do {
-                                       rc = StrBufStreamTranscode(eZLibEncode, &WriteBuffer, &ReadBuffer, NULL, -1, SC, done, &Err);
+                                       rc = StrBufStreamTranscode(eZLibEncode, &WriteBuffer, &ReadBuffer, NULL, -1, SC, done,
+                                                                  &Err);
 
-                                       if (StrLength (pBuf) > 0) {
-                                               StrBufPrintf(BufHeader, "%s%x\r\n", 
-                                                    (first)?"":"\r\n",
-                                                            StrLength (pBuf));
+                                       if (StrLength(pBuf) > 0) {
+                                               StrBufPrintf(BufHeader, "%s%x\r\n", (first) ? "" : "\r\n", StrLength(pBuf));
                                                first = 0;
                                                client_con_state = send_http(BufHeader);
                                                if (client_con_state == 0) {
@@ -555,9 +535,7 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
                }
                else {
                        if ((chunked) && (client_con_state == 0)) {
-                               StrBufPrintf(BufHeader, "%s%x\r\n", 
-                                            (first)?"":"\r\n",
-                                            StrLength (pBuf));
+                               StrBufPrintf(BufHeader, "%s%x\r\n", (first) ? "" : "\r\n", StrLength(pBuf));
                                first = 0;
                                client_con_state = send_http(BufHeader);
                        }
@@ -577,7 +555,7 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
                StrBufPlain(BufHeader, HKEY("\r\n0\r\n\r\n"));
                if (send_http(BufHeader) < 0) {
                        FreeStrBuf(&Buf);
-                       FreeStrBuf(&BufHeader);
+                       FreeStrBuf(&BufHeader);
                        return;
                }
        }
@@ -585,7 +563,7 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
        FreeStrBuf(&Buf);
 }
 
-int ClientGetLine(ParsedHttpHdrs *Hdr, StrBuf *Target) {
+int ClientGetLine(ParsedHttpHdrs * Hdr, StrBuf * Target) {
        const char *Error;
 #ifdef HAVE_OPENSSL
        const char *pch, *pchs;
@@ -599,15 +577,15 @@ int ClientGetLine(ParsedHttpHdrs *Hdr, StrBuf *Target) {
                        if (pch != NULL) {
                                rlen = 0;
                                len = pch - pchs;
-                               if (len > 0 && (*(pch - 1) == '\r') )
-                                       rlen ++;
+                               if (len > 0 && (*(pch - 1) == '\r'))
+                                       rlen++;
                                StrBufSub(Target, Hdr->ReadBuf, 0, len - rlen);
                                StrBufCutLeft(Hdr->ReadBuf, len + 1);
                                return len - rlen;
                        }
                }
 
-               while (retval == 0) { 
+               while (retval == 0) {
                        pch = NULL;
                        pchs = ChrPtr(Hdr->ReadBuf);
                        if (*pchs != '\0')
@@ -621,7 +599,7 @@ int ClientGetLine(ParsedHttpHdrs *Hdr, StrBuf *Target) {
                        }
                        if (retval == 0) {
                                sleeeeeeeeeep(1);
-                               ntries ++;
+                               ntries++;
                        }
                        if (ntries > 10)
                                return 0;
@@ -629,25 +607,19 @@ int ClientGetLine(ParsedHttpHdrs *Hdr, StrBuf *Target) {
                if ((retval > 0) && (pch != NULL)) {
                        rlen = 0;
                        len = pch - pchs;
-                       if (len > 0 && (*(pch - 1) == '\r') )
-                               rlen ++;
+                       if (len > 0 && (*(pch - 1) == '\r'))
+                               rlen++;
                        StrBufSub(Target, Hdr->ReadBuf, 0, len - rlen);
                        StrBufCutLeft(Hdr->ReadBuf, len + 1);
                        return len - rlen;
 
                }
-               else 
+               else
                        return -1;
        }
-       else 
+       else
 #endif
-               return StrBufTCP_read_buffered_line_fast(Target, 
-                                                        Hdr->ReadBuf,
-                                                        &Hdr->Pos,
-                                                        &Hdr->http_sock,
-                                                        5,
-                                                        1,
-                                                        &Error);
+               return StrBufTCP_read_buffered_line_fast(Target, Hdr->ReadBuf, &Hdr->Pos, &Hdr->http_sock, 5, 1, &Error);
 }
 
 
@@ -668,35 +640,32 @@ int webcit_tcp_server(const char *ip_addr, int port_number, int queue_len) {
        int s, i, b;
        int ip_version = 6;
 
-retry:
+      retry:
        memset(&sin6, 0, sizeof(sin6));
        memset(&sin4, 0, sizeof(sin4));
        sin6.sin6_family = AF_INET6;
        sin4.sin_family = AF_INET;
 
-       if (    (ip_addr == NULL)                                                       /* any IPv6 */
-               || (IsEmptyStr(ip_addr))
-               || (!strcmp(ip_addr, "*"))
-       ) {
+       if ((ip_addr == NULL)   /* any IPv6 */
+           ||(IsEmptyStr(ip_addr))
+           || (!strcmp(ip_addr, "*"))
+           ) {
                IsDefault = 1;
                ip_version = 6;
                sin6.sin6_addr = in6addr_any;
        }
-       else if (!strcmp(ip_addr, "0.0.0.0"))                                           /* any IPv4 */
-       {
+       else if (!strcmp(ip_addr, "0.0.0.0")) { /* any IPv4 */
                ip_version = 4;
                sin4.sin_addr.s_addr = INADDR_ANY;
        }
-       else if ((strchr(ip_addr, '.')) && (!strchr(ip_addr, ':')))                     /* specific IPv4 */
-       {
+       else if ((strchr(ip_addr, '.')) && (!strchr(ip_addr, ':'))) {   /* specific IPv4 */
                ip_version = 4;
                if (inet_pton(AF_INET, ip_addr, &sin4.sin_addr) <= 0) {
                        syslog(LOG_WARNING, "Error binding to [%s] : %s\n", ip_addr, strerror(errno));
                        return (-WC_EXIT_BIND);
                }
        }
-       else                                                                            /* specific IPv6 */
-       {
+       else {                  /* specific IPv6 */
                ip_version = 6;
                if (inet_pton(AF_INET6, ip_addr, &sin6.sin6_addr) <= 0) {
                        syslog(LOG_WARNING, "Error binding to [%s] : %s\n", ip_addr, strerror(errno));
@@ -713,10 +682,9 @@ retry:
 
        p = getprotobyname("tcp");
 
-       s = socket( ((ip_version == 6) ? PF_INET6 : PF_INET), SOCK_STREAM, (p->p_proto));
+       s = socket(((ip_version == 6) ? PF_INET6 : PF_INET), SOCK_STREAM, (p->p_proto));
        if (s < 0) {
-               if (IsDefault && (errno == EAFNOSUPPORT))
-               {
+               if (IsDefault && (errno == EAFNOSUPPORT)) {
                        s = 0;
                        ip_addr = ipv4broadcast;
                        goto retry;
@@ -762,12 +730,12 @@ int webcit_uds_server(char *sockpath, int queue_len) {
        int actual_queue_len;
 
        actual_queue_len = queue_len;
-       if (actual_queue_len < 5) actual_queue_len = 5;
+       if (actual_queue_len < 5)
+               actual_queue_len = 5;
 
        i = unlink(sockpath);
        if ((i != 0) && (errno != ENOENT)) {
-               syslog(LOG_WARNING, "webcit: can't unlink %s: %s\n",
-                       sockpath, strerror(errno));
+               syslog(LOG_WARNING, "webcit: can't unlink %s: %s\n", sockpath, strerror(errno));
                return (-WC_EXIT_BIND);
        }
 
@@ -781,7 +749,7 @@ int webcit_uds_server(char *sockpath, int queue_len) {
                return (-WC_EXIT_BIND);
        }
 
-       if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+       if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
                syslog(LOG_WARNING, "webcit: Can't bind: %s\n", strerror(errno));
                close(s);
                return (-WC_EXIT_BIND);
@@ -794,7 +762,7 @@ int webcit_uds_server(char *sockpath, int queue_len) {
        }
 
        chmod(sockpath, 0777);
-       return(s);
+       return (s);
 }
 
 
@@ -811,7 +779,7 @@ int webcit_uds_server(char *sockpath, int queue_len) {
  *      0       Request timed out.
  *     -1      Connection is broken, or other error.
  */
-int client_read_to(ParsedHttpHdrs *Hdr, StrBuf *Target, int bytes, int timeout) {
+int client_read_to(ParsedHttpHdrs * Hdr, StrBuf * Target, int bytes, int timeout) {
        const char *Error;
        int retval = 0;
 
@@ -828,7 +796,7 @@ int client_read_to(ParsedHttpHdrs *Hdr, StrBuf *Target, int bytes, int timeout)
 
                if (StrLength(Hdr->ReadBuf) > 0) {
                        bufremain = StrLength(Hdr->ReadBuf) - (Hdr->Pos - ChrPtr(Hdr->ReadBuf));
-                       
+
                        if (bytes < bufremain)
                                bufremain = bytes;
                        StrBufAppendBufPlain(Target, Hdr->Pos, bufremain, 0);
@@ -836,11 +804,10 @@ int client_read_to(ParsedHttpHdrs *Hdr, StrBuf *Target, int bytes, int timeout)
                }
 
                if (bytes > bufremain) {
-                       while ((StrLength(Hdr->ReadBuf) + StrLength(Target) < bytes + baselen) &&
-                              (retval >= 0))
+                       while ((StrLength(Hdr->ReadBuf) + StrLength(Target) < bytes + baselen) && (retval >= 0))
                                retval = client_read_sslbuffer(Hdr->ReadBuf, timeout);
                        if (retval >= 0) {
-                               StrBufAppendBuf(Target, Hdr->ReadBuf, 0); /* todo: Buf > bytes? */
+                               StrBufAppendBuf(Target, Hdr->ReadBuf, 0);       /* todo: Buf > bytes? */
                                return 1;
                        }
                        else {
@@ -848,18 +815,11 @@ int client_read_to(ParsedHttpHdrs *Hdr, StrBuf *Target, int bytes, int timeout)
                                return -1;
                        }
                }
-               else 
+               else
                        return 1;
        }
 #endif
-       retval = StrBufReadBLOBBuffered(Target, 
-                                       Hdr->ReadBuf, 
-                                       &Hdr->Pos, 
-                                       &Hdr->http_sock, 
-                                       1, 
-                                       bytes,
-                                       O_TERM,
-                                       &Error);
+       retval = StrBufReadBLOBBuffered(Target, Hdr->ReadBuf, &Hdr->Pos, &Hdr->http_sock, 1, bytes, O_TERM, &Error);
        if (retval < 0) {
                syslog(LOG_INFO, "client_read() failed: %s\n", Error);
                wc_backtrace(LOG_DEBUG);
@@ -873,8 +833,7 @@ int client_read_to(ParsedHttpHdrs *Hdr, StrBuf *Target, int bytes, int timeout)
 /*
  * Begin buffering HTTP output so we can transmit it all in one write operation later.
  */
-void begin_burst(void)
-{
+void begin_burst(void) {
        if (WC->WBuf == NULL) {
                WC->WBuf = NewStrBufPlain(NULL, 32768);
        }
@@ -884,16 +843,14 @@ void begin_burst(void)
 /*
  * Finish buffering HTTP output.  [Compress using zlib and] output with a Content-Length: header.
  */
-long end_burst(void)
-{
-        const char *ptr, *eptr;
-        long count;
+long end_burst(void) {
+       const char *ptr, *eptr;
+       long count;
        ssize_t res = 0;
-        fd_set wset;
-        int fdflags;
+       fd_set wset;
+       int fdflags;
 
-       if (!DisableGzip && (WC->Hdr->HR.gzip_ok))
-       {
+       if (!DisableGzip && (WC->Hdr->HR.gzip_ok)) {
                if (CompressBuffer(WC->WBuf) > 0)
                        hprintf("Content-encoding: gzip\r\n");
                else {
@@ -929,52 +886,46 @@ long end_burst(void)
        fdflags = fcntl(WC->Hdr->http_sock, F_GETFL);
 
        while ((ptr < eptr) && (WC->Hdr->http_sock != -1)) {
-                if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
-                        FD_ZERO(&wset);
-                        FD_SET(WC->Hdr->http_sock, &wset);
-                        if (select(WC->Hdr->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
-                                syslog(LOG_DEBUG, "client_write: Socket select failed (%s)\n", strerror(errno));
-                                return -1;
-                        }
-                }
-
-                if ((WC->Hdr->http_sock == -1) || 
-                   (res = write(WC->Hdr->http_sock, 
-                                ptr,
-                                count)) == -1) {
-                        syslog(LOG_DEBUG, "client_write: Socket write failed (%s)\n", strerror(errno));
-                       wc_backtrace(LOG_INFO);
-                        return res;
-                }
-                count -= res;
+               if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
+                       FD_ZERO(&wset);
+                       FD_SET(WC->Hdr->http_sock, &wset);
+                       if (select(WC->Hdr->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
+                               syslog(LOG_DEBUG, "client_write: Socket select failed (%s)\n", strerror(errno));
+                               return -1;
+                       }
+               }
+
+               if ((WC->Hdr->http_sock == -1) || (res = write(WC->Hdr->http_sock, ptr, count)) == -1) {
+                       syslog(LOG_DEBUG, "client_write: Socket write failed (%s)\n", strerror(errno));
+                       wc_backtrace(LOG_INFO);
+                       return res;
+               }
+               count -= res;
                ptr += res;
-        }
+       }
 
        ptr = ChrPtr(WC->WBuf);
        count = StrLength(WC->WBuf);
        eptr = ptr + count;
 
-        while ((ptr < eptr) && (WC->Hdr->http_sock != -1)) {
-                if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
-                        FD_ZERO(&wset);
-                        FD_SET(WC->Hdr->http_sock, &wset);
-                        if (select(WC->Hdr->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
-                                syslog(LOG_INFO, "client_write: Socket select failed (%s)\n", strerror(errno));
-                                return -1;
-                        }
-                }
-
-                if ((WC->Hdr->http_sock == -1) || 
-                   (res = write(WC->Hdr->http_sock, 
-                                ptr,
-                                count)) == -1) {
-                        syslog(LOG_INFO, "client_write: Socket write failed (%s)\n", strerror(errno));
+       while ((ptr < eptr) && (WC->Hdr->http_sock != -1)) {
+               if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
+                       FD_ZERO(&wset);
+                       FD_SET(WC->Hdr->http_sock, &wset);
+                       if (select(WC->Hdr->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
+                               syslog(LOG_INFO, "client_write: Socket select failed (%s)\n", strerror(errno));
+                               return -1;
+                       }
+               }
+
+               if ((WC->Hdr->http_sock == -1) || (res = write(WC->Hdr->http_sock, ptr, count)) == -1) {
+                       syslog(LOG_INFO, "client_write: Socket write failed (%s)\n", strerror(errno));
                        wc_backtrace(LOG_INFO);
-                        return res;
-                }
-                count -= res;
+                       return res;
+               }
+               count -= res;
                ptr += res;
-        }
+       }
 
        return StrLength(WC->WBuf);
 }
@@ -984,8 +935,7 @@ long end_burst(void)
  * lingering_close() a`la Apache. see
  * http://httpd.apache.org/docs/2.0/misc/fin_wait_2.html for rationale
  */
-int lingering_close(int fd)
-{
+int lingering_close(int fd) {
        char buf[SIZ];
        int i;
        fd_set set;
@@ -1018,44 +968,29 @@ int lingering_close(int fd)
        return close(fd);
 }
 
-void
-HttpNewModule_TCPSOCKETS
-(ParsedHttpHdrs *httpreq)
-{
+void HttpNewModule_TCPSOCKETS(ParsedHttpHdrs * httpreq) {
 
        httpreq->ReadBuf = NewStrBufPlain(NULL, SIZ * 4);
 }
 
-void
-HttpDetachModule_TCPSOCKETS
-(ParsedHttpHdrs *httpreq)
-{
+void HttpDetachModule_TCPSOCKETS(ParsedHttpHdrs * httpreq) {
 
        FlushStrBuf(httpreq->ReadBuf);
        ReAdjustEmptyBuf(httpreq->ReadBuf, 4 * SIZ, SIZ);
 }
 
-void
-HttpDestroyModule_TCPSOCKETS
-(ParsedHttpHdrs *httpreq)
-{
+void HttpDestroyModule_TCPSOCKETS(ParsedHttpHdrs * httpreq) {
 
        FreeStrBuf(&httpreq->ReadBuf);
 }
 
 
-void
-SessionNewModule_TCPSOCKETS
-(wcsession *sess)
-{
+void SessionNewModule_TCPSOCKETS(wcsession * sess) {
        sess->CLineBuf = NewStrBuf();
        sess->MigrateReadLineBuf = NewStrBuf();
 }
 
-void 
-SessionDestroyModule_TCPSOCKETS
-(wcsession *sess)
-{
+void SessionDestroyModule_TCPSOCKETS(wcsession * sess) {
        FreeStrBuf(&sess->CLineBuf);
        FreeStrBuf(&sess->ReadBuf);
        sess->connected = 0;
index 340e71eb511cf29491eb6a6939ee118a3615235a..de2220bb287059c9d9e85753a6797050036033dc 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2013 by the citadel.org team
  *
@@ -13,7 +14,7 @@
 int connect_to_citadel(char *);
 int connectsock(char *, char *);
 int serv_getln(char *strbuf, int bufsize);
-int StrBuf_ServGetln(StrBuf *buf);
+int StrBuf_ServGetln(StrBuf * buf);
 
 /*
  * parse & check the server reply 
@@ -27,7 +28,7 @@ int StrBuf_ServGetln(StrBuf *buf);
  * returns the most significant digit of the server status
  */
 
-int GetServerStatusMsg(StrBuf *Line, long* FullState, int PutImportantMessage, int MajorOK);
+int GetServerStatusMsg(StrBuf * Line, long *FullState, int PutImportantMessage, int MajorOK);
 
 /*
  * to migrate old calls.... 
@@ -37,15 +38,15 @@ int GetServerStatusMsg(StrBuf *Line, long* FullState, int PutImportantMessage, i
 int serv_puts(const char *string);
 
 int serv_write(const char *buf, int nbytes);
-int serv_putbuf(const StrBuf *string);
-int serv_printf(const char *format,...)__attribute__((__format__(__printf__,1,2)));
-int serv_read_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf);
-void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static, int detect_mime);
-int StrBuf_ServGetBLOB(StrBuf *buf, long BlobSize);
-int StrBuf_ServGetBLOBBuffered(StrBuf *buf, long BlobSize);
-int read_server_text(StrBuf *Buf, long *nLines);
+int serv_putbuf(const StrBuf * string);
+int serv_printf(const char *format, ...) __attribute__((__format__(__printf__, 1, 2)));
+int serv_read_binary(StrBuf * Ret, size_t total_len, StrBuf * Buf);
+void serv_read_binary_to_http(StrBuf * MimeType, size_t total_len, int is_static, int detect_mime);
+int StrBuf_ServGetBLOB(StrBuf * buf, long BlobSize);
+int StrBuf_ServGetBLOBBuffered(StrBuf * buf, long BlobSize);
+int read_server_text(StrBuf * Buf, long *nLines);
 
 void text_to_server(char *ptr);
-void text_to_server_qp(const StrBuf *SendMeEncoded);
+void text_to_server_qp(const StrBuf * SendMeEncoded);
 void server_to_text(void);
 int lingering_close(int fd);
index ccae7d2974b2cff098bd9669684d649d1a9b082d..cb8e496c022e728c9cd092e6f070c6b7ca5efcf1 100644 (file)
 #include "webserver.h"
 
 unsigned char OnePixelGif[37] = {
-               0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x01, 0x00,
-               0x01, 0x00, 0x80, 0x00, 0x00, 0xff, 0xff, 0xff,
-               0xff, 0xff, 0xff, 0x2c, 0x00, 0x00, 0x00, 0x00,
-               0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x44,
-               0x01, 0x00, 0x3b 
+       0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x01, 0x00,
+       0x01, 0x00, 0x80, 0x00, 0x00, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0x2c, 0x00, 0x00, 0x00, 0x00,
+       0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x44,
+       0x01, 0x00, 0x3b
 };
 
 
@@ -30,7 +30,7 @@ void output_error_pic(const char *ErrMsg1, const char *ErrMsg2) {
        hprintf("Content-Type: image/gif\r\n");
        hprintf("x-webcit-errormessage: %s\r\n", ErrMsg2);
        begin_burst();
-       StrBufPlain(WC->WBuf, (const char *)OnePixelGif, sizeof(OnePixelGif));
+       StrBufPlain(WC->WBuf, (const char *) OnePixelGif, sizeof(OnePixelGif));
        end_burst();
 }
 
@@ -45,10 +45,10 @@ void output_static(char *prefix) {
        int len;
        const char *Err;
        char what[SIZ];
-       snprintf(what, sizeof what, "./%s/%s", prefix, (char *)ChrPtr(WC->Hdr->HR.ReqLine));
+       snprintf(what, sizeof what, "./%s/%s", prefix, (char *) ChrPtr(WC->Hdr->HR.ReqLine));
 
        syslog(LOG_DEBUG, "output_static(%s)", what);
-       len = strlen (what);
+       len = strlen(what);
        content_type = GuessMimeByFilename(what, len);
        fd = open(what, O_RDONLY);
        if (fd <= 0) {
@@ -77,19 +77,21 @@ void output_static(char *prefix) {
                                wc_printf("Cannot fstat %s: %s\n", what, strerror(errno));
                                end_burst();
                        }
-                       if (fd > 0) close(fd);
+                       if (fd > 0)
+                               close(fd);
                        return;
                }
 
                bytes = statbuf.st_size;
 
                if (StrBufReadBLOB(WC->WBuf, &fd, 1, bytes, &Err) < 0) {
-                       if (fd > 0) close(fd);
+                       if (fd > 0)
+                               close(fd);
                        syslog(LOG_INFO, "output_static('%s')  -- FREAD FAILED (%s) --\n", what, strerror(errno));
-                               hprintf("HTTP/1.1 500 internal server error \r\n");
-                               hprintf("Content-Type: text/plain\r\n");
-                               end_burst();
-                               return;
+                       hprintf("HTTP/1.1 500 internal server error \r\n");
+                       hprintf("Content-Type: text/plain\r\n");
+                       end_burst();
+                       return;
                }
 
                close(fd);
@@ -107,61 +109,52 @@ void output_static(char *prefix) {
 void robots_txt(void) {
        output_headers(0, 0, 0, 0, 0, 0);
 
-       hprintf("Content-type: text/plain\r\n"
-               "Server: %s\r\n"
-               "Connection: close\r\n",
-               PACKAGE_STRING);
+       hprintf("Content-type: text/plain\r\n" "Server: %s\r\n" "Connection: close\r\n", PACKAGE_STRING);
        begin_burst();
 
        wc_printf("User-agent: *\r\n"
-               "Disallow: /printmsg\r\n"
-               "Disallow: /msgheaders\r\n"
-               "Disallow: /groupdav\r\n"
-               "Disallow: /do_template\r\n"
-               "Disallow: /static\r\n"
-               "Disallow: /display_page\r\n"
-               "Disallow: /readnew\r\n"
-               "Disallow: /display_enter\r\n"
-               "Disallow: /skip\r\n"
-               "Disallow: /ungoto\r\n"
-               "Sitemap: %s/sitemap.xml\r\n"
-               "\r\n"
-               ,
-               ChrPtr(site_prefix)
-       );
+                 "Disallow: /printmsg\r\n"
+                 "Disallow: /msgheaders\r\n"
+                 "Disallow: /groupdav\r\n"
+                 "Disallow: /do_template\r\n"
+                 "Disallow: /static\r\n"
+                 "Disallow: /display_page\r\n"
+                 "Disallow: /readnew\r\n"
+                 "Disallow: /display_enter\r\n"
+                 "Disallow: /skip\r\n" "Disallow: /ungoto\r\n" "Sitemap: %s/sitemap.xml\r\n" "\r\n", ChrPtr(site_prefix)
+           );
 
        wDumpContent(0);
 }
 
 
 // These are the various prefixes we can use to fetch static pages.
-void output_static_root(void)          {       output_static(".");             }
-void output_static_static(void)                {       output_static("static");        }
-void output_static_tinymce(void)       {       output_static("tiny_mce");      }
-void output_static_acme(void)          {       output_static(".well-known");   }
+void output_static_root(void) {
+       output_static(".");
+}
+void output_static_static(void) {
+       output_static("static");
+}
+void output_static_tinymce(void) {
+       output_static("tiny_mce");
+}
+void output_static_acme(void) {
+       output_static(".well-known");
+}
 
 
-void 
-ServerStartModule_STATIC
-(void)
-{
+void ServerStartModule_STATIC(void) {
 }
 
 
-void 
-ServerShutdownModule_STATIC
-(void)
-{
+void ServerShutdownModule_STATIC(void) {
 }
 
-void 
-InitModule_STATIC
-(void)
-{
-       WebcitAddUrlHandler(HKEY("robots.txt"), "", 0, robots_txt, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC|LOGCHATTY);
-       WebcitAddUrlHandler(HKEY("favicon.ico"), "", 0, output_static_root, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC|LOGCHATTY);
-       WebcitAddUrlHandler(HKEY("static"), "", 0, output_static_static, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC|LOGCHATTY);
-       WebcitAddUrlHandler(HKEY("tinymce"), "", 0, output_static_tinymce, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC|LOGCHATTY);
-       WebcitAddUrlHandler(HKEY("tiny_mce"), "", 0, output_static_tinymce, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC|LOGCHATTY);
-       WebcitAddUrlHandler(HKEY(".well-known"), "", 0, output_static_acme, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC|LOGCHATTY);
+void InitModule_STATIC(void) {
+       WebcitAddUrlHandler(HKEY("robots.txt"), "", 0, robots_txt, ANONYMOUS | COOKIEUNNEEDED | ISSTATIC | LOGCHATTY);
+       WebcitAddUrlHandler(HKEY("favicon.ico"), "", 0, output_static_root, ANONYMOUS | COOKIEUNNEEDED | ISSTATIC | LOGCHATTY);
+       WebcitAddUrlHandler(HKEY("static"), "", 0, output_static_static, ANONYMOUS | COOKIEUNNEEDED | ISSTATIC | LOGCHATTY);
+       WebcitAddUrlHandler(HKEY("tinymce"), "", 0, output_static_tinymce, ANONYMOUS | COOKIEUNNEEDED | ISSTATIC | LOGCHATTY);
+       WebcitAddUrlHandler(HKEY("tiny_mce"), "", 0, output_static_tinymce, ANONYMOUS | COOKIEUNNEEDED | ISSTATIC | LOGCHATTY);
+       WebcitAddUrlHandler(HKEY(".well-known"), "", 0, output_static_acme, ANONYMOUS | COOKIEUNNEEDED | ISSTATIC | LOGCHATTY);
 }
index 0cd7615f26b1b5746b8c4871be568aa9b2090e56..0798d3b71b29cccfb3fdb152a4001e7e1a47266b 100644 (file)
@@ -17,7 +17,7 @@
 #include "webcit.h"
 #include "webserver.h"
 
-extern char *static_dirs[PATH_MAX];  /* Disk representation */
+extern char *static_dirs[PATH_MAX];    /* Disk representation */
 
 HashList *TemplateCache;
 HashList *LocalTemplateCache;
@@ -34,7 +34,7 @@ int dbg_backtrace_template_errors = 0;
 WCTemplputParams NoCtx;
 StrBuf *I18nDump = NULL;
 
-const char EmptyStr[]="";
+const char EmptyStr[] = "";
 
 #define SV_GETTEXT 1
 #define SV_CONDITIONAL 2
@@ -50,11 +50,11 @@ const char EmptyStr[]="";
  */
 typedef struct _wcsubst {
        ContextFilter Filter;
-       int wcs_type;                           /* which type of Substitution are we */
-       char wcs_key[32];                       /* copy of our hashkey for debugging */
-       StrBuf *wcs_value;                      /* if we're a string, keep it here */
-       long lvalue;                            /* type long? keep data here */
-       WCHandlerFunc wcs_function;             /* funcion hook ???*/
+       int wcs_type;           /* which type of Substitution are we */
+       char wcs_key[32];       /* copy of our hashkey for debugging */
+       StrBuf *wcs_value;      /* if we're a string, keep it here */
+       long lvalue;            /* type long? keep data here */
+       WCHandlerFunc wcs_function;     /* funcion hook ??? */
 } wcsubst;
 
 
@@ -71,15 +71,15 @@ typedef struct _HashHandler {
        ContextFilter Filter;
        WCPreevalFunc PreEvalFunc;
        WCHandlerFunc HandlerFunc;
-}HashHandler;
+} HashHandler;
 
 typedef enum _estate {
        eNext,
        eSkipTilEnd
 } TemplState;
 
-void *load_template(StrBuf *Target, WCTemplate *NewTemplate);
-int EvaluateConditional(StrBuf *Target, int Neg, int state, WCTemplputParams **TPP);
+void *load_template(StrBuf * Target, WCTemplate * NewTemplate);
+int EvaluateConditional(StrBuf * Target, int Neg, int state, WCTemplputParams ** TPP);
 
 
 
@@ -91,7 +91,7 @@ typedef struct _SortStruct {
        CompareFunc GroupChange;
 
        CtxType ContextType;
-}SortStruct;
+} SortStruct;
 
 HashList *CtxList = NULL;
 
@@ -104,24 +104,21 @@ CtxType CTX_LONGVECTOR = CTX_NONE;
 CtxType CTX_ITERATE = CTX_NONE;
 CtxType CTX_TAB = CTX_NONE;
 
-void HFreeContextType(void *pCtx)
-{
+void HFreeContextType(void *pCtx) {
        CtxTypeStruct *FreeStruct = (CtxTypeStruct *) pCtx;
        FreeStrBuf(&FreeStruct->Name);
        free(FreeStruct);
 }
-void PutContextType(const char *name, long len, CtxType TheCtx)
-{
+void PutContextType(const char *name, long len, CtxType TheCtx) {
        CtxTypeStruct *NewStruct;
 
-       NewStruct = (CtxTypeStruct*) malloc(sizeof(CtxTypeStruct));
+       NewStruct = (CtxTypeStruct *) malloc(sizeof(CtxTypeStruct));
        NewStruct->Name = NewStrBufPlain(name, len);
        NewStruct->Type = TheCtx;
 
        Put(CtxList, IKEY(NewStruct->Type), NewStruct, HFreeContextType);
 }
-void RegisterContextType(const char *name, long len, CtxType *TheCtx)
-{
+void RegisterContextType(const char *name, long len, CtxType * TheCtx) {
        if (*TheCtx != CTX_NONE)
                return;
 
@@ -129,8 +126,7 @@ void RegisterContextType(const char *name, long len, CtxType *TheCtx)
        PutContextType(name, len, *TheCtx);
 }
 
-CtxTypeStruct *GetContextType(CtxType Type)
-{
+CtxTypeStruct *GetContextType(CtxType Type) {
        void *pv = NULL;
        GetHash(CtxList, IKEY(Type), &pv);
        return pv;
@@ -138,27 +134,21 @@ CtxTypeStruct *GetContextType(CtxType Type)
 
 const char *UnknownContext = "CTX_UNKNOWN";
 
-const char *ContextName(CtxType ContextType)
-{
+const char *ContextName(CtxType ContextType) {
        CtxTypeStruct *pCtx;
 
        pCtx = GetContextType(ContextType);
 
-       if (pCtx != NULL) 
+       if (pCtx != NULL)
                return ChrPtr(pCtx->Name);
        else
                return UnknownContext;
 }
 
-void StackDynamicContext(WCTemplputParams *Super, 
-                        WCTemplputParams *Sub, 
+void StackDynamicContext(WCTemplputParams * Super,
+                        WCTemplputParams * Sub,
                         void *Context,
-                        CtxType ContextType,
-                        int nArgs,
-                        WCTemplateToken *Tokens, 
-                        WCConditionalFunc ExitCtx, 
-                        long ExitCTXID)
-{
+                        CtxType ContextType, int nArgs, WCTemplateToken * Tokens, WCConditionalFunc ExitCtx, long ExitCTXID) {
        memset(Sub, 0, sizeof(WCTemplputParams));
 
        if (Super != NULL) {
@@ -168,7 +158,7 @@ void StackDynamicContext(WCTemplputParams *Super,
        if (Sub->Sub != NULL)
                Sub->Sub->Super = Sub;
        Sub->Super = Super;
-       
+
        Sub->Context = Context;
        Sub->Filter.ContextType = ContextType;
        Sub->nArgs = nArgs;
@@ -177,27 +167,22 @@ void StackDynamicContext(WCTemplputParams *Super,
        Sub->ExitCTXID = ExitCTXID;
 }
 
-void UnStackContext(WCTemplputParams *Sub)
-{
-       if (Sub->Super != NULL)
-       {
+void UnStackContext(WCTemplputParams * Sub) {
+       if (Sub->Super != NULL) {
                Sub->Super->Sub = Sub->Sub;
        }
-       if (Sub->Sub != NULL)
-       {
+       if (Sub->Sub != NULL) {
                Sub->Sub->Super = Sub->Super;
        }
 }
-void UnStackDynamicContext(StrBuf *Target, WCTemplputParams **TPP)
-{
+void UnStackDynamicContext(StrBuf * Target, WCTemplputParams ** TPP) {
        WCTemplputParams *TP = *TPP;
        WCTemplputParams *Super = TP->Super;
        TP->ExitCtx(Target, TP);
        *TPP = Super;
 }
 
-void *GetContextPayload(WCTemplputParams *TP, CtxType ContextType)
-{
+void *GetContextPayload(WCTemplputParams * TP, CtxType ContextType) {
        WCTemplputParams *whichTP = TP;
 
        if (ContextType == CTX_NONE)
@@ -206,96 +191,73 @@ void *GetContextPayload(WCTemplputParams *TP, CtxType ContextType)
        while ((whichTP != NULL) && (whichTP->Filter.ContextType != ContextType))
                whichTP = whichTP->Super;
 
-       return whichTP->Context;        
+       return whichTP->Context;
 }
 
-void DestroySortStruct(void *vSort)
-{
-       SortStruct *Sort = (SortStruct*) vSort;
+void DestroySortStruct(void *vSort) {
+       SortStruct *Sort = (SortStruct *) vSort;
        FreeStrBuf(&Sort->Name);
        FreeStrBuf(&Sort->PrefPrepend);
-       free (Sort);
+       free(Sort);
 }
 
 
-void LogTemplateError (StrBuf *Target, const char *Type, int ErrorPos, WCTemplputParams *TP, const char *Format, ...)
-{
+void LogTemplateError(StrBuf * Target, const char *Type, int ErrorPos, WCTemplputParams * TP, const char *Format, ...) {
        StrBuf *Error;
        StrBuf *Info;
-        va_list arg_ptr;
+       va_list arg_ptr;
        const char *Err = NULL;
 
        Info = NewStrBuf();
        Error = NewStrBuf();
 
-        va_start(arg_ptr, Format);
+       va_start(arg_ptr, Format);
        StrBufVAppendPrintf(Error, Format, arg_ptr);
        va_end(arg_ptr);
 
        switch (ErrorPos) {
-       case ERR_NAME: /* the main token name... */ 
-               Err = (TP->Tokens!= NULL)? TP->Tokens->pName:"";
+       case ERR_NAME:          /* the main token name... */
+               Err = (TP->Tokens != NULL) ? TP->Tokens->pName : "";
                break;
        default:
-               Err = ((TP->Tokens!= NULL) && 
-                      (TP->Tokens->nParameters > ErrorPos - 1))? 
-                       TP->Tokens->Params[ErrorPos - 1]->Start : "";
+               Err = ((TP->Tokens != NULL) &&
+                      (TP->Tokens->nParameters > ErrorPos - 1)) ? TP->Tokens->Params[ErrorPos - 1]->Start : "";
                break;
        }
-       if (TP->Tokens != NULL) 
-       {
-               syslog(LOG_WARNING, "%s [%s]  (in '%s' line %ld); %s; [%s]\n", 
-                      Type, 
-                      Err, 
-                      ChrPtr(TP->Tokens->FileName),
-                      TP->Tokens->Line, 
-                      ChrPtr(Error), 
-                      ChrPtr(TP->Tokens->FlatToken));
-       }
-       else 
-       {
-               syslog(LOG_WARNING, "%s: %s;\n", 
-                      Type, 
-                      ChrPtr(Error));
+       if (TP->Tokens != NULL) {
+               syslog(LOG_WARNING, "%s [%s]  (in '%s' line %ld); %s; [%s]\n",
+                      Type, Err, ChrPtr(TP->Tokens->FileName), TP->Tokens->Line, ChrPtr(Error), ChrPtr(TP->Tokens->FlatToken));
+       }
+       else {
+               syslog(LOG_WARNING, "%s: %s;\n", Type, ChrPtr(Error));
        }
        if (WC == NULL) {
                FreeStrBuf(&Info);
                FreeStrBuf(&Error);
-               return; 
+               return;
        }
 
-       if (WC->WFBuf == NULL) WC->WFBuf = NewStrBuf();
-       if (TP->Tokens != NULL) 
-       {
+       if (WC->WFBuf == NULL)
+               WC->WFBuf = NewStrBuf();
+       if (TP->Tokens != NULL) {
                /* deprecated: 
-               StrBufAppendPrintf(                                                          
-                       Target,                                                              
-                       "<pre>\n%s [%s] (in '%s' line %ld); %s\n[%s]\n</pre>\n",
-                       Type, 
-                       Err, 
-                       ChrPtr(TP->Tokens->FileName),
-                       TP->Tokens->Line,
-                       ChrPtr(Error),
-                       ChrPtr(TP->Tokens->FlatToken));
-               */
-               StrBufPrintf(Info, "%s [%s]  %s; [%s]", 
-                            Type, 
-                            Err, 
-                            ChrPtr(Error), 
-                            ChrPtr(TP->Tokens->FlatToken));
-
-
-               SerializeJson(WC->WFBuf, WildFireException(SKEY(TP->Tokens->FileName),
-                                                       TP->Tokens->Line,
-                                                       Info,
-                                                       1), 1);
+                  StrBufAppendPrintf(                                                          
+                  Target,                                                              
+                  "<pre>\n%s [%s] (in '%s' line %ld); %s\n[%s]\n</pre>\n",
+                  Type, 
+                  Err, 
+                  ChrPtr(TP->Tokens->FileName),
+                  TP->Tokens->Line,
+                  ChrPtr(Error),
+                  ChrPtr(TP->Tokens->FlatToken));
+                */
+               StrBufPrintf(Info, "%s [%s]  %s; [%s]", Type, Err, ChrPtr(Error), ChrPtr(TP->Tokens->FlatToken));
+
+
+               SerializeJson(WC->WFBuf, WildFireException(SKEY(TP->Tokens->FileName), TP->Tokens->Line, Info, 1), 1);
        }
        else {
-               StrBufPrintf(Info, "%s [%s]  %s; [%s]", 
-                            Type, 
-                            Err, 
-                            ChrPtr(Error), 
-                            ChrPtr(TP->Tokens->FlatToken));
+               StrBufPrintf(Info, "%s [%s]  %s; [%s]", Type, Err, ChrPtr(Error), ChrPtr(TP->Tokens->FlatToken));
                SerializeJson(WC->WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1);
        }
        FreeStrBuf(&Info);
@@ -303,86 +265,72 @@ void LogTemplateError (StrBuf *Target, const char *Type, int ErrorPos, WCTemplpu
 }
 
 
-void LogError (StrBuf *Target, const char *Type, const char *Format, ...) {
+void LogError(StrBuf * Target, const char *Type, const char *Format, ...) {
        StrBuf *Error;
        StrBuf *Info;
-        va_list arg_ptr;
+       va_list arg_ptr;
 
        Info = NewStrBuf();
        Error = NewStrBuf();
 
-        va_start(arg_ptr, Format);
+       va_start(arg_ptr, Format);
        StrBufVAppendPrintf(Error, Format, arg_ptr);
        va_end(arg_ptr);
 
        syslog(LOG_WARNING, "%s", ChrPtr(Error));
 
-       if (WC->WFBuf == NULL) WC->WFBuf = NewStrBuf();
+       if (WC->WFBuf == NULL)
+               WC->WFBuf = NewStrBuf();
 
-       SerializeJson(WC->WFBuf, WildFireException(Type, strlen(Type),
-                                                   0,
-                                                   Info,
-                                                   1), 1);
+       SerializeJson(WC->WFBuf, WildFireException(Type, strlen(Type), 0, Info, 1), 1);
 
        FreeStrBuf(&Info);
        FreeStrBuf(&Error);
 }
 
 
-void RegisterNS(const char *NSName, 
-               long len, 
-               int nMinArgs, 
-               int nMaxArgs, 
-               WCHandlerFunc HandlerFunc, 
-               WCPreevalFunc PreevalFunc,
-               CtxType ContextRequired)
-{
+void RegisterNS(const char *NSName,
+               long len,
+               int nMinArgs, int nMaxArgs, WCHandlerFunc HandlerFunc, WCPreevalFunc PreevalFunc, CtxType ContextRequired) {
        HashHandler *NewHandler;
-       
-       NewHandler = (HashHandler*) malloc(sizeof(HashHandler));
+
+       NewHandler = (HashHandler *) malloc(sizeof(HashHandler));
        memset(NewHandler, 0, sizeof(HashHandler));
        NewHandler->Filter.nMinArgs = nMinArgs;
        NewHandler->Filter.nMaxArgs = nMaxArgs;
        NewHandler->Filter.ContextType = ContextRequired;
 
        NewHandler->PreEvalFunc = PreevalFunc;
-       NewHandler->HandlerFunc = HandlerFunc;  
+       NewHandler->HandlerFunc = HandlerFunc;
        Put(GlobalNS, NSName, len, NewHandler, NULL);
 }
 
 
 
-int CheckContext(StrBuf *Target, ContextFilter *Need, WCTemplputParams *TP, const char *ErrType)
-{
+int CheckContext(StrBuf * Target, ContextFilter * Need, WCTemplputParams * TP, const char *ErrType) {
        WCTemplputParams *TPP = TP;
-       
-       if ((Need != NULL) &&
-           (Need->ContextType != CTX_NONE) && 
-           (Need->ContextType != TPP->Filter.ContextType)) {
-
-               while ((TPP != NULL) && 
-                      (Need->ContextType != TPP->Filter.ContextType))
-               {
+
+       if ((Need != NULL) && (Need->ContextType != CTX_NONE) && (Need->ContextType != TPP->Filter.ContextType)) {
+
+               while ((TPP != NULL) && (Need->ContextType != TPP->Filter.ContextType)) {
                        TPP = TPP->Super;
                }
 
                if (TPP != NULL)
                        return 1;
 
-                LogTemplateError(
-                        Target, ErrType, ERR_NAME, TP,
-                       "  WARNING: requires Context: [%s], have [%s]!", 
-                       ContextName(Need->ContextType), 
-                       ContextName(TP->Filter.ContextType));
+               LogTemplateError(Target, ErrType, ERR_NAME, TP,
+                                "  WARNING: requires Context: [%s], have [%s]!",
+                                ContextName(Need->ContextType), ContextName(TP->Filter.ContextType));
                return 0;
        }
        return 1;
 }
 
-void FreeToken(WCTemplateToken **Token) {
-       int i; 
+void FreeToken(WCTemplateToken ** Token) {
+       int i;
        FreeStrBuf(&(*Token)->FlatToken);
-       if ((*Token)->HaveParameters) 
+       if ((*Token)->HaveParameters)
                for (i = 0; i < (*Token)->nParameters; i++)
                        free((*Token)->Params[i]);
        free(*Token);
@@ -392,10 +340,10 @@ void FreeToken(WCTemplateToken **Token) {
 
 void FreeWCTemplate(void *vFreeMe) {
        int i;
-       WCTemplate *FreeMe = (WCTemplate*)vFreeMe;
+       WCTemplate *FreeMe = (WCTemplate *) vFreeMe;
 
        if (FreeMe->TokenSpace > 0) {
-               for (i = 0; i < FreeMe->nTokensUsed; i ++) {
+               for (i = 0; i < FreeMe->nTokensUsed; i++) {
                        FreeToken(&FreeMe->Tokens[i]);
                }
                free(FreeMe->Tokens);
@@ -406,12 +354,7 @@ void FreeWCTemplate(void *vFreeMe) {
        free(FreeMe);
 }
 
-int HaveTemplateTokenString(StrBuf *Target, 
-                           WCTemplputParams *TP,
-                           int N,
-                           const char **Value, 
-                           long *len)
-{
+int HaveTemplateTokenString(StrBuf * Target, WCTemplputParams * TP, int N, const char **Value, long *len) {
        if (N >= TP->Tokens->nParameters) {
                return 0;
        }
@@ -432,13 +375,11 @@ int HaveTemplateTokenString(StrBuf *Target,
        }
 }
 
-void GetTemplateTokenString(StrBuf *Target, WCTemplputParams *TP, int N, const char **Value, long *len) {
+void GetTemplateTokenString(StrBuf * Target, WCTemplputParams * TP, int N, const char **Value, long *len) {
        StrBuf *Buf;
 
        if (N >= TP->Tokens->nParameters) {
-               LogTemplateError(Target, 
-                                "TokenParameter", N, TP, 
-                                "invalid token %d. this shouldn't have come till here.\n", N);
+               LogTemplateError(Target, "TokenParameter", N, TP, "invalid token %d. this shouldn't have come till here.\n", N);
                *Value = "";
                *len = 0;
                return;
@@ -453,21 +394,21 @@ void GetTemplateTokenString(StrBuf *Target, WCTemplputParams *TP, int N, const c
                break;
        case TYPE_BSTR:
                if (TP->Tokens->Params[N]->len == 0) {
-                       LogTemplateError(Target, 
-                                        "TokenParameter", N, TP, 
+                       LogTemplateError(Target,
+                                        "TokenParameter", N, TP,
                                         "Requesting parameter %d; of type BSTR, empty lookup string not admitted.", N);
                        *len = 0;
                        *Value = EmptyStr;
                        break;
                }
-               Buf = (StrBuf*) SBstr(TKEY(N));
+               Buf = (StrBuf *) SBstr(TKEY(N));
                *Value = ChrPtr(Buf);
                *len = StrLength(Buf);
                break;
        case TYPE_PREFSTR:
                if (TP->Tokens->Params[N]->len == 0) {
-                       LogTemplateError(Target, 
-                                        "TokenParameter", N, TP, 
+                       LogTemplateError(Target,
+                                        "TokenParameter", N, TP,
                                         "Requesting parameter %d; of type PREFSTR, empty lookup string not admitted.", N);
                        *len = 0;
                        *Value = EmptyStr;
@@ -479,8 +420,8 @@ void GetTemplateTokenString(StrBuf *Target, WCTemplputParams *TP, int N, const c
                break;
        case TYPE_ROOMPREFSTR:
                if (TP->Tokens->Params[N]->len == 0) {
-                       LogTemplateError(Target, 
-                                        "TokenParameter", N, TP, 
+                       LogTemplateError(Target,
+                                        "TokenParameter", N, TP,
                                         "Requesting parameter %d; of type PREFSTR, empty lookup string not admitted.", N);
                        *len = 0;
                        *Value = EmptyStr;
@@ -491,14 +432,10 @@ void GetTemplateTokenString(StrBuf *Target, WCTemplputParams *TP, int N, const c
                *len = StrLength(Buf);
                break;
        case TYPE_LONG:
-               LogTemplateError(Target, 
-                                "TokenParameter", N, TP, 
-                                "Requesting parameter %d; of type LONG, want string.", N);
+               LogTemplateError(Target, "TokenParameter", N, TP, "Requesting parameter %d; of type LONG, want string.", N);
                break;
        case TYPE_PREFINT:
-               LogTemplateError(Target, 
-                                "TokenParameter", N, TP, 
-                                "Requesting parameter %d; of type PREFINT, want string.", N);
+               LogTemplateError(Target, "TokenParameter", N, TP, "Requesting parameter %d; of type PREFINT, want string.", N);
                break;
        case TYPE_GETTEXT:
                *Value = _(TP->Tokens->Params[N]->Start);
@@ -506,8 +443,8 @@ void GetTemplateTokenString(StrBuf *Target, WCTemplputParams *TP, int N, const c
                break;
        case TYPE_SUBTEMPLATE:
                if (TP->Tokens->Params[N]->len == 0) {
-                       LogTemplateError(Target, 
-                                        "TokenParameter", N, TP, 
+                       LogTemplateError(Target,
+                                        "TokenParameter", N, TP,
                                         "Requesting parameter %d; of type SUBTEMPLATE, empty lookup string not admitted.", N);
                        *len = 0;
                        *Value = EmptyStr;
@@ -524,20 +461,16 @@ void GetTemplateTokenString(StrBuf *Target, WCTemplputParams *TP, int N, const c
                break;
 
        default:
-               LogTemplateError(Target, 
-                                "TokenParameter", N, TP, 
-                                "unknown param type %d; [%d]", N, TP->Tokens->Params[N]->Type);
+               LogTemplateError(Target, "TokenParameter", N, TP, "unknown param type %d; [%d]", N, TP->Tokens->Params[N]->Type);
                break;
        }
 }
 
-long GetTemplateTokenNumber(StrBuf *Target, WCTemplputParams *TP, int N, long dflt) {
+long GetTemplateTokenNumber(StrBuf * Target, WCTemplputParams * TP, int N, long dflt) {
        long Ret;
        if (N >= TP->Tokens->nParameters) {
-               LogTemplateError(Target, 
-                                "TokenParameter", N, TP, 
-                                "invalid token %d. this shouldn't have come till here.\n", N);
-               wc_backtrace(LOG_DEBUG); 
+               LogTemplateError(Target, "TokenParameter", N, TP, "invalid token %d. this shouldn't have come till here.\n", N);
+               wc_backtrace(LOG_DEBUG);
                return 0;
        }
 
@@ -548,20 +481,18 @@ long GetTemplateTokenNumber(StrBuf *Target, WCTemplputParams *TP, int N, long df
                break;
        case TYPE_BSTR:
                if (TP->Tokens->Params[N]->len == 0) {
-                       LogTemplateError(Target, 
-                                        "TokenParameter", N, TP, 
+                       LogTemplateError(Target,
+                                        "TokenParameter", N, TP,
                                         "Requesting parameter %d; of type BSTR, empty lookup string not admitted.", N);
                        return 0;
                }
-               return  LBstr(TKEY(N));
+               return LBstr(TKEY(N));
                break;
        case TYPE_PREFSTR:
-               LogTemplateError(Target, 
-                                "TokenParameter", N, TP, 
-                                "requesting a prefstring in param %d want a number", N);
+               LogTemplateError(Target, "TokenParameter", N, TP, "requesting a prefstring in param %d want a number", N);
                if (TP->Tokens->Params[N]->len == 0) {
-                       LogTemplateError(Target, 
-                                        "TokenParameter", N, TP, 
+                       LogTemplateError(Target,
+                                        "TokenParameter", N, TP,
                                         "Requesting parameter %d; of type PREFSTR, empty lookup string not admitted.", N);
                        return 0;
                }
@@ -569,12 +500,10 @@ long GetTemplateTokenNumber(StrBuf *Target, WCTemplputParams *TP, int N, long df
                        return Ret;
                return 0;
        case TYPE_ROOMPREFSTR:
-               LogTemplateError(Target, 
-                                "TokenParameter", N, TP, 
-                                "requesting a prefstring in param %d want a number", N);
+               LogTemplateError(Target, "TokenParameter", N, TP, "requesting a prefstring in param %d want a number", N);
                if (TP->Tokens->Params[N]->len == 0) {
-                       LogTemplateError(Target, 
-                                        "TokenParameter", N, TP, 
+                       LogTemplateError(Target,
+                                        "TokenParameter", N, TP,
                                         "Requesting parameter %d; of type PREFSTR, empty lookup string not admitted.", N);
                        return 0;
                }
@@ -586,28 +515,23 @@ long GetTemplateTokenNumber(StrBuf *Target, WCTemplputParams *TP, int N, long df
                return TP->Tokens->Params[N]->lvalue;
        case TYPE_PREFINT:
                if (TP->Tokens->Params[N]->len == 0) {
-                       LogTemplateError(Target, 
-                                        "TokenParameter", N, TP, 
+                       LogTemplateError(Target,
+                                        "TokenParameter", N, TP,
                                         "Requesting parameter %d; of type PREFINT, empty lookup string not admitted.", N);
                        return 0;
                }
                if (get_PREF_LONG(TKEY(N), &Ret, dflt))
                        return Ret;
-               return 0;               
+               return 0;
        case TYPE_GETTEXT:
-               LogTemplateError(Target, 
-                                "TokenParameter", N, TP, 
-                                "requesting a I18N string in param %d; want a number", N);
+               LogTemplateError(Target, "TokenParameter", N, TP, "requesting a I18N string in param %d; want a number", N);
                return 0;
        case TYPE_SUBTEMPLATE:
-               LogTemplateError(Target, 
-                                "TokenParameter", N, TP, 
-                                "requesting a subtemplate in param %d; not supported for numbers", N);
+               LogTemplateError(Target,
+                                "TokenParameter", N, TP, "requesting a subtemplate in param %d; not supported for numbers", N);
                return 0;
        default:
-               LogTemplateError(Target, 
-                                "TokenParameter", N, TP, 
-                                "unknown param type %d; [%d]", N, TP->Tokens->Params[N]->Type);
+               LogTemplateError(Target, "TokenParameter", N, TP, "unknown param type %d; [%d]", N, TP->Tokens->Params[N]->Type);
                return 0;
        }
 }
@@ -618,23 +542,18 @@ long GetTemplateTokenNumber(StrBuf *Target, WCTemplputParams *TP, int N, long df
  * Source = the string we should put into the template
  * FormatTypeIndex = where should we look for escape types if?
  */
-void StrBufAppendTemplate(StrBuf *Target, 
-                         WCTemplputParams *TP,
-                         const StrBuf *Source, int FormatTypeIndex)
-{
+void StrBufAppendTemplate(StrBuf * Target, WCTemplputParams * TP, const StrBuf * Source, int FormatTypeIndex) {
        const char *pFmt = NULL;
        char EscapeAs = ' ';
 
        if ((FormatTypeIndex < TP->Tokens->nParameters) &&
            (TP->Tokens->Params[FormatTypeIndex] != NULL) &&
-           (TP->Tokens->Params[FormatTypeIndex]->Type == TYPE_STR) &&
-           (TP->Tokens->Params[FormatTypeIndex]->len >= 1)) {
+           (TP->Tokens->Params[FormatTypeIndex]->Type == TYPE_STR) && (TP->Tokens->Params[FormatTypeIndex]->len >= 1)) {
                pFmt = TP->Tokens->Params[FormatTypeIndex]->Start;
                EscapeAs = *pFmt;
        }
 
-       switch(EscapeAs)
-       {
+       switch (EscapeAs) {
        case 'H':
                StrEscAppend(Target, Source, NULL, 0, 2);
                break;
@@ -651,9 +570,12 @@ void StrBufAppendTemplate(StrBuf *Target,
                StrBufUrlescAppend(Target, Source, NULL);
                break;
        case 'F':
-               if (pFmt != NULL)       pFmt++;
-               else                    pFmt = "JUSTIFY";
-               if (*pFmt == '\0')      pFmt = "JUSTIFY";
+               if (pFmt != NULL)
+                       pFmt++;
+               else
+                       pFmt = "JUSTIFY";
+               if (*pFmt == '\0')
+                       pFmt = "JUSTIFY";
                FmOut(Target, pFmt, Source);
                break;
        default:
@@ -666,22 +588,17 @@ void StrBufAppendTemplate(StrBuf *Target,
  * Source = the string we should put into the template
  * FormatTypeIndex = where should we look for escape types if?
  */
-void StrBufAppendTemplateStr(StrBuf *Target, 
-                            WCTemplputParams *TP,
-                            const char *Source, int FormatTypeIndex)
-{
+void StrBufAppendTemplateStr(StrBuf * Target, WCTemplputParams * TP, const char *Source, int FormatTypeIndex) {
        const char *pFmt = NULL;
        char EscapeAs = ' ';
 
        if ((FormatTypeIndex < TP->Tokens->nParameters) &&
-           (TP->Tokens->Params[FormatTypeIndex]->Type == TYPE_STR) &&
-           (TP->Tokens->Params[FormatTypeIndex]->len >= 1)) {
+           (TP->Tokens->Params[FormatTypeIndex]->Type == TYPE_STR) && (TP->Tokens->Params[FormatTypeIndex]->len >= 1)) {
                pFmt = TP->Tokens->Params[FormatTypeIndex]->Start;
                EscapeAs = *pFmt;
        }
 
-       switch(EscapeAs)
-       {
+       switch (EscapeAs) {
        case 'H':
                StrEscAppend(Target, NULL, Source, 0, 2);
                break;
@@ -690,13 +607,14 @@ void StrBufAppendTemplateStr(StrBuf *Target,
                break;
        case 'J':
                StrECMAEscAppend(Target, NULL, Source);
-         break;
+               break;
        case 'K':
                StrHtmlEcmaEscAppend(Target, NULL, Source, 0, 0);
-         break;
+               break;
        case 'U':
                StrBufUrlescAppend(Target, NULL, Source);
                break;
+
 /*
        case 'F':
                if (pFmt != NULL)       pFmt++;
@@ -711,27 +629,21 @@ void StrBufAppendTemplateStr(StrBuf *Target,
 }
 
 
-void PutNewToken(WCTemplate *Template, WCTemplateToken *NewToken)
-{
+void PutNewToken(WCTemplate * Template, WCTemplateToken * NewToken) {
        if (Template->nTokensUsed + 1 >= Template->TokenSpace) {
                if (Template->TokenSpace <= 0) {
-                       Template->Tokens = (WCTemplateToken**)malloc(
-                               sizeof(WCTemplateToken*) * 10);
-                       memset(Template->Tokens, 0, sizeof(WCTemplateToken*) * 10);
+                       Template->Tokens = (WCTemplateToken **) malloc(sizeof(WCTemplateToken *) * 10);
+                       memset(Template->Tokens, 0, sizeof(WCTemplateToken *) * 10);
                        Template->TokenSpace = 10;
                }
                else {
                        WCTemplateToken **NewTokens;
 
-                       NewTokens= (WCTemplateToken**) malloc(
-                               sizeof(WCTemplateToken*) * Template->TokenSpace * 2);
+                       NewTokens = (WCTemplateToken **) malloc(sizeof(WCTemplateToken *) * Template->TokenSpace * 2);
 
-                       memset(NewTokens, 
-                              0, sizeof(WCTemplateToken*) * Template->TokenSpace * 2);
+                       memset(NewTokens, 0, sizeof(WCTemplateToken *) * Template->TokenSpace * 2);
 
-                       memcpy(NewTokens, 
-                              Template->Tokens, 
-                              sizeof(WCTemplateToken*) * Template->nTokensUsed);
+                       memcpy(NewTokens, Template->Tokens, sizeof(WCTemplateToken *) * Template->nTokensUsed);
 
                        free(Template->Tokens);
                        Template->TokenSpace *= 2;
@@ -741,14 +653,9 @@ void PutNewToken(WCTemplate *Template, WCTemplateToken *NewToken)
        Template->Tokens[(Template->nTokensUsed)++] = NewToken;
 }
 
-int GetNextParameter(StrBuf *Buf, 
-                    const char **pCh, 
-                    const char *pe, 
-                    WCTemplateToken *Tokens, 
-                    WCTemplate *pTmpl, 
-                    WCTemplputParams *TP, 
-                    TemplateParam **pParm)
-{
+int GetNextParameter(StrBuf * Buf,
+                    const char **pCh,
+                    const char *pe, WCTemplateToken * Tokens, WCTemplate * pTmpl, WCTemplputParams * TP, TemplateParam ** pParm) {
        const char *pch = *pCh;
        const char *pchs, *pche;
        TemplateParam *Parm;
@@ -760,60 +667,58 @@ int GetNextParameter(StrBuf *Buf,
        Parm->Type = TYPE_STR;
 
        /* Skip leading whitespaces */
-       while ((*pch == ' ' )||
-              (*pch == '\t')||
-              (*pch == '\r')||
-              (*pch == '\n')) pch ++;
+       while ((*pch == ' ') || (*pch == '\t') || (*pch == '\r') || (*pch == '\n'))
+               pch++;
 
        if (*pch == ':') {
                Parm->Type = TYPE_PREFSTR;
-               pch ++;
+               pch++;
                if (*pch == '(') {
-                       pch ++;
+                       pch++;
                        ParamBrace = 1;
                }
        }
        else if (*pch == '.') {
                Parm->Type = TYPE_ROOMPREFSTR;
-               pch ++;
+               pch++;
                if (*pch == '(') {
-                       pch ++;
+                       pch++;
                        ParamBrace = 1;
                }
        }
        else if (*pch == ';') {
                Parm->Type = TYPE_PREFINT;
-               pch ++;
+               pch++;
                if (*pch == '(') {
-                       pch ++;
+                       pch++;
                        ParamBrace = 1;
                }
        }
        else if (*pch == '#') {
                Parm->Type = TYPE_INTDEFINE;
-               pch ++;
+               pch++;
        }
        else if (*pch == '_') {
                Parm->Type = TYPE_GETTEXT;
-               pch ++;
+               pch++;
                if (*pch == '(') {
-                       pch ++;
+                       pch++;
                        ParamBrace = 1;
                }
        }
        else if (*pch == 'B') {
                Parm->Type = TYPE_BSTR;
-               pch ++;
+               pch++;
                if (*pch == '(') {
-                       pch ++;
+                       pch++;
                        ParamBrace = 1;
                }
        }
        else if (*pch == '=') {
                Parm->Type = TYPE_SUBTEMPLATE;
-               pch ++;
+               pch++;
                if (*pch == '(') {
-                       pch ++;
+                       pch++;
                        ParamBrace = 1;
                }
        }
@@ -824,40 +729,34 @@ int GetNextParameter(StrBuf *Buf,
        else if (*pch == '\'')
                quote = '\'';
        if (quote != '\0') {
-               pch ++;
+               pch++;
                pchs = pch;
-               while (pch <= pe &&
-                      ((*pch != quote) ||
-                       ( (pch > pchs) && (*(pch - 1) == '\\'))
-                              )) {
-                       pch ++;
+               while (pch <= pe && ((*pch != quote) || ((pch > pchs) && (*(pch - 1) == '\\'))
+                      )) {
+                       pch++;
                }
                pche = pch;
                if (*pch != quote) {
                        syslog(LOG_WARNING, "Error (in '%s' line %ld); "
-                               "evaluating template param [%s] in Token [%s]\n",
-                               ChrPtr(pTmpl->FileName),
-                               Tokens->Line,
-                               ChrPtr(Tokens->FlatToken),
-                               *pCh);
-                       pch ++;
+                              "evaluating template param [%s] in Token [%s]\n",
+                              ChrPtr(pTmpl->FileName), Tokens->Line, ChrPtr(Tokens->FlatToken), *pCh);
+                       pch++;
                        free(Parm);
                        *pParm = NULL;
                        return 0;
                }
                else {
-                       StrBufPeek(Buf, pch, -1, '\0');         
-                       if (LoadTemplates > 1) {                        
+                       StrBufPeek(Buf, pch, -1, '\0');
+                       if (LoadTemplates > 1) {
                                syslog(LOG_DEBUG,
-                                       "DBG: got param [%s] "SIZE_T_FMT" "SIZE_T_FMT"\n", 
-                                       pchs, pche - pchs, strlen(pchs)
-                               );
+                                      "DBG: got param [%s] " SIZE_T_FMT " " SIZE_T_FMT "\n", pchs, pche - pchs, strlen(pchs)
+                                   );
                        }
                        Parm->Start = pchs;
                        Parm->len = pche - pchs;
-                       pch ++; /* move after trailing quote */
+                       pch++;  /* move after trailing quote */
                        if (ParamBrace && (*pch == ')')) {
-                               pch ++;
+                               pch++;
                        }
 
                }
@@ -865,13 +764,10 @@ int GetNextParameter(StrBuf *Buf,
        else {
                Parm->Type = TYPE_LONG;
                pchs = pch;
-               while ((pch <= pe) &&
-                      (isdigit(*pch) ||
-                       (*pch == '+') ||
-                       (*pch == '-')))
-                       pch ++;
-               pch ++;
-               if (pch - pchs > 1){
+               while ((pch <= pe) && (isdigit(*pch) || (*pch == '+') || (*pch == '-')))
+                       pch++;
+               pch++;
+               if (pch - pchs > 1) {
                        StrBufPeek(Buf, pch, -1, '\0');
                        Parm->lvalue = atol(pchs);
                        Parm->Start = pchs;
@@ -879,6 +775,7 @@ int GetNextParameter(StrBuf *Buf,
                }
                else {
                        Parm->lvalue = 0;
+
 /* TODO whUT?
                        syslog(LOG_DEBUG, "Error (in '%s' line %ld); "
                                "evaluating long template param [%s] in Token [%s]\n",
@@ -892,161 +789,131 @@ int GetNextParameter(StrBuf *Buf,
                        return 0;
                }
        }
-       while ((*pch == ' ' )||
-              (*pch == '\t')||
-              (*pch == '\r')||
-              (*pch == ',' )||
-              (*pch == '\n')) pch ++;
+       while ((*pch == ' ') || (*pch == '\t') || (*pch == '\r') || (*pch == ',') || (*pch == '\n'))
+               pch++;
 
-       switch (Parm->Type)
-       {
+       switch (Parm->Type) {
        case TYPE_GETTEXT:
                if (DumpTemplateI18NStrings) {
                        StrBufAppendPrintf(I18nDump, "_(\"%s\");\n", Parm->Start);
                }
                break;
-       case TYPE_INTDEFINE: {
-               void *vPVal;
-               
-               if (GetHash(Defines, Parm->Start, Parm->len, &vPVal) &&
-                   (vPVal != NULL))
-               {
-                       long *PVal;
-                       PVal = (long*) vPVal;
-               
-                       Parm->lvalue = *PVal;
-               }
-               else if (strchr(Parm->Start, '|') != NULL)
-               {
-                       const char *Pos;
-                       StrBuf *pToken;
-                       StrBuf *Match;
-
-                       Parm->MaskBy = eOR;
-                       pToken = NewStrBufPlain (Parm->Start, Parm->len);
-                       Match = NewStrBufPlain (NULL, Parm->len);
-                       Pos = ChrPtr(pToken);
-                       
-                       while ((Pos != NULL) && (Pos != StrBufNOTNULL))
-                       {
-                               StrBufExtract_NextToken(Match, pToken, &Pos, '|');
-                               StrBufTrim(Match);
-                               if (StrLength (Match) > 0)
-                               {
-                                       if (GetHash(Defines, SKEY(Match), &vPVal) &&
-                                           (vPVal != NULL))
-                                       {
-                                               long *PVal;
-                                               PVal = (long*) vPVal;
-                                               
-                                               Parm->lvalue |= *PVal;
-                                       }
-                                       else {
-                                               LogTemplateError(NULL, "Define", 
-                                                                Tokens->nParameters,
-                                                                TP,
-                                                                "%s isn't known!!",
-                                                                ChrPtr(Match));
+       case TYPE_INTDEFINE:{
+                       void *vPVal;
 
+                       if (GetHash(Defines, Parm->Start, Parm->len, &vPVal) && (vPVal != NULL)) {
+                               long *PVal;
+                               PVal = (long *) vPVal;
+
+                               Parm->lvalue = *PVal;
+                       }
+                       else if (strchr(Parm->Start, '|') != NULL) {
+                               const char *Pos;
+                               StrBuf *pToken;
+                               StrBuf *Match;
+
+                               Parm->MaskBy = eOR;
+                               pToken = NewStrBufPlain(Parm->Start, Parm->len);
+                               Match = NewStrBufPlain(NULL, Parm->len);
+                               Pos = ChrPtr(pToken);
+
+                               while ((Pos != NULL) && (Pos != StrBufNOTNULL)) {
+                                       StrBufExtract_NextToken(Match, pToken, &Pos, '|');
+                                       StrBufTrim(Match);
+                                       if (StrLength(Match) > 0) {
+                                               if (GetHash(Defines, SKEY(Match), &vPVal) && (vPVal != NULL)) {
+                                                       long *PVal;
+                                                       PVal = (long *) vPVal;
+
+                                                       Parm->lvalue |= *PVal;
+                                               }
+                                               else {
+                                                       LogTemplateError(NULL, "Define",
+                                                                        Tokens->nParameters,
+                                                                        TP, "%s isn't known!!", ChrPtr(Match));
+
+                                               }
                                        }
                                }
+                               FreeStrBuf(&pToken);
+                               FreeStrBuf(&Match);
                        }
-                       FreeStrBuf(&pToken);
-                       FreeStrBuf(&Match);
-               }
-               else if (strchr(Parm->Start, '&') != NULL)
-               {
-                       const char *Pos;
-                       StrBuf *pToken;
-                       StrBuf *Match;
-
-                       Parm->MaskBy = eAND;
-                       pToken = NewStrBufPlain (Parm->Start, Parm->len);
-                       Match = NewStrBufPlain (NULL, Parm->len);
-                       Pos = ChrPtr(pToken);
-                       
-                       while ((Pos != NULL) && (Pos != StrBufNOTNULL))
-                       {
-                               StrBufExtract_NextToken(Match, pToken, &Pos, '&');
-                               StrBufTrim(Match);
-                               if (StrLength (Match) > 0)
-                               {
-                                       if (GetHash(Defines, SKEY(Match), &vPVal) &&
-                                           (vPVal != NULL))
-                                       {
-                                               long *PVal;
-                                               PVal = (long*) vPVal;
-                                               
-                                               Parm->lvalue |= *PVal;
-                                       }
-                                       else {
-                                               LogTemplateError(NULL, "Define", 
-                                                                Tokens->nParameters,
-                                                                TP,
-                                                                "%s isn't known!!",
-                                                                ChrPtr(Match));
+                       else if (strchr(Parm->Start, '&') != NULL) {
+                               const char *Pos;
+                               StrBuf *pToken;
+                               StrBuf *Match;
+
+                               Parm->MaskBy = eAND;
+                               pToken = NewStrBufPlain(Parm->Start, Parm->len);
+                               Match = NewStrBufPlain(NULL, Parm->len);
+                               Pos = ChrPtr(pToken);
+
+                               while ((Pos != NULL) && (Pos != StrBufNOTNULL)) {
+                                       StrBufExtract_NextToken(Match, pToken, &Pos, '&');
+                                       StrBufTrim(Match);
+                                       if (StrLength(Match) > 0) {
+                                               if (GetHash(Defines, SKEY(Match), &vPVal) && (vPVal != NULL)) {
+                                                       long *PVal;
+                                                       PVal = (long *) vPVal;
+
+                                                       Parm->lvalue |= *PVal;
+                                               }
+                                               else {
+                                                       LogTemplateError(NULL, "Define",
+                                                                        Tokens->nParameters,
+                                                                        TP, "%s isn't known!!", ChrPtr(Match));
 
+                                               }
                                        }
                                }
+                               FreeStrBuf(&Match);
+                               FreeStrBuf(&pToken);
                        }
-                       FreeStrBuf(&Match);
-                       FreeStrBuf(&pToken);
-               }
-               else {
+                       else {
 
 
-                       LogTemplateError(NULL, "Define", 
-                                        Tokens->nParameters,
-                                        TP,
-                                        "%s isn't known!!",
-                                        Parm->Start);
-               }}
+                               LogTemplateError(NULL, "Define", Tokens->nParameters, TP, "%s isn't known!!", Parm->Start);
+                       }
+               }
                break;
        case TYPE_SUBTEMPLATE:{
-               void *vTmpl;
-               /* well, we don't check the mobile stuff here... */
-               if (!GetHash(LocalTemplateCache, Parm->Start, Parm->len, &vTmpl) &&
-                   !GetHash(TemplateCache, Parm->Start, Parm->len, &vTmpl)) {
-                       LogTemplateError(NULL, 
-                                        "SubTemplate", 
-                                        Tokens->nParameters,
-                                        TP,
-                                        "referenced here doesn't exist");
-               }}
+                       void *vTmpl;
+                       /* well, we don't check the mobile stuff here... */
+                       if (!GetHash(LocalTemplateCache, Parm->Start, Parm->len, &vTmpl) &&
+                           !GetHash(TemplateCache, Parm->Start, Parm->len, &vTmpl)) {
+                               LogTemplateError(NULL, "SubTemplate", Tokens->nParameters, TP, "referenced here doesn't exist");
+                       }
+               }
                break;
        }
        *pCh = pch;
        return 1;
 }
 
-WCTemplateToken *NewTemplateSubstitute(StrBuf *Buf, 
-                                      const char *pStart, 
-                                      const char *pTokenStart, 
-                                      const char *pTokenEnd, 
-                                      long Line,
-                                      WCTemplate *pTmpl)
-{
+WCTemplateToken *NewTemplateSubstitute(StrBuf * Buf,
+                                      const char *pStart,
+                                      const char *pTokenStart, const char *pTokenEnd, long Line, WCTemplate * pTmpl) {
        void *vVar;
        const char *pch;
        WCTemplateToken *NewToken;
        WCTemplputParams TP;
 
-       NewToken = (WCTemplateToken*)malloc(sizeof(WCTemplateToken));
+       NewToken = (WCTemplateToken *) malloc(sizeof(WCTemplateToken));
        memset(NewToken, 0, sizeof(WCTemplateToken));
        TP.Tokens = NewToken;
-       NewToken->FileName = pTmpl->FileName; /* to print meaningfull log messages... */
+       NewToken->FileName = pTmpl->FileName;   /* to print meaningfull log messages... */
        NewToken->Flags = 0;
        NewToken->Line = Line + 1;
        NewToken->pTokenStart = pTokenStart;
        NewToken->TokenStart = pTokenStart - pStart;
-       NewToken->TokenEnd =  (pTokenEnd - pStart) - NewToken->TokenStart;
+       NewToken->TokenEnd = (pTokenEnd - pStart) - NewToken->TokenStart;
        NewToken->pTokenEnd = pTokenEnd;
        NewToken->NameEnd = NewToken->TokenEnd - 2;
        NewToken->PreEval = NULL;
        NewToken->FlatToken = NewStrBufPlain(pTokenStart + 2, pTokenEnd - pTokenStart - 2);
        StrBufShrinkToFit(NewToken->FlatToken, 1);
 
-       StrBufPeek(Buf, pTokenStart, + 1, '\0');
+       StrBufPeek(Buf, pTokenStart, +1, '\0');
        StrBufPeek(Buf, pTokenEnd, -1, '\0');
        pch = NewToken->pName = pTokenStart + 2;
 
@@ -1057,39 +924,30 @@ WCTemplateToken *NewTemplateSubstitute(StrBuf *Buf,
                if (*pch == '(') {
                        StrBufPeek(Buf, pch, -1, '\0');
                        NewToken->NameEnd = pch - NewToken->pName;
-                       pch ++;
+                       pch++;
                        if (*(pTokenEnd - 1) != ')') {
-                               LogTemplateError(
-                                       NULL, "Parseerror", ERR_NAME, &TP, 
-                                       "Warning, Non welformed Token; missing right parenthesis");
+                               LogTemplateError(NULL, "Parseerror", ERR_NAME, &TP,
+                                                "Warning, Non welformed Token; missing right parenthesis");
                        }
                        while (pch < pTokenEnd - 1) {
                                NewToken->nParameters++;
-                               if (GetNextParameter(Buf, 
-                                                    &pch, 
-                                                    pTokenEnd - 1, 
-                                                    NewToken, 
-                                                    pTmpl, 
-                                                    &TP, 
-                                                    &NewToken->Params[NewToken->nParameters - 1]))
-                               {
+                               if (GetNextParameter(Buf,
+                                                    &pch,
+                                                    pTokenEnd - 1,
+                                                    NewToken, pTmpl, &TP, &NewToken->Params[NewToken->nParameters - 1])) {
                                        NewToken->HaveParameters = 1;
                                        if (NewToken->nParameters >= MAXPARAM) {
-                                               LogTemplateError(
-                                                       NULL, "Parseerror", ERR_NAME, &TP,
-                                                       "only [%d] Params allowed in Tokens",
-                                                       MAXPARAM);
+                                               LogTemplateError(NULL, "Parseerror", ERR_NAME, &TP,
+                                                                "only [%d] Params allowed in Tokens", MAXPARAM);
 
                                                FreeToken(&NewToken);
                                                return NULL;
                                        }
                                }
-                               else break;
+                               else
+                                       break;
                        }
-                       if((NewToken->NameEnd == 1) &&
-                          (NewToken->HaveParameters == 1))
-                          
-                       {
+                       if ((NewToken->NameEnd == 1) && (NewToken->HaveParameters == 1)) {
                                if (*(NewToken->pName) == '_')
                                        NewToken->Flags = SV_GETTEXT;
                                else if (*(NewToken->pName) == '=')
@@ -1102,60 +960,48 @@ WCTemplateToken *NewTemplateSubstitute(StrBuf *Buf,
                                        NewToken->Flags = SV_NEG_CONDITIONAL;
                        }
                }
-               else pch ++;            
+               else
+                       pch++;
        }
-       
+
        switch (NewToken->Flags) {
        case 0:
                /* If we're able to find out more about the token, do it now while its fresh. */
                pch = NewToken->pName;
-               while (pch <  NewToken->pName + NewToken->NameEnd)
-               {
-                       if (((*pch >= 'A') && (*pch <= 'Z')) || 
-                           ((*pch >= '0') && (*pch <= '9')) ||
-                           (*pch == ':') || 
-                           (*pch == '-') ||
-                           (*pch == '_')) 
-                               pch ++;
-                       else
-                       {
-                               LogTemplateError(
-                                       NULL, "Token Name", ERR_NAME, &TP,
-                                       "contains illegal char: '%c'", 
-                                       *pch);
+               while (pch < NewToken->pName + NewToken->NameEnd) {
+                       if (((*pch >= 'A') && (*pch <= 'Z')) ||
+                           ((*pch >= '0') && (*pch <= '9')) || (*pch == ':') || (*pch == '-') || (*pch == '_'))
+                               pch++;
+                       else {
+                               LogTemplateError(NULL, "Token Name", ERR_NAME, &TP, "contains illegal char: '%c'", *pch);
                                pch++;
                        }
 
                }
                if (GetHash(GlobalNS, NewToken->pName, NewToken->NameEnd, &vVar)) {
                        HashHandler *Handler;
-                       Handler = (HashHandler*) vVar;
-                       if ((NewToken->nParameters < Handler->Filter.nMinArgs) || 
+                       Handler = (HashHandler *) vVar;
+                       if ((NewToken->nParameters < Handler->Filter.nMinArgs) ||
                            (NewToken->nParameters > Handler->Filter.nMaxArgs)) {
-                               LogTemplateError(
-                                       NULL, "Token", ERR_NAME, &TP,
-                                       "doesn't work with %d params", 
-                                       NewToken->nParameters);
+                               LogTemplateError(NULL, "Token", ERR_NAME, &TP,
+                                                "doesn't work with %d params", NewToken->nParameters);
 
                        }
                        else {
                                NewToken->PreEval = Handler;
-                               NewToken->Flags = SV_PREEVALUATED;              
+                               NewToken->Flags = SV_PREEVALUATED;
                                if (Handler->PreEvalFunc != NULL)
                                        Handler->PreEvalFunc(NewToken);
                        }
-               } else {
-                       LogTemplateError(
-                               NULL, "Token ", ERR_NAME, &TP,
-                               " isn't known to us.");
+               }
+               else {
+                       LogTemplateError(NULL, "Token ", ERR_NAME, &TP, " isn't known to us.");
                }
                break;
        case SV_GETTEXT:
                if ((NewToken->nParameters < 1) || (NewToken->nParameters > 2)) {
-                       LogTemplateError(                               
-                               NULL, "Gettext", ERR_NAME, &TP,
-                               "requires 1 or 2 parameter, you gave %d params", 
-                               NewToken->nParameters);
+                       LogTemplateError(NULL, "Gettext", ERR_NAME, &TP,
+                                        "requires 1 or 2 parameter, you gave %d params", NewToken->nParameters);
                        NewToken->Flags = 0;
                        break;
                }
@@ -1165,58 +1011,41 @@ WCTemplateToken *NewTemplateSubstitute(StrBuf *Buf,
                break;
        case SV_SUBTEMPL:
                if (NewToken->nParameters != 1) {
-                       LogTemplateError(
-                               NULL, "Subtemplates", ERR_NAME, &TP,
-                               "require exactly 1 parameter, you gave %d params", 
-                               NewToken->nParameters);
+                       LogTemplateError(NULL, "Subtemplates", ERR_NAME, &TP,
+                                        "require exactly 1 parameter, you gave %d params", NewToken->nParameters);
                        break;
                }
                else {
                        void *vTmpl;
                        /* well, we don't check the mobile stuff here... */
-                       if (!GetHash(LocalTemplateCache, 
-                                    NewToken->Params[0]->Start, 
-                                    NewToken->Params[0]->len, 
+                       if (!GetHash(LocalTemplateCache,
+                                    NewToken->Params[0]->Start,
+                                    NewToken->Params[0]->len,
                                     &vTmpl) &&
-                           !GetHash(TemplateCache, 
-                                    NewToken->Params[0]->Start, 
-                                    NewToken->Params[0]->len, 
-                                    &vTmpl)) {
-                               LogTemplateError(
-                                       NULL, "SubTemplate", ERR_PARM1, &TP,
-                                       "doesn't exist");
+                           !GetHash(TemplateCache, NewToken->Params[0]->Start, NewToken->Params[0]->len, &vTmpl)) {
+                               LogTemplateError(NULL, "SubTemplate", ERR_PARM1, &TP, "doesn't exist");
                        }
                }
                break;
        case SV_CUST_STR_CONDITIONAL:
        case SV_CONDITIONAL:
        case SV_NEG_CONDITIONAL:
-               if (NewToken->nParameters <2) {
-                       LogTemplateError(
-                               NULL, "Conditional", ERR_PARM1, &TP,
-                               "require at least 2 parameters, you gave %d params", 
-                               NewToken->nParameters);
+               if (NewToken->nParameters < 2) {
+                       LogTemplateError(NULL, "Conditional", ERR_PARM1, &TP,
+                                        "require at least 2 parameters, you gave %d params", NewToken->nParameters);
                        NewToken->Flags = 0;
                        break;
                }
                if (NewToken->Params[1]->lvalue == 0) {
-                       LogTemplateError(
-                               NULL, "Conditional", ERR_PARM1, &TP,
-                               "Conditional ID (Parameter 1) mustn't be 0!");
+                       LogTemplateError(NULL, "Conditional", ERR_PARM1, &TP, "Conditional ID (Parameter 1) mustn't be 0!");
                        NewToken->Flags = 0;
                        break;
                }
-               if (!GetHash(Conditionals, 
-                            NewToken->Params[0]->Start, 
-                            NewToken->Params[0]->len, 
-                            &vVar) || 
-                   (vVar == NULL)) {
-                       if ((NewToken->Params[0]->len == 1) &&
-                           (NewToken->Params[0]->Start[0] == 'X'))
+               if (!GetHash(Conditionals, NewToken->Params[0]->Start, NewToken->Params[0]->len, &vVar) || (vVar == NULL)) {
+                       if ((NewToken->Params[0]->len == 1) && (NewToken->Params[0]->Start[0] == 'X'))
                                break;
-                       LogTemplateError(
-                               NULL, "Conditional", ERR_PARM1, &TP,
-                               "Not found!");
+                       LogTemplateError(NULL, "Conditional", ERR_PARM1, &TP, "Not found!");
+
 /*
                        NewToken->Error = NewStrBuf();
                        StrBufAppendPrintf(
@@ -1244,7 +1073,7 @@ WCTemplateToken *NewTemplateSubstitute(StrBuf *Buf,
  * Display a variable-substituted template
  * templatename template file to load
  */
-void *prepare_template(StrBuf *filename, StrBuf *Key, HashList *PutThere) {
+void *prepare_template(StrBuf * filename, StrBuf * Key, HashList * PutThere) {
        WCTemplate *NewTemplate;
 
        NewTemplate = (WCTemplate *) malloc(sizeof(WCTemplate));
@@ -1255,7 +1084,7 @@ void *prepare_template(StrBuf *filename, StrBuf *Key, HashList *PutThere) {
        NewTemplate->nTokensUsed = 0;
        NewTemplate->TokenSpace = 0;
        NewTemplate->Tokens = NULL;
-       NewTemplate->MimeType = NewStrBufPlain(GuessMimeByFilename (SKEY(NewTemplate->FileName)), -1);
+       NewTemplate->MimeType = NewStrBufPlain(GuessMimeByFilename(SKEY(NewTemplate->FileName)), -1);
        if (strstr(ChrPtr(NewTemplate->MimeType), "text") != NULL) {
                StrBufAppendBufPlain(NewTemplate->MimeType, HKEY("; charset=utf-8"), 0);
        }
@@ -1272,7 +1101,7 @@ void *prepare_template(StrBuf *filename, StrBuf *Key, HashList *PutThere) {
  * Display a variable-substituted template
  * templatename template file to load
  */
-void *duplicate_template(WCTemplate *OldTemplate) {
+void *duplicate_template(WCTemplate * OldTemplate) {
        WCTemplate *NewTemplate;
 
        NewTemplate = (WCTemplate *) malloc(sizeof(WCTemplate));
@@ -1288,40 +1117,32 @@ void *duplicate_template(WCTemplate *OldTemplate) {
 }
 
 
-void SanityCheckTemplate(StrBuf *Target, WCTemplate *CheckMe) {
+void SanityCheckTemplate(StrBuf * Target, WCTemplate * CheckMe) {
        int i = 0;
        int j;
        int FoundConditionalEnd;
 
        for (i = 0; i < CheckMe->nTokensUsed; i++) {
-               switch(CheckMe->Tokens[i]->Flags) {
+               switch (CheckMe->Tokens[i]->Flags) {
                case SV_CONDITIONAL:
                case SV_NEG_CONDITIONAL:
                        FoundConditionalEnd = 0;
-                       if ((CheckMe->Tokens[i]->Params[0]->len == 1) && 
-                           (CheckMe->Tokens[i]->Params[0]->Start[0] == 'X'))
+                       if ((CheckMe->Tokens[i]->Params[0]->len == 1) && (CheckMe->Tokens[i]->Params[0]->Start[0] == 'X'))
                                break;
-                       for (j = i + 1; j < CheckMe->nTokensUsed; j++)
-                       {
+                       for (j = i + 1; j < CheckMe->nTokensUsed; j++) {
                                if (((CheckMe->Tokens[j]->Flags == SV_CONDITIONAL) ||
-                                    (CheckMe->Tokens[j]->Flags == SV_NEG_CONDITIONAL)) && 
-                                   (CheckMe->Tokens[i]->Params[1]->lvalue == 
-                                    CheckMe->Tokens[j]->Params[1]->lvalue))
-                               {
+                                    (CheckMe->Tokens[j]->Flags == SV_NEG_CONDITIONAL)) &&
+                                   (CheckMe->Tokens[i]->Params[1]->lvalue == CheckMe->Tokens[j]->Params[1]->lvalue)) {
                                        FoundConditionalEnd = 1;
                                        break;
                                }
 
                        }
-                       if (!FoundConditionalEnd)
-                       {
+                       if (!FoundConditionalEnd) {
                                WCTemplputParams TP;
                                memset(&TP, 0, sizeof(WCTemplputParams));
                                TP.Tokens = CheckMe->Tokens[i];
-                               LogTemplateError(
-                                       Target, "Token", ERR_PARM1, &TP,
-                                       "Conditional without Endconditional"
-                                       );
+                               LogTemplateError(Target, "Token", ERR_PARM1, &TP, "Conditional without Endconditional");
                        }
                        break;
                default:
@@ -1334,8 +1155,7 @@ void SanityCheckTemplate(StrBuf *Target, WCTemplate *CheckMe) {
  * Display a variable-substituted template
  * templatename template file to load
  */
-void *load_template(StrBuf *Target, WCTemplate *NewTemplate)
-{
+void *load_template(StrBuf * Target, WCTemplate * NewTemplate) {
        int fd;
        struct stat statbuf;
        const char *pS, *pE, *pch, *Err;
@@ -1343,22 +1163,19 @@ void *load_template(StrBuf *Target, WCTemplate *NewTemplate)
 
        fd = open(ChrPtr(NewTemplate->FileName), O_RDONLY);
        if (fd <= 0) {
-               syslog(LOG_WARNING, "ERROR: could not open template '%s' - %s\n",
-                       ChrPtr(NewTemplate->FileName), strerror(errno));
+               syslog(LOG_WARNING, "ERROR: could not open template '%s' - %s\n", ChrPtr(NewTemplate->FileName), strerror(errno));
                return NULL;
        }
 
        if (fstat(fd, &statbuf) == -1) {
-               syslog(LOG_WARNING, "ERROR: could not stat template '%s' - %s\n",
-                       ChrPtr(NewTemplate->FileName), strerror(errno));
+               syslog(LOG_WARNING, "ERROR: could not stat template '%s' - %s\n", ChrPtr(NewTemplate->FileName), strerror(errno));
                return NULL;
        }
 
        NewTemplate->Data = NewStrBufPlain(NULL, statbuf.st_size + 1);
        if (StrBufReadBLOB(NewTemplate->Data, &fd, 1, statbuf.st_size, &Err) < 0) {
                close(fd);
-               syslog(LOG_WARNING, "ERROR: reading template '%s' - %s<br>\n",
-                       ChrPtr(NewTemplate->FileName), strerror(errno));
+               syslog(LOG_WARNING, "ERROR: reading template '%s' - %s<br>\n", ChrPtr(NewTemplate->FileName), strerror(errno));
                return NULL;
        }
        close(fd);
@@ -1374,39 +1191,30 @@ void *load_template(StrBuf *Target, WCTemplate *NewTemplate)
                void *pv;
 
                /** Find one <? > */
-               for (; pch < pE; pch ++) {
-                       if ((*pch=='<')&&(*(pch + 1)=='?') &&
-                           !((pch == pS) && /* we must ommit a <?xml */
-                             (*(pch + 2) == 'x') && 
-                             (*(pch + 3) == 'm') && 
-                             (*(pch + 4) == 'l')))                          
+               for (; pch < pE; pch++) {
+                       if ((*pch == '<') && (*(pch + 1) == '?') && !((pch == pS) &&    /* we must ommit a <?xml */
+                                                                     (*(pch + 2) == 'x') &&
+                                                                     (*(pch + 3) == 'm') && (*(pch + 4) == 'l')))
                                break;
-                       if (*pch=='\n') Line ++;
+                       if (*pch == '\n')
+                               Line++;
                }
                if (pch >= pE)
                        continue;
                pts = pch;
 
                /** Found one? parse it. */
-               for (; pch <= pE - 1; pch ++) {
-                       if ((!InQuotes) &&
-                           ((*pch == '\'') || (*pch == '"')))
-                       {
+               for (; pch <= pE - 1; pch++) {
+                       if ((!InQuotes) && ((*pch == '\'') || (*pch == '"'))) {
                                InQuotes = *pch;
                        }
-                       else if (InQuotes && (InQuotes == *pch))
-                       {
+                       else if (InQuotes && (InQuotes == *pch)) {
                                InQuotes = '\0';
                        }
-                       else if ((InQuotes) &&
-                                (*pch == '\\') &&
-                                (*(pch + 1) == InQuotes))
-                       {
+                       else if ((InQuotes) && (*pch == '\\') && (*(pch + 1) == InQuotes)) {
                                pch++;
                        }
-                       else if ((!InQuotes) && 
-                                (*pch == '>'))
-                       {
+                       else if ((!InQuotes) && (*pch == '>')) {
                                break;
                        }
                }
@@ -1416,7 +1224,7 @@ void *load_template(StrBuf *Target, WCTemplate *NewTemplate)
                pv = NewTemplateSubstitute(NewTemplate->Data, pS, pts, pte, Line, NewTemplate);
                if (pv != NULL) {
                        PutNewToken(NewTemplate, pv);
-                       pch ++;
+                       pch++;
                }
        }
 
@@ -1425,16 +1233,14 @@ void *load_template(StrBuf *Target, WCTemplate *NewTemplate)
 }
 
 
-const char* PrintTemplate(void *vSubst)
-{
+const char *PrintTemplate(void *vSubst) {
        WCTemplate *Tmpl = vSubst;
 
        return ChrPtr(Tmpl->FileName);
 
 }
 
-int LoadTemplateDir(const StrBuf *DirName, HashList *big, const StrBuf *BaseKey)
-{
+int LoadTemplateDir(const StrBuf * DirName, HashList * big, const StrBuf * BaseKey) {
        int Toplevel;
        StrBuf *FileName;
        StrBuf *Key;
@@ -1446,13 +1252,13 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *big, const StrBuf *BaseKey)
        int d_type = 0;
        int d_namelen;
        int d_without_ext;
-       
-       d = (struct dirent *)malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1);
+
+       d = (struct dirent *) malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1);
        if (d == NULL) {
                return 0;
        }
 
-       filedir = opendir (ChrPtr(DirName));
+       filedir = opendir(ChrPtr(DirName));
        if (filedir == NULL) {
                free(d);
                return 0;
@@ -1463,9 +1269,7 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *big, const StrBuf *BaseKey)
        SubKey = NewStrBuf();
        FileName = NewStrBufPlain(NULL, PATH_MAX);
        Key = NewStrBuf();
-       while ((readdir_r(filedir, d, &filedir_entry) == 0) &&
-              (filedir_entry != NULL))
-       {
+       while ((readdir_r(filedir, d, &filedir_entry) == 0) && (filedir_entry != NULL)) {
                char *MinorPtr;
 
 #ifdef _DIRENT_HAVE_D_NAMLEN
@@ -1492,28 +1296,23 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *big, const StrBuf *BaseKey)
                d_without_ext = d_namelen;
 
                if ((d_namelen > 1) && filedir_entry->d_name[d_namelen - 1] == '~')
-                       continue; /* Ignore backup files... */
+                       continue;       /* Ignore backup files... */
 
-               if ((d_namelen == 1) && 
-                   (filedir_entry->d_name[0] == '.'))
+               if ((d_namelen == 1) && (filedir_entry->d_name[0] == '.'))
                        continue;
 
-               if ((d_namelen == 2) && 
-                   (filedir_entry->d_name[0] == '.') &&
-                   (filedir_entry->d_name[1] == '.'))
+               if ((d_namelen == 2) && (filedir_entry->d_name[0] == '.') && (filedir_entry->d_name[1] == '.'))
                        continue;
 
                if (d_type == DT_UNKNOWN) {
                        struct stat s;
                        char path[PATH_MAX];
-                       snprintf(path, PATH_MAX, "%s/%s", 
-                                ChrPtr(DirName), filedir_entry->d_name);
+                       snprintf(path, PATH_MAX, "%s/%s", ChrPtr(DirName), filedir_entry->d_name);
                        if (lstat(path, &s) == 0) {
                                d_type = IFTODT(s.st_mode);
                        }
                }
-               switch (d_type)
-               {
+               switch (d_type) {
                case DT_DIR:
                        /* Skip directories we are not interested in... */
                        if (strcmp(filedir_entry->d_name, ".svn") == 0)
@@ -1521,7 +1320,7 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *big, const StrBuf *BaseKey)
 
                        FlushStrBuf(SubKey);
                        if (!Toplevel) {
-                               /* If we're not toplevel, the upper dirs count as foo_bar_<local name>*/
+                               /* If we're not toplevel, the upper dirs count as foo_bar_<local name> */
                                StrBufAppendBuf(SubKey, BaseKey, 0);
                                StrBufAppendBufPlain(SubKey, HKEY("_"), 0);
                        }
@@ -1536,25 +1335,25 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *big, const StrBuf *BaseKey)
                        LoadTemplateDir(SubDirectory, big, SubKey);
 
                        break;
-               case DT_LNK: 
+               case DT_LNK:
                case DT_REG:
 
 
                        while ((d_without_ext > 0) && (filedir_entry->d_name[d_without_ext] != '.'))
-                               d_without_ext --;
+                               d_without_ext--;
                        if ((d_without_ext == 0) || (d_namelen < 3))
                                continue;
                        if (((d_namelen > 1) && filedir_entry->d_name[d_namelen - 1] == '~') ||
                            (strcmp(&filedir_entry->d_name[d_without_ext], ".orig") == 0) ||
                            (strcmp(&filedir_entry->d_name[d_without_ext], ".swp") == 0))
-                               continue; /* Ignore backup files... */
-                       StrBufPrintf(FileName, "%s/%s", ChrPtr(DirName),  filedir_entry->d_name);
+                               continue;       /* Ignore backup files... */
+                       StrBufPrintf(FileName, "%s/%s", ChrPtr(DirName), filedir_entry->d_name);
                        MinorPtr = strchr(filedir_entry->d_name, '.');
                        if (MinorPtr != NULL)
                                *MinorPtr = '\0';
                        FlushStrBuf(Key);
                        if (!Toplevel) {
-                               /* If we're not toplevel, the upper dirs count as foo_bar_<local name>*/
+                               /* If we're not toplevel, the upper dirs count as foo_bar_<local name> */
                                StrBufAppendBuf(Key, BaseKey, 0);
                                StrBufAppendBufPlain(Key, HKEY("_"), 0);
                        }
@@ -1576,8 +1375,7 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *big, const StrBuf *BaseKey)
        return 1;
 }
 
-void InitTemplateCache(void)
-{
+void InitTemplateCache(void) {
        int i;
        StrBuf *Key;
        StrBuf *Dir;
@@ -1593,17 +1391,17 @@ void InitTemplateCache(void)
        /* User local Template set */
        StrBufPrintf(Dir, "%s/t", static_dirs[1]);
        LoadTemplateDir(Dir, LocalTemplateCache, Key);
-       
+
        /* Debug Templates, just to be loaded while debugging. */
-       
+
        StrBufPrintf(Dir, "%s/dbg", static_dirs[0]);
        LoadTemplateDir(Dir, TemplateCache, Key);
        Templates[0] = TemplateCache;
        Templates[1] = LocalTemplateCache;
 
 
-       if (LoadTemplates == 0) 
-               for (i=0; i < 2; i++) {
+       if (LoadTemplates == 0)
+               for (i = 0; i < 2; i++) {
                        const char *Key;
                        long KLen;
                        HashPos *At;
@@ -1611,7 +1409,7 @@ void InitTemplateCache(void)
 
                        At = GetNewHashPos(Templates[i], 0);
                        while (GetNextHashPos(Templates[i], At, &KLen, &Key, &vTemplate) && (vTemplate != NULL)) {
-                               load_template(NULL, (WCTemplate *)vTemplate);
+                               load_template(NULL, (WCTemplate *) vTemplate);
                        }
                        DeleteHashPos(&At);
                }
@@ -1626,6 +1424,7 @@ void InitTemplateCache(void)
 /*-----------------------------------------------------------------------------
  *                      Filling & processing Templates
  */
+
 /**
  * \brief executes one token
  * \param Target buffer to append to
@@ -1635,14 +1434,13 @@ void InitTemplateCache(void)
  * \param state are we in conditional state?
  * \param ContextType what type of information does context giv us?
  */
-int EvaluateToken(StrBuf *Target, int state, WCTemplputParams **TPP)
-{
+int EvaluateToken(StrBuf * Target, int state, WCTemplputParams ** TPP) {
        const char *AppendMe;
        long AppendMeLen;
        HashHandler *Handler;
        void *vVar;
        WCTemplputParams *TP = *TPP;
-       
+
 /* much output, since pName is not terminated...
        syslog(LOG_DEBUG,"Doing token: %s\n",Token->pName);
 */
@@ -1651,22 +1449,25 @@ int EvaluateToken(StrBuf *Target, int state, WCTemplputParams **TPP)
        case SV_GETTEXT:
                TmplGettext(Target, TP);
                break;
-       case SV_CONDITIONAL: /** Forward conditional evaluation */
-               Handler = (HashHandler*) TP->Tokens->PreEval;
+
+       case SV_CONDITIONAL:/** Forward conditional evaluation */
+               Handler = (HashHandler *) TP->Tokens->PreEval;
                if (!CheckContext(Target, &Handler->Filter, TP, "Conditional")) {
                        return 0;
                }
                return EvaluateConditional(Target, 1, state, TPP);
                break;
-       case SV_NEG_CONDITIONAL: /** Reverse conditional evaluation */
-               Handler = (HashHandler*) TP->Tokens->PreEval;
+
+       case SV_NEG_CONDITIONAL:/** Reverse conditional evaluation */
+               Handler = (HashHandler *) TP->Tokens->PreEval;
                if (!CheckContext(Target, &Handler->Filter, TP, "Conditional")) {
                        return 0;
                }
                return EvaluateConditional(Target, 0, state, TPP);
                break;
-       case SV_CUST_STR_CONDITIONAL: /** Conditional put custom strings from params */
-               Handler = (HashHandler*) TP->Tokens->PreEval;
+
+       case SV_CUST_STR_CONDITIONAL:/** Conditional put custom strings from params */
+               Handler = (HashHandler *) TP->Tokens->PreEval;
                if (!CheckContext(Target, &Handler->Filter, TP, "Conditional")) {
                        return 0;
                }
@@ -1675,17 +1476,16 @@ int EvaluateToken(StrBuf *Target, int state, WCTemplputParams **TPP)
                                GetTemplateTokenString(Target, TP, 5, &AppendMe, &AppendMeLen);
                                StrBufAppendBufPlain(Target, AppendMe, AppendMeLen, 0);
                        }
-                       else{
+                       else {
                                GetTemplateTokenString(Target, TP, 4, &AppendMe, &AppendMeLen);
                                StrBufAppendBufPlain(Target, AppendMe, AppendMeLen, 0);
                        }
-                       if (*TPP != TP)
-                       {
+                       if (*TPP != TP) {
                                UnStackDynamicContext(Target, TPP);
                        }
                }
-               else  {
-                       LogTemplateError( Target, "Conditional", ERR_NAME, TP, "needs at least 6 Params!"); 
+               else {
+                       LogTemplateError(Target, "Conditional", ERR_NAME, TP, "needs at least 6 Params!");
                }
                break;
        case SV_SUBTEMPL:
@@ -1693,15 +1493,15 @@ int EvaluateToken(StrBuf *Target, int state, WCTemplputParams **TPP)
                        DoTemplate(TKEY(0), Target, TP);
                break;
        case SV_PREEVALUATED:
-               Handler = (HashHandler*) TP->Tokens->PreEval;
+               Handler = (HashHandler *) TP->Tokens->PreEval;
                if (!CheckContext(Target, &Handler->Filter, TP, "Token")) {
                        return 0;
                }
                Handler->HandlerFunc(Target, TP);
-               break;          
+               break;
        default:
                if (GetHash(GlobalNS, TP->Tokens->pName, TP->Tokens->NameEnd, &vVar)) {
-                       Handler = (HashHandler*) vVar;
+                       Handler = (HashHandler *) vVar;
                        if (!CheckContext(Target, &Handler->Filter, TP, "Token")) {
                                return 0;
                        }
@@ -1710,9 +1510,8 @@ int EvaluateToken(StrBuf *Target, int state, WCTemplputParams **TPP)
                        }
                }
                else {
-                       LogTemplateError(
-                               Target, "Token UNKNOWN", ERR_NAME, TP,
-                               "You've specified a token that isn't known to webcit.!");
+                       LogTemplateError(Target, "Token UNKNOWN", ERR_NAME, TP,
+                                        "You've specified a token that isn't known to webcit.!");
                }
        }
        return 0;
@@ -1720,8 +1519,7 @@ int EvaluateToken(StrBuf *Target, int state, WCTemplputParams **TPP)
 
 
 
-const StrBuf *ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, WCTemplputParams *CallingTP)
-{
+const StrBuf *ProcessTemplate(WCTemplate * Tmpl, StrBuf * Target, WCTemplputParams * CallingTP) {
        WCTemplate *pTmpl = Tmpl;
        int done = 0;
        int i;
@@ -1739,15 +1537,14 @@ const StrBuf *ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, WCTemplputParams
        TP.Sub = CallingTP->Sub;
        TP.Super = CallingTP->Super;
 
-       if (LoadTemplates != 0) {                       
+       if (LoadTemplates != 0) {
                if (LoadTemplates > 1)
-                       syslog(LOG_DEBUG, "DBG: ----- loading:  [%s] ------ \n", 
-                               ChrPtr(Tmpl->FileName));
+                       syslog(LOG_DEBUG, "DBG: ----- loading:  [%s] ------ \n", ChrPtr(Tmpl->FileName));
                pTmpl = duplicate_template(Tmpl);
-               if(load_template(Target, pTmpl) == NULL) {
-                       StrBufAppendPrintf( Target,
-                               "<pre>\nError loading Template [%s]\n See Logfile for details\n</pre>\n", 
-                               ChrPtr(Tmpl->FileName));
+               if (load_template(Target, pTmpl) == NULL) {
+                       StrBufAppendPrintf(Target,
+                                          "<pre>\nError loading Template [%s]\n See Logfile for details\n</pre>\n",
+                                          ChrPtr(Tmpl->FileName));
                        FreeWCTemplate(pTmpl);
                        return NULL;
                }
@@ -1766,11 +1563,11 @@ const StrBuf *ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, WCTemplputParams
                else {
                        int TokenRc = 0;
 
-                       StrBufAppendBufPlain( Target, pData, pTmpl->Tokens[i]->pTokenStart - pData, 0);
+                       StrBufAppendBufPlain(Target, pData, pTmpl->Tokens[i]->pTokenStart - pData, 0);
                        TPtr->Tokens = pTmpl->Tokens[i];
                        TPtr->nArgs = pTmpl->Tokens[i]->nParameters;
 
-                       TokenRc = EvaluateToken(Target, TokenRc, &TPtr);
+                       TokenRc = EvaluateToken(Target, TokenRc, &TPtr);
                        if (TokenRc > 0) {
                                state = eSkipTilEnd;
                        }
@@ -1781,24 +1578,18 @@ const StrBuf *ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, WCTemplputParams
                                TokenRc = 0;
                        }
 
-                       while ((state != eNext) && (i+1 < pTmpl->nTokensUsed)) {
-                       /* condition told us to skip till its end condition */
+                       while ((state != eNext) && (i + 1 < pTmpl->nTokensUsed)) {
+                               /* condition told us to skip till its end condition */
                                i++;
                                TPtr->Tokens = pTmpl->Tokens[i];
                                TPtr->nArgs = pTmpl->Tokens[i]->nParameters;
-                               if ((pTmpl->Tokens[i]->Flags == SV_CONDITIONAL) ||
-                                   (pTmpl->Tokens[i]->Flags == SV_NEG_CONDITIONAL))
-                               {
+                               if ((pTmpl->Tokens[i]->Flags == SV_CONDITIONAL) || (pTmpl->Tokens[i]->Flags == SV_NEG_CONDITIONAL)) {
                                        int rc;
-                                       rc = EvaluateConditional(
-                                               Target, 
-                                               pTmpl->Tokens[i]->Flags, 
-                                               TokenRc, 
-                                               &TPtr);
+                                       rc = EvaluateConditional(Target, pTmpl->Tokens[i]->Flags, TokenRc, &TPtr);
                                        if (-rc == TokenRc) {
                                                TokenRc = 0;
                                                state = eNext;
-                                               if ((TPtr != &TP) && (TPtr->ExitCTXID == - rc)) {
+                                               if ((TPtr != &TP) && (TPtr->ExitCTXID == -rc)) {
                                                        UnStackDynamicContext(Target, &TPtr);
                                                }
                                        }
@@ -1819,18 +1610,18 @@ const StrBuf *ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, WCTemplputParams
 
 
 StrBuf *textPlainType;
+
 /**
  * \brief Display a variable-substituted template
  * \param templatename template file to load
  * \returns the mimetype of the template its doing
  */
-const StrBuf *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;
        HashList *StaticLocal;
        void *vTmpl;
-       
+
        if (Target == NULL)
                Target = WC->WBuf;
        if (TP == NULL) {
@@ -1847,15 +1638,13 @@ const StrBuf *DoTemplate(const char *templatename, long len, StrBuf *Target, WCT
                return textPlainType;
        }
 
-       if (!GetHash(StaticLocal, templatename, len, &vTmpl) &&
-           !GetHash(Static, templatename, len, &vTmpl)) {
+       if (!GetHash(StaticLocal, templatename, len, &vTmpl) && !GetHash(Static, templatename, len, &vTmpl)) {
                StrBuf *escapedString = NewStrBufPlain(NULL, len);
-               
+
                StrHtmlEcmaEscAppend(escapedString, NULL, templatename, 1, 1);
-               syslog(LOG_WARNING, "didn't find Template [%s] %ld %ld\n", ChrPtr(escapedString), len , (long)strlen(templatename));
-               StrBufAppendPrintf(Target, "<pre>\ndidn't find Template [%s] %ld %ld\n</pre>", 
-                                  ChrPtr(escapedString), len, 
-                                  (long)strlen(templatename));
+               syslog(LOG_WARNING, "didn't find Template [%s] %ld %ld\n", ChrPtr(escapedString), len, (long) strlen(templatename));
+               StrBufAppendPrintf(Target, "<pre>\ndidn't find Template [%s] %ld %ld\n</pre>",
+                                  ChrPtr(escapedString), len, (long) strlen(templatename));
                WC->isFailure = 1;
 #if 0
                dbg_PrintHash(Static, PrintTemplate, NULL);
@@ -1864,17 +1653,15 @@ const StrBuf *DoTemplate(const char *templatename, long len, StrBuf *Target, WCT
                FreeStrBuf(&escapedString);
                return textPlainType;
        }
-       if (vTmpl == NULL) 
+       if (vTmpl == NULL)
                return textPlainType;
        return ProcessTemplate(vTmpl, Target, TP);
 
 }
 
 
-void tmplput_Comment(StrBuf *Target, WCTemplputParams *TP)
-{
-       if (LoadTemplates != 0)
-       {
+void tmplput_Comment(StrBuf * Target, WCTemplputParams * TP) {
+       if (LoadTemplates != 0) {
                StrBuf *Comment;
                const char *pch;
                long len;
@@ -1903,20 +1690,16 @@ typedef struct _HashIterator {
        FilterByParamFunc Filter;
 } HashIterator;
 
-void RegisterITERATOR(const char *Name, long len, 
-                     int AdditionalParams, 
-                     HashList *StaticList, 
-                     RetrieveHashlistFunc GetHash, 
+void RegisterITERATOR(const char *Name, long len,
+                     int AdditionalParams,
+                     HashList * StaticList,
+                     RetrieveHashlistFunc GetHash,
                      SubTemplFunc DoSubTempl,
                      HashDestructorFunc Destructor,
-                     FilterByParamFunc Filter,
-                     CtxType ContextType, 
-                     CtxType XPectContextType, 
-                     int Flags)
-{
+                     FilterByParamFunc Filter, CtxType ContextType, CtxType XPectContextType, int Flags) {
        HashIterator *It;
 
-       It = (HashIterator*)malloc(sizeof(HashIterator));
+       It = (HashIterator *) malloc(sizeof(HashIterator));
        memset(It, 0, sizeof(HashIterator));
        It->StaticList = StaticList;
        It->AdditionalParams = AdditionalParams;
@@ -1937,10 +1720,9 @@ typedef struct _iteratestruct {
        long KeyLen;
        int n;
        int LastN;
-       }IterateStruct; 
+} IterateStruct;
 
-int preeval_iterate(WCTemplateToken *Token)
-{
+int preeval_iterate(WCTemplateToken * Token) {
        WCTemplputParams TPP;
        WCTemplputParams *TP;
        void *vTmpl;
@@ -1951,42 +1733,33 @@ int preeval_iterate(WCTemplateToken *Token)
        TP = &TPP;
        TP->Tokens = Token;
        if (!GetHash(Iterators, TKEY(0), &vIt)) {
-               LogTemplateError(
-                       NULL, "Iterator", ERR_PARM1, TP,
-                       "not found");
+               LogTemplateError(NULL, "Iterator", ERR_PARM1, TP, "not found");
                return 0;
        }
        if (TP->Tokens->Params[1]->Type != TYPE_SUBTEMPLATE) {
                LogTemplateError(NULL, "Iterator", ERR_PARM1, TP,
-                                "Need token with type Subtemplate as param 1, have %s", 
-                                TP->Tokens->Params[1]->Start);
+                                "Need token with type Subtemplate as param 1, have %s", TP->Tokens->Params[1]->Start);
        }
-       
+
        /* well, we don't check the mobile stuff here... */
-       if (!GetHash(LocalTemplateCache, TKEY(1), &vTmpl) &&
-           !GetHash(TemplateCache, TKEY(1), &vTmpl)) {
-               LogTemplateError(NULL, "SubTemplate", ERR_PARM1, TP,
-                                "referenced here doesn't exist");
+       if (!GetHash(LocalTemplateCache, TKEY(1), &vTmpl) && !GetHash(TemplateCache, TKEY(1), &vTmpl)) {
+               LogTemplateError(NULL, "SubTemplate", ERR_PARM1, TP, "referenced here doesn't exist");
        }
        Token->Preeval2 = vIt;
        It = (HashIterator *) vIt;
 
        if (TP->Tokens->nParameters < It->AdditionalParams + 2) {
-               LogTemplateError(                               
-                       NULL, "Iterator", ERR_PARM1, TP,
-                       "doesn't work with %d params", 
-                       TP->Tokens->nParameters);
+               LogTemplateError(NULL, "Iterator", ERR_PARM1, TP, "doesn't work with %d params", TP->Tokens->nParameters);
        }
 
 
        return 1;
 }
 
-void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_iterate_subtmpl(StrBuf * Target, WCTemplputParams * TP) {
        HashIterator *It;
        HashList *List;
-       HashPos  *it;
+       HashPos *it;
        SortStruct *SortBy = NULL;
        void *vSortBy;
        int DetectGroupChange = 0;
@@ -2003,31 +1776,24 @@ void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP)
        long StopAt = -1;
 
        memset(&Status, 0, sizeof(IterateStruct));
-       
-       It = (HashIterator*) TP->Tokens->Preeval2;
+
+       It = (HashIterator *) TP->Tokens->Preeval2;
        if (It == NULL) {
-               LogTemplateError(
-                       Target, "Iterator", ERR_PARM1, TP, "Unknown!");
+               LogTemplateError(Target, "Iterator", ERR_PARM1, TP, "Unknown!");
                return;
        }
 
        if (TP->Tokens->nParameters < It->AdditionalParams + 2) {
-               LogTemplateError(                               
-                       Target, "Iterator", ERR_PARM1, TP,
-                       "doesn't work with %d params", 
-                       TP->Tokens->nParameters - 1);
+               LogTemplateError(Target, "Iterator", ERR_PARM1, TP, "doesn't work with %d params", TP->Tokens->nParameters - 1);
                return;
        }
 
-       if ((It->XPectContextType != CTX_NONE) &&
-           (It->XPectContextType != TP->Filter.ContextType)) {
-               LogTemplateError(
-                       Target, "Iterator", ERR_PARM1, TP,
-                       "requires context of type %s, have %s", 
-                       ContextName(It->XPectContextType), 
-                       ContextName(TP->Filter.ContextType));
-               return ;
-               
+       if ((It->XPectContextType != CTX_NONE) && (It->XPectContextType != TP->Filter.ContextType)) {
+               LogTemplateError(Target, "Iterator", ERR_PARM1, TP,
+                                "requires context of type %s, have %s",
+                                ContextName(It->XPectContextType), ContextName(TP->Filter.ContextType));
+               return;
+
        }
 
        if (It->StaticList == NULL)
@@ -2041,11 +1807,11 @@ void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP)
                DetectGroupChange = 0;
                if (havebstr("SortBy")) {
                        BSort = sbstr("SortBy");
-                       if (GetHash(SortHash, SKEY(BSort), &vSortBy) &&
-                           (vSortBy != NULL)) {
-                               SortBy = (SortStruct*)vSortBy;
+                       if (GetHash(SortHash, SKEY(BSort), &vSortBy) && (vSortBy != NULL)) {
+                               SortBy = (SortStruct *) vSortBy;
                                /* first check whether its intended for us... */
-                               if ((SortBy->ContextType == It->ContextType)&&
+                               if ((SortBy->ContextType == It->ContextType) &&
+
                                /** Ok, its us, lets see in which direction we should sort... */
                                    (havebstr("SortOrder"))) {
                                        int SortOrder;
@@ -2058,10 +1824,10 @@ void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP)
        }
        nMembersUsed = GetCount(List);
 
-       StackContext (TP, &IterateTP, &Status, CTX_ITERATE, 0, TP->Tokens);
+       StackContext(TP, &IterateTP, &Status, CTX_ITERATE, 0, TP->Tokens);
        {
                SubBuf = NewStrBuf();
-       
+
                if (HAVE_PARAM(2)) {
                        StartAt = GetTemplateTokenNumber(Target, TP, 2, 0);
                }
@@ -2078,9 +1844,7 @@ void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP)
                while (GetNextHashPos(List, it, &Status.KeyLen, &Status.Key, &vContext)) {
                        if ((Status.n >= StartAt) && (Status.n <= StopAt)) {
 
-                               if ((It->Filter != NULL) &&
-                                   !It->Filter(Status.Key, Status.KeyLen, vContext, Target, TP)) 
-                               {
+                               if ((It->Filter != NULL) && !It->Filter(Status.Key, Status.KeyLen, vContext, Target, TP)) {
                                        continue;
                                }
 
@@ -2098,7 +1862,7 @@ void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP)
                                        FlushStrBuf(SubBuf);
                                }
                                UnStackContext(&SubTP);
-                               Status.oddeven = ! Status.oddeven;
+                               Status.oddeven = !Status.oddeven;
                                vLastContext = vContext;
                        }
                        Status.n++;
@@ -2112,17 +1876,15 @@ void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-int conditional_ITERATE_ISGROUPCHANGE(StrBuf *Target, WCTemplputParams *TP)
-{
+int conditional_ITERATE_ISGROUPCHANGE(StrBuf * Target, WCTemplputParams * TP) {
        IterateStruct *Ctx = CTX(CTX_ITERATE);
        if (TP->Tokens->nParameters < 3)
-               return  Ctx->GroupChange;
+               return Ctx->GroupChange;
 
        return TP->Tokens->Params[2]->lvalue == Ctx->GroupChange;
 }
 
-void tmplput_ITERATE_ODDEVEN(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ITERATE_ODDEVEN(StrBuf * Target, WCTemplputParams * TP) {
        IterateStruct *Ctx = CTX(CTX_ITERATE);
        if (Ctx->oddeven)
                StrBufAppendBufPlain(Target, HKEY("odd"), 0);
@@ -2131,15 +1893,13 @@ void tmplput_ITERATE_ODDEVEN(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void tmplput_ITERATE_KEY(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ITERATE_KEY(StrBuf * Target, WCTemplputParams * TP) {
        IterateStruct *Ctx = CTX(CTX_ITERATE);
 
        StrBufAppendBufPlain(Target, Ctx->Key, Ctx->KeyLen, 0);
 }
 
-void tmplput_ITERATE_N_DIV(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ITERATE_N_DIV(StrBuf * Target, WCTemplputParams * TP) {
        IterateStruct *Ctx = CTX(CTX_ITERATE);
        long div;
        long divisor = GetTemplateTokenNumber(Target, TP, 0, 1);
@@ -2148,31 +1908,27 @@ void tmplput_ITERATE_N_DIV(StrBuf *Target, WCTemplputParams *TP)
        StrBufAppendPrintf(Target, "%ld", div);
 }
 
-void tmplput_ITERATE_N(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ITERATE_N(StrBuf * Target, WCTemplputParams * TP) {
        IterateStruct *Ctx = CTX(CTX_ITERATE);
        StrBufAppendPrintf(Target, "%d", Ctx->n);
 }
 
-int conditional_ITERATE_FIRSTN(StrBuf *Target, WCTemplputParams *TP)
-{
+int conditional_ITERATE_FIRSTN(StrBuf * Target, WCTemplputParams * TP) {
        IterateStruct *Ctx = CTX(CTX_ITERATE);
        return Ctx->n == 0;
 }
 
-int conditional_ITERATE_LASTN(StrBuf *Target, WCTemplputParams *TP)
-{
+int conditional_ITERATE_LASTN(StrBuf * Target, WCTemplputParams * TP) {
        IterateStruct *Ctx = CTX(CTX_ITERATE);
        return Ctx->LastN;
 }
 
-int conditional_ITERATE_ISMOD(StrBuf *Target, WCTemplputParams *TP)
-{
+int conditional_ITERATE_ISMOD(StrBuf * Target, WCTemplputParams * TP) {
        IterateStruct *Ctx = CTX(CTX_ITERATE);
 
        long divisor = GetTemplateTokenNumber(Target, TP, 2, 1);
        long expectRemainder = GetTemplateTokenNumber(Target, TP, 3, 0);
-       
+
        return Ctx->n % divisor == expectRemainder;
 }
 
@@ -2181,24 +1937,19 @@ int conditional_ITERATE_ISMOD(StrBuf *Target, WCTemplputParams *TP)
 /*-----------------------------------------------------------------------------
  *                      Conditionals
  */
-int EvaluateConditional(StrBuf *Target, int Neg, int state, WCTemplputParams **TPP)
-{
+int EvaluateConditional(StrBuf * Target, int Neg, int state, WCTemplputParams ** TPP) {
        ConditionalStruct *Cond;
        int rc = 0;
        int res;
        WCTemplputParams *TP = *TPP;
 
-       if ((TP->Tokens->Params[0]->len == 1) &&
-           (TP->Tokens->Params[0]->Start[0] == 'X'))
-       {
-               return - (TP->Tokens->Params[1]->lvalue);
+       if ((TP->Tokens->Params[0]->len == 1) && (TP->Tokens->Params[0]->Start[0] == 'X')) {
+               return -(TP->Tokens->Params[1]->lvalue);
        }
-           
+
        Cond = (ConditionalStruct *) TP->Tokens->PreEval;
        if (Cond == NULL) {
-               LogTemplateError(
-                       Target, "Conditional", ERR_PARM1, TP,
-                       "unknown!");
+               LogTemplateError(Target, "Conditional", ERR_PARM1, TP, "unknown!");
                return 0;
        }
 
@@ -2210,27 +1961,20 @@ int EvaluateConditional(StrBuf *Target, int Neg, int state, WCTemplputParams **T
        if (res == Neg)
                rc = TP->Tokens->Params[1]->lvalue;
 
-       if (LoadTemplates > 5) 
-               syslog(LOG_DEBUG, "<%s> : %d %d==%d\n", 
-                       ChrPtr(TP->Tokens->FlatToken), 
-                       rc, res, Neg);
+       if (LoadTemplates > 5)
+               syslog(LOG_DEBUG, "<%s> : %d %d==%d\n", ChrPtr(TP->Tokens->FlatToken), rc, res, Neg);
 
-       if (TP->Sub != NULL)
-       {
+       if (TP->Sub != NULL) {
                *TPP = TP->Sub;
        }
        return rc;
 }
 
-void RegisterContextConditional(const char *Name, long len, 
-                               int nParams,
-                               WCConditionalFunc CondF, 
-                               WCConditionalFunc ExitCtxCond,
-                               int ContextRequired)
-{
+void RegisterContextConditional(const char *Name, long len,
+                               int nParams, WCConditionalFunc CondF, WCConditionalFunc ExitCtxCond, int ContextRequired) {
        ConditionalStruct *Cond;
 
-       Cond = (ConditionalStruct*)malloc(sizeof(ConditionalStruct));
+       Cond = (ConditionalStruct *) malloc(sizeof(ConditionalStruct));
        memset(Cond, 0, sizeof(ConditionalStruct));
        Cond->PlainName = Name;
        Cond->Filter.nMaxArgs = nParams;
@@ -2241,43 +1985,34 @@ void RegisterContextConditional(const char *Name, long len,
        Put(Conditionals, Name, len, Cond, NULL);
 }
 
-void RegisterTokenParamDefine(const char *Name, long len, 
-                             long Value)
-{
+void RegisterTokenParamDefine(const char *Name, long len, long Value) {
        long *PVal;
 
-       PVal = (long*)malloc(sizeof(long));
+       PVal = (long *) malloc(sizeof(long));
        *PVal = Value;
        Put(Defines, Name, len, PVal, NULL);
 }
 
-long GetTokenDefine(const char *Name, long len, 
-                   long DefValue)
-{
+long GetTokenDefine(const char *Name, long len, long DefValue) {
        void *vPVal;
 
-       if (GetHash(Defines, Name, len, &vPVal) &&
-            (vPVal != NULL))
-        {
-                return *(long*) vPVal;
-        }
-        else
-        {
-                return DefValue;
-        }
+       if (GetHash(Defines, Name, len, &vPVal) && (vPVal != NULL)) {
+               return *(long *) vPVal;
+       }
+       else {
+               return DefValue;
+       }
 }
 
-void tmplput_DefStr(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_DefStr(StrBuf * Target, WCTemplputParams * TP) {
        const char *Str;
        long len;
        GetTemplateTokenString(Target, TP, 2, &Str, &len);
-       
+
        StrBufAppendBufPlain(Target, Str, len, 0);
 }
 
-void tmplput_DefVal(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_DefVal(StrBuf * Target, WCTemplputParams * TP) {
        int val;
 
        val = GetTemplateTokenNumber(Target, TP, 0, 0);
@@ -2289,13 +2024,11 @@ HashList *Defines;
 /*-----------------------------------------------------------------------------
  *                      Context Strings
  */
-void tmplput_ContextString(StrBuf *Target, WCTemplputParams *TP)
-{
-       StrBufAppendTemplate(Target, TP, (StrBuf*)CTX(CTX_STRBUF), 0);
+void tmplput_ContextString(StrBuf * Target, WCTemplputParams * TP) {
+       StrBufAppendTemplate(Target, TP, (StrBuf *) CTX(CTX_STRBUF), 0);
 }
-int ConditionalContextStr(StrBuf *Target, WCTemplputParams *TP)
-{
-       StrBuf *TokenText = (StrBuf*) CTX((CTX_STRBUF));
+int ConditionalContextStr(StrBuf * Target, WCTemplputParams * TP) {
+       StrBuf *TokenText = (StrBuf *) CTX((CTX_STRBUF));
        const char *CompareToken;
        long len;
 
@@ -2303,21 +2036,18 @@ int ConditionalContextStr(StrBuf *Target, WCTemplputParams *TP)
        return strcmp(ChrPtr(TokenText), CompareToken) == 0;
 }
 
-void tmplput_ContextStringArray(StrBuf *Target, WCTemplputParams *TP)
-{
-       HashList *Arr = (HashList*) CTX(CTX_STRBUFARR);
+void tmplput_ContextStringArray(StrBuf * Target, WCTemplputParams * TP) {
+       HashList *Arr = (HashList *) CTX(CTX_STRBUFARR);
        void *pV;
        int val;
 
        val = GetTemplateTokenNumber(Target, TP, 0, 0);
-       if (GetHash(Arr, IKEY(val), &pV) && 
-           (pV != NULL)) {
-               StrBufAppendTemplate(Target, TP, (StrBuf*)pV, 1);
+       if (GetHash(Arr, IKEY(val), &pV) && (pV != NULL)) {
+               StrBufAppendTemplate(Target, TP, (StrBuf *) pV, 1);
        }
 }
-int ConditionalContextStrinArray(StrBuf *Target, WCTemplputParams *TP)
-{
-       HashList *Arr = (HashList*) CTX(CTX_STRBUFARR);
+int ConditionalContextStrinArray(StrBuf * Target, WCTemplputParams * TP) {
+       HashList *Arr = (HashList *) CTX(CTX_STRBUFARR);
        void *pV;
        int val;
        const char *CompareToken;
@@ -2325,9 +2055,8 @@ int ConditionalContextStrinArray(StrBuf *Target, WCTemplputParams *TP)
 
        GetTemplateTokenString(Target, TP, 2, &CompareToken, &len);
        val = GetTemplateTokenNumber(Target, TP, 0, 0);
-       if (GetHash(Arr, IKEY(val), &pV) && 
-           (pV != NULL)) {
-               return strcmp(ChrPtr((StrBuf*)pV), CompareToken) == 0;
+       if (GetHash(Arr, IKEY(val), &pV) && (pV != NULL)) {
+               return strcmp(ChrPtr((StrBuf *) pV), CompareToken) == 0;
        }
        else
                return 0;
@@ -2337,8 +2066,7 @@ int ConditionalContextStrinArray(StrBuf *Target, WCTemplputParams *TP)
  *                      Boxed-API
  */
 
-void tmpl_do_boxed(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_do_boxed(StrBuf * Target, WCTemplputParams * TP) {
        WCTemplputParams SubTP;
 
        StrBuf *Headline = NULL;
@@ -2350,17 +2078,13 @@ void tmpl_do_boxed(StrBuf *Target, WCTemplputParams *TP)
                else {
                        const char *Ch;
                        long len;
-                       GetTemplateTokenString(Target, 
-                                              TP, 
-                                              1,
-                                              &Ch,
-                                              &len);
+                       GetTemplateTokenString(Target, TP, 1, &Ch, &len);
                        Headline = NewStrBufPlain(Ch, len);
                }
        }
        /* else TODO error? logging? */
 
-       StackContext (TP, &SubTP, Headline, CTX_STRBUF, 0, NULL);
+       StackContext(TP, &SubTP, Headline, CTX_STRBUF, 0, NULL);
        {
                DoTemplate(HKEY("box_begin"), Target, &SubTP);
        }
@@ -2379,8 +2103,7 @@ typedef struct _tab_struct {
        StrBuf *TabTitle;
 } tab_struct;
 
-int preeval_do_tabbed(WCTemplateToken *Token)
-{
+int preeval_do_tabbed(WCTemplateToken * Token) {
        WCTemplputParams TPP;
        WCTemplputParams *TP;
        const char *Ch;
@@ -2391,49 +2114,30 @@ int preeval_do_tabbed(WCTemplateToken *Token)
        TP = &TPP;
        TP->Tokens = Token;
        nTabs = TP->Tokens->nParameters / 2 - 1;
-       if (TP->Tokens->nParameters % 2 != 0)
-       {
-               LogTemplateError(NULL, "TabbedApi", ERR_PARM1, TP,
-                                "need even number of arguments");
+       if (TP->Tokens->nParameters % 2 != 0) {
+               LogTemplateError(NULL, "TabbedApi", ERR_PARM1, TP, "need even number of arguments");
                return 0;
 
        }
-       else for (i = 0; i < nTabs; i++) {
-               if (!HaveTemplateTokenString(NULL, 
-                                            TP, 
-                                            i * 2,
-                                            &Ch,
-                                            &len) || 
-                   (TP->Tokens->Params[i * 2]->len == 0))
-               {
-                       LogTemplateError(NULL, "TabbedApi", ERR_PARM1, TP,
-                                        "Tab-Subject %d needs to be able to produce a string, have %s", 
-                                        i, TP->Tokens->Params[i * 2]->Start);
-                       return 0;
-               }
-               if (!HaveTemplateTokenString(NULL, 
-                                            TP, 
-                                            i * 2 + 1,
-                                            &Ch,
-                                            &len) || 
-                   (TP->Tokens->Params[i * 2 + 1]->len == 0))
-               {
-                       LogTemplateError(NULL, "TabbedApi", ERR_PARM1, TP,
-                                        "Tab-Content %d needs to be able to produce a string, have %s", 
-                                        i, TP->Tokens->Params[i * 2 + 1]->Start);
-                       return 0;
+       else
+               for (i = 0; i < nTabs; i++) {
+                       if (!HaveTemplateTokenString(NULL, TP, i * 2, &Ch, &len) || (TP->Tokens->Params[i * 2]->len == 0)) {
+                               LogTemplateError(NULL, "TabbedApi", ERR_PARM1, TP,
+                                                "Tab-Subject %d needs to be able to produce a string, have %s",
+                                                i, TP->Tokens->Params[i * 2]->Start);
+                               return 0;
+                       }
+                       if (!HaveTemplateTokenString(NULL, TP, i * 2 + 1, &Ch, &len) || (TP->Tokens->Params[i * 2 + 1]->len == 0)) {
+                               LogTemplateError(NULL, "TabbedApi", ERR_PARM1, TP,
+                                                "Tab-Content %d needs to be able to produce a string, have %s",
+                                                i, TP->Tokens->Params[i * 2 + 1]->Start);
+                               return 0;
+                       }
                }
-       }
 
-       if (!HaveTemplateTokenString(NULL, 
-                                    TP, 
-                                    i * 2 + 1,
-                                    &Ch,
-                                    &len) || 
-           (TP->Tokens->Params[i * 2 + 1]->len == 0))
-       {
+       if (!HaveTemplateTokenString(NULL, TP, i * 2 + 1, &Ch, &len) || (TP->Tokens->Params[i * 2 + 1]->len == 0)) {
                LogTemplateError(NULL, "TabbedApi", ERR_PARM1, TP,
-                                "Tab-Content %d needs to be able to produce a string, have %s", 
+                                "Tab-Content %d needs to be able to produce a string, have %s",
                                 i, TP->Tokens->Params[i * 2 + 1]->Start);
                return 0;
        }
@@ -2441,8 +2145,7 @@ int preeval_do_tabbed(WCTemplateToken *Token)
 }
 
 
-void tmpl_do_tabbed(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_do_tabbed(StrBuf * Target, WCTemplputParams * TP) {
        StrBuf **TabNames;
        int i, ntabs, nTabs;
        tab_struct TS;
@@ -2451,31 +2154,27 @@ void tmpl_do_tabbed(StrBuf *Target, WCTemplputParams *TP)
        memset(&TS, 0, sizeof(tab_struct));
 
        nTabs = ntabs = TP->Tokens->nParameters / 2;
-       TabNames = (StrBuf **) malloc(ntabs * sizeof(StrBuf*));
-       memset(TabNames, 0, ntabs * sizeof(StrBuf*));
+       TabNames = (StrBuf **) malloc(ntabs * sizeof(StrBuf *));
+       memset(TabNames, 0, ntabs * sizeof(StrBuf *));
 
        for (i = 0; i < ntabs; i++) {
-               if ((TP->Tokens->Params[i * 2]->Type == TYPE_STR) &&
-                   (TP->Tokens->Params[i * 2]->len > 0)) {
+               if ((TP->Tokens->Params[i * 2]->Type == TYPE_STR) && (TP->Tokens->Params[i * 2]->len > 0)) {
                        TabNames[i] = NewStrBuf();
                        DoTemplate(TKEY(i * 2), TabNames[i], TP);
                }
                else if (TP->Tokens->Params[i * 2]->Type == TYPE_GETTEXT) {
                        const char *Ch;
                        long len;
-                       GetTemplateTokenString(Target, 
-                                              TP, 
-                                              i * 2,
-                                              &Ch,
-                                              &len);
+                       GetTemplateTokenString(Target, TP, i * 2, &Ch, &len);
                        TabNames[i] = NewStrBufPlain(Ch, -1);
                }
-               else { 
+               else {
+
                        /** A Tab without subject? we can't count that, add it as silent */
-                       nTabs --;
+                       nTabs--;
                }
        }
-       StackContext (TP, &SubTP, &TS, CTX_TAB, 0, NULL);
+       StackContext(TP, &SubTP, &TS, CTX_TAB, 0, NULL);
        {
                StrTabbedDialog(Target, nTabs, TabNames);
                for (i = 0; i < ntabs; i++) {
@@ -2486,22 +2185,20 @@ void tmpl_do_tabbed(StrBuf *Target, WCTemplputParams *TP)
                        DoTemplate(TKEY(i * 2 + 1), Target, &SubTP);
                        StrEndTab(Target, i, nTabs);
                }
-               for (i = 0; i < ntabs; i++) 
+               for (i = 0; i < ntabs; i++)
                        FreeStrBuf(&TabNames[i]);
                free(TabNames);
        }
        UnStackContext(&SubTP);
 }
 
-void tmplput_TAB_N(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_TAB_N(StrBuf * Target, WCTemplputParams * TP) {
        tab_struct *Ctx = CTX(CTX_TAB);
 
        StrBufAppendPrintf(Target, "%d", Ctx->CurrentTab);
 }
 
-void tmplput_TAB_TITLE(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_TAB_TITLE(StrBuf * Target, WCTemplputParams * TP) {
        tab_struct *Ctx = CTX(CTX_TAB);
        StrBufAppendTemplate(Target, TP, Ctx->TabTitle, 0);
 }
@@ -2511,16 +2208,12 @@ void tmplput_TAB_TITLE(StrBuf *Target, WCTemplputParams *TP)
  */
 
 
-void RegisterSortFunc(const char *name, long len, 
+void RegisterSortFunc(const char *name, long len,
                      const char *prepend, long preplen,
-                     CompareFunc Forward, 
-                     CompareFunc Reverse, 
-                     CompareFunc GroupChange, 
-                     CtxType ContextType)
-{
+                     CompareFunc Forward, CompareFunc Reverse, CompareFunc GroupChange, CtxType ContextType) {
        SortStruct *NewSort;
 
-       NewSort = (SortStruct*) malloc(sizeof(SortStruct));
+       NewSort = (SortStruct *) malloc(sizeof(SortStruct));
        memset(NewSort, 0, sizeof(SortStruct));
        NewSort->Name = NewStrBufPlain(name, len);
        if (prepend != NULL)
@@ -2535,19 +2228,17 @@ void RegisterSortFunc(const char *name, long len,
                syslog(LOG_WARNING, "sorting requires a context. CTX_NONE won't make it.\n");
                exit(1);
        }
-               
+
        Put(SortHash, name, len, NewSort, DestroySortStruct);
 }
 
-CompareFunc RetrieveSort(WCTemplputParams *TP, 
-                        const char *OtherPrefix, long OtherPrefixLen,
-                        const char *Default, long ldefault, long DefaultDirection)
-{
+CompareFunc RetrieveSort(WCTemplputParams * TP,
+                        const char *OtherPrefix, long OtherPrefixLen, const char *Default, long ldefault, long DefaultDirection) {
        const StrBuf *BSort = NULL;
        SortStruct *SortBy;
        void *vSortBy;
        long SortOrder = -1;
-       
+
        if (havebstr("SortBy")) {
                BSort = sbstr("SortBy");
                if (OtherPrefix == NULL) {
@@ -2557,6 +2248,7 @@ CompareFunc RetrieveSort(WCTemplputParams *TP,
                        set_X_PREFS(HKEY("sort"), OtherPrefix, OtherPrefixLen, NewStrBufDup(BSort), 0);
                }
        }
+
        else { /** Try to fallback to our remembered values... */
                if (OtherPrefix == NULL) {
                        BSort = get_room_pref("sort");
@@ -2574,17 +2266,13 @@ CompareFunc RetrieveSort(WCTemplputParams *TP,
                }
        }
 
-       if (!GetHash(SortHash, SKEY(BSort), &vSortBy) || 
-           (vSortBy == NULL)) {
-               if (!GetHash(SortHash, Default, ldefault, &vSortBy) || 
-                   (vSortBy == NULL)) {
-                       LogTemplateError(
-                               NULL, "Sorting", ERR_PARM1, TP,
-                               "Illegal default sort: [%s]", Default);
+       if (!GetHash(SortHash, SKEY(BSort), &vSortBy) || (vSortBy == NULL)) {
+               if (!GetHash(SortHash, Default, ldefault, &vSortBy) || (vSortBy == NULL)) {
+                       LogTemplateError(NULL, "Sorting", ERR_PARM1, TP, "Illegal default sort: [%s]", Default);
                        wc_backtrace(LOG_WARNING);
                }
        }
-       SortBy = (SortStruct*)vSortBy;
+       SortBy = (SortStruct *) vSortBy;
 
        if (SortBy->ContextType != TP->Filter.ContextType)
                return NULL;
@@ -2593,6 +2281,7 @@ CompareFunc RetrieveSort(WCTemplputParams *TP,
        if (havebstr("SortOrder")) {
                SortOrder = lbstr("SortOrder");
        }
+
        else { /** Try to fallback to our remembered values... */
                StrBuf *Buf = NULL;
                if (SortBy->PrefPrepend == NULL) {
@@ -2623,38 +2312,36 @@ CompareFunc RetrieveSort(WCTemplputParams *TP,
 
 
 enum {
-       eNO_SUCH_SORT, 
+       eNO_SUCH_SORT,
        eNOT_SPECIFIED,
        eINVALID_PARAM,
        eFOUND
 };
 
 ConstStr SortIcons[] = {
-       {HKEY("static/webcit_icons/sort_none.gif")},
-       {HKEY("static/webcit_icons/up_pointer.gif")},
-       {HKEY("static/webcit_icons/down_pointer.gif")},
+       { HKEY("static/webcit_icons/sort_none.gif") },
+       { HKEY("static/webcit_icons/up_pointer.gif") },
+       { HKEY("static/webcit_icons/down_pointer.gif") },
 };
 
 ConstStr SortNextOrder[] = {
-       {HKEY("1")},
-       {HKEY("2")},
-       {HKEY("0")},
+       { HKEY("1") },
+       { HKEY("2") },
+       { HKEY("0") },
 };
 
 
-int GetSortMetric(WCTemplputParams *TP, SortStruct **Next, SortStruct **Param, long *SortOrder, int N)
-{
+int GetSortMetric(WCTemplputParams * TP, SortStruct ** Next, SortStruct ** Param, long *SortOrder, int N) {
        int bSortError = eNOT_SPECIFIED;
        const StrBuf *BSort;
        void *vSort;
-       
+
        *SortOrder = 0;
        *Next = NULL;
-       if (!GetHash(SortHash, TKEY(0), &vSort) || 
-           (vSort == NULL))
+       if (!GetHash(SortHash, TKEY(0), &vSort) || (vSort == NULL))
                return eNO_SUCH_SORT;
-       *Param = (SortStruct*) vSort;
-       
+       *Param = (SortStruct *) vSort;
+
 
        if (havebstr("SortBy")) {
                BSort = sbstr("SortBy");
@@ -2666,6 +2353,7 @@ int GetSortMetric(WCTemplputParams *TP, SortStruct **Next, SortStruct **Param, l
                        set_X_PREFS(HKEY("sort"), TKEY(N), NewStrBufDup(BSort), 0);
                }
        }
+
        else { /** Try to fallback to our remembered values... */
                if ((*Param)->PrefPrepend == NULL) {
                        BSort = get_room_pref("sort");
@@ -2675,16 +2363,16 @@ int GetSortMetric(WCTemplputParams *TP, SortStruct **Next, SortStruct **Param, l
                }
        }
 
-       if (!GetHash(SortHash, SKEY(BSort), &vSort) || 
-           (vSort == NULL))
+       if (!GetHash(SortHash, SKEY(BSort), &vSort) || (vSort == NULL))
                return bSortError;
 
-       *Next = (SortStruct*) vSort;
+       *Next = (SortStruct *) vSort;
 
        /** Ok, its us, lets see in which direction we should sort... */
        if (havebstr("SortOrder")) {
                *SortOrder = lbstr("SortOrder");
        }
+
        else { /** Try to fallback to our remembered values... */
                if ((*Param)->PrefPrepend == NULL) {
                        *SortOrder = StrTol(get_room_pref("SortOrder"));
@@ -2700,29 +2388,24 @@ int GetSortMetric(WCTemplputParams *TP, SortStruct **Next, SortStruct **Param, l
 }
 
 
-void tmplput_SORT_ICON(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_SORT_ICON(StrBuf * Target, WCTemplputParams * TP) {
        long SortOrder;
        SortStruct *Next;
        SortStruct *Param;
        const ConstStr *SortIcon;
 
-       switch (GetSortMetric(TP, &Next, &Param, &SortOrder, 2)){
+       switch (GetSortMetric(TP, &Next, &Param, &SortOrder, 2)) {
        case eNO_SUCH_SORT:
-                LogTemplateError(
-                        Target, "Sorter", ERR_PARM1, TP,
-                       " Sorter [%s] unknown!", 
-                       TP->Tokens->Params[0]->Start);
-               break;          
+               LogTemplateError(Target, "Sorter", ERR_PARM1, TP, " Sorter [%s] unknown!", TP->Tokens->Params[0]->Start);
+               break;
        case eINVALID_PARAM:
-                LogTemplateError(NULL, "Sorter", ERR_PARM1, TP,
-                                " Sorter specified by BSTR 'SortBy' [%s] unknown!", 
-                                bstr("SortBy"));
+               LogTemplateError(NULL, "Sorter", ERR_PARM1, TP, " Sorter specified by BSTR 'SortBy' [%s] unknown!", bstr("SortBy"));
        case eNOT_SPECIFIED:
        case eFOUND:
                if (Next == Param) {
                        SortIcon = &SortIcons[SortOrder];
                }
+
                else { /** Not Us... */
                        SortIcon = &SortIcons[0];
                }
@@ -2730,55 +2413,42 @@ void tmplput_SORT_ICON(StrBuf *Target, WCTemplputParams *TP)
        }
 }
 
-void tmplput_SORT_NEXT(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_SORT_NEXT(StrBuf * Target, WCTemplputParams * TP) {
        long SortOrder;
        SortStruct *Next;
        SortStruct *Param;
 
-       switch (GetSortMetric(TP, &Next, &Param, &SortOrder, 2)){
+       switch (GetSortMetric(TP, &Next, &Param, &SortOrder, 2)) {
        case eNO_SUCH_SORT:
-                LogTemplateError(
-                        Target, "Sorter", ERR_PARM1, TP,                                  
-                       " Sorter [%s] unknown!", 
-                       TP->Tokens->Params[0]->Start);
-               break;          
+               LogTemplateError(Target, "Sorter", ERR_PARM1, TP, " Sorter [%s] unknown!", TP->Tokens->Params[0]->Start);
+               break;
        case eINVALID_PARAM:
-                LogTemplateError(
-                        NULL, "Sorter", ERR_PARM1, TP,
-                       " Sorter specified by BSTR 'SortBy' [%s] unknown!", 
-                       bstr("SortBy"));
+               LogTemplateError(NULL, "Sorter", ERR_PARM1, TP, " Sorter specified by BSTR 'SortBy' [%s] unknown!", bstr("SortBy"));
        case eNOT_SPECIFIED:
        case eFOUND:
                StrBufAppendBuf(Target, Param->Name, 0);
-               
+
        }
 }
 
-void tmplput_SORT_ORDER(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_SORT_ORDER(StrBuf * Target, WCTemplputParams * TP) {
        long SortOrder;
        const ConstStr *SortOrderStr;
        SortStruct *Next;
        SortStruct *Param;
 
-       switch (GetSortMetric(TP, &Next, &Param, &SortOrder, 2)){
+       switch (GetSortMetric(TP, &Next, &Param, &SortOrder, 2)) {
        case eNO_SUCH_SORT:
-                LogTemplateError(
-                        Target, "Sorter", ERR_PARM1, TP,
-                        " Sorter [%s] unknown!",
-                        TP->Tokens->Params[0]->Start);
-               break;          
+               LogTemplateError(Target, "Sorter", ERR_PARM1, TP, " Sorter [%s] unknown!", TP->Tokens->Params[0]->Start);
+               break;
        case eINVALID_PARAM:
-                LogTemplateError(
-                        NULL, "Sorter", ERR_PARM1, TP,
-                        " Sorter specified by BSTR 'SortBy' [%s] unknown!",
-                        bstr("SortBy"));
+               LogTemplateError(NULL, "Sorter", ERR_PARM1, TP, " Sorter specified by BSTR 'SortBy' [%s] unknown!", bstr("SortBy"));
        case eNOT_SPECIFIED:
        case eFOUND:
                if (Next == Param) {
                        SortOrderStr = &SortNextOrder[SortOrder];
                }
+
                else { /** Not Us... */
                        SortOrderStr = &SortNextOrder[0];
                }
@@ -2787,34 +2457,25 @@ void tmplput_SORT_ORDER(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void tmplput_long_vector(StrBuf *Target, WCTemplputParams *TP)
-{
-       long *LongVector = (long*) CTX(CTX_LONGVECTOR);
+void tmplput_long_vector(StrBuf * Target, WCTemplputParams * TP) {
+       long *LongVector = (long *) CTX(CTX_LONGVECTOR);
 
-       if ((TP->Tokens->Params[0]->Type == TYPE_LONG) && 
-           (TP->Tokens->Params[0]->lvalue <= LongVector[0]))
-       {
+       if ((TP->Tokens->Params[0]->Type == TYPE_LONG) && (TP->Tokens->Params[0]->lvalue <= LongVector[0])) {
                StrBufAppendPrintf(Target, "%ld", LongVector[TP->Tokens->Params[0]->lvalue]);
        }
-       else
-       {
+       else {
                if (TP->Tokens->Params[0]->Type != TYPE_LONG) {
-                       LogTemplateError(
-                               Target, "Longvector", ERR_NAME, TP,
-                               "needs a numerical Parameter!");
+                       LogTemplateError(Target, "Longvector", ERR_NAME, TP, "needs a numerical Parameter!");
                }
                else {
-                       LogTemplateError(
-                               Target, "LongVector", ERR_PARM1, TP,
-                               "doesn't have %ld Parameters, its just the size of %ld!", 
-                               TP->Tokens->Params[0]->lvalue,
-                               LongVector[0]);
+                       LogTemplateError(Target, "LongVector", ERR_PARM1, TP,
+                                        "doesn't have %ld Parameters, its just the size of %ld!",
+                                        TP->Tokens->Params[0]->lvalue, LongVector[0]);
                }
        }
 }
 
-void dbg_print_longvector(long *LongVector)
-{
+void dbg_print_longvector(long *LongVector) {
        StrBuf *Buf = NewStrBufPlain(HKEY("Longvector: ["));
        int nItems = LongVector[0];
        int i;
@@ -2830,48 +2491,33 @@ void dbg_print_longvector(long *LongVector)
        FreeStrBuf(&Buf);
 }
 
-int ConditionalLongVector(StrBuf *Target, WCTemplputParams *TP)
-{
-       long *LongVector = (long*) CTX(CTX_LONGVECTOR);
+int ConditionalLongVector(StrBuf * Target, WCTemplputParams * TP) {
+       long *LongVector = (long *) CTX(CTX_LONGVECTOR);
 
-       if ((TP->Tokens->Params[2]->Type == TYPE_LONG) && 
-           (TP->Tokens->Params[2]->lvalue <= LongVector[0])&&
-           (TP->Tokens->Params[3]->Type == TYPE_LONG) && 
-           (TP->Tokens->Params[3]->lvalue <= LongVector[0]))
-       {
-               return LongVector[TP->Tokens->Params[2]->lvalue] == 
-                       LongVector[TP->Tokens->Params[3]->lvalue];
+       if ((TP->Tokens->Params[2]->Type == TYPE_LONG) &&
+           (TP->Tokens->Params[2]->lvalue <= LongVector[0]) &&
+           (TP->Tokens->Params[3]->Type == TYPE_LONG) && (TP->Tokens->Params[3]->lvalue <= LongVector[0])) {
+               return LongVector[TP->Tokens->Params[2]->lvalue] == LongVector[TP->Tokens->Params[3]->lvalue];
        }
-       else
-       {
-               if ((TP->Tokens->Params[2]->Type == TYPE_LONG) ||
-                   (TP->Tokens->Params[2]->Type == TYPE_LONG)) {
-                       LogTemplateError(
-                               Target, "ConditionalLongvector", ERR_PARM1, TP,
-                               "needs two long Parameter!");
+       else {
+               if ((TP->Tokens->Params[2]->Type == TYPE_LONG) || (TP->Tokens->Params[2]->Type == TYPE_LONG)) {
+                       LogTemplateError(Target, "ConditionalLongvector", ERR_PARM1, TP, "needs two long Parameter!");
                }
                else {
-                       LogTemplateError(
-                               Target, "Longvector", ERR_PARM1, TP,
-                               "doesn't have %ld / %ld Parameters, its just the size of %ld!",
-                               TP->Tokens->Params[2]->lvalue,
-                               TP->Tokens->Params[3]->lvalue,
-                               LongVector[0]);
+                       LogTemplateError(Target, "Longvector", ERR_PARM1, TP,
+                                        "doesn't have %ld / %ld Parameters, its just the size of %ld!",
+                                        TP->Tokens->Params[2]->lvalue, TP->Tokens->Params[3]->lvalue, LongVector[0]);
                }
        }
        return 0;
 }
 
 
-void tmplput_CURRENT_FILE(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_CURRENT_FILE(StrBuf * Target, WCTemplputParams * TP) {
        StrBufAppendTemplate(Target, TP, TP->Tokens->FileName, 0);
 }
 
-void 
-InitModule_SUBST
-(void)
-{
+void InitModule_SUBST(void) {
        RegisterCTX(CTX_TAB);
        RegisterCTX(CTX_ITERATE);
 
@@ -2897,18 +2543,10 @@ InitModule_SUBST
        RegisterConditional("COND:LONGVECTOR", 4, ConditionalLongVector, CTX_LONGVECTOR);
 
 
-       RegisterConditional("COND:ITERATE:ISGROUPCHANGE", 2, 
-                           conditional_ITERATE_ISGROUPCHANGE, 
-                           CTX_ITERATE);
-       RegisterConditional("COND:ITERATE:LASTN", 2, 
-                           conditional_ITERATE_LASTN, 
-                           CTX_ITERATE);
-       RegisterConditional("COND:ITERATE:FIRSTN", 2, 
-                           conditional_ITERATE_FIRSTN, 
-                           CTX_ITERATE);
-       RegisterConditional("COND:ITERATE:ISMOD", 3, 
-                           conditional_ITERATE_ISMOD, 
-                           CTX_ITERATE);
+       RegisterConditional("COND:ITERATE:ISGROUPCHANGE", 2, conditional_ITERATE_ISGROUPCHANGE, CTX_ITERATE);
+       RegisterConditional("COND:ITERATE:LASTN", 2, conditional_ITERATE_LASTN, CTX_ITERATE);
+       RegisterConditional("COND:ITERATE:FIRSTN", 2, conditional_ITERATE_FIRSTN, CTX_ITERATE);
+       RegisterConditional("COND:ITERATE:ISMOD", 3, conditional_ITERATE_ISMOD, CTX_ITERATE);
 
        RegisterNamespace("ITERATE:ODDEVEN", 0, 0, tmplput_ITERATE_ODDEVEN, NULL, CTX_ITERATE);
        RegisterNamespace("ITERATE:KEY", 0, 0, tmplput_ITERATE_KEY, NULL, CTX_ITERATE);
@@ -2923,10 +2561,7 @@ InitModule_SUBST
 
 }
 
-void
-ServerStartModule_SUBST
-(void)
-{
+void ServerStartModule_SUBST(void) {
        textPlainType = NewStrBufPlain(HKEY("text/plain"));
        LocalTemplateCache = NewHash(1, NULL);
        TemplateCache = NewHash(1, NULL);
@@ -2936,7 +2571,7 @@ ServerStartModule_SUBST
        SortHash = NewHash(1, NULL);
        Defines = NewHash(1, NULL);
        CtxList = NewHash(1, NULL);
-       
+
        PutContextType(HKEY("CTX_NONE"), 0);
 
        RegisterCTX(CTX_STRBUF);
@@ -2944,22 +2579,16 @@ ServerStartModule_SUBST
        RegisterCTX(CTX_LONGVECTOR);
 }
 
-void
-FinalizeModule_SUBST
-(void)
-{
+void FinalizeModule_SUBST(void) {
 
 }
 
-void 
-ServerShutdownModule_SUBST
-(void)
-{
+void ServerShutdownModule_SUBST(void) {
        FreeStrBuf(&textPlainType);
 
        DeleteHash(&TemplateCache);
        DeleteHash(&LocalTemplateCache);
-       
+
        DeleteHash(&GlobalNS);
        DeleteHash(&Iterators);
        DeleteHash(&Conditionals);
@@ -2969,29 +2598,17 @@ ServerShutdownModule_SUBST
 }
 
 
-void
-SessionNewModule_SUBST
-(wcsession *sess)
-{
+void SessionNewModule_SUBST(wcsession * sess) {
 
 }
 
-void
-SessionAttachModule_SUBST
-(wcsession *sess)
-{
+void SessionAttachModule_SUBST(wcsession * sess) {
 }
 
-void
-SessionDetachModule_SUBST
-(wcsession *sess)
-{
+void SessionDetachModule_SUBST(wcsession * sess) {
        FreeStrBuf(&sess->WFBuf);
 }
 
-void 
-SessionDestroyModule_SUBST  
-(wcsession *sess)
-{
+void SessionDestroyModule_SUBST(wcsession * sess) {
 
 }
index 063f46d211e0883fe2be28a773943f4fd83b661a..4acf59f920dc64395a9eaa4d632d21699f1ff116 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2013 by the citadel.org team
  *
@@ -38,12 +39,12 @@ extern HashList *LocalTemplateCache;
  * \brief Values for wcs_type
  */
 enum {
-       WCS_STRING,       /* its a string */
-       WCS_FUNCTION,     /* its a function callback */
-       WCS_SERVCMD,      /* its a command to send to the citadel server */
-       WCS_STRBUF,       /* its a strbuf we own */
-       WCS_STRBUF_REF,   /* its a strbuf we mustn't free */
-       WCS_LONG          /* its an integer */
+       WCS_STRING,             /* its a string */
+       WCS_FUNCTION,           /* its a function callback */
+       WCS_SERVCMD,            /* its a command to send to the citadel server */
+       WCS_STRBUF,             /* its a strbuf we own */
+       WCS_STRBUF_REF,         /* its a strbuf we mustn't free */
+       WCS_LONG                /* its an integer */
 };
 
 #define CTX_NONE 0
@@ -55,7 +56,7 @@ typedef struct __CtxTypeStruct {
 } CtxTypeStruct;
 
 CtxTypeStruct *GetContextType(CtxType Type);
-void RegisterContextType(const char *name, long len, CtxType *TheCtx);
+void RegisterContextType(const char *name, long len, CtxType * TheCtx);
 #define RegisterCTX(a) RegisterContextType(#a, sizeof(#a) - 1, &a)
 
 extern CtxType CTX_STRBUF;
@@ -70,9 +71,9 @@ extern CtxType CTX_LONGVECTOR;
  * if not, we will log/print an error and refuse to call it.
  */
 typedef struct _contexts {
-       CtxType ContextType;                /* do we require a User Context ? */
-       int nMinArgs;                   /* How many arguments do we need at least? */
-       int nMaxArgs;                   /* up to how many arguments can we handle? */
+       CtxType ContextType;    /* do we require a User Context ? */
+       int nMinArgs;           /* How many arguments do we need at least? */
+       int nMaxArgs;           /* up to how many arguments can we handle? */
 } ContextFilter;
 
 
@@ -81,15 +82,15 @@ typedef struct WCTemplateToken WCTemplateToken;
 typedef struct WCTemplputParams WCTemplputParams;
 
 /* this is the signature of a tmplput function */
-typedef void (*WCHandlerFunc)(StrBuf *Target, WCTemplputParams *TP);
+typedef void (*WCHandlerFunc)(StrBuf * Target, WCTemplputParams * TP);
 
-/* if you want to pre-evaluate parts of your token, or do additional syntax, use this. */ 
-typedef int (*WCPreevalFunc)(WCTemplateToken *Token);
+/* if you want to pre-evaluate parts of your token, or do additional syntax, use this. */
+typedef int (*WCPreevalFunc)(WCTemplateToken * Token);
 
 /* make a template token a lookup key: */
 #define TKEY(a) TP->Tokens->Params[a]->Start, TP->Tokens->Params[a]->len
 
-void *GetContextPayload(WCTemplputParams *TP, CtxType ContextType);
+void *GetContextPayload(WCTemplputParams * TP, CtxType ContextType);
 #define CTX(a) GetContextPayload(TP, a)
 
 /**
@@ -97,16 +98,16 @@ void *GetContextPayload(WCTemplputParams *TP, CtxType ContextType);
  * this is the signature of a conditional function 
  * Note: Target is just passed in for error messages; don't write onto it in regular cases.
  */
-typedef int (*WCConditionalFunc)(StrBuf *Target, WCTemplputParams *TP);
+typedef int (*WCConditionalFunc)(StrBuf * Target, WCTemplputParams * TP);
 
 typedef enum _eBitMask {
        eNO = 0,
        eOR,
        eAND
-}eBitMask;
+} eBitMask;
 
 typedef struct _TemplateParam {
-        /* are we a string or a number? */
+       /* are we a string or a number? */
        int Type;
        /* string data: */
        const char *Start;
@@ -120,10 +121,10 @@ typedef struct _TemplateParam {
 /**
  * @ingroup subst
  * Representation of a token; everything thats inbetween <? and >
- */ 
+ */
 struct WCTemplateToken {
-        /* Reference to the filename we're in to print error messages; not to be freed */
-       const StrBuf *FileName; 
+       /* Reference to the filename we're in to print error messages; not to be freed */
+       const StrBuf *FileName;
        /* Raw copy of our original token; for error printing */
        StrBuf *FlatToken;
        /* Which line did the template parser pick us up in? For error printing */
@@ -164,7 +165,7 @@ struct WCTemplputParams {
        WCTemplateToken *Tokens;
        WCTemplputParams *Sub, *Super;
        WCConditionalFunc ExitCtx;
-        long ExitCTXID;
+       long ExitCTXID;
 };
 
 
@@ -177,10 +178,10 @@ typedef struct _ConditionalStruct {
 } ConditionalStruct;
 
 
-typedef void (*SubTemplFunc)(StrBuf *TemplBuffer, WCTemplputParams *TP);
-typedef HashList *(*RetrieveHashlistFunc)(StrBuf *Target, WCTemplputParams *TP);
-typedef void (*HashDestructorFunc) (HashList **KillMe);
-typedef int (*FilterByParamFunc)(const char* key, long len, void *Context, StrBuf *Target, WCTemplputParams *TP);
+typedef void (*SubTemplFunc)(StrBuf * TemplBuffer, WCTemplputParams * TP);
+typedef HashList *(*RetrieveHashlistFunc)(StrBuf * Target, WCTemplputParams * TP);
+typedef void (*HashDestructorFunc)(HashList ** KillMe);
+typedef int (*FilterByParamFunc)(const char *key, long len, void *Context, StrBuf * Target, WCTemplputParams * TP);
 
 extern WCTemplputParams NoCtx;
 
@@ -190,6 +191,7 @@ extern WCTemplputParams NoCtx;
 #define ERR_NAME 0
 #define ERR_PARM1 1
 #define ERR_PARM2 2
+
 /**
  * @ingroup subst
  * @brief log an error while evaluating a token; print it to the actual template 
@@ -197,12 +199,10 @@ extern WCTemplputParams NoCtx;
  * @param Type What sort of thing are we talking about? Tokens? Conditionals?
  * @param TP grab our set of default information here
  * @param Format for the custom error message
- */ 
-void LogTemplateError (StrBuf *Target, 
-                      const char *Type, 
-                      int ErrorPos, 
-                      WCTemplputParams *TP, 
-                      const char *Format, ...)__attribute__((__format__(__printf__,5,6)));
+ */
+void LogTemplateError(StrBuf * Target,
+                     const char *Type,
+                     int ErrorPos, WCTemplputParams * TP, const char *Format, ...) __attribute__((__format__(__printf__, 5, 6)));
 
 
 /**
@@ -211,8 +211,8 @@ void LogTemplateError (StrBuf *Target,
  * @param Target your Target Buffer to print the error message next to the log
  * @param Type What sort of thing are we talking about? Tokens? Conditionals?
  * @param Format for the custom error message
- */ 
-void LogError (StrBuf *Target, const char *Type, const char *Format, ...);
+ */
+void LogError(StrBuf * Target, const char *Type, const char *Format, ...);
 
 /**
  * @ingroup subst
@@ -228,20 +228,13 @@ void LogError (StrBuf *Target, const char *Type, const char *Format, ...);
  * @param Value reference to the string of the token; don't free me.
  * @param len the length of Value
  */
-void GetTemplateTokenString(StrBuf *Target, 
-                           WCTemplputParams *TP,
-                           int N,
-                           const char **Value, 
-                           long *len);
+void GetTemplateTokenString(StrBuf * Target, WCTemplputParams * TP, int N, const char **Value, long *len);
+
 /**
  * @ingroup subst
  * @return whether @ref GetTemplateTokenString would be able to give you a string
  */
-int HaveTemplateTokenString(StrBuf *Target, 
-                           WCTemplputParams *TP,
-                           int N,
-                           const char **Value, 
-                           long *len);
+int HaveTemplateTokenString(StrBuf * Target, WCTemplputParams * TP, int N, const char **Value, long *len);
 
 
 
@@ -259,9 +252,7 @@ int HaveTemplateTokenString(StrBuf *Target,
  * @param dflt default value to be retrieved if not found in preferences
  * \returns the long value
  */
-long GetTemplateTokenNumber(StrBuf *Target, 
-                           WCTemplputParams *TP, 
-                           int N, long dflt);
+long GetTemplateTokenNumber(StrBuf * Target, WCTemplputParams * TP, int N, long dflt);
 
 /**
  * @brief put a token value into the template
@@ -276,18 +267,13 @@ long GetTemplateTokenNumber(StrBuf *Target,
  * @param FormatTypeIndex which parameter contains the escaping functionality?
  *        if this token doesn't have as much parameters, plain append is done.
  */
-void StrBufAppendTemplate(StrBuf *Target, 
-                         WCTemplputParams *TP,
-                         const StrBuf *Source, 
-                         int FormatTypeIndex);
+void StrBufAppendTemplate(StrBuf * Target, WCTemplputParams * TP, const StrBuf * Source, int FormatTypeIndex);
 
-void StrBufAppendTemplateStr(StrBuf *Target, 
-                            WCTemplputParams *TP,
-                            const char *Source, 
-                            int FormatTypeIndex);
+void StrBufAppendTemplateStr(StrBuf * Target, WCTemplputParams * TP, const char *Source, int FormatTypeIndex);
 
 
 #define RegisterNamespace(a, b, c, d, e, f) RegisterNS(a, sizeof(a)-1, b, c, d, e, f)
+
 /**
  * @ingroup subst
  * @brief register a template token handler
@@ -299,12 +285,8 @@ void StrBufAppendTemplateStr(StrBuf *Target,
  *        syntax checks here or pre-evaluate stuff for better performance
  * @param ContextRequired if your token requires a specific context, else say CTX_NONE here.
  */
-void RegisterNS(const char *NSName, long len, 
-               int nMinArgs, 
-               int nMaxArgs, 
-               WCHandlerFunc HandlerFunc,
-               WCPreevalFunc PreEvalFunc,
-               int ContextRequired);
+void RegisterNS(const char *NSName, long len,
+               int nMinArgs, int nMaxArgs, WCHandlerFunc HandlerFunc, WCPreevalFunc PreEvalFunc, int ContextRequired);
 
 /**
  * @ingroup subst
@@ -318,11 +300,8 @@ void RegisterNS(const char *NSName, long len,
  * @param ExitCtxCond if non-NULL, will be called after the area of the conditional is left behind.
  * @param ContextRequired if your token requires a specific context, else say CTX_NONE here.
  */
-void RegisterContextConditional(const char *Name, long len, 
-                               int nParams,
-                               WCConditionalFunc CondF, 
-                               WCConditionalFunc ExitCtxCond,
-                               int ContextRequired);
+void RegisterContextConditional(const char *Name, long len,
+                               int nParams, WCConditionalFunc CondF, WCConditionalFunc ExitCtxCond, int ContextRequired);
 
 #define RegisterCtxConditional(Name, nParams, CondF, ExitCtxCond, ContextRequired) \
        RegisterContextConditional(Name, sizeof(Name) -1, nParams, CondF, ExitCtxCond, ContextRequired)
@@ -341,8 +320,8 @@ void RegisterContextConditional(const char *Name, long len,
  * @param len length of Name
  * @param Value the value to associate with Name
  */
-void RegisterTokenParamDefine(const char *Name, long len, 
-                             long Value);
+void RegisterTokenParamDefine(const char *Name, long len, long Value);
+
 /**
  * teh r0x0r! forward your favourite define from C to the templates with one easy call!
  */
@@ -355,63 +334,52 @@ void RegisterTokenParamDefine(const char *Name, long len,
  * @param len length of Name
  * @param Value the value to return if not found
  */
-long GetTokenDefine(const char *Name, 
-                   long len, 
-                   long DefValue);
+long GetTokenDefine(const char *Name, long len, long DefValue);
 
 
 #define IT_NOFLAG 0
 #define IT_FLAG_DETECT_GROUPCHANGE (1<<0)
-#define IT_ADDT_PARAM(n) 5 + n /* If you have AdditionalParams, use this macro to fetch them. */
+#define IT_ADDT_PARAM(n) 5 + n /* If you have AdditionalParams, use this macro to fetch them. */
 #define RegisterIterator(a, b, c, d, e, f, g, h, i) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e, f, NULL, g, h, i)
 #define RegisterFilteredIterator(a, b, c, d, e, f, g, h, i, j) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e, f, g, h, i, j)
-void RegisterITERATOR(const char *Name, long len, /* Our identifier */
-                     int AdditionalParams,       /* do we use more parameters? */
-                     HashList *StaticList,       /* pointer to webcit lifetime hashlists */
-                     RetrieveHashlistFunc GetHash, /* else retrieve the hashlist by calling this function */
-                     SubTemplFunc DoSubTempl,       /* call this function on each iteration for svput & friends */
-                     HashDestructorFunc Destructor, /* use this function to shut down the hash; NULL if its a reference */
-                     FilterByParamFunc Filter,      /* use this function if you want to skip items */
-                     CtxType ContextType,               /* which context do we provide to the subtemplate? */
-                     CtxType XPectContextType,          /* which context do we expct to be called in? */
+void RegisterITERATOR(const char *Name, long len,      /* Our identifier */
+                     int AdditionalParams,     /* do we use more parameters? */
+                     HashList * StaticList,    /* pointer to webcit lifetime hashlists */
+                     RetrieveHashlistFunc GetHash,     /* else retrieve the hashlist by calling this function */
+                     SubTemplFunc DoSubTempl,  /* call this function on each iteration for svput & friends */
+                     HashDestructorFunc Destructor,    /* use this function to shut down the hash; NULL if its a reference */
+                     FilterByParamFunc Filter, /* use this function if you want to skip items */
+                     CtxType ContextType,      /* which context do we provide to the subtemplate? */
+                     CtxType XPectContextType, /* which context do we expct to be called in? */
                      int Flags);
 
 
 
-void StackDynamicContext(WCTemplputParams *Super, 
-                        WCTemplputParams *Sub, 
+void StackDynamicContext(WCTemplputParams * Super,
+                        WCTemplputParams * Sub,
                         void *Context,
-                        CtxType ContextType,
-                        int nArgs,
-                        WCTemplateToken *Tokens, 
-                        WCConditionalFunc ExitCtx,
-                        long ExitCTXID);
+                        CtxType ContextType, int nArgs, WCTemplateToken * Tokens, WCConditionalFunc ExitCtx, long ExitCTXID);
 
 #define StackContext(Super, Sub, Context, ContextType, nArgs, Tokens) \
        StackDynamicContext(Super, Sub, Context, ContextType, nArgs, Tokens, NULL, 0)
 
 
-void UnStackContext(WCTemplputParams *Sub);
+void UnStackContext(WCTemplputParams * Sub);
 
 
 
-CompareFunc RetrieveSort(WCTemplputParams *TP, 
-                        const char *OtherPrefix, long OtherPrefixLen,  
-                        const char *Default, long ldefault, 
-                        long DefaultDirection);
-void RegisterSortFunc(const char *name, long len, 
+CompareFunc RetrieveSort(WCTemplputParams * TP,
+                        const char *OtherPrefix, long OtherPrefixLen, const char *Default, long ldefault, long DefaultDirection);
+void RegisterSortFunc(const char *name, long len,
                      const char *prepend, long preplen,
-                     CompareFunc Forward, 
-                     CompareFunc Reverse, 
-                     CompareFunc GroupChange, 
-                     CtxType ContextType);
+                     CompareFunc Forward, CompareFunc Reverse, CompareFunc GroupChange, CtxType ContextType);
 
 void dbg_print_longvector(long *LongVector);
 
 #define do_template(a) DoTemplate(a, sizeof(a) -1, NULL, &NoCtx)
-const StrBuf *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);
 
 
-int CompareSubstToToken(TemplateParam *ParamToCompare, TemplateParam *ParamToLookup);
-int CompareSubstToStrBuf(StrBuf *Compare, TemplateParam *ParamToLookup);
+int CompareSubstToToken(TemplateParam * ParamToCompare, TemplateParam * ParamToLookup);
+int CompareSubstToStrBuf(StrBuf * Compare, TemplateParam * ParamToLookup);
index 5dbe60435631534f2125b8ded2ee956d8d8eb1f4..97dd184f9225330db91b544e71fae11ed5e0f65f 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Displays the "Summary Page"
  *
@@ -32,8 +33,7 @@ void output_date(void) {
        wc_printf("%s", buf);
 }
 
-void tmplput_output_date(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_output_date(StrBuf * Target, WCTemplputParams * TP) {
        struct tm tm;
        time_t now;
        char buf[128];
@@ -59,10 +59,11 @@ void new_messages_section(void) {
 
 
        number_of_rooms_to_check = num_tokens(rooms_to_check, '|');
-       if (number_of_rooms_to_check == 0) return;
+       if (number_of_rooms_to_check == 0)
+               return;
 
        wc_printf("<table border=\"0\" width=\"100%%\">\n");
-       for (i=0; i<number_of_rooms_to_check; ++i) {
+       for (i = 0; i < number_of_rooms_to_check; ++i) {
                extract_token(room, rooms_to_check, i, '|', sizeof room);
 
                serv_printf("GOTO %s", room);
@@ -73,10 +74,8 @@ void new_messages_section(void) {
                        urlescputs(room);
                        wc_printf("\">");
                        escputs(room);
-                       wc_printf("</a></td><td>%d/%d</td></tr>\n",
-                               extract_int(&buf[4], 1),
-                               extract_int(&buf[4], 2)
-                       );
+                       wc_printf("</a></td><td>%d/%d</td></tr>\n", extract_int(&buf[4], 1), extract_int(&buf[4], 2)
+                           );
                }
        }
        wc_printf("</table>\n");
@@ -116,7 +115,7 @@ void tasks_section(void) {
        if (num_msgs > 0) {
                at = GetNewHashPos(WC->summ, 0);
                while (GetNextHashPos(WC->summ, at, &HKLen, &HashKey, &vMsg)) {
-                       Msg = (message_summary*) vMsg;          
+                       Msg = (message_summary *) vMsg;
                        tasks_LoadMsgFromServer(NULL, NULL, Msg, 0, 0);
                }
                DeleteHashPos(&at);
@@ -150,29 +149,23 @@ void calendar_section(void) {
        Stat.maxload = 10000;
        Stat.lowest_found = (-1);
        Stat.highest_found = (-1);
-       
+
        Buf = NewStrBufPlain(HKEY("_CALENDAR_"));
        gotoroom(Buf);
        FreeStrBuf(&Buf);
-       if ( (WC->CurRoom.view != VIEW_CALENDAR) && (WC->CurRoom.view != VIEW_CALBRIEF) ) {
+       if ((WC->CurRoom.view != VIEW_CALENDAR) && (WC->CurRoom.view != VIEW_CALBRIEF)) {
                num_msgs = 0;
        }
        else {
                num_msgs = load_msg_ptrs("MSGS ALL", NULL, NULL, &Stat, NULL, NULL, NULL, NULL, 0);
        }
-       calendar_GetParamsGetServerCall(&Stat, 
-                                       &v,
-                                       readnew, 
-                                       cmd, 
-                                       sizeof(cmd),
-                                       filter,
-                                       sizeof(filter));
+       calendar_GetParamsGetServerCall(&Stat, &v, readnew, cmd, sizeof(cmd), filter, sizeof(filter));
 
 
        if (num_msgs > 0) {
                at = GetNewHashPos(WC->summ, 0);
                while (GetNextHashPos(WC->summ, at, &HKLen, &HashKey, &vMsg)) {
-                       Msg = (message_summary*) vMsg;          
+                       Msg = (message_summary *) vMsg;
                        calendar_LoadMsgFromServer(NULL, &v, Msg, 0, 0);
                }
                DeleteHashPos(&at);
@@ -185,13 +178,13 @@ void calendar_section(void) {
        __calendar_Cleanup(&v);
 }
 
-void tmplput_new_messages_section(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_new_messages_section(StrBuf * Target, WCTemplputParams * TP) {
        new_messages_section();
 }
-void tmplput_tasks_section(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_tasks_section(StrBuf * Target, WCTemplputParams * TP) {
        tasks_section();
 }
-void tmplput_calendar_section(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_calendar_section(StrBuf * Target, WCTemplputParams * TP) {
        calendar_section();
 }
 
@@ -199,22 +192,17 @@ void tmplput_calendar_section(StrBuf *Target, WCTemplputParams *TP) {
 /*
  * summary page
  */
-void display_summary_page(void)
-{
-       output_headers(1, 1, 1, 0, 0, 0); 
+void display_summary_page(void) {
+       output_headers(1, 1, 1, 0, 0, 0);
        do_template("summary_page");
        wDumpContent(1);
 }
 
 
-void 
-InitModule_SUMMARY
-(void)
-{
+void InitModule_SUMMARY(void) {
        RegisterNamespace("TIME:NOW", 0, 0, tmplput_output_date, NULL, CTX_NONE);
        WebcitAddUrlHandler(HKEY("summary"), "", 0, display_summary_page, ANONYMOUS);
        WebcitAddUrlHandler(HKEY("new_messages_html"), "", 0, new_messages_section, AJAX);
        WebcitAddUrlHandler(HKEY("tasks_inner_html"), "", 0, tasks_section, AJAX);
        WebcitAddUrlHandler(HKEY("calendar_inner_html"), "", 0, calendar_section, AJAX);
 }
-
index 7c699699afb83939feddd2410f390111ff82ece5..5e79bd90e2b92c8241cfefea863591f646c157e8 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * WebCit "system dependent" code.
  *
 #endif
 
 pthread_mutex_t Critters[MAX_SEMAPHORES];      /* Things needing locking */
-pthread_key_t MyConKey;                                /* TSD key for MyContext() */
-pthread_key_t MyReq;                           /* TSD key for MyReq() */
+pthread_key_t MyConKey;                /* TSD key for MyContext() */
+pthread_key_t MyReq;           /* TSD key for MyReq() */
 int msock;                     /* master listening socket */
-int time_to_die = 0;            /* Nonzero if server is shutting down */
+int time_to_die = 0;           /* Nonzero if server is shutting down */
 
-extern void *context_loop(ParsedHttpHdrs *Hdr);
+extern void *context_loop(ParsedHttpHdrs * Hdr);
 extern void *housekeeping_loop(void);
 extern void do_housekeeping(void);
 
-char file_etc_mimelist[PATH_MAX]="";
+char file_etc_mimelist[PATH_MAX] = "";
 
 char etc_dir[PATH_MAX];
-char static_dir[PATH_MAX];             /* calculated on startup */
-char static_local_dir[PATH_MAX];               /* calculated on startup */
-char static_icon_dir[PATH_MAX];          /* where should we find our mime icons? */
-char  *static_dirs[]={                         /* needs same sort order as the web mapping */
+char static_dir[PATH_MAX];     /* calculated on startup */
+char static_local_dir[PATH_MAX];       /* calculated on startup */
+char static_icon_dir[PATH_MAX];        /* where should we find our mime icons? */
+char *static_dirs[] = {                /* needs same sort order as the web mapping */
        "./static",
        "./static.local",
        "./tiny_mce",
@@ -78,14 +79,13 @@ char  *static_dirs[]={                              /* needs same sort order as the web mapping */
 };
 
 int ExitPipe[2];
-HashList *GZMimeBlackList = NULL; /* mimetypes which shouldn't be gzip compressed */
+HashList *GZMimeBlackList = NULL;      /* mimetypes which shouldn't be gzip compressed */
 
-void LoadMimeBlacklist(void)
-{
+void LoadMimeBlacklist(void) {
        StrBuf *MimeBlackLine;
        IOBuffer IOB;
        eReadState state;
-       
+
        memset(&IOB, 0, sizeof(IOBuffer));
        IOB.fd = open(file_etc_mimelist, O_RDONLY);
 
@@ -93,22 +93,17 @@ void LoadMimeBlacklist(void)
        MimeBlackLine = NewStrBuf();
        GZMimeBlackList = NewHash(1, NULL);
 
-       do
-       {
+       do {
                state = StrBufChunkSipLine(MimeBlackLine, &IOB);
 
-               switch (state)
-               {
+               switch (state) {
                case eMustReadMore:
                        if (StrBuf_read_one_chunk_callback(IOB.fd, 0, &IOB) <= 0)
                                state = eReadFail;
                        break;
                case eReadSuccess:
-                       if ((StrLength(MimeBlackLine) > 1) && 
-                           (*ChrPtr(MimeBlackLine) != '#'))
-                       {
-                               Put(GZMimeBlackList, SKEY(MimeBlackLine),
-                                   (void*) 1, reference_free_handler);
+                       if ((StrLength(MimeBlackLine) > 1) && (*ChrPtr(MimeBlackLine) != '#')) {
+                               Put(GZMimeBlackList, SKEY(MimeBlackLine), (void *) 1, reference_free_handler);
                        }
                        FlushStrBuf(MimeBlackLine);
                        break;
@@ -121,34 +116,29 @@ void LoadMimeBlacklist(void)
        while (state != eReadFail);
 
        close(IOB.fd);
-       
+
        FreeStrBuf(&IOB.Buf);
        FreeStrBuf(&MimeBlackLine);
 }
 
-void CheckGZipCompressionAllowed(const char *MimeType, long MLen)
-{
+void CheckGZipCompressionAllowed(const char *MimeType, long MLen) {
        void *v;
 
        if (WC->Hdr->HR.gzip_ok)
-           WC->Hdr->HR.gzip_ok = GetHash(GZMimeBlackList, MimeType, MLen, &v) == 0;
+               WC->Hdr->HR.gzip_ok = GetHash(GZMimeBlackList, MimeType, MLen, &v) == 0;
 }
 
-void InitialiseSemaphores(void)
-{
+void InitialiseSemaphores(void) {
        int i;
 
        /* Set up a bunch of semaphores to be used for critical sections */
-       for (i=0; i<MAX_SEMAPHORES; ++i) {
+       for (i = 0; i < MAX_SEMAPHORES; ++i) {
                pthread_mutex_init(&Critters[i], NULL);
        }
 
-       if (pipe(ExitPipe))
-       {
-               syslog(LOG_WARNING, "Failed to open exit pipe: %d [%s]\n", 
-                      errno, 
-                      strerror(errno));
-               
+       if (pipe(ExitPipe)) {
+               syslog(LOG_WARNING, "Failed to open exit pipe: %d [%s]\n", errno, strerror(errno));
+
                exit(-1);
        }
 }
@@ -156,36 +146,32 @@ void InitialiseSemaphores(void)
 /*
  * Obtain a semaphore lock to begin a critical section.
  */
-void begin_critical_section(int which_one)
-{
+void begin_critical_section(int which_one) {
        pthread_mutex_lock(&Critters[which_one]);
 }
 
 /*
  * Release a semaphore lock to end a critical section.
  */
-void end_critical_section(int which_one)
-{
+void end_critical_section(int which_one) {
        pthread_mutex_unlock(&Critters[which_one]);
 }
 
 
-void ShutDownWebcit(void)
-{
+void ShutDownWebcit(void) {
 
        DeleteHash(&GZMimeBlackList);
-       free_zone_directory ();
-       icaltimezone_release_zone_tab ();
-       icalmemory_free_ring ();
-       ShutDownLibCitadel ();
-       shutdown_modules ();
+       free_zone_directory();
+       icaltimezone_release_zone_tab();
+       icalmemory_free_ring();
+       ShutDownLibCitadel();
+       shutdown_modules();
 }
 
 /*
  * Entry point for worker threads
  */
-void worker_entry(void)
-{
+void worker_entry(void) {
        int ssock;
        int i = 0;
        int fail_this_transaction = 0;
@@ -193,71 +179,72 @@ void worker_entry(void)
 
        memset(&Hdr, 0, sizeof(ParsedHttpHdrs));
        Hdr.HR.eReqType = eGET;
-       http_new_modules(&Hdr); 
+       http_new_modules(&Hdr);
 
        do {
                /* Each worker thread blocks on accept() while waiting for something to do. */
                fail_this_transaction = 0;
-               ssock = -1; 
+               ssock = -1;
                errno = EAGAIN;
                do {
                        fd_set wset;
                        --num_threads_executing;
-                        FD_ZERO(&wset);
-                        FD_SET(msock, &wset);
-                        FD_SET(ExitPipe[1], &wset);
+                       FD_ZERO(&wset);
+                       FD_SET(msock, &wset);
+                       FD_SET(ExitPipe[1], &wset);
 
-                        select(msock + 1, NULL, &wset, NULL, NULL);
+                       select(msock + 1, NULL, &wset, NULL, NULL);
                        if (time_to_die)
                                break;
 
                        ssock = accept(msock, NULL, 0);
                        ++num_threads_executing;
-                       if (ssock < 0) fail_this_transaction = 1;
-               } while ((msock > 0) && (ssock < 0)  && (time_to_die == 0));
+                       if (ssock < 0)
+                               fail_this_transaction = 1;
+               } while ((msock > 0) && (ssock < 0) && (time_to_die == 0));
 
-               if ((msock == -1)||(time_to_die))
-               {/* ok, we're going down. */
+               if ((msock == -1) || (time_to_die)) {   /* ok, we're going down. */
                        int shutdown = 0;
 
                        /* The first thread to get here will have to do the cleanup.
                         * Make sure it's really just one.
                         */
                        begin_critical_section(S_SHUTDOWN);
-                       if (msock == -1)
-                       {
+                       if (msock == -1) {
                                msock = -2;
                                shutdown = 1;
                        }
                        end_critical_section(S_SHUTDOWN);
-                       if (shutdown == 1)
-                       {/* we're the one to cleanup the mess. */
+                       if (shutdown == 1) {    /* we're the one to cleanup the mess. */
                                http_destroy_modules(&Hdr);
                                syslog(LOG_DEBUG, "I'm master shutdown: tagging sessions to be killed.\n");
                                shutdown_sessions();
                                syslog(LOG_DEBUG, "master shutdown: waiting for others\n");
-                               sleeeeeeeeeep(1); /* wait so some others might finish... */
+                               sleeeeeeeeeep(1);       /* wait so some others might finish... */
                                syslog(LOG_DEBUG, "master shutdown: cleaning up sessions\n");
                                do_housekeeping();
                                syslog(LOG_DEBUG, "master shutdown: cleaning up libical\n");
 
                                ShutDownWebcit();
 
-                               syslog(LOG_DEBUG, "master shutdown exiting.\n");                                
+                               syslog(LOG_DEBUG, "master shutdown exiting.\n");
                                exit(0);
                        }
                        break;
                }
-               if (ssock < 0 ) continue;
+               if (ssock < 0)
+                       continue;
 
                check_thread_pool_size();
 
                /* Now do something. */
                if (msock < 0) {
-                       if (ssock > 0) close (ssock);
+                       if (ssock > 0)
+                               close(ssock);
                        syslog(LOG_DEBUG, "in between.");
                        pthread_exit(NULL);
-               } else {
+               }
+               else {
                        /* Got it? do some real work! */
                        /* Set the SO_REUSEADDR socket option */
                        i = 1;
@@ -271,18 +258,17 @@ void worker_entry(void)
                                        close(ssock);
                                }
                        }
-                       else 
+                       else
 #endif
                        {
-                               int fdflags; 
+                               int fdflags;
                                fdflags = fcntl(ssock, F_GETFL);
                                if (fdflags < 0)
-                                       syslog(LOG_WARNING, "unable to get server socket flags! %s \n",
-                                               strerror(errno));
+                                       syslog(LOG_WARNING, "unable to get server socket flags! %s \n", strerror(errno));
                                fdflags = fdflags | O_NONBLOCK;
                                if (fcntl(ssock, F_SETFL, fdflags) < 0)
                                        syslog(LOG_WARNING, "unable to set server socket nonblocking flags! %s \n",
-                                               strerror(errno));
+                                              strerror(errno));
                        }
 
                        if (fail_this_transaction == 0) {
@@ -343,9 +329,9 @@ void graceful_shutdown(int signum) {
        fd = msock;
        msock = -1;
        time_to_die = 1;
-       FD=fdopen(fd, "a+");
-       fflush (FD);
-       fclose (FD);
+       FD = fdopen(fd, "a+");
+       fflush(FD);
+       fclose(FD);
        close(fd);
        write(ExitPipe[0], HKEY("                              "));
 }
@@ -354,8 +340,7 @@ void graceful_shutdown(int signum) {
 /*
  * Start running as a daemon.
  */
-void start_daemon(char *pid_file) 
-{
+void start_daemon(char *pid_file) {
        int status = 0;
        pid_t child = 0;
        FILE *fp;
@@ -389,19 +374,19 @@ void start_daemon(char *pid_file)
        do {
                current_child = fork();
 
-       
+
                if (current_child < 0) {
                        perror("fork");
-                       ShutDownLibCitadel ();
+                       ShutDownLibCitadel();
                        exit(errno);
                }
-       
+
                else if (current_child == 0) {  /* child process */
                        signal(SIGHUP, graceful_shutdown);
 
-                       return; /* continue starting webcit. */
+                       return; /* continue starting webcit. */
                }
-               else { /* watcher process */
+               else {          /* watcher process */
                        if (pid_file) {
                                fp = fopen(pid_file, "w");
                                if (fp != NULL) {
@@ -423,7 +408,7 @@ void start_daemon(char *pid_file)
                        }
 
                        /* Exit code 101-109 means the watcher should exit */
-                       else if ( (WEXITSTATUS(status) >= 101) && (WEXITSTATUS(status) <= 109) ) {
+                       else if ((WEXITSTATUS(status) >= 101) && (WEXITSTATUS(status) <= 109)) {
                                do_restart = 0;
                        }
 
@@ -443,7 +428,7 @@ void start_daemon(char *pid_file)
        if (pid_file) {
                unlink(pid_file);
        }
-       ShutDownLibCitadel ();
+       ShutDownLibCitadel();
        exit(WEXITSTATUS(status));
 }
 
@@ -451,8 +436,7 @@ void start_daemon(char *pid_file)
 /*
  * Spawn an additional worker thread into the pool.
  */
-void spawn_another_worker_thread()
-{
+void spawn_another_worker_thread() {
        pthread_t SessThread;   /* Thread descriptor */
        pthread_attr_t attr;    /* Thread attributes */
        int ret;
@@ -483,13 +467,11 @@ void spawn_another_worker_thread()
 }
 
 
-void
-webcit_calc_dirs_n_files(int relh, const char *basedir, int home, char *webcitdir, char *relhome)
-{
-       char dirbuffer[PATH_MAX]="";
+void webcit_calc_dirs_n_files(int relh, const char *basedir, int home, char *webcitdir, char *relhome) {
+       char dirbuffer[PATH_MAX] = "";
        /* calculate all our path on a central place */
-    /* where to keep our config */
-       
+       /* where to keep our config */
+
 #define COMPUTE_DIRECTORY(SUBDIR) memcpy(dirbuffer,SUBDIR, sizeof dirbuffer);\
        snprintf(SUBDIR,sizeof SUBDIR,  "%s%s%s%s%s%s%s", \
                         (home&!relh)?webcitdir:basedir, \
@@ -499,25 +481,22 @@ webcit_calc_dirs_n_files(int relh, const char *basedir, int home, char *webcitdi
              (relhome[0]!='\0')?"/":"",\
                         dirbuffer,\
                         (dirbuffer[0]!='\0')?"/":"");
-       basedir=RUNDIR;
+       basedir = RUNDIR;
        COMPUTE_DIRECTORY(socket_dir);
-       basedir=WWWDIR "/static";
+       basedir = WWWDIR "/static";
        COMPUTE_DIRECTORY(static_dir);
-       basedir=WWWDIR "/static/icons";
+       basedir = WWWDIR "/static/icons";
        COMPUTE_DIRECTORY(static_icon_dir);
-       basedir=WWWDIR "/static.local";
+       basedir = WWWDIR "/static.local";
        COMPUTE_DIRECTORY(static_local_dir);
        StripSlashes(static_dir, 1);
        StripSlashes(static_icon_dir, 1);
        StripSlashes(static_local_dir, 1);
 
-       basedir=ETCDIR;
+       basedir = ETCDIR;
        COMPUTE_DIRECTORY(etc_dir);
        StripSlashes(etc_dir, 1);
-       snprintf(file_etc_mimelist,
-                sizeof file_etc_mimelist, 
-                "%s/nogz-mimetypes.txt",
-                etc_dir);
+       snprintf(file_etc_mimelist, sizeof file_etc_mimelist, "%s/nogz-mimetypes.txt", etc_dir);
 
        /* we should go somewhere we can leave our coredump, if enabled... */
        syslog(LOG_INFO, "Changing directory to %s\n", socket_dir);
@@ -526,8 +505,7 @@ webcit_calc_dirs_n_files(int relh, const char *basedir, int home, char *webcitdi
        }
 }
 
-void drop_root(uid_t UID)
-{
+void drop_root(uid_t UID) {
        struct passwd pw, *pwp = NULL;
 #ifdef HAVE_GETPWUID_R
        char pwbuf[SIZ];
@@ -538,28 +516,25 @@ void drop_root(uid_t UID)
         * corresponding group ids
         */
        if (UID != -1) {
-               
+
 #ifdef HAVE_GETPWUID_R
 #ifdef SOLARIS_GETPWUID
                pwp = getpwuid_r(UID, &pw, pwbuf, sizeof(pwbuf));
-#else /* SOLARIS_GETPWUID */
+#else                          /* SOLARIS_GETPWUID */
                getpwuid_r(UID, &pw, pwbuf, sizeof(pwbuf), &pwp);
-#endif /* SOLARIS_GETPWUID */
-#else /* HAVE_GETPWUID_R */
+#endif                         /* SOLARIS_GETPWUID */
+#else                          /* HAVE_GETPWUID_R */
                pwp = NULL;
-#endif /* HAVE_GETPWUID_R */
+#endif                         /* HAVE_GETPWUID_R */
 
                if (pwp == NULL)
-                       syslog(LOG_CRIT, "WARNING: getpwuid(%d): %s\n"
-                               "Group IDs will be incorrect.\n", UID,
-                               strerror(errno));
+                       syslog(LOG_CRIT, "WARNING: getpwuid(%d): %s\n" "Group IDs will be incorrect.\n", UID, strerror(errno));
                else {
                        initgroups(pw.pw_name, pw.pw_gid);
                        if (setgid(pw.pw_gid))
-                               syslog(LOG_CRIT, "setgid(%ld): %s\n", (long)pw.pw_gid,
-                                       strerror(errno));
+                               syslog(LOG_CRIT, "setgid(%ld): %s\n", (long) pw.pw_gid, strerror(errno));
                }
-               syslog(LOG_INFO, "Changing uid to %ld\n", (long)UID);
+               syslog(LOG_INFO, "Changing uid to %ld\n", (long) UID);
                if (setuid(UID) != 0) {
                        syslog(LOG_CRIT, "setuid() failed: %s\n", strerror(errno));
                }
@@ -573,15 +548,14 @@ void drop_root(uid_t UID)
 /*
  * print the actual stack frame.
  */
-void wc_backtrace(long LogLevel)
-{
+void wc_backtrace(long LogLevel) {
 #ifdef HAVE_BACKTRACE
        void *stack_frames[50];
        size_t size, i;
        char **strings;
 
 
-       size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*));
+       size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void *));
        strings = backtrace_symbols(stack_frames, size);
        for (i = 0; i < size; i++) {
                if (strings != NULL)
index 99f84533ebad507d4b8335a1d21c41ebd43ea5e5..f73fbf971fd9b91382fd0c5a1f111664cec2974c 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2012 by the citadel.org team
  *
@@ -18,8 +19,7 @@
  *  enter_cmd which command to enter at the citadel server???
  *  regoto should we go to that room again after executing that command?
  */
-void save_edit(char *description, char *enter_cmd, int regoto)
-{
+void save_edit(char *description, char *enter_cmd, int regoto) {
        StrBuf *Line;
        const StrBuf *templ;
 
@@ -36,7 +36,7 @@ void save_edit(char *description, char *enter_cmd, int regoto)
                putlbstr("success", 0);
                FreeStrBuf(&Line);
                if (templ != NULL) {
-                       output_headers(1, 0, 0, 0, 0, 0);       
+                       output_headers(1, 0, 0, 0, 0, 0);
                        DoTemplate(SKEY(templ), NULL, &NoCtx);
                        end_burst();
                }
@@ -53,26 +53,28 @@ void save_edit(char *description, char *enter_cmd, int regoto)
        AppendImportantMessage(_(" has been saved."), -1);
        putlbstr("success", 1);
        if (templ != NULL) {
-               output_headers(1, 0, 0, 0, 0, 0);       
+               output_headers(1, 0, 0, 0, 0, 0);
                DoTemplate(SKEY(templ), NULL, &NoCtx);
                end_burst();
        }
        else if (regoto) {
                smart_goto(WC->CurRoom.name);
-       } else {
+       }
+       else {
                display_main_menu();
                return;
        }
 }
 
 
-void editinfo(void) {save_edit(_("Room info"), "EINF 1", 1);}
-void editbio(void) { save_edit(_("Your bio"), "EBIO", 0); }
+void editinfo(void) {
+       save_edit(_("Room info"), "EINF 1", 1);
+}
+void editbio(void) {
+       save_edit(_("Your bio"), "EBIO", 0);
+}
 
-void 
-InitModule_SYSMSG
-(void)
-{
+void InitModule_SYSMSG(void) {
        WebcitAddUrlHandler(HKEY("editinfo"), "", 0, editinfo, 0);
        WebcitAddUrlHandler(HKEY("editbio"), "", 0, editbio, 0);
 }
index 4b58ba590a64c086ce8eba75dd18583f63ff4655..20f3e3583b13098d85f8343d2f022058036fc509 100644 (file)
@@ -9,31 +9,24 @@ void tabbed_dialog(int num_tabs, const char *tabnames[]) {
        int i;
 
        StrBufAppendPrintf(WC->trailing_javascript,
-               "var previously_selected_tab = '0';                                             \n"
-               "function tabsel(which_tab) {                                                   \n"
-               "       if (which_tab == previously_selected_tab) {                             \n"
-               "               return;                                                         \n"
-               "       }                                                                       \n"
-               "       $('tabdiv'+previously_selected_tab).style.display = 'none';             \n"
-               "       $('tabdiv'+which_tab).style.display = 'block';                          \n"
-               "       $('tabtd'+previously_selected_tab).className = 'tab_cell_edit';         \n"
-               "       $('tabtd'+which_tab).className = 'tab_cell_label';                      \n"
-               "       previously_selected_tab = which_tab;                                    \n"
-               "}                                                                              \n"
-       );
+                          "var previously_selected_tab = '0';                                          \n"
+                          "function tabsel(which_tab) {                                                        \n"
+                          "    if (which_tab == previously_selected_tab) {                             \n"
+                          "            return;                                                         \n"
+                          "    }                                                                       \n"
+                          "    $('tabdiv'+previously_selected_tab).style.display = 'none';             \n"
+                          "    $('tabdiv'+which_tab).style.display = 'block';                          \n"
+                          "    $('tabtd'+previously_selected_tab).className = 'tab_cell_edit';         \n"
+                          "    $('tabtd'+which_tab).className = 'tab_cell_label';                      \n"
+                          "    previously_selected_tab = which_tab;                                    \n"
+                          "}                                                                           \n");
 
        wc_printf("<table id=\"TheTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
-               "<tr align=\"center\" style=\"cursor:pointer\"><td>&nbsp;</td>"
-       );
+                 "<tr align=\"center\" style=\"cursor:pointer\"><td>&nbsp;</td>");
 
-       for (i=0; i<num_tabs; ++i) {
+       for (i = 0; i < num_tabs; ++i) {
                wc_printf("<td id=\"tabtd%d\" class=\"%s\" "
-                       "onClick='tabsel(\"%d\");'"
-                       ">",
-                       i,
-                       ( (i==0) ? "tab_cell_label" : "tab_cell_edit" ),
-                       i
-                       );
+                         "onClick='tabsel(\"%d\");'" ">", i, ((i == 0) ? "tab_cell_label" : "tab_cell_edit"), i);
                wc_printf("%s", tabnames[i]);
                wc_printf("</td>");
 
@@ -60,9 +53,8 @@ void begin_tab(int tabnum, int num_tabs) {
        else {
                wc_printf("<!-- begin tab %d of %d -->\n", tabnum, num_tabs);
                wc_printf("<div id=\"tabdiv%d\" style=\"display:%s\" class=\"tabcontent\" >",
-                       tabnum,
-                       ( (tabnum == 0) ? "block" : "none" )
-               );
+                         tabnum, ((tabnum == 0) ? "block" : "none")
+                   );
        }
 }
 
@@ -89,55 +81,37 @@ void end_tab(int tabnum, int num_tabs) {
 /*
  * print tabbed dialog
  */
-void StrTabbedDialog(StrBuf *Target, int num_tabs, StrBuf *tabnames[]) {
+void StrTabbedDialog(StrBuf * Target, int num_tabs, StrBuf * tabnames[]) {
        int i;
 
-       StrBufAppendBufPlain(
-               Target, 
-               HKEY(
-                       "<script type=\"text/javascript\">                                              "
-                       "var previously_selected_tab = '0';                                             "
-                       "function tabsel(which_tab) {                                                   "
-                       "       if (which_tab == previously_selected_tab) {                             "
-                       "               return;                                                         "
-                       "       }                                                                       "
-                       "       $('tabdiv'+previously_selected_tab).style.display = 'none';             "
-                       "       $('tabdiv'+which_tab).style.display = 'block';                          "
-                       "       $('tabtd'+previously_selected_tab).className = 'tab_cell_edit';         "
-                       "       $('tabtd'+which_tab).className = 'tab_cell_label';                      "
-                       "       previously_selected_tab = which_tab;                                    "
-                       "}                                                                              "
-                       "</script>                                                                      \n"
-                       ), 0);
-
-       StrBufAppendBufPlain(
-               Target, 
-               HKEY(
-                       "<table id=\"TheTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
-                       "<tr align=\"center\" style=\"cursor:pointer\"><td>&nbsp;</td>"
-                       ), 0);
-
-       for (i=0; i<num_tabs; ++i) {
-               StrBufAppendPrintf(
-                       Target, 
-                       "<td id=\"tabtd%d\" class=\"%s\" "
-                       "onClick='tabsel(\"%d\");'"
-                       ">",
-                       i,
-                       ( (i==0) ? "tab_cell_label" : "tab_cell_edit" ),
-                       i
-                       );
+       StrBufAppendBufPlain(Target,
+                            HKEY("<script type=\"text/javascript\">                                            "
+                                 "var previously_selected_tab = '0';                                           "
+                                 "function tabsel(which_tab) {                                                 "
+                                 "     if (which_tab == previously_selected_tab) {                             "
+                                 "             return;                                                         "
+                                 "     }                                                                       "
+                                 "     $('tabdiv'+previously_selected_tab).style.display = 'none';             "
+                                 "     $('tabdiv'+which_tab).style.display = 'block';                          "
+                                 "     $('tabtd'+previously_selected_tab).className = 'tab_cell_edit';         "
+                                 "     $('tabtd'+which_tab).className = 'tab_cell_label';                      "
+                                 "     previously_selected_tab = which_tab;                                    "
+                                 "}                                                                            "
+                                 "</script>                                                                    \n"), 0);
+
+       StrBufAppendBufPlain(Target,
+                            HKEY("<table id=\"TheTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
+                                 "<tr align=\"center\" style=\"cursor:pointer\"><td>&nbsp;</td>"), 0);
+
+       for (i = 0; i < num_tabs; ++i) {
+               StrBufAppendPrintf(Target,
+                                  "<td id=\"tabtd%d\" class=\"%s\" "
+                                  "onClick='tabsel(\"%d\");'" ">", i, ((i == 0) ? "tab_cell_label" : "tab_cell_edit"), i);
                StrEscAppend(Target, tabnames[i], NULL, 0, 0);
-               StrBufAppendBufPlain(
-                       Target, 
-                       HKEY(
-                               "</td>"
-                               "<td>&nbsp;</td>\n"), 0);
+               StrBufAppendBufPlain(Target, HKEY("</td>" "<td>&nbsp;</td>\n"), 0);
        }
 
-       StrBufAppendBufPlain(
-               Target, 
-               HKEY("</tr></table>\n"), 0);
+       StrBufAppendBufPlain(Target, HKEY("</tr></table>\n"), 0);
 }
 
 /*
@@ -147,34 +121,24 @@ void StrTabbedDialog(StrBuf *Target, int num_tabs, StrBuf *tabnames[]) {
  * num_tabs:    total number oftabs to be printed
  *
  */
-void StrBeginTab(StrBuf *Target, int tabnum, int num_tabs, StrBuf **Names) {
+void StrBeginTab(StrBuf * Target, int tabnum, int num_tabs, StrBuf ** Names) {
 
        if (tabnum == num_tabs) {
-               StrBufAppendBufPlain(
-                       Target, 
-                       HKEY("<!-- begin tab-common epilogue ["), 0);
+               StrBufAppendBufPlain(Target, HKEY("<!-- begin tab-common epilogue ["), 0);
                StrEscAppend(Target, Names[tabnum], NULL, 0, 2);
-               StrBufAppendBufPlain(
-                       Target, 
-                       HKEY("] -->\n<div class=\"tabcontent_submit\">"), 0);
+               StrBufAppendBufPlain(Target, HKEY("] -->\n<div class=\"tabcontent_submit\">"), 0);
        }
 
        else {
-               StrBufAppendBufPlain(
-                       Target, 
-                       HKEY("<!-- begin tab "), 0);
-               StrBufAppendPrintf(
-                       Target,  "%d of %d [",
-                       tabnum, num_tabs);
-               
+               StrBufAppendBufPlain(Target, HKEY("<!-- begin tab "), 0);
+               StrBufAppendPrintf(Target, "%d of %d [", tabnum, num_tabs);
+
                StrEscAppend(Target, Names[tabnum], NULL, 0, 2);
 
-               StrBufAppendPrintf(
-                       Target, 
-                       "] -->\n<div id=\"tabdiv%d\" style=\"display:%s\" class=\"tabcontent\" >",
-                       tabnum,
-                       ( (tabnum == 0) ? "block" : "none" )
-                       );
+               StrBufAppendPrintf(Target,
+                                  "] -->\n<div id=\"tabdiv%d\" style=\"display:%s\" class=\"tabcontent\" >",
+                                  tabnum, ((tabnum == 0) ? "block" : "none")
+                   );
        }
 }
 
@@ -184,27 +148,16 @@ void StrBeginTab(StrBuf *Target, int tabnum, int num_tabs, StrBuf **Names) {
  * num_tabs:    total number of tabs to be printed
  *
  */
-void StrEndTab(StrBuf *Target, int tabnum, int num_tabs) {
+void StrEndTab(StrBuf * Target, int tabnum, int num_tabs) {
 
        if (tabnum == num_tabs) {
-               StrBufAppendBufPlain(
-                       Target, 
-                       HKEY(
-                               "</div>\n"
-                               "<!-- end tab-common epilogue -->\n"), 0);
+               StrBufAppendBufPlain(Target, HKEY("</div>\n" "<!-- end tab-common epilogue -->\n"), 0);
        }
 
        else {
-               StrBufAppendPrintf(
-                       Target, 
-                       "</div>\n",
-                       "<!-- end tab %d of %d -->\n", tabnum, num_tabs
-               );
+               StrBufAppendPrintf(Target, "</div>\n", "<!-- end tab %d of %d -->\n", tabnum, num_tabs);
        }
-       if (havebstr("last_tabsel"))
-       {
+       if (havebstr("last_tabsel")) {
                StrBufAppendPrintf(Target, "<script type=\"text/javascript\">tabsel(%s);</script>", BSTR("last_tabsel"));
        }
 }
-
-
index b3543826f112313c83c196badcc6c449981d1e04..4ab7099977c08751b85f6a310e0838872e582682 100644 (file)
@@ -6,13 +6,14 @@
  * qsort filter to move completed tasks to bottom of task list
  */
 int task_completed_cmp(const void *vtask1, const void *vtask2) {
-       disp_cal * Task1 = (disp_cal *)GetSearchPayload(vtask1);
+       disp_cal *Task1 = (disp_cal *) GetSearchPayload(vtask1);
+
 /*     disp_cal * Task2 = (disp_cal *)GetSearchPayload(vtask2); */
 
        icalproperty_status t1 = icalcomponent_get_status((Task1)->cal);
        /* icalproperty_status t2 = icalcomponent_get_status(((struct disp_cal *)task2)->cal); */
-       
-       if (t1 == ICAL_STATUS_COMPLETED) 
+
+       if (t1 == ICAL_STATUS_COMPLETED)
                return 1;
        return 0;
 }
@@ -21,11 +22,11 @@ int task_completed_cmp(const void *vtask1, const void *vtask2) {
 /*
  * Helper function for do_tasks_view().  Returns the due date/time of a vtodo.
  */
-time_t get_task_due_date(icalcomponent *vtodo, int *is_date) {
+time_t get_task_due_date(icalcomponent * vtodo, int *is_date) {
        icalproperty *p;
 
        if (vtodo == NULL) {
-               return(0L);
+               return (0L);
        }
 
        /*
@@ -34,11 +35,7 @@ time_t get_task_due_date(icalcomponent *vtodo, int *is_date) {
         * structure until we get a VTODO.
         */
        if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
-               return get_task_due_date(
-                       icalcomponent_get_first_component(
-                               vtodo, ICAL_VTODO_COMPONENT
-                               ), is_date
-                       );
+               return get_task_due_date(icalcomponent_get_first_component(vtodo, ICAL_VTODO_COMPONENT), is_date);
        }
 
        p = icalcomponent_get_first_property(vtodo, ICAL_DUE_PROPERTY);
@@ -47,10 +44,10 @@ time_t get_task_due_date(icalcomponent *vtodo, int *is_date) {
 
                if (is_date)
                        *is_date = t.is_date;
-               return(icaltime_as_timet(t));
+               return (icaltime_as_timet(t));
        }
        else {
-               return(0L);
+               return (0L);
        }
 }
 
@@ -58,26 +55,25 @@ time_t get_task_due_date(icalcomponent *vtodo, int *is_date) {
  * Compare the due dates of two tasks (this is for sorting)
  */
 int task_due_cmp(const void *vtask1, const void *vtask2) {
-       disp_cal * Task1 = (disp_cal *)GetSearchPayload(vtask1);
-       disp_cal * Task2 = (disp_cal *)GetSearchPayload(vtask2);
+       disp_cal *Task1 = (disp_cal *) GetSearchPayload(vtask1);
+       disp_cal *Task2 = (disp_cal *) GetSearchPayload(vtask2);
 
        time_t t1;
        time_t t2;
 
-       t1 =  get_task_due_date(Task1->cal, NULL);
-       t2 =  get_task_due_date(Task2->cal, NULL);
-       if (t1 < t2) return(-1);
-       if (t1 > t2) return(1);
-       return(0);
+       t1 = get_task_due_date(Task1->cal, NULL);
+       t2 = get_task_due_date(Task2->cal, NULL);
+       if (t1 < t2)
+               return (-1);
+       if (t1 > t2)
+               return (1);
+       return (0);
 }
 
 /*
  * do the whole task view stuff
  */
-int tasks_RenderView_or_Tail(SharedMessageStatus *Stat, 
-                             void **ViewSpecific, 
-                             long oper)
-{
+int tasks_RenderView_or_Tail(SharedMessageStatus * Stat, void **ViewSpecific, long oper) {
        long hklen;
        const char *HashKey;
        void *vCal;
@@ -96,22 +92,20 @@ int tasks_RenderView_or_Tail(SharedMessageStatus *Stat,
        wc_printf(_("Date due"));
        wc_printf("</th><th>");
        wc_printf(_("Category"));
-       wc_printf(" (<select id=\"selectcategory\"><option value=\"showall\">%s</option></select>)</th></tr>\n",
-               _("Show All"));
+       wc_printf(" (<select id=\"selectcategory\"><option value=\"showall\">%s</option></select>)</th></tr>\n", _("Show All"));
 
        nItems = GetCount(WC->disp_cal_items);
 
        /* Sort them if necessary
-       if (nItems > 1) {
-               SortByPayload(WC->disp_cal_items, task_due_cmp);
-       }
-       * this shouldn't be neccessary, since we sort by the start time.
-       */
+          if (nItems > 1) {
+          SortByPayload(WC->disp_cal_items, task_due_cmp);
+          }
+          * this shouldn't be neccessary, since we sort by the start time.
+        */
 
        /* And then again, by completed */
        if (nItems > 1) {
-               SortByPayload(WC->disp_cal_items, 
-                             task_completed_cmp);
+               SortByPayload(WC->disp_cal_items, task_completed_cmp);
        }
 
        Pos = GetNewHashPos(WC->disp_cal_items, 0);
@@ -119,7 +113,7 @@ int tasks_RenderView_or_Tail(SharedMessageStatus *Stat,
                icalproperty_status todoStatus;
                int is_date;
 
-               Cal = (disp_cal*)vCal;
+               Cal = (disp_cal *) vCal;
                wc_printf("<tr><td>");
                todoStatus = icalcomponent_get_status(Cal->cal);
                wc_printf("<input type=\"checkbox\" name=\"completed\" value=\"completed\" ");
@@ -127,15 +121,14 @@ int tasks_RenderView_or_Tail(SharedMessageStatus *Stat,
                        wc_printf("checked=\"checked\" ");
                }
                wc_printf("disabled=\"disabled\">\n</td><td>");
-               p = icalcomponent_get_first_property(Cal->cal,
-                       ICAL_SUMMARY_PROPERTY);
+               p = icalcomponent_get_first_property(Cal->cal, ICAL_SUMMARY_PROPERTY);
                wc_printf("<a href=\"display_edit_task?msgnum=%ld?taskrm=", Cal->cal_msgnum);
                urlescputs(ChrPtr(WC->CurRoom.name));
                wc_printf("\">");
                /* wc_printf("<img align=middle "
-               "src=\"static/taskmanag_16x.gif\" border=0>&nbsp;"); */
+                  "src=\"static/taskmanag_16x.gif\" border=0>&nbsp;"); */
                if (p != NULL) {
-                       escputs((char *)icalproperty_get_comment(p));
+                       escputs((char *) icalproperty_get_comment(p));
                }
                wc_printf("</a>\n");
                wc_printf("</td>\n");
@@ -144,17 +137,16 @@ int tasks_RenderView_or_Tail(SharedMessageStatus *Stat,
                wc_printf("<td><span");
                if (due > 0) {
                        webcit_fmt_date(buf, SIZ, due, is_date ? DATEFMT_RAWDATE : DATEFMT_FULL);
-                       wc_printf(">%s",buf);
+                       wc_printf(">%s", buf);
                }
                else {
                        wc_printf(">");
                }
                wc_printf("</span></td>");
                wc_printf("<td>");
-               p = icalcomponent_get_first_property(Cal->cal,
-                       ICAL_CATEGORIES_PROPERTY);
+               p = icalcomponent_get_first_property(Cal->cal, ICAL_CATEGORIES_PROPERTY);
                if (p != NULL) {
-                       escputs((char *)icalproperty_get_categories(p));
+                       escputs((char *) icalproperty_get_categories(p));
                }
                wc_printf("</td>");
                wc_printf("</tr>");
@@ -172,9 +164,7 @@ int tasks_RenderView_or_Tail(SharedMessageStatus *Stat,
 /*
  * Display a task by itself (for editing)
  */
-void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, char *from,
-                       int unread, calview *calv)
-{
+void display_edit_individual_task(icalcomponent * supplied_vtodo, long msgnum, char *from, int unread, calview * calv) {
        icalcomponent *vtodo;
        icalproperty *p;
        struct icaltimetype IcalTime;
@@ -198,12 +188,8 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
                 * new one.
                 */
                if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
-                       display_edit_individual_task(
-                               icalcomponent_get_first_component(
-                                       vtodo, ICAL_VTODO_COMPONENT
-                                       ), 
-                               msgnum, from, unread, calv
-                               );
+                       display_edit_individual_task(icalcomponent_get_first_component(vtodo, ICAL_VTODO_COMPONENT),
+                                                    msgnum, from, unread, calv);
                        return;
                }
        }
@@ -211,8 +197,8 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
                vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT);
                created_new_vtodo = 1;
        }
-       
-       /* TODO: Can we take all this and move it into a template?       */
+
+       /* TODO: Can we take all this and move it into a template?       */
        output_headers(1, 1, 1, 0, 0, 0);
        wc_printf("<!-- start task edit form -->");
        p = icalcomponent_get_first_property(vtodo, ICAL_SUMMARY_PROPERTY);
@@ -222,10 +208,10 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
        wc_printf(_("Edit task"));
        wc_printf("- ");
        if (p != NULL) {
-               escputs((char *)icalproperty_get_comment(p));
+               escputs((char *) icalproperty_get_comment(p));
        }
        wc_printf("</div>");
-       
+
        wc_printf("<div class=\"boxcontent\">\n");
        wc_printf("<FORM METHOD=\"POST\" action=\"save_task\">\n");
        wc_printf("<div style=\"display: none;\">\n     ");
@@ -236,20 +222,17 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
 
        wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
        wc_printf("<INPUT TYPE=\"hidden\" NAME=\"msgnum\" VALUE=\"%ld\">\n", msgnum);
-       wc_printf("<INPUT TYPE=\"hidden\" NAME=\"return_to_summary\" VALUE=\"%d\">\n",
-               ibstr("return_to_summary"));
+       wc_printf("<INPUT TYPE=\"hidden\" NAME=\"return_to_summary\" VALUE=\"%d\">\n", ibstr("return_to_summary"));
        wc_printf("</div>");
        wc_printf("<table class=\"calendar_background\"><tr><td>");
        wc_printf("<TABLE STYLE=\"border: none;\">\n");
 
        wc_printf("<TR><TD>");
        wc_printf(_("Summary:"));
-       wc_printf("</TD><TD>"
-               "<INPUT TYPE=\"text\" NAME=\"summary\" "
-               "MAXLENGTH=\"64\" SIZE=\"64\" VALUE=\"");
+       wc_printf("</TD><TD>" "<INPUT TYPE=\"text\" NAME=\"summary\" " "MAXLENGTH=\"64\" SIZE=\"64\" VALUE=\"");
        p = icalcomponent_get_first_property(vtodo, ICAL_SUMMARY_PROPERTY);
        if (p != NULL) {
-               escputs((char *)icalproperty_get_comment(p));
+               escputs((char *) icalproperty_get_comment(p));
        }
        wc_printf("\"></TD></TR>\n");
 
@@ -263,7 +246,7 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
        }
        wc_printf(">");
        wc_printf(_("No date"));
-       
+
        wc_printf(" ");
        wc_printf("<span ID=\"dtstart_date\">");
        wc_printf(_("or"));
@@ -318,7 +301,7 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
        wc_printf("<INPUT TYPE=\"CHECKBOX\" NAME=\"status\" VALUE=\"COMPLETED\"");
        if (todoStatus == ICAL_STATUS_COMPLETED) {
                wc_printf(" CHECKED=\"CHECKED\"");
-       } 
+       }
        wc_printf(" >");
        wc_printf("</TD></TR>");
        /* start category field */
@@ -328,7 +311,7 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
        wc_printf("</TD><TD>");
        wc_printf("<INPUT TYPE=\"text\" NAME=\"category\" MAXLENGTH=\"32\" SIZE=\"32\" VALUE=\"");
        if (p != NULL) {
-               escputs((char *)icalproperty_get_categories(p));
+               escputs((char *) icalproperty_get_categories(p));
        }
        wc_printf("\">");
        wc_printf("</TD></TR>\n ");
@@ -336,26 +319,20 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
        wc_printf("<TR><TD>");
        wc_printf(_("Description:"));
        wc_printf("</TD><TD>");
-       wc_printf("<TEXTAREA NAME=\"description\" "
-               "ROWS=\"10\" COLS=\"80\">\n"
-               );
+       wc_printf("<TEXTAREA NAME=\"description\" " "ROWS=\"10\" COLS=\"80\">\n");
        p = icalcomponent_get_first_property(vtodo, ICAL_DESCRIPTION_PROPERTY);
        if (p != NULL) {
-               escputs((char *)icalproperty_get_comment(p));
+               escputs((char *) icalproperty_get_comment(p));
        }
        wc_printf("</TEXTAREA></TD></TR></TABLE>\n");
 
        wc_printf("<SPAN STYLE=\"text-align: center;\">"
-               "<INPUT TYPE=\"submit\" NAME=\"save_button\" VALUE=\"%s\">"
-               "&nbsp;&nbsp;"
-               "<INPUT TYPE=\"submit\" NAME=\"delete_button\" VALUE=\"%s\">\n"
-               "&nbsp;&nbsp;"
-               "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">\n"
-               "</SPAN>\n",
-               _("Save"),
-               _("Delete"),
-               _("Cancel")
-               );
+                 "<INPUT TYPE=\"submit\" NAME=\"save_button\" VALUE=\"%s\">"
+                 "&nbsp;&nbsp;"
+                 "<INPUT TYPE=\"submit\" NAME=\"delete_button\" VALUE=\"%s\">\n"
+                 "&nbsp;&nbsp;"
+                 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">\n" "</SPAN>\n", _("Save"), _("Delete"), _("Cancel")
+           );
        wc_printf("</td></tr></table>");
        wc_printf("</FORM>\n");
        wc_printf("</div></div></div>\n");
@@ -373,9 +350,7 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
  * supplied_vtodo      the task to save
  * msgnum              number of the mesage in our db
  */
-void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from, int unread,
-                         calview *calv)
-{
+void save_individual_task(icalcomponent * supplied_vtodo, long msgnum, char *from, int unread, calview * calv) {
        char buf[SIZ];
        int delete_existing = 0;
        icalproperty *prop;
@@ -387,6 +362,7 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from
 
        if (supplied_vtodo != NULL) {
                vtodo = supplied_vtodo;
+
                /**
                 * If we're looking at a fully encapsulated VCALENDAR
                 * rather than a VTODO component, attempt to use the first
@@ -396,11 +372,8 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from
                 * new one.
                 */
                if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
-                       save_individual_task(
-                               icalcomponent_get_first_component(
-                                       vtodo, ICAL_VTODO_COMPONENT), 
-                               msgnum, from, unread, calv
-                               );
+                       save_individual_task(icalcomponent_get_first_component(vtodo, ICAL_VTODO_COMPONENT),
+                                            msgnum, from, unread, calv);
                        return;
                }
        }
@@ -413,32 +386,27 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from
 
                /** Replace values in the component with ones from the form */
 
-               while (prop = icalcomponent_get_first_property(vtodo,
-                                                              ICAL_SUMMARY_PROPERTY), prop != NULL) {
+               while (prop = icalcomponent_get_first_property(vtodo, ICAL_SUMMARY_PROPERTY), prop != NULL) {
                        icalcomponent_remove_property(vtodo, prop);
                        icalproperty_free(prop);
                }
                if (havebstr("summary")) {
 
-                       icalcomponent_add_property(vtodo,
-                                                  icalproperty_new_summary(bstr("summary")));
-               } else {
-                       icalcomponent_add_property(vtodo,
-                                                  icalproperty_new_summary(_("Untitled Task")));
+                       icalcomponent_add_property(vtodo, icalproperty_new_summary(bstr("summary")));
+               }
+               else {
+                       icalcomponent_add_property(vtodo, icalproperty_new_summary(_("Untitled Task")));
                }
-       
-               while (prop = icalcomponent_get_first_property(vtodo,
-                                                              ICAL_DESCRIPTION_PROPERTY), prop != NULL) {
+
+               while (prop = icalcomponent_get_first_property(vtodo, ICAL_DESCRIPTION_PROPERTY), prop != NULL) {
                        icalcomponent_remove_property(vtodo, prop);
                        icalproperty_free(prop);
                }
                if (havebstr("description")) {
-                       icalcomponent_add_property(vtodo,
-                                                  icalproperty_new_description(bstr("description")));
+                       icalcomponent_add_property(vtodo, icalproperty_new_description(bstr("description")));
                }
-       
-               while (prop = icalcomponent_get_first_property(vtodo,
-                                                              ICAL_DTSTART_PROPERTY), prop != NULL) {
+
+               while (prop = icalcomponent_get_first_property(vtodo, ICAL_DTSTART_PROPERTY), prop != NULL) {
                        icalcomponent_remove_property(vtodo, prop);
                        icalproperty_free(prop);
                }
@@ -449,18 +417,15 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from
                        else {
                                icaltime_from_webform_dateonly(&t, "dtstart");
                        }
-                       icalcomponent_add_property(vtodo,
-                                                  icalproperty_new_dtstart(t)
-                               );
+                       icalcomponent_add_property(vtodo, icalproperty_new_dtstart(t)
+                           );
                }
-               while(prop = icalcomponent_get_first_property(vtodo,
-                                                             ICAL_STATUS_PROPERTY), prop != NULL) {
-                       icalcomponent_remove_property(vtodo,prop);
+               while (prop = icalcomponent_get_first_property(vtodo, ICAL_STATUS_PROPERTY), prop != NULL) {
+                       icalcomponent_remove_property(vtodo, prop);
                        icalproperty_free(prop);
                }
-               while(prop = icalcomponent_get_first_property(vtodo,
-                                                             ICAL_PERCENTCOMPLETE_PROPERTY), prop != NULL) {
-                       icalcomponent_remove_property(vtodo,prop);
+               while (prop = icalcomponent_get_first_property(vtodo, ICAL_PERCENTCOMPLETE_PROPERTY), prop != NULL) {
+                       icalcomponent_remove_property(vtodo, prop);
                        icalproperty_free(prop);
                }
 
@@ -468,25 +433,23 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from
                        icalproperty_status taskStatus = icalproperty_string_to_status(bstr("status"));
                        icalcomponent_set_status(vtodo, taskStatus);
                        icalcomponent_add_property(vtodo,
-                               icalproperty_new_percentcomplete(
-                                       (strcasecmp(bstr("status"), "completed") ? 0 : 100)
-                               )
-                       );
+                                                  icalproperty_new_percentcomplete((strcasecmp(bstr("status"), "completed") ? 0 :
+                                                                                    100)
+                                                  )
+                           );
                }
                else {
                        icalcomponent_add_property(vtodo, icalproperty_new_percentcomplete(0));
                }
-               while (prop = icalcomponent_get_first_property(vtodo,
-                                                              ICAL_CATEGORIES_PROPERTY), prop != NULL) {
-                       icalcomponent_remove_property(vtodo,prop);
+               while (prop = icalcomponent_get_first_property(vtodo, ICAL_CATEGORIES_PROPERTY), prop != NULL) {
+                       icalcomponent_remove_property(vtodo, prop);
                        icalproperty_free(prop);
                }
                if (!IsEmptyStr(bstr("category"))) {
                        prop = icalproperty_new_categories(bstr("category"));
-                       icalcomponent_add_property(vtodo,prop);
+                       icalcomponent_add_property(vtodo, prop);
                }
-               while (prop = icalcomponent_get_first_property(vtodo,
-                                                              ICAL_DUE_PROPERTY), prop != NULL) {
+               while (prop = icalcomponent_get_first_property(vtodo, ICAL_DUE_PROPERTY), prop != NULL) {
                        icalcomponent_remove_property(vtodo, prop);
                        icalproperty_free(prop);
                }
@@ -497,35 +460,32 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from
                        else {
                                icaltime_from_webform_dateonly(&t, "due");
                        }
-                       icalcomponent_add_property(vtodo,
-                                                  icalproperty_new_due(t)
-                               );
+                       icalcomponent_add_property(vtodo, icalproperty_new_due(t)
+                           );
                }
+
                /** Give this task a UID if it doesn't have one. */
                syslog(LOG_DEBUG, "Give this task a UID if it doesn't have one.\n");
-               if (icalcomponent_get_first_property(vtodo,
-                                                    ICAL_UID_PROPERTY) == NULL) {
+               if (icalcomponent_get_first_property(vtodo, ICAL_UID_PROPERTY) == NULL) {
                        generate_uuid(buf);
-                       icalcomponent_add_property(vtodo,
-                                                  icalproperty_new_uid(buf)
-                               );
+                       icalcomponent_add_property(vtodo, icalproperty_new_uid(buf)
+                           );
                }
 
                /* Increment the sequence ID */
                syslog(LOG_DEBUG, "Increment the sequence ID\n");
-               while (prop = icalcomponent_get_first_property(vtodo,
-                                                              ICAL_SEQUENCE_PROPERTY), (prop != NULL) ) {
+               while (prop = icalcomponent_get_first_property(vtodo, ICAL_SEQUENCE_PROPERTY), (prop != NULL)) {
                        i = icalproperty_get_sequence(prop);
                        syslog(LOG_DEBUG, "Sequence was %d\n", i);
-                       if (i > sequence) sequence = i;
+                       if (i > sequence)
+                               sequence = i;
                        icalcomponent_remove_property(vtodo, prop);
                        icalproperty_free(prop);
                }
                ++sequence;
                syslog(LOG_DEBUG, "New sequence is %d.  Adding...\n", sequence);
-               icalcomponent_add_property(vtodo,
-                                          icalproperty_new_sequence(sequence)
-                       );
+               icalcomponent_add_property(vtodo, icalproperty_new_sequence(sequence)
+                   );
 
                /*
                 * Encapsulate event into full VCALENDAR component.  Clone it first,
@@ -563,7 +523,7 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from
                delete_existing = 1;
        }
 
-       if ( (delete_existing) && (msgnum > 0L) ) {
+       if ((delete_existing) && (msgnum > 0L)) {
                serv_printf("DELE %ld", lbstr("msgnum"));
                serv_getln(buf, sizeof buf);
        }
@@ -585,20 +545,18 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from
 /*
  * free memory allocated using libical
  */
-void delete_task(void *vCal)
-{
-        disp_cal *Cal = (disp_cal*) vCal;
-        icalcomponent_free(Cal->cal);
-        free(Cal->from);
-        free(Cal);
+void delete_task(void *vCal) {
+       disp_cal *Cal = (disp_cal *) vCal;
+       icalcomponent_free(Cal->cal);
+       free(Cal->from);
+       free(Cal);
 }
 
 
 /*
  * Load a Task into a hash table for later display.
  */
-void load_task(icalcomponent *event, long msgnum, char *from, int unread, calview *calv)
-{
+void load_task(icalcomponent * event, long msgnum, char *from, int unread, calview * calv) {
        icalproperty *ps = NULL;
        struct icaltimetype dtstart, dtend;
        disp_cal *Cal;
@@ -607,12 +565,12 @@ void load_task(icalcomponent *event, long msgnum, char *from, int unread, calvie
 
        dtstart = icaltime_null_time();
        dtend = icaltime_null_time();
-       
+
        if (WC->disp_cal_items == NULL) {
                WC->disp_cal_items = NewHash(0, Flathash);
        }
 
-       Cal = (disp_cal*) malloc(sizeof(disp_cal));
+       Cal = (disp_cal *) malloc(sizeof(disp_cal));
        memset(Cal, 0, sizeof(disp_cal));
        Cal->cal = icalcomponent_new_clone(event);
 
@@ -629,7 +587,7 @@ void load_task(icalcomponent *event, long msgnum, char *from, int unread, calvie
 
        Cal->unread = unread;
        len = strlen(from);
-       Cal->from = (char*)malloc(len+ 1);
+       Cal->from = (char *) malloc(len + 1);
        memcpy(Cal->from, from, len + 1);
        Cal->cal_msgnum = msgnum;
 
@@ -652,12 +610,7 @@ void load_task(icalcomponent *event, long msgnum, char *from, int unread, calvie
 
        /* Store it in the hash list. */
        /* syslog(LOG_DEBUG, "INITIAL: %s", ctime(&Cal->event_start)); */
-       Put(WC->disp_cal_items, 
-           (char*) &Cal->event_start,
-           sizeof(Cal->event_start), 
-           Cal, 
-           delete_task
-       );
+       Put(WC->disp_cal_items, (char *) &Cal->event_start, sizeof(Cal->event_start), Cal, delete_task);
 }
 
 
@@ -665,12 +618,7 @@ void load_task(icalcomponent *event, long msgnum, char *from, int unread, calvie
 /*
  * Display task view
  */
-int tasks_LoadMsgFromServer(SharedMessageStatus *Stat, 
-                           void **ViewSpecific, 
-                           message_summary* Msg, 
-                           int is_new, 
-                           int i)
-{
+int tasks_LoadMsgFromServer(SharedMessageStatus * Stat, void **ViewSpecific, message_summary * Msg, int is_new, int i) {
        /* Not (yet?) needed here? calview *c = (calview *) *ViewSpecific; */
 
        load_ical_object(Msg->msgnum, is_new, ICAL_VTODO_COMPONENT, load_task, NULL, 0);
@@ -682,7 +630,7 @@ int tasks_LoadMsgFromServer(SharedMessageStatus *Stat,
  */
 void display_edit_task(void) {
        long msgnum = 0L;
-                       
+
        /* Force change the room if we have to */
        if (havebstr("taskrm")) {
                gotoroom(sbstr("taskrm"));
@@ -691,11 +639,7 @@ void display_edit_task(void) {
        msgnum = lbstr("msgnum");
        if (msgnum > 0L) {
                /* existing task */
-               load_ical_object(msgnum, 0,
-                                ICAL_VTODO_COMPONENT,
-                                display_edit_individual_task,
-                                NULL, 0
-               );
+               load_ical_object(msgnum, 0, ICAL_VTODO_COMPONENT, display_edit_individual_task, NULL, 0);
        }
        else {
                /* new task */
@@ -719,23 +663,17 @@ void save_task(void) {
 
 
 
-int tasks_GetParamsGetServerCall(SharedMessageStatus *Stat, 
-                                void **ViewSpecific, 
-                                long oper, 
-                                char *cmd, 
-                                long len,
-                                char *filter,
-                                long flen)
-{
+int tasks_GetParamsGetServerCall(SharedMessageStatus * Stat,
+                                void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen) {
        strcpy(cmd, "MSGS ALL");
        Stat->maxmsgs = 32767;
        return 200;
 }
 
 
-int tasks_Cleanup(void **ViewSpecific)
-{
+int tasks_Cleanup(void **ViewSpecific) {
        wDumpContent(1);
+
 /* Tasks doesn't need the calview struct... 
        free (*ViewSpecific);
        *ViewSpecific = NULL;
@@ -743,19 +681,9 @@ int tasks_Cleanup(void **ViewSpecific)
        return 0;
 }
 
-void 
-InitModule_TASKS
-(void)
-{
-       RegisterReadLoopHandlerset(
-               VIEW_TASKS,
-               tasks_GetParamsGetServerCall,
-               NULL,
-               NULL,
-               NULL,
-               tasks_LoadMsgFromServer,
-               tasks_RenderView_or_Tail,
-               tasks_Cleanup,
-               NULL);
+void InitModule_TASKS(void) {
+       RegisterReadLoopHandlerset(VIEW_TASKS,
+                                  tasks_GetParamsGetServerCall,
+                                  NULL, NULL, NULL, tasks_LoadMsgFromServer, tasks_RenderView_or_Tail, tasks_Cleanup, NULL);
        WebcitAddUrlHandler(HKEY("save_task"), "", 0, save_task, 0);
 }
index 80371dc9f4e9ef6a368192a3158b0f1aa8873e26..0d334bdcd2cf01a2ab806831f3a5d8d91cf66f68 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2021 by the citadel.org team
  *
 #include "webserver.h"
 
 CtxType CTX_USERLIST = CTX_NONE;
+
 /*
  *  show a list of available users to edit them
  *  message the header message???
  *  preselect = which user should be selected in the browser
  */
-void select_user_to_edit(const char *preselect)
-{
+void select_user_to_edit(const char *preselect) {
        output_headers(1, 0, 0, 0, 1, 0);
        do_template("aide_edituser_select");
-        end_burst();
+       end_burst();
 }
 
 
@@ -47,35 +48,34 @@ typedef struct _UserListEntry {
 } UserListEntry;
 
 
-UserListEntry* NewUserListOneEntry(StrBuf *SerializedUser, const char *Pos)
-{
+UserListEntry *NewUserListOneEntry(StrBuf * SerializedUser, const char *Pos) {
        UserListEntry *ul;
 
-       if (StrLength(SerializedUser) < 8) 
+       if (StrLength(SerializedUser) < 8)
                return NULL;
 
-       ul = (UserListEntry*) malloc(sizeof(UserListEntry));
+       ul = (UserListEntry *) malloc(sizeof(UserListEntry));
        ul->UserName = NewStrBuf();
        ul->Passvoid = NewStrBuf();
        ul->PrimaryEmail = NewStrBuf();
        ul->OtherEmails = NewStrBuf();
 
-       StrBufExtract_NextToken(ul->UserName,               SerializedUser, &Pos, '|');
-       StrBufExtract_NextToken(ul->Passvoid,               SerializedUser, &Pos, '|');
-       ul->Flags         = StrBufExtractNext_unsigned_long(SerializedUser, &Pos, '|');
-       ul->nLogons       = StrBufExtractNext_int(          SerializedUser, &Pos, '|');
-       ul->nPosts        = StrBufExtractNext_int(          SerializedUser, &Pos, '|');
-       ul->AccessLevel   = StrBufExtractNext_int(          SerializedUser, &Pos, '|');
-       ul->UID           = StrBufExtractNext_int(          SerializedUser, &Pos, '|');
-       ul->LastLogonT    = StrBufExtractNext_long(         SerializedUser, &Pos, '|');
-       ul->DaysTillPurge = StrBufExtractNext_int(          SerializedUser, &Pos, '|');
+       StrBufExtract_NextToken(ul->UserName, SerializedUser, &Pos, '|');
+       StrBufExtract_NextToken(ul->Passvoid, SerializedUser, &Pos, '|');
+       ul->Flags = StrBufExtractNext_unsigned_long(SerializedUser, &Pos, '|');
+       ul->nLogons = StrBufExtractNext_int(SerializedUser, &Pos, '|');
+       ul->nPosts = StrBufExtractNext_int(SerializedUser, &Pos, '|');
+       ul->AccessLevel = StrBufExtractNext_int(SerializedUser, &Pos, '|');
+       ul->UID = StrBufExtractNext_int(SerializedUser, &Pos, '|');
+       ul->LastLogonT = StrBufExtractNext_long(SerializedUser, &Pos, '|');
+       ul->DaysTillPurge = StrBufExtractNext_int(SerializedUser, &Pos, '|');
        return ul;
 }
 
-void DeleteUserListEntry(void *vUserList)
-{
-       UserListEntry *ul = (UserListEntry*) vUserList;
-       if (!ul) return;
+void DeleteUserListEntry(void *vUserList) {
+       UserListEntry *ul = (UserListEntry *) vUserList;
+       if (!ul)
+               return;
        FreeStrBuf(&ul->UserName);
        FreeStrBuf(&ul->Passvoid);
        FreeStrBuf(&ul->PrimaryEmail);
@@ -83,27 +83,26 @@ void DeleteUserListEntry(void *vUserList)
        free(ul);
 }
 
-UserListEntry* NewUserListEntry(StrBuf *SerializedUserList)
-{
+UserListEntry *NewUserListEntry(StrBuf * SerializedUserList) {
        const char *Pos = NULL;
        UserListEntry *ul;
 
-       if (StrLength(SerializedUserList) < 8) 
+       if (StrLength(SerializedUserList) < 8)
                return NULL;
 
-       ul = (UserListEntry*) malloc(sizeof(UserListEntry));
+       ul = (UserListEntry *) malloc(sizeof(UserListEntry));
        ul->UserName = NewStrBuf();
        ul->Passvoid = NewStrBuf();
        ul->PrimaryEmail = NewStrBuf();
        ul->OtherEmails = NewStrBuf();
 
-       StrBufExtract_NextToken(ul->UserName,    SerializedUserList, &Pos, '|');
-       ul->AccessLevel = StrBufExtractNext_int( SerializedUserList, &Pos, '|');
-       ul->UID         = StrBufExtractNext_int( SerializedUserList, &Pos, '|');
-       ul->LastLogonT  = StrBufExtractNext_long(SerializedUserList, &Pos, '|');
-       ul->nLogons     = StrBufExtractNext_int( SerializedUserList, &Pos, '|');
-       ul->nPosts      = StrBufExtractNext_int( SerializedUserList, &Pos, '|');
-       StrBufExtract_NextToken(ul->Passvoid,    SerializedUserList, &Pos, '|');
+       StrBufExtract_NextToken(ul->UserName, SerializedUserList, &Pos, '|');
+       ul->AccessLevel = StrBufExtractNext_int(SerializedUserList, &Pos, '|');
+       ul->UID = StrBufExtractNext_int(SerializedUserList, &Pos, '|');
+       ul->LastLogonT = StrBufExtractNext_long(SerializedUserList, &Pos, '|');
+       ul->nLogons = StrBufExtractNext_int(SerializedUserList, &Pos, '|');
+       ul->nPosts = StrBufExtractNext_int(SerializedUserList, &Pos, '|');
+       StrBufExtract_NextToken(ul->Passvoid, SerializedUserList, &Pos, '|');
        ul->Flags = 0;
        ul->HasBio = 0;
        ul->DaysTillPurge = -1;
@@ -113,51 +112,45 @@ UserListEntry* NewUserListEntry(StrBuf *SerializedUserList)
 /*
  * Sort by Username
  */
-int CompareUserListName(const void *vUser1, const void *vUser2)
-{
-       UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
-       UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int CompareUserListName(const void *vUser1, const void *vUser2) {
+       UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+       UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
 
        return strcmp(ChrPtr(u1->UserName), ChrPtr(u2->UserName));
 }
 
-int CompareUserListNameRev(const void *vUser1, const void *vUser2)
-{
-       UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
-       UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int CompareUserListNameRev(const void *vUser1, const void *vUser2) {
+       UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+       UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
        return strcmp(ChrPtr(u2->UserName), ChrPtr(u1->UserName));
 }
 
-int GroupchangeUserListName(const void *vUser1, const void *vUser2)
-{
-       UserListEntry *u1 = (UserListEntry*) vUser1;
-       UserListEntry *u2 = (UserListEntry*) vUser2;
+int GroupchangeUserListName(const void *vUser1, const void *vUser2) {
+       UserListEntry *u1 = (UserListEntry *) vUser1;
+       UserListEntry *u2 = (UserListEntry *) vUser2;
        return ChrPtr(u2->UserName)[0] != ChrPtr(u1->UserName)[0];
 }
 
 /*
  * Sort by access level
  */
-int CompareAccessLevel(const void *vUser1, const void *vUser2)
-{
-       UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
-       UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int CompareAccessLevel(const void *vUser1, const void *vUser2) {
+       UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+       UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
 
        return (u1->AccessLevel > u2->AccessLevel);
 }
 
-int CompareAccessLevelRev(const void *vUser1, const void *vUser2)
-{
-       UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
-       UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int CompareAccessLevelRev(const void *vUser1, const void *vUser2) {
+       UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+       UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
 
        return (u2->AccessLevel > u1->AccessLevel);
 }
 
-int GroupchangeAccessLevel(const void *vUser1, const void *vUser2)
-{
-       UserListEntry *u1 = (UserListEntry*) vUser1;
-       UserListEntry *u2 = (UserListEntry*) vUser2;
+int GroupchangeAccessLevel(const void *vUser1, const void *vUser2) {
+       UserListEntry *u1 = (UserListEntry *) vUser1;
+       UserListEntry *u2 = (UserListEntry *) vUser2;
 
        return u2->AccessLevel != u1->AccessLevel;
 }
@@ -165,26 +158,23 @@ int GroupchangeAccessLevel(const void *vUser1, const void *vUser2)
 /*
  * Sort by UID
  */
-int CompareUID(const void *vUser1, const void *vUser2)
-{
-       UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
-       UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int CompareUID(const void *vUser1, const void *vUser2) {
+       UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+       UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
 
        return (u1->UID > u2->UID);
 }
 
-int CompareUIDRev(const void *vUser1, const void *vUser2)
-{
-       UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
-       UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int CompareUIDRev(const void *vUser1, const void *vUser2) {
+       UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+       UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
 
        return (u2->UID > u1->UID);
 }
 
-int GroupchangeUID(const void *vUser1, const void *vUser2)
-{
-       UserListEntry *u1 = (UserListEntry*) vUser1;
-       UserListEntry *u2 = (UserListEntry*) vUser2;
+int GroupchangeUID(const void *vUser1, const void *vUser2) {
+       UserListEntry *u1 = (UserListEntry *) vUser1;
+       UserListEntry *u2 = (UserListEntry *) vUser2;
 
        return (u2->UID / 10) != (u1->UID / 10);
 }
@@ -192,26 +182,23 @@ int GroupchangeUID(const void *vUser1, const void *vUser2)
 /*
  * Sort By Date /// TODO!
  */
-int CompareLastLogon(const void *vUser1, const void *vUser2)
-{
-       UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
-       UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int CompareLastLogon(const void *vUser1, const void *vUser2) {
+       UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+       UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
 
        return (u1->LastLogonT > u2->LastLogonT);
 }
 
-int CompareLastLogonRev(const void *vUser1, const void *vUser2)
-{
-       UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
-       UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int CompareLastLogonRev(const void *vUser1, const void *vUser2) {
+       UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+       UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
 
        return (u2->LastLogonT > u1->LastLogonT);
 }
 
-int GroupchangeLastLogon(const void *vUser1, const void *vUser2)
-{
-       UserListEntry *u1 = (UserListEntry*) vUser1;
-       UserListEntry *u2 = (UserListEntry*) vUser2;
+int GroupchangeLastLogon(const void *vUser1, const void *vUser2) {
+       UserListEntry *u1 = (UserListEntry *) vUser1;
+       UserListEntry *u2 = (UserListEntry *) vUser2;
 
        return (u2->LastLogonT != u1->LastLogonT);
 }
@@ -219,26 +206,23 @@ int GroupchangeLastLogon(const void *vUser1, const void *vUser2)
 /*
  * Sort By Number of Logons
  */
-int ComparenLogons(const void *vUser1, const void *vUser2)
-{
-       UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
-       UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int ComparenLogons(const void *vUser1, const void *vUser2) {
+       UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+       UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
 
        return (u1->nLogons > u2->nLogons);
 }
 
-int ComparenLogonsRev(const void *vUser1, const void *vUser2)
-{
-       UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
-       UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int ComparenLogonsRev(const void *vUser1, const void *vUser2) {
+       UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+       UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
 
        return (u2->nLogons > u1->nLogons);
 }
 
-int GroupchangenLogons(const void *vUser1, const void *vUser2)
-{
-       UserListEntry *u1 = (UserListEntry*) vUser1;
-       UserListEntry *u2 = (UserListEntry*) vUser2;
+int GroupchangenLogons(const void *vUser1, const void *vUser2) {
+       UserListEntry *u1 = (UserListEntry *) vUser1;
+       UserListEntry *u2 = (UserListEntry *) vUser2;
 
        return (u2->nLogons / 100) != (u1->nLogons / 100);
 }
@@ -246,45 +230,41 @@ int GroupchangenLogons(const void *vUser1, const void *vUser2)
 /*
  * Sort By Number of Posts
  */
-int ComparenPosts(const void *vUser1, const void *vUser2)
-{
-       UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
-       UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int ComparenPosts(const void *vUser1, const void *vUser2) {
+       UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+       UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
 
        return (u1->nPosts > u2->nPosts);
 }
 
-int ComparenPostsRev(const void *vUser1, const void *vUser2)
-{
-       UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
-       UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int ComparenPostsRev(const void *vUser1, const void *vUser2) {
+       UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+       UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
 
        return (u2->nPosts > u1->nPosts);
 }
 
-int GroupchangenPosts(const void *vUser1, const void *vUser2)
-{
-       UserListEntry *u1 = (UserListEntry*) vUser1;
-       UserListEntry *u2 = (UserListEntry*) vUser2;
+int GroupchangenPosts(const void *vUser1, const void *vUser2) {
+       UserListEntry *u1 = (UserListEntry *) vUser1;
+       UserListEntry *u2 = (UserListEntry *) vUser2;
 
        return (u2->nPosts / 100) != (u1->nPosts / 100);
 }
 
 
-HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *iterate_load_userlist(StrBuf * Target, WCTemplputParams * TP) {
        int Done = 0;
        CompareFunc SortIt;
        HashList *Hash = NULL;
        StrBuf *Buf;
-       UserListEntryul;
+       UserListEntry *ul;
        int len;
        int UID;
        void *vData;
        WCTemplputParams SubTP;
 
-       memset(&SubTP, 0, sizeof(WCTemplputParams));    
-        serv_puts("LIST");
+       memset(&SubTP, 0, sizeof(WCTemplputParams));
+       serv_puts("LIST");
        Buf = NewStrBuf();
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) == 1) {
@@ -292,10 +272,7 @@ HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
                Done = 0;
                while (!Done) {
                        len = StrBuf_ServGetln(Buf);
-                       if ((len <0) || 
-                           ((len == 3) &&
-                            !strcmp(ChrPtr(Buf), "000")))
-                       {
+                       if ((len < 0) || ((len == 3) && !strcmp(ChrPtr(Buf), "000"))) {
                                Done = 1;
                                break;
                        }
@@ -303,7 +280,7 @@ HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
                        if (ul == NULL)
                                continue;
 
-                       Put(Hash, IKEY(ul->UID), ul, DeleteUserListEntry); 
+                       Put(Hash, IKEY(ul->UID), ul, DeleteUserListEntry);
                }
 
                serv_puts("LBIO 1");
@@ -312,16 +289,14 @@ HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
                        Done = 0;
                        while (!Done) {
                                len = StrBuf_ServGetln(Buf);
-                               if ((len <0) || ((len == 3) && !strcmp(ChrPtr(Buf), "000")))
-                               {
+                               if ((len < 0) || ((len == 3) && !strcmp(ChrPtr(Buf), "000"))) {
                                        Done = 1;
                                        break;
                                }
                        }
                        UID = atoi(ChrPtr(Buf));
-                       if (GetHash(Hash, IKEY(UID), &vData) && vData != 0)
-                       {
-                               ul = (UserListEntry*)vData;
+                       if (GetHash(Hash, IKEY(UID), &vData) && vData != 0) {
+                               ul = (UserListEntry *) vData;
                                ul->HasBio = 1;
                        }
                }
@@ -329,162 +304,139 @@ HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
                SortIt = RetrieveSort(&SubTP, HKEY("USER"), HKEY("user:uid"), 0);
                if (SortIt != NULL)
                        SortByPayload(Hash, SortIt);
-               else 
+               else
                        SortByPayload(Hash, CompareUID);
-        }
+       }
        FreeStrBuf(&Buf);
        return Hash;
 }
 
 
-void tmplput_USERLIST_UserName(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_UserName(StrBuf * Target, WCTemplputParams * TP) {
+       UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
        StrBufAppendTemplate(Target, TP, ul->UserName, 0);
 }
 
-void tmplput_USERLIST_Password(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_Password(StrBuf * Target, WCTemplputParams * TP) {
+       UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
        StrBufAppendTemplate(Target, TP, ul->Passvoid, 0);
 }
 
-void tmplput_USERLIST_PrimaryEmail(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_PrimaryEmail(StrBuf * Target, WCTemplputParams * TP) {
+       UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
        StrBufAppendTemplate(Target, TP, ul->PrimaryEmail, 0);
 }
 
-void tmplput_USERLIST_OtherEmails(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_OtherEmails(StrBuf * Target, WCTemplputParams * TP) {
+       UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
        StrBufAppendTemplate(Target, TP, ul->OtherEmails, 0);
 }
 
-void tmplput_USERLIST_AccessLevelNo(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_AccessLevelNo(StrBuf * Target, WCTemplputParams * TP) {
+       UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
 
        StrBufAppendPrintf(Target, "%d", ul->AccessLevel, 0);
 }
 
-void tmplput_USERLIST_AccessLevelStr(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
-       
+void tmplput_USERLIST_AccessLevelStr(StrBuf * Target, WCTemplputParams * TP) {
+       UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
+
        StrBufAppendBufPlain(Target, _(axdefs[ul->AccessLevel]), -1, 0);
 }
 
-void tmplput_USERLIST_UID(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_UID(StrBuf * Target, WCTemplputParams * TP) {
+       UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
 
        StrBufAppendPrintf(Target, "%d", ul->UID, 0);
 }
 
 
-void tmplput_USERLIST_LastLogonNo(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_LastLogonNo(StrBuf * Target, WCTemplputParams * TP) {
+       UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
 
-       StrBufAppendPrintf(Target,"%ld", ul->LastLogonT, 0);
+       StrBufAppendPrintf(Target, "%ld", ul->LastLogonT, 0);
 }
 
 
-void tmplput_USERLIST_LastLogonStr(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_LastLogonStr(StrBuf * Target, WCTemplputParams * TP) {
+       UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
        StrEscAppend(Target, NULL, asctime(localtime(&ul->LastLogonT)), 0, 0);
 }
 
 
-void tmplput_USERLIST_nLogons(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_nLogons(StrBuf * Target, WCTemplputParams * TP) {
+       UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
 
        StrBufAppendPrintf(Target, "%d", ul->nLogons, 0);
 }
 
 
-void tmplput_USERLIST_nPosts(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_nPosts(StrBuf * Target, WCTemplputParams * TP) {
+       UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
 
        StrBufAppendPrintf(Target, "%d", ul->nPosts, 0);
 }
 
 
-void tmplput_USERLIST_Flags(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_Flags(StrBuf * Target, WCTemplputParams * TP) {
+       UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
 
        StrBufAppendPrintf(Target, "%d", ul->Flags, 0);
 }
 
 
-void tmplput_USERLIST_DaysTillPurge(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_DaysTillPurge(StrBuf * Target, WCTemplputParams * TP) {
+       UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
 
        StrBufAppendPrintf(Target, "%d", ul->DaysTillPurge, 0);
 }
 
 
-int ConditionalUser(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+int ConditionalUser(StrBuf * Target, WCTemplputParams * TP) {
+       UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
        if (havebstr("usernum")) {
                return ibstr("usernum") == ul->UID;
        }
        else if (havebstr("username")) {
                return strcmp(bstr("username"), ChrPtr(ul->UserName)) == 0;
        }
-       else 
+       else
                return 0;
 }
 
 
-int ConditionalFlagINetEmail(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+int ConditionalFlagINetEmail(StrBuf * Target, WCTemplputParams * TP) {
+       UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
        return (ul->Flags & US_INTERNET) != 0;
 }
 
 
-int ConditionalUserAccess(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
-       
+int ConditionalUserAccess(StrBuf * Target, WCTemplputParams * TP) {
+       UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
+
        if (ul == NULL)
                return 0;
 
-       return GetTemplateTokenNumber(Target, 
-                                     TP, 
-                                     3, 
-                                     AxNewU)
-               ==
-               ul->AccessLevel;
+       return GetTemplateTokenNumber(Target, TP, 3, AxNewU)
+           == ul->AccessLevel;
 }
 
 
-int ConditionalHaveBIO(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
-       
+int ConditionalHaveBIO(StrBuf * Target, WCTemplputParams * TP) {
+       UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
+
        if (ul == NULL)
                return 0;
        return ul->HasBio;
 }
 
 
-int ConditionalSuppressEmailFields(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalSuppressEmailFields(StrBuf * Target, WCTemplputParams * TP) {
        return 0;               // FIXME this makes all email fields display
 }
 
 
-void tmplput_USER_BIO(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_USER_BIO(StrBuf * Target, WCTemplputParams * TP) {
        int Done = 0;
        StrBuf *Buf;
        const char *who;
@@ -500,9 +452,8 @@ void tmplput_USER_BIO(StrBuf *Target, WCTemplputParams *TP)
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) == 1) {
                StrBuf *BioBuf = NewStrBufPlain(NULL, SIZ);
-               while (!Done && StrBuf_ServGetln(Buf)>=0) {
-                       if ( (StrLength(Buf)==3) && 
-                            !strcmp(ChrPtr(Buf), "000")) 
+               while (!Done && StrBuf_ServGetln(Buf) >= 0) {
+                       if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000"))
                                Done = 1;
                        else {
                                StrBufAppendBuf(BioBuf, Buf, 0);
@@ -516,10 +467,9 @@ void tmplput_USER_BIO(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-int Conditional_USER_HAS_PIC(StrBuf *Target, WCTemplputParams *TP)
-{
+int Conditional_USER_HAS_PIC(StrBuf * Target, WCTemplputParams * TP) {
        // ajc 2016apr10 this needs to be re-evaluated with the new protocol
-       return(0);
+       return (0);
 }
 
 
@@ -527,8 +477,7 @@ int Conditional_USER_HAS_PIC(StrBuf *Target, WCTemplputParams *TP)
  *  Locate the message number of a user's vCard in the current room
  *  Returns the message id of his vcard
  */
-long locate_user_vcard_in_this_room(message_summary **VCMsg, wc_mime_attachment **VCAtt)
-{
+long locate_user_vcard_in_this_room(message_summary ** VCMsg, wc_mime_attachment ** VCAtt) {
        HashPos *at;
        HashPos *att;
        const char *HashKey;
@@ -545,7 +494,7 @@ long locate_user_vcard_in_this_room(message_summary **VCMsg, wc_mime_attachment
 
 
        Buf = NewStrBuf();
-TRYAGAIN:
+      TRYAGAIN:
        memset(&Stat, 0, sizeof(SharedMessageStatus));
        Stat.maxload = 10000;
        Stat.lowest_found = (-1);
@@ -554,22 +503,20 @@ TRYAGAIN:
        if (load_msg_ptrs("MSGS ALL||||1", NULL, NULL, &Stat, NULL, NULL, NULL, NULL, 0) > 0) {
                at = GetNewHashPos(WC->summ, 0);
                while (GetNextHashPos(WC->summ, at, &HKLen, &HashKey, &vMsg)) {
-                       Msg = (message_summary*) vMsg;          
-                       Msg->MsgBody =  (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
+                       Msg = (message_summary *) vMsg;
+                       Msg->MsgBody = (wc_mime_attachment *) malloc(sizeof(wc_mime_attachment));
                        memset(Msg->MsgBody, 0, sizeof(wc_mime_attachment));
                        Msg->MsgBody->msgnum = Msg->msgnum;
 
                        load_message(Msg, FoundCharset, &Error);
-                       
+
                        if (Msg->AllAttach != NULL) {
                                att = GetNewHashPos(Msg->AllAttach, 0);
-                               while (GetNextHashPos(Msg->AllAttach, att, &HKLen, &HashKey, &vMsg) && 
-                                      (vcard_msgnum == -1)) {
-                                       Att = (wc_mime_attachment*) vMsg;
-                                       if (
-                                               (strcasecmp(ChrPtr(Att->ContentType), "text/x-vcard") == 0)
-                                               || (strcasecmp(ChrPtr(Att->ContentType), "text/vcard") == 0)
-                                       ) {
+                               while (GetNextHashPos(Msg->AllAttach, att, &HKLen, &HashKey, &vMsg) && (vcard_msgnum == -1)) {
+                                       Att = (wc_mime_attachment *) vMsg;
+                                       if ((strcasecmp(ChrPtr(Att->ContentType), "text/x-vcard") == 0)
+                                           || (strcasecmp(ChrPtr(Att->ContentType), "text/vcard") == 0)
+                                           ) {
                                                *VCAtt = Att;
                                                *VCMsg = Msg;
                                                vcard_msgnum = Msg->msgnum;
@@ -581,9 +528,9 @@ TRYAGAIN:
                                DeleteHashPos(&att);
                        }
                        FreeStrBuf(&Error);     /* don't care... */
-                       
+
                }
-               DeleteHashPos(&at);             
+               DeleteHashPos(&at);
        }
 
        /* If there's no vcard, create one */
@@ -599,14 +546,14 @@ TRYAGAIN:
                        serv_puts("end:vcard");
                        serv_puts("000");
                }
-               else 
+               else
                        syslog(LOG_WARNING, "Error while creating user vcard: %s\n", ChrPtr(Buf));
                goto TRYAGAIN;
        }
        FreeStrBuf(&Buf);
        FreeStrBuf(&FoundCharset);
 
-       return(vcard_msgnum);
+       return (vcard_msgnum);
 }
 
 
@@ -652,11 +599,7 @@ void display_edit_address_book_entry(const char *username, long usernum) {
                return;
        }
 
-       do_edit_vcard(vcard_msgnum, "1", 
-                     VCMsg,
-                     VCAtt,
-                     "select_user_to_edit", 
-                     ChrPtr(roomname));
+       do_edit_vcard(vcard_msgnum, "1", VCMsg, VCAtt, "select_user_to_edit", ChrPtr(roomname));
        FreeStrBuf(&roomname);
 }
 
@@ -666,20 +609,20 @@ void display_edit_address_book_entry(const char *username, long usernum) {
  */
 void delete_user(char *username) {
        StrBuf *Buf;
-       
+
        Buf = NewStrBuf();
        serv_printf("ASUP %s|0|0|0|0|0|", username);
        StrBuf_ServGetln(Buf);
        GetServerStatusMsg(Buf, NULL, 1, 2);
 
-       select_user_to_edit( bstr("username"));
+       select_user_to_edit(bstr("username"));
        FreeStrBuf(&Buf);
 }
-               
+
 
 void display_edituser(const char *supplied_username, int is_new) {
        const char *Pos;
-       UserListEntryUL;
+       UserListEntry *UL;
        StrBuf *Buf;
        char username[256];
        int i = 0;
@@ -713,7 +656,7 @@ void display_edituser(const char *supplied_username, int is_new) {
                        serv_printf("AGEA %s", username);
                        StrBuf_ServGetln(Buf);
                        if (GetServerStatusMsg(Buf, NULL, 1, 2) == 1) {
-                               while(StrBuf_ServGetln(Buf) , strcmp(ChrPtr(Buf), "000")) {
+                               while (StrBuf_ServGetln(Buf), strcmp(ChrPtr(Buf), "000")) {
                                        if (i == 0) {
                                                StrBufAppendPrintf(UL->PrimaryEmail, "%s", ChrPtr(Buf));
                                        }
@@ -736,7 +679,7 @@ void display_edituser(const char *supplied_username, int is_new) {
                        end_burst();
                }
                DeleteUserListEntry(UL);
-               
+
        }
        FreeStrBuf(&Buf);
 }
@@ -754,7 +697,7 @@ void edituser(void) {
 
        if (!havebstr("ok_button")) {
                AppendImportantMessage(_("Changes were not saved."), -1);
-       }       
+       }
        else {
                StrBuf *Buf = NewStrBuf();
 
@@ -763,7 +706,7 @@ void edituser(void) {
                        flags |= US_INTERNET;
                }
                else {
-                       flags &= ~US_INTERNET ;
+                       flags &= ~US_INTERNET;
                }
 
                if ((havebstr("newname")) && (strcasecmp(bstr("username"), bstr("newname")))) {
@@ -776,16 +719,12 @@ void edituser(void) {
 
                /* Send the new account parameters */
                serv_printf("ASUP %s|%s|%d|%s|%s|%s|%s|%s|%s|",
-                       username,
-                       bstr("password"),
-                       flags,
-                       bstr("timescalled"),
-                       bstr("msgsposted"),
-                       bstr("axlevel"),
-                       bstr("usernum"),
-                       bstr("lastcall"),
-                       bstr("purgedays")
-               );
+                           username,
+                           bstr("password"),
+                           flags,
+                           bstr("timescalled"),
+                           bstr("msgsposted"), bstr("axlevel"), bstr("usernum"), bstr("lastcall"), bstr("purgedays")
+                   );
                StrBuf_ServGetln(Buf);
                GetServerStatusMsg(Buf, NULL, 1, 2);
 
@@ -795,20 +734,21 @@ void edituser(void) {
 
                /* Replace any commas, semicolons, or spaces with newlines */
                char *pos;
-               for (pos=all_the_emails; *pos!=0; ++pos) {
-                       if ((*pos == ',') || (*pos == ';') || (*pos == ' ')) *pos = '\n' ;
+               for (pos = all_the_emails; *pos != 0; ++pos) {
+                       if ((*pos == ',') || (*pos == ';') || (*pos == ' '))
+                               *pos = '\n';
                }
 
                /* Remove any naughty inappropriate whitespace */
                striplt(all_the_emails);
                while (pos = strstr(all_the_emails, "\n,"), (pos != NULL)) {
-                       strcpy(pos, pos+1);
+                       strcpy(pos, pos + 1);
                }
                while (pos = strstr(all_the_emails, ",\n"), (pos != NULL)) {
-                       strcpy(pos+1, pos+2);
+                       strcpy(pos + 1, pos + 2);
                }
                while (pos = strstr(all_the_emails, "\n\n"), (pos != NULL)) {
-                       strcpy(pos+1, pos+2);
+                       strcpy(pos + 1, pos + 2);
                }
 
                /* Now send it to the server. */
@@ -826,7 +766,7 @@ void edituser(void) {
         * the vCard edit screen.
         */
        if (is_new) {
-               display_edit_address_book_entry(username, lbstr("usernum") );
+               display_edit_address_book_entry(username, lbstr("usernum"));
        }
        else {
                select_user_to_edit(username);
@@ -854,8 +794,7 @@ void create_user(void) {
        else if (FullState == 570) {
                AppendImportantMessage(_("You are attempting to create a new user from within Citadel "
                                         "while running in host based authentication mode.  In this mode, "
-                                        "you must create new users on the host system, not within Citadel."), 
-                                      -1);
+                                        "you must create new users on the host system, not within Citadel."), -1);
                select_user_to_edit(NULL);
        }
        else {
@@ -899,10 +838,7 @@ void _display_edituser(void) {
 }
 
 
-void 
-InitModule_USEREDIT
-(void)
-{
+void InitModule_USEREDIT(void) {
        RegisterCTX(CTX_USERLIST);
        WebcitAddUrlHandler(HKEY("select_user_to_edit"), "", 0, _select_user_to_edit, 0);
        WebcitAddUrlHandler(HKEY("display_edituser"), "", 0, _display_edituser, 0);
@@ -910,70 +846,46 @@ InitModule_USEREDIT
        WebcitAddUrlHandler(HKEY("create_user"), "", 0, create_user, 0);
        WebcitAddUrlHandler(HKEY("userpic"), "", 0, display_userpic, 0);
 
-       RegisterNamespace("USERLIST:USERNAME",      0, 1, tmplput_USERLIST_UserName, NULL, CTX_USERLIST);
-       RegisterNamespace("USERLIST:PASSWD",        0, 1, tmplput_USERLIST_Password, NULL, CTX_USERLIST);
-       RegisterNamespace("USERLIST:ACCLVLNO",      0, 0, tmplput_USERLIST_AccessLevelNo, NULL, CTX_USERLIST);
-       RegisterNamespace("USERLIST:ACCLVLSTR",     0, 0, tmplput_USERLIST_AccessLevelStr, NULL, CTX_USERLIST);
-       RegisterNamespace("USERLIST:UID",           0, 0, tmplput_USERLIST_UID, NULL, CTX_USERLIST);
+       RegisterNamespace("USERLIST:USERNAME", 0, 1, tmplput_USERLIST_UserName, NULL, CTX_USERLIST);
+       RegisterNamespace("USERLIST:PASSWD", 0, 1, tmplput_USERLIST_Password, NULL, CTX_USERLIST);
+       RegisterNamespace("USERLIST:ACCLVLNO", 0, 0, tmplput_USERLIST_AccessLevelNo, NULL, CTX_USERLIST);
+       RegisterNamespace("USERLIST:ACCLVLSTR", 0, 0, tmplput_USERLIST_AccessLevelStr, NULL, CTX_USERLIST);
+       RegisterNamespace("USERLIST:UID", 0, 0, tmplput_USERLIST_UID, NULL, CTX_USERLIST);
        RegisterNamespace("USERLIST:LASTLOGON:STR", 0, 0, tmplput_USERLIST_LastLogonStr, NULL, CTX_USERLIST);
-       RegisterNamespace("USERLIST:LASTLOGON:NO",  0, 0, tmplput_USERLIST_LastLogonNo, NULL, CTX_USERLIST);
-       RegisterNamespace("USERLIST:NLOGONS",       0, 0, tmplput_USERLIST_nLogons, NULL, CTX_USERLIST);
-       RegisterNamespace("USERLIST:NPOSTS",        0, 0, tmplput_USERLIST_nPosts, NULL, CTX_USERLIST);
-       RegisterNamespace("USERLIST:PRIMARYEMAIL",  0, 1, tmplput_USERLIST_PrimaryEmail, NULL, CTX_USERLIST);
-       RegisterNamespace("USERLIST:OTHEREMAILS",   0, 1, tmplput_USERLIST_OtherEmails, NULL, CTX_USERLIST);
-       RegisterNamespace("USERLIST:FLAGS",         0, 0, tmplput_USERLIST_Flags, NULL, CTX_USERLIST);
+       RegisterNamespace("USERLIST:LASTLOGON:NO", 0, 0, tmplput_USERLIST_LastLogonNo, NULL, CTX_USERLIST);
+       RegisterNamespace("USERLIST:NLOGONS", 0, 0, tmplput_USERLIST_nLogons, NULL, CTX_USERLIST);
+       RegisterNamespace("USERLIST:NPOSTS", 0, 0, tmplput_USERLIST_nPosts, NULL, CTX_USERLIST);
+       RegisterNamespace("USERLIST:PRIMARYEMAIL", 0, 1, tmplput_USERLIST_PrimaryEmail, NULL, CTX_USERLIST);
+       RegisterNamespace("USERLIST:OTHEREMAILS", 0, 1, tmplput_USERLIST_OtherEmails, NULL, CTX_USERLIST);
+       RegisterNamespace("USERLIST:FLAGS", 0, 0, tmplput_USERLIST_Flags, NULL, CTX_USERLIST);
        RegisterNamespace("USERLIST:DAYSTILLPURGE", 0, 0, tmplput_USERLIST_DaysTillPurge, NULL, CTX_USERLIST);
 
-       RegisterNamespace("USER:BIO", 1, 2, tmplput_USER_BIO,  NULL, CTX_NONE);
+       RegisterNamespace("USER:BIO", 1, 2, tmplput_USER_BIO, NULL, CTX_NONE);
 
-       RegisterConditional("COND:USERNAME",                    0,      ConditionalUser,                CTX_USERLIST);
-       RegisterConditional("COND:USERACCESS",                  0,      ConditionalUserAccess,          CTX_USERLIST);
-       RegisterConditional("COND:USERLIST:FLAG:USE_INTERNET",  0,      ConditionalFlagINetEmail,       CTX_USERLIST);
-       RegisterConditional("COND:USERLIST:HAVEBIO",            0,      ConditionalHaveBIO,             CTX_USERLIST);
-       RegisterConditional("COND:USER:PIC",                    1,      Conditional_USER_HAS_PIC,       CTX_NONE);
+       RegisterConditional("COND:USERNAME", 0, ConditionalUser, CTX_USERLIST);
+       RegisterConditional("COND:USERACCESS", 0, ConditionalUserAccess, CTX_USERLIST);
+       RegisterConditional("COND:USERLIST:FLAG:USE_INTERNET", 0, ConditionalFlagINetEmail, CTX_USERLIST);
+       RegisterConditional("COND:USERLIST:HAVEBIO", 0, ConditionalHaveBIO, CTX_USERLIST);
+       RegisterConditional("COND:USER:PIC", 1, Conditional_USER_HAS_PIC, CTX_NONE);
 
-       RegisterIterator("USERLIST", 0, NULL, iterate_load_userlist, NULL, DeleteHash, CTX_USERLIST, CTX_NONE, IT_FLAG_DETECT_GROUPCHANGE);
+       RegisterIterator("USERLIST", 0, NULL, iterate_load_userlist, NULL, DeleteHash, CTX_USERLIST, CTX_NONE,
+                        IT_FLAG_DETECT_GROUPCHANGE);
 
        RegisterSortFunc(HKEY("user:name"),
-                        HKEY("userlist"),
-                        CompareUserListName,
-                        CompareUserListNameRev,
-                        GroupchangeUserListName,
-                        CTX_USERLIST);
+                        HKEY("userlist"), CompareUserListName, CompareUserListNameRev, GroupchangeUserListName, CTX_USERLIST);
        RegisterSortFunc(HKEY("user:accslvl"),
-                        HKEY("userlist"),
-                        CompareAccessLevel,
-                        CompareAccessLevelRev,
-                        GroupchangeAccessLevel,
-                        CTX_USERLIST);
+                        HKEY("userlist"), CompareAccessLevel, CompareAccessLevelRev, GroupchangeAccessLevel, CTX_USERLIST);
 
        RegisterSortFunc(HKEY("user:nlogons"),
-                        HKEY("userlist"),
-                        ComparenLogons,
-                        ComparenLogonsRev,
-                        GroupchangenLogons,
-                        CTX_USERLIST);
-
-       RegisterSortFunc(HKEY("user:uid"),
-                        HKEY("userlist"),
-                        CompareUID,
-                        CompareUIDRev,
-                        GroupchangeUID,
-                        CTX_USERLIST);
+                        HKEY("userlist"), ComparenLogons, ComparenLogonsRev, GroupchangenLogons, CTX_USERLIST);
+
+       RegisterSortFunc(HKEY("user:uid"), HKEY("userlist"), CompareUID, CompareUIDRev, GroupchangeUID, CTX_USERLIST);
 
        RegisterSortFunc(HKEY("user:lastlogon"),
-                        HKEY("userlist"),
-                        CompareLastLogon,
-                        CompareLastLogonRev,
-                        GroupchangeLastLogon,
-                        CTX_USERLIST);
+                        HKEY("userlist"), CompareLastLogon, CompareLastLogonRev, GroupchangeLastLogon, CTX_USERLIST);
 
        RegisterSortFunc(HKEY("user:nmsgposts"),
-                        HKEY("userlist"),
-                        ComparenPosts,
-                        ComparenPostsRev,
-                        GroupchangenPosts,
-                        CTX_USERLIST);
+                        HKEY("userlist"), ComparenPosts, ComparenPostsRev, GroupchangenPosts, CTX_USERLIST);
 
        REGISTERTokenParamDefine(AxDeleted);
        REGISTERTokenParamDefine(AxNewU);
@@ -983,4 +895,3 @@ InitModule_USEREDIT
        REGISTERTokenParamDefine(AxPrefU);
        REGISTERTokenParamDefine(AxAideU);
 }
-
index 4a822814609ee26811bb6eb15c0ad4dc036d468a..b5812b595d1e7f9bfa33dda53303fc5527b3dceb 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * de/encoding stuff. hopefully mostly to be depricated in favour of subst.c + strbuf
  */
@@ -11,8 +12,7 @@
 /*   
  * remove escaped strings from i.e. the url string (like %20 for blanks)
  */
-long unescape_input(char *buf)
-{
+long unescape_input(char *buf) {
        unsigned int a, b;
        char hex[3];
        long buflen;
@@ -20,12 +20,12 @@ long unescape_input(char *buf)
 
        buflen = strlen(buf);
 
-       while ((buflen > 0) && (isspace(buf[buflen - 1]))){
+       while ((buflen > 0) && (isspace(buf[buflen - 1]))) {
                buf[buflen - 1] = 0;
-               buflen --;
+               buflen--;
        }
 
-       a = 0; 
+       a = 0;
        while (a < buflen) {
                if (buf[a] == '+')
                        buf[a] = ' ';
@@ -35,7 +35,7 @@ long unescape_input(char *buf)
                                buf[a] = '\0';
                                buflen = a;
                        }
-                       else {                  
+                       else {
                                hex[0] = buf[a + 1];
                                hex[1] = buf[a + 2];
                                hex[2] = 0;
@@ -45,8 +45,8 @@ long unescape_input(char *buf)
                                len = buflen - a - 2;
                                if (len > 0)
                                        memmove(&buf[a + 1], &buf[a + 3], len);
-                       
-                               buflen -=2;
+
+                               buflen -= 2;
                        }
                }
                a++;
@@ -62,84 +62,81 @@ long unescape_input(char *buf)
  * nbsp                        If nonzero, spaces are converted to non-breaking spaces.
  * nolinebreaks                if set, linebreaks are removed from the string.
  */
-long stresc(char *target, long tSize, char *strbuf, int nbsp, int nolinebreaks)
-{
-        char *aptr, *bptr, *eptr;
-        *target = '\0';
-        aptr = strbuf;
-        bptr = target;
-        eptr = target + tSize - 6; /* our biggest unit to put in...  */
-        while ((bptr < eptr) && !IsEmptyStr(aptr) ){
-                if (*aptr == '<') {
-                        memcpy(bptr, "&lt;", 4);
-                        bptr += 4;
-                }
-                else if (*aptr == '>') {
-                        memcpy(bptr, "&gt;", 4);
-                        bptr += 4;
-                }
-                else if (*aptr == '&') {
-                        memcpy(bptr, "&amp;", 5);
-                        bptr += 5;
-                }
-                else if (*aptr == '\"') {
-                        memcpy(bptr, "&quot;", 6);
-                        bptr += 6;
-                }
-                else if (*aptr == '\'') {
-                        memcpy(bptr, "&#39;", 5);
-                        bptr += 5;
-                }
-                else if (*aptr == LB) {
-                        *bptr = '<';
-                        bptr ++;
-                }
-                else if (*aptr == RB) {
-                        *bptr = '>';
-                        bptr ++;
-                }
-                else if (*aptr == QU) {
-                        *bptr ='"';
-                        bptr ++;
-                }
-                else if ((*aptr == 32) && (nbsp == 1)) {
-                        memcpy(bptr, "&nbsp;", 6);
-                        bptr += 6;
-                }
-                else if ((*aptr == '\n') && (nolinebreaks)) {
-                        *bptr='\0';     /* nothing */
-                }
-                else if ((*aptr == '\r') && (nolinebreaks)) {
-                        *bptr='\0';     /* nothing */
-                }
-                else{
-                        *bptr = *aptr;
-                        bptr++;
-                }
-                aptr ++;
-        }
-        *bptr = '\0';
-        if ((bptr = eptr - 1 ) && !IsEmptyStr(aptr) )
-                return -1;
-        return (bptr - target);
+long stresc(char *target, long tSize, char *strbuf, int nbsp, int nolinebreaks) {
+       char *aptr, *bptr, *eptr;
+
+       *target = '\0';
+       aptr = strbuf;
+       bptr = target;
+       eptr = target + tSize - 6;      /* our biggest unit to put in...  */
+
+
+       while ((bptr < eptr) && !IsEmptyStr(aptr)) {
+               if (*aptr == '<') {
+                       memcpy(bptr, "&lt;", 4);
+                       bptr += 4;
+               }
+               else if (*aptr == '>') {
+                       memcpy(bptr, "&gt;", 4);
+                       bptr += 4;
+               }
+               else if (*aptr == '&') {
+                       memcpy(bptr, "&amp;", 5);
+                       bptr += 5;
+               }
+               else if (*aptr == '\"') {
+                       memcpy(bptr, "&quot;", 6);
+                       bptr += 6;
+               }
+               else if (*aptr == '\'') {
+                       memcpy(bptr, "&#39;", 5);
+                       bptr += 5;
+               }
+               else if (*aptr == LB) {
+                       *bptr = '<';
+                       bptr++;
+               }
+               else if (*aptr == RB) {
+                       *bptr = '>';
+                       bptr++;
+               }
+               else if (*aptr == QU) {
+                       *bptr = '"';
+                       bptr++;
+               }
+               else if ((*aptr == 32) && (nbsp == 1)) {
+                       memcpy(bptr, "&nbsp;", 6);
+                       bptr += 6;
+               }
+               else if ((*aptr == '\n') && (nolinebreaks)) {
+                       *bptr = '\0';   /* nothing */
+               }
+               else if ((*aptr == '\r') && (nolinebreaks)) {
+                       *bptr = '\0';   /* nothing */
+               }
+               else {
+                       *bptr = *aptr;
+                       bptr++;
+               }
+               aptr++;
+       }
+       *bptr = '\0';
+       if ((bptr = eptr - 1) && !IsEmptyStr(aptr))
+               return -1;
+       return (bptr - target);
 }
 
 /* 
  * static wrapper for ecsputs1
  */
-void escputs(const char *strbuf)
-{
+void escputs(const char *strbuf) {
        StrEscAppend(WC->WBuf, NULL, strbuf, 0, 0);
 }
 
 /*
  * urlescape buffer and print it to the client
  */
-void urlescputs(const char *strbuf)
-{
+void urlescputs(const char *strbuf) {
        StrBufUrlescAppend(WC->WBuf, NULL, strbuf);
 }
 
@@ -147,8 +144,7 @@ void urlescputs(const char *strbuf)
 /**
  * urlescape buffer and print it as header 
  */
-void hurlescputs(const char *strbuf) 
-{
+void hurlescputs(const char *strbuf) {
        StrBufUrlescAppend(WC->HBuf, NULL, strbuf);
 }
 
@@ -156,16 +152,16 @@ void hurlescputs(const char *strbuf)
 /*
  * Output a string to the client as a CDATA block
  */
-void cdataout(char *rawdata)
-{
+void cdataout(char *rawdata) {
        char *ptr = rawdata;
        wc_printf("<![CDATA[");
 
-       while ((ptr != NULL) && (ptr[0] != 0))
-       {
+       while ((ptr != NULL) && (ptr[0] != 0)) {
                if (!strncmp(ptr, "]]>", 3)) {
                        wc_printf("]]]]><![CDATA[>");
-                       ++ptr; ++ptr; ++ptr;
+                       ++ptr;
+                       ++ptr;
+                       ++ptr;
                }
                else {
                        wc_printf("%c", ptr[0]);
@@ -175,4 +171,3 @@ void cdataout(char *rawdata)
 
        wc_printf("]]>");
 }
-
index 7c322492b351f434a635928ed2b0d615af701491..206df63c1c17d35f1dfc9a5d435dd5068ae7a64c 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2013 by the citadel.org team
  *
@@ -10,8 +11,8 @@
  * GNU General Public License for more details.
  */
 
-void StrEscPuts(const StrBuf *strbuf);
-void StrEscputs1(const StrBuf *strbuf, int nbsp, int nolinebreaks);
+void StrEscPuts(const StrBuf * strbuf);
+void StrEscputs1(const StrBuf * strbuf, int nbsp, int nolinebreaks);
 
 void urlescputs(const char *);
 void hurlescputs(const char *);
index d1a16d383a62ab3c83da8c935d60f9d2e4f6bad8..e9fd37a37b1f93b2e764f3aded300b93b19b2927 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2021 by the citadel.org team
  *
@@ -31,7 +32,7 @@ typedef enum _VCStrEnum {
        Base64BinaryAttachment,
        UnKnown,
        TerminateList
-}VCStrEnum;
+} VCStrEnum;
 typedef struct vcField vcField;
 struct vcField {
        ConstStr STR;
@@ -42,65 +43,65 @@ struct vcField {
        ConstStr Name;
 };
 
-vcField VCStr_Ns [] = {
-       {{HKEY("last")},   FlatString,    NULL, 0, 0, {HKEY("Last Name")}},
-       {{HKEY("first")},  FlatString,    NULL, 0, 0, {HKEY("First Name")}},
-       {{HKEY("middle")}, FlatString,    NULL, 0, 0, {HKEY("Middle Name")}},
-       {{HKEY("prefix")}, FlatString,    NULL, 0, 0, {HKEY("Prefix")}},
-       {{HKEY("suffix")}, FlatString,    NULL, 0, 0, {HKEY("Suffix")}},
-       {{HKEY("")},       TerminateList, NULL, 0, 0, {HKEY("")}}
+vcField VCStr_Ns[] = {
+       { { HKEY("last")}, FlatString, NULL, 0, 0, { HKEY("Last Name")} },
+       { { HKEY("first")}, FlatString, NULL, 0, 0, { HKEY("First Name")} },
+       { { HKEY("middle")}, FlatString, NULL, 0, 0, { HKEY("Middle Name")} },
+       { { HKEY("prefix")}, FlatString, NULL, 0, 0, { HKEY("Prefix")} },
+       { { HKEY("suffix")}, FlatString, NULL, 0, 0, { HKEY("Suffix")} },
+       { { HKEY("")}, TerminateList, NULL, 0, 0, { HKEY("")} }
 };
 
-vcField VCStr_Addrs [] = {
-       {{HKEY("POBox")},    Address,       NULL, 0, 0, {HKEY("PO box")}},
-       {{HKEY("extadr")},   Address,       NULL, 0, 0, {HKEY("Address")}},
-       {{HKEY("street")},   Address,       NULL, 0, 0, {HKEY("")}},
-       {{HKEY("city")},     Address,       NULL, 0, 0, {HKEY("City")}},
-       {{HKEY("state")},    Address,       NULL, 0, 0, {HKEY("State")}},
-       {{HKEY("zip")},      Address,       NULL, 0, 0, {HKEY("ZIP code")}},
-       {{HKEY("country")},  Address,       NULL, 0, 0, {HKEY("Country")}},
-       {{HKEY("")},         TerminateList, NULL, 0, 0, {HKEY("")}}
+vcField VCStr_Addrs[] = {
+       { { HKEY("POBox")}, Address, NULL, 0, 0, { HKEY("PO box")} },
+       { { HKEY("extadr")}, Address, NULL, 0, 0, { HKEY("Address")} },
+       { { HKEY("street")}, Address, NULL, 0, 0, { HKEY("")} },
+       { { HKEY("city")}, Address, NULL, 0, 0, { HKEY("City")} },
+       { { HKEY("state")}, Address, NULL, 0, 0, { HKEY("State")} },
+       { { HKEY("zip")}, Address, NULL, 0, 0, { HKEY("ZIP code")} },
+       { { HKEY("country")}, Address, NULL, 0, 0, { HKEY("Country")} },
+       { { HKEY("")}, TerminateList, NULL, 0, 0, { HKEY("")} }
 };
 
-vcField VCStrE [] = {
-       {{HKEY("version")},         Number,                 NULL,        0, 0, {HKEY("")}},
-       {{HKEY("rev")},             Number,                 NULL,        0, 0, {HKEY("")}},
-       {{HKEY("label")},           FlatString,             NULL,        0, 0, {HKEY("")}},
-       {{HKEY("uid")},             FlatString,             NULL,        0, 0, {HKEY("")}},
-       {{HKEY("n")},               StringCluster,          VCStr_Ns,    0, 0, {HKEY("")}}, /* N is name, but only if there's no FN already there */
-       {{HKEY("fn")},              FlatString,             NULL,        0, 0, {HKEY("")}}, /* FN (full name) is a true 'display name' field */
-       {{HKEY("title")},           FlatString,             NULL,        0, 0, {HKEY("Title:")}},
-       {{HKEY("org")},             FlatString,             NULL,        0, 0, {HKEY("Organization:")}},/* organization */
-       {{HKEY("email")},           EmailAddr,              NULL,        0, 0, {HKEY("E-mail:")}},
-       {{HKEY("tel")},             PhoneNumber,            NULL,        0, 0, {HKEY("Telephone:")}},
-       {{HKEY("adr")},             StringCluster,          VCStr_Addrs, 0, 0, {HKEY("Address:")}},
-       {{HKEY("photo")},           Base64BinaryAttachment, NULL,        0, 0, {HKEY("Photo:")}},
-       {{HKEY("tel;home")},        PhoneNumber,            NULL,        0, 0, {HKEY(" (home)")}},
-       {{HKEY("tel;work")},        PhoneNumber,            NULL,        0, 0, {HKEY(" (work)")}},
-       {{HKEY("tel;fax")},         PhoneNumber,            NULL,        0, 0, {HKEY(" (fax)")}},
-       {{HKEY("tel;cell")},        PhoneNumber,            NULL,        0, 0, {HKEY(" (cell)")}},
-       {{HKEY("email;internet")},  EmailAddr,              NULL,        0, 0, {HKEY("E-mail:")}},
-       {{HKEY("UNKNOWN")},         UnKnown,                NULL,        0, 0, {HKEY("")}},
-       {{HKEY("")},                TerminateList,          NULL,        0, 0, {HKEY("")}}
+vcField VCStrE[] = {
+       { { HKEY("version")}, Number, NULL, 0, 0, { HKEY("")} },
+       { { HKEY("rev")}, Number, NULL, 0, 0, { HKEY("")} },
+       { { HKEY("label")}, FlatString, NULL, 0, 0, { HKEY("")} },
+       { { HKEY("uid")}, FlatString, NULL, 0, 0, { HKEY("")} },
+       { { HKEY("n")}, StringCluster, VCStr_Ns, 0, 0, { HKEY("")} },   /* N is name, but only if there's no FN already there */
+       { { HKEY("fn")}, FlatString, NULL, 0, 0, { HKEY("")} }, /* FN (full name) is a true 'display name' field */
+       { { HKEY("title")}, FlatString, NULL, 0, 0, { HKEY("Title:")} },
+       { { HKEY("org")}, FlatString, NULL, 0, 0, { HKEY("Organization:")} },   /* organization */
+       { { HKEY("email")}, EmailAddr, NULL, 0, 0, { HKEY("E-mail:")} },
+       { { HKEY("tel")}, PhoneNumber, NULL, 0, 0, { HKEY("Telephone:")} },
+       { { HKEY("adr")}, StringCluster, VCStr_Addrs, 0, 0, { HKEY("Address:")} },
+       { { HKEY("photo")}, Base64BinaryAttachment, NULL, 0, 0, { HKEY("Photo:")} },
+       { { HKEY("tel;home")}, PhoneNumber, NULL, 0, 0, { HKEY(" (home)")} },
+       { { HKEY("tel;work")}, PhoneNumber, NULL, 0, 0, { HKEY(" (work)")} },
+       { { HKEY("tel;fax")}, PhoneNumber, NULL, 0, 0, { HKEY(" (fax)")} },
+       { { HKEY("tel;cell")}, PhoneNumber, NULL, 0, 0, { HKEY(" (cell)")} },
+       { { HKEY("email;internet")}, EmailAddr, NULL, 0, 0, { HKEY("E-mail:")} },
+       { { HKEY("UNKNOWN")}, UnKnown, NULL, 0, 0, { HKEY("")} },
+       { { HKEY("")}, TerminateList, NULL, 0, 0, { HKEY("")} }
 };
 
-ConstStr VCStr [] = {
-       {HKEY("")},
-       {HKEY("n")}, /* N is name, but only if there's no FN already there */
-       {HKEY("fn")}, /* FN (full name) is a true 'display name' field */
-       {HKEY("title")},   /* title */
-       {HKEY("org")},    /* organization */
-       {HKEY("email")},
-       {HKEY("tel")},
-       {HKEY("work")},
-       {HKEY("home")},
-       {HKEY("cell")},
-       {HKEY("adr")},
-       {HKEY("photo")},
-       {HKEY("version")},
-       {HKEY("rev")},
-       {HKEY("label")},
-       {HKEY("uid")}
+ConstStr VCStr[] = {
+       { HKEY("") },
+       { HKEY("n") },          /* N is name, but only if there's no FN already there */
+       { HKEY("fn") },         /* FN (full name) is a true 'display name' field */
+       { HKEY("title") },      /* title */
+       { HKEY("org") },        /* organization */
+       { HKEY("email") },
+       { HKEY("tel") },
+       { HKEY("work") },
+       { HKEY("home") },
+       { HKEY("cell") },
+       { HKEY("adr") },
+       { HKEY("photo") },
+       { HKEY("version") },
+       { HKEY("rev") },
+       { HKEY("label") },
+       { HKEY("uid") }
 };
 
 /*
@@ -115,7 +116,7 @@ typedef struct _addrbookent {
 } addrbookent;
 
 void deleteAbEnt(void *v) {
-       addrbookent *vc = (addrbookent*)v;
+       addrbookent *vc = (addrbookent *) v;
        DeleteHash(&vc->VC);
        FreeStrBuf(&vc->name);
        FreeStrBuf(&vc->msgNoStr);
@@ -124,15 +125,14 @@ void deleteAbEnt(void *v) {
 
 HashList *DefineToToken = NULL;
 HashList *VCTokenToDefine = NULL;
-HashList *vcNames = NULL; /* todo: fill with the name strings */
-vcFieldvcfUnknown = NULL;
+HashList *vcNames = NULL;      /* todo: fill with the name strings */
+vcField *vcfUnknown = NULL;
 
 /******************************************************************************
  *                   initialize vcard structure                               *
  ******************************************************************************/
 
-void RegisterVCardToken(vcField* vf, StrBuf *name, int inTokenCount)
-{
+void RegisterVCardToken(vcField * vf, StrBuf * name, int inTokenCount) {
        if (vf->Type == UnKnown) {
                vcfUnknown = vf;
        }
@@ -140,20 +140,16 @@ void RegisterVCardToken(vcField* vf, StrBuf *name, int inTokenCount)
        Put(DefineToToken, LKEY(vf->cval), vf, reference_free_handler);
        Put(vcNames, LKEY(vf->cval), NewStrBufPlain(CKEY(vf->Name)), HFreeStrBuf);
 
-       syslog(LOG_DEBUG, "Token: %s -> %ld, %d", 
-              ChrPtr(name),
-              vf->cval, 
-              inTokenCount);
+       syslog(LOG_DEBUG, "Token: %s -> %ld, %d", ChrPtr(name), vf->cval, inTokenCount);
 
 }
 
-void autoRegisterTokens(long *enumCounter, vcField* vf, StrBuf *BaseStr, int layer, long parentCVal)
-{
+void autoRegisterTokens(long *enumCounter, vcField * vf, StrBuf * BaseStr, int layer, long parentCVal) {
        int i = 0;
        StrBuf *subStr = NewStrBuf();
        while (vf[i].STR.len > 0) {
                FlushStrBuf(subStr);
-               vf[i].cval = (*enumCounter) ++;
+               vf[i].cval = (*enumCounter)++;
                vf[i].parentCVal = parentCVal;
                StrBufAppendBuf(subStr, BaseStr, 0);
                if (StrLength(subStr) > 0) {
@@ -167,10 +163,10 @@ void autoRegisterTokens(long *enumCounter, vcField* vf, StrBuf *BaseStr, int lay
                case FlatString:
                        break;
                case StringCluster:
-               {
-                       autoRegisterTokens(enumCounter, vf[i].Sub, subStr, 1, vf[i].cval);
-               }
-               break;
+                       {
+                               autoRegisterTokens(enumCounter, vf[i].Sub, subStr, 1, vf[i].cval);
+                       }
+                       break;
                case PhoneNumber:
                        break;
                case EmailAddr:
@@ -200,8 +196,7 @@ void autoRegisterTokens(long *enumCounter, vcField* vf, StrBuf *BaseStr, int lay
  *               VCard template functions                                     *
  ******************************************************************************/
 
-int preeval_vcard_item(WCTemplateToken *Token)
-{
+int preeval_vcard_item(WCTemplateToken * Token) {
        WCTemplputParams TPP;
        WCTemplputParams *TP;
        int searchFieldNo;
@@ -218,21 +213,19 @@ int preeval_vcard_item(WCTemplateToken *Token)
        return 1;
 }
 
-void tmpl_vcard_item(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_vcard_item(StrBuf * Target, WCTemplputParams * TP) {
        void *vItem;
        long searchFieldNo = GetTemplateTokenNumber(Target, TP, 0, 0);
-       addrbookent *ab = (addrbookent*) CTX(CTX_VCARD);
+       addrbookent *ab = (addrbookent *) CTX(CTX_VCARD);
        if (GetHash(ab->VC, LKEY(searchFieldNo), &vItem) && (vItem != NULL)) {
-               StrBufAppendTemplate(Target, TP, (StrBuf*) vItem, 1);
+               StrBufAppendTemplate(Target, TP, (StrBuf *) vItem, 1);
        }
 }
 
-void tmpl_vcard_context_item(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_vcard_context_item(StrBuf * Target, WCTemplputParams * TP) {
        void *vItem;
-       vcField *t = (vcField*) CTX(CTX_VCARD_TYPE);
-       addrbookent *ab = (addrbookent*) CTX(CTX_VCARD);
+       vcField *t = (vcField *) CTX(CTX_VCARD_TYPE);
+       addrbookent *ab = (addrbookent *) CTX(CTX_VCARD);
 
        if (t == NULL) {
                LogTemplateError(NULL, "VCard item", ERR_NAME, TP, "Missing context");
@@ -240,15 +233,13 @@ void tmpl_vcard_context_item(StrBuf *Target, WCTemplputParams *TP)
        }
 
        if (GetHash(ab->VC, LKEY(t->cval), &vItem) && (vItem != NULL)) {
-               StrBufAppendTemplate(Target, TP, (StrBuf*) vItem, 0);
+               StrBufAppendTemplate(Target, TP, (StrBuf *) vItem, 0);
        }
        else {
-               LogTemplateError(NULL, "VCard item", ERR_NAME, TP,
-                                "Doesn't have that key - did you miss to filter in advance?");
+               LogTemplateError(NULL, "VCard item", ERR_NAME, TP, "Doesn't have that key - did you miss to filter in advance?");
        }
 }
-int preeval_vcard_name_str(WCTemplateToken *Token)
-{
+int preeval_vcard_name_str(WCTemplateToken * Token) {
        WCTemplputParams TPP;
        WCTemplputParams *TP;
        int searchFieldNo;
@@ -259,71 +250,63 @@ int preeval_vcard_name_str(WCTemplateToken *Token)
        TP->Tokens = Token;
        searchFieldNo = GetTemplateTokenNumber(Target, TP, 0, 0);
        if (searchFieldNo >= VCEnumCounter) {
-               LogTemplateError(NULL, "VCardName", ERR_PARM1, TP,
-                                "Invalid define");
+               LogTemplateError(NULL, "VCardName", ERR_PARM1, TP, "Invalid define");
                return 0;
        }
        return 1;
 }
 
-void tmpl_vcard_name_str(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_vcard_name_str(StrBuf * Target, WCTemplputParams * TP) {
        void *vItem;
        long searchFieldNo = GetTemplateTokenNumber(Target, TP, 0, 0);
        /* todo: get descriptive string for this vcard type */
        if (GetHash(vcNames, LKEY(searchFieldNo), &vItem) && (vItem != NULL)) {
-               StrBufAppendTemplate(Target, TP, (StrBuf*) vItem, 1);
+               StrBufAppendTemplate(Target, TP, (StrBuf *) vItem, 1);
        }
        else {
-               LogTemplateError(NULL, "VCard item type", ERR_NAME, TP,
-                                "No i18n string for this.");
+               LogTemplateError(NULL, "VCard item type", ERR_NAME, TP, "No i18n string for this.");
                return;
        }
 }
 
-void tmpl_vcard_msgno(StrBuf *Target, WCTemplputParams *TP)
-{
-       addrbookent *ab = (addrbookent*) CTX(CTX_VCARD);
+void tmpl_vcard_msgno(StrBuf * Target, WCTemplputParams * TP) {
+       addrbookent *ab = (addrbookent *) CTX(CTX_VCARD);
        if (ab->msgNoStr == NULL) {
                ab->msgNoStr = NewStrBufPlain(NULL, 64);
        }
        StrBufPrintf(ab->msgNoStr, "%ld", ab->ab_msgnum);
        StrBufAppendTemplate(Target, TP, ab->msgNoStr, 0);
 }
-void tmpl_vcard_context_name_str(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_vcard_context_name_str(StrBuf * Target, WCTemplputParams * TP) {
        void *vItem;
-       vcField *t = (vcField*) CTX(CTX_VCARD_TYPE);
+       vcField *t = (vcField *) CTX(CTX_VCARD_TYPE);
 
        if (t == NULL) {
-               LogTemplateError(NULL, "VCard item type", ERR_NAME, TP,
-                                "Missing context");
+               LogTemplateError(NULL, "VCard item type", ERR_NAME, TP, "Missing context");
                return;
        }
-       
+
        if (GetHash(vcNames, LKEY(t->cval), &vItem) && (vItem != NULL)) {
-               StrBufAppendTemplate(Target, TP, (StrBuf*) vItem, 1);
+               StrBufAppendTemplate(Target, TP, (StrBuf *) vItem, 1);
        }
        else {
-               LogTemplateError(NULL, "VCard item type", ERR_NAME, TP,
-                                "No i18n string for this.");
+               LogTemplateError(NULL, "VCard item type", ERR_NAME, TP, "No i18n string for this.");
                return;
        }
 }
 
-int filter_VC_ByType(const char* key, long len, void *Context, StrBuf *Target, WCTemplputParams *TP)
-{
+int filter_VC_ByType(const char *key, long len, void *Context, StrBuf * Target, WCTemplputParams * TP) {
        long searchType;
        long type = 0;
        void *v;
-       vcField *vf = (vcField*) Context;
+       vcField *vf = (vcField *) Context;
        int rc = 0;
 
        memcpy(&type, key, sizeof(long));
        searchType = GetTemplateTokenNumber(Target, TP, IT_ADDT_PARAM(0), 0);
-       
+
        if (vf->Type == searchType) {
-               addrbookent *ab = (addrbookent*) CTX(CTX_VCARD);
+               addrbookent *ab = (addrbookent *) CTX(CTX_VCARD);
                if (GetHash(ab->VC, LKEY(vf->cval), &v) && v != NULL) {
                        return 1;
                }
@@ -331,27 +314,24 @@ int filter_VC_ByType(const char* key, long len, void *Context, StrBuf *Target, W
        return rc;
 }
 
-HashList *getContextVcard(StrBuf *Target, WCTemplputParams *TP)
-{
-       vcField *vf = (vcField*) CTX(CTX_VCARD_TYPE);
-       addrbookent *ab = (addrbookent*) CTX(CTX_VCARD);
+HashList *getContextVcard(StrBuf * Target, WCTemplputParams * TP) {
+       vcField *vf = (vcField *) CTX(CTX_VCARD_TYPE);
+       addrbookent *ab = (addrbookent *) CTX(CTX_VCARD);
 
        if ((vf == NULL) || (ab == NULL)) {
-               LogTemplateError(NULL, "VCard item type", ERR_NAME, TP,
-                                "Need VCard and Vcard type in context");
-               
+               LogTemplateError(NULL, "VCard item type", ERR_NAME, TP, "Need VCard and Vcard type in context");
+
                return NULL;
        }
        return ab->VC;
 }
 
-int filter_VC_ByContextType(const char* key, long len, void *Context, StrBuf *Target, WCTemplputParams *TP)
-{
+int filter_VC_ByContextType(const char *key, long len, void *Context, StrBuf * Target, WCTemplputParams * TP) {
        long searchType;
-       vcField *vf = (vcField*) CTX(CTX_VCARD_TYPE);
+       vcField *vf = (vcField *) CTX(CTX_VCARD_TYPE);
 
        memcpy(&searchType, key, sizeof(long));
-       
+
        if (vf->cval == searchType) {
                return 1;
        }
@@ -360,25 +340,20 @@ int filter_VC_ByContextType(const char* key, long len, void *Context, StrBuf *Ta
        }
 }
 
-int conditional_VC_Havetype(StrBuf *Target, WCTemplputParams *TP)
-{
-       addrbookent *ab = (addrbookent*) CTX(CTX_VCARD);
+int conditional_VC_Havetype(StrBuf * Target, WCTemplputParams * TP) {
+       addrbookent *ab = (addrbookent *) CTX(CTX_VCARD);
        long HaveFieldType = GetTemplateTokenNumber(Target, TP, 2, 0);
-       int rc = 0;     
+       int rc = 0;
        void *vVCitem;
        const char *Key;
        long len;
        HashPos *it = GetNewHashPos(ab->VC, 0);
-       while (GetNextHashPos(ab->VC, it, &len, &Key, &vVCitem) && 
-              (vVCitem != NULL)) 
-       {
+       while (GetNextHashPos(ab->VC, it, &len, &Key, &vVCitem) && (vVCitem != NULL)) {
                void *vvcField;
                long type = 0;
                memcpy(&type, Key, sizeof(long));
-               if (GetHash(DefineToToken, LKEY(type), &vvcField) &&
-                   (vvcField != NULL))
-               {
-                       vcField *t = (vcField*) vvcField;
+               if (GetHash(DefineToToken, LKEY(type), &vvcField) && (vvcField != NULL)) {
+                       vcField *t = (vcField *) vvcField;
                        if (t && t->Type == HaveFieldType) {
                                rc = 1;
                                break;
@@ -393,9 +368,8 @@ int conditional_VC_Havetype(StrBuf *Target, WCTemplputParams *TP)
 /* Returns 1 to suppress the "email" fields in the vCard editor, if we're editing a user's contact info.
  * Returns 0 to present those fields, if we're editing a vCard in an address book.
  */
-int conditional_VC_SuppressEmailFields(StrBuf *Target, WCTemplputParams *TP)
-{      
-       return(atoi(bstr("suppress_email")));
+int conditional_VC_SuppressEmailFields(StrBuf * Target, WCTemplputParams * TP) {
+       return (atoi(bstr("suppress_email")));
 }
 
 
@@ -403,20 +377,18 @@ int conditional_VC_SuppressEmailFields(StrBuf *Target, WCTemplputParams *TP)
  *              parse one VCard                                               *
  ******************************************************************************/
 
-void PutVcardItem(HashList *thisVC, vcField *thisField, StrBuf *ThisFieldStr, int is_qp, StrBuf *Swap)
-{
+void PutVcardItem(HashList * thisVC, vcField * thisField, StrBuf * ThisFieldStr, int is_qp, StrBuf * Swap) {
        /* if we have some untagged QP, detect it here. */
-       if (is_qp || (strstr(ChrPtr(ThisFieldStr), "=?")!=NULL)){
+       if (is_qp || (strstr(ChrPtr(ThisFieldStr), "=?") != NULL)) {
                FlushStrBuf(Swap);
-               StrBuf_RFC822_to_Utf8(Swap, ThisFieldStr, NULL, NULL); /* default charset, current charset */
+               StrBuf_RFC822_to_Utf8(Swap, ThisFieldStr, NULL, NULL);  /* default charset, current charset */
                SwapBuffers(Swap, ThisFieldStr);
                FlushStrBuf(Swap);
        }
        Put(thisVC, LKEY(thisField->cval), ThisFieldStr, HFreeStrBuf);
 }
 
-void parse_vcard(StrBuf *Target, struct vCard *v, HashList *VC, wc_mime_attachment *Mime)
-{
+void parse_vcard(StrBuf * Target, struct vCard *v, HashList * VC, wc_mime_attachment * Mime) {
        StrBuf *Swap = NULL;
        int i, j, k;
        char buf[SIZ];
@@ -428,20 +400,20 @@ void parse_vcard(StrBuf *Target, struct vCard *v, HashList *VC, wc_mime_attachme
        StrBuf *thisVCToken;
        void *vField = NULL;
 
-       Swap = NewStrBuf ();
+       Swap = NewStrBuf();
        thisname = NewStrBuf();
        thisVCToken = NewStrBufPlain(NULL, 63);
-       for (i=0; i<(v->numprops); ++i) {
+       for (i = 0; i < (v->numprops); ++i) {
                FlushStrBuf(thisVCToken);
                is_qp = 0;
                is_b64 = 0;
                // syslog(LOG_DEBUG, "i: %d oneprop: %s - value: %s", i, v->prop[i].name, v->prop[i].value);
                StrBufPlain(thisname, v->prop[i].name, -1);
                StrBufLowerCase(thisname);
-               
+
                extract_token(firsttoken, ChrPtr(thisname), 0, ';', sizeof firsttoken);
                ntokens = num_tokens(ChrPtr(thisname), ';');
-               for (j=0, k=0; j < ntokens && k < 10; ++j) {
+               for (j = 0, k = 0; j < ntokens && k < 10; ++j) {
                        len = extract_token(buf, ChrPtr(thisname), j, ';', sizeof buf);
                        if (!strcasecmp(buf, "encoding=quoted-printable")) {
                                is_qp = 1;
@@ -457,28 +429,26 @@ void parse_vcard(StrBuf *Target, struct vCard *v, HashList *VC, wc_mime_attachme
                        }
                }
 
-               vField = NULL;  
-               if ((StrLength(thisVCToken) > 0) &&
-                   GetHash(VCTokenToDefine, SKEY(thisVCToken), &vField) && 
-                   (vField != NULL)) {
-                       vcField *thisField = (vcField *)vField;
+               vField = NULL;
+               if ((StrLength(thisVCToken) > 0) && GetHash(VCTokenToDefine, SKEY(thisVCToken), &vField) && (vField != NULL)) {
+                       vcField *thisField = (vcField *) vField;
                        StrBuf *ThisFieldStr = NULL;
                        // syslog(LOG_DEBUG, "got this token: %s, found: %s", ChrPtr(thisVCToken), thisField->STR.Key);
                        switch (thisField->Type) {
-                       case StringCluster: {
-                               int j = 0;
-                               const char *Pos = NULL;
-                               StrBuf *thisArray = NewStrBufPlain(v->prop[i].value, -1);
-                               StrBuf *Buf = NewStrBufPlain(NULL, StrLength(thisArray));
-                               while (thisField->Sub[j].STR.len > 0) {
-                                       StrBufExtract_NextToken(Buf, thisArray, &Pos, ';');
-                                       ThisFieldStr = NewStrBufDup(Buf);
-                                       PutVcardItem(VC, &thisField->Sub[j], ThisFieldStr, is_qp, Swap);
-                                       j++;
+                       case StringCluster:{
+                                       int j = 0;
+                                       const char *Pos = NULL;
+                                       StrBuf *thisArray = NewStrBufPlain(v->prop[i].value, -1);
+                                       StrBuf *Buf = NewStrBufPlain(NULL, StrLength(thisArray));
+                                       while (thisField->Sub[j].STR.len > 0) {
+                                               StrBufExtract_NextToken(Buf, thisArray, &Pos, ';');
+                                               ThisFieldStr = NewStrBufDup(Buf);
+                                               PutVcardItem(VC, &thisField->Sub[j], ThisFieldStr, is_qp, Swap);
+                                               j++;
+                                       }
+                                       FreeStrBuf(&thisArray);
+                                       FreeStrBuf(&Buf);
                                }
-                               FreeStrBuf(&thisArray);
-                               FreeStrBuf(&Buf);
-                       }
                                break;
                        case Address:
                        case FlatString:
@@ -508,7 +478,7 @@ void parse_vcard(StrBuf *Target, struct vCard *v, HashList *VC, wc_mime_attachme
                        void *pv = NULL;
                        StrBuf *oldVal;
                        GetHash(VC, IKEY(vcfUnknown->cval), &pv);
-                       oldVal = (StrBuf*) pv;
+                       oldVal = (StrBuf *) pv;
                        if (oldVal == NULL) {
                                oldVal = NewStrBuf();
                                Put(VC, IKEY(vcfUnknown->cval), oldVal, HFreeStrBuf);
@@ -528,8 +498,7 @@ void parse_vcard(StrBuf *Target, struct vCard *v, HashList *VC, wc_mime_attachme
        FreeStrBuf(&thisVCToken);
 }
 
-HashList *CtxGetVcardList(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *CtxGetVcardList(StrBuf * Target, WCTemplputParams * TP) {
        HashList *pb = CTX(CTX_VCARD_LIST);
        return pb;
 }
@@ -538,8 +507,7 @@ HashList *CtxGetVcardList(StrBuf *Target, WCTemplputParams *TP)
  * Extract an embedded photo from a vCard for display on the client           *
  ******************************************************************************/
 
-void display_vcard_photo_img(void)
-{
+void display_vcard_photo_img(void) {
        long msgnum = 0L;
        StrBuf *vcard;
        struct vCard *v;
@@ -547,17 +515,17 @@ void display_vcard_photo_img(void)
        const char *contentType;
 
        msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
-       
-       vcard = load_mimepart(msgnum,"1");
+
+       vcard = load_mimepart(msgnum, "1");
        v = VCardLoad(vcard);
-       
-       photosrc = vcard_get_prop(v, "PHOTO", 1,0,0);
+
+       photosrc = vcard_get_prop(v, "PHOTO", 1, 0, 0);
        FlushStrBuf(WC->WBuf);
        StrBufAppendBufPlain(WC->WBuf, photosrc, -1, 0);
        if (StrBufDecodeBase64(WC->WBuf) <= 0) {
                FlushStrBuf(WC->WBuf);
-               
-               hprintf("HTTP/1.1 500 %s\n","Unable to get photo");
+
+               hprintf("HTTP/1.1 500 %s\n", "Unable to get photo");
                output_headers(0, 0, 0, 0, 0, 0);
                hprintf("Content-Type: text/plain\r\n");
                begin_burst();
@@ -571,9 +539,8 @@ void display_vcard_photo_img(void)
        free(photosrc);
 }
 
-wc_mime_attachment *load_vcard(message_summary *Msg) 
-{
-       HashPos  *it;
+wc_mime_attachment *load_vcard(message_summary * Msg) {
+       HashPos *it;
        StrBuf *FoundCharset = NewStrBuf();
        StrBuf *Error;
        void *vMime;
@@ -582,7 +549,7 @@ wc_mime_attachment *load_vcard(message_summary *Msg)
        wc_mime_attachment *Mime;
        wc_mime_attachment *VCMime = NULL;
 
-       Msg->MsgBody =  (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
+       Msg->MsgBody = (wc_mime_attachment *) malloc(sizeof(wc_mime_attachment));
        memset(Msg->MsgBody, 0, sizeof(wc_mime_attachment));
        Msg->MsgBody->msgnum = Msg->msgnum;
 
@@ -591,15 +558,10 @@ wc_mime_attachment *load_vcard(message_summary *Msg)
        FreeStrBuf(&FoundCharset);
        /* look up the vcard... */
        it = GetNewHashPos(Msg->AllAttach, 0);
-       while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) && 
-              (vMime != NULL)) 
-       {
-               Mime = (wc_mime_attachment*) vMime;
+       while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) && (vMime != NULL)) {
+               Mime = (wc_mime_attachment *) vMime;
                if ((strcmp(ChrPtr(Mime->ContentType),
-                          "text/x-vcard") == 0) ||
-                   (strcmp(ChrPtr(Mime->ContentType),
-                           "text/vcard") == 0))
-               {
+                           "text/x-vcard") == 0) || (strcmp(ChrPtr(Mime->ContentType), "text/vcard") == 0)) {
                        VCMime = Mime;
                        break;
                }
@@ -619,11 +581,8 @@ wc_mime_attachment *load_vcard(message_summary *Msg)
  * and MIME part number to fetch.  Or, specify -1 for the message number
  * to start with a blank card.
  */
-void do_edit_vcard(long msgnum, char *partnum, 
-                  message_summary *VCMsg,
-                  wc_mime_attachment *VCAtt,
-                  const char *return_to, 
-                  const char *force_room) {
+void do_edit_vcard(long msgnum, char *partnum,
+                  message_summary * VCMsg, wc_mime_attachment * VCAtt, const char *return_to, const char *force_room) {
        WCTemplputParams SubTP;
        message_summary *Msg = NULL;
        wc_mime_attachment *VCMime = NULL;
@@ -638,9 +597,7 @@ void do_edit_vcard(long msgnum, char *partnum,
 
        safestrncpy(whatuser, "", sizeof whatuser);
 
-       if ((msgnum >= 0) || 
-           ((VCMsg != NULL) && (VCAtt != NULL)))
-       {
+       if ((msgnum >= 0) || ((VCMsg != NULL) && (VCAtt != NULL))) {
                if ((VCMsg == NULL) && (VCAtt == NULL)) {
 
                        Msg = (message_summary *) malloc(sizeof(message_summary));
@@ -648,12 +605,12 @@ void do_edit_vcard(long msgnum, char *partnum,
                        Msg->msgnum = msgnum;
                        VCMime = load_vcard(Msg);
                        if (VCMime == NULL) {
-                               convenience_page("770000", _("Error"), "");/*TODO: important message*/
+                               convenience_page("770000", _("Error"), "");     /*TODO: important message */
                                DestroyMessageSummary(Msg);
                                return;
                                DeleteHash(&ab.VC);
                        }
-               
+
                        v = VCardLoad(VCMime->Data);
                }
                else {
@@ -661,12 +618,12 @@ void do_edit_vcard(long msgnum, char *partnum,
                }
 
                parse_vcard(WC->WBuf, v, ab.VC, NULL);
-       
-       
+
+
                vcard_free(v);
        }
 
-        memset(&SubTP, 0, sizeof(WCTemplputParams));    
+       memset(&SubTP, 0, sizeof(WCTemplputParams));
        {
                WCTemplputParams *TP = NULL;
                WCTemplputParams SubTP;
@@ -706,7 +663,7 @@ void submit_vcard(void) {
        char *serialized_vcard;
        StrBuf *Buf;
        const StrBuf *ForceRoom;
-       HashListpostVcard;
+       HashList *postVcard;
        HashPos *it, *itSub;
        const char *Key;
        long len;
@@ -715,7 +672,7 @@ void submit_vcard(void) {
        const StrBuf *s;
        const char *Pos = NULL;
 
-       if (!havebstr("ok_button")) { 
+       if (!havebstr("ok_button")) {
                readloop(readnew, eUseDefault);
                return;
        }
@@ -749,21 +706,19 @@ void submit_vcard(void) {
        if (postVcard == NULL) {
                AppendImportantMessage(_("An error has occurred."), -1);
                edit_vcard();
-               return;/*/// more details*/
+               return;         /*/// more details */
        }
-       
+
        Buf = NewStrBuf();
        serv_write(HKEY("ENT0 1|||4\n"));
-       if (!StrBuf_ServGetln(Buf) && (GetServerStatus(Buf, NULL) != 4))
-       {
+       if (!StrBuf_ServGetln(Buf) && (GetServerStatus(Buf, NULL) != 4)) {
                edit_vcard();
                return;
        }
-       
+
        /* Make a vCard structure out of the data supplied in the form */
-       StrBufPrintf(Buf, "begin:vcard\r\n%s\r\nend:vcard\r\n",
-                    bstr("extrafields")
-       );
+       StrBufPrintf(Buf, "begin:vcard\r\n%s\r\nend:vcard\r\n", bstr("extrafields")
+           );
        v = VCardLoad(Buf);     /* Start with the extra fields */
        if (v == NULL) {
                AppendImportantMessage(_("An error has occurred."), -1);
@@ -774,21 +729,17 @@ void submit_vcard(void) {
 
        SubStr = NewStrBuf();
        it = GetNewHashPos(DefineToToken, 0);
-       while (GetNextHashPos(DefineToToken, it, &len, &Key, &pv) && 
-              (pv != NULL)) 
-       {
+       while (GetNextHashPos(DefineToToken, it, &len, &Key, &pv) && (pv != NULL)) {
                char buf[32];
                long blen;
-               vcField *t = (vcField*) pv;
+               vcField *t = (vcField *) pv;
 
-               if (t->Sub != NULL){
+               if (t->Sub != NULL) {
                        vcField *Sub;
                        FlushStrBuf(SubStr);
                        itSub = GetNewHashPos(DefineToToken, 0);
-                       while (GetNextHashPos(DefineToToken, itSub, &len, &Key, &pv) && 
-                              (pv != NULL)) 
-                       {
-                               Sub = (vcField*) pv;
+                       while (GetNextHashPos(DefineToToken, itSub, &len, &Key, &pv) && (pv != NULL)) {
+                               Sub = (vcField *) pv;
                                if (Sub->parentCVal == t->cval) {
                                        if (StrLength(SubStr) > 0)
                                                StrBufAppendBufPlain(SubStr, HKEY(";"), 0);
@@ -797,7 +748,7 @@ void submit_vcard(void) {
 
                                        blen = snprintf(buf, sizeof(buf), "%ld", Sub->cval);
                                        s = SSubBstr(postVcard, buf, blen);
-                       
+
                                        if ((s != NULL) && (StrLength(s) > 0)) {
                                                /// todo: utf8 qp
                                                StrBufAppendBuf(SubStr, s, 0);
@@ -812,7 +763,7 @@ void submit_vcard(void) {
                else if (t->parentCVal == 0) {
                        blen = snprintf(buf, sizeof(buf), "%ld", t->cval);
                        s = SSubBstr(postVcard, buf, blen);
-                       
+
                        if ((s != NULL) && (StrLength(s) > 0)) {
                                vcard_add_prop(v, t->STR.Key, ChrPtr(s));
                        }
@@ -823,7 +774,7 @@ void submit_vcard(void) {
        s = sbstr("other_inetemail");
        if (StrLength(s) > 0) {
                FlushStrBuf(SubStr);
-               while (StrBufSipLine(SubStr, s, &Pos), ((Pos!=StrBufNOTNULL) && (Pos!=NULL)) ) {
+               while (StrBufSipLine(SubStr, s, &Pos), ((Pos != StrBufNOTNULL) && (Pos != NULL))) {
                        if (StrLength(SubStr) > 0) {
                                vcard_add_prop(v, "email;internet", ChrPtr(SubStr));
                        }
@@ -874,19 +825,13 @@ typedef struct _vcardview_struct {
 
 } vcardview_struct;
 
-int vcard_GetParamsGetServerCall(SharedMessageStatus *Stat, 
-                                void **ViewSpecific, 
-                                long oper, 
-                                char *cmd, 
-                                long len,
-                                char *filter,
-                                long flen)
-{
+int vcard_GetParamsGetServerCall(SharedMessageStatus * Stat,
+                                void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen) {
        vcardview_struct *VS;
 
-       VS = (vcardview_struct*) malloc (sizeof(vcardview_struct));
+       VS = (vcardview_struct *) malloc(sizeof(vcardview_struct));
        memset(VS, 0, sizeof(vcardview_struct));
-       *ViewSpecific = (void*)VS;
+       *ViewSpecific = (void *) VS;
 
        VS->is_singlecard = ibstr("is_singlecard");
        if (VS->is_singlecard != 1) {
@@ -902,20 +847,15 @@ int vcard_GetParamsGetServerCall(SharedMessageStatus *Stat,
        return 200;
 }
 
-int vcard_LoadMsgFromServer(SharedMessageStatus *Stat, 
-                           void **ViewSpecific, 
-                           message_summary* Msg, 
-                           int is_new, 
-                           int i)
-{
+int vcard_LoadMsgFromServer(SharedMessageStatus * Stat, void **ViewSpecific, message_summary * Msg, int is_new, int i) {
        WCTemplputParams *TP = NULL;
        WCTemplputParams SubTP;
        vcardview_struct *VS;
        wc_mime_attachment *VCMime = NULL;
        struct vCard *v;
-       addrbookentabEntry;
+       addrbookent *abEntry;
 
-       VS = (vcardview_struct*) *ViewSpecific;
+       VS = (vcardview_struct *) * ViewSpecific;
 
        VCMime = load_vcard(Msg);
        if (VCMime == NULL)
@@ -923,9 +863,10 @@ int vcard_LoadMsgFromServer(SharedMessageStatus *Stat,
 
        v = VCardLoad(VCMime->Data);
 
-       if (v == NULL) return 0;
+       if (v == NULL)
+               return 0;
 
-       abEntry = (addrbookent*) malloc(sizeof(addrbookent));
+       abEntry = (addrbookent *) malloc(sizeof(addrbookent));
        memset(abEntry, 0, sizeof(addrbookent));
        abEntry->name = NewStrBuf();
        abEntry->VC = NewHash(0, lFlathash);
@@ -933,7 +874,7 @@ int vcard_LoadMsgFromServer(SharedMessageStatus *Stat,
 
        parse_vcard(WC->WBuf, v, abEntry->VC, VCMime);
 
-        memset(&SubTP, 0, sizeof(WCTemplputParams));    
+       memset(&SubTP, 0, sizeof(WCTemplputParams));
        StackContext(TP, &SubTP, abEntry, CTX_VCARD, 0, NULL);
 
        // No, don't display the name, it just shits all over the screen
@@ -948,7 +889,7 @@ int vcard_LoadMsgFromServer(SharedMessageStatus *Stat,
        syslog(LOG_DEBUG, "abEntry->name : %s", ChrPtr(abEntry->name));
 
        vcard_free(v);
-       
+
        Put(VS->addrbook, SKEY(abEntry->name), abEntry, deleteAbEnt);
        return 0;
 }
@@ -961,7 +902,7 @@ int vcard_LoadMsgFromServer(SharedMessageStatus *Stat,
  * num_ab      the number of the addressbook
  */
 static int NAMESPERPAGE = 60;
-void do_addrbook_view(vcardview_struct* VS) {
+void do_addrbook_view(vcardview_struct * VS) {
        long i = 0;
        int num_pages = 0;
        int tabfirst = 0;
@@ -973,8 +914,8 @@ void do_addrbook_view(vcardview_struct* VS) {
        WCTemplputParams *TP = NULL;
        WCTemplputParams SubTP;
 
-        memset(&SubTP, 0, sizeof(WCTemplputParams));    
-       
+       memset(&SubTP, 0, sizeof(WCTemplputParams));
+
        if (num_ab == 0) {
                do_template("vcard_list_empty");
                return;
@@ -986,13 +927,13 @@ void do_addrbook_view(vcardview_struct* VS) {
 
        num_pages = (GetCount(VS->addrbook) / NAMESPERPAGE) + 1;
 
-       tablabels = malloc(num_pages * sizeof (StrBuf *));
+       tablabels = malloc(num_pages * sizeof(StrBuf *));
        if (tablabels == NULL) {
                return;
        }
 
        headlines = NewHash(0, lFlathash);
-       for (i=0; i<num_pages; ++i) {
+       for (i = 0; i < num_pages; ++i) {
                void *v1 = NULL;
                void *v2 = NULL;
                long hklen1, hklen2;
@@ -1002,16 +943,17 @@ void do_addrbook_view(vcardview_struct* VS) {
 
                tabfirst = i * NAMESPERPAGE;
                tablast = tabfirst + NAMESPERPAGE - 1;
-               if (tablast > (num_ab - 1)) tablast = (num_ab - 1);
+               if (tablast > (num_ab - 1))
+                       tablast = (num_ab - 1);
 
                headline = NewStrBufPlain(NULL, StrLength(v1) + StrLength(v2) + 10);
                if (GetHashAt(VS->addrbook, tabfirst, &hklen1, &c1, &v1)) {
-                       a1 = (addrbookent*) v1;
+                       a1 = (addrbookent *) v1;
                        StrBufAppendBuf(headline, a1->name, 0);
                        StrBuf_Utf8StrCut(headline, 3);
                        if (GetHashAt(VS->addrbook, tablast, &hklen2, &c2, &v2)) {
 
-                               a2 = (addrbookent*) v2;
+                               a2 = (addrbookent *) v2;
                                StrBufAppendBufPlain(headline, HKEY(" - "), 0);
                                StrBufAppendBuf(headline, a2->name, 0);
                                StrBuf_Utf8StrCut(headline, 9);
@@ -1027,17 +969,16 @@ void do_addrbook_view(vcardview_struct* VS) {
        UnStackContext(&SubTP);
        DeleteHash(&headlines);
        free(tablabels);
-       StrBufAppendBufPlain(WC->WBuf, HKEY("</div>"), 0);/* closes: id=global */
+       StrBufAppendBufPlain(WC->WBuf, HKEY("</div>"), 0);      /* closes: id=global */
 }
 
 
 
-int vcard_RenderView_or_Tail(SharedMessageStatus *Stat, void **ViewSpecific, long oper)
-{
+int vcard_RenderView_or_Tail(SharedMessageStatus * Stat, void **ViewSpecific, long oper) {
        const StrBuf *Mime;
        vcardview_struct *VS;
 
-       VS = (vcardview_struct*) *ViewSpecific;
+       VS = (vcardview_struct *) * ViewSpecific;
        if (VS->is_singlecard) {
                read_message(WC->WBuf, HKEY("view_message"), lbstr("startmsg"), NULL, &Mime, NULL);
        }
@@ -1047,24 +988,22 @@ int vcard_RenderView_or_Tail(SharedMessageStatus *Stat, void **ViewSpecific, lon
        return 0;
 }
 
-int vcard_Cleanup(void **ViewSpecific)
-{
+int vcard_Cleanup(void **ViewSpecific) {
        vcardview_struct *VS;
 
-       VS = (vcardview_struct*) *ViewSpecific;
+       VS = (vcardview_struct *) * ViewSpecific;
        wDumpContent(1);
        if ((VS != NULL) && (VS->addrbook != NULL)) {
                DeleteHash(&VS->addrbook);
        }
-       if (VS != NULL)  {
+       if (VS != NULL) {
                free(VS);
        }
 
        return 0;
 }
 
-void render_MIME_VCard(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
-{
+void render_MIME_VCard(StrBuf * Target, WCTemplputParams * TP, StrBuf * FoundCharset) {
        wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
        if (StrLength(Mime->Data) == 0) {
                MimeLoadData(Mime);
@@ -1074,14 +1013,14 @@ void render_MIME_VCard(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharse
                StrBuf *Buf;
 
                Buf = NewStrBuf();
+
                /** If it's my vCard I can edit it */
-               if (    (!strcasecmp(ChrPtr(WC->CurRoom.name), USERCONFIGROOM))
-                       || ((StrLength(WC->CurRoom.name) > 11) &&
-                           (!strcasecmp(&(ChrPtr(WC->CurRoom.name)[11]), USERCONFIGROOM)))
-                       || (WC->CurRoom.view == VIEW_ADDRESSBOOK)
-                       ) {
+               if ((!strcasecmp(ChrPtr(WC->CurRoom.name), USERCONFIGROOM))
+                   || ((StrLength(WC->CurRoom.name) > 11) && (!strcasecmp(&(ChrPtr(WC->CurRoom.name)[11]), USERCONFIGROOM)))
+                   || (WC->CurRoom.view == VIEW_ADDRESSBOOK)
+                   ) {
                        StrBufAppendPrintf(Buf, "<a href=\"edit_vcard?msgnum=%ld?partnum=%s\">",
-                               Mime->msgnum, ChrPtr(Mime->PartNum));
+                                          Mime->msgnum, ChrPtr(Mime->PartNum));
                        StrBufAppendPrintf(Buf, "[%s]</a>", _("edit"));
                }
 
@@ -1100,7 +1039,7 @@ void render_MIME_VCard(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharse
 
                        parse_vcard(Target, v, ab.VC, Mime);
 
-                       memset(&SubTP, 0, sizeof(WCTemplputParams));    
+                       memset(&SubTP, 0, sizeof(WCTemplputParams));
                        StackContext(TP, &SubTP, &ab, CTX_VCARD, 0, NULL);
 
                        DoTemplate(HKEY("vcard_msg_display"), Target, &SubTP);
@@ -1118,28 +1057,19 @@ void render_MIME_VCard(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharse
 
 }
 
-void 
-ServerStartModule_VCARD
-(void)
-{
+void ServerStartModule_VCARD(void) {
 }
 
-void 
-ServerShutdownModule_VCARD
-(void)
-{
+void ServerShutdownModule_VCARD(void) {
        DeleteHash(&DefineToToken);
        DeleteHash(&vcNames);
        DeleteHash(&VCTokenToDefine);
 }
 
-void 
-InitModule_VCARD
-(void)
-{
-       StrBuf *Prefix  = NewStrBufPlain(HKEY("VC:"));
-       DefineToToken   = NewHash(1, lFlathash);
-       vcNames         = NewHash(1, lFlathash);
+void InitModule_VCARD(void) {
+       StrBuf *Prefix = NewStrBufPlain(HKEY("VC:"));
+       DefineToToken = NewHash(1, lFlathash);
+       vcNames = NewHash(1, lFlathash);
        VCTokenToDefine = NewHash(1, NULL);
        autoRegisterTokens(&VCEnumCounter, VCStrE, Prefix, 0, 0);
        FreeStrBuf(&Prefix);
@@ -1151,16 +1081,9 @@ InitModule_VCARD
        RegisterCTX(CTX_VCARD_LIST);
        RegisterCTX(CTX_VCARD_TYPE);
 
-       RegisterReadLoopHandlerset(
-               VIEW_ADDRESSBOOK,
-               vcard_GetParamsGetServerCall,
-               NULL,
-               NULL,
-               NULL, 
-               vcard_LoadMsgFromServer,
-               vcard_RenderView_or_Tail,
-               vcard_Cleanup,
-               NULL);
+       RegisterReadLoopHandlerset(VIEW_ADDRESSBOOK,
+                                  vcard_GetParamsGetServerCall,
+                                  NULL, NULL, NULL, vcard_LoadMsgFromServer, vcard_RenderView_or_Tail, vcard_Cleanup, NULL);
 
        RegisterIterator("MAIL:VCARDS", 0, NULL, CtxGetVcardList, NULL, NULL, CTX_VCARD, CTX_VCARD_LIST, IT_NOFLAG);
 
@@ -1185,11 +1108,13 @@ InitModule_VCARD
        REGISTERTokenParamDefine(TerminateList);
        REGISTERTokenParamDefine(Address);
 
-       RegisterConditional("VC:HAVE:TYPE",                     1,      conditional_VC_Havetype, CTX_VCARD);
-       RegisterConditional("COND:VC:SUPPRESS_EMAIL_FIELDS",    1,      conditional_VC_SuppressEmailFields, CTX_VCARD);
+       RegisterConditional("VC:HAVE:TYPE", 1, conditional_VC_Havetype, CTX_VCARD);
+       RegisterConditional("COND:VC:SUPPRESS_EMAIL_FIELDS", 1, conditional_VC_SuppressEmailFields, CTX_VCARD);
 
-       RegisterFilteredIterator("VC:TYPE", 1, DefineToToken, NULL, NULL, NULL, filter_VC_ByType, CTX_VCARD_TYPE, CTX_VCARD, IT_NOFLAG);
-       RegisterFilteredIterator("VC:TYPE:ITEMS", 0, NULL, getContextVcard, NULL, NULL, filter_VC_ByContextType, CTX_STRBUF, CTX_VCARD_TYPE, IT_NOFLAG);
+       RegisterFilteredIterator("VC:TYPE", 1, DefineToToken, NULL, NULL, NULL, filter_VC_ByType, CTX_VCARD_TYPE, CTX_VCARD,
+                                IT_NOFLAG);
+       RegisterFilteredIterator("VC:TYPE:ITEMS", 0, NULL, getContextVcard, NULL, NULL, filter_VC_ByContextType, CTX_STRBUF,
+                                CTX_VCARD_TYPE, IT_NOFLAG);
 
        RegisterMimeRenderer(HKEY("text/x-vcard"), render_MIME_VCard, 1, 201);
        RegisterMimeRenderer(HKEY("text/vcard"), render_MIME_VCard, 1, 200);
index 7cc9768b9fc20de15dab0b656e59322a876dc3b8..59d5bc822936415a1f22d36b899a5a3515b0a868 100644 (file)
@@ -22,29 +22,23 @@ void stuff_to_cookie(int unset_cookie);
 extern int GetConnected(void);
 extern int verbose;
 
-void PutRequestLocalMem(void *Data, DeleteHashDataFunc DeleteIt)
-{
+void PutRequestLocalMem(void *Data, DeleteHashDataFunc DeleteIt) {
        int n;
-       
+
        n = GetCount(WC->Hdr->HTTPHeaders);
        Put(WC->Hdr->HTTPHeaders, IKEY(n), Data, DeleteIt);
 }
 
-void DeleteWebcitHandler(void *vHandler)
-{
-       WebcitHandler *Handler = (WebcitHandler*) vHandler;
+void DeleteWebcitHandler(void *vHandler) {
+       WebcitHandler *Handler = (WebcitHandler *) vHandler;
        FreeStrBuf(&Handler->Name);
        FreeStrBuf(&Handler->DisplayName);
-       free (Handler);
+       free(Handler);
 }
 
-void WebcitAddUrlHandler(const char * UrlString, long UrlSLen, 
-                        const char *DisplayName, long dslen,
-                        WebcitHandlerFunc F, 
-                        long Flags)
-{
-       WebcitHandler *NewHandler;      
-       NewHandler = (WebcitHandler*) malloc(sizeof(WebcitHandler));
+void WebcitAddUrlHandler(const char *UrlString, long UrlSLen, const char *DisplayName, long dslen, WebcitHandlerFunc F, long Flags) {
+       WebcitHandler *NewHandler;
+       NewHandler = (WebcitHandler *) malloc(sizeof(WebcitHandler));
        NewHandler->F = F;
        NewHandler->Flags = Flags;
        NewHandler->Name = NewStrBufPlain(UrlString, UrlSLen);
@@ -54,8 +48,7 @@ void WebcitAddUrlHandler(const char * UrlString, long UrlSLen,
        Put(HandlerHash, UrlString, UrlSLen, NewHandler, DeleteWebcitHandler);
 }
 
-void tmplput_HANDLER_DISPLAYNAME(StrBuf *Target, WCTemplputParams *TP) 
-{
+void tmplput_HANDLER_DISPLAYNAME(StrBuf * Target, WCTemplputParams * TP) {
        if (WC->Hdr->HR.Handler != NULL)
                StrBufAppendTemplate(Target, TP, WC->Hdr->HR.Handler->DisplayName, 0);
 }
@@ -65,9 +58,9 @@ void tmplput_HANDLER_DISPLAYNAME(StrBuf *Target, WCTemplputParams *TP)
  * web-printing funcion. uses our vsnprintf wrapper
  */
 #ifdef UBER_VERBOSE_DEBUGGING
-void wcc_printf(const char *FILE, const char *FUNCTION, long LINE, const char *format,...)
+void wcc_printf(const char *FILE, const char *FUNCTION, long LINE, const char *format, ...)
 #else
-void wc_printf(const char *format,...)
+void wc_printf(const char *format, ...)
 #endif
 {
        va_list arg_ptr;
@@ -89,8 +82,7 @@ void wc_printf(const char *format,...)
 /*
  * http-header-printing funcion. uses our vsnprintf wrapper
  */
-void hprintf(const char *format,...)
-{
+void hprintf(const char *format, ...) {
        va_list arg_ptr;
 
        va_start(arg_ptr, format);
@@ -107,8 +99,7 @@ void hprintf(const char *format,...)
  * 0           - to transmit only,
  * nonzero     - to append the closing tags
  */
-void wDumpContent(int print_standard_html_footer)
-{
+void wDumpContent(int print_standard_html_footer) {
        if (print_standard_html_footer) {
                wc_printf("</div> <!-- end of 'content' div -->\n");
                do_template("trailing");
@@ -121,21 +112,21 @@ 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                        */
-                       int do_htmlhead,        /* 1 = output HTML <head> section and <body> opener */
-                       int do_room_banner,     /* 1 = include the room banner and <div id="content"></div> */
-                       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      */
-) {
+void output_headers(int do_httpheaders,        /* 1 = output HTTP headers                        */
+                   int do_htmlhead,    /* 1 = output HTML <head> section and <body> opener */
+                   int do_room_banner, /* 1 = include the room banner and <div id="content"></div> */
+                   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      */
+    ) {
        char httpnow[128];
 
-       if (WC->isFailure) 
+       if (WC->isFailure)
                hprintf("HTTP/2.2 500 Internal Server Error");
        else if (WC->Hdr->HaveRange > 1)
                hprintf("HTTP/1.1 206 Partial Content\r\n");
@@ -147,44 +138,32 @@ void output_headers(      int do_httpheaders,     /* 1 = output HTTP headers                        */
        if (do_httpheaders) {
                if (WC->serv_info != NULL)
                        hprintf("Content-type: text/html; charset=utf-8\r\n"
-                               "Server: %s / %s\n"
-                               "Connection: close\r\n",
-                               PACKAGE_STRING, 
-                               ChrPtr(WC->serv_info->serv_software));
+                               "Server: %s / %s\n" "Connection: close\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
                else
                        hprintf("Content-type: text/html; charset=utf-8\r\n"
-                               "Server: %s / [n/a]\n"
-                               "Connection: close\r\n",
-                               PACKAGE_STRING);
+                               "Server: %s / [n/a]\n" "Connection: close\r\n", PACKAGE_STRING);
        }
 
        if (cache > 0) {
                char httpTomorow[128];
 
-               http_datestring(httpTomorow, sizeof httpTomorow, 
-                               time(NULL) + 60 * 60 * 24 * 2);
+               http_datestring(httpTomorow, sizeof httpTomorow, time(NULL) + 60 * 60 * 24 * 2);
 
                hprintf("Pragma: public\r\n"
                        "Cache-Control: max-age=3600, must-revalidate\r\n"
-                       "Last-modified: %s\r\n"
-                       "Expires: %s\r\n",
-                       httpnow,
-                       httpTomorow
-               );
+                       "Last-modified: %s\r\n" "Expires: %s\r\n", httpnow, httpTomorow);
        }
        else {
-               hprintf("Pragma: no-cache\r\n"
-                       "Cache-Control: no-store\r\n"
-                       "Expires: -1\r\n"
-               );
+               hprintf("Pragma: no-cache\r\n" "Cache-Control: no-store\r\n" "Expires: -1\r\n");
        }
 
-       if (cache < 2) stuff_to_cookie(unset_cookies);
+       if (cache < 2)
+               stuff_to_cookie(unset_cookies);
 
        if (do_htmlhead) {
                begin_burst();
                do_template("head");
-               if ( (WC->logged_in) && (!unset_cookies) ) {
+               if ((WC->logged_in) && (!unset_cookies)) {
                        DoTemplate(HKEY("paging"), NULL, &NoCtx);
                }
                if (do_room_banner) {
@@ -199,7 +178,7 @@ void output_headers(        int do_httpheaders,     /* 1 = output HTTP headers                        */
 
 void output_custom_content_header(const char *ctype) {
        hprintf("HTTP/1.1 200 OK\r\n");
-       hprintf("Content-type: %s; charset=utf-8\r\n",ctype);
+       hprintf("Content-type: %s; charset=utf-8\r\n", ctype);
        hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
        hprintf("Connection: close\r\n");
 }
@@ -231,23 +210,17 @@ void http_redirect(const char *whichpage) {
  * bunch of headers to the client.  end_burst() will add some headers of its own, and then
  * transmit the buffered content to the client.
  */
-void http_transmit_thing(const char *content_type, int is_static)
-{
+void http_transmit_thing(const char *content_type, int is_static) {
        if (verbose)
                syslog(LOG_DEBUG, "http_transmit_thing(%s)%s", content_type, ((is_static > 0) ? " (static)" : ""));
        output_headers(0, 0, 0, 0, 0, is_static);
 
-       hprintf("Content-type: %s\r\n"
-               "Server: %s\r\n"
-               "Connection: close\r\n",
-               content_type,
-               PACKAGE_STRING);
+       hprintf("Content-type: %s\r\n" "Server: %s\r\n" "Connection: close\r\n", content_type, PACKAGE_STRING);
 
        end_burst();
 }
 
-void http_transmit_headers(const char *content_type, int is_static, long is_chunked, int is_gzip)
-{
+void http_transmit_headers(const char *content_type, int is_static, long is_chunked, int is_gzip) {
        if (verbose)
                syslog(LOG_DEBUG, "http_transmit_thing(%s)%s", content_type, ((is_static > 0) ? " (static)" : ""));
        output_headers(0, 0, 0, 0, 0, is_static);
@@ -257,17 +230,11 @@ void http_transmit_headers(const char *content_type, int is_static, long is_chun
 
        if (WC->Hdr->HaveRange)
                hprintf("Accept-Ranges: bytes\r\n"
-                       "Content-Range: bytes %ld-%ld/%ld\r\n",
-                       WC->Hdr->RangeStart,
-                       WC->Hdr->RangeTil,
-                       WC->Hdr->TotalBytes);
+                       "Content-Range: bytes %ld-%ld/%ld\r\n", WC->Hdr->RangeStart, WC->Hdr->RangeTil, WC->Hdr->TotalBytes);
 
        hprintf("Content-type: %s\r\n"
-               "Server: "PACKAGE_STRING"\r\n"
-               "%s"
-               "Connection: close\r\n\r\n",
-               content_type,
-               (is_chunked)?"Transfer-Encoding: chunked\r\n":"");
+               "Server: " PACKAGE_STRING "\r\n"
+               "%s" "Connection: close\r\n\r\n", content_type, (is_chunked) ? "Transfer-Encoding: chunked\r\n" : "");
 }
 
 
@@ -278,8 +245,7 @@ void http_transmit_headers(const char *content_type, int is_static, long is_chun
  * titlebarmsg         text to display in the title bar
  * messagetext         body of the box
  */
-void convenience_page(const char *titlebarcolor, const char *titlebarmsg, const char *messagetext)
-{
+void convenience_page(const char *titlebarcolor, const char *titlebarmsg, const char *messagetext) {
        hprintf("HTTP/1.1 200 OK\n");
        output_headers(1, 1, 1, 0, 0, 0);
        wc_printf("<div id=\"room_banner_override\">\n");
@@ -318,8 +284,7 @@ void url_do_template(void) {
 /*
  * convenience function to indicate success
  */
-void display_success(const char *successmessage)
-{
+void display_success(const char *successmessage) {
        convenience_page("007700", "OK", successmessage);
 }
 
@@ -327,16 +292,12 @@ void display_success(const char *successmessage)
 /*
  * Authorization required page (sends a 401, causing the browser to request login credentials)
  */
-void authorization_required(void)
-{
+void authorization_required(void) {
        const char *message = "";
 
        hprintf("HTTP/1.1 401 Authorization Required\r\n");
-       hprintf(
-               "Server: %s / %s\r\n"
-               "Connection: close\r\n",
-               PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
-       );
+       hprintf("Server: %s / %s\r\n" "Connection: close\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
+           );
        hprintf("WWW-Authenticate: Basic realm=\"%s\"\r\n", ChrPtr(WC->serv_info->serv_humannode));
 
        /* if this is a false cookie authentication, remove it to avoid endless loops. */
@@ -353,11 +314,8 @@ void authorization_required(void)
                message = ChrPtr(WC->ImportantMsg);
        }
 
-       wc_printf(
-               _("The resource you requested requires a valid username and password. "
-               "You could not be logged in: %s\n"),
-               message
-       );
+       wc_printf(_("The resource you requested requires a valid username and password. "
+                   "You could not be logged in: %s\n"), message);
        wDumpContent(0);
 }
 
@@ -370,11 +328,7 @@ void begin_ajax_response(void) {
        FlushStrBuf(WC->HBuf);
        output_headers(0, 0, 0, 0, 0, 0);
 
-       hprintf("Content-type: text/html; charset=UTF-8\r\n"
-               "Server: %s\r\n"
-               "Connection: close\r\n"
-               ,
-               PACKAGE_STRING);
+       hprintf("Content-type: text/html; charset=UTF-8\r\n" "Server: %s\r\n" "Connection: close\r\n", PACKAGE_STRING);
        begin_burst();
 }
 
@@ -397,7 +351,7 @@ void ajax_servcmd(void) {
        size_t len;
 
        if (verbose) {
-               syslog(LOG_DEBUG, "ajax_servcmd() g_cmd=\"%s\"", bstr("g_cmd") );
+               syslog(LOG_DEBUG, "ajax_servcmd() g_cmd=\"%s\"", bstr("g_cmd"));
        }
        begin_ajax_response();
        Buf = NewStrBuf();
@@ -405,12 +359,11 @@ void ajax_servcmd(void) {
        StrBuf_ServGetln(Buf);
        StrBufAppendBuf(WC->WBuf, Buf, 0);
        StrBufAppendBufPlain(WC->WBuf, HKEY("\n"), 0);
-       
+
        switch (GetServerStatus(Buf, NULL)) {
        case 8:
                serv_puts("\n\n000");
-               if ( (StrLength(Buf)==3) && 
-                    !strcmp(ChrPtr(Buf), "000")) {
+               if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
                        StrBufAppendBufPlain(WC->WBuf, HKEY("\000"), 0);
                        break;
                }
@@ -418,8 +371,7 @@ void ajax_servcmd(void) {
                while (!Done) {
                        if (StrBuf_ServGetln(Buf) < 0)
                                break;
-                       if ( (StrLength(Buf)==3) && 
-                            !strcmp(ChrPtr(Buf), "000")) {
+                       if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
                                Done = 1;
                        }
                        StrBufAppendBuf(WC->WBuf, Buf, 0);
@@ -441,9 +393,9 @@ void ajax_servcmd(void) {
                serv_write(junk, len);
                free(junk);
        }
-       
+
        end_ajax_response();
-       
+
        /*
         * This is kind of an ugly hack, but this is the only place it can go.
         * If the command was GEXP, then the instant messenger window must be
@@ -461,11 +413,10 @@ void ajax_servcmd(void) {
  * Helper function for the asynchronous check to see if we need
  * to open the instant messenger window.
  */
-void seconds_since_last_gexp(void)
-{
+void seconds_since_last_gexp(void) {
        char buf[256];
 
-       if ( (time(NULL) - WC->last_pager_check) < 30) {
+       if ((time(NULL) - WC->last_pager_check) < 30) {
                wc_printf("NO\n");
        }
        else {
@@ -523,7 +474,7 @@ void pop_destination(void) {
         * Do something reasonable if we somehow ended up requesting a pop without
         * having first done a push.
         */
-       if ( (!WC) || (WC->PushedDestination == NULL) || (StrLength(WC->PushedDestination) == 0) ) {
+       if ((!WC) || (WC->PushedDestination == NULL) || (StrLength(WC->PushedDestination) == 0)) {
                do_welcome();
                return;
        }
@@ -542,18 +493,15 @@ int ReadPostData(void) {
        int rc;
        int urlencoded_post = 0;
        StrBuf *content = NULL;
-       
-       urlencoded_post = (strncasecmp(ChrPtr(WC->Hdr->HR.ContentType), "application/x-www-form-urlencoded", 33) == 0) ;
+
+       urlencoded_post = (strncasecmp(ChrPtr(WC->Hdr->HR.ContentType), "application/x-www-form-urlencoded", 33) == 0);
 
        content = NewStrBufPlain(NULL, WC->Hdr->HR.ContentLength + 256);
 
        if (!urlencoded_post) {
-               StrBufPrintf(content, 
-                       "Content-type: %s\n"
-                       "Content-length: %ld\n\n",
-                       ChrPtr(WC->Hdr->HR.ContentType), 
-                       WC->Hdr->HR.ContentLength
-               );
+               StrBufPrintf(content,
+                            "Content-type: %s\n"
+                            "Content-length: %ld\n\n", ChrPtr(WC->Hdr->HR.ContentType), WC->Hdr->HR.ContentLength);
        }
 
        /* Read the entire input data at once. */
@@ -561,7 +509,7 @@ int ReadPostData(void) {
        if (rc < 0) {
                return rc;
        }
-       
+
        if (urlencoded_post) {
                ParseURLParams(content);
        }
@@ -586,22 +534,21 @@ int ReadPostData(void) {
 }
 
 
-int Conditional_REST_DEPTH(StrBuf *Target, WCTemplputParams *TP)
-{
+int Conditional_REST_DEPTH(StrBuf * Target, WCTemplputParams * TP) {
        long Depth, IsDepth;
        long offset = 0;
 
        if (WC->Hdr->HR.Handler != NULL)
-               offset ++;
+               offset++;
        Depth = GetTemplateTokenNumber(Target, TP, 2, 0);
        IsDepth = GetCount(WC->Directory) + offset;
 
-//     LogTemplateError(Target, "bla", 1, TP, "REST_DEPTH: %ld : %ld\n", Depth, IsDepth);
+//      LogTemplateError(Target, "bla", 1, TP, "REST_DEPTH: %ld : %ld\n", Depth, IsDepth);
        if (Depth < 0) {
                Depth = -Depth;
                return IsDepth > Depth;
        }
-       else 
+       else
                return Depth == IsDepth;
 }
 
@@ -610,11 +557,10 @@ int Conditional_REST_DEPTH(StrBuf *Target, WCTemplputParams *TP)
 /*
  * Entry point for WebCit transaction
  */
-void session_loop(void)
-{
+void session_loop(void) {
        int xhttp;
        StrBuf *Buf;
-       
+
        /*
         * We stuff these with the values coming from the client cookies,
         * so we can use them to reconnect a timed out session if we have to.
@@ -671,14 +617,12 @@ void session_loop(void)
                        begin_burst();
                        wc_printf("<html><head><title>503 Service Unavailable</title></head><body>\n");
                        wc_printf(_("This program was unable to connect or stay "
-                               "connected to the Citadel server.  Please report "
-                               "this problem to your system administrator.")
-                       );
+                                   "connected to the Citadel server.  Please report " "this problem to your system administrator.")
+                           );
                        wc_printf("<br>");
                        wc_printf("<a href=\"http://www.citadel.org/doku.php/"
-                               "faq:generalquestions:webcit_unable_to_connect\">%s</a>",
-                               _("Read More...")
-                       );
+                                 "faq:generalquestions:webcit_unable_to_connect\">%s</a>", _("Read More...")
+                           );
                        wc_printf("</body></html>\n");
                        end_burst();
                        goto SKIP_ALL_THIS_CRAP;
@@ -689,10 +633,10 @@ void session_loop(void)
         * If we're not logged in, but we have authentication data (either from
         * a cookie or from http-auth), try logging in to Citadel using that.
         */
-       if (    (!WC->logged_in)
-               && (StrLength(WC->Hdr->c_username) > 0)
-               && (StrLength(WC->Hdr->c_password) > 0)
-       ) {
+       if ((!WC->logged_in)
+           && (StrLength(WC->Hdr->c_username) > 0)
+           && (StrLength(WC->Hdr->c_password) > 0)
+           ) {
                long Status;
 
                FlushStrBuf(Buf);
@@ -717,9 +661,7 @@ void session_loop(void)
                }
        }
 
-       xhttp = (WC->Hdr->HR.eReqType != eGET) &&
-               (WC->Hdr->HR.eReqType != ePOST) &&
-               (WC->Hdr->HR.eReqType != eHEAD);
+       xhttp = (WC->Hdr->HR.eReqType != eGET) && (WC->Hdr->HR.eReqType != ePOST) && (WC->Hdr->HR.eReqType != eHEAD);
 
        /*
         * If a 'go' (or 'gotofirst') parameter has been specified, attempt to goto that room
@@ -730,7 +672,7 @@ void session_loop(void)
                if (verbose)
                        syslog(LOG_DEBUG, "Explicit room selection: %s", bstr("go"));
                ret = gotoroom(sbstr("go"));    /* do quietly to avoid session output! */
-               if ((ret/100) != 2) {
+               if ((ret / 100) != 2) {
                        if (verbose)
                                syslog(LOG_DEBUG, "Unable to change to [%s]; Reason: %d", bstr("go"), ret);
                }
@@ -740,7 +682,7 @@ void session_loop(void)
                if (verbose)
                        syslog(LOG_DEBUG, "Explicit room selection: %s", bstr("gotofirst"));
                ret = gotoroom(sbstr("gotofirst"));     /* do quietly to avoid session output! */
-               if ((ret/100) != 2) {
+               if ((ret / 100) != 2) {
                        syslog(LOG_INFO, "Unable to change to [%s]; Reason: %d", bstr("gotofirst"), ret);
                }
        }
@@ -749,16 +691,15 @@ void session_loop(void)
         * If we aren't in any room yet, but we have cookie data telling us where we're
         * supposed to be, and 'go' was not specified, then go there.
         */
-       else if ( (StrLength(WC->CurRoom.name) == 0) && ( (StrLength(WC->Hdr->c_roomname) > 0) )) {
+       else if ((StrLength(WC->CurRoom.name) == 0) && ((StrLength(WC->Hdr->c_roomname) > 0))) {
                int ret;
 
                if (verbose)
                        syslog(LOG_DEBUG, "We are in '%s' but cookie indicates '%s', going there...",
-                              ChrPtr(WC->CurRoom.name),
-                              ChrPtr(WC->Hdr->c_roomname)
-               );
+                              ChrPtr(WC->CurRoom.name), ChrPtr(WC->Hdr->c_roomname)
+                           );
                ret = gotoroom(WC->Hdr->c_roomname);    /* do quietly to avoid session output! */
-               if ((ret/100) != 2) {
+               if ((ret / 100) != 2) {
                        if (verbose)
                                syslog(LOG_DEBUG, "COOKIEGOTO: Unable to change to [%s]; Reason: %d",
                                       ChrPtr(WC->Hdr->c_roomname), ret);
@@ -766,11 +707,11 @@ void session_loop(void)
        }
 
        if (WC->Hdr->HR.Handler != NULL) {
-               if (    (!WC->logged_in)
-                       && ((WC->Hdr->HR.Handler->Flags & ANONYMOUS) == 0)
-                       && (WC->serv_info != NULL)
-                       && (WC->serv_info->serv_supports_guest == 0)
-               ) {
+               if ((!WC->logged_in)
+                   && ((WC->Hdr->HR.Handler->Flags & ANONYMOUS) == 0)
+                   && (WC->serv_info != NULL)
+                   && (WC->serv_info->serv_supports_guest == 0)
+                   ) {
                        display_login();
                }
                else {
@@ -789,7 +730,7 @@ void session_loop(void)
                 * ordinary browser users get a nice login screen, DAV etc. requsets
                 * are given a 401 so they can handle it appropriate.
                 */
-               if (!WC->logged_in)  {
+               if (!WC->logged_in) {
                        if (xhttp) {
                                authorization_required();
                        }
@@ -810,7 +751,7 @@ void session_loop(void)
                }
        }
 
-SKIP_ALL_THIS_CRAP:
+      SKIP_ALL_THIS_CRAP:
        FreeStrBuf(&Buf);
        fflush(stdout);
 }
@@ -847,8 +788,7 @@ void display_default_landing_page(void) {
 /*
  * Replacement for sleep() that uses select() in order to avoid SIGALRM
  */
-void sleeeeeeeeeep(int seconds)
-{
+void sleeeeeeeeeep(int seconds) {
        struct timeval tv;
 
        tv.tv_sec = seconds;
@@ -856,23 +796,20 @@ void sleeeeeeeeeep(int seconds)
        select(0, NULL, NULL, NULL, &tv);
 }
 
-int Conditional_IS_HTTPS(StrBuf *Target, WCTemplputParams *TP)
-{
+int Conditional_IS_HTTPS(StrBuf * Target, WCTemplputParams * TP) {
        return is_https != 0;
 }
 
-void AppendImportantMessage(const char *pch, long len)
-{
+void AppendImportantMessage(const char *pch, long len) {
 
        if (StrLength(WC->ImportantMsg) > 0) {
                StrBufAppendBufPlain(WC->ImportantMsg, HKEY("\n"), 0);
        }
-               
+
        StrBufAppendBufPlain(WC->ImportantMsg, pch, len, 0);
 }
 
-int ConditionalImportantMesage(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalImportantMesage(StrBuf * Target, WCTemplputParams * TP) {
        if (WC != NULL) {
                return (StrLength(WC->ImportantMsg) > 0);
        }
@@ -881,9 +818,8 @@ int ConditionalImportantMesage(StrBuf *Target, WCTemplputParams *TP)
        }
 }
 
-void tmplput_importantmessage(StrBuf *Target, WCTemplputParams *TP)
-{
-       
+void tmplput_importantmessage(StrBuf * Target, WCTemplputParams * TP) {
+
        if (WC != NULL) {
                if (StrLength(WC->ImportantMsg) > 0) {
                        StrBufAppendTemplate(Target, TP, WC->ImportantMsg, 0);
@@ -891,42 +827,36 @@ void tmplput_importantmessage(StrBuf *Target, WCTemplputParams *TP)
        }
 }
 
-void tmplput_trailing_javascript(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_trailing_javascript(StrBuf * Target, WCTemplputParams * TP) {
 
        if (WC != NULL) {
                StrBufAppendTemplate(Target, TP, WC->trailing_javascript, 0);
        }
 }
 
-void tmplput_csslocal(StrBuf *Target, WCTemplputParams *TP)
-{
-       StrBufAppendBuf(Target, 
-                       csslocal, 0);
+void tmplput_csslocal(StrBuf * Target, WCTemplputParams * TP) {
+       StrBufAppendBuf(Target, csslocal, 0);
 }
 
-void tmplput_packagestring(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_packagestring(StrBuf * Target, WCTemplputParams * TP) {
        StrBufAppendBufPlain(Target, HKEY(PACKAGE_STRING), 0);
 }
 
 extern char static_local_dir[PATH_MAX];
 
 
-void 
-InitModule_WEBCIT
-(void)
-{
+void InitModule_WEBCIT(void) {
        char dir[SIZ];
-       WebcitAddUrlHandler(HKEY("blank"), "", 0, blank_page, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC);
-       WebcitAddUrlHandler(HKEY("landing"), "", 0, display_default_landing_page, ANONYMOUS|COOKIEUNNEEDED);
+       WebcitAddUrlHandler(HKEY("blank"), "", 0, blank_page, ANONYMOUS | COOKIEUNNEEDED | ISSTATIC);
+       WebcitAddUrlHandler(HKEY("landing"), "", 0, display_default_landing_page, ANONYMOUS | COOKIEUNNEEDED);
        WebcitAddUrlHandler(HKEY("do_template"), "", 0, url_do_template, ANONYMOUS);
-       WebcitAddUrlHandler(HKEY("sslg"), "", 0, seconds_since_last_gexp, AJAX|LOGCHATTY);
+       WebcitAddUrlHandler(HKEY("sslg"), "", 0, seconds_since_last_gexp, AJAX | LOGCHATTY);
        WebcitAddUrlHandler(HKEY("ajax_servcmd"), "", 0, ajax_servcmd, 0);
        WebcitAddUrlHandler(HKEY("webcit"), "", 0, blank_page, URLNAMESPACE);
        WebcitAddUrlHandler(HKEY("push"), "", 0, push_destination, AJAX);
        WebcitAddUrlHandler(HKEY("pop"), "", 0, pop_destination, 0);
 
-       WebcitAddUrlHandler(HKEY("401"), "", 0, authorization_required, ANONYMOUS|COOKIEUNNEEDED);
+       WebcitAddUrlHandler(HKEY("401"), "", 0, authorization_required, ANONYMOUS | COOKIEUNNEEDED);
        RegisterConditional("COND:IMPMSG", 0, ConditionalImportantMesage, CTX_NONE);
        RegisterConditional("COND:REST:DEPTH", 0, Conditional_REST_DEPTH, CTX_NONE);
        RegisterConditional("COND:IS_HTTPS", 0, Conditional_IS_HTTPS, CTX_NONE);
@@ -937,7 +867,7 @@ InitModule_WEBCIT
        RegisterNamespace("URL:DISPLAYNAME", 0, 1, tmplput_HANDLER_DISPLAYNAME, NULL, CTX_NONE);
        RegisterNamespace("PACKAGESTRING", 0, 1, tmplput_packagestring, NULL, CTX_NONE);
 
-       
+
        snprintf(dir, SIZ, "%s/webcit.css", static_local_dir);
        if (!access(dir, R_OK)) {
                syslog(LOG_INFO, "Using local Stylesheet [%s]", dir);
@@ -948,46 +878,33 @@ InitModule_WEBCIT
 
 }
 
-void
-ServerStartModule_WEBCIT
-(void)
-{
+void ServerStartModule_WEBCIT(void) {
        HandlerHash = NewHash(1, NULL);
 }
 
 
-void 
-ServerShutdownModule_WEBCIT
-(void)
-{
+void ServerShutdownModule_WEBCIT(void) {
        FreeStrBuf(&csslocal);
        DeleteHash(&HandlerHash);
 }
 
 
 
-void
-SessionNewModule_WEBCIT
-(wcsession *sess)
-{
+void SessionNewModule_WEBCIT(wcsession * sess) {
        sess->ImportantMsg = NewStrBuf();
        sess->WBuf = NewStrBufPlain(NULL, SIZ * 4);
        sess->HBuf = NewStrBufPlain(NULL, SIZ / 4);
 }
 
-void
-SessionDetachModule_WEBCIT
-(wcsession *sess)
-{
+void SessionDetachModule_WEBCIT(wcsession * sess) {
        DeleteHash(&sess->Directory);
 
        FreeStrBuf(&sess->upload);
        sess->upload_length = 0;
-       
+
        FreeStrBuf(&sess->trailing_javascript);
 
-       if (StrLength(sess->WBuf) > SIZ * 30) /* Bigger than 120K? release. */
-       {
+       if (StrLength(sess->WBuf) > SIZ * 30) { /* Bigger than 120K? release. */
                FreeStrBuf(&sess->WBuf);
                sess->WBuf = NewStrBuf();
        }
@@ -1000,13 +917,10 @@ SessionDetachModule_WEBCIT
 
 }
 
-void 
-SessionDestroyModule_WEBCIT
-(wcsession *sess)
-{
+void
+ SessionDestroyModule_WEBCIT(wcsession * sess) {
        FreeStrBuf(&sess->WBuf);
        FreeStrBuf(&sess->HBuf);
        FreeStrBuf(&sess->ImportantMsg);
        FreeStrBuf(&sess->PushedDestination);
 }
-
index a5adb52fd4b89687d843980bbcb4c333580f3297..5e58b755a6e5c879418b224d0949d468fb829b9b 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1987-2021 by the citadel.org team
  *
@@ -90,6 +91,7 @@ typedef struct wcsession wcsession;
 #include "sockets.h"
 #include "utils.h"
 #ifdef HAVE_OPENSSL
+
 /* Work around RedHat's b0rken OpenSSL includes */
 #define OPENSSL_NO_KRB5
 #include <openssl/ssl.h>
@@ -99,7 +101,7 @@ extern char *ssl_cipher_list;
 #define        DEFAULT_SSL_CIPHER_LIST "DEFAULT"       /* See http://openssl.org/docs/apps/ciphers.html */
 #endif
 
-#if SIZEOF_SIZE_T == SIZEOF_INT 
+#if SIZEOF_SIZE_T == SIZEOF_INT
 #define SIZE_T_FMT "%d"
 #else
 #define SIZE_T_FMT "%ld"
@@ -114,7 +116,7 @@ extern char *ssl_cipher_list;
 #define CALENDAR_ROOM_NAME     "Calendar"
 #define PRODID "-//Citadel//NONSGML Citadel Calendar//EN"
 
-#define SIZ                    4096            /* generic buffer size */
+#define SIZ                    4096    /* generic buffer size */
 
 #define TRACE syslog(LOG_DEBUG, "\033[3%dmCHECKPOINT: %s:%d\033[0m", ((__LINE__%6)+1), __FILE__, __LINE__)
 
@@ -122,19 +124,19 @@ extern char *ssl_cipher_list;
 #undef memcpy
 #endif
 
-#define SLEEPING               180                     /* TCP connection timeout */
-#define WEBCIT_TIMEOUT         900                     /* WebCit session timeout */
-#define PORT_NUM               80                      /* port number to listen on */
+#define SLEEPING               180     /* TCP connection timeout */
+#define WEBCIT_TIMEOUT         900     /* WebCit session timeout */
+#define PORT_NUM               80      /* port number to listen on */
 #define DEVELOPER_ID           0
 #define CLIENT_ID              4
-#define CLIENT_VERSION 957             /* This version of WebCit */
-#define MINIMUM_CIT_VERSION    931                     /* Minimum required version of Citadel server */
-#define        LIBCITADEL_MIN          931                     /* Minimum required version of libcitadel */
+#define CLIENT_VERSION 957     /* This version of WebCit */
+#define MINIMUM_CIT_VERSION    931     /* Minimum required version of Citadel server */
+#define        LIBCITADEL_MIN          931     /* Minimum required version of libcitadel */
 #define DEFAULT_CTDLDIR                "/usr/local/citadel"    /* Default Citadel server directory */
-#define TARGET                 "webcit01"              /* Window target for inline URL's */
-#define HOUSEKEEPING           15                      /* Housekeeping frequency */
+#define TARGET                 "webcit01"      /* Window target for inline URL's */
+#define HOUSEKEEPING           15      /* Housekeeping frequency */
 #define MAX_WORKER_THREADS     250
-#define LISTEN_QUEUE_LENGTH    100                     /* listen() backlog queue */
+#define LISTEN_QUEUE_LENGTH    100     /* listen() backlog queue */
 
 #define USERCONFIGROOM         "My Citadel Config"
 #define DEFAULT_MAXMSGS                20
@@ -149,7 +151,7 @@ extern char *ssl_cipher_list;
 #define MAJORCODE(a) (((int)(a / 100) ) * 100)
 
 #define LISTING_FOLLOWS        100
-#define CIT_OK                 200     
+#define CIT_OK                 200
 #define MORE_DATA      300
 #define SEND_LISTING   400
 #define ERROR          500
@@ -159,27 +161,27 @@ extern char *ssl_cipher_list;
 #define ASYNC_MSG      900
 
 #define MINORCODE(a) (a % 100)
-#define ASYNC_GEXP                     02      
-#define INTERNAL_ERROR                         10      
-#define TOO_BIG                        11      
-#define ILLEGAL_VALUE                  12      
-#define NOT_LOGGED_IN                  20      
-#define CMD_NOT_SUPPORTED              30      
-#define SERVER_SHUTTING_DOWN           31      
-#define PASSWORD_REQUIRED              40      
-#define ALREADY_LOGGED_IN              41      
-#define USERNAME_REQUIRED              42      
-#define HIGHER_ACCESS_REQUIRED                 50      
-#define MAX_SESSIONS_EXCEEDED          51      
-#define RESOURCE_BUSY                  52      
-#define RESOURCE_NOT_OPEN              53      
-#define NOT_HERE                       60      
-#define INVALID_FLOOR_OPERATION        61      
-#define NO_SUCH_USER                   70      
-#define FILE_NOT_FOUND                         71      
-#define ROOM_NOT_FOUND                         72      
-#define NO_SUCH_SYSTEM                         73      
-#define ALREADY_EXISTS                         74      
+#define ASYNC_GEXP                     02
+#define INTERNAL_ERROR                         10
+#define TOO_BIG                        11
+#define ILLEGAL_VALUE                  12
+#define NOT_LOGGED_IN                  20
+#define CMD_NOT_SUPPORTED              30
+#define SERVER_SHUTTING_DOWN           31
+#define PASSWORD_REQUIRED              40
+#define ALREADY_LOGGED_IN              41
+#define USERNAME_REQUIRED              42
+#define HIGHER_ACCESS_REQUIRED                 50
+#define MAX_SESSIONS_EXCEEDED          51
+#define RESOURCE_BUSY                  52
+#define RESOURCE_NOT_OPEN              53
+#define NOT_HERE                       60
+#define INVALID_FLOOR_OPERATION        61
+#define NO_SUCH_USER                   70
+#define FILE_NOT_FOUND                         71
+#define ROOM_NOT_FOUND                         72
+#define NO_SUCH_SYSTEM                         73
+#define ALREADY_EXISTS                         74
 #define MESSAGE_NOT_FOUND              75
 
 /*
@@ -193,8 +195,8 @@ extern char *ssl_cipher_list;
  */
 
 typedef struct __ExpirePolicy {
-        int expire_mode;
-        int expire_value;
+       int expire_mode;
+       int expire_value;
 } ExpirePolicy;
 
 /*
@@ -202,27 +204,27 @@ typedef struct __ExpirePolicy {
  */
 typedef struct urlcontent urlcontent;
 struct urlcontent {
-       char url_key[32];               /* key */
+       char url_key[32];       /* key */
        long klen;
-       StrBuf *url_data;               /* value */
+       StrBuf *url_data;       /* value */
        HashList *sub;
 };
 
 /*
  * Information about the Citadel server to which we are connected
- */ 
+ */
 typedef struct _serv_info {
-       int serv_pid;                   /* Process ID of the Citadel server */
-       StrBuf *serv_nodename;          /* Node name of the Citadel server */
-       StrBuf *serv_humannode;         /* Juman readable node name of the Citadel server */
-       StrBuf *serv_fqdn;              /* Fully qualified Domain Name (such as uncensored.citadel.org) */
-       StrBuf *serv_software;          /* Free form text description of the server software in use */
-       int serv_rev_level;             /* Server version number (times 100) */
-       StrBuf *serv_bbs_city;          /* Geographic location of the Citadel server */
-       StrBuf *serv_sysadm;            /* Name of system administrator */
-       int serv_supports_ldap;         /* is the server linked against an ldap tree for adresses? */
+       int serv_pid;           /* Process ID of the Citadel server */
+       StrBuf *serv_nodename;  /* Node name of the Citadel server */
+       StrBuf *serv_humannode; /* Juman readable node name of the Citadel server */
+       StrBuf *serv_fqdn;      /* Fully qualified Domain Name (such as uncensored.citadel.org) */
+       StrBuf *serv_software;  /* Free form text description of the server software in use */
+       int serv_rev_level;     /* Server version number (times 100) */
+       StrBuf *serv_bbs_city;  /* Geographic location of the Citadel server */
+       StrBuf *serv_sysadm;    /* Name of system administrator */
+       int serv_supports_ldap; /* is the server linked against an ldap tree for adresses? */
        int serv_newuser_disabled;      /* Has the server disabled self-service new user creation? */
-       StrBuf *serv_default_cal_zone;  /* Default timezone for unspecified calendar items */
+       StrBuf *serv_default_cal_zone;  /* Default timezone for unspecified calendar items */
        int serv_supports_sieve;        /* Server supports Sieve mail filtering */
        int serv_fulltext_enabled;      /* Full text index is enabled */
        StrBuf *serv_svn_revision;      /* svn or git revision of the server */
@@ -231,20 +233,20 @@ typedef struct _serv_info {
 } ServInfo;
 
 
-typedef struct _disp_cal {                                     
-       icalcomponent *cal;             /* cal items for display */
-       long cal_msgnum;                /* cal msgids for display */
-       char *from;                     /* owner of this component */
-       int unread;                     /* already seen by the user? */
+typedef struct _disp_cal {
+       icalcomponent *cal;     /* cal items for display */
+       long cal_msgnum;        /* cal msgids for display */
+       char *from;             /* owner of this component */
+       int unread;             /* already seen by the user? */
 
        time_t event_start;
        time_t event_end;
 
        int multi_day_event;
        int is_repeat;
-       icalcomponent *SortBy;          /* cal items for display */
+       icalcomponent *SortBy;  /* cal items for display */
        icalproperty_status Status;
-} disp_cal;                                            
+} disp_cal;
 
 typedef struct _IcalKindEnumMap {
        const char *Name;
@@ -254,7 +256,7 @@ typedef struct _IcalKindEnumMap {
 typedef struct _IcalMethodEnumMap {
        const char *Name;
        long NameLen;
-        icalproperty_method map;
+       icalproperty_method map;
 } IcalMethodEnumMap;
 
 
@@ -287,7 +289,7 @@ typedef enum _RESTDispatchID {
 
 typedef int (*WebcitRESTDispatchID)(RESTDispatchID WhichAction, int IgnoreFloor);
 typedef void (*WebcitHandlerFunc)(void);
-typedef struct  _WebcitHandler{
+typedef struct _WebcitHandler {
        WebcitHandlerFunc F;
        WebcitRESTDispatchID RID;
        long Flags;
@@ -295,7 +297,7 @@ typedef struct  _WebcitHandler{
        StrBuf *DisplayName;
 } WebcitHandler;
 
-void WebcitAddUrlHandler(const char * UrlString, long UrlSLen, const char *DisplayName, long dslen, WebcitHandlerFunc F, long Flags);
+void WebcitAddUrlHandler(const char *UrlString, long UrlSLen, const char *DisplayName, long dslen, WebcitHandlerFunc F, long Flags);
 
 typedef struct _headereval {
        ExamineMsgHeaderFunc evaluator;
@@ -333,7 +335,7 @@ extern const char *ReqStrs[eNONE];
 #define AUTH_BASIC 2
 
 typedef struct _HdrRefs {
-       long eReqType;                          /* HTTP method */
+       long eReqType;          /* HTTP method */
        int desired_session;
        int SessionKey;
 
@@ -341,7 +343,7 @@ typedef struct _HdrRefs {
        int DontNeedAuth;
        long ContentLength;
        time_t if_modified_since;
-       int gzip_ok;                            /* Nonzero if Accept-encoding: gzip */
+       int gzip_ok;            /* Nonzero if Accept-encoding: gzip */
        int prohibit_caching;
        int dav_depth;
        int Static;
@@ -360,7 +362,7 @@ typedef struct _HdrRefs {
 } HdrRefs;
 
 typedef struct _ParsedHttpHdrs {
-       int http_sock;                          /* HTTP server socket */
+       int http_sock;          /* HTTP server socket */
        long HaveRange;
        long RangeStart;
        long RangeTil;
@@ -372,13 +374,13 @@ typedef struct _ParsedHttpHdrs {
        StrBuf *c_password;
        StrBuf *c_roomname;
        StrBuf *c_language;
-       StrBuf *this_page;                      /* URL of current page */
-       StrBuf *PlainArgs; 
+       StrBuf *this_page;      /* URL of current page */
+       StrBuf *PlainArgs;
        StrBuf *HostHeader;
 
-       HashList *urlstrings;                   /* variables passed to webcit in a URL */
-       HashList *HTTPHeaders;                  /* the headers the client sent us */
-       int nWildfireHeaders;                   /* how many wildfire headers did we already send? */
+       HashList *urlstrings;   /* variables passed to webcit in a URL */
+       HashList *HTTPHeaders;  /* the headers the client sent us */
+       int nWildfireHeaders;   /* how many wildfire headers did we already send? */
 
        HdrRefs HR;
 } ParsedHttpHdrs;
@@ -388,95 +390,98 @@ typedef struct _ParsedHttpHdrs {
  * HTTP transactions are bound to one at a time.
  */
 struct wcsession {
+
 /* infrastructural members */
-       wcsession *next;                        /* Linked list */
-       pthread_mutex_t SessionMutex;           /* mutex for exclusive access */
-       int wc_session;                         /* WebCit session ID */
-       int killthis;                           /* Nonzero == purge this session */
-       int ctdl_pid;                           /* Session ID on the Citadel server */
-       int nonce;                              /* session nonce (to prevent session riding) */
-       int inuse;                              /* set to nonzero if bound to a running thread */
-       int isFailure;                          /* Http 2xx or 5xx? */
+       wcsession *next;        /* Linked list */
+       pthread_mutex_t SessionMutex;   /* mutex for exclusive access */
+       int wc_session;         /* WebCit session ID */
+       int killthis;           /* Nonzero == purge this session */
+       int ctdl_pid;           /* Session ID on the Citadel server */
+       int nonce;              /* session nonce (to prevent session riding) */
+       int inuse;              /* set to nonzero if bound to a running thread */
+       int isFailure;          /* Http 2xx or 5xx? */
 
 /* Session local Members */
-       int serv_sock;                          /* Client socket to Citadel server */
-       StrBuf *ReadBuf;                        /* linebuffered reads from the server */
-       StrBuf *MigrateReadLineBuf;             /* here we buffer legacy server read stuff */
-       const char *ReadPos;                    /* whats our read position in ReadBuf? */
-       int last_chat_seq;                      /* When in chat - last message seq# we saw */
-       time_t lastreq;                         /* Timestamp of most recent HTTP */
-       time_t last_pager_check;                /* last time we polled for instant msgs */
-       ServInfo *serv_info;                    /* Information about the citserver we're connected to */
-       StrBuf *PushedDestination;              /* Where to go after login, registration, etc. */
+       int serv_sock;          /* Client socket to Citadel server */
+       StrBuf *ReadBuf;        /* linebuffered reads from the server */
+       StrBuf *MigrateReadLineBuf;     /* here we buffer legacy server read stuff */
+       const char *ReadPos;    /* whats our read position in ReadBuf? */
+       int last_chat_seq;      /* When in chat - last message seq# we saw */
+       time_t lastreq;         /* Timestamp of most recent HTTP */
+       time_t last_pager_check;        /* last time we polled for instant msgs */
+       ServInfo *serv_info;    /* Information about the citserver we're connected to */
+       StrBuf *PushedDestination;      /* Where to go after login, registration, etc. */
 
 /* Request local Members */
-       StrBuf *CLineBuf;                       /* linebuffering client stuff */
+       StrBuf *CLineBuf;       /* linebuffering client stuff */
        ParsedHttpHdrs *Hdr;
-       StrBuf *WBuf;                           /* Our output buffer */
-       StrBuf *HBuf;                           /* Our HeaderBuffer */
-       StrBuf *WFBuf;                          /* Wildfire error logging buffer */
-       StrBuf *trailing_javascript;            /* extra javascript to be appended to page */
+       StrBuf *WBuf;           /* Our output buffer */
+       StrBuf *HBuf;           /* Our HeaderBuffer */
+       StrBuf *WFBuf;          /* Wildfire error logging buffer */
+       StrBuf *trailing_javascript;    /* extra javascript to be appended to page */
        StrBuf *ImportantMsg;
-       HashList *Directory;                    /* Parts of the directory URL in snippets */
-       const Floor *CurrentFloor;              /* when Parsing REST, which floor are we on? */
+       HashList *Directory;    /* Parts of the directory URL in snippets */
+       const Floor *CurrentFloor;      /* when Parsing REST, which floor are we on? */
 
 /* accounting */
-       StrBuf *wc_username;                    /* login name of current user */
-       StrBuf *wc_fullname;                    /* Screen name of current user */
-       StrBuf *wc_password;                    /* Password of current user */
-       StrBuf *httpauth_pass;                  /* only for GroupDAV sessions */
-       int axlevel;                            /* this user's access level */
-       int is_aide;                            /* nonzero == this user is an Admin */
-       int connected;                          /* nonzero == we are connected to Citadel */
-       int logged_in;                          /* nonzero == we are logged in  */
-       int need_regi;                          /* This user needs to register. */
-       int need_vali;                          /* New users require validation. */
+       StrBuf *wc_username;    /* login name of current user */
+       StrBuf *wc_fullname;    /* Screen name of current user */
+       StrBuf *wc_password;    /* Password of current user */
+       StrBuf *httpauth_pass;  /* only for GroupDAV sessions */
+       int axlevel;            /* this user's access level */
+       int is_aide;            /* nonzero == this user is an Admin */
+       int connected;          /* nonzero == we are connected to Citadel */
+       int logged_in;          /* nonzero == we are logged in  */
+       int need_regi;          /* This user needs to register. */
+       int need_vali;          /* New users require validation. */
 
 /* Preferences */
-       StrBuf *cs_inet_email;                  /* User's preferred Internet addr. */
-       HashList *hash_prefs;                   /* WebCit preferences for this user */
-       StrBuf *DefaultCharset;                 /* Charset the user preferes */
-       int downloaded_prefs;                   /* Has the client download its prefs yet? */
-       int SavePrefsToServer;                  /* Should we save our preferences to the server at the end of the request? */
-       int selected_language;                  /* Language selected by user */
-       int time_format_cache;                  /* which timeformat does our user like? */
-
-       folder CurRoom;                         /* information about our current room */
-       const folder *ThisRoom;                 /* if REST found a room, remember it here. */
+       StrBuf *cs_inet_email;  /* User's preferred Internet addr. */
+       HashList *hash_prefs;   /* WebCit preferences for this user */
+       StrBuf *DefaultCharset; /* Charset the user preferes */
+       int downloaded_prefs;   /* Has the client download its prefs yet? */
+       int SavePrefsToServer;  /* Should we save our preferences to the server at the end of the request? */
+       int selected_language;  /* Language selected by user */
+       int time_format_cache;  /* which timeformat does our user like? */
+
+       folder CurRoom;         /* information about our current room */
+       const folder *ThisRoom; /* if REST found a room, remember it here. */
+
 /* next/previous room thingabob */
-       struct march *march;                    /* march mode room list */
-       char ugname[128];                       /* where does 'ungoto' take us */
-       long uglsn;                             /* last seen message number for ungoto */
+       struct march *march;    /* march mode room list */
+       char ugname[128];       /* where does 'ungoto' take us */
+       long uglsn;             /* last seen message number for ungoto */
 
 /* Uploading; mime attachments for composing messages */
-       HashList *attachments;                  /* list of attachments for 'enter message' */
-       int upload_length;                      /* content length of http-uploaded data */
-       StrBuf *upload;                         /* pointer to http-uploaded data */
-       StrBuf *upload_filename;                /* filename of http-uploaded data */
-       char upload_content_type[256];          /* content type of http-uploaded data */
+       HashList *attachments;  /* list of attachments for 'enter message' */
+       int upload_length;      /* content length of http-uploaded data */
+       StrBuf *upload;         /* pointer to http-uploaded data */
+       StrBuf *upload_filename;        /* filename of http-uploaded data */
+       char upload_content_type[256];  /* content type of http-uploaded data */
 
-       int remember_new_mail;                  /* last count of new mail messages */
+       int remember_new_mail;  /* last count of new mail messages */
 
 /* Roomiew control */
-       HashList *Floors;                       /* floors our citserver has hashed numeric for quicker access*/
-       HashList *FloorsByName;                 /* same but hashed by its name */
-       HashList *Rooms;                        /* our directory structure as loaded by LKRA */
-       HashList *summ;                         /* list of messages for mailbox summary view */
+       HashList *Floors;       /* floors our citserver has hashed numeric for quicker access */
+       HashList *FloorsByName; /* same but hashed by its name */
+       HashList *Rooms;        /* our directory structure as loaded by LKRA */
+       HashList *summ;         /* list of messages for mailbox summary view */
+
   /** Perhaps these should be within a struct instead */
-       long startmsg;                          /* message number to start at */
-       long maxmsgs;                           /* maximum messages to display */
-        long num_displayed;                     /* number of messages actually displayed */
-       HashList *disp_cal_items;               /* sorted list of calendar items; startdate is the sort criteria. */
+       long startmsg;          /* message number to start at */
+       long maxmsgs;           /* maximum messages to display */
+       long num_displayed;     /* number of messages actually displayed */
+       HashList *disp_cal_items;       /* sorted list of calendar items; startdate is the sort criteria. */
 
 
        char last_chat_user[256];
 
-       StrBuf *IconTheme;                      /* Icontheme setting */
+       StrBuf *IconTheme;      /* Icontheme setting */
 
 /* Iconbar controls */
        int cache_max_folders;
        int cache_num_floors;
-       long *IBSettingsVec;                    /* which icons should be shown / not shown? */
+       long *IBSettingsVec;    /* which icons should be shown / not shown? */
        const StrBuf *floordiv_expanded;        /* which floordiv currently expanded */
        int ib_wholist_expanded;
        int ib_roomlist_expanded;
@@ -489,14 +494,14 @@ struct wcsession {
        StrBuf *ConvertBuf2;
 
 /* cache stuff for templates. TODO: find a smarter way */
-       HashList *ServCfg;                      /* cache our server config for editing */
-       HashList *InetCfg;                      /* Our inet server config for editing */
+       HashList *ServCfg;      /* cache our server config for editing */
+       HashList *InetCfg;      /* Our inet server config for editing */
        ExpirePolicy Policy[maxpolicy];
 
 };
 
 
-typedef void (*Header_Evaluator)(StrBuf *Line, ParsedHttpHdrs *hdr);
+typedef void (*Header_Evaluator)(StrBuf * Line, ParsedHttpHdrs * hdr);
 
 typedef struct _HttpHeader {
        Header_Evaluator H;
@@ -514,7 +519,7 @@ enum {
 };
 
 #ifndef num_parms
-#define num_parms(source)              num_tokens(source, '|') 
+#define num_parms(source)              num_tokens(source, '|')
 #endif
 
 #define site_prefix    (WC ? (WC->Hdr->HostHeader) : NULL)
@@ -531,9 +536,9 @@ extern pthread_key_t ThreadSSL;
 void init_ssl(void);
 void endtls(void);
 int starttls(int sock);
-extern SSL_CTX *ssl_ctx;  
-int client_read_sslbuffer(StrBuf *buf, int timeout);
-int client_write_ssl(const StrBuf *Buf);
+extern SSL_CTX *ssl_ctx;
+int client_read_sslbuffer(StrBuf * buf, int timeout);
+int client_write_ssl(const StrBuf * Buf);
 #endif
 
 extern int is_https;
@@ -556,21 +561,21 @@ void http_redirect(const char *);
 #ifdef UBER_VERBOSE_DEBUGGING
 #define wc_printf(...) wcc_printf(__FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
 void wcc_printf(const char *FILE, const char *FUNCTION, long LINE, const char *format, ...);
-#else 
-void wc_printf(const char *format,...)__attribute__((__format__(__printf__,1,2)));
+#else
+void wc_printf(const char *format, ...) __attribute__((__format__(__printf__, 1, 2)));
 #endif
-void hprintf(const char *format,...)__attribute__((__format__(__printf__,1,2)));
-void CheckAuthBasic(ParsedHttpHdrs *hdr);
-void GetAuthBasic(ParsedHttpHdrs *hdr);
+void hprintf(const char *format, ...) __attribute__((__format__(__printf__, 1, 2)));
+void CheckAuthBasic(ParsedHttpHdrs * hdr);
+void GetAuthBasic(ParsedHttpHdrs * hdr);
 void sleeeeeeeeeep(int);
 size_t wc_strftime(char *s, size_t max, const char *format, const struct tm *tm);
 void fmt_time(char *buf, size_t siz, time_t thetime);
 void httpdate(char *buf, time_t thetime);
-time_t httpdate_to_timestamp(StrBuf *buf);
+time_t httpdate_to_timestamp(StrBuf * buf);
 void end_webcit_session(void);
-void cookie_to_stuff(StrBuf *cookie, int *session, StrBuf *user, StrBuf *pass, StrBuf *room, StrBuf *language);
-void locate_host(StrBuf *TBuf, int);
-void become_logged_in(const StrBuf *user, const StrBuf *pass, StrBuf *serv_response);
+void cookie_to_stuff(StrBuf * cookie, int *session, StrBuf * user, StrBuf * pass, StrBuf * room, StrBuf * language);
+void locate_host(StrBuf * TBuf, int);
+void become_logged_in(const StrBuf * user, const StrBuf * pass, StrBuf * serv_response);
 void display_login(void);
 void display_openids(void);
 void display_default_landing_page(void);
@@ -581,43 +586,44 @@ void display_aide_menu(void);
 void RegisterEmbeddableMimeType(const char *MimeType, long MTLen, int Priority);
 void CreateMimeStr(void);
 void pop_destination(void);
-void FmOut(StrBuf *Target, const char *align, const StrBuf *Source);
+void FmOut(StrBuf * Target, const char *align, const StrBuf * Source);
 void wDumpContent(int);
 void PutRequestLocalMem(void *Data, DeleteHashDataFunc DeleteIt);
 void output_headers(int do_httpheaders, int do_htmlhead, int do_room_banner, int unset_cookies, int suppress_check, int cache);
 void cdataout(char *rawdata);
 void url(char *buf, size_t bufsize);
-void UrlizeText(StrBuf* Target, StrBuf *Source, StrBuf *WrkBuf);
+void UrlizeText(StrBuf * Target, StrBuf * Source, StrBuf * WrkBuf);
 void display_success(const char *successmessage);
 void shutdown_sessions(void);
 StrBuf *load_mimepart(long msgnum, char *partnum);
-void MimeLoadData(wc_mime_attachment *Mime);
-void do_edit_vcard(long msgnum, char *partnum, message_summary *VCMsg, wc_mime_attachment *VCAtt, const char *return_to, const char *force_room);
+void MimeLoadData(wc_mime_attachment * Mime);
+void do_edit_vcard(long msgnum, char *partnum, message_summary * VCMsg, wc_mime_attachment * VCAtt, const char *return_to,
+                  const char *force_room);
 void select_user_to_edit(const char *preselect);
 void convenience_page(const char *titlebarcolor, const char *titlebarmsg, const char *messagetext);
 void output_html(const char *, int, int, StrBuf *, StrBuf *);
 ssize_t write(int fd, const void *buf, size_t count);
-void cal_process_attachment(wc_mime_attachment *Mime);
+void cal_process_attachment(wc_mime_attachment * Mime);
 void begin_ajax_response(void);
 void end_ajax_response(void);
 extern char *months[];
 extern char *days[];
-long locate_user_vcard_in_this_room(message_summary **VCMsg, wc_mime_attachment **VCAtt);
+long locate_user_vcard_in_this_room(message_summary ** VCMsg, wc_mime_attachment ** VCAtt);
 void http_transmit_thing(const char *content_type, int is_static);
 void http_transmit_headers(const char *content_type, int is_static, long is_chunked, int is_gzip);
 long unescape_input(char *buf);
 void check_thread_pool_size(void);
-void StrEndTab(StrBuf *Target, int tabnum, int num_tabs);
-void StrBeginTab(StrBuf *Target, int tabnum, int num_tabs, StrBuf **Names);
-void StrTabbedDialog(StrBuf *Target, int num_tabs, StrBuf *tabnames[]);
+void StrEndTab(StrBuf * Target, int tabnum, int num_tabs);
+void StrBeginTab(StrBuf * Target, int tabnum, int num_tabs, StrBuf ** Names);
+void StrTabbedDialog(StrBuf * Target, int num_tabs, StrBuf * tabnames[]);
 void tabbed_dialog(int num_tabs, const char *tabnames[]);
 void begin_tab(int tabnum, int num_tabs);
 void end_tab(int tabnum, int num_tabs);
-int get_time_format_cached (void);
+int get_time_format_cached(void);
 void display_wiki_pagelist(void);
 void str_wiki_index(StrBuf *);
-HashList *GetRoomListHashLKRA(StrBuf *Target, WCTemplputParams *TP);
-void TmplGettext(StrBuf *Target, WCTemplputParams *TP); /* actual supported locales */
+HashList *GetRoomListHashLKRA(StrBuf * Target, WCTemplputParams * TP);
+void TmplGettext(StrBuf * Target, WCTemplputParams * TP);      /* actual supported locales */
 void set_selected_language(const char *);
 void go_selected_language(void);
 const char *get_selected_language(void);
@@ -642,11 +648,11 @@ void display_enter(void);
 #define WC_TIMEFORMAT_AMPM 1
 #define WC_TIMEFORMAT_24 2
 
-extern int time_to_die;                        /* Nonzero if server is shutting down */
+extern int time_to_die;                /* Nonzero if server is shutting down */
 extern int DisableGzip;
 
 void display_summary_page(void);
-HashList *GetValidDomainNames(StrBuf *Target, WCTemplputParams *TP);
+HashList *GetValidDomainNames(StrBuf * Target, WCTemplputParams * TP);
 void output_error_pic(const char *ErrMsg1, const char *ErrMsg2);
 void jsonMessageListHdr(void);
-extern char *ctdl_dir;                         /* Directory where Citadel Server is running */
+extern char *ctdl_dir;         /* Directory where Citadel Server is running */
index 8f7a9c9081f81ad705507d1c9b50bf4550b25248..a72b48a8d5f9e7180f9feb6d28a4c4eec378e201 100644 (file)
 #include "webserver.h"
 #include "modules_init.h"
 
-extern int msock;                              /* master listening socket */
-extern char static_icon_dir[PATH_MAX];          /* where should we find our mime icons */
-int is_https = 0;                              /* Nonzero if I am an HTTPS service */
-int follow_xff = 0;                            /* Follow X-Forwarded-For: header? */
+extern int msock;              /* master listening socket */
+extern char static_icon_dir[PATH_MAX]; /* where should we find our mime icons */
+int is_https = 0;              /* Nonzero if I am an HTTPS service */
+int follow_xff = 0;            /* Follow X-Forwarded-For: header? */
 int DisableGzip = 0;
 char *default_landing_page = NULL;
 extern pthread_mutex_t SessionListMutex;
@@ -30,18 +30,21 @@ extern void webcit_calc_dirs_n_files(int relh, const char *basedir, int home, ch
 extern void worker_entry(void);
 extern void drop_root(uid_t UID);
 
-char socket_dir[PATH_MAX];             /* where to talk to our citadel server */
-char *server_cookie = NULL;            /* our Cookie connection to the client */
-int http_port = PORT_NUM;              /* Port to listen on */
-int running_as_daemon = 0;             /* should we deamonize on startup? */
+char socket_dir[PATH_MAX];     /* where to talk to our citadel server */
+char *server_cookie = NULL;    /* our Cookie connection to the client */
+int http_port = PORT_NUM;      /* Port to listen on */
+int running_as_daemon = 0;     /* should we deamonize on startup? */
 char *ctdl_dir = DEFAULT_CTDLDIR;      /* Directory where Citadel Server is running */
 
 /* #define DBG_PRINNT_HOOKS_AT_START */
 #ifdef DBG_PRINNT_HOOKS_AT_START
 extern HashList *HandlerHash;
 const char foobuf[32];
-const char *nix(void *vptr) {snprintf(foobuf, 32, "%0x", (long) vptr); return foobuf;}
-#endif 
+const char *nix(void *vptr) {
+       snprintf(foobuf, 32, "%0x", (long) vptr);
+       return foobuf;
+}
+#endif
 extern int verbose;
 extern int dbg_analyze_msg;
 extern int dbg_backtrace_template_errors;
@@ -57,13 +60,13 @@ void LoadMimeBlacklist(void);
  */
 int main(int argc, char **argv) {
        uid_t UID = -1;
-       pthread_t SessThread;           /* Thread descriptor */
-       pthread_attr_t attr;            /* Thread attributes */
-       int a;                          /* General-purpose variable */
-       char ip_addr[256]="*";
-       int relh=0;
-       int home=0;
-       char relhome[PATH_MAX]="";
+       pthread_t SessThread;   /* Thread descriptor */
+       pthread_attr_t attr;    /* Thread attributes */
+       int a;                  /* General-purpose variable */
+       char ip_addr[256] = "*";
+       int relh = 0;
+       int home = 0;
+       char relhome[PATH_MAX] = "";
        char webcitdir[PATH_MAX] = DATADIR;
        char *pidfile = NULL;
        char *hdir;
@@ -77,14 +80,15 @@ int main(int argc, char **argv) {
        start_modules();
 
 #ifdef DBG_PRINNT_HOOKS_AT_START
+
 /*     dbg_PrintHash(HandlerHash, nix, NULL);*/
 #endif
 
        /* Ensure that we are linked to the correct version of libcitadel */
        if (libcitadel_version_number() < LIBCITADEL_VERSION_NUMBER) {
-               fprintf(stderr, " You are running libcitadel version %d\n", libcitadel_version_number() );
-               fprintf(stderr, "WebCit was compiled against version %d\n", LIBCITADEL_VERSION_NUMBER );
-               return(1);
+               fprintf(stderr, " You are running libcitadel version %d\n", libcitadel_version_number());
+               fprintf(stderr, "WebCit was compiled against version %d\n", LIBCITADEL_VERSION_NUMBER);
+               return (1);
        }
 
        strcpy(uds_listen_path, "");
@@ -101,14 +105,14 @@ int main(int argc, char **argv) {
                        break;
                case 'h':
                        hdir = strdup(optarg);
-                       relh=hdir[0]!='/';
+                       relh = hdir[0] != '/';
                        if (!relh) {
                                safestrncpy(webcitdir, hdir, sizeof webcitdir);
                        }
                        else {
                                safestrncpy(relhome, relhome, sizeof relhome);
                        }
-                       home=1;
+                       home = 1;
                        break;
                case 'd':
                        running_as_daemon = 1;
@@ -120,7 +124,7 @@ int main(int argc, char **argv) {
                case 'g':
                        default_landing_page = strdup(optarg);
                        break;
-               case 'B': /* deprecated */
+               case 'B':       /* deprecated */
                        break;
                case 'i':
                        safestrncpy(ip_addr, optarg, sizeof ip_addr);
@@ -136,8 +140,8 @@ int main(int argc, char **argv) {
                        break;
                case 'T':
                        LoadTemplates = atoi(optarg);
-                       dbg_analyze_msg = (LoadTemplates & (1<<1)) != 0;
-                       dbg_backtrace_template_errors = (LoadTemplates & (1<<2)) != 0;
+                       dbg_analyze_msg = (LoadTemplates & (1 << 1)) != 0;
+                       dbg_backtrace_template_errors = (LoadTemplates & (1 << 2)) != 0;
                        break;
                case 'Z':
                        DisableGzip = 1;
@@ -152,7 +156,7 @@ int main(int argc, char **argv) {
                        server_cookie = malloc(256);
                        if (server_cookie != NULL) {
                                safestrncpy(server_cookie, "Set-cookie: wcserver=", 256);
-                               if (gethostname (&server_cookie[strlen(server_cookie)], 200) != 0) {
+                               if (gethostname(&server_cookie[strlen(server_cookie)], 200) != 0) {
                                        syslog(LOG_INFO, "gethostname: %s", strerror(errno));
                                        free(server_cookie);
                                }
@@ -173,7 +177,7 @@ int main(int argc, char **argv) {
                        I18nDumpFile = optarg;
                        break;
                case 'v':
-                       verbose=1;
+                       verbose = 1;
                        break;
                default:
                        fprintf(stderr, "usage:\nwebcit "
@@ -181,9 +185,7 @@ int main(int argc, char **argv) {
                                "[-c] [-f] "
                                "[-T Templatedebuglevel] "
                                "[-d] [-Z] [-G i18ndumpfile] "
-                               "[-u uid] [-h homedirectory] "
-                               "[-D daemonizepid] [-v] "
-                               "[-g defaultlandingpage] "
+                               "[-u uid] [-h homedirectory] " "[-D daemonizepid] [-v] " "[-g defaultlandingpage] "
 #ifdef HAVE_OPENSSL
                                "[-s] [-S cipher_suites]"
 #endif
@@ -193,10 +195,7 @@ int main(int argc, char **argv) {
 
        /* Start the logger */
        setlogmask(LOG_UPTO(max_log_level));
-       openlog("webcit",
-               ( running_as_daemon ? (LOG_PID) : (LOG_PID | LOG_PERROR) ),
-               LOG_DAEMON
-       );
+       openlog("webcit", (running_as_daemon ? (LOG_PID) : (LOG_PID | LOG_PERROR)), LOG_DAEMON);
 
        while (optind < argc) {
                ctdl_dir = strdup(argv[optind]);
@@ -242,14 +241,14 @@ int main(int argc, char **argv) {
        if (DumpTemplateI18NStrings) {
                FILE *fd;
                StrBufAppendBufPlain(I18nDump, HKEY("}\n"), 0);
-               if (StrLength(I18nDump) < 50) {
+               if (StrLength(I18nDump) < 50) {
                        syslog(LOG_INFO, "*******************************************************************\n");
                        syslog(LOG_INFO, "*   No strings found in templates!  Are you sure they're there?   *\n");
                        syslog(LOG_INFO, "*******************************************************************\n");
                        return -1;
                }
                fd = fopen(I18nDumpFile, "w");
-               if (fd == NULL) {
+               if (fd == NULL) {
                        syslog(LOG_INFO, "***********************************************\n");
                        syslog(LOG_INFO, "*   unable to open I18N dumpfile [%s]         *\n", I18nDumpFile);
                        syslog(LOG_INFO, "***********************************************\n");
@@ -263,9 +262,9 @@ int main(int argc, char **argv) {
        /* Tell libical to return an error instead of aborting if it sees badly formed iCalendar data. */
 
 #ifdef LIBICAL_ICAL_EXPORT     // cheap and sleazy way to detect libical >=2.0
-               icalerror_set_errors_are_fatal(0);
+       icalerror_set_errors_are_fatal(0);
 #else
-               icalerror_errors_are_fatal = 0;
+       icalerror_errors_are_fatal = 0;
 #endif
 
        /* Use our own prefix on tzid's generated from system tzdata */
@@ -307,8 +306,7 @@ int main(int argc, char **argv) {
                syslog(LOG_DEBUG, "Attempting to bind to port %d...", http_port);
                msock = webcit_tcp_server(ip_addr, http_port, LISTEN_QUEUE_LENGTH);
        }
-       if (msock < 0)
-       {
+       if (msock < 0) {
                ShutDownWebcit();
                return -msock;
        }
@@ -336,10 +334,3 @@ int main(int argc, char **argv) {
        ShutDownLibCitadel();
        return 0;
 }
-
-
-
-
-
-
-
index dc142d0d1a08e7a7887efbb0cbb078e7e8e570a1..f8e966bd7852cf390a982a9e14391ab0a0429b65 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 1996-2013 by the citadel.org team
  *
  */
 
 
-extern char *static_dirs[PATH_MAX];          /**< Web representation */
+extern char *static_dirs[PATH_MAX];         /**< Web representation */
 extern int ndirs;
 extern char socket_dir[PATH_MAX];
 
 extern char *default_landing_page;
 
-int ClientGetLine(ParsedHttpHdrs *Hdr, StrBuf *Target);
-int client_read_to(ParsedHttpHdrs *Hdr, StrBuf *Target, int bytes, int timeout);
+int ClientGetLine(ParsedHttpHdrs * Hdr, StrBuf * Target);
+int client_read_to(ParsedHttpHdrs * Hdr, StrBuf * Target, int bytes, int timeout);
 void wc_backtrace(long LogLevel);
 void ShutDownWebcit(void);
 void shutdown_ssl(void);
-
-
index dee492caf8e641da9c5d82d3117318caa5b5edd8..3cc798d656be70655d230c24a9b26480ff507d20 100644 (file)
@@ -17,9 +17,8 @@ typedef struct UserStateStruct {
        int SessionCount;
 } UserStateStruct;
 
-void DestroyUserStruct(void *vUser)
-{
-       UserStateStruct *User = (UserStateStruct*) vUser;
+void DestroyUserStruct(void *vUser) {
+       UserStateStruct *User = (UserStateStruct *) vUser;
        FreeStrBuf(&User->UserName);
        FreeStrBuf(&User->Room);
        FreeStrBuf(&User->Host);
@@ -29,20 +28,17 @@ void DestroyUserStruct(void *vUser)
        free(User);
 }
 
-int CompareUserStruct(const void *VUser1, const void *VUser2)
-{
-       const UserStateStruct *User1 = (UserStateStruct*) GetSearchPayload(VUser1);
-       const UserStateStruct *User2 = (UserStateStruct*) GetSearchPayload(VUser2);
-       
+int CompareUserStruct(const void *VUser1, const void *VUser2) {
+       const UserStateStruct *User1 = (UserStateStruct *) GetSearchPayload(VUser1);
+       const UserStateStruct *User2 = (UserStateStruct *) GetSearchPayload(VUser2);
+
        if (User1->Idle != User2->Idle)
                return User1->Idle > User2->Idle;
-       return strcasecmp(ChrPtr(User1->UserName), 
-                         ChrPtr(User2->UserName));
+       return strcasecmp(ChrPtr(User1->UserName), ChrPtr(User2->UserName));
 }
 
 
-int GetWholistSection(HashList *List, time_t now, StrBuf *Buf, const char *FilterName, long FNLen)
-{
+int GetWholistSection(HashList * List, time_t now, StrBuf * Buf, const char *FilterName, long FNLen) {
        UserStateStruct *User, *OldUser;
        void *VOldUser;
        size_t BufLen;
@@ -51,19 +47,16 @@ int GetWholistSection(HashList *List, time_t now, StrBuf *Buf, const char *Filte
        serv_puts("RWHO");
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) == 1) {
-               while (BufLen = StrBuf_ServGetln(Buf), 
-                      ((BufLen >= 0) && 
-                       ((BufLen != 3) || strcmp(ChrPtr(Buf), "000"))))
-               {
+               while (BufLen = StrBuf_ServGetln(Buf), ((BufLen >= 0) && ((BufLen != 3) || strcmp(ChrPtr(Buf), "000")))) {
                        if (BufLen <= 0)
-                           continue;
+                               continue;
                        Pos = NULL;
-                       User = (UserStateStruct*) malloc(sizeof(UserStateStruct));
+                       User = (UserStateStruct *) malloc(sizeof(UserStateStruct));
                        User->Session = StrBufExtractNext_int(Buf, &Pos, '|');
 
                        User->UserName = NewStrBufPlain(NULL, BufLen);
                        StrBufExtract_NextToken(User->UserName, Buf, &Pos, '|');
-                       
+
                        User->Room = NewStrBufPlain(NULL, BufLen);
                        StrBufExtract_NextToken(User->Room, Buf, &Pos, '|');
 
@@ -81,40 +74,32 @@ int GetWholistSection(HashList *List, time_t now, StrBuf *Buf, const char *Filte
 
                        User->RealHost = NewStrBufPlain(NULL, BufLen);
                        StrBufExtract_NextToken(User->RealHost, Buf, &Pos, '|');
-                       
+
                        User->Idle = (now - User->LastActive) > 900L;
                        User->IdleSince = (now - User->LastActive) / 60;
                        User->SessionCount = 1;
 
                        if (FilterName == NULL) {
-                               if (GetHash(List, 
-                                           SKEY(User->UserName), 
-                                           &VOldUser)) {
+                               if (GetHash(List, SKEY(User->UserName), &VOldUser)) {
                                        OldUser = VOldUser;
                                        OldUser->SessionCount++;
                                        if (!User->Idle) {
-                                               if (User->Session == WC->ctdl_pid) 
+                                               if (User->Session == WC->ctdl_pid)
                                                        OldUser->Session = User->Session;
-                                               
+
                                                OldUser->Idle = User->Idle;
                                                OldUser->LastActive = User->LastActive;
                                        }
                                        DestroyUserStruct(User);
                                }
                                else
-                                       Put(List, 
-                                           SKEY(User->UserName), 
-                                           User, DestroyUserStruct);
+                                       Put(List, SKEY(User->UserName), User, DestroyUserStruct);
                        }
                        else {
-                               if (strcmp(FilterName, ChrPtr(User->UserName)) == 0)
-                               {
-                                       Put(List, 
-                                           SKEY(User->UserName), 
-                                           User, DestroyUserStruct);
+                               if (strcmp(FilterName, ChrPtr(User->UserName)) == 0) {
+                                       Put(List, SKEY(User->UserName), User, DestroyUserStruct);
                                }
-                               else 
-                               {
+                               else {
                                        DestroyUserStruct(User);
                                }
                        }
@@ -131,8 +116,7 @@ int GetWholistSection(HashList *List, time_t now, StrBuf *Buf, const char *Filte
 /*
  * end session
  */
-void terminate_session(void)
-{
+void terminate_session(void) {
        char buf[SIZ];
 
        serv_printf("TERM %s", bstr("which_session"));
@@ -146,30 +130,27 @@ void _terminate_session(void) {
        terminate_session();
 }
 
-HashList *GetWholistHash(StrBuf *Target, WCTemplputParams *TP)
-
-{
+HashList *GetWholistHash(StrBuf * Target, WCTemplputParams * TP) {
        const char *ch = NULL;
        int HashUniq = 1;
        long len;
        StrBuf *FilterNameStr = NULL;
        StrBuf *Buf;
        HashList *List;
-        time_t now;
+       time_t now;
 
        Buf = NewStrBuf();
 
        serv_puts("TIME");
        StrBuf_ServGetln(Buf);
-       if (GetServerStatus(Buf, NULL)  == 2) {
+       if (GetServerStatus(Buf, NULL) == 2) {
                const char *pos = ChrPtr(Buf) + 4;
                now = StrBufExtractNext_long(Buf, &pos, '|');
        }
        else {
                now = time(NULL);
        }
-       if (HaveTemplateTokenString(NULL, TP, 2, &ch, &len))
-       {
+       if (HaveTemplateTokenString(NULL, TP, 2, &ch, &len)) {
                FilterNameStr = NewStrBuf();
                GetTemplateTokenString(FilterNameStr, TP, 2, &ch, &len);
                HashUniq = 0;
@@ -183,124 +164,105 @@ HashList *GetWholistHash(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-void DeleteWholistHash(HashList **KillMe)
-{
+void DeleteWholistHash(HashList ** KillMe) {
        DeleteHash(KillMe);
 }
 
-void tmplput_who_username(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_username(StrBuf * Target, WCTemplputParams * TP) {
+       UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
        StrBufAppendTemplate(Target, TP, User->UserName, 0);
 }
 
-void tmplput_who_UserAgent(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_UserAgent(StrBuf * Target, WCTemplputParams * TP) {
+       UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
        StrBufAppendTemplate(Target, TP, User->UserAgent, 0);
 }
 
-void tmplput_who_room(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_room(StrBuf * Target, WCTemplputParams * TP) {
+       UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
        StrBufAppendTemplate(Target, TP, User->Room, 0);
 }
 
-void tmplput_who_host(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_host(StrBuf * Target, WCTemplputParams * TP) {
+       UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
        StrBufAppendTemplate(Target, TP, User->Host, 0);
 }
 
-void tmplput_who_realroom(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_realroom(StrBuf * Target, WCTemplputParams * TP) {
+       UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
        StrBufAppendTemplate(Target, TP, User->RealRoom, 0);
 }
-int conditional_who_realroom(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+int conditional_who_realroom(StrBuf * Target, WCTemplputParams * TP) {
+       UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
        return StrLength(User->RealRoom) > 0;
 }
 
-void tmplput_who_realhost(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_realhost(StrBuf * Target, WCTemplputParams * TP) {
+       UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
        StrBufAppendTemplate(Target, TP, User->RealHost, 0);
 }
-int conditional_who_realhost(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+int conditional_who_realhost(StrBuf * Target, WCTemplputParams * TP) {
+       UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
        return StrLength(User->RealHost) > 0;
 }
 
-void tmplput_who_lastactive(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_lastactive(StrBuf * Target, WCTemplputParams * TP) {
+       UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
        StrBufAppendPrintf(Target, "%d", User->LastActive);
 }
 
-void tmplput_who_idlesince(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_idlesince(StrBuf * Target, WCTemplputParams * TP) {
+       UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
        StrBufAppendPrintf(Target, "%d", User->IdleSince);
 }
 
-void tmplput_who_session(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_session(StrBuf * Target, WCTemplputParams * TP) {
+       UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
        StrBufAppendPrintf(Target, "%d", User->Session);
 }
 
-int conditional_who_idle(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+int conditional_who_idle(StrBuf * Target, WCTemplputParams * TP) {
+       UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
        return User->Idle;
 }
 
-int conditional_who_nsessions(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+int conditional_who_nsessions(StrBuf * Target, WCTemplputParams * TP) {
+       UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
        return User->SessionCount;
 }
 
-void tmplput_who_nsessions(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_nsessions(StrBuf * Target, WCTemplputParams * TP) {
+       UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
        StrBufAppendPrintf(Target, "%d", User->SessionCount);
 }
 
-int conditional_who_isme(StrBuf *Target, WCTemplputParams *TP)
-{
-       UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+int conditional_who_isme(StrBuf * Target, WCTemplputParams * TP) {
+       UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
        return (User->Session == WC->ctdl_pid);
 }
 
-void 
-InitModule_WHO
-(void)
-{
+void InitModule_WHO(void) {
        RegisterCTX(CTX_WHO);
 
        WebcitAddUrlHandler(HKEY("terminate_session"), "", 0, _terminate_session, 0);
 
        RegisterIterator("WHOLIST", 1, NULL, GetWholistHash, NULL, DeleteWholistHash, CTX_WHO, CTX_NONE, IT_NOFLAG);
 
-       RegisterNamespace("WHO:NAME",        0, 1, tmplput_who_username, NULL, CTX_WHO);
-       RegisterNamespace("WHO:USERAGENT",   0, 1, tmplput_who_UserAgent, NULL, CTX_WHO);
-       RegisterNamespace("WHO:ROOM",        0, 1, tmplput_who_room, NULL, CTX_WHO);
-       RegisterNamespace("WHO:HOST",        0, 1, tmplput_who_host, NULL, CTX_WHO);
-       RegisterNamespace("WHO:REALROOM",    0, 1, tmplput_who_realroom, NULL, CTX_WHO);
-       RegisterNamespace("WHO:REALHOST",    0, 1, tmplput_who_realhost, NULL, CTX_WHO);
-       RegisterNamespace("WHO:LASTACTIVE",  0, 1, tmplput_who_lastactive, NULL, CTX_WHO);
-       RegisterNamespace("WHO:IDLESINCE",   0, 1, tmplput_who_idlesince, NULL, CTX_WHO);
-       RegisterNamespace("WHO:SESSION",     0, 1, tmplput_who_session, NULL, CTX_WHO);
-       RegisterNamespace("WHO:NSESSIONS",   0, 1, tmplput_who_nsessions, NULL, CTX_WHO);
-       RegisterNamespace("WHO:NSESSIONS",   0, 1, tmplput_who_nsessions, NULL, CTX_WHO);
-
-       RegisterConditional("WHO:IDLE",      1, conditional_who_idle, CTX_WHO);
+       RegisterNamespace("WHO:NAME", 0, 1, tmplput_who_username, NULL, CTX_WHO);
+       RegisterNamespace("WHO:USERAGENT", 0, 1, tmplput_who_UserAgent, NULL, CTX_WHO);
+       RegisterNamespace("WHO:ROOM", 0, 1, tmplput_who_room, NULL, CTX_WHO);
+       RegisterNamespace("WHO:HOST", 0, 1, tmplput_who_host, NULL, CTX_WHO);
+       RegisterNamespace("WHO:REALROOM", 0, 1, tmplput_who_realroom, NULL, CTX_WHO);
+       RegisterNamespace("WHO:REALHOST", 0, 1, tmplput_who_realhost, NULL, CTX_WHO);
+       RegisterNamespace("WHO:LASTACTIVE", 0, 1, tmplput_who_lastactive, NULL, CTX_WHO);
+       RegisterNamespace("WHO:IDLESINCE", 0, 1, tmplput_who_idlesince, NULL, CTX_WHO);
+       RegisterNamespace("WHO:SESSION", 0, 1, tmplput_who_session, NULL, CTX_WHO);
+       RegisterNamespace("WHO:NSESSIONS", 0, 1, tmplput_who_nsessions, NULL, CTX_WHO);
+       RegisterNamespace("WHO:NSESSIONS", 0, 1, tmplput_who_nsessions, NULL, CTX_WHO);
+
+       RegisterConditional("WHO:IDLE", 1, conditional_who_idle, CTX_WHO);
        RegisterConditional("WHO:NSESSIONS", 1, conditional_who_nsessions, CTX_WHO);
-       RegisterConditional("WHO:ISME",      1, conditional_who_isme, CTX_WHO);
-       RegisterConditional("WHO:REALROOM",  1, conditional_who_realroom, CTX_WHO);
-       RegisterConditional("WHO:REALHOST",  1, conditional_who_realhost, CTX_WHO);
+       RegisterConditional("WHO:ISME", 1, conditional_who_isme, CTX_WHO);
+       RegisterConditional("WHO:REALROOM", 1, conditional_who_realroom, CTX_WHO);
+       RegisterConditional("WHO:REALHOST", 1, conditional_who_realhost, CTX_WHO);
 }
index 390bf3cbea7e84203eca49ded48c5186552a05e5..c4b5736ccdef3aae5b26762ce91b61ebdb0fecf9 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Functions pertaining to rooms with a wiki view
  *
@@ -18,8 +19,7 @@
 /* 
  * Convert a string to something suitable as a wiki index
  */
-void str_wiki_index(StrBuf *s)
-{
+void str_wiki_index(StrBuf * s) {
        StrBufSanitizeAscii(s, '_');
        StrBufLowerCase(s);
 }
@@ -30,14 +30,13 @@ void str_wiki_index(StrBuf *s)
  * "rev" may be set to an empty string to display the current version.
  * "do_revert" may be set to nonzero to perform a reversion to the specified version.
  */
-void display_wiki_page_backend(StrBuf *pagename, char *rev, int do_revert)
-{
+void display_wiki_page_backend(StrBuf * pagename, char *rev, int do_revert) {
        const StrBuf *Mime;
        long msgnum = (-1L);
        char buf[256];
 
        if (WC->CurRoom.view != VIEW_WIKI) {
-               wc_printf(_("'%s' is not a Wiki room."), ChrPtr(WC->CurRoom.name) );
+               wc_printf(_("'%s' is not a Wiki room."), ChrPtr(WC->CurRoom.name));
                return;
        }
 
@@ -49,7 +48,7 @@ void display_wiki_page_backend(StrBuf *pagename, char *rev, int do_revert)
 
        if ((rev != NULL) && (strlen(rev) > 0)) {
                /* read an older revision */
-               serv_printf("WIKI rev|%s|%s|%s", ChrPtr(pagename), rev, (do_revert ? "revert" : "fetch") );
+               serv_printf("WIKI rev|%s|%s|%s", ChrPtr(pagename), rev, (do_revert ? "revert" : "fetch"));
                serv_getln(buf, sizeof buf);
                if (buf[0] == '2') {
                        msgnum = extract_long(&buf[4], 0);
@@ -72,8 +71,7 @@ void display_wiki_page_backend(StrBuf *pagename, char *rev, int do_revert)
 /*
  * Display a specific page from a wiki room
  */
-void display_wiki_page(void)
-{
+void display_wiki_page(void) {
        StrBuf *pagename;
        char rev[128];
        int do_revert = 0;
@@ -91,8 +89,7 @@ void display_wiki_page(void)
 /*
  * Display the revision history for a wiki page (template callback)
  */
-void tmplput_display_wiki_history(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_display_wiki_history(StrBuf * Target, WCTemplputParams * TP) {
        StrBuf *pagename;
        StrBuf *Buf;
        int row = 0;
@@ -116,13 +113,13 @@ void tmplput_display_wiki_history(StrBuf *Target, WCTemplputParams *TP)
                wc_printf("<th>%s</th>", _("Date"));
                wc_printf("<th>%s</th>", _("Author"));
 
-               while((StrBuf_ServGetln(Buf) >= 0) &&  strcmp(ChrPtr(Buf), "000")) {
+               while ((StrBuf_ServGetln(Buf) >= 0) && strcmp(ChrPtr(Buf), "000")) {
 
                        rev_date = extract_long(ChrPtr(Buf), 1);
                        webcit_fmt_date(rev_date_displayed, sizeof rev_date_displayed, rev_date, DATEFMT_FULL);
                        StrBufExtract_token(author, Buf, 2, '|');
 
-                       wc_printf("<tr bgcolor=\"%s\">", ((row%2) ? "#FFFFFF" : "#DDDDDD"));
+                       wc_printf("<tr bgcolor=\"%s\">", ((row % 2) ? "#FFFFFF" : "#DDDDDD"));
                        wc_printf("<td>%s</td><td>", rev_date_displayed);
                        wc_printf("<a href=\"showuser?who=");
                        urlescputs(ChrPtr(author));
@@ -132,23 +129,22 @@ void tmplput_display_wiki_history(StrBuf *Target, WCTemplputParams *TP)
 
                        if (row == 0) {
                                wc_printf("<td><a href=\"wiki?page=%s", bstr("page"));
-                               wc_printf("?go="); urlescputs(ChrPtr(WC->CurRoom.name));
+                               wc_printf("?go=");
+                               urlescputs(ChrPtr(WC->CurRoom.name));
                                wc_printf("\">%s</a></td>", _("(show)"));
                                wc_printf("<td>(%s)</td>", _("Current version"));
                        }
 
                        else {
-                               wc_printf("<td><a href=\"wiki?page=%s?rev=%s",
-                                       bstr("page"),
-                                       ChrPtr(rev_uuid)
-                               );
-                               wc_printf("?go="); urlescputs(ChrPtr(WC->CurRoom.name));
+                               wc_printf("<td><a href=\"wiki?page=%s?rev=%s", bstr("page"), ChrPtr(rev_uuid)
+                                   );
+                               wc_printf("?go=");
+                               urlescputs(ChrPtr(WC->CurRoom.name));
                                wc_printf("\">%s</a></td>", _("(show)"));
-                               wc_printf("<td><a href=\"javascript:GetLoggedInFirst(encodeURIComponent('wiki?page=%s?rev=%s?revert=1'))\">%s</a></td>",
-                                       bstr("page"),
-                                       ChrPtr(rev_uuid),
-                                       _("(revert)")
-                               );
+                               wc_printf
+                                   ("<td><a href=\"javascript:GetLoggedInFirst(encodeURIComponent('wiki?page=%s?rev=%s?revert=1'))\">%s</a></td>",
+                                    bstr("page"), ChrPtr(rev_uuid), _("(revert)")
+                                   );
                        }
                        wc_printf("</tr>\n");
 
@@ -180,8 +176,7 @@ void tmplput_display_wiki_history(StrBuf *Target, WCTemplputParams *TP)
 /*
  * Display the revision history for a wiki page
  */
-void display_wiki_history(void)
-{
+void display_wiki_history(void) {
        output_headers(1, 1, 1, 0, 0, 0);
        do_template("wiki_history");
        wDumpContent(1);
@@ -191,8 +186,7 @@ void display_wiki_history(void)
 /*
  * Display a list of all pages in a Wiki room (template callback)
  */
-void tmplput_display_wiki_pagelist(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_display_wiki_pagelist(StrBuf * Target, WCTemplputParams * TP) {
        StrBuf *Buf;
        int row = 0;
 
@@ -200,7 +194,7 @@ void tmplput_display_wiki_pagelist(StrBuf *Target, WCTemplputParams *TP)
                serv_printf("MSGS SEARCH|%s||4", bstr("query"));        /* search-reduced list */
        }
        else {
-               serv_printf("MSGS ALL|||4");                            /* full list */
+               serv_printf("MSGS ALL|||4");    /* full list */
        }
 
        Buf = NewStrBuf();
@@ -211,11 +205,11 @@ void tmplput_display_wiki_pagelist(StrBuf *Target, WCTemplputParams *TP)
                wc_printf("<table class=\"wiki_pagelist_background\">");
                wc_printf("<th>%s</th>", _("Page title"));
 
-               while((StrBuf_ServGetln(Buf) >= 0) && strcmp(ChrPtr(Buf), "000")) {
+               while ((StrBuf_ServGetln(Buf) >= 0) && strcmp(ChrPtr(Buf), "000")) {
                        StrBufExtract_token(pagetitle, Buf, 1, '|');
 
-                       if (!bmstrcasestr((char *)ChrPtr(pagetitle), "_HISTORY_")) {    /* no history pages */
-                               wc_printf("<tr bgcolor=\"%s\">", ((row%2) ? "#FFFFFF" : "#DDDDDD"));
+                       if (!bmstrcasestr((char *) ChrPtr(pagetitle), "_HISTORY_")) {   /* no history pages */
+                               wc_printf("<tr bgcolor=\"%s\">", ((row % 2) ? "#FFFFFF" : "#DDDDDD"));
                                wc_printf("<td><a href=\"wiki?page=");
                                urlescputs(ChrPtr(pagetitle));
                                wc_printf("\">");
@@ -236,16 +230,14 @@ void tmplput_display_wiki_pagelist(StrBuf *Target, WCTemplputParams *TP)
 /*
  * Display a list of all pages in a Wiki room.  Search requests in a Wiki room also go here.
  */
-void display_wiki_pagelist(void)
-{
+void display_wiki_pagelist(void) {
        output_headers(1, 1, 1, 0, 0, 0);
        do_template("wiki_pagelist");
        wDumpContent(1);
 }
 
 
-int wiki_Cleanup(void **ViewSpecific)
-{
+int wiki_Cleanup(void **ViewSpecific) {
        StrBuf *pagename;
        pagename = NewStrBufDup(sbstr("page"));
        display_wiki_page_backend(pagename, "", 0);
@@ -254,8 +246,7 @@ int wiki_Cleanup(void **ViewSpecific)
 }
 
 
-int ConditionalHaveWikiPage(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalHaveWikiPage(StrBuf * Target, WCTemplputParams * TP) {
        const char *page;
        const char *pch;
        long len;
@@ -266,54 +257,34 @@ int ConditionalHaveWikiPage(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-int ConditionalHavewikiType(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalHavewikiType(StrBuf * Target, WCTemplputParams * TP) {
        const char *pch;
        long len;
 
        GetTemplateTokenString(Target, TP, 2, &pch, &len);
-       return bmstrcasestr((char *)ChrPtr(WC->Hdr->HR.ReqLine), pch) != NULL;
+       return bmstrcasestr((char *) ChrPtr(WC->Hdr->HR.ReqLine), pch) != NULL;
 }
 
 
-int wiki_PrintHeaderPage(SharedMessageStatus *Stat, void **ViewSpecific)
-{
+int wiki_PrintHeaderPage(SharedMessageStatus * Stat, void **ViewSpecific) {
        /* this function was intentionaly left empty. */
        return 0;
 }
 
-int wiki_GetParamsGetServerCall(SharedMessageStatus *Stat, 
-                               void **ViewSpecific, 
-                               long oper, 
-                               char *cmd, 
-                               long len,
-                               char *filter,
-                               long flen)
-{
+int wiki_GetParamsGetServerCall(SharedMessageStatus * Stat,
+                               void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen) {
        if (oper == do_search)
                display_wiki_pagelist();
-       else 
+       else
                http_redirect("wiki?page=home");
 
        return 300;
 }
 
 
-void 
-InitModule_WIKI
-(void)
-{
-       RegisterReadLoopHandlerset(
-               VIEW_WIKI,
-               wiki_GetParamsGetServerCall,
-               wiki_PrintHeaderPage,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               wiki_Cleanup,
-               NULL
-       );
+void InitModule_WIKI(void) {
+       RegisterReadLoopHandlerset(VIEW_WIKI,
+                                  wiki_GetParamsGetServerCall, wiki_PrintHeaderPage, NULL, NULL, NULL, NULL, wiki_Cleanup, NULL);
 
        WebcitAddUrlHandler(HKEY("wiki"), "", 0, display_wiki_page, 0);
        WebcitAddUrlHandler(HKEY("wiki_history"), "", 0, display_wiki_history, 0);