--- smsdaemon/main.cpp 2008/06/10 12:58:30 33 +++ smsdaemon/main.cpp 2008/06/11 16:08:37 57 @@ -62,6 +62,7 @@ } modem.DeleteSms(sms[i].sms_index); + cmn->smsCounter.incomming++; } if (sms.size() == 0) @@ -73,6 +74,13 @@ } } +bool sms_exit(int exitcode) +{ + if (Common::instance()->isDaemon) + daemonCleanup(); + + exit(exitcode); +} int main(int argc, char* argv[]) { @@ -88,6 +96,7 @@ cmn->gid = 1000; cmn->loadConfig(argc,argv); + cmn->daemonStart = time(0); ///////////////////// @@ -113,11 +122,21 @@ catch(std::exception &e) { cmn->logMessage( string("PortOpen Exception: ") + e.what() ); - exit(1); + sms_exit(1); } GsmModem modem(port); + try + { + modem.Init(); + } + catch (std::exception& e) + { + cmn->logMessage( string("GsmModem Exception: ") + e.what() ); + sms_exit(2); + } + ////////////////////////////////// @@ -127,6 +146,8 @@ main_loop(modem); + cmn->logMessage( cmn->getStatusMessage() ); + if (cmn->isDaemon) daemonCleanup();