#include "defs.h" #include "state.h" //---------------------------------------------------------------------------------------- ---------- //! Constructor // State::State(const char* file) : _doc(file), _file(file) { if (xmlStrcmp(_doc.root()->name, (const xmlChar *) "statDump")) { die("Unknown root element \"%s\" (file=%s)!\n", _doc.root()->name, file); } for (xmlNodePtr node = _doc.root()->xmlChildrenNode; node != NULL; node = node->next) { if (!xmlStrcmp(node->name, (const xmlChar *) "startDate")) { time_t t = _doc.getNodeChildInt64(node); tm* tm = localtime(&t); _startDate = *tm; } if (!xmlStrcmp(node->name, (const xmlChar *) "dumpDate")) { time_t t = _doc.getNodeChildInt64(node); tm* tm = localtime(&t); _dumpDate = *tm; } if (!xmlStrcmp(node->name, (const xmlChar *) "user")) { _user = _doc.getNodeChildString(node); } if (!xmlStrcmp(node->name, (const xmlChar *) "cwd")) { _cwd = _doc.getNodeChildString(node); } if (!xmlStrcmp(node->name, (const xmlChar *) "executable")) { _exe = _doc.getNodeChildString(node); } } for (xmlNodePtr node = _doc.root()->xmlChildrenNode; node != NULL; node = node->next) { if (!xmlStrcmp(node->name, (const xmlChar *) "board")) { _boardList.push_back(Board(_doc, node)); } } } //-------------------------------------------------------------------------------------------------- //! Return true if an exception has been found on any board // bool State::haveExc(void) const { for (BoardListConstIterator b = _boardList.begin(); b != _boardList.end(); b++) if (b->haveExc()) return true; return false; } ... //-------------------------------------------------------------------------------------------------- //! Generate string representation of information // std::string State::printMsg(unsigned prCtrl) const { char buf[10240]; std::string pre = ""; std::string msg = ""; if (!(prCtrl & (prShort|prLogFile))) pre += "> File = " + _file + "\n"; if (prCtrl & prLogFile) { sprintf(buf, "%02d%02d%02d", (_dumpDate.tm_year%100), (_dumpDate.tm_mon+1), _dumpDate.tm_mday); pre += buf; pre += "\tuser=" + _user + ", " + "executable=" + _exe + "\n"; } if (prCtrl & prVerbose) { pre += " Start date = " + std::string(asctime(&_startDate)); pre += " Dump date = " + std::string(asctime(&_dumpDate)); pre += " User = " + _user + "\n"; pre += " Directory = " + _cwd + "\n"; pre += " Executable = " + _exe + "\n"; } for (BoardListConstIterator b = _boardList.begin(); b != _boardList.end(); b++) { if ((prCtrl & prExc) && b->haveExc()) msg += b->printMsg(prCtrl); if ((prCtrl & prMemSer) && b->haveMemSer()) msg += b->printMsg(prCtrl); if ((prCtrl & prNetErr) && b->haveNetErr()) msg += b->printMsg(prCtrl); } if (msg.length() == 0) return std::string(""); return (pre + msg); }