war on old style
authorArt Cancro <ajc@citadel.org>
Wed, 9 Nov 2022 21:20:01 +0000 (16:20 -0500)
committerArt Cancro <ajc@citadel.org>
Wed, 9 Nov 2022 21:20:01 +0000 (16:20 -0500)
libcitadel/lib/stringbuf.c
libcitadel/lib/tools.c
libcitadel/lib/urlhandling.c
webcit-ng/server/util.c
webcit-ng/static/js/view_mail.js
webcit/utils.c

index 8023ab7c7166c0feb54d109a80b692188c442361..e4824cf369fd5d64ac8dfd8bf253c2b5cd0ad531 100644 (file)
@@ -517,7 +517,7 @@ int StrBufPlain(StrBuf *Buf, const char* ptr, int nChars) {
 }
 
 
-/**
+/*
  *  use strbuf as wrapper for a string constant for easy handling
  *  StringConstant a string to wrap
  *  SizeOfStrConstant should be sizeof(StringConstant)-1
@@ -540,7 +540,7 @@ StrBuf* _NewConstStrBuf(const char* StringConstant, size_t SizeOfStrConstant)
 }
 
 
-/**
+/*
  *  flush the content of a Buf; keep its struct
  *  buf Buffer to flush
  */
@@ -555,7 +555,7 @@ int FlushStrBuf(StrBuf *buf)
        return 0;
 }
 
-/**
+/*
  *  wipe the content of a Buf thoroughly (overwrite it -> expensive); keep its struct
  *  buf Buffer to wipe
  */
@@ -575,7 +575,7 @@ int FLUSHStrBuf(StrBuf *buf)
 #ifdef SIZE_DEBUG
 int hFreeDbglog = -1;
 #endif
-/**
+/*
  *  Release a Buffer
  * Its a double pointer, so it can NULL your pointer
  * so fancy SIG11 appear instead of random results
@@ -639,7 +639,7 @@ void HFreeStrBuf (void *VFreeMe) {
  *                      Simple string transformations                          *
  *******************************************************************************/
 
-/**
+/*
  *  Wrapper around atol
  */
 long StrTol(const StrBuf *Buf)
@@ -652,7 +652,7 @@ long StrTol(const StrBuf *Buf)
                return 0;
 }
 
-/**
+/*
  *  Wrapper around atoi
  */
 int StrToi(const StrBuf *Buf)
@@ -665,7 +665,7 @@ int StrToi(const StrBuf *Buf)
                return 0;
 }
 
-/**
+/*
  *  Checks to see if the string is a pure number 
  *  Buf The buffer to inspect
  * @returns 1 if its a pure number, 0, if not.
index 53151fb950565a0d0500cced540c27c86efd80a2..131cc2f7ae98f1fb83f8553ebb568921ca7a118e 100644 (file)
@@ -282,8 +282,7 @@ size_t striplt(char *buf) {
  * ch  the char to search
  * returns the number of times ch appears in st
  */
