striplt() is now string_trim()
authorArt Cancro <ajc@citadel.org>
Sat, 19 Nov 2022 21:20:33 +0000 (16:20 -0500)
committerArt Cancro <ajc@citadel.org>
Sat, 19 Nov 2022 21:20:33 +0000 (16:20 -0500)
31 files changed:
citadel/server/internet_addressing.c
citadel/server/ldap.c
citadel/server/modules/autocompletion/serv_autocompletion.c
citadel/server/modules/calendar/serv_calendar.c
citadel/server/modules/ctdlproto/serv_user.c
citadel/server/modules/imap/imap_fetch.c
citadel/server/modules/imap/imap_store.c
citadel/server/modules/inboxrules/serv_inboxrules.c
citadel/server/modules/migrate/serv_migrate.c
citadel/server/modules/pop3/serv_pop3.c
citadel/server/modules/rssclient/serv_rssclient.c
citadel/server/modules/vcard/serv_vcard.c
citadel/server/modules/wiki/serv_wiki.c
citadel/server/modules/xmpp/serv_xmpp.c
citadel/server/modules/xmpp/xmpp_messages.c
citadel/server/msgbase.c
citadel/server/user_ops.c
citadel/utils/citmail.c
libcitadel/lib/html_to_ascii.c
libcitadel/lib/libcitadel.h
libcitadel/lib/mime_parser.c
libcitadel/lib/tools.c
libcitadel/lib/vcard.c
textclient/routines.c
textclient/routines2.c
textclient/tuiconfig.c
webcit-ng/server/forum_view.c
webcit-ng/server/html2html.c
webcit-ng/server/http.c
webcit-ng/server/messages.c
webcit-ng/server/room_functions.c

