--- smsdaemon/util.cpp 2008/06/10 22:22:19 42 +++ smsdaemon/util.cpp 2008/06/16 06:12:45 84 @@ -7,7 +7,7 @@ #include #include #include - +#include #include #include "util.h" @@ -53,13 +53,16 @@ return str; } - + bool my_isspace(char ch) + { + return (isspace(ch) || ch == 0); + } string str_trim(string str) { - while (str.length() > 0 && isspace(str.at(0))) + while (str.length() > 0 && my_isspace(str.at(0))) str.erase(0,1); - while (str.length() > 0 && isspace(str.at(str.length()-1))) + while (str.length() > 0 && my_isspace(str.at(str.length()-1))) str.erase(str.length()-1,1); return str; } @@ -101,6 +104,34 @@ return retval; } + + string str_toupper(string str) + { + for (unsigned i=0; i0) + { + throw std::runtime_error("Command time out"); + } ifstream in( tempfile.c_str() ); @@ -232,7 +280,8 @@ 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); } }