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 #ifdef USE_WINDOWS_DEBUG 52 void error(
const char* msg) {
53 OutputDebugString(msg); OutputDebugString(
"\n");
87 vsnprintf(buf,
sizeof(buf)-1,fmt,va);
89 buf[
sizeof(buf)-1] = 0;
100 vsnprintf(buf,
sizeof(buf)-1,fmt,va);
102 buf[
sizeof(buf)-1] = 0;
112 if (xml.length() > size_t(__INT_MAX__))
return std::string();
113 if (*offset >=
int(xml.length()))
return std::string();
114 size_t istart = xml.find(tag, *offset);
115 if (istart == std::string::npos)
return std::string();
116 istart += strlen(tag);
117 std::string etag =
"</";
119 size_t iend = xml.find(etag, istart);
120 if (iend == std::string::npos)
return std::string();
122 *offset = int(iend + etag.length());
123 return xml.substr(istart, iend-istart);
131 if (xml.length() > size_t(__INT_MAX__))
return false;
132 if (*offset >=
int(xml.length()))
return false;
133 size_t istart = xml.find(tag, *offset);
134 if (istart == std::string::npos)
137 *offset = int(istart + strlen(tag));
147 if (xml.length() > size_t(__INT_MAX__))
return false;
148 if (*offset >=
int(xml.length()))
return false;
149 const char* cp = xml.c_str() + *offset;
151 while (*cp && isspace(*cp)) {
156 int len = int(strlen(tag));
157 if (*cp && (strncmp(cp, tag, len) == 0)) {
169 if (xml.length() > size_t(__INT_MAX__))
return std::string();
170 if (*offset >=
int(xml.length()))
return std::string();
172 size_t pos = *offset;
173 const char* cp = xml.c_str() + pos;
174 while (*cp && isspace(*cp)) {
179 if (*cp !=
'<')
return std::string();
185 }
while (*cp++ !=
'>' && *cp != 0);
194 static const char AMP =
'&';
195 static const char rawEntity[] = {
'<',
'>',
'&',
'\'',
'\"', 0 };
196 static const char*
xmlEntity[] = {
"lt;",
"gt;",
"amp;",
"apos;",
"quot;", 0 };
205 std::string::size_type iAmp = encoded.find(AMP);
206 if (iAmp == std::string::npos)
209 std::string decoded(encoded, 0, iAmp);
210 std::string::size_type iSize = encoded.size();
211 decoded.reserve(iSize);
213 const char* ens = encoded.c_str();
214 while (iAmp != iSize) {
215 if (encoded[iAmp] == AMP && iAmp+1 < iSize) {
217 for (iEntity=0; xmlEntity[iEntity] != 0; ++iEntity)
219 if (strncmp(ens+iAmp+1, xmlEntity[iEntity], xmlEntLen[iEntity]) == 0)
221 decoded += rawEntity[iEntity];
222 iAmp += xmlEntLen[iEntity]+1;
225 if (xmlEntity[iEntity] == 0)
226 decoded += encoded[iAmp++];
229 decoded += encoded[iAmp++];
242 std::string::size_type iRep = raw.find_first_of(rawEntity);
243 if (iRep == std::string::npos)
246 std::string encoded(raw, 0, iRep);
247 std::string::size_type iSize = raw.size();
249 while (iRep != iSize) {
251 for (iEntity=0; rawEntity[iEntity] != 0; ++iEntity)
252 if (raw[iRep] == rawEntity[iEntity])
255 encoded += xmlEntity[iEntity];
258 if (rawEntity[iEntity] == 0)
259 encoded += raw[iRep];
static XmlRpcLogHandler * getLogHandler()
Returns a pointer to the currently installed message reporting object.
void log(int level, const char *msg)
Output a message. Custom error handlers should define this method.
const char XMLRPC_VERSION[]
Version identifier.
static XmlRpcErrorHandler * _errorHandler
static int getVerbosity()
Returns the level of verbosity of informational messages. 0 is no output, 5 is very verbose...
static const char rawEntity[]
static std::string getNextTag(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 setVerbosity(int v)
Specify the level of verbosity of informational messages. 0 is no output, 5 is very verbose...
static XmlRpcErrorHandler * getErrorHandler()
Returns a pointer to the currently installed error handling object.
static void error(const char *fmt,...)
Dump error messages somewhere.
DefaultErrorHandler defaultErrorHandler
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.
virtual void error(const char *msg)=0
Report an error. Custom error handlers should define this method.
int getVerbosity()
Returns log message verbosity. This is short for XmlRpcLogHandler::getVerbosity() ...
void setVerbosity(int level)
Sets log message verbosity. This is short for XmlRpcLogHandler::setVerbosity(level) ...
An interface allowing custom handling of informational message reporting.
static XmlRpcLogHandler * _logHandler
DefaultLogHandler defaultLogHandler
static std::string xmlEncode(const std::string &raw)
Convert raw text to encoded xml.
void error(const char *)
Report an error. Custom error handlers should define this method.
static const int xmlEntLen[]
static std::string xmlDecode(const std::string &encoded)
Convert encoded xml to raw text.
static void log(int level, const char *fmt,...)
Dump messages somewhere.
static bool nextTagIs(const char *tag, std::string const &xml, int *offset)
static const char * xmlEntity[]
virtual void log(int level, const char *msg)=0
Output a message. Custom error handlers should define this method.
An interface allowing custom handling of error message reporting.