index d9a363a23ac8ec5de5b8c3abe1db2029c86c34af..59a1b91b2eb5cd478ee843ab00585ff494e49f2a 100644 (file)
@@ -174,8 +174,8 @@ int expand_aliases(char *name, char *aliases) {
                        if (bar) {
                                bar[0] = 0;
                                ++bar;
-                               striplt(aaa);
-                               striplt(bar);
+                               string_trim(aaa);
+                               string_trim(bar);
                                if ( (!IsEmptyStr(aaa)) && (!strcasecmp(name, aaa)) ) {
                                        syslog(LOG_DEBUG, "internet_addressing: global alias <%s> to <%s>", name, bar);
                                        strcpy(name, bar);
@@ -191,7 +191,7 @@ int expand_aliases(char *name, char *aliases) {
        safestrncpy(original_name, name, sizeof original_name);
 
        // should these checks still be here, or maybe move them to split_recps() ?
-       striplt(name);
+       string_trim(name);
        remove_any_whitespace_to_the_left_or_right_of_at_symbol(name);
        stripallbut(name, '<', '>');
 
@@ -277,7 +277,7 @@ Array *split_recps(char *addresses, Array *append_to) {
        for (i=0; i<num_addresses; ++i) {
                char this_address[256];
                extract_token(this_address, a, i, ',', sizeof this_address);
-               striplt(this_address);                          // strip leading and trailing whitespace
+               string_trim(this_address);                              // strip leading and trailing whitespace
                stripout(this_address, '(', ')');               // remove any portion in parentheses
                stripallbut(this_address, '<', '>');            // if angle brackets are present, keep only what is inside them
                if (!IsEmptyStr(this_address)) {
@@ -795,9 +795,9 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name)
        }
 
        // strip leading and trailing spaces in all strings
-       striplt(user);
-       striplt(node);
-       striplt(name);
+       string_trim(user);
+       string_trim(node);
+       string_trim(name);
 
        // If we processed a string that had the address in angle brackets
        // but no name outside the brackets, we now have an empty name.  In
@@ -1141,11 +1141,11 @@ char *rfc822_fetch_field(const char *rfc822, const char *fieldname) {
                strcat(fieldbuf, " ");
                cont = &fieldbuf[strlen(fieldbuf)];
                ptr = cmemreadline(ptr, cont, SIZ-strlen(fieldbuf) );
-               striplt(cont);
+               string_trim(cont);
        }
 
        strcpy(fieldbuf, &fieldbuf[strlen(fieldhdr)]);
-       striplt(fieldbuf);
+       string_trim(fieldbuf);
 
        return(fieldbuf);
 }
@@ -1182,7 +1182,7 @@ int IsDirectory(char *addr, int allow_masq_domains) {
        int h;
 
        extract_token(domain, addr, 1, '@', sizeof domain);
-       striplt(domain);
+       string_trim(domain);
 
        h = CtdlHostAlias(domain);
 
@@ -1319,7 +1319,7 @@ char *harvest_collected_addresses(struct CtdlMessage *msg) {
                                        if (!IsEmptyStr(coll)) {
                                                strcat(coll, ",");
                                        }
-                                       striplt(addr);
+                                       string_trim(addr);
                                        strcat(coll, addr);
                                }
                        }
index 87e6c15746431cc65a5ae97a0b5532773fd53727..21624ad9d614759ee1f26f8dc146ddc9bc9d513a 100644 (file)
@@ -126,8 +126,8 @@ LDAP *ctdl_ldap_bind(void) {
        ldap_set_option(ldserver, LDAP_OPT_PROTOCOL_VERSION, &ctdl_require_ldap_version);
        ldap_set_option(ldserver, LDAP_OPT_REFERRALS, (void *)LDAP_OPT_OFF);
 
-       striplt(CtdlGetConfigStr("c_ldap_bind_dn"));
-       striplt(CtdlGetConfigStr("c_ldap_bind_pw"));
+       string_trim(CtdlGetConfigStr("c_ldap_bind_dn"));
+       string_trim(CtdlGetConfigStr("c_ldap_bind_pw"));
        i = ldap_simple_bind_s(ldserver,
                (!IsEmptyStr(CtdlGetConfigStr("c_ldap_bind_dn")) ? CtdlGetConfigStr("c_ldap_bind_dn") : NULL),
                (!IsEmptyStr(CtdlGetConfigStr("c_ldap_bind_pw")) ? CtdlGetConfigStr("c_ldap_bind_pw") : NULL)
index 7ce241d03e1a76bbff149cd37145b9c3657cb80a..fb225ddb42ef05dc12d45aa4084a760654082df6 100644 (file)
@@ -41,7 +41,7 @@ char *n_to_fn(char *value) {
        for (i=0; i<strlen(nnn); ++i) {
                if (!strncmp(&nnn[i], "  ", 2)) strcpy(&nnn[i], &nnn[i+1]);
        }
-       striplt(nnn);
+       string_trim(nnn);
        return(nnn);
 }
 
index 61f3d73cab948b671616c69fcdbdcbb66ebdb4f9..6ae4e37f19195c5a69fc756226279b13b3a505c8 100644 (file)
@@ -207,7 +207,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
                        ch = icalproperty_get_attendee(attendee);
                        if ((ch != NULL) && !strncasecmp(ch, "MAILTO:", 7)) {
                                safestrncpy(attendee_string, ch + 7, sizeof (attendee_string));
-                               striplt(attendee_string);
+                               string_trim(attendee_string);
                                recp = validate_recipients(attendee_string, NULL, 0);
                                if (recp != NULL) {
                                        if (!strcasecmp(recp->recp_local, CC->user.fullname)) {
@@ -254,7 +254,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
                }
                if (!strncasecmp(organizer_string, "MAILTO:", 7)) {
                        strcpy(organizer_string, &organizer_string[7]);
-                       striplt(organizer_string);
+                       string_trim(organizer_string);
                } else {
                        strcpy(organizer_string, "");
                }
@@ -2220,7 +2220,7 @@ void ical_saving_vevent(icalcomponent *top_level_cal, icalcomponent *cal) {
                }
                if (!strncasecmp(organizer_string, "MAILTO:", 7)) {
                        strcpy(organizer_string, &organizer_string[7]);
-                       striplt(organizer_string);
+                       string_trim(organizer_string);
                        /*
                         * If the user saving the event is listed as the
                         * organizer, then send out invitations.
@@ -2490,7 +2490,7 @@ void ical_fixed_output_backend(icalcomponent *cal, int recursion_level) {
 
                        /* screen name or email address */
                        safestrncpy(buf, ch + 7, sizeof(buf));
-                       striplt(buf);
+                       string_trim(buf);
                        cprintf("%s ", buf);
                }
                cprintf("\n");
index 9e438625c0bf46684e26ab457dc9b57950940570..3ee1e79bcbd9a8849626b540acf554f0905cbce2 100644 (file)
@@ -26,7 +26,7 @@ void cmd_user(char *cmdbuf) {
        int a;
 
        extract_token(username, cmdbuf, 0, '|', sizeof username);
-       striplt(username);
+       string_trim(username);
        syslog(LOG_DEBUG, "user_ops: cmd_user(%s)", username);
 
        a = CtdlLoginExistingUser(username);
@@ -486,7 +486,7 @@ void ListThisUser(char *username, void *data) {
 void cmd_list(char *cmdbuf) {
        char searchstring[256];
        extract_token(searchstring, cmdbuf, 0, '|', sizeof searchstring);
-       striplt(searchstring);
+       string_trim(searchstring);
        cprintf("%d \n", LISTING_FOLLOWS);
        ForEachUser(ListThisUser, (void *)searchstring );
        cprintf("000\n");
index f2d37b366521fe0a8495ab791af4238e8eb0606c..2ac8745c87a6f2b288af6642a386cb8c1726e42b 100644 (file)
@@ -382,7 +382,7 @@ void imap_output_envelope_addr(char *addr) {
        /* Output them one by one. */
        for (i=0; i<num_addrs; ++i) {
                extract_token(individual_addr, addr, i, ',', sizeof individual_addr);
-               striplt(individual_addr);
+               string_trim(individual_addr);
                process_rfc822_addr(individual_addr, user, node, name);
                IAPuts("(");
                IPutStr(name, strlen(name));
index 479a104860e5be5fcfbad38fb9c2994898d6276a..bc235d7529b5cdad8cc1ffa2cea9b98ed367d41c 100644 (file)
@@ -116,7 +116,7 @@ void imap_do_store(citimap_command *Cmd) {
                if (whichflags[strlen(whichflags)-1]==')') {
                        whichflags[strlen(whichflags)-1]=0;
                }
-               striplt(whichflags);
+               string_trim(whichflags);
 
                /* A client might twiddle more than one bit at a time.
                 * Note that we check for the flag names without the leading
index fb6bdd66e86b30d34005c878a1a58020f45c2fe7..1e1f8899a8ac38839fb91594fbb16b2bac41a359 100644 (file)
@@ -206,7 +206,7 @@ struct inboxrules *deserialize_inbox_rules(char *serialized_rules) {
                        int t = 0;
                        for (t=0; t<nt; ++t) {
                                extract_token(rtoken, decoded_rule, t, '|', sizeof(rtoken));
-                               striplt(rtoken);
+                               string_trim(rtoken);
                                switch(t) {
                                        case 1:                                                         // field to compare
                                                for (i=0; i<=field_all; ++i) {
index a45cc017da4a6c06be0e86441b1e10e7e717e807..08568763f4c4c7a18b4693480bf35d2d1a3191f5 100644 (file)
@@ -935,7 +935,7 @@ int migr_restore_message_metadata(long msgnum, int refcount) {
        if (mptr != NULL) {
                char *aptr;
                safestrncpy(smi.meta_content_type, &mptr[13], sizeof smi.meta_content_type);
-               striplt(smi.meta_content_type);
+               string_trim(smi.meta_content_type);
                aptr = smi.meta_content_type;
                while (!IsEmptyStr(aptr)) {
                        if ((*aptr == ';')
index e6b018d5affbc39f8f782bbd8a828762f7d0b817..335968708ad5daf83db979e3f0eccef20fa80bf0 100644 (file)
@@ -99,7 +99,7 @@ void pop3_user(char *argbuf) {
        }
 
        strcpy(username, argbuf);
-       striplt(username);
+       string_trim(username);
 
        if (CtdlLoginExistingUser(username) == login_ok) {
                cprintf("+OK Password required for %s\r\n", username);
@@ -186,7 +186,7 @@ void pop3_pass(char *argbuf) {
        char password[SIZ];
 
        safestrncpy(password, argbuf, sizeof password);
-       striplt(password);
+       string_trim(password);
 
        if (CtdlTryPassword(password, strlen(password)) == pass_ok) {
                pop3_login();
index b1c42f2921bd17a0c4a4766fe0fc918fbe8df91e..8021ebdba484e34e7836b84423d322c5a04e3374 100644 (file)
@@ -96,7 +96,7 @@ void rss_start_element(void *data, const char *el, const char **attribute) {
                                        r->link = NULL;
                                }
                                r->link = strdup(attribute[i+1]);
-                               striplt(r->link);
+                               string_trim(r->link);
                        }
                }
        }
index 9c9f98dd5600a6af21c3cc6b4a27ea70bcd83c17..7dbeb4a911eaee64374b1edd1dfbdc676bbc628d 100644 (file)
@@ -95,7 +95,7 @@ void extract_inet_email_addrs(char *emailaddrbuf, size_t emailaddrbuf_len,
                k = vcard_get_prop(v, "email", 1, instance, 1);
                if ( (s != NULL) && (k != NULL) && (bmstrcasestr(k, "internet")) ) {
                        addr = strdup(s);
-                       striplt(addr);
+                       string_trim(addr);
                        if (!IsEmptyStr(addr)) {
                                IsDirectoryAddress = IsDirectory(addr, 1);
 
@@ -826,7 +826,7 @@ void dvca_mime_callback(char *name, char *filename, char *partnum, char *disp,
                if (displayname[i] == ';') displayname[i] = ',';
                if (displayname[i] == ',') has_commas = 1;
        }
-       striplt(displayname);
+       string_trim(displayname);
 
        cprintf("%s%s%s <%s>\n",
                (has_commas ? "\"" : ""),
@@ -1112,7 +1112,7 @@ void store_this_ha(struct addresses_to_be_filed *aptr) {
 
                /* Make a vCard out of each address */
                extract_token(recipient, aptr->collected_addresses, i, ',', sizeof recipient);
-               striplt(recipient);
+               string_trim(recipient);
                v = vcard_new_from_rfc822_addr(recipient);
                if (v != NULL) {
                        const char *s;
index 75238f8524fb97ffcc7b738a35304398cdb12e74..d547d2157c449b901dd941d8aee89becbbf7af76 100644 (file)
@@ -257,7 +257,7 @@ int wiki_upload_beforesave(struct CtdlMessage *msg, struct recptypes *recp) {
        do {
                ptr = memreadline(ptr, buf, sizeof buf);
                if (*ptr != 0) {
-                       striplt(buf);
+                       string_trim(buf);
                        if (!IsEmptyStr(buf) && (!strncasecmp(buf, "Content-type:", 13))) {
                                if (
                                        (bmstrcasestr(buf, "multipart") != NULL)
@@ -446,7 +446,7 @@ void wiki_rev_callback(char *name, char *filename, char *partnum, char *disp,
 
        CtdlDecodeBase64(memo, filename, strlen(filename));
        extract_token(this_rev, memo, 0, '|', sizeof this_rev);
-       striplt(this_rev);
+       string_trim(this_rev);
 
        /* Perform the patch */
        fp = popen("patch -f -s -p0 -r /dev/null >/dev/null 2>/dev/null", "w");
@@ -580,7 +580,7 @@ void wiki_rev(char *pagename, char *rev, char *operation)
        memset(&hecbd, 0, sizeof(struct HistoryEraserCallBackData));
        hecbd.tempfilename = temp;
        hecbd.stop_when = rev;
-       striplt(hecbd.stop_when);
+       string_trim(hecbd.stop_when);
 
        mime_parser(CM_RANGE(msg, eMesageText), *wiki_rev_callback, NULL, NULL, (void *)&hecbd, 0);
        CM_Free(msg);
index 1a0ec98c2e1f8c07af0a6834a474384825c55b88..13e8c17649731d02120601b503eeeeb530e074fd 100644 (file)
@@ -311,21 +311,21 @@ void xmpp_xml_end(void *data, const char *supplied_el) {
        if (!strcasecmp(el, "resource")) {
                if (XMPP->chardata_len > 0) {
                        safestrncpy(XMPP->iq_client_resource, XMPP->chardata, sizeof XMPP->iq_client_resource);
-                       striplt(XMPP->iq_client_resource);
+                       string_trim(XMPP->iq_client_resource);
                }
        }
 
        else if (!strcasecmp(el, "username")) {         /* NON SASL ONLY */
                if (XMPP->chardata_len > 0) {
                        safestrncpy(XMPP->iq_client_username, XMPP->chardata, sizeof XMPP->iq_client_username);
-                       striplt(XMPP->iq_client_username);
+                       string_trim(XMPP->iq_client_username);
                }
        }
 
        else if (!strcasecmp(el, "password")) {         /* NON SASL ONLY */
                if (XMPP->chardata_len > 0) {
                        safestrncpy(XMPP->iq_client_password, XMPP->chardata, sizeof XMPP->iq_client_password);
-                       striplt(XMPP->iq_client_password);
+                       string_trim(XMPP->iq_client_password);
                }
        }
 
index 45e4822b0d88ed384253f59a85d1b93f7877a30a..219f8efdda9017712a58a5e7f50c7da6898da4f4 100644 (file)
@@ -61,7 +61,7 @@ void xmpp_output_incoming_messages(void) {
                        xmlesc(xmlbuf2, ptr->sender_email, sizeof xmlbuf2)
                );
                if (ptr->text != NULL) {
-                       striplt(ptr->text);
+                       string_trim(ptr->text);
                        cprintf("<body>%s</body>", xmlesc(xmlbuf1, ptr->text, sizeof xmlbuf1));
                        free(ptr->text);
                }
index 4ddd9aa4228b2b66685538ca699a3126a6f0ba0e..679390eea01aa753e6e44e8cf3cb22690190d85f 100644 (file)
@@ -2658,7 +2658,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
                if (mptr != NULL) {
                        char *aptr;
                        safestrncpy(content_type, &mptr[13], sizeof content_type);
-                       striplt(content_type);
+                       string_trim(content_type);
                        aptr = content_type;
                        while (!IsEmptyStr(aptr)) {
                                if ((*aptr == ';')
@@ -3128,8 +3128,8 @@ struct CtdlMessage *CtdlMakeMessageLen(
        msg->cm_anon_type = type;
        msg->cm_format_type = format_type;
 
-       if (recipient != NULL) rcplen = striplt(recipient);
-       if (recp_cc != NULL) cclen = striplt(recp_cc);
+       if (recipient != NULL) rcplen = string_trim(recipient);
+       if (recp_cc != NULL) cclen = string_trim(recp_cc);
 
        /* Path or Return-Path */
        if (myelen > 0) {
@@ -3178,7 +3178,7 @@ struct CtdlMessage *CtdlMakeMessageLen(
 
        if (subject != NULL) {
                long length;
-               length = striplt(subject);
+               length = string_trim(subject);
                if (length > 0) {
                        long i;
                        long IsAscii;
index 6617fabe9d9184243a97b06d5386e738403c08a2..62b11981cc625ac5b25df5c3d460ab2eed8a8d7e 100644 (file)
@@ -478,7 +478,7 @@ int CtdlLoginExistingUser(const char *trythisname) {
 
        // Continue attempting user validation...
        safestrncpy(username, trythisname, sizeof (username));
-       striplt(username);
+       string_trim(username);
 
        if (IsEmptyStr(username)) {
                return login_not_found;
index b611766e6884e69de7e62ace7f925e40301c28ea..6686507ec0e88f55a77e845d34620855cb209739 100644 (file)
@@ -247,7 +247,7 @@ int main(int argc, char **argv) {
                                for (i=0; i<num_recp_on_this_line; ++i) {
                                        extract_token(this_recp, add_these_recipients,
                                                i, ',', sizeof this_recp);
-                                       striplt(this_recp);
+                                       string_trim(this_recp);
                                        if (!IsEmptyStr(this_recp)) {
                                                ++num_recipients;
                                                recipients = realloc(recipients,
index 33373c19d3c44cd4f75a28d2a457f09ba3d3e12c..251f1adea777b2661a27edcc4ec848a213d6e338 100644 (file)
@@ -591,7 +591,7 @@ char *html_to_ascii(const char *inputmsg, int msglen, int screenwidth, int ansi)
        output_len += strlen(outbuf);
 
        /* Strip leading/trailing whitespace.  We can't do this with
-        * striplt() because it uses too many strlen()'s
+        * string_trim() because it uses too many strlen()'s
         */
        while ((output_len > 0) && (isspace(outptr[0]))) {
                strcpy(outptr, &outptr[1]);
index 4d83d8e79f95e3735953df347474f5b194930495..37cd26b06dbab30391951bf9c270401fbf070a71 100644 (file)
@@ -406,7 +406,7 @@ size_t CtdlDecodeBase64(char *dest, const char *source, size_t length);
 unsigned int decode_hex(char *Source);
 int CtdlDecodeQuotedPrintable(char *decoded, char *encoded, int sourcelen);
 void StripSlashes(char *Dir, int TrailingSlash);
-size_t striplt(char *);
+size_t string_trim(char *);
 int haschar(const char *st, int ch);
 void remove_token(char *source, int parmnum, char separator);
 int is_msg_in_sequence_set(const char *mset, long msgnum);
@@ -430,7 +430,7 @@ void CtdlMakeTempFileName(char *name, int len);
 char *rfc2047encode(const char *line, long length);
 int is_msg_in_mset(const char *mset, long msgnum);
 int pattern2(char *search, char *patn);
-void stripltlen(char *, int *);
+void string_trimlen(char *, int *);
 char *html_to_ascii(const char *inputmsg, int msglen, int screenwidth, int ansi);
 void LoadEntityList(char *FileName);
 void utf8ify_rfc822_string(char *buf);
index 318c23fdebc30a1b96446bac2994764e44e78158..d6ff049edafbd6d7df668cc867edf2663e0a3589 100644 (file)
@@ -390,7 +390,7 @@ static long parse_MimeHeaders(interesting_mime_headers *m,
                        if (!strncasecmp(header, "Content-type:", 13)) {
                                memcpy (m->b[content_type].Key, &header[13], headerlen - 12);
                                m->b[content_type].Key[headerlen - 12] = '\0';
-                               m->b[content_type].len = striplt (m->b[content_type].Key);
+                               m->b[content_type].len = string_trim (m->b[content_type].Key);
 
                                m->b[content_type_name].len = extract_key(m->b[content_type_name].Key, CKEY(m->b[content_type]), HKEY("name"), '=');
                                m->b[charset].len           = extract_key(m->b[charset].Key,           CKEY(m->b[content_type]), HKEY("charset"), '=');
@@ -411,18 +411,18 @@ static long parse_MimeHeaders(interesting_mime_headers *m,
                        else if (!strncasecmp(header, "Content-Disposition:", 20)) {
                                memcpy (m->b[disposition].Key, &header[20], headerlen - 19);
                                m->b[disposition].Key[headerlen - 19] = '\0';
-                               m->b[disposition].len = striplt(m->b[disposition].Key);
+                               m->b[disposition].len = string_trim(m->b[disposition].Key);
 
                                m->b[content_disposition_name].len = extract_key(m->b[content_disposition_name].Key, CKEY(m->b[disposition]), HKEY("name"), '=');
                                m->b[filename].len                 = extract_key(m->b[filename].Key,                 CKEY(m->b[disposition]), HKEY("filename"), '=');
                                pch = strchr(m->b[disposition].Key, ';');
                                if (pch != NULL) *pch = '\0';
-                               m->b[disposition].len = striplt(m->b[disposition].Key);
+                               m->b[disposition].len = string_trim(m->b[disposition].Key);
                        }
                        else if (!strncasecmp(header, "Content-ID:", 11)) {
                                memcpy(m->b[id].Key, &header[11], headerlen - 11);
                                m->b[id].Key[headerlen - 11] = '\0';
-                               striplt(m->b[id].Key);
+                               string_trim(m->b[id].Key);
                                m->b[id].len = stripallbut(m->b[id].Key, '<', '>');
                        }
                        else if (!strncasecmp(header, "Content-length: ", 15)) {
@@ -435,7 +435,7 @@ static long parse_MimeHeaders(interesting_mime_headers *m,
                        else if (!strncasecmp(header, "Content-transfer-encoding: ", 26)) {
                                memcpy(m->b[encoding].Key, &header[26], headerlen - 26);
                                m->b[encoding].Key[headerlen - 26] = '\0';
-                               m->b[encoding].len = striplt(m->b[encoding].Key);
+                               m->b[encoding].len = string_trim(m->b[encoding].Key);
                        }
                        *header = '\0';
                        headerlen = 0;
index 131cc2f7ae98f1fb83f8553ebb568921ca7a118e..8971b30e69a5761a29f413250e0926e844f6649a 100644 (file)
@@ -245,7 +245,7 @@ void StripSlashes(char *Dir, int TrailingSlash) {
 
 
 // Strip leading and trailing spaces from a string
-size_t striplt(char *buf) {
+size_t string_trim(char *buf) {
        char *first_nonspace = NULL;
        char *last_nonspace = NULL;
        char *ptr;
@@ -849,7 +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 string_trimlen(char *buf, int *len) {
        int delta = 0;
        if (*len == 0) return;
        while ((*len > delta) && (isspace(buf[delta]))){
index f52bb29c49f5ba14ac66b93734ee82545396eb05..b58f61c967f748c37d99816eb6dd9c23f46e3b36 100644 (file)
@@ -62,7 +62,7 @@ void remove_charset_attribute(char *strbuf)
        t = num_tokens(strbuf, ';');
        for (i=0; i<t; ++i) {
                extract_token(compare, strbuf, i, ';', sizeof compare);
-               striplt(compare);
+               string_trim(compare);
                if (!strncasecmp(compare, "charset=", 8)) {
                        remove_token(strbuf, i, ';');
                }
@@ -387,7 +387,7 @@ void vcard_fn_to_n(char *vname, char *n, size_t vname_size) {
 
        /* Anything left is probably the first name */
        safestrncpy(firstname, buf, sizeof firstname);
-       striplt(firstname);
+       string_trim(firstname);
 
        /* Compose the structured name */
        snprintf(vname, vname_size, "%s;%s;%s;%s;%s", lastname, firstname, middlename,
index 6ef2978663fb1d67b999288d791fcddf4f5063ee..1dff2b7d1003a464932e2dabf01b23443a236169 100644 (file)
@@ -81,7 +81,7 @@ void edit_user_internet_email_addresses(CtdlIPC * ipc, char *who) {
                switch (ch) {
                case 'a':
                        newprompt("Enter new email address: ", buf, 50);
-                       striplt(buf);
+                       string_trim(buf);
                        if (!IsEmptyStr(buf)) {
                                // FIXME validate the email address (format, our own domain, addr does not belong to another user)
                                ++num_recs;
index edf206dd16fc2dee69465e7f5ecb434d7631d533..ebabf6e3ef7dfcb010485e68b64d37af37e70fde 100644 (file)
@@ -109,8 +109,8 @@ void entregis(CtdlIPC * ipc) {
                if (r / 100 == 2) {
                        extract_token(diruser, buf, 0, '@', sizeof diruser);
                        extract_token(dirnode, buf, 1, '@', sizeof dirnode);
-                       striplt(diruser);
-                       striplt(dirnode);
+                       string_trim(diruser);
+                       string_trim(dirnode);
                        if ((strcasecmp(diruser, fullname))
                            || (strcasecmp(dirnode, ipc->ServInfo.nodename))) {
                                scr_printf("\nYou can't use %s as your address.\n", tmpemail);
index 209ff246333fead6eb81b230d278eabbac64f473..aefae6aedd9161a5105aef5189ce71e45d20085c 100644 (file)
@@ -374,7 +374,7 @@ void do_internet_configuration(CtdlIPC * ipc) {
                switch (ch) {
                case 'a':
                        newprompt("Enter host name: ", buf, 50);
-                       striplt(buf);
+                       string_trim(buf);
                        if (!IsEmptyStr(buf)) {
                                ++num_recs;
                                if (num_recs == 1) {
@@ -549,7 +549,7 @@ void network_config_management(CtdlIPC * ipc, char *entrytype, char *comment) {
                                if (buf[i] == '#')
                                        buf[i] = 0;
                        }
-                       striplt(buf);
+                       string_trim(buf);
                        if (!IsEmptyStr(buf)) {
                                fprintf(changefp, "%s|%s\n", entrytype, buf);
                        }
index 9fccab60f104b8435bf8c46f8971edea486c63bd..ef16e4eeb54089dcc41cfe49a623317f9215bbe8 100644 (file)
@@ -28,7 +28,7 @@ JsonValue *json_tokenize_recipients(const char *Key, long keylen, char *recp) {
        int num_recp = num_tokens(recp, ',');
        for (int i=0; i<num_recp; ++i) {
                extract_token(tokbuf, recp, i, ',', sizeof(tokbuf));
-               striplt(tokbuf);
+               string_trim(tokbuf);
                JsonArrayAppend(j, NewJsonPlainString(HKEY("r"), tokbuf, strlen(tokbuf)));
        }
        return(j);
@@ -96,11 +96,11 @@ void json_render_one_message(struct http_transaction *h, struct ctdlsession *c,
                        // rfc822 header parsing here
                        if (!strncasecmp(buf, "Content-transfer-encoding:", 26)) {
                                strcpy(content_transfer_encoding, &buf[26]);
-                               striplt(content_transfer_encoding);
+                               string_trim(content_transfer_encoding);
                        }
                        if (!strncasecmp(buf, "Content-type:", 13)) {
                                strcpy(content_type, &buf[13]);
-                               striplt(content_type);
+                               string_trim(content_type);
                        }
                }
                if (!strcmp(buf, "000")) {              // if we have an empty message, don't try to read further
index b6dadc35eeec1397d48282fe31cc88dda72f3c74..ab37b7b0896a097a4405e9937f6c048e9360af6a 100644 (file)
@@ -52,7 +52,7 @@ void extract_charset_from_meta(char *charset, char *meta_http_equiv, char *meta_
                return;
 
        safestrncpy(buf, ++ptr, sizeof buf);
-       striplt(buf);
+       string_trim(buf);
        if (!strncasecmp(buf, "charset=", 8)) {
                strcpy(charset, &buf[8]);
 
@@ -68,7 +68,7 @@ void extract_charset_from_meta(char *charset, char *meta_http_equiv, char *meta_
                // Remove wandering punctuation
                if ((ptr = strchr(charset, '\"')))
                        *ptr = 0;
-               striplt(charset);
+               string_trim(charset);
        }
 }
 
@@ -151,7 +151,7 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
                                meta = malloc(meta_length + 1);
                                safestrncpy(meta, meta_start, meta_length);
                                meta[meta_length] = 0;
-                               striplt(meta);
+                               string_trim(meta);
                                if (!strncasecmp(meta, "HTTP-EQUIV=", 11)) {
                                        meta_http_equiv = strdup(&meta[11]);
                                        spaceptr = strchr(meta_http_equiv, ' ');
index 55c335eff5100ca1532e880a207367c6c358dfc0..161c070f52a6a13f3af4b8e3f6beb3052bdc02a9 100644 (file)
@@ -140,8 +140,8 @@ void perform_one_http_transaction(struct client_handle *ch) {
                                new_request_header.key = strdup(buf);
                                ++c;
                                new_request_header.val = strdup(c);
-                               striplt(new_request_header.key);
-                               striplt(new_request_header.val);
+                               string_trim(new_request_header.key);
+                               string_trim(new_request_header.val);
                                array_append(h.request_headers, &new_request_header);
 #ifdef DEBUG_HTTP
                                syslog(LOG_DEBUG, "\033[1m\033[35m{ %s: %s\033[0m", new_request_header.key, new_request_header.val);
index 1f28af8bb93edcadafb63362f040157ff566ae92..a45337b897910b19d364f85118ac1ebb4a73ddec 100644 (file)
@@ -77,7 +77,7 @@ void dav_get_message(struct http_transaction *h, struct ctdlsession *c, long msg
                        if (v) {
                                *v = 0;
                                ++v;
-                               striplt(v);     // we now have a key (k) and a value (v)
+                               string_trim(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"))
                                ) {
index 67b3e9082943ca78a952b0048e00c6d8fa9a3ff5..e18633a8be79e4d020a688b9a7f4dfee0edd87bc 100644 (file)
@@ -52,14 +52,14 @@ int match_etags(char *taglist, long msgnum) {
 
        for (i = 0; i < num_tags; ++i) {
                extract_token(tag, taglist, i, ',', sizeof tag);
-               striplt(tag);
+               string_trim(tag);
                char *lq = (strchr(tag, '"'));
                char *rq = (strrchr(tag, '"'));
                if (lq < rq) {                                  // has two double quotes
                        strcpy(rq, "");
                        strcpy(tag, ++lq);
                }
-               striplt(tag);
+               string_trim(tag);
                if (!strcmp(tag, "*")) {                        // wildcard match
                        return (1);
                }