5 |
#include "common.h" |
#include "common.h" |
6 |
|
|
7 |
#include "GsmModem.h" |
#include "GsmModem.h" |
8 |
#include "SerialPort.h" |
#include "serialport/SerialPort.h" |
9 |
#include "SmsDaemon.h" |
#include "SmsDaemon.h" |
10 |
|
#include "ConfigFile.h" |
11 |
|
|
12 |
using namespace std; |
using namespace std; |
13 |
|
|
20 |
exit(exitcode); |
exit(exitcode); |
21 |
} |
} |
22 |
|
|
23 |
|
|
24 |
int main(int argc, char* argv[]) |
int main(int argc, char* argv[]) |
25 |
{ |
{ |
26 |
Common* cmn = Common::instance(); |
Common* cmn = Common::instance(); |
31 |
cmn->pidfile = "/var/run/smsdaemon.pid"; |
cmn->pidfile = "/var/run/smsdaemon.pid"; |
32 |
cmn->spooldir = "/var/spool/smsdaemon"; |
cmn->spooldir = "/var/spool/smsdaemon"; |
33 |
|
|
|
cmn->uid = 1000; |
|
|
cmn->gid = 1000; |
|
34 |
|
|
35 |
cmn->loadConfig(argc,argv); |
cmn->loadConfig(argc,argv); |
36 |
cmn->daemonStart = time(0); |
cmn->daemonStart = time(0); |
37 |
|
|
38 |
|
ConfigFile* config = cmn->GetConfigfile(); |
39 |
|
|
40 |
|
bool res = config->Open( cmn->configFilePath ) ; |
41 |
|
if (!res) { |
42 |
|
cmn->logMessage(string("Could not open config file:") + cmn->configFilePath); |
43 |
|
return 1; |
44 |
|
} |
45 |
|
|
46 |
|
|
47 |
///////////////////// |
///////////////////// |
48 |
|
|
49 |
//Write a delimiter line in the logfile to seperate sessions |
//Write a delimiter line in the logfile to seperate sessions |
50 |
|
|
51 |
if (Common::instance()->isDaemon) |
if (Common::instance()->isDaemon) |
52 |
|
{ |
53 |
|
lookup_uid_values(); |
54 |
daemonize(); |
daemonize(); |
55 |
|
} |
56 |
|
|
57 |
|
|
58 |
SerialPort port("/dev/ttyUSB0" ); |
SerialPort port( config->GetValue("smsdaemon","serialport") ); |
59 |
try |
try |
60 |
{ |
{ |
61 |
port.Open( SerialPort::BAUD_9600, |
port.Open( SerialPort::BAUD_9600, |