diff --git a/phoned/config.y b/phoned/config.y index a58eb8d..25517ae 100644 --- a/phoned/config.y +++ b/phoned/config.y @@ -13,6 +13,7 @@ int chrcnt = 0; int lincnt = 1; int yylex(void); extern char* yytext; +extern struct conf cf; void yyerror(str) char* str; { @@ -82,6 +83,7 @@ devpath: QUOTE PATH QUOTE { lprintf(debug, "Modem dev == %s\n", $2); + cf.modemdev = $2; } ; %% diff --git a/phoned/init.c b/phoned/init.c index 0a13d74..227db86 100644 --- a/phoned/init.c +++ b/phoned/init.c @@ -39,5 +39,8 @@ void initialize(void) open_logs(); install_handlers(); read_config(); + if(init_modem(cf.modemdev) != 1) { + lprintf(warn, "warning: modem didn't initialise properly; see previous messages\n"); + } } diff --git a/phoned/modem.c b/phoned/modem.c index 83421b9..43a230c 100644 --- a/phoned/modem.c +++ b/phoned/modem.c @@ -57,7 +57,7 @@ int init_modem(char* dev) { int lres = 0; modemfd = open(dev, O_RDWR); - if(!modemfd) { + if(modemfd == -1) { lprintf(error, "Error opening modem %s: %s\n", dev, strerror(errno)); return -2; } diff --git a/phoned/socket.c b/phoned/socket.c index e6beb07..d53f9f1 100644 --- a/phoned/socket.c +++ b/phoned/socket.c @@ -57,7 +57,7 @@ void handclient(sk) lprintf(debug, "Client said %s.", buffer); } -void network(void) +void network(void) /* name is misleading because we also do modem IO here */ { int s, us, sn; fd_set fds;