int CompressBuffer(StrBuf *Buf);
void StrBufConvert(StrBuf *ConvertBuf, StrBuf *TmpBuf, void *pic);
void ctdl_iconv_open(const char *tocode, const char *fromcode, void *pic);
-void StrBuf_RFC822_to_Utf8(StrBuf *Target, StrBuf *DecodeMe, const StrBuf* DefaultCharset, StrBuf *FoundCharset);
+void StrBuf_RFC822_to_Utf8(StrBuf *Target, const StrBuf *DecodeMe, const StrBuf* DefaultCharset, StrBuf *FoundCharset);
int StrBufDecodeBase64(StrBuf *Buf);
int StrBufRFC2047encode(StrBuf **target, const StrBuf *source);
#define LB (1) /* Internal escape chars */
void StrBufAppendBufPlain(StrBuf *Buf, const char *AppendBuf, long AppendSize, size_t Offset)
{
long aps;
+ long BufSizeRequired;
if ((AppendBuf == NULL) || (Buf == NULL))
return;
else
aps = AppendSize - Offset;
- if (Buf->BufSize < Buf->BufUsed + aps + 1)
- IncreaseBuf(Buf, (Buf->BufUsed > 0), Buf->BufUsed + aps + 1);
+ BufSizeRequired = Buf->BufUsed + aps + 1;
+ if (Buf->BufSize <= BufSizeRequired)
+ IncreaseBuf(Buf, (Buf->BufUsed > 0), BufSizeRequired);
memcpy(Buf->buf + Buf->BufUsed,
AppendBuf + Offset,
bptr += 5;
Target->BufUsed += 5;
}
- else if (*aptr == '\"') {
+ else if (*aptr == '"') {
memcpy(bptr, """, 6);
bptr += 6;
Target->BufUsed += 6;
-static inline char *FindNextEnd (StrBuf *Buf, char *bptr)
+static inline char *FindNextEnd (const StrBuf *Buf, char *bptr)
{
char * end;
/* Find the next ?Q? */
inline static void DecodeSegment(StrBuf *Target,
- StrBuf *DecodeMe,
+ const StrBuf *DecodeMe,
char *SegmentStart,
char *SegmentEnd,
StrBuf *ConvertBuf,
* Handle subjects with RFC2047 encoding such as:
* =?koi8-r?B?78bP0s3Mxc7JxSDXz9rE1dvO2c3JINvB0sHNySDP?=
*/
-void StrBuf_RFC822_to_Utf8(StrBuf *Target, StrBuf *DecodeMe, const StrBuf* DefaultCharset, StrBuf *FoundCharset)
+void StrBuf_RFC822_to_Utf8(StrBuf *Target, const StrBuf *DecodeMe, const StrBuf* DefaultCharset, StrBuf *FoundCharset)
{
StrBuf *ConvertBuf, *ConvertBuf2;
char *start, *end, *next, *nextend, *ptr = NULL;
{
ctdl_iconv_open("UTF-8", ChrPtr(DefaultCharset), &ic);
if (ic != (iconv_t)(-1) ) {
- StrBufConvert(DecodeMe, ConvertBuf, &ic);
+ StrBufConvert((StrBuf*)DecodeMe, ConvertBuf, &ic);///TODO: don't void const?
iconv_close(ic);
}
}
len - (next - start));
/* now terminate the gab at the end */
- delta = (next - end) - 2;
- DecodeMe->BufUsed -= delta;
- DecodeMe->buf[DecodeMe->BufUsed] = '\0';
+ delta = (next - end) - 2; ////TODO: const!
+ ((StrBuf*)DecodeMe)->BufUsed -= delta;
+ ((StrBuf*)DecodeMe)->buf[DecodeMe->BufUsed] = '\0';
/* move next to its new location. */
next -= delta;