From e06ab2dde63cebcf4ffbccee3ee9d13972aeb4dd Mon Sep 17 00:00:00 2001 From: dcp1990 Date: Tue, 28 Jun 2005 02:00:06 +0000 Subject: [PATCH] More bugfixes --- phoned/modem.c | 20 ++++++++++++++++++-- phoned/modems/rockwell.c | 4 +++- phoned/remote.c | 9 ++++++--- phoned/socket.c | 1 + 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/phoned/modem.c b/phoned/modem.c index be8921e..c075ffc 100644 --- a/phoned/modem.c +++ b/phoned/modem.c @@ -123,7 +123,6 @@ char *sendwr(str, bufferback, howmuch) write(modemfd, "\r\n", 3); fds[0].fd = modemfd; fds[0].events = POLLRDNORM; - fcntl(modemfd, F_SETFL, O_NONBLOCK); switch(poll(fds, 1, 3000)) { case 0: pthread_cond_signal(&mpcond); @@ -146,7 +145,24 @@ char *sendwr(str, bufferback, howmuch) pthread_mutex_lock(&modemmx); write(modemfd, str, strlen(str) + 1); write(modemfd, "\r\n", 3); - fgets(bufferback, howmuch, modem); + fds[0].fd = modemfd; + fds[0].events = POLLRDNORM; + switch(poll(fds, 1, 3000)) { + case 0: + pthread_cond_signal(&mpcond); + pthread_mutex_unlock(&modemmx); + snprintf(bufferback, howmuch, "*MODEM TIMEOUT*"); + return bufferback; + case -1: + lprintf(error, "poll in sendwr: %s\n", strerror(errno)); + pthread_cond_signal(&mpcond); + pthread_mutex_unlock(&modemmx); + return bufferback; + default: + /* fgets(bufferback, howmuch, modem); */ + read(modemfd, bufferback, howmuch); + break; + } pthread_mutex_unlock(&modemmx); } return bufferback; diff --git a/phoned/modems/rockwell.c b/phoned/modems/rockwell.c index fe9c570..7f8d14c 100644 --- a/phoned/modems/rockwell.c +++ b/phoned/modems/rockwell.c @@ -27,7 +27,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -/* $Amigan: phoned/phoned/modems/rockwell.c,v 1.8 2005/06/26 21:44:40 dcp1990 Exp $ */ +/* $Amigan: phoned/phoned/modems/rockwell.c,v 1.9 2005/06/28 02:00:08 dcp1990 Exp $ */ #include #include #include @@ -147,6 +147,8 @@ void rw_voice_init(void) rw_sdev(dialup); stmod("AT#CID=2"); stmod("AT#CLS=8"); + stmod("ATE0"); + stmod("ATV0"); } void rw_set_rings(rings) int rings; diff --git a/phoned/remote.c b/phoned/remote.c index 0e6605e..40418ed 100644 --- a/phoned/remote.c +++ b/phoned/remote.c @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -/* $Amigan: phoned/phoned/remote.c,v 1.17 2005/06/28 00:52:17 dcp1990 Exp $ */ +/* $Amigan: phoned/phoned/remote.c,v 1.18 2005/06/28 02:00:06 dcp1990 Exp $ */ /* system includes */ #include #include @@ -42,6 +42,7 @@ #include #include #include +#include #include /* us */ #include @@ -366,6 +367,8 @@ char *parse_command(cmd, cont, s) free(rc); *cont = 0; RNF("500 OK: Parser tested.\n"); + } else if(CHK("bye")) { + return NULL; } else if(CHK("tmop")) { if(argvect[1] != NULL) { cid_t *rc; @@ -418,7 +421,7 @@ void begin_dialogue(fp, fd) } else if(rc == -1) { lprintf(error, "Error with recv: %s\n", strerror(errno)); break; - } + } else if(rc < 3) continue; if((c = strrchr(buffer, '\n')) != NULL) *c = '\0'; rcode = parse_command(buffer, &keep_going, &si); @@ -428,7 +431,7 @@ void begin_dialogue(fp, fd) break; } if(si.freeit) free(rcode); - } + } else break; } if(si.l != NULL) { pthread_mutex_lock(&usermx); diff --git a/phoned/socket.c b/phoned/socket.c index 6fdaf0d..5916543 100644 --- a/phoned/socket.c +++ b/phoned/socket.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include