STRBUF: add wrapper to do source -> target buffer base 64 decoding
authorWilfried Goesgens <dothebart@citadel.org>
Thu, 2 Jan 2014 19:18:09 +0000 (20:18 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Thu, 2 Jan 2014 19:18:09 +0000 (20:18 +0100)
libcitadel/lib/libcitadel.h
libcitadel/lib/stringbuf.c

index bd7c8da9ccf2be13e1bd6389a784e7a6f4652220..a1aacb5fb2aa965b8d28873420e886ff46c107df 100644 (file)
@@ -339,6 +339,7 @@ void StrBuf_RFC822_2_Utf8(StrBuf *Target,
 void StrBuf_RFC822_to_Utf8(StrBuf *Target, const StrBuf *DecodeMe, const StrBuf* DefaultCharset, StrBuf *FoundCharset);
 
 int StrBufDecodeBase64(StrBuf *Buf);
+int StrBufDecodeBase64To(const StrBuf *BufIn, StrBuf *BufOut);
 int StrBufDecodeHex(StrBuf *Buf);
 StrBuf *StrBufRFC2047encodeMessage(const StrBuf *EncodeMe);
 int StrBufRFC2047encode(StrBuf **target, const StrBuf *source);
index 6bcbaf1fa3ab725d10c19c1132b2cd2ec4628bbc..547037751961c011899f9b364d74a463ae829637 100644 (file)
@@ -2823,6 +2823,26 @@ int StrBufDecodeBase64(StrBuf *Buf)
        return siz;
 }
 
+/**
+ * @ingroup StrBuf_DeEnCoder
+ * @brief decode a buffer from base 64 encoding; expects targetbuffer
+ * @param BufIn Buffor to transform
+ * @param BufOut Buffer to put result into
+ */
+int StrBufDecodeBase64To(const StrBuf *BufIn, StrBuf *BufOut)
+{
+       if ((BufIn == NULL) || (BufOut == NULL))
+               return -1;
+
+       if (BufOut->BufSize < BufIn->BufUsed)
+               IncreaseBuf(BufOut, BufIn->BufUsed, 0);
+
+       BufOut->BufUsed = CtdlDecodeBase64(BufOut->buf,
+                                          BufIn->buf,
+                                          BufIn->BufUsed);
+       return BufOut->BufUsed;
+}
+
 /**
  * @ingroup StrBuf_DeEnCoder
  * @brief decode a buffer from base 64 encoding; destroys original