-int haschar(const char *st, int ch)
-{
+int haschar(const char *st, int ch) {
        const char *ptr;
        int b;
        b = 0;
@@ -302,8 +301,7 @@ int haschar(const char *st, int ch)
  * Determine whether the specified message number is contained within the
  * specified sequence set.
  */
-int is_msg_in_sequence_set(const char *mset, long msgnum)
-{
+int is_msg_in_sequence_set(const char *mset, long msgnum) {
        int num_sets;
        int s;
        char setstr[128], lostr[128], histr[128];
@@ -342,8 +340,7 @@ int is_msg_in_sequence_set(const char *mset, long msgnum)
  * maxlen      Size of string buffer
  * returns pointer to the source memory right after we stopped reading.
  */
-char *memreadline(char *start, char *buf, int maxlen)
-{
+char *memreadline(char *start, char *buf, int maxlen) {
        char ch;
        char *ptr;
        int len = 0;            /* tally our own length to avoid strlen() delays */
@@ -371,8 +368,7 @@ char *memreadline(char *start, char *buf, int maxlen)
  * retlen      the length of the returned string
  * returns a pointer to the source memory right after we stopped reading.
  */
-char *memreadlinelen(char *start, char *buf, int maxlen, int *retlen)
-{
+char *memreadlinelen(char *start, char *buf, int maxlen, int *retlen) {
        char ch;
        char *ptr;
        int len = 0;            /* tally our own length to avoid strlen() delays */
@@ -668,6 +664,7 @@ inline static char *_bmstrcasestr_len(char *text, size_t textlen, const char *pa
        return (NULL);
 }
 
+
 /*
  * bmstrcasestr() -- case-insensitive substring search
  *
@@ -693,8 +690,6 @@ char *bmstrcasestr_len(char *text, size_t textlen, const char *pattern, size_t p
 }
 
 
-
-
 /*
  * bmstrcasestr() -- case-insensitive substring search
  *
@@ -753,6 +748,7 @@ inline static const char *_cbmstrcasestr_len(const char *text, size_t textlen, c
        return (NULL);
 }
 
+
 /*
  * bmstrcasestr() -- case-insensitive substring search
  *
@@ -773,10 +769,12 @@ const char *cbmstrcasestr(const char *text, const char *pattern) {
        return _cbmstrcasestr_len(text, textlen, pattern, patlen);
 }
 
+
 const char *cbmstrcasestr_len(const char *text, size_t textlen, const char *pattern, size_t patlen) {
        return _cbmstrcasestr_len(text, textlen, pattern, patlen);
 }
 
+
 /*
  * Local replacement for controversial C library function that generates
  * names for temporary files.  Included to shut up compiler warnings.
@@ -796,7 +794,6 @@ void CtdlMakeTempFileName(char *name, int len) {
 }
 
 
-
 /*
  * Determine whether the specified message number is contained within the specified set.
  * Returns nonzero if the specified message number is in the specified message set string.
@@ -804,12 +801,10 @@ void CtdlMakeTempFileName(char *name, int len) {
 int is_msg_in_mset(const char *mset, long msgnum) {
        int num_sets;
        int s;
-       char setstr[SIZ], lostr[SIZ], histr[SIZ];       /* was 1024 */
+       char setstr[SIZ], lostr[SIZ], histr[SIZ];
        long lo, hi;
 
-       /*
-        * Now set it for all specified messages.
-        */
+       // Now set it for all specified messages.
        num_sets = num_tokens(mset, ',');
        for (s=0; s<num_sets; ++s) {
                extract_token(setstr, mset, s, ',', sizeof setstr);
@@ -834,12 +829,9 @@ int is_msg_in_mset(const char *mset, long msgnum) {
 }
 
 
-/*
- * searches for a pattern within a search string
- * returns position in string
- */
-int pattern2(char *search, char *patn)
-{
+// searches for a pattern within a search string
+// returns position in string
+int pattern2(char *search, char *patn) {
        int a;
        int len, plen;
        len = strlen (search);
@@ -857,8 +849,7 @@ int pattern2(char *search, char *patn)
  * buf - the string to modify
  * len - length of the string. 
  */
-void stripltlen(char *buf, int *len)
-{
+void stripltlen(char *buf, int *len) {
        int delta = 0;
        if (*len == 0) return;
        while ((*len > delta) && (isspace(buf[delta]))){
@@ -877,8 +868,7 @@ void stripltlen(char *buf, int *len)
 /*
  * Convert all whitespace characters in a supplied string to underscores
  */
-void convert_spaces_to_underscores(char *str)
-{
+void convert_spaces_to_underscores(char *str) {
        int len;
        int i;
 
@@ -896,8 +886,7 @@ void convert_spaces_to_underscores(char *str)
 /*
  * check whether the provided string needs to be qp encoded or not
  */
-int CheckEncode(const char *pch, long len, const char *pche)
-{
+int CheckEncode(const char *pch, long len, const char *pche) {
        if (pche == NULL)
                pche = pch + len;
        while (pch < pche) {
index 7d53f9bdb83701b20f597ae7e49304335bbdea3d..db879dcaf971f3185b574d7cb6580d0039704e3d 100644 (file)
 #include "libcitadel.h"
 #include <sys/socket.h>
 
-/**
- * @defgroup URLHandling ParsedURL object to handle connection data
- */
-
-/**
- * @ingroup URLHandling
- * @brief frees a linked list of ParsedURL 
- * @param Url (list) of ParsedURL to be freet; Pointer is NULL'ed for the caller.
- */
-void FreeURL(ParsedURL** Url)
-{
+// frees a linked list of ParsedURL 
+// Url (list) of ParsedURL to be freet; Pointer is NULL'ed for the caller.
+void FreeURL(ParsedURL** Url) {
        if (*Url != NULL) {
                FreeStrBuf(&(*Url)->URL);
                FreeStrBuf(&(*Url)->UrlWithoutCred);
@@ -37,30 +29,23 @@ void FreeURL(ParsedURL** Url)
        }
 }
 
-/**
- * @ingroup URLHandling
- * @brief parses the string provided with UrlStr into *Url
- * @param Url on success this contains the parsed object; needs to be free'd by caller.
- * @param UrlStr String we should parse into parts
- * @param DefaultPort Which is the default port here?
- */
-int ParseURL(ParsedURL **Url, StrBuf *UrlStr, unsigned short DefaultPort)
-{
+// parses the string provided with UrlStr into *Url
+// Url on success this contains the parsed object; needs to be free'd by caller.
+// UrlStr String we should parse into parts
+// DefaultPort Which is the default port here?
+int ParseURL(ParsedURL **Url, StrBuf *UrlStr, unsigned short DefaultPort) {
        const char *pch, *pPort, *pCredEnd, *pUserEnd;
        ParsedURL *url = (ParsedURL *)malloc(sizeof(ParsedURL));
        memset(url, 0, sizeof(ParsedURL));
 
        url->af = AF_INET;
        url->Port =  DefaultPort;
-       /*
-        * http://username:passvoid@[ipv6]:port/url 
-        */
-       url->URL = NewStrBufDup(UrlStr);
+       url->URL = NewStrBufDup(UrlStr); // http://username:password@[ipv6]:port/url 
        url->Host = pch = ChrPtr(url->URL);
        url->LocalPart = strchr(pch, '/');
        if (url->LocalPart != NULL) {
                if ((*(url->LocalPart + 1) == '/') && 
-                   (*(url->LocalPart - 1) == ':')) { /* TODO: find default port for this protocol... */
+                   (*(url->LocalPart - 1) == ':')) {
                        url->Host = url->LocalPart + 2;
                        url->LocalPart = strchr(url->Host, '/');
                        if (url->LocalPart != NULL)
@@ -77,8 +62,7 @@ int ParseURL(ParsedURL **Url, StrBuf *UrlStr, unsigned short DefaultPort)
        pCredEnd = strrchr(ChrPtr(url->URL), '@');
        if (pCredEnd >= url->LocalPart)
                pCredEnd = NULL;
-       if (pCredEnd != NULL)
-       {
+       if (pCredEnd != NULL) {
                url->User = url->Host;
                url->Host = pCredEnd + 1;
                pUserEnd = strchr(url->User, ':');
@@ -120,20 +104,16 @@ int ParseURL(ParsedURL **Url, StrBuf *UrlStr, unsigned short DefaultPort)
        }
        if (pPort != NULL)
                url->Port = atol(pPort);
-       if (url->IPv6)
-       {
+       if (url->IPv6) {
            url->IsIP = inet_pton(AF_INET6, url->Host, &url->Addr.sin6_addr);
-           if (url->IsIP)
-           {
+           if (url->IsIP) {
                url->Addr.sin6_port = htons(url->Port);
                url->Addr.sin6_port = AF_INET6;
            }
        }
-       else
-       {
+       else {
            url->IsIP = inet_pton(AF_INET, url->Host, &((struct sockaddr_in *)&(url->Addr))->sin_addr);
-           if (url->IsIP)
-           {
+           if (url->IsIP) {
                ((struct sockaddr_in *)&(url->Addr))->sin_port = htons(url->Port);
                ((struct sockaddr_in *)&(url->Addr))->sin_family = AF_INET;
            }   
@@ -157,8 +137,7 @@ int ParseURL(ParsedURL **Url, StrBuf *UrlStr, unsigned short DefaultPort)
        return 1;
 }
 
-void CurlPrepareURL(ParsedURL *Url)
-{
+void CurlPrepareURL(ParsedURL *Url) {
        if (!strcmp(ChrPtr(Url->URL), "http"))
                Url->UrlWithoutCred = NewStrBufPlain(ChrPtr(Url->URL), -1);
        else 
@@ -170,12 +149,10 @@ void CurlPrepareURL(ParsedURL *Url)
        StrBufAppendPrintf(Url->UrlWithoutCred, "%u", Url->Port);
 
        StrBufAppendBufPlain(Url->UrlWithoutCred, HKEY("/"), 0);
-       if (Url->LocalPart)
-       {
+       if (Url->LocalPart) {
            StrBufAppendBufPlain(Url->UrlWithoutCred, Url->LocalPart, -1, 0);
        }
-       if (Url->User != NULL)
-       {
+       if (Url->User != NULL) {
                Url->CurlCreds = NewStrBufPlain(Url->User, -1);
                StrBufAppendBufPlain(Url->CurlCreds, HKEY(":"), 0);
                if (Url->Pass != NULL)
index 72bf66038828b6c59815a2d4e1827534ceea47cf..e14dcd2e4e802df834b6996dda6f0ed3cf587fde 100644 (file)
@@ -1,10 +1,6 @@
-//
 // Utility functions
-//
 // Copyright (c) 1996-2022 by the citadel.org team
-//
-// This program is open source software.  Use, duplication, or
-// disclosure are subject to the GNU General Public License v3.
+// This program is open source software.  Use, duplication, or disclosure are subject to the GNU General Public License v3.
 
 #include "webcit.h"
 
index d524c7988f1a71b4d6a86f1846f21629eb332b46..fac046decf109e5b9fc85b94144d5967d1dff155 100644 (file)
@@ -343,7 +343,7 @@ function mail_compose(is_quoted, references, quoted_msgnum, m_to, m_cc, m_subjec
 
                // The button bar is a Grid element, and is also a Flexbox container.
                + "<div class=\"ctdl-compose-toolbar\">"
-               + "<span class=\"ctdl-msg-button\" onclick=\"mail_save_message()\"><i class=\"fa fa-paper-plane\" style=\"color:green\"></i> " + _("Send message") + "</span>"
+               + "<span class=\"ctdl-msg-button\" onclick=\"mail_send_message()\"><i class=\"fa fa-paper-plane\" style=\"color:green\"></i> " + _("Send message") + "</span>"
                + "<span class=\"ctdl-msg-button\">" + _("Save to Drafts") + "</span>"
                + "<span class=\"ctdl-msg-button\">" + _("Attachments:") + " 0" + "</span>"
                + "<span class=\"ctdl-msg-button\">" + _("Contacts") + "</span>"
@@ -367,7 +367,7 @@ function make_cc_bcc_visible() {
 }
 
 
-// Helper function for mail_save_messages() to extract form values.
+// Helper function for mail_send_messages() to extract form values.
 // (We have to replace "|" with "!" because "|" is a field separator in the Citadel protocol)
 function msm_field(element_name, separator) {
        return (document.getElementById(element_name).innerHTML).replaceAll("|",separator);
@@ -375,7 +375,7 @@ function msm_field(element_name, separator) {
 
 
 // Save the posted message to the server
-function mail_save_message() {
+function mail_send_message() {
 
        document.body.style.cursor = "wait";
        url = "/ctdl/r/" + escapeHTMLURI(current_room)
@@ -386,6 +386,7 @@ function mail_save_message() {
                + "&mailcc="    + msm_field("ctdl-compose-cc-field", ",")                       // Cc: (if present)
                + "&mailbcc="   + msm_field("ctdl-compose-bcc-field", ",")                      // Bcc: (if present)
        ;
+       console.log(url);
        boundary = randomString();
        body_text =
                "--" + boundary + "\r\n"
index 4a822814609ee26811bb6eb15c0ad4dc036d468a..e08dcb7d5166f58d279b823b19f97bd11d99816a 100644 (file)
@@ -1,6 +1,4 @@
-/*
- * de/encoding stuff. hopefully mostly to be depricated in favour of subst.c + strbuf
- */
+// de/encoding stuff. hopefully mostly to be depricated in favour of subst.c + strbuf
 
 #define SHOW_ME_VAPPEND_PRINTF
 #include <stdio.h>
@@ -8,11 +6,8 @@
 #include "webcit.h"
 
 
-/*   
- * remove escaped strings from i.e. the url string (like %20 for blanks)
- */
-long unescape_input(char *buf)
-{
+// remove escaped strings from i.e. the url string (like %20 for blanks)
+long unescape_input(char *buf) {
        unsigned int a, b;
        char hex[3];
        long buflen;
@@ -30,7 +25,7 @@ long unescape_input(char *buf)
                if (buf[a] == '+')
                        buf[a] = ' ';
                if (buf[a] == '%') {
-                       /* don't let % chars through, rather truncate the input. */
+                       // don't let % chars through, rather truncate the input.
                        if (a + 2 > buflen) {
                                buf[a] = '\0';
                                buflen = a;
@@ -54,22 +49,19 @@ long unescape_input(char *buf)
        return a;
 }
 
-/*
- * Copy a string, escaping characters which have meaning in HTML.  
- *
- * target              target buffer
- * strbuf              source buffer
- * 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)
-{
+// Copy a string, escaping characters which have meaning in HTML.  
+//
+// target              target buffer
+// strbuf              source buffer
+// 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...  */
+        eptr = target + tSize - 6; // our biggest unit to put in...
  
  
         while ((bptr < eptr) && !IsEmptyStr(aptr) ){
@@ -127,37 +119,25 @@ long stresc(char *target, long tSize, char *strbuf, int nbsp, int nolinebreaks)
         return (bptr - target);
 }
 
-/* 
- * static wrapper for ecsputs1
- */
-void escputs(const char *strbuf)
-{
+// static wrapper for escputs1
+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)
-{
+// urlescape buffer and print it to the client
+void urlescputs(const char *strbuf) {
        StrBufUrlescAppend(WC->WBuf, NULL, strbuf);
 }
 
 
-/**
- * urlescape buffer and print it as header 
- */
-void hurlescputs(const char *strbuf) 
-{
+// urlescape buffer and print it as header 
+void hurlescputs(const char *strbuf) {
        StrBufUrlescAppend(WC->HBuf, NULL, strbuf);
 }
 
 
-/*
- * Output a string to the client as a CDATA block
- */
-void cdataout(char *rawdata)
-{
+// Output a string to the client as a CDATA block
+void cdataout(char *rawdata) {
        char *ptr = rawdata;
        wc_printf("<![CDATA[");
 
@@ -174,5 +154,4 @@ void cdataout(char *rawdata)
        }
 
        wc_printf("]]>");
-}
-
+}
\ No newline at end of file