18#ifdef USE_WINDOWS_DEBUG
19#define WIN32_LEAN_AND_MEAN
33 void log(
int level,
const char* msg) {
34#ifdef USE_WINDOWS_DEBUG
35 if (level <=
_verbosity) { OutputDebugString(msg); OutputDebugString(
"\n"); }
37 if (level <=
_verbosity) std::cout << msg << std::endl;
51 void error(
const char* msg) {
52#ifdef USE_WINDOWS_DEBUG
53 OutputDebugString(msg); OutputDebugString(
"\n");
55 std::cerr << msg << std::endl;
78 vsnprintf(buf,
sizeof(buf)-1,fmt,va);
79 buf[
sizeof(buf)-1] = 0;
90 vsnprintf(buf,
sizeof(buf)-1,fmt,va);
91 buf[
sizeof(buf)-1] = 0;
100 if (*offset >=
int(xml.length()))
return std::string();
101 size_t istart = xml.find(tag, *offset);
102 if (istart == std::string::npos)
return std::string();
103 istart += strlen(tag);
104 std::string etag =
"</";
106 size_t iend = xml.find(etag, istart);
107 if (iend == std::string::npos)
return std::string();
109 *offset = int(iend + etag.length());
110 return xml.substr(istart, iend-istart);
118 if (*offset >=
int(xml.length()))
return false;
119 size_t istart = xml.find(tag, *offset);
120 if (istart == std::string::npos)
123 *offset = int(istart + strlen(tag));
133 if (*offset >=
int(xml.length()))
return false;
134 const char* cp = xml.c_str() + *offset;
136 while (*cp && isspace(*cp)) {
141 int len = int(strlen(tag));
142 if (*cp && (strncmp(cp, tag, len) == 0)) {
154 if (*offset >=
int(xml.length()))
return std::string();
156 size_t pos = *offset;
157 const char* cp = xml.c_str() + pos;
158 while (*cp && isspace(*cp)) {
163 if (*cp !=
'<')
return std::string();
169 }
while (*cp++ !=
'>' && *cp != 0);
178static const char AMP =
'&';
179static const char rawEntity[] = {
'<',
'>',
'&',
'\'',
'\"', 0 };
180static const char* xmlEntity[] = {
"lt;",
"gt;",
"amp;",
"apos;",
"quot;", 0 };
181static const int xmlEntLen[] = { 3, 3, 4, 5, 5 };
189 std::string::size_type iAmp = encoded.find(AMP);
190 if (iAmp == std::string::npos)
193 std::string decoded(encoded, 0, iAmp);
194 std::string::size_type iSize = encoded.size();
195 decoded.reserve(iSize);
197 const char* ens = encoded.c_str();
198 while (iAmp != iSize) {
199 if (encoded[iAmp] == AMP && iAmp+1 < iSize) {
201 for (iEntity=0; xmlEntity[iEntity] != 0; ++iEntity)
203 if (strncmp(ens+iAmp+1, xmlEntity[iEntity], xmlEntLen[iEntity]) == 0)
205 decoded += rawEntity[iEntity];
206 iAmp += xmlEntLen[iEntity]+1;
209 if (xmlEntity[iEntity] == 0)
210 decoded += encoded[iAmp++];
213 decoded += encoded[iAmp++];
226 std::string::size_type iRep = raw.find_first_of(rawEntity);
227 if (iRep == std::string::npos)
230 std::string encoded(raw, 0, iRep);
231 std::string::size_type iSize = raw.size();
233 while (iRep != iSize) {
235 for (iEntity=0; rawEntity[iEntity] != 0; ++iEntity)
236 if (raw[iRep] == rawEntity[iEntity])
239 encoded += xmlEntity[iEntity];
242 if (rawEntity[iEntity] == 0)
243 encoded += raw[iRep];
An interface allowing custom handling of error message reporting.
static XmlRpcErrorHandler * getErrorHandler()
Returns a pointer to the currently installed error handling object.
virtual void error(const char *msg)=0
Report an error. Custom error handlers should define this method.
static XmlRpcErrorHandler * _errorHandler
An interface allowing custom handling of informational message reporting.
static XmlRpcLogHandler * getLogHandler()
Returns a pointer to the currently installed message reporting object.
virtual void log(int level, const char *msg)=0
Output a message. Custom error handlers should define this method.
static int getVerbosity()
Returns the level of verbosity of informational messages. 0 is no output, 5 is very verbose.
static void setVerbosity(int v)
Specify the level of verbosity of informational messages. 0 is no output, 5 is very verbose.
static XmlRpcLogHandler * _logHandler
static bool nextTagIs(const char *tag, std::string const &xml, int *offset)
static std::string parseTag(const char *tag, std::string const &xml, int *offset)
Returns contents between <tag> and </tag>, updates offset to char after </tag>
static void error(const char *fmt,...)
Dump error messages somewhere.
static std::string xmlEncode(const std::string &raw)
Convert raw text to encoded xml.
static bool findTag(const char *tag, std::string const &xml, int *offset)
Returns true if the tag is found and updates offset to the char after the tag.
static void log(int level, const char *fmt,...)
Dump messages somewhere.
static std::string getNextTag(std::string const &xml, int *offset)
static std::string xmlDecode(const std::string &encoded)
Convert encoded xml to raw text.
int getVerbosity()
Returns log message verbosity. This is short for XmlRpcLogHandler::getVerbosity()
const char XMLRPC_VERSION[]
Version identifier.
void setVerbosity(int level)
Sets log message verbosity. This is short for XmlRpcLogHandler::setVerbosity(level)