void ctdl_iconv_open(const char *tocode, const char *fromcode, void *pic);
void StrBuf_RFC822_to_Utf8(StrBuf *Target, const StrBuf *DecodeMe, const StrBuf* DefaultCharset, StrBuf *FoundCharset);
int StrBufDecodeBase64(StrBuf *Buf);
+int StrBufDecodeHex(StrBuf *Buf);
int StrBufRFC2047encode(StrBuf **target, const StrBuf *source);
int StrBufSanitizeAscii(StrBuf *Buf, const char Mute);
#define LB (1) /* Internal escape chars */
*fd = -1;
return -1;
}
- if (FD_ISSET(*fd, &rfds)) {
+ if (FD_ISSET(*fd, &rfds) != 0) {
rlen = read(*fd,
&buf->buf[buf->BufUsed],
buf->BufSize - buf->BufUsed - 1);
return siz;
}
+/**
+ * \brief decode a buffer from base 64 encoding; destroys original
+ * \param Buf Buffor to transform
+ */
+int StrBufDecodeHex(StrBuf *Buf)
+{
+ unsigned int ch;
+ char *pch, *pche, *pchi;
+
+ if (Buf == NULL) return -1;
+
+ pch = pchi = Buf->buf;
+ pche = pch + Buf->BufUsed;
+
+ while (pchi < pche){
+ ch = decode_hex(pchi);
+ *pch = ch;
+ pch ++;
+ pchi += 2;
+ }
+
+ *pch = '\0';
+ Buf->BufUsed = pch - Buf->buf;
+ return Buf->BufUsed;
+}
+
/**
* \brief replace all chars >0x20 && < 0x7F with Mute
* \param Mute char to put over invalid chars