]> code.citadel.org Git - citadel.git/blobdiff - libcitadel/lib/tools.c
Removed the 'ascmonths' global declaration from libCitadel.
[citadel.git] / libcitadel / lib / tools.c
index e3882c7bb7033d286e57f96fd76c75e6b25ea4df..ab885268bf08bf1e44d9625b986368dc5fb41f0d 100644 (file)
@@ -1,5 +1,6 @@
 /*
- *
+ * A basic toolset containing miscellaneous functions for string manipluation,
+ * encoding/decoding, and a bunch of other stuff.
  */
 
 
@@ -35,12 +36,6 @@ typedef unsigned char byte;        /* Byte type */
 static byte dtable[256] = "\0";              /* base64 decode table */
 static byte etable[256] = "\0";              /* base64 encode table */
 
-/* Month strings for date conversions */
-char *ascmonths[12] = {
-       "Jan", "Feb", "Mar", "Apr", "May", "Jun",
-       "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
-};
-
 char *safestrncpy(char *dest, const char *src, size_t n)
 {
        int i = 0;
@@ -101,8 +96,8 @@ long extract_token(char *dest, const char *source, int parmnum, char separator,
                return(-1);
        }
 
-//     cit_backtrace();
-//     lprintf (CTDL_DEBUG, "test >: n: %d sep: %c source: %s \n willi \n", parmnum, separator, source);
+       //cit_backtrace();
+       //lprintf (CTDL_DEBUG, "test >: n: %d sep: %c source: %s \n willi \n", parmnum, separator, source);
        dest[0] = 0;
 
        if (s == NULL) {
@@ -129,10 +124,10 @@ long extract_token(char *dest, const char *source, int parmnum, char separator,
 
        dest[len] = '\0';
        if (current_token < parmnum) {
-//             lprintf (CTDL_DEBUG,"test <!: %s\n", dest);
+               //lprintf (CTDL_DEBUG,"test <!: %s\n", dest);
                return(-1);
        }
-//     lprintf (CTDL_DEBUG,"test <: %d; %s\n", len, dest);
+       //lprintf (CTDL_DEBUG,"test <: %d; %s\n", len, dest);
        return(len);
 }
 //*/
@@ -149,8 +144,8 @@ long extract_token(char *dest, const char *source, int parmnum, char separator,
        int len = 0;
 
        
-//     cit_backtrace();
-       lprintf (CTDL_DEBUG, "test >: n: %d sep: %c source: %s \n willi \n", parmnum, separator, source);
+       //cit_backtrace();
+       //lprintf (CTDL_DEBUG, "test >: n: %d sep: %c source: %s \n willi \n", parmnum, separator, source);
        strcpy(dest, "");
 
        //  Locate desired parameter 
@@ -167,7 +162,7 @@ long extract_token(char *dest, const char *source, int parmnum, char separator,
                s++;
        }
        if (!s) {
-               lprintf (CTDL_DEBUG,"test <!: %s\n", dest);
+               //lprintf (CTDL_DEBUG,"test <!: %s\n", dest);
                return -1;              // Parameter not found
        }
        
@@ -175,7 +170,7 @@ long extract_token(char *dest, const char *source, int parmnum, char separator,
                *d = *s;
        }
        *d = 0;
-       lprintf (CTDL_DEBUG,"test <: %d; %s\n", len, dest);
+       //lprintf (CTDL_DEBUG,"test <: %d; %s\n", len, dest);
        return 0;
 }
 */
@@ -518,6 +513,11 @@ void fmt_date(char *buf, size_t n, time_t thetime, int seconds) {
        struct tm tm;
        int hour;
 
+       /* Month strings for date conversions ... this needs to be localized eventually */
+       char *fmt_date_months[12] = {
+               "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+       };
+
        strcpy(buf, "");
        localtime_r(&thetime, &tm);
 
@@ -527,7 +527,7 @@ void fmt_date(char *buf, size_t n, time_t thetime, int seconds) {
 
        if (seconds) {
                snprintf(buf, n, "%s %d %4d %d:%02d:%02d%s",
-                       ascmonths[tm.tm_mon],
+                       fmt_date_months[tm.tm_mon],
                        tm.tm_mday,
                        tm.tm_year + 1900,
                        hour,
@@ -537,7 +537,7 @@ void fmt_date(char *buf, size_t n, time_t thetime, int seconds) {
                );
        } else {
                snprintf(buf, n, "%s %d %4d %d:%02d%s",
-                       ascmonths[tm.tm_mon],
+                       fmt_date_months[tm.tm_mon],
                        tm.tm_mday,
                        tm.tm_year + 1900,
                        hour,
@@ -869,7 +869,7 @@ int is_msg_in_mset(char *mset, long msgnum) {
 }
 
 
-/**
+/*
  * \brief searches for a  paternn within asearch string
  * \param search the string to search 
  * \param patn the pattern to find in string