Moved the remaining else blocks
authorArt Cancro <ajc@citadel.org>
Wed, 24 Nov 2021 04:44:04 +0000 (23:44 -0500)
committerArt Cancro <ajc@citadel.org>
Wed, 24 Nov 2021 04:44:04 +0000 (23:44 -0500)
19 files changed:
webcit-ng/admin_functions.c
webcit-ng/api.txt
webcit-ng/caldav_reports.c
webcit-ng/ctdl_commands.c
webcit-ng/ctdlclient.c
webcit-ng/ctdlfunctions.c
webcit-ng/forum_view.c
webcit-ng/html2html.c
webcit-ng/http.c
webcit-ng/main.c
webcit-ng/messages.c
webcit-ng/room_functions.c
webcit-ng/ssl.c
webcit-ng/static.c
webcit-ng/static/js/view_forum.js
webcit-ng/tcp_sockets.c
webcit-ng/user_functions.c
webcit-ng/util.c
webcit-ng/webserver.c

index 551c06d13f9c3e8be06d531b1bd1a63b6dd84e55..9ac3d1a1860ea516941846a9c421ef8c03e58c71 100644 (file)
@@ -1,7 +1,7 @@
 //
 // Admin functions
 //
-// Copyright (c) 1996-2018 by the citadel.org team
+// Copyright (c) 1996-2021 by the citadel.org team
 //
 // This program is open source software.  It runs great on the
 // Linux operating system (and probably elsewhere).  You can use,
index 8daab3466a256fff1e648fd31b572ef7dad4efa7..635feb3ead400ecfafd97d4c5f18baece61db8be 100644 (file)
@@ -8,7 +8,7 @@ PROPFIND        /ctdl/r/ROOMNAME/               Show a bunch of crap
 GET            /ctdl/r/ROOMNAME/               Returns information about the room (name, view, etc.) in JSON format
 GET            /ctdl/r/ROOMNAME/msgs.all       JSON array of message list in room
 GET            /ctdl/r/ROOMNAME/msgs.new       JSON array of message list in room (new messages)
-GET            /ctdl/r/ROOMNAME/MSGNUM         Retrieve the content of an individual message (message headers are HTTP headers)
+GET            /ctdl/r/ROOMNAME/MSGNUM         Retrieve the content of an individual message (FIXME: make msg headers HTTP headers)
 PUT            /ctdl/r/ROOMNAME/xxx            DAV operation to insert a new message into a room
                                                (The returned ETag will be the new message number)
 GET            /ctdl/r/ROOMNAME/MSGNUM/json    Retrieve an individual message in a room, encapsulated in JSON
index b5ae8744abd9bf4ae6ea3529e02f3806d9b4d125..e7c9687e03e26fe4517ff596d998e99ab0e427ff 100644 (file)
@@ -2,7 +2,7 @@
 // This file contains functions which handle all of the CalDAV "REPORT" queries
 // specified in RFC4791 section 7.
 //
-// Copyright (c) 2018 by the citadel.org team
+// Copyright (c) 2021 by the citadel.org team
 //
 // This program is open source software.  It runs great on the
 // Linux operating system (and probably elsewhere).  You can use,
@@ -76,7 +76,8 @@ void caldav_xml_end(void *data, const char *el) {
        if ((!strcasecmp(el, "DAV::href")) || (!strcasecmp(el, "DAV:href"))) {
                if (crp->Hrefs == NULL) {       // append crp->Chardata to crp->Hrefs
                        crp->Hrefs = NewStrBuf();
-               } else {
+               }
+               else {
                        StrBufAppendBufPlain(crp->Hrefs, HKEY("|"), 0);
                }
                StrBufAppendBuf(crp->Hrefs, crp->Chardata, 0);
@@ -121,7 +122,8 @@ StrBuf *fetch_ical(struct ctdlsession * c, long msgnum) {
        while (ctdl_readline(c, buf, sizeof(buf)), strcmp(buf, "000")) {
                if (Buf != NULL) {      // already in body
                        StrBufAppendPrintf(Buf, "%s\n", buf);
-               } else if (IsEmptyStr(buf)) {   // beginning of body
+               }
+               else if (IsEmptyStr(buf)) {     // beginning of body
                        Buf = NewStrBuf();
                }
        }
@@ -159,7 +161,8 @@ void caldav_response(struct http_transaction *h, struct ctdlsession *c, StrBuf *
        euid = strrchr(ChrPtr(ThisHref), '/');
        if (euid != NULL) {
                ++euid;
-       } else {
+       }
+       else {
                euid = (char *) ChrPtr(ThisHref);
        }
 
@@ -195,7 +198,8 @@ void caldav_response(struct http_transaction *h, struct ctdlsession *c, StrBuf *
                StrBufAppendPrintf(ReportOut, "</D:prop>");
                FreeStrBuf(&Caldata);
                Caldata = NULL;
-       } else {
+       }
+       else {
                // syslog(LOG_DEBUG, "caldav_response(%s) 404 not found", ChrPtr(ThisHref));
                StrBufAppendPrintf(ReportOut, "<D:status>");
                StrBufAppendPrintf(ReportOut, "HTTP/1.1 404 not found");
index d50885be977a8043cc88f69da48fa585ed9fed76..90c10e17cad92ba493b7a2d74a58768688c86e94 100644 (file)
@@ -1,5 +1,5 @@
 //
-// Copyright (c) 1996-2018 by the citadel.org team
+// Copyright (c) 1996-2021 by the citadel.org team
 //
 // This program is open source software.  It runs great on the
 // Linux operating system (and probably elsewhere).  You can use,
@@ -94,7 +94,8 @@ void serv_info(struct http_transaction *h, struct ctdlsession *c) {
 void ctdl_c(struct http_transaction *h, struct ctdlsession *c) {
        if (!strcasecmp(h->uri, "/ctdl/c/info")) {
                serv_info(h, c);
-       } else {
+       }
+       else {
                do_404(h);
        }
 }
index eb74598e4613dcd640cb013098ee23fdcb745470..a5a25f9e5b7f88cacb2e26c48598438cd128fa58 100644 (file)
@@ -1,7 +1,7 @@
 //
 // Functions that handle communication with a Citadel Server
 //
-// Copyright (c) 1987-2018 by the citadel.org team
+// Copyright (c) 1987-2021 by the citadel.org team
 //
 // This program is open source software.  It runs great on the
 // Linux operating system (and probably elsewhere).  You can use,
@@ -158,7 +158,8 @@ int tcp_connectsock(char *host, char *service) {
        if (rc == 1) {          // dotted quad
                hints.ai_family = AF_INET;
                hints.ai_flags |= AI_NUMERICHOST;
-       } else {
+       }
+       else {
                rc = inet_pton(AF_INET6, host, &serveraddr);
                if (rc == 1) {  // IPv6 address
                        hints.ai_family = AF_INET6;
@@ -210,7 +211,8 @@ int tcp_connectsock(char *host, char *service) {
                        }
 
                        return (s);
-               } else {
+               }
+               else {
                        syslog(LOG_WARNING, "connect() failed: %s", strerror(errno));
                        close(s);
                }
@@ -341,7 +343,8 @@ struct ctdlsession *connect_to_citadel(struct http_transaction *h) {
 
        if (my_session->sock < 3) {
                is_new_session = 1;
-       } else {                // make sure our Citadel session is still good
+       }
+       else {          // make sure our Citadel session is still good
                int test_conn;
                test_conn = ctdl_write(my_session, HKEY("NOOP\n"));
                if (test_conn < 5) {
@@ -349,7 +352,8 @@ struct ctdlsession *connect_to_citadel(struct http_transaction *h) {
                        close(my_session->sock);
                        my_session->sock = 0;
                        is_new_session = 1;
-               } else {
+               }
+               else {
                        test_conn = ctdl_readline(my_session, buf, sizeof(buf));
                        if (test_conn < 1) {
                                syslog(LOG_DEBUG, "Citadel session is broken , must reconnect");
index 0365ad498c6cea6a97d0a046d4cfad9234bd00d9..d937110b75adf10713abb302dd221a1f945c07de 100644 (file)
@@ -1,7 +1,7 @@
 //
 // These utility functions loosely make up a Citadel protocol client library.
 //
-// Copyright (c) 2016-2018 by the citadel.org team
+// Copyright (c) 2016-2021 by the citadel.org team
 //
 // This program is open source software.  It runs great on the
 // Linux operating system (and probably elsewhere).  You can use,
@@ -35,7 +35,8 @@ void ctdl_delete_msgs(struct ctdlsession *c, long *msgnums, int num_msgs) {
                        ctdl_printf(c, "%s", buf);
                        ctdl_readline(c, buf, sizeof(buf));
                        syslog(LOG_DEBUG, "%s", buf);
-               } else {
+               }
+               else {
                        strcat(buf, ",");
                }
        } while (++i < num_msgs);
index 4321a89fc4331b134a4b79869777ccc4cd6c0b22..97f8a1b28d3fabef5b7b5f9abc7a2e3ca05cc0de 100644 (file)
@@ -1,7 +1,7 @@
 //
 // Forum view (threaded/flat)
 //
-// Copyright (c) 1996-2020 by the citadel.org team
+// Copyright (c) 1996-2021 by the citadel.org team
 //
 // This program is open source software.  It runs great on the
 // Linux operating system (and probably elsewhere).  You can use,
@@ -104,7 +104,8 @@ void json_render_one_message(struct http_transaction *h, struct ctdlsession *c,
                        }
                }
                raw_msg = ctdl_readtextmsg(c);
-       } else {
+       }
+       else {
                raw_msg = NULL;
        }
 
index 0d0264a43b28ab2024b3aec5cfaae6b732f3a472..8704525bea4c73e284a3069e5e0f43163d96b607 100644 (file)
@@ -2,7 +2,7 @@
 // Output an HTML message, modifying it slightly to make sure it plays nice
 // with the rest of our web framework.
 //
-// Copyright (c) 2005-2020 by the citadel.org team
+// Copyright (c) 2005-2021 by the citadel.org team
 //
 // This program is open source software.  It runs great on the
 // Linux operating system (and probably elsewhere).  You can use,
@@ -221,8 +221,10 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
 
                                                if (ptr - cid_end > 0)
                                                        StrBufAppendBufPlain(BodyArea, cid_end + 1, ptr - cid_end, 0);
-                                       } else
+                                       }
+                                       else {
                                                StrBufAppendBufPlain(BodyArea, pBody, ptr - pBody, 0);
+                                       }
                                }
                                *ptr = '>';
                        }
@@ -274,7 +276,8 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
                        msg = osav;
                        iconv_close(ic);
                }
-       } else {
+       }
+       else {
                if (ic != (iconv_t) (-1)) {
                        StrBuf *Buf = NewStrBufPlain(NULL, StrLength(Source) + 8096);;
                        StrBufConvert(Source, Buf, &ic);
@@ -336,7 +339,8 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
                                // open external links to new window
                                StrBufAppendPrintf(converted_msg, new_window);
                                ptr = &ptr[8];
-                       } else if ((treat_as_wiki)
+                       }
+                       else if ((treat_as_wiki)
                                   && (strncasecmp(ptr, "<a href=\"wiki?", 14))
                                   && (strncasecmp(ptr, "<a href=\"dotgoto?", 17))
                                   && (strncasecmp(ptr, "<a href=\"knrooms?", 17))
@@ -346,7 +350,8 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
                                //StrBufUrlescAppend(converted_msg, "FIXME ROOM NAME", NULL);                   // FIXME make compatible with webcit-ng
                                StrBufAppendPrintf(converted_msg, "?page=");
                                ptr = &ptr[9];
-                       } else {
+                       }
+                       else {
                                StrBufAppendPrintf(converted_msg, "<a href=\"");
                                ptr = &ptr[9];
                        }
index 51d50ce503479933751ca1e2e21bf48cc388f741..a79473e79f7b8039fd05c092f2ed1f274e6de99e 100644 (file)
@@ -1,7 +1,7 @@
 //
 // This module handles HTTP transactions.
 //
-// Copyright (c) 1996-2018 by the citadel.org team
+// Copyright (c) 1996-2021 by the citadel.org team
 //
 // This program is open source software.  It runs great on the
 // Linux operating system (and probably elsewhere).  You can use,
index 2d30dabb2c928478fbbda460898efa3177c5426c..faf244beecfee27984434afd19111420597298b4 100644 (file)
@@ -1,7 +1,7 @@
 //
 // Main entry point for the program.
 //
-// Copyright (c) 1996-2020 by the citadel.org team
+// Copyright (c) 1996-2021 by the citadel.org team
 //
 // This program is open source software.  It runs great on the
 // Linux operating system (and probably elsewhere).  You can use,
index a910b1f6abb781ee1de03c2ca0a63faa6e41e086..adc4260adc5d5da5430049f902d91c65930d8636 100644 (file)
@@ -1,7 +1,7 @@
 //
 // Message base functions
 //
-// Copyright (c) 1996-2018 by the citadel.org team
+// Copyright (c) 1996-2021 by the citadel.org team
 //
 // This program is open source software.  It runs great on the
 // Linux operating system (and probably elsewhere).  You can use,
@@ -77,7 +77,8 @@ void dav_get_message(struct http_transaction *h, struct ctdlsession *c, long msg
                if (IsEmptyStr(buf) && (in_body == 0)) {
                        in_body = 1;
                        Body = NewStrBuf();
-               } else if (in_body == 0) {
+               }
+               else if (in_body == 0) {
                        char *k = buf;
                        char *v = strchr(buf, ':');
                        if (v) {
@@ -86,17 +87,20 @@ void dav_get_message(struct http_transaction *h, struct ctdlsession *c, long msg
                                striplt(v);     // we now have a key (k) and a value (v)
                                if ((!strcasecmp(k, "content-type"))    // fields which can be passed from RFC822 to HTTP as-is
                                    || (!strcasecmp(k, "date"))
-                                   ) {
+                               ) {
                                        add_response_header(h, strdup(k), strdup(v));
-                               } else if (!strcasecmp(k, "content-transfer-encoding")) {
+                               }
+                               else if (!strcasecmp(k, "content-transfer-encoding")) {
                                        if (!strcasecmp(v, "base64")) {
                                                encoding = 'b';
-                                       } else if (!strcasecmp(v, "quoted-printable")) {
+                                       }
+                                       else if (!strcasecmp(v, "quoted-printable")) {
                                                encoding = 'q';
                                        }
                                }
                        }
-               } else if ((in_body == 1) && (Body != NULL)) {
+               }
+               else if ((in_body == 1) && (Body != NULL)) {
                        StrBufAppendPrintf(Body, "%s\n", buf);
                }
        }
@@ -112,13 +116,15 @@ void dav_get_message(struct http_transaction *h, struct ctdlsession *c, long msg
                                    CtdlDecodeQuotedPrintable(h->response_body, (char *) ChrPtr(Body), StrLength(Body));
                        }
                        FreeStrBuf(&Body);
-               } else if (encoding == 'b') {
+               }
+               else if (encoding == 'b') {
                        h->response_body = malloc(StrLength(Body));
                        if (h->response_body != NULL) {
                                h->response_body_length = CtdlDecodeBase64(h->response_body, ChrPtr(Body), StrLength(Body));
                        }
                        FreeStrBuf(&Body);
-               } else {
+               }
+               else {
                        h->response_body_length = StrLength(Body);
                        h->response_body = SmashStrBuf(&Body);
                }
@@ -212,7 +218,8 @@ void dav_put_message(struct http_transaction *h, struct ctdlsession *c, char *eu
        if (old_msgnum <= 0) {
                h->response_code = 201; // We created this item for the first time.
                h->response_string = strdup("created");
-       } else {
+       }
+       else {
                h->response_code = 204; // We modified an existing item.
                h->response_string = strdup("no content");
 
index 179884d9f3ae88bde2590622467f956152dc8df1..6e081bd298a39248404323cb7a68c8764b74c2b2 100644 (file)
@@ -523,7 +523,8 @@ void ctdl_r(struct http_transaction *h, struct ctdlsession *c) {
                        //      13      (int)is_trash                   Boolean flag: 1 if this is the user's Trash folder, 0 otherwise.
                        //      14      (int)CC->room.QRflags2          More flags associated with this room
                        //      15      (long)CC->room.QRmtime          Timestamp of the last write activity in this room
-               } else {
+               }
+               else {
                        do_404(h);
                        return;
                }
index 8d33fe45f24f8cc5d9b8fd707666563321e7dd10..f1744c2bb8144586984601a71e6f7d5291a56ab9 100644 (file)
@@ -2,7 +2,7 @@
 // Functions in this module handle SSL encryption when WebCit is running
 // as an HTTPS server.
 //
-// Copyright (c) 1996-2018 by the citadel.org team
+// Copyright (c) 1996-2021 by the citadel.org team
 //
 // This program is open source software.  It runs great on the
 // Linux operating system (and probably elsewhere).  You can use,
index 8b74834244a140b9ad9b75198e40431ab3d7264e..80f506431e1a68b2ede0cf3894cf9c0bdd8ee159 100644 (file)
@@ -1,7 +1,7 @@
 //
 // Output static content
 //
-// Copyright (c) 1996-2018 by the citadel.org team
+// Copyright (c) 1996-2021 by the citadel.org team
 //
 // This program is open source software.  It runs great on the
 // Linux operating system (and probably elsewhere).  You can use,
index edf0a971ba269b3004fffe0695a7f8fa0950e6fc..fb9121b58fe35c3c5f67beabd3918f3c75577603 100644 (file)
@@ -264,8 +264,15 @@ function cancel_post(div_name) {
 
 
 // Save the posted message to the server
-function save_message(div_name, reply_to_msgnum) {
+function Xsave_message(div_name, reply_to_msgnum) {
+       msg_text = "<html><body>" + document.getElementById("ctdl-editor-body").innerHTML + "</body></html>\n";
+       m = btoa(msg_text);
+       alert(m);
+}
 
+
+// Save the posted message to the server
+function save_message(div_name, reply_to_msgnum) {
        msg_text = "<html><body>" + document.getElementById("ctdl-editor-body").innerHTML + "</body></html>\n";
        url = "/ctdl/r/" + escapeHTMLURI(current_room) + "/dummy_name_for_new_message";
 
index 1e005a546f9359ede6a333269c18b1499d323a80..4fbc427b68798b7e636c18449b41e49ec3ba1303 100644 (file)
@@ -1,7 +1,7 @@
 //
 // TCP sockets layer
 //
-// Copyright (c) 1987-2018 by the citadel.org team
+// Copyright (c) 1987-2021 by the citadel.org team
 //
 // This program is open source software.  It runs great on the
 // Linux operating system (and probably elsewhere).  You can use,
index 5f668049f89380b7bddb0d85456c322242c5432e..fbecef57c75802b3c09ecf0eb7b3653fb2308a7a 100644 (file)
@@ -1,7 +1,7 @@
 //
 // User functions
 //
-// Copyright (c) 1996-2018 by the citadel.org team
+// Copyright (c) 1996-2021 by the citadel.org team
 //
 // This program is open source software.  It runs great on the
 // Linux operating system (and probably elsewhere).  You can use,
@@ -115,7 +115,8 @@ void ctdl_u(struct http_transaction *h, struct ctdlsession *c) {
        if (num_tokens(h->uri, '/') == 5) {
                if (IsEmptyStr(buf)) {
                        the_user_itself(h, c, requested_username);      //      /ctdl/u/username/       ( same as /ctdl/u/username )
-               } else {
+               }
+               else {
                        object_in_user(h, c, requested_username);       //      /ctdl/u/username/object
                }
                return;
index 17dca336c5a2c67656a8737762a58cee4f8a40a5..66591944d2ad6f371ec9b1db715cb4eb66e0eea8 100644 (file)
@@ -1,7 +1,7 @@
 //
 // Utility functions
 //
-// Copyright (c) 1996-2018 by the citadel.org team
+// Copyright (c) 1996-2021 by the citadel.org team
 //
 // This program is open source software.  It runs great on the
 // Linux operating system (and probably elsewhere).  You can use,
index 2cf80a0caa1fb9a138586d95e003a625c0743ba2..b28a3fab2fdaf24326add528fd5c9271ef0ec621 100644 (file)
@@ -5,7 +5,7 @@
 // connections, and dispatching active connections onto a pool of worker
 // threads.
 //
-// Copyright (c) 1996-2018 by the citadel.org team
+// Copyright (c) 1996-2021 by the citadel.org team
 //
 // This program is open source software.  It runs great on the
 // Linux operating system (and probably elsewhere).  You can use,