Removed the superfluous function fmt_date() in libcitadel since it just calls strftim...
[citadel.git] / libcitadel / lib / tools.c
index fa8f1657db46ec35462622c77dcfca53ceb60eb4..c93758e2bc1388498e895f1f21b2b272bcb81c8c 100644 (file)
@@ -2,7 +2,7 @@
  * A basic toolset containing miscellaneous functions for string manipluation,
  * encoding/decoding, and a bunch of other stuff.
  *
- * Copyright (c) 1987-2011 by the citadel.org team
+ * Copyright (c) 1987-2017 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 as published by
@@ -292,7 +292,6 @@ size_t CtdlEncodeBase64(char *dest, const char *source, size_t sourcelen, int li
        int breaklength = 68;
        int readlength = 3 * breaklength / 4;
 
-       int t;
        int destoffset;
        int sourceoffset;
        int sourceremaining;
@@ -318,17 +317,12 @@ size_t CtdlEncodeBase64(char *dest, const char *source, size_t sourcelen, int li
                        dest[destoffset++] = '\n';
                }
 
-               t = destoffset;
-               destoffset += base64_encode_blockend(&(dest[destoffset]), &_state);
-               if (t < destoffset) {
-                       dest[destoffset++] = '\r';
-                       dest[destoffset++] = '\n';
-               }
+               destoffset += base64_encode_blockend(&(dest[destoffset]), &_state, 0);
        }
        else {
                destoffset = base64_encode_block(source, sourcelen, dest, &_state);
 
-               destoffset += base64_encode_blockend(&(dest[destoffset]), &_state);
+               destoffset += base64_encode_blockend(&(dest[destoffset]), &_state, 0);
        }
        dest[destoffset] = 0;
        return destoffset;
@@ -342,10 +336,13 @@ size_t CtdlEncodeBase64(char *dest, const char *source, size_t sourcelen, int li
 int CtdlDecodeBase64(char *dest, const char *source, size_t length)
 {
        base64_decodestate _state;
+       int len;
 
        base64_init_decodestate(&_state);
 
-       return base64_decode_block(source, length, dest, &_state);
+       len = base64_decode_block(source, length, dest, &_state);
+       dest[len] = '\0';
+       return len;
 }
 
 
@@ -464,32 +461,6 @@ int haschar(const char *st, int ch)
 }
 
 
-
-
-
-/*
- * Format a date/time stamp for output 
- * seconds is whether to print the seconds
- */
-void fmt_date(char *buf, size_t n, time_t thetime, int seconds) {
-       struct tm tm;
-       char *teh_format = NULL;
-
-       *buf = '\0';
-       localtime_r(&thetime, &tm);
-
-       if (seconds) {
-               teh_format = "%F %R:%S";
-       }
-       else {
-               teh_format = "%F %R";
-       }
-
-       strftime(buf, n, teh_format, &tm);
-}
-
-
-
 /*
  * Determine whether the specified message number is contained within the
  * specified sequence set.