debug msg
This commit is contained in:
parent
d12021b22c
commit
af8bfb3fe7
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: mimeparse.cpp,v 1.17 2006-11-30 13:38:44 dockes Exp $ (C) 2004 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: mimeparse.cpp,v 1.18 2007-01-18 14:23:42 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -38,6 +38,13 @@ static char rcsid[] = "@(#$Id: mimeparse.cpp,v 1.17 2006-11-30 13:38:44 dockes E
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
#endif /* NO_NAMESPACES */
|
#endif /* NO_NAMESPACES */
|
||||||
|
|
||||||
|
//#define DEBUG_MIMEPARSE
|
||||||
|
#ifdef DEBUG_MIMEPARSE
|
||||||
|
#define DPRINT(X) fprintf X
|
||||||
|
#else
|
||||||
|
#define DPRINT(X)
|
||||||
|
#endif
|
||||||
|
|
||||||
// Parsing a header value. Only content-type and content-disposition
|
// Parsing a header value. Only content-type and content-disposition
|
||||||
// have parameters, but others are compatible with content-type
|
// have parameters, but others are compatible with content-type
|
||||||
// syntax, only, parameters are not used. So we can parse all like:
|
// syntax, only, parameters are not used. So we can parse all like:
|
||||||
@ -426,15 +433,15 @@ static bool rfc2047_decodeParsed(const std::string& charset,
|
|||||||
const std::string& value,
|
const std::string& value,
|
||||||
std::string &utf8)
|
std::string &utf8)
|
||||||
{
|
{
|
||||||
// fprintf(stderr, "DecodeParsed: charset [%s] enc [%s] val [%s]\n",
|
DPRINT((stderr, "DecodeParsed: charset [%s] enc [%s] val [%s]\n",
|
||||||
// charset.c_str(), encoding.c_str(), value.c_str());
|
charset.c_str(), encoding.c_str(), value.c_str()));
|
||||||
utf8 = "";
|
utf8 = "";
|
||||||
|
|
||||||
string decoded;
|
string decoded;
|
||||||
if (!stringlowercmp("b", encoding)) {
|
if (!stringlowercmp("b", encoding)) {
|
||||||
if (!base64_decode(value, decoded))
|
if (!base64_decode(value, decoded))
|
||||||
return false;
|
return false;
|
||||||
// fprintf(stderr, "FromB64: [%s]\n", decoded.c_str());
|
DPRINT((stderr, "FromB64: [%s]\n", decoded.c_str()));
|
||||||
} else if (!stringlowercmp("q", encoding)) {
|
} else if (!stringlowercmp("q", encoding)) {
|
||||||
if (!qp_decode(value, decoded))
|
if (!qp_decode(value, decoded))
|
||||||
return false;
|
return false;
|
||||||
@ -446,14 +453,14 @@ static bool rfc2047_decodeParsed(const std::string& charset,
|
|||||||
else
|
else
|
||||||
temp += decoded[pos];
|
temp += decoded[pos];
|
||||||
decoded = temp;
|
decoded = temp;
|
||||||
// fprintf(stderr, "FromQP: [%s]\n", decoded.c_str());
|
DPRINT((stderr, "FromQP: [%s]\n", decoded.c_str()));
|
||||||
} else {
|
} else {
|
||||||
// fprintf(stderr, "Bad encoding [%s]\n", encoding.c_str());
|
DPRINT((stderr, "Bad encoding [%s]\n", encoding.c_str()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!transcode(decoded, utf8, charset, "UTF-8")) {
|
if (!transcode(decoded, utf8, charset, "UTF-8")) {
|
||||||
// fprintf(stderr, "Transcode failed\n");
|
DPRINT((stderr, "Transcode failed\n"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -471,6 +478,8 @@ typedef enum {rfc2047base, rfc2047ready, rfc2047open_eq,
|
|||||||
|
|
||||||
bool rfc2047_decode(const std::string& in, std::string &out)
|
bool rfc2047_decode(const std::string& in, std::string &out)
|
||||||
{
|
{
|
||||||
|
DPRINT((stderr, "rfc2047_decode: [%s]\n", in.c_str()));
|
||||||
|
|
||||||
Rfc2047States state = rfc2047ready;
|
Rfc2047States state = rfc2047ready;
|
||||||
string encoding, charset, value, utf8;
|
string encoding, charset, value, utf8;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user