--- smsdaemon/util.cpp 2008/06/14 08:39:40 78 +++ smsdaemon/util.cpp 2008/06/16 10:09:17 89 @@ -9,6 +9,7 @@ #include #include #include +#include #include "util.h" @@ -189,9 +190,17 @@ ostringstream command; command << "wget -O " << tempfile << " --tries=1 --timeout=15 -o /dev/null \"" << url << "\""; - int res = system( command.str().c_str() ); - if (res) - throw std::runtime_error("Command time out"); + int res = my_system( command.str().c_str() ); + + if (res<0) + { + throw( std::runtime_error("Error retrieving document")); + } + + if (res>0) + { + throw std::runtime_error("Command time out or document not found"); + } ifstream in( tempfile.c_str() ); @@ -277,7 +286,24 @@ int mTimeDiff(const timeval& then, const timeval& now) { - return uTimeDiff(then,now) / 1000; + return ( (now.tv_sec - then.tv_sec)*1000) + + ((now.tv_usec-then.tv_usec)/1000); + } + + + timeval GetTimeOfDay() + { + timeval now; + gettimeofday(&now,0); + return now; + } + + int my_system(const char* cmd) + { + FILE* p; + if ((p = popen(cmd,"w")) == NULL) + return (-1); + return (pclose(p)); } }