From ddc3964ed95d01e72229dc9af968a327cd84e56c Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Fri, 1 Oct 2004 13:21:35 +0000 Subject: - add python, missing gui - remove console (needs to be rewritten anyway) - eString -> std::string --- lib/network/Makefile.am | 4 +- lib/network/http_dyn.cpp | 18 ++++----- lib/network/http_dyn.h | 14 +++---- lib/network/http_file.cpp | 28 +++++++------- lib/network/http_file.h | 10 ++--- lib/network/httpd.cpp | 41 +++++++++++---------- lib/network/httpd.h | 10 ++--- lib/network/serversocket.lo | Bin 191574 -> 191634 bytes lib/network/socket.cpp | 8 ++-- lib/network/socket.h | 6 +-- lib/network/socket.lo | Bin 224253 -> 224321 bytes lib/network/xmlrpc.cpp | 88 ++++++++++++++++++++++---------------------- lib/network/xmlrpc.h | 28 +++++++------- 13 files changed, 130 insertions(+), 125 deletions(-) (limited to 'lib/network') diff --git a/lib/network/Makefile.am b/lib/network/Makefile.am index cfdc79b1..f5efef9a 100644 --- a/lib/network/Makefile.am +++ b/lib/network/Makefile.am @@ -4,4 +4,6 @@ INCLUDES = \ noinst_LIBRARIES = libenigma_network.a libenigma_network_a_SOURCES = \ - http_dyn.cpp http_file.cpp httpd.cpp serversocket.cpp socket.cpp xmlrpc.cpp + http_dyn.cpp http_file.cpp httpd.cpp serversocket.cpp socket.cpp + +# xmlrpc.cpp diff --git a/lib/network/http_dyn.cpp b/lib/network/http_dyn.cpp index d020133a..eb94d462 100644 --- a/lib/network/http_dyn.cpp +++ b/lib/network/http_dyn.cpp @@ -1,6 +1,6 @@ #include -eHTTPDyn::eHTTPDyn(eHTTPConnection *c, eString result): eHTTPDataSource(c), result(result) +eHTTPDyn::eHTTPDyn(eHTTPConnection *c, std::string result): eHTTPDataSource(c), result(result) { wptr=0; char buffer[10]; @@ -34,18 +34,18 @@ eHTTPDynPathResolver::eHTTPDynPathResolver() #warning autodelete removed } -void eHTTPDynPathResolver::addDyn(eString request, eString path, eString (*function)(eString, eString, eString, eHTTPConnection*)) +void eHTTPDynPathResolver::addDyn(std::string request, std::string path, std::string (*function)(std::string, std::string, std::string, eHTTPConnection*)) { dyn.push_back(new eHTTPDynEntry(request, path, function)); } -eHTTPDataSource *eHTTPDynPathResolver::getDataSource(eString request, eString path, eHTTPConnection *conn) +eHTTPDataSource *eHTTPDynPathResolver::getDataSource(std::string request, std::string path, eHTTPConnection *conn) { - eString p, opt; - if (path.find('?')!=eString::npos) + std::string p, opt; + if (path.find('?')!=std::string::npos) { - p=path.left(path.find('?')); - opt=path.mid(path.find('?')+1); + p=path.substr(0, path.find('?')); + opt=path.substr(path.find('?')+1); } else { p=path; @@ -55,9 +55,9 @@ eHTTPDataSource *eHTTPDynPathResolver::getDataSource(eString request, eString pa if ((i->path==p) && (i->request==request)) { conn->code=-1; - eString s=i->function(request, path, opt, conn); + std::string s=i->function(request, path, opt, conn); - if (s) + if (!s.empty()) return new eHTTPDyn(conn, s); return new eHTTPError(conn, 500); diff --git a/lib/network/http_dyn.h b/lib/network/http_dyn.h index 6fb8b9b1..d714403b 100644 --- a/lib/network/http_dyn.h +++ b/lib/network/http_dyn.h @@ -5,10 +5,10 @@ class eHTTPDyn: public eHTTPDataSource { - eString result; + std::string result; int wptr, size; public: - eHTTPDyn(eHTTPConnection *c, eString result); + eHTTPDyn(eHTTPConnection *c, std::string result); ~eHTTPDyn(); int doWrite(int); }; @@ -17,18 +17,18 @@ class eHTTPDynPathResolver: public eHTTPPathResolver { struct eHTTPDynEntry { - eString request, path; - eString (*function)(eString request, eString path, eString opt, eHTTPConnection *content); + std::string request, path; + std::string (*function)(std::string request, std::string path, std::string opt, eHTTPConnection *content); - eHTTPDynEntry(eString request, eString path, eString (*function)(eString, eString, eString, eHTTPConnection *)): request(request), path(path), function(function) + eHTTPDynEntry(std::string request, std::string path, std::string (*function)(std::string, std::string, std::string, eHTTPConnection *)): request(request), path(path), function(function) { } }; ePtrList dyn; public: - void addDyn(eString request, eString path, eString (*function)(eString, eString, eString, eHTTPConnection *conn)); + void addDyn(std::string request, std::string path, std::string (*function)(std::string, std::string, std::string, eHTTPConnection *conn)); eHTTPDynPathResolver(); - eHTTPDataSource *getDataSource(eString request, eString path, eHTTPConnection *conn); + eHTTPDataSource *getDataSource(std::string request, std::string path, eHTTPConnection *conn); }; #endif diff --git a/lib/network/http_file.cpp b/lib/network/http_file.cpp index 19c8a15f..2b47d63c 100644 --- a/lib/network/http_file.cpp +++ b/lib/network/http_file.cpp @@ -64,7 +64,7 @@ eHTTPFilePathResolver::eHTTPFilePathResolver() static char _base64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; -static int unbase64(eString &dst, const eString string) +static int unbase64(std::string &dst, const std::string string) { dst=""; char c[4]; @@ -124,21 +124,21 @@ int CheckUnixPassword(const char *user, const char *pass) return !!strcmp(cres, cpwd); } -static int checkAuth(const eString cauth) +static int checkAuth(const std::string cauth) { - eString auth; - if (cauth.left(6) != "Basic ") + std::string auth; + if (cauth.substr(0, 6) != "Basic ") return -1; - if (unbase64(auth, cauth.mid(6))) + if (unbase64(auth, cauth.substr(6))) return -1; - eString username=auth.left(auth.find(":")); - eString password=auth.mid(auth.find(":")+1); + std::string username=auth.substr(0, auth.find(":")); + std::string password=auth.substr(auth.find(":")+1); if (CheckUnixPassword(username.c_str(), password.c_str())) return -1; return 0; } -eHTTPDataSource *eHTTPFilePathResolver::getDataSource(eString request, eString path, eHTTPConnection *conn) +eHTTPDataSource *eHTTPFilePathResolver::getDataSource(std::string request, std::string path, eHTTPConnection *conn) { int method; eDebug("request = %s, path = %s", request.c_str(), path.c_str()); @@ -148,7 +148,7 @@ eHTTPDataSource *eHTTPFilePathResolver::getDataSource(eString request, eString p method=eHTTPFile::methodPUT; else return new eHTTPError(conn, 405); // method not allowed - if (path.find("../")!=eString::npos) // evil hax0r + if (path.find("../")!=std::string::npos) // evil hax0r return new eHTTPError(conn, 403); if (path[0] != '/') // prepend '/' path.insert(0,"/"); @@ -158,11 +158,11 @@ eHTTPDataSource *eHTTPFilePathResolver::getDataSource(eString request, eString p eHTTPDataSource *data=0; for (ePtrList::iterator i(translate); i != translate.end(); ++i) { - if (i->root==path.left(i->root.length())) + if (i->root==path.substr(0, i->root.length())) { - eString newpath=i->path+path.mid(i->root.length()); + std::string newpath=i->path+path.substr(i->root.length()); if (newpath.find('?')) - newpath=newpath.left(newpath.find('?')); + newpath=newpath.substr(0, newpath.find('?')); eDebug("translated %s to %s", path.c_str(), newpath.c_str()); if (i->authorized & ((method==eHTTPFile::methodGET)?1:2)) @@ -194,7 +194,7 @@ eHTTPDataSource *eHTTPFilePathResolver::getDataSource(eString request, eString p break; } - eString ext=path.mid(path.rfind('.')); + std::string ext=path.substr(path.rfind('.')); const char *mime="text/unknown"; if ((ext==".html") || (ext==".htm")) mime="text/html"; @@ -218,7 +218,7 @@ eHTTPDataSource *eHTTPFilePathResolver::getDataSource(eString request, eString p return data; } -void eHTTPFilePathResolver::addTranslation(eString path, eString root, int authorized) +void eHTTPFilePathResolver::addTranslation(std::string path, std::string root, int authorized) { if (path[path.length()-1]!='/') path+='/'; diff --git a/lib/network/http_file.h b/lib/network/http_file.h index 88bffc60..109dc07e 100644 --- a/lib/network/http_file.h +++ b/lib/network/http_file.h @@ -20,18 +20,18 @@ class eHTTPFilePathResolver: public eHTTPPathResolver { struct eHTTPFilePath { - eString path; - eString root; + std::string path; + std::string root; int authorized; // must be authorized (1 means read, 2 write) - eHTTPFilePath(eString path, eString root, int authorized): path(path), root(root), authorized(authorized) + eHTTPFilePath(std::string path, std::string root, int authorized): path(path), root(root), authorized(authorized) { } }; ePtrList translate; public: eHTTPFilePathResolver(); - eHTTPDataSource *getDataSource(eString request, eString path, eHTTPConnection *conn); - void addTranslation(eString path, eString root, int auth); + eHTTPDataSource *getDataSource(std::string request, std::string path, eHTTPConnection *conn); + void addTranslation(std::string path, std::string root, int auth); }; #endif diff --git a/lib/network/httpd.cpp b/lib/network/httpd.cpp index acd3ebe6..f706ccf8 100644 --- a/lib/network/httpd.cpp +++ b/lib/network/httpd.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -26,7 +27,7 @@ int eHTTPDataSource::doWrite(int) eHTTPError::eHTTPError(eHTTPConnection *c, int errcode): eHTTPDataSource(c), errcode(errcode) { - eString error="unknown error"; + std::string error="unknown error"; switch (errcode) { case 400: error="Bad Request"; break; @@ -44,9 +45,9 @@ eHTTPError::eHTTPError(eHTTPConnection *c, int errcode): eHTTPDataSource(c), err int eHTTPError::doWrite(int w) { - eString html; - html+="Error "+eString().setNum(connection->code)+""+ - "

Error "+eString().setNum(errcode)+": "+connection->code_descr+"

\n"; + std::string html; + html+="Error " + getNum(connection->code) + ""+ + "

Error " + getNum(errcode) + ": " + connection->code_descr + "

\n"; connection->writeBlock(html.c_str(), html.length()); return -1; } @@ -266,7 +267,7 @@ int eHTTPConnection::processLocalState() #ifdef DEBUG_HTTPD eDebug("local request"); #endif - eString req=request+" "+requestpath+" "+httpversion+"\r\n"; + std::string req=request+" "+requestpath+" "+httpversion+"\r\n"; writeBlock(req.c_str(), req.length()); localstate=stateHeader; remotestate=stateResponse; @@ -277,7 +278,7 @@ int eHTTPConnection::processLocalState() #ifdef DEBUG_HTTPD eDebug("local Response"); #endif - writeString( (httpversion + " " + eString().setNum(code)+" " + code_descr + "\r\n").c_str() ); + writeString( (httpversion + " " + getNum(code) + " " + code_descr + "\r\n").c_str() ); localstate=stateHeader; local_header["Connection"]="close"; break; @@ -323,7 +324,7 @@ int eHTTPConnection::processLocalState() // move to stateClose if (remote_header.find("Connection") != remote_header.end()) { - eString &connection=remote_header["Connection"]; + std::string &connection=remote_header["Connection"]; if (connection == "keep-alive") localstate=stateWait; else @@ -387,7 +388,7 @@ int eHTTPConnection::processRemoteState() #ifdef DEBUG_HTTPD eDebug("stateRequest"); #endif - eString line; + std::string line; if (!getLine(line)) { done=1; @@ -412,16 +413,16 @@ int eHTTPConnection::processRemoteState() return -1; break; } - request=line.left(del[0]); - requestpath=line.mid(del[0]+1, (del[1]==-1)?-1:(del[1]-del[0]-1)); + request=line.substr(0, del[0]); + requestpath=line.substr(del[0]+1, (del[1]==-1)?-1:(del[1]-del[0]-1)); if (del[1]!=-1) { is09=0; - httpversion=line.mid(del[1]+1); + httpversion=line.substr(del[1]+1); } else is09=1; - if (is09 || (httpversion.left(7) != "HTTP/1.") || httpversion.size()!=8) + if (is09 || (httpversion.substr(0, 7) != "HTTP/1.") || httpversion.size()!=8) { remotestate=stateData; done=0; @@ -437,7 +438,7 @@ int eHTTPConnection::processRemoteState() #ifdef DEBUG_HTTPD eDebug("state response.."); #endif - eString line; + std::string line; if (!getLine(line)) { done=1; @@ -454,10 +455,10 @@ int eHTTPConnection::processRemoteState() code=-1; else { - httpversion=line.left(del[0]); - code=atoi(line.mid(del[0]+1, (del[1]==-1)?-1:(del[1]-del[0]-1)).c_str()); + httpversion=line.substr(0, del[0]); + code=atoi(line.substr(del[0]+1, (del[1]==-1)?-1:(del[1]-del[0]-1)).c_str()); if (del[1] != -1) - code_descr=line.mid(del[1]+1); + code_descr=line.substr(del[1]+1); else code_descr=""; } @@ -470,7 +471,7 @@ int eHTTPConnection::processRemoteState() #ifdef DEBUG_HTTPD eDebug("remote stateHeader"); #endif - eString line; + std::string line; if (!getLine(line)) { done=1; @@ -519,9 +520,9 @@ int eHTTPConnection::processRemoteState() } else { int del=line.find(":"); - eString name=line.left(del), value=line.mid(del+1); + std::string name=line.substr(0, del), value=line.substr(del+1); if (value[0]==' ') - value=value.mid(1); + value=value.substr(1); remote_header[std::string(name)]=std::string(value); } done=1; @@ -583,7 +584,7 @@ void eHTTPConnection::writeString(const char *data) writeBlock(data, strlen(data)); } -int eHTTPConnection::getLine(eString &line) +int eHTTPConnection::getLine(std::string &line) { if (!canReadLine()) return 0; diff --git a/lib/network/httpd.h b/lib/network/httpd.h index 791d49c8..61fe2c75 100644 --- a/lib/network/httpd.h +++ b/lib/network/httpd.h @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include @@ -19,7 +19,7 @@ class eHTTPPathResolver { public: virtual ~eHTTPPathResolver() {}; - virtual eHTTPDataSource *getDataSource(eString request, eString path, eHTTPConnection *conn)=0; + virtual eHTTPDataSource *getDataSource(std::string request, std::string path, eHTTPConnection *conn)=0; }; class eHTTPDataSource @@ -47,7 +47,7 @@ class eHTTPConnection: public eSocket { void doError(int error); - int getLine(eString &line); + int getLine(std::string &line); int processLocalState(); int processRemoteState(); @@ -93,13 +93,13 @@ public: ~eHTTPConnection(); // stateRequest - eString request, requestpath, httpversion; + std::string request, requestpath, httpversion; int is09; // stateResponse int code; - eString code_descr; + std::string code_descr; std::map remote_header, local_header; diff --git a/lib/network/serversocket.lo b/lib/network/serversocket.lo index 8039034b..180ed5dc 100644 Binary files a/lib/network/serversocket.lo and b/lib/network/serversocket.lo differ diff --git a/lib/network/socket.cpp b/lib/network/socket.cpp index 9de0ca0a..628a128b 100644 --- a/lib/network/socket.cpp +++ b/lib/network/socket.cpp @@ -43,16 +43,16 @@ void eSocket::inject(const char *data, int len) readyRead_(); } -eString eSocket::readLine() +std::string eSocket::readLine() { int size=readbuffer.searchchr('\n'); if (size == -1) - return eString(); + return std::string(); size++; // ich will auch das \n char buffer[size+1]; buffer[size]=0; readbuffer.read(buffer, size); - return eString(buffer); + return std::string(buffer); } bool eSocket::canReadLine() @@ -225,7 +225,7 @@ int eSocket::getDescriptor() return socketdesc; } -int eSocket::connectToHost(eString hostname, int port) +int eSocket::connectToHost(std::string hostname, int port) { struct hostent *server; int res; diff --git a/lib/network/socket.h b/lib/network/socket.h index edf9b904..08a191f6 100644 --- a/lib/network/socket.h +++ b/lib/network/socket.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include @@ -32,7 +32,7 @@ public: eSocket(eMainloop *ml); eSocket(int socket, int issocket, eMainloop *ml); ~eSocket(); - int connectToHost(eString hostname, int port); + int connectToHost(std::string hostname, int port); int getDescriptor(); int writeBlock(const char *data, unsigned int len); int setSocket(int socketfd, int issocket, eMainloop *ml); @@ -40,7 +40,7 @@ public: int readBlock(char *data, unsigned int maxlen); int bytesAvailable(); bool canReadLine(); - eString readLine(); + std::string readLine(); void close(); // flow control: start/stop data delivery into read buffer. void enableRead(); diff --git a/lib/network/socket.lo b/lib/network/socket.lo index 1d809469..912fce9e 100644 Binary files a/lib/network/socket.lo and b/lib/network/socket.lo differ diff --git a/lib/network/xmlrpc.cpp b/lib/network/xmlrpc.cpp index 57b09e82..3d981d51 100644 --- a/lib/network/xmlrpc.cpp +++ b/lib/network/xmlrpc.cpp @@ -1,9 +1,10 @@ #ifndef DISABLE_NETWORK #include +#include -static std::map&, ePtrList&)> rpcproc; +static std::map&, ePtrList&)> rpcproc; void eXMLRPCVariant::zero() { @@ -17,7 +18,7 @@ void eXMLRPCVariant::zero() // _base64=0; } -eXMLRPCVariant::eXMLRPCVariant(std::map *__struct) +eXMLRPCVariant::eXMLRPCVariant(std::map *__struct) { zero(); _struct=__struct; @@ -41,7 +42,7 @@ eXMLRPCVariant::eXMLRPCVariant(bool *__boolean) _boolean=__boolean; } -eXMLRPCVariant::eXMLRPCVariant(eString *__string) +eXMLRPCVariant::eXMLRPCVariant(std::string *__string) { zero(); _string=__string; @@ -73,15 +74,15 @@ eXMLRPCVariant::eXMLRPCVariant(const eXMLRPCVariant &c) if (c._boolean) _boolean=new bool(*c._boolean); if (c._string) - _string=new eString(*c._string); + _string=new std::string(*c._string); if (c._double) _double=new double(*c._double); // datetime, base64 if (c._struct) { - _struct=new std::map; - for (std::map::iterator b(c._struct->begin()); b != c._struct->end(); ++b) - _struct->insert(std::pair(b->first, new eXMLRPCVariant(*b->second))); + _struct=new std::map; + for (std::map::iterator b(c._struct->begin()); b != c._struct->end(); ++b) + _struct->insert(std::pair(b->first, new eXMLRPCVariant(*b->second))); } if (c._array) _array = new std::vector(*c._array); @@ -91,7 +92,7 @@ eXMLRPCVariant::~eXMLRPCVariant() { if (_struct) { - for (std::map::iterator i(_struct->begin()); i != _struct->end(); ++i) + for (std::map::iterator i(_struct->begin()); i != _struct->end(); ++i) delete i->second; delete _struct; @@ -112,7 +113,7 @@ eXMLRPCVariant::~eXMLRPCVariant() delete _base64;*/ } -std::map *eXMLRPCVariant::getStruct() +std::map *eXMLRPCVariant::getStruct() { return _struct; } @@ -132,7 +133,7 @@ bool *eXMLRPCVariant::getBoolean() return _boolean; } -eString *eXMLRPCVariant::getString() +std::string *eXMLRPCVariant::getString() { return _string; } @@ -152,61 +153,62 @@ double *eXMLRPCVariant::getDouble() return _base64; } */ -void eXMLRPCVariant::toXML(eString &result) +void eXMLRPCVariant::toXML(std::string &result) { if (getArray()) { - static eString s1(""); + static std::string s1(""); result+=s1; for (unsigned int i=0; isize(); i++) { - static eString s(" "); + static std::string s(" "); result+=s; (*getArray())[i].toXML(result); - static eString s1("\n"); + static std::string s1("\n"); result+=s1; } - static eString s2("\n"); + static std::string s2("\n"); result+=s2; } else if (getStruct()) { - static eString s1(""); + static std::string s1(""); result+=s1; - for (std::map::iterator i(_struct->begin()); i != _struct->end(); ++i) + for (std::map::iterator i(_struct->begin()); i != _struct->end(); ++i) { - static eString s1(" "); + static std::string s1(" "); result+=s1; result+=i->first; - static eString s2(""); + static std::string s2(""); result+=s2; i->second->toXML(result); - static eString s3("\n"); + static std::string s3("\n"); result+=s3; } - static eString s2("\n"); + static std::string s2("\n"); result+=s2; } else if (getI4()) { - static eString s1(""); + static std::string s1(""); result+=s1; - result+=eString().setNum(*getI4()); - static eString s2(""); + result+=getNum(*getI4()); + static std::string s2(""); result+=s2; } else if (getBoolean()) { - static eString s0("0"); - static eString s1("1"); + static std::string s0("0"); + static std::string s1("1"); result+=(*getBoolean())?s1:s0; } else if (getString()) { - static eString s1(""); - static eString s2(""); + static std::string s1(""); + static std::string s2(""); result+=s1; result+=*getString(); result+=s2; } else if (getDouble()) { - result+=eString().sprintf("%lf", *getDouble()); +// result+=std::string().sprintf("%lf", *getDouble()); +#warning double support removed } else eFatal("couldn't append"); } @@ -224,11 +226,11 @@ static eXMLRPCVariant *fromXML(XMLTreeNode *n) else if (!strcmp(n->GetType(), "boolean")) return new eXMLRPCVariant(new bool(atoi(data))); else if (!strcmp(n->GetType(), "string")) - return new eXMLRPCVariant(new eString(data)); + return new eXMLRPCVariant(new std::string(data)); else if (!strcmp(n->GetType(), "double")) return new eXMLRPCVariant(new double(atof(data))); else if (!strcmp(n->GetType(), "struct")) { - std::map *s=new std::map; + std::map *s=new std::map; for (n=n->GetChild(); n; n=n->GetNext()) { if (strcmp(data, "member")) @@ -236,12 +238,12 @@ static eXMLRPCVariant *fromXML(XMLTreeNode *n) delete s; return 0; } - eString name=0; + std::string name=0; eXMLRPCVariant *value; for (XMLTreeNode *v=n->GetChild(); v; v=v->GetNext()) { if (!strcmp(v->GetType(), "name")) - name=eString(v->GetData()); + name=std::string(v->GetData()); else if (!strcmp(v->GetType(), "value")) value=fromXML(v); } @@ -292,7 +294,7 @@ int eXMLRPCResponse::doCall() eDebug("doing call"); result=""; // get method name - eString methodName=0; + std::string methodName=0; if (connection->remote_header["Content-Type"]!="text/xml") { @@ -319,7 +321,7 @@ int eXMLRPCResponse::doCall() for (XMLTreeNode *c=methodCall->GetChild(); c; c=c->GetNext()) { if (!strcmp(c->GetType(), "methodName")) - methodName=eString(c->GetData()); + methodName=std::string(c->GetData()); else if (!strcmp(c->GetType(), "params")) { for (XMLTreeNode *p=c->GetChild(); p; p=p->GetNext()) @@ -441,24 +443,24 @@ void xmlrpc_initialize(eHTTPD *httpd) httpd->addResolver(new eHTTPXMLRPCResolver); } -void xmlrpc_addMethod(eString methodName, int (*proc)(std::vector&, ePtrList&)) +void xmlrpc_addMethod(std::string methodName, int (*proc)(std::vector&, ePtrList&)) { rpcproc[methodName]=proc; } -void xmlrpc_fault(ePtrList &res, int faultCode, eString faultString) +void xmlrpc_fault(ePtrList &res, int faultCode, std::string faultString) { - std::map *s=new std::map; + std::map *s=new std::map; s->INSERT("faultCode", new eXMLRPCVariant(new __s32(faultCode))); - s->INSERT("faultString", new eXMLRPCVariant(new eString(faultString))); + s->INSERT("faultString", new eXMLRPCVariant(new std::string(faultString))); res.push_back(new eXMLRPCVariant(s)); } -int xmlrpc_checkArgs(eString args, std::vector &parm, ePtrList &res) +int xmlrpc_checkArgs(std::string args, std::vector &parm, ePtrList &res) { if (parm.size() != args.length()) { - xmlrpc_fault(res, -500, eString().sprintf("parameter count mismatch (found %d, expected %d)", parm.size(), args.length())); + xmlrpc_fault(res, -500, std::string().sprintf("parameter count mismatch (found %d, expected %d)", parm.size(), args.length())); return 1; } @@ -499,7 +501,7 @@ int xmlrpc_checkArgs(eString args, std::vector &parm, ePtrList #include -#include +#include #include #include -#define INSERT(KEY,VALUE) insert(std::pair(KEY,VALUE)) +#define INSERT(KEY,VALUE) insert(std::pair(KEY,VALUE)) class eXMLRPCVariant { - std::map *_struct; + std::map *_struct; std::vector *_array; __s32 *_i4; bool *_boolean; - eString *_string; + std::string *_string; double *_double; // QDateTime *_datetime; // QByteArray *_base64; void zero(); public: - eXMLRPCVariant(std::map *_struct); + eXMLRPCVariant(std::map *_struct); eXMLRPCVariant(std::vector *_array); eXMLRPCVariant(__s32 *_i4); eXMLRPCVariant(bool *_boolean); - eXMLRPCVariant(eString *_string); + eXMLRPCVariant(std::string *_string); eXMLRPCVariant(double *_double); // eXMLRPCVariant(QDateTime *_datetime); // eXMLRPCVariant(QByteArray *_base64); eXMLRPCVariant(const eXMLRPCVariant &c); ~eXMLRPCVariant(); - std::map *getStruct(); + std::map *getStruct(); std::vector *getArray(); __s32 *getI4(); bool *getBoolean(); - eString *getString(); + std::string *getString(); double *getDouble(); // QDateTime *getDatetime(); // QByteArray *getBase64(); - void toXML(eString &); + void toXML(std::string &); }; class eXMLRPCResponse: public eHTTPDataSource { XMLTreeParser parser; - eString result; + std::string result; int size; int wptr; int doCall(); @@ -65,15 +65,15 @@ public: }; void xmlrpc_initialize(eHTTPD *httpd); -void xmlrpc_addMethod(eString methodName, int (*)(std::vector&, ePtrList&)); -void xmlrpc_fault(ePtrList &res, int faultCode, eString faultString); -int xmlrpc_checkArgs(eString args, std::vector&, ePtrList &res); +void xmlrpc_addMethod(std::string methodName, int (*)(std::vector&, ePtrList&)); +void xmlrpc_fault(ePtrList &res, int faultCode, std::string faultString); +int xmlrpc_checkArgs(std::string args, std::vector&, ePtrList &res); class eHTTPXMLRPCResolver: public eHTTPPathResolver { public: eHTTPXMLRPCResolver(); - eHTTPDataSource *getDataSource(eString request, eString path, eHTTPConnection *conn); + eHTTPDataSource *getDataSource(std::string request, std::string path, eHTTPConnection *conn); }; #endif -- cgit v1.2.3