diff options
author | deva <deva> | 2007-09-03 14:51:37 +0000 |
---|---|---|
committer | deva <deva> | 2007-09-03 14:51:37 +0000 |
commit | 20c7a5d63dc1f68fcf0e1aa053a4b725235e6f78 (patch) | |
tree | 43fb3b46f1e7bfbf2e3a098535365fbcd4154d23 /server/src | |
parent | 41e5a068b0b595be86797fd12035dabb87c21f36 (diff) |
Added some XML parsing => DOM (pracro, requests and commits).
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/server.cc | 15 | ||||
-rw-r--r-- | server/src/transaction.h | 12 | ||||
-rw-r--r-- | server/src/xmlparser.cc | 21 |
3 files changed, 44 insertions, 4 deletions
diff --git a/server/src/server.cc b/server/src/server.cc index 288dbe1..58b54b9 100644 --- a/server/src/server.cc +++ b/server/src/server.cc @@ -97,7 +97,9 @@ static void connection(TCPSocket &socket) int fd = open(macro.c_str(), O_RDONLY); if(fd == -1) { - fprintf(stderr, "Aaargh... cannot open file...[%s]\n", macro.c_str()); + printf("Cannot open file \"%s\"...", macro.c_str()); + printf("failed!\n"); + i++; continue; } @@ -114,7 +116,16 @@ static void connection(TCPSocket &socket) // Handle commits Commits::iterator j = transaction.commits.begin(); while(j != transaction.commits.end()) { - printf("Commit...\n"); + Commit commit = *j; + printf("Commit %s\n", commit.macro.c_str()); + + CommitValues::iterator k = commit.values.begin(); + while(k != commit.values.end()) { + CommitValue val = *k; + printf("\t%s=%s\n", val.name.c_str(), val.value.c_str()); + k++; + } + j++; } diff --git a/server/src/transaction.h b/server/src/transaction.h index 41559e0..d898ef7 100644 --- a/server/src/transaction.h +++ b/server/src/transaction.h @@ -30,30 +30,40 @@ #include <string> #include <vector> + class Request { public: std::string macro; }; typedef std::vector< Request > Requests; + class CommitValue { public: std::string name; std::string value; }; +typedef std::vector< CommitValue > CommitValues; + class Commit { public: - std::vector< CommitValue > values; + std::string user; + std::string macro; + std::string version; + CommitValues values; }; typedef std::vector< Commit > Commits; + class Transaction { public: std::string cpr; + std::string version; Requests requests; Commits commits; }; + #endif/*__PRACRO_TRANSACTION_H__*/ diff --git a/server/src/xmlparser.cc b/server/src/xmlparser.cc index 7e5fb14..7efdc83 100644 --- a/server/src/xmlparser.cc +++ b/server/src/xmlparser.cc @@ -62,13 +62,32 @@ void start_hndl(void *p, const char *el, const char **attr) */ // Do something reasonable with them... + if(name == "pracro") { + transaction->cpr = attributes["cpr"]; + transaction->version = attributes["version"]; + } + if(name == "request") { Request r; r.macro = attributes["macro"]; - // printf("%s\n", r.macro.c_str()); transaction->requests.push_back(r); } + if(name == "commit") { + Commit c; + c.user = attributes["user"]; + c.macro = attributes["macro"]; + c.version = attributes["version"]; + transaction->commits.push_back(c); + } + + if(name == "field") { + CommitValue v; + v.name = attributes["name"]; + v.value = attributes["value"]; + transaction->commits.back().values.push_back(v); + } + } void end_hndl(void *p, const char *el) |