New utility function convert_spaces_to_underscores()
authorArt Cancro <ajc@citadel.org>
Sat, 15 Mar 2008 03:20:27 +0000 (03:20 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 15 Mar 2008 03:20:27 +0000 (03:20 +0000)
We do this in a couple of different places so it's going into libcitadel.

citadel/citadel.h
citadel/msgbase.c
citadel/user_ops.c
libcitadel/lib/libcitadel.h
libcitadel/lib/tools.c
webcit/webcit.h

index 2db49b597fb05cb17bd9e0868dc8367b4742f073..ff2406563aa8fc4b043843c1ec7aebe74416401d 100644 (file)
@@ -50,7 +50,7 @@ extern "C" {
 #define REV_LEVEL      732             /* This version */
 #define REV_MIN                591             /* Oldest compatible database */
 #define EXPORT_REV_MIN 725             /* Oldest compatible export files */
-#define LIBCITADEL_MIN 108             /* Minimum required version of libcitadel */
+#define LIBCITADEL_MIN 109             /* Minimum required version of libcitadel */
 
 #define SERVER_TYPE 0                  /* zero for stock Citadel; other developers please
                                           obtain SERVER_TYPE codes for your implementations */
index 10ec60887d068f470c6e667aea2a166a9f33af69..8f61f33291b7ca386302b64ec2cb3b3831709888 100644 (file)
@@ -3010,11 +3010,7 @@ struct CtdlMessage *CtdlMakeMessage(
                snprintf(buf, sizeof buf, "%s", author->fullname);
                msg->cm_fields['P'] = strdup(buf);
        }
-       for (i=0; (msg->cm_fields['P'][i]!=0); ++i) {
-               if (isspace(msg->cm_fields['P'][i])) {
-                       msg->cm_fields['P'][i] = '_';
-               }
-       }
+       convert_spaces_to_underscores(msg->cm_fields['P']);
 
        snprintf(buf, sizeof buf, "%ld", (long)time(NULL));     /* timestamp */
        msg->cm_fields['T'] = strdup(buf);
index 3fd6b4a8536ab6ddd2511e2dcb7787aab7a0e78b..85f21d69503095bd661dbd34a46562fac5d06afc 100644 (file)
@@ -590,11 +590,7 @@ void session_startup(void)
         */
        snprintf(CC->cs_inet_email, sizeof CC->cs_inet_email, "%s@%s",
                CC->user.fullname, config.c_fqdn);
-       for (i=0; !IsEmptyStr(&CC->cs_inet_email[i]); ++i) {
-               if (isspace(CC->cs_inet_email[i])) {
-                       CC->cs_inet_email[i] = '_';
-               }
-       }
+       convert_spaces_to_underscores(CC->cs_inet_email);
 
        /* Create any personal rooms required by the system.
         * (Technically, MAILROOM should be there already, but just in case...)
index 3a9bbbd671c12d9a2c609c4a080815062ffec1de..90bbb3530c8a3f10bf908a587683a5ffd866d140 100644 (file)
@@ -10,7 +10,7 @@
  */
 #include <time.h>
 #include <stdlib.h>
-#define LIBCITADEL_VERSION_NUMBER      108
+#define LIBCITADEL_VERSION_NUMBER      109
 
 /*
  * Here's a bunch of stupid magic to make the MIME parser portable.
@@ -291,3 +291,4 @@ void SortByHashKeyStr(HashList *Hash);
 const void *GetSearchPayload(const void *HashVoid);
 void SortByPayload(HashList *Hash, CompareFunc SortBy);
 
+void convert_spaces_to_underscores(char *str);
index c056fe94d8ea4a4b1ecf50c81dfac15a77c79ddc..32c96e035f569b54f21c05d230144676deee79c9 100644 (file)
@@ -895,10 +895,10 @@ int pattern2(char *search, char *patn)
 }
 
 
-/**
- * \brief Strip leading and trailing spaces from a string; with premeasured and adjusted length.
- * \param buf the string to modify
- * \param len length of the string. 
+/*
+ * Strip leading and trailing spaces from a string; with premeasured and adjusted length.
+ * buf - the string to modify
+ * len - length of the string. 
  */
 void stripltlen(char *buf, int *len)
 {
@@ -916,3 +916,21 @@ void stripltlen(char *buf, int *len)
        }
 }
 
+
+/*
+ * Convert all whitespace characters in a supplied string to underscores
+ */
+void convert_spaces_to_underscores(char *str)
+{
+       int len;
+       int i;
+
+       if (!str) return;
+
+       len = strlen(str);
+       for (i=0; i<len; ++i) {
+               if (isspace(str[i])) {
+                       str[i] = '_';
+               }
+       }
+}
index 96977c5670bae5b30ce2622e91bfc5facfb04c94..e7e3e75fa21f7247eda9234b6dca599997515796 100644 (file)
@@ -126,7 +126,7 @@ extern locale_t wc_locales[];
 #define CLIENT_ID              4
 #define CLIENT_VERSION         734             /* This version of WebCit */
 #define MINIMUM_CIT_VERSION    730             /* min required Citadel ver */
-#define        LIBCITADEL_MIN          108             /* min required libcitadel ver */
+#define        LIBCITADEL_MIN          109             /* min required libcitadel ver */
 #define DEFAULT_HOST           "localhost"     /* Default Citadel server */
 #define DEFAULT_PORT           "504"
 #define LB                     (1)             /* Internal escape chars */