--- smsdaemon/util.cpp 2008/06/16 07:39:56 86 +++ smsdaemon/util.cpp 2008/06/19 14:47:52 107 @@ -9,6 +9,7 @@ #include #include #include +#include #include "util.h" @@ -289,11 +290,33 @@ ((now.tv_usec-then.tv_usec)/1000); } - int my_system(const char* cmd) + + timeval GetTimeOfDay() + { + timeval now; + gettimeofday(&now,0); + return now; + } + + int my_system(const char* cmd, std::string* response) { FILE* p; - if ((p = popen(cmd,"w")) == NULL) + if ((p = popen(cmd,"r")) == NULL) return (-1); + + if (response) + { + std::string output; + char buf[256]; + while(!feof(p)) + { + int len = fread(buf,1,255, p); + buf[len] = 0; + output += buf; + } + *response = output; + } + return (pclose(p)); }