--- smsdaemon/util.cpp 2008/06/16 06:12:45 84 +++ smsdaemon/util.cpp 2008/07/04 07:58:26 108 @@ -9,6 +9,7 @@ #include #include #include +#include #include "util.h" @@ -104,12 +105,34 @@ return retval; } + char my_toupper(char ch) + { + if (ch == 'æ') + return 'Æ'; + if (ch == 'ø') + return 'Ø'; + if (ch == 'å') + return 'Å'; + + return ::toupper(ch); + } + + char my_tolower(char ch) + { + if (ch == 'Æ') + return 'æ'; + if (ch == 'Ø') + return 'ø'; + if (ch == 'Å') + return 'å'; + return ::tolower(ch); + } string str_toupper(string str) { for (unsigned i=0; i0) { - throw std::runtime_error("Command time out"); + throw std::runtime_error("Command time out or document not found"); } ifstream in( tempfile.c_str() ); @@ -284,6 +312,36 @@ ((now.tv_usec-then.tv_usec)/1000); } + + timeval GetTimeOfDay() + { + timeval now; + gettimeofday(&now,0); + return now; + } + + int my_system(const char* cmd, std::string* response) + { + FILE* p; + 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)); + } + }