--- smsdaemon/util.cpp 2008/06/11 10:21:47 49 +++ smsdaemon/util.cpp 2008/06/15 18:57:00 80 @@ -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; } @@ -121,6 +124,14 @@ } + string str_formatint(int i) + { + std::ostringstream os; + os << i; + return os.str(); + } + + string str_characters(string str) { string rep; @@ -179,8 +190,11 @@ ostringstream command; command << "wget -O " << tempfile << " --tries=1 --timeout=15 -o /dev/null \"" << url << "\""; int res = system( command.str().c_str() ); - if (res) + + if (res>0) + { throw std::runtime_error("Command time out"); + } ifstream in( tempfile.c_str() );