diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/praxisd.cc | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/server/src/praxisd.cc b/server/src/praxisd.cc index 8a5b6d6..d1ac4e5 100644 --- a/server/src/praxisd.cc +++ b/server/src/praxisd.cc @@ -29,6 +29,13 @@ #include "saxparser.h" +static const char* str2err(std::string msg) +{ + static char errbuf[1024]; + sprintf(errbuf, "%s", msg.c_str()); + return errbuf; +} + static std::string strtime(bool with_sec = true) { std::string ret; @@ -65,7 +72,7 @@ Praxisd::Praxisd(std::string h, int port) host = h; curl_easy_setopt(ch, CURLOPT_PORT, port); - curl_easy_setopt(ch, CURLOPT_FAILONERROR, 1L); + curl_easy_setopt(ch, CURLOPT_FAILONERROR, 0L/*1L*/); curl_easy_setopt(ch, CURLOPT_TIMEOUT, 150L); curl_easy_setopt(ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_easy_setopt(ch, CURLOPT_CONNECTTIMEOUT, 15L); @@ -98,6 +105,12 @@ std::string Praxisd::journal_get_by_cpr(std::string cpr) throw curl_easy_strerror(errornum); } + long code = 0; + errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code); + if(code != 200) { + throw str2err(journal); + } + return journal; } @@ -123,6 +136,12 @@ time_t Praxisd::journal_last_changed(std::string cpr) throw curl_easy_strerror(errornum); } + long code = 0; + errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code); + if(code != 200) { + throw str2err(journal); + } + return time; } @@ -156,6 +175,12 @@ void Praxisd::journal_add(std::string cpr, std::string entry) if(errornum != CURLE_OK) { throw curl_easy_strerror(errornum); } + + long code = 0; + errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code); + if(code != 200) { + throw str2err(reply); + } } void Praxisd::add_sogeord(std::string cpr, std::string sogeord, @@ -194,6 +219,12 @@ void Praxisd::add_sogeord(std::string cpr, std::string sogeord, if(errornum != CURLE_OK) { throw curl_easy_strerror(errornum); } + + long code = 0; + errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code); + if(code != 200) { + throw str2err(reply); + } } #define DOTAG(x) if(name == #x) str = &p.x; @@ -281,6 +312,12 @@ Praxisd::patient_t Praxisd::patient_get_by_cpr(std::string cpr) throw curl_easy_strerror(errornum); } + long code = 0; + errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code); + if(code != 200) { + throw str2err(xml); + } + PatientParser parser(p); parser.parse(xml.data(), xml.length()); @@ -304,6 +341,12 @@ std::string Praxisd::get_sogenr(std::string sogenr) throw curl_easy_strerror(errornum); } + long code = 0; + errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code); + if(code != 200) { + throw str2err(xml); + } + return xml; } @@ -814,6 +857,12 @@ Praxisd::aftale_get_all_by_date_and_calendar(int cal, throw curl_easy_strerror(errornum); } + long code = 0; + errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code); + if(code != 200) { + throw str2err(xml); + } + AftaleParser parser(aft); parser.parse(xml.data(), xml.length()); @@ -838,6 +887,12 @@ std::vector<Praxisd::aftale_t> Praxisd::aftale_get_all_by_cpr(std::string cpr) throw curl_easy_strerror(errornum); } + long code = 0; + errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code); + if(code != 200) { + throw str2err(xml); + } + AftaleParser parser(aft); parser.parse(xml.data(), xml.length()); @@ -916,6 +971,12 @@ std::vector<Praxisd::dokmenu_t> Praxisd::dokmenu_get_all_by_cpr(std::string cpr) throw curl_easy_strerror(errornum); } + long code = 0; + errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code); + if(code != 200) { + throw str2err(xml); + } + DokMenuParser parser(dokmenu); parser.parse(xml.data(), xml.length()); @@ -941,6 +1002,12 @@ std::string Praxisd::dokmenu_get_by_cpr_and_name(std::string cpr, throw curl_easy_strerror(errornum); } + long code = 0; + errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code); + if(code != 200) { + throw str2err(data); + } + return data; } |