From ccc6a3c84995e357a13de5a44c3316d9edb5baba Mon Sep 17 00:00:00 2001 From: dcp1990 Date: Wed, 1 Jun 2005 20:53:09 +0000 Subject: [PATCH] Extra error checking, and other stuff --- phoned/config.y | 2 ++ phoned/init.c | 3 +++ phoned/modem.c | 2 +- phoned/socket.c | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) 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;