// Copyright (c) 2004 David Muse // See the COPYING file for more information. #include #include #include #include #include #include #include #define DEBUG_CHAT 1 #ifdef RUDIMENTS_NAMESPACE namespace rudiments { #endif class chatprivate { friend class chat; private: const filedescriptor *_readfd; const filedescriptor *_writefd; long _timeout; stringlist _aborts; }; chat::chat(const filedescriptor *fd) { pvt=new chatprivate; pvt->_readfd=fd; pvt->_writefd=fd; pvt->_timeout=45; } chat::chat(const filedescriptor *rfd, const filedescriptor *wfd) { pvt=new chatprivate; pvt->_readfd=rfd; pvt->_writefd=wfd; pvt->_timeout=45; } chat::~chat() { delete pvt; } int chat::runScript(const char *script, char **abort) { return runScript(script,abort,NULL); } int chat::runScript(const char *script, char **abort, constnamevaluepairs *variables) { #ifdef DEBUG_CHAT printf("runScript(\"%s\")\n",script); #endif // if there was no script, just return success if (!script || !script[0]) { return RESULT_SUCCESS; } // parse the script xmldom xmld; if (!xmld.parseString(script)) { return RESULT_ERROR; } // get the