19 #ifdef USE_WINDOWS_DEBUG 20 #define WIN32_LEAN_AND_MEAN 34 void log(
int level,
const char* msg) {
35 #ifdef USE_WINDOWS_DEBUG 36 if (level <= _verbosity) { OutputDebugString(msg); OutputDebugString(
"\n"); }
38 if (level <= _verbosity) std::cout << msg << std::endl;
52 #ifdef USE_WINDOWS_DEBUG 53 void error(
const char* msg) {
54 OutputDebugString(msg); OutputDebugString(
"\n");
88 std::vsnprintf(buf,
sizeof(buf)-1,fmt,va);
90 buf[
sizeof(buf)-1] = 0;
101 std::vsnprintf(buf,
sizeof(buf)-1,fmt,va);
103 buf[
sizeof(buf)-1] = 0;
114 if (offset == NULL)
return std::string();
116 if (xml.length() > size_t(INT_MAX))
return std::string();
117 if (*offset >=
int(xml.length()))
return std::string();
118 size_t istart = xml.find(tag, *offset);
119 if (istart == std::string::npos)
return std::string();
120 istart += strlen(tag);
121 std::string etag =
"</";
123 size_t iend = xml.find(etag, istart);
124 if (iend == std::string::npos)
return std::string();
126 *offset = int(iend + etag.length());
127 return xml.substr(istart, iend-istart);
135 if (offset == NULL)
return false;
136 if (xml.length() > size_t(INT_MAX))
return false;
137 if (*offset >=
int(xml.length()))
return false;
138 size_t istart = xml.find(tag, *offset);
139 if (istart == std::string::npos)
142 *offset = int(istart + strlen(tag));
152 if (offset == NULL)
return false;
153 if (xml.length() > size_t(INT_MAX))
return false;
154 if (*offset >=
int(xml.length()))
return false;
155 const char* cp = xml.c_str() + *offset;
157 while (*cp && isspace(*cp)) {
162 int len = int(strlen(tag));
163 if (*cp && (strncmp(cp, tag, len) == 0)) {
175 if (offset == NULL)
return std::string();
176 if (xml.length() > size_t(INT_MAX))
return std::string();
177 if (*offset >=
int(xml.length()))
return std::string();
179 const char* start_cp = xml.c_str() + *offset;
180 const char* cp = start_cp;
181 while (*cp && isspace(*cp)) {
185 const int len = int(strnlen(tag, xml.length()));
187 if (!(*cp) || (strncmp(cp, tag, len) != 0)) {
188 return std::string();
204 return std::string();
208 std::string etag =
"</";
211 if (strncmp(cp, etag.c_str(), etag.length()) != 0) {
212 return std::string();
217 *offset += (cp - start_cp);
227 if (offset == NULL)
return std::string();
228 if (xml.length() > size_t(INT_MAX))
return std::string();
229 if (*offset >=
int(xml.length()))
return std::string();
231 size_t pos = *offset;
232 const char* cp = xml.c_str() + pos;
233 while (*cp && isspace(*cp)) {
238 if (*cp !=
'<')
return std::string();
244 }
while (*cp++ !=
'>' && *cp != 0);
253 static const char AMP =
'&';
254 static const char rawEntity[] = {
'<',
'>',
'&',
'\'',
'\"', 0 };
255 static const char*
xmlEntity[] = {
"lt;",
"gt;",
"amp;",
"apos;",
"quot;", 0 };
264 std::string::size_type iAmp = encoded.find(AMP);
265 if (iAmp == std::string::npos)
268 std::string decoded(encoded, 0, iAmp);
269 std::string::size_type iSize = encoded.size();
270 decoded.reserve(iSize);
272 const char* ens = encoded.c_str();
273 while (iAmp != iSize) {
274 if (encoded[iAmp] == AMP && iAmp+1 < iSize) {
276 for (iEntity=0; xmlEntity[iEntity] != 0; ++iEntity)
278 if (strncmp(ens+iAmp+1, xmlEntity[iEntity], xmlEntLen[iEntity]) == 0)
280 decoded += rawEntity[iEntity];
281 iAmp += xmlEntLen[iEntity]+1;
284 if (xmlEntity[iEntity] == 0)
285 decoded += encoded[iAmp++];
288 decoded += encoded[iAmp++];
301 std::string::size_type iRep = raw.find_first_of(rawEntity);
302 if (iRep == std::string::npos)
305 std::string encoded(raw, 0, iRep);
306 std::string::size_type iSize = raw.size();
308 while (iRep != iSize) {
310 for (iEntity=0; rawEntity[iEntity] != 0; ++iEntity)
311 if (raw[iRep] == rawEntity[iEntity])
314 encoded += xmlEntity[iEntity];
317 if (rawEntity[iEntity] == 0)
318 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.
XMLRPCPP_DECL const char XMLRPC_VERSION[]
Version identifier.
static std::string nextTagData(const char *tag, std::string const &xml, int *offset)
static XMLRPCPP_DECL int _verbosity
static XMLRPCPP_DECL 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)
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.
XMLRPCPP_DECL int getVerbosity()
Returns log message verbosity. This is short for XmlRpcLogHandler::getVerbosity() ...
XMLRPCPP_DECL 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 XMLRPCPP_DECL 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.