Did a little more style updating. Realized that I started this thing in 2018 and...
authorArt Cancro <ajc@citadel.org>
Mon, 27 Sep 2021 23:27:43 +0000 (19:27 -0400)
committerArt Cancro <ajc@citadel.org>
Mon, 27 Sep 2021 23:27:43 +0000 (19:27 -0400)
webcit-ng/admin_functions.c
webcit-ng/caldav_reports.c
webcit-ng/ctdlclient.c
webcit-ng/ctdlfunctions.c
webcit-ng/forum_view.c
webcit-ng/html2html.c
webcit-ng/main.c
webcit-ng/webcit.h

index 27b93cc05e478c3711db8a8dff76772fb0a700aa..551c06d13f9c3e8be06d531b1bd1a63b6dd84e55 100644 (file)
 #include "webcit.h"
 
 
-/*
- * /ctdl/a/login is called when a user is trying to log in
- */
-void try_login(struct http_transaction *h, struct ctdlsession *c)
-{
+// /ctdl/a/login is called when a user is trying to log in
+void try_login(struct http_transaction *h, struct ctdlsession *c) {
        char buf[1024];
        char auth[AUTH_MAX];
        char username[256];
@@ -50,11 +47,8 @@ void try_login(struct http_transaction *h, struct ctdlsession *c)
 }
 
 
-/*
- * /ctdl/a/logout is called when a user is trying to log out.   Don't use this as an ajax.
- */
-void logout(struct http_transaction *h, struct ctdlsession *c)
-{
+// /ctdl/a/logout is called when a user is trying to log out.   Don't use this as an ajax.
+void logout(struct http_transaction *h, struct ctdlsession *c) {
        char buf[1024];
        char auth[AUTH_MAX];
        char username[256];
@@ -71,11 +65,8 @@ void logout(struct http_transaction *h, struct ctdlsession *c)
 }
 
 
-/*
- * /ctdl/a/whoami returns the name of the currently logged in user, or an empty string if not logged in
- */
-void whoami(struct http_transaction *h, struct ctdlsession *c)
-{
+// /ctdl/a/whoami returns the name of the currently logged in user, or an empty string if not logged in
+void whoami(struct http_transaction *h, struct ctdlsession *c) {
        h->response_code = 200;
        h->response_string = strdup("OK");
        add_response_header(h, strdup("Content-type"), strdup("text/plain"));
@@ -84,11 +75,8 @@ void whoami(struct http_transaction *h, struct ctdlsession *c)
 }
 
 
-/*
- * Dispatcher for paths starting with /ctdl/a/
- */
-void ctdl_a(struct http_transaction *h, struct ctdlsession *c)
-{
+// Dispatcher for paths starting with /ctdl/a/
+void ctdl_a(struct http_transaction *h, struct ctdlsession *c) {
        if (!strcasecmp(h->uri, "/ctdl/a/login")) {     // log in
                try_login(h, c);
                return;
index 26fbec8d91dea15a5e6e28ad13234660d687173e..b5ae8744abd9bf4ae6ea3529e02f3806d9b4d125 100644 (file)
@@ -17,9 +17,7 @@
 #include "webcit.h"
 
 
-/*
- * A CalDAV REPORT can only be one type.  This is stored in the report_type member.
- */
+// A CalDAV REPORT can only be one type.  This is stored in the report_type member.
 enum cr_type {
        cr_calendar_query,
        cr_calendar_multiget,
@@ -27,11 +25,9 @@ enum cr_type {
 };
 
 
-/*
- * Data type for CalDAV Report Parameters.
- * As we slog our way through the XML we learn what the client is asking for
- * and build up the contents of this data type.
- */
+// Data type for CalDAV Report Parameters.
+// As we slog our way through the XML we learn what the client is asking for
+// and build up the contents of this data type.
 struct cr_parms {
        int tag_nesting_level;          // not needed, just kept for pretty-printing
        enum cr_type report_type;       // which RFC4791 section 7 REPORT are we generating
@@ -40,11 +36,8 @@ struct cr_parms {
 };
 
 
-/*
- * XML parser callback
- */
-void caldav_xml_start(void *data, const char *el, const char **attr)
-{
+// XML parser callback
+void caldav_xml_start(void *data, const char *el, const char **attr) {
        struct cr_parms *crp = (struct cr_parms *) data;
        int i;
 
@@ -70,11 +63,8 @@ void caldav_xml_start(void *data, const char *el, const char **attr)
 }
 
 
-/*
- * XML parser callback
- */
-void caldav_xml_end(void *data, const char *el)
-{
+// XML parser callback
+void caldav_xml_end(void *data, const char *el) {
        struct cr_parms *crp = (struct cr_parms *) data;
        --crp->tag_nesting_level;
 
@@ -99,11 +89,8 @@ void caldav_xml_end(void *data, const char *el)
 }
 
 
-/*
- * XML parser callback
- */
-void caldav_xml_chardata(void *data, const XML_Char * s, int len)
-{
+// XML parser callback
+void caldav_xml_chardata(void *data, const XML_Char * s, int len) {
        struct cr_parms *crp = (struct cr_parms *) data;
 
        if (crp->Chardata == NULL) {
@@ -116,15 +103,12 @@ void caldav_xml_chardata(void *data, const XML_Char * s, int len)
 }
 
 
-/*
- * Called by caldav_response() to fetch a message (by number) in the current room,
- * and return only the icalendar data as a StrBuf.  Returns NULL if not found.
- *
- * NOTE: this function expects that "MSGP text/calendar" was issued at the beginning
- * of a REPORT operation to set our preferred MIME type to calendar data.
- */
-StrBuf *fetch_ical(struct ctdlsession * c, long msgnum)
-{
+// Called by caldav_response() to fetch a message (by number) in the current room,
+// and return only the icalendar data as a StrBuf.  Returns NULL if not found.
+//
+// NOTE: this function expects that "MSGP text/calendar" was issued at the beginning
+// of a REPORT operation to set our preferred MIME type to calendar data.
+StrBuf *fetch_ical(struct ctdlsession * c, long msgnum) {
        char buf[1024];
        StrBuf *Buf = NULL;
 
@@ -165,12 +149,9 @@ StrBuf *fetch_ical(struct ctdlsession * c, long msgnum)
 }
 
 
-/*
- * Called by caldav_report() to output a single item.
- * Our policy is to throw away the list of properties the client asked for, and just send everything.
- */
-void caldav_response(struct http_transaction *h, struct ctdlsession *c, StrBuf * ReportOut, StrBuf * ThisHref)
-{
+// Called by caldav_report() to output a single item.
+// Our policy is to throw away the list of properties the client asked for, and just send everything.
+void caldav_response(struct http_transaction *h, struct ctdlsession *c, StrBuf * ReportOut, StrBuf * ThisHref) {
        long msgnum;
        StrBuf *Caldata = NULL;
        char *euid;
@@ -226,13 +207,10 @@ void caldav_response(struct http_transaction *h, struct ctdlsession *c, StrBuf *
 }
 
 
-/*
- * Called by report_the_room_itself() in room_functions.c when a CalDAV REPORT method
- * is requested on a calendar room.  We fire up an XML Parser to decode the request and
- * hopefully produce the correct output.
- */
-void caldav_report(struct http_transaction *h, struct ctdlsession *c)
-{
+// Called by report_the_room_itself() in room_functions.c when a CalDAV REPORT method
+// is requested on a calendar room.  We fire up an XML Parser to decode the request and
+// hopefully produce the correct output.
+void caldav_report(struct http_transaction *h, struct ctdlsession *c) {
        struct cr_parms crp;
        char buf[1024];
 
@@ -257,16 +235,12 @@ void caldav_report(struct http_transaction *h, struct ctdlsession *c)
                crp.Chardata = NULL;
        }
 
-       /*
-        * We're going to make a lot of MSG4 calls, and the preferred MIME type we want is "text/calendar".
-        * The iCalendar standard is mature now, and we are no longer interested in text/x-vcal or application/ics.
-        */
+       // We're going to make a lot of MSG4 calls, and the preferred MIME type we want is "text/calendar".
+       // The iCalendar standard is mature now, and we are no longer interested in text/x-vcal or application/ics.
        ctdl_printf(c, "MSGP text/calendar");
        ctdl_readline(c, buf, sizeof buf);
 
-       /*
-        * Now begin the REPORT.
-        */
+       // Now begin the REPORT.
        syslog(LOG_DEBUG, "CalDAV REPORT type is: %d", crp.report_type);
        StrBuf *ReportOut = NewStrBuf();
        StrBufAppendPrintf(ReportOut, "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
index ddbc0926a7a294f1688ccdc0a116134dc8e8ff48..eb74598e4613dcd640cb013098ee23fdcb745470 100644 (file)
@@ -19,12 +19,9 @@ struct ctdlsession *cpool = NULL;                            // linked list of connections to the Citade
 pthread_mutex_t cpool_mutex = PTHREAD_MUTEX_INITIALIZER;       // Lock it before modifying
 
 
-/*
- * Read a specific number of bytes of binary data from the Citadel server.
- * Returns the number of bytes read or -1 for error.
- */
-int ctdl_read_binary(struct ctdlsession *ctdl, char *buf, int bytes_requested)
-{
+// Read a specific number of bytes of binary data from the Citadel server.
+// Returns the number of bytes read or -1 for error.
+int ctdl_read_binary(struct ctdlsession *ctdl, char *buf, int bytes_requested) {
        int bytes_read = 0;
        int c = 0;
 
@@ -40,12 +37,9 @@ int ctdl_read_binary(struct ctdlsession *ctdl, char *buf, int bytes_requested)
 }
 
 
-/*
- * Read a newline-terminated line of text from the Citadel server.
- * Returns the string length or -1 for error.
- */
-int ctdl_readline(struct ctdlsession *ctdl, char *buf, int maxbytes)
-{
+// Read a newline-terminated line of text from the Citadel server.
+// Returns the string length or -1 for error.
+int ctdl_readline(struct ctdlsession *ctdl, char *buf, int maxbytes) {
        int len = 0;
        int c = 0;
 
@@ -73,13 +67,10 @@ int ctdl_readline(struct ctdlsession *ctdl, char *buf, int maxbytes)
 }
 
 
-/*
- * Read lines of text from the Citadel server until a 000 terminator is received.
- * Implemented in terms of ctdl_readline() and is therefore transparent...
- * Returns a newly allocated StrBuf or NULL for error.
- */
-StrBuf *ctdl_readtextmsg(struct ctdlsession * ctdl)
-{
+// Read lines of text from the Citadel server until a 000 terminator is received.
+// Implemented in terms of ctdl_readline() and is therefore transparent...
+// Returns a newly allocated StrBuf or NULL for error.
+StrBuf *ctdl_readtextmsg(struct ctdlsession * ctdl) {
        char buf[1024];
        StrBuf *sj = NewStrBuf();
        if (!sj) {
@@ -94,21 +85,15 @@ StrBuf *ctdl_readtextmsg(struct ctdlsession * ctdl)
 }
 
 
-/*
- * Write to the Citadel server.  For now we're just wrapping write() in case we
- * need to add anything else later.
- */
-ssize_t ctdl_write(struct ctdlsession * ctdl, const void *buf, size_t count)
-{
+// Write to the Citadel server.  For now we're just wrapping write() in case we
+// need to add anything else later.
+ssize_t ctdl_write(struct ctdlsession * ctdl, const void *buf, size_t count) {
        return write(ctdl->sock, buf, count);
 }
 
 
-/*
- * printf() type function to send data to the Citadel Server.
- */
-void ctdl_printf(struct ctdlsession *ctdl, const char *format, ...)
-{
+// printf() type function to send data to the Citadel Server.
+void ctdl_printf(struct ctdlsession *ctdl, const char *format, ...) {
        va_list arg_ptr;
        StrBuf *Buf = NewStrBuf();
 
@@ -123,11 +108,8 @@ void ctdl_printf(struct ctdlsession *ctdl, const char *format, ...)
 }
 
 
-/*
- * Client side - connect to a unix domain socket
- */
-int uds_connectsock(char *sockpath)
-{
+// Client side - connect to a unix domain socket
+int uds_connectsock(char *sockpath) {
        struct sockaddr_un addr;
        int s;
 
@@ -150,11 +132,8 @@ int uds_connectsock(char *sockpath)
 }
 
 
-/*
- * TCP client - connect to a host/port 
- */
-int tcp_connectsock(char *host, char *service)
-{
+// TCP client - connect to a host/port 
+int tcp_connectsock(char *host, char *service) {
        struct in6_addr serveraddr;
        struct addrinfo hints;
        struct addrinfo *res = NULL;
@@ -174,22 +153,20 @@ int tcp_connectsock(char *host, char *service)
        hints.ai_family = AF_UNSPEC;
        hints.ai_socktype = SOCK_STREAM;
 
-       /*
-        * Handle numeric IPv4 and IPv6 addresses
-        */
+       // Handle numeric IPv4 and IPv6 addresses
        rc = inet_pton(AF_INET, host, &serveraddr);
-       if (rc == 1) {          /* dotted quad */
+       if (rc == 1) {          // dotted quad
                hints.ai_family = AF_INET;
                hints.ai_flags |= AI_NUMERICHOST;
        } else {
                rc = inet_pton(AF_INET6, host, &serveraddr);
-               if (rc == 1) {  /* IPv6 address */
+               if (rc == 1) {  // IPv6 address
                        hints.ai_family = AF_INET6;
                        hints.ai_flags |= AI_NUMERICHOST;
                }
        }
 
-       /* Begin the connection process */
+       // Begin the connection process
 
        rc = getaddrinfo(host, service, &hints, &res);
        if (rc != 0) {
@@ -198,9 +175,7 @@ int tcp_connectsock(char *host, char *service)
                return (-1);
        }
 
-       /*
-        * Try all available addresses until we connect to one or until we run out.
-        */
+       // Try all available addresses until we connect to one or until we run out.
        for (ai = res; ai != NULL; ai = ai->ai_next) {
 
                if (ai->ai_family == AF_INET)
@@ -245,12 +220,9 @@ int tcp_connectsock(char *host, char *service)
 }
 
 
-/*
- * Extract from the headers, the username and password the client is attempting to use.
- * This could be HTTP AUTH or it could be in the cookies.
- */
-void extract_auth(struct http_transaction *h, char *authbuf, int authbuflen)
-{
+// Extract from the headers, the username and password the client is attempting to use.
+// This could be HTTP AUTH or it could be in the cookies.
+void extract_auth(struct http_transaction *h, char *authbuf, int authbuflen) {
        if (authbuf == NULL)
                return;
        authbuf[0] = 0;
@@ -282,16 +254,13 @@ void extract_auth(struct http_transaction *h, char *authbuf, int authbuflen)
 }
 
 
-/*
- * Log in to the Citadel server.  Returns 0 on success or nonzero on error.
- *
- * 'auth' should be a base64-encoded "username:password" combination (like in http-auth)
- *
- * If 'resultbuf' is not NULL, it should be a buffer of at least 1024 characters,
- * and will be filled with the result from a Citadel server command.
- */
-int login_to_citadel(struct ctdlsession *c, char *auth, char *resultbuf)
-{
+// Log in to the Citadel server.  Returns 0 on success or nonzero on error.
+//
+// 'auth' should be a base64-encoded "username:password" combination (like in http-auth)
+//
+// If 'resultbuf' is not NULL, it should be a buffer of at least 1024 characters,
+// and will be filled with the result from a Citadel server command.
+int login_to_citadel(struct ctdlsession *c, char *auth, char *resultbuf) {
        char localbuf[1024];
        char *buf;
        int buflen;
@@ -300,7 +269,8 @@ int login_to_citadel(struct ctdlsession *c, char *auth, char *resultbuf)
 
        if (resultbuf != NULL) {
                buf = resultbuf;
-       } else {
+       }
+       else {
                buf = localbuf;
        }
 
@@ -331,11 +301,8 @@ int login_to_citadel(struct ctdlsession *c, char *auth, char *resultbuf)
 }
 
 
-/*
- * Hunt for, or create, a connection to our Citadel Server
- */
-struct ctdlsession *connect_to_citadel(struct http_transaction *h)
-{
+// Hunt for, or create, a connection to our Citadel Server
+struct ctdlsession *connect_to_citadel(struct http_transaction *h) {
        struct ctdlsession *cptr = NULL;
        struct ctdlsession *my_session = NULL;
        int is_new_session = 0;
@@ -411,11 +378,8 @@ struct ctdlsession *connect_to_citadel(struct http_transaction *h)
 }
 
 
-/*
- * Release our Citadel Server connection back into the pool.
- */
-void disconnect_from_citadel(struct ctdlsession *ctdl)
-{
+// Release our Citadel Server connection back into the pool.
+void disconnect_from_citadel(struct ctdlsession *ctdl) {
        pthread_mutex_lock(&cpool_mutex);
        ctdl->is_bound = 0;
        pthread_mutex_unlock(&cpool_mutex);
index 70e394ae2dcedee6ad463611b1f378edd36618c9..0365ad498c6cea6a97d0a046d4cfad9234bd00d9 100644 (file)
 
 #include "webcit.h"
 
-
-/*
- * Delete one or more messages from the connected Citadel server.
- * This function expects the session to already be "in" the room from which the messages will be deleted.
- */
-void ctdl_delete_msgs(struct ctdlsession *c, long *msgnums, int num_msgs)
-{
+// Delete one or more messages from the connected Citadel server.
+// This function expects the session to already be "in" the room from which the messages will be deleted.
+void ctdl_delete_msgs(struct ctdlsession *c, long *msgnums, int num_msgs) {
        int i = 0;
        char buf[1024];
 
index e7c4820afafc1e37101f5685024d153f18ff2f12..4c54818584801c790a9bbed0dfd4f5d14c1fa87f 100644 (file)
@@ -27,9 +27,7 @@ struct mthread {
 
 // Commands we need to send to Citadel Server before we begin rendering forum view.
 // These are common to flat and threaded views.
-//
-void setup_for_forum_view(struct ctdlsession *c)
-{
+void setup_for_forum_view(struct ctdlsession *c) {
        char buf[1024];
        ctdl_printf(c, "MSGP text/html|text/plain");    // Declare the MIME types we know how to render
        ctdl_readline(c, buf, sizeof(buf));             // Ignore the response
@@ -39,9 +37,7 @@ void setup_for_forum_view(struct ctdlsession *c)
 
 
 // Fetch a single message and return it in JSON format for client-side rendering
-//
-void json_render_one_message(struct http_transaction *h, struct ctdlsession *c, long msgnum)
-{
+void json_render_one_message(struct http_transaction *h, struct ctdlsession *c, long msgnum) {
        StrBuf *raw_msg = NULL;
        StrBuf *sanitized_msg = NULL;
        char buf[1024];
index f4f9e077e18df5370ab3a00c19860a1efec0411f..4eaca438c01d3b99f331625f49cebfa70438f329 100644 (file)
 #include "webcit.h"
 
 
-/*
- * Strip surrounding single or double quotes from a string.
- */
-void stripquotes(char *s)
-{
+// Strip surrounding single or double quotes from a string.
+void stripquotes(char *s) {
        int len;
 
        if (!s)
@@ -38,15 +35,12 @@ void stripquotes(char *s)
 }
 
 
-/*
- * Check to see if a META tag has overridden the declared MIME character set.
- *
- * charset             Character set name (left unchanged if we don't do anything)
- * 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)
-{
+// Check to see if a META tag has overridden the declared MIME character set.
+//
+// charset             Character set name (left unchanged if we don't do anything)
+// 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) {
        char *ptr;
        char buf[64];
 
@@ -69,18 +63,16 @@ void extract_charset_from_meta(char *charset, char *meta_http_equiv, char *meta_
        if (!strncasecmp(buf, "charset=", 8)) {
                strcpy(charset, &buf[8]);
 
-               /*
-                * The brain-damaged webmail program in Microsoft Exchange declares
-                * a charset of "unicode" when they really mean "UTF-8".  GNU iconv
-                * treats "unicode" as an alias for "UTF-16" so we have to manually
-                * fix this here, otherwise messages generated in Exchange webmail
-                * show up as a big pile of weird characters.
-                */
+               // The brain-damaged webmail program in Microsoft Exchange declares
+               // a charset of "unicode" when they really mean "UTF-8".  GNU iconv
+               // treats "unicode" as an alias for "UTF-16" so we have to manually
+               // fix this here, otherwise messages generated in Exchange webmail
+               // show up as a big pile of weird characters.
                if (!strcasecmp(charset, "unicode")) {
                        strcpy(charset, "UTF-8");
                }
 
-               /* Remove wandering punctuation */
+               // Remove wandering punctuation
                if ((ptr = strchr(charset, '\"')))
                        *ptr = 0;
                striplt(charset);
@@ -88,14 +80,10 @@ void extract_charset_from_meta(char *charset, char *meta_http_equiv, char *meta_
 }
 
 
-/*
- * Sanitize and enhance an HTML message for display.
- * Also convert weird character sets to UTF-8 if necessary.
- * Also fixup img src="cid:..." type inline images to fetch the image
- *
- */
-StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomname, long msgnum, StrBuf *Source)
-{
+// Sanitize and enhance an HTML message for display.
+// Also convert weird character sets to UTF-8 if necessary.
+// Also fixup img src="cid:..." type inline images to fetch the image
+StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomname, long msgnum, StrBuf *Source) {
        char buf[SIZ];
        char *msg;
        char *ptr;
@@ -116,11 +104,11 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
        StrBuf *BodyArea = NULL;
 
        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       */
+       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
 
        StrBuf *Target = NewStrBuf();
        if (Target == NULL) {
@@ -134,14 +122,14 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
        msg = (char *) ChrPtr(Source);
        buffer_length = content_length;
 
-       /* Do a first pass to isolate the message body */
+       // Do a first pass to isolate the message body
        ptr = msg + 1;
        msgstart = msg;
        msgend = &msg[content_length];
 
        while (ptr < msgend) {
 
-               /* Advance to next tag */
+               // Advance to next tag
                ptr = strchr(ptr, '<');
                if ((ptr == NULL) || (ptr >= msgend))
                        break;
@@ -149,12 +137,10 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
                if ((ptr == NULL) || (ptr >= msgend))
                        break;
 
-               /*
-                *  Look for META tags.  Some messages (particularly in
-                *  Asian locales) illegally declare a message's character
-                *  set in the HTML instead of in the MIME headers.  This
-                *  is wrong but we have to work around it anyway.
-                */
+               //  Look for META tags.  Some messages (particularly in
+               //  Asian locales) illegally declare a message's character
+               //  set in the HTML instead of in the MIME headers.  This
+               //  is wrong but we have to work around it anyway.
                if (!strncasecmp(ptr, "META", 4)) {
 
                        char *meta_start;
@@ -193,10 +179,8 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
                        }
                }
 
-               /*
-                * Any of these tags cause everything up to and including
-                * the tag to be removed.
-                */
+               // 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))
@@ -227,11 +211,11 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
                                                while ((*cid_end != '"') && !isspace(*cid_end) && (cid_end < ptr))
                                                        cid_end++;
 
-                                               /* copy tag and attributes up to src="cid: */
+                                               // 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 */
+                                               // add in /webcit/mimepart/<msgno>/CID/ 
+                                               // trailing / stops dumb URL filters getting excited
                                                StrBufAppendPrintf(BodyArea, "/webcit/mimepart/%ld/", msgnum);
                                                StrBufAppendBufPlain(BodyArea, cid_start, cid_end - cid_start, 0);
 
@@ -248,10 +232,8 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
                        msgstart = ptr;
                }
 
-               /*
-                * Any of these tags cause everything including and following
-                * the tag to be removed.
-                */
+               // Any of these tags cause everything including and following
+               // the tag to be removed.
                if ((!strncasecmp(ptr, "/HTML", 5)) || (!strncasecmp(ptr, "/BODY", 5))) {
                        --ptr;
                        msgend = ptr;
@@ -264,10 +246,10 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
                strcpy(msg, msgstart);
        }
 
-       /* Now go through the message, parsing tags as necessary. */
+       // Now go through the message, parsing tags as necessary.
        converted_msg = NewStrBufPlain(NULL, content_length + 8192);
 
-       /* Convert foreign character sets to UTF-8 if necessary. */
+       // Convert foreign character sets to UTF-8 if necessary
        if ((strcasecmp(charset, "us-ascii"))
            && (strcasecmp(charset, "UTF-8"))
            && (strcasecmp(charset, ""))
@@ -298,17 +280,15 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
                        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.
                }
        }
 
-       /*
-        * 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) {
                StrBufAppendPrintf(Target, "Error %d: %s<br>%s:%d", errno, strerror(errno), __FILE__, __LINE__);
@@ -324,7 +304,7 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
        msgend = strchr(msg, 0);
        while (ptr < msgend) {
 
-               /* Try to sanitize the html of any rogue scripts */
+               // Try to sanitize the html of any rogue scripts
                if (!strncasecmp(ptr, "<script", 7)) {
                        if (scriptlevel == 0) {
                                script_start_pos = StrLength(converted_msg);
@@ -335,25 +315,25 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
                        --scriptlevel;
                }
 
-               /*
-                * Change mailto: links to WebCit mail, by replacing the
-                * link with one that points back to our mail room.  Due to
-                * the way we parse URL's, it'll even handle mailto: links
-                * that have "?subject=" in them.
-                */
+               // Change mailto: links to WebCit mail, by replacing the
+               // link with one that points back to our mail room.  Due to
+               // the way we parse URL's, it'll even handle mailto: links
+               // that have "?subject=" in them.
+               // FIXME change URL syntax for webcit-ng
                if (!strncasecmp(ptr, "<a href=\"mailto:", 16)) {
                        content_length += 64;
-                       StrBufAppendPrintf(converted_msg, "<a href=\"display_enter?force_room=_MAIL_?recp=");   // FIXME make compatible with webcit-ng
+                       StrBufAppendPrintf(converted_msg, "<a href=\"display_enter?force_room=_MAIL_?recp=");
                        ptr = &ptr[16];
                        ++alevel;
                        ++brak;
                }
-               /* Make external links open in a separate window */
+
+               // 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, '>')))) {
-                               /* open external links to new window */
+                               // open external links to new window
                                StrBufAppendPrintf(converted_msg, new_window);
                                ptr = &ptr[8];
                        } else if ((treat_as_wiki)
@@ -371,14 +351,14 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
                                ptr = &ptr[9];
                        }
                }
-               /* Fixup <img src="cid:... ...> to fetch the mime part */
+
+               // 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, '>');
                        char *src;
-                       /* FIXME - handle this situation (maybe someone opened an <img cid... 
-                        * and then ended the message)
-                        */
+                       // 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:");
                                syslog(LOG_DEBUG, "%s", ptr);
@@ -393,12 +373,12 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
                            && (cid_end = strchr(cid_start, '"'))
                            && (cid_end < tag_end)
                            ) {
-                               /* copy tag and attributes up to src="cid: */
+                               // copy tag and attributes up to src="cid:
                                StrBufAppendBufPlain(converted_msg, ptr, src - ptr, 0);
                                cid_start++;
 
-                               /* add in /webcit/mimepart/<msgnum>/CID/ 
-                                  trailing / stops dumb URL filters getting excited */
+                               // add in /webcit/mimepart/<msgnum>/CID/ 
+                               // trailing / stops dumb URL filters getting excited
                                StrBufAppendPrintf(converted_msg, " src=\"/ctdl/r/");
                                StrBufXMLEscAppend(converted_msg, NULL, roomname, strlen(roomname), 0);
                                syslog(LOG_DEBUG, "room name is '%s'", roomname);
@@ -411,12 +391,10 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
                        ptr = tag_end;
                }
 
-               /*
-                * Turn anything that looks like a URL into a real link, as long
-                * as it's not inside a tag already
-                */
+               // 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)))) {
-                       /* Find the end of the link */
+                       // Find the end of the link
                        int strlenptr;
                        linklen = 0;
 
@@ -436,7 +414,7 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
                                    || (ptr[i] == '\'')
                                    )
                                        linklen = i;
-                               /* entity tag? */
+                               // entity tag?
                                if (ptr[i] == '&') {
                                        if ((ptr[i + 2] == ';') ||
                                            (ptr[i + 3] == ';') ||
index aa674176e149a0930383de2e7c989afa4c77e6ce..2d30dabb2c928478fbbda460898efa3177c5426c 100644 (file)
 char *ctdlhost = CTDLHOST;
 char *ctdlport = CTDLPORT;
 
-/*
- * Main entry point for the web server.
- */
-int main(int argc, char **argv)
-{
+// Main entry point for the web server.
+int main(int argc, char **argv) {
        int webserver_port = WEBSERVER_PORT;
        char *webserver_interface = WEBSERVER_INTERFACE;
        int running_as_daemon = 0;
@@ -30,7 +27,7 @@ int main(int argc, char **argv)
        int a;
        char *pid_file = NULL;
 
-       /* Parse command line */
+       // Parse command line
        while ((a = getopt(argc, argv, "u:h:i:p:t:T:B:x:g:dD:G:cfsS:Z:v:")) != EOF)
                switch (a) {
                case 'u':
@@ -53,7 +50,7 @@ int main(int argc, char **argv)
                case 'x':
                case 'T':
                case 'v':
-                       /* The above options are no longer used, but ignored so old scripts don't break */
+                       // The above options are no longer used, but ignored so old scripts don't break
                        break;
                case 'i':
                        webserver_interface = optarg;
@@ -100,12 +97,12 @@ int main(int argc, char **argv)
                        ctdlport = argv[optind];
        }
 
-       /* Start the logger */
+       // Start the logger
        openlog("webcit", (running_as_daemon ? (LOG_PID) : (LOG_PID | LOG_PERROR)), LOG_DAEMON);
 
-       /* Tell 'em who's in da house */
+       // Tell 'em who's in da house
        syslog(LOG_NOTICE, "MAKE WEBCIT GREAT AGAIN!");
-       syslog(LOG_NOTICE, "Copyright (C) 1996-2020 by the citadel.org team");
+       syslog(LOG_NOTICE, "Copyright (C) 1996-2021 by the citadel.org team");
        syslog(LOG_NOTICE, " ");
        syslog(LOG_NOTICE, "This program is open source software: you can redistribute it and/or");
        syslog(LOG_NOTICE, "modify it under the terms of the GNU General Public License, version 3.");
@@ -116,14 +113,14 @@ int main(int argc, char **argv)
        syslog(LOG_NOTICE, "GNU General Public License for more details.");
        syslog(LOG_NOTICE, " ");
 
-       /* Ensure that we are linked to the correct version of libcitadel */
+       // Ensure that we are linked to the correct version of libcitadel
        if (libcitadel_version_number() < LIBCITADEL_VERSION_NUMBER) {
                syslog(LOG_INFO, " You are running libcitadel version %d", libcitadel_version_number());
                syslog(LOG_INFO, "WebCit was compiled against version %d", LIBCITADEL_VERSION_NUMBER);
                return (1);
        }
 
-       /* Go into the background if we were asked to run as a daemon */
+       // Go into the background if we were asked to run as a daemon
        if (running_as_daemon) {
                daemon(1, 0);
                if (pid_file != NULL) {
index 36f47acf72582bb5f6261ad1f240fd98eb641f1b..94bd4b8739ccbd621e3f2553a973637888c2a686 100644 (file)
@@ -1,11 +1,9 @@
-/*
- * webcit.h - "header of headers"
- *
- * Copyright (c) 1996-2018 by the citadel.org team
- *
- * This program is open source software.  You can redistribute it and/or
- * modify it under the terms of the GNU General Public License, version 3.
- */
+// webcit.h - "header of headers"
+//
+// Copyright (c) 1996-2021 by the citadel.org team
+//
+// This program is open source software.  You can redistribute it and/or
+// modify it under the terms of the GNU General Public License, version 3.
 
 #define SHOW_ME_VAPPEND_PRINTF
 
@@ -44,7 +42,7 @@
 #define _(x)   x                               // temporary hack until we add i18n back in
 //#define DEBUG_HTTP                           // uncomment to debug HTTP headers
 
-/* XML_StopParser is present in expat 2.x */
+// XML_StopParser is present in expat 2.x
 #if XML_MAJOR_VERSION > 1
 #define HAVE_XML_STOPPARSER
 #endif