unsigned long StrBufExtract_unsigned_long(const StrBuf* Source, int parmnum, char separator);
long StrBufExtract_long(const StrBuf* Source, int parmnum, char separator);
int StrBufExtract_int(const StrBuf* Source, int parmnum, char separator);
-inline int StrBufNum_tokens(const StrBuf *source, char tok);
+int StrBufNum_tokens(const StrBuf *source, char tok);
int StrBufRemove_token(StrBuf *Source, int parmnum, char separator);
int StrBufExtract_NextToken(StrBuf *dest, const StrBuf *Source, const char **pStart, char separator);
void CtdlInitBase64Table(void);
size_t CtdlEncodeBase64(char *dest, const char *source, size_t sourcelen, int linebreaks);
int CtdlDecodeBase64(char *dest, const char *source, size_t length);
-inline unsigned int decode_hex(char *Source);
+unsigned int decode_hex(char *Source);
int CtdlDecodeQuotedPrintable(char *decoded, char *encoded, int sourcelen);
void striplt(char *);
int haschar(const char *st, int ch);
}
-unsigned int decode_hex(char *Source)
+static inline unsigned int _decode_hex(char *Source)
{
int ret = 0;
- if (*Source < 'A') {
+ if ((*Source >= '0') && (*Source <= '9')) {
ret += (*Source - '0');
}
- else if (*Source > 'Z') {
+ else if ((*Source >= 'A') && (*Source <= 'F')) {
+ ret += (*Source - 'A' + 10);
+ }
+ else if ((*Source >= 'a') && (*Source <= 'f')) {
ret += (*Source - 'a' + 10);
}
else {
- ret += (*Source - 'A' + 10);
+ return '?';
}
-
+
ret = ret << 4;
-
- if (*(Source + 1) < 'A') {
- ret += (*(Source + 1) - '0');
+
+ if ((*(Source + 1) >= '0') && (*(Source + 1) <= '9')) {
+ ret |= (*(Source + 1) - '0');
}
- else if (*(Source + 1) > 'Z') {
- ret += (*(Source + 1) - 'a' + 10);
+ else if ((*(Source + 1) >= 'A') && (*(Source + 1) <= 'F')) {
+ ret |= (*(Source + 1) - 'A' + 10);
}
- else {
- ret += (*(Source + 1) - 'A' + 10);
+ else if ((*(Source + 1) >= 'a') && (*(Source + 1) <= 'f')) {
+ ret |= (*(Source + 1) - 'a' + 10);
}
- if (ret > 255)
+ else {
return '?';
+ }
return ret;
}
+unsigned int decode_hex(char *Source) {return _decode_hex(Source);}
+
/*
* Convert "quoted-printable" to binary. Returns number of bytes decoded.
* according to RFC2045 section 6.7
else if (encoded[pos] == '=')
{
ch = 0;
- ch = decode_hex(&encoded[pos+1]);
+ ch = _decode_hex(&encoded[pos+1]);
pos += 3;
decoded[decoded_length++] = ch;
}
* \param tok Tokenizer char to count
* \returns numbers of tokenizer chars found
*/
-inline int StrBufNum_tokens(const StrBuf *source, char tok)
+int StrBufNum_tokens(const StrBuf *source, char tok)
{
if (source == NULL)
return 0;