Skip to content
Snippets Groups Projects
Commit cb1ec01b authored by rswindell's avatar rswindell
Browse files

Abort modem init/dial correctly.

parent 1df142e3
No related branches found
No related tags found
No related merge requests found
...@@ -84,6 +84,12 @@ int modem_response(char *str, size_t maxlen, int timeout) ...@@ -84,6 +84,12 @@ int modem_response(char *str, size_t maxlen, int timeout)
start=time(NULL); start=time(NULL);
while(1){ while(1){
/* Abort with keystroke */
if(kbhit()) {
getch();
return(1);
}
if(time(NULL)-start >= timeout) if(time(NULL)-start >= timeout)
return(-1); return(-1);
if(len >= maxlen) if(len >= maxlen)
...@@ -108,6 +114,7 @@ int modem_response(char *str, size_t maxlen, int timeout) ...@@ -108,6 +114,7 @@ int modem_response(char *str, size_t maxlen, int timeout)
int modem_connect(struct bbslist *bbs) int modem_connect(struct bbslist *bbs)
{ {
int ret;
char respbuf[1024]; char respbuf[1024];
init_uifc(TRUE, TRUE); init_uifc(TRUE, TRUE);
...@@ -140,9 +147,10 @@ int modem_connect(struct bbslist *bbs) ...@@ -140,9 +147,10 @@ int modem_connect(struct bbslist *bbs)
/* Wait for "OK" */ /* Wait for "OK" */
while(1) { while(1) {
if(modem_response(respbuf, sizeof(respbuf), 5)) { if((ret=modem_response(respbuf, sizeof(respbuf), 5))!=0) {
modem_close(); modem_close();
uifc.pop(NULL); uifc.pop(NULL);
if(ret<0)
uifcmsg("Modem Not Responding", "`Modem Not Responding`\n\n" uifcmsg("Modem Not Responding", "`Modem Not Responding`\n\n"
"The modem did not respond to the initializtion string\n" "The modem did not respond to the initializtion string\n"
"Check your init string and phone number.\n"); "Check your init string and phone number.\n");
...@@ -162,6 +170,9 @@ int modem_connect(struct bbslist *bbs) ...@@ -162,6 +170,9 @@ int modem_connect(struct bbslist *bbs)
conn_api.terminate=-1; conn_api.terminate=-1;
return(-1); return(-1);
} }
/* drain keyboard input to avoid accidental cancel */
while(kbhit())
getch();
uifc.pop(NULL); uifc.pop(NULL);
uifc.pop("Dialing..."); uifc.pop("Dialing...");
...@@ -171,9 +182,10 @@ int modem_connect(struct bbslist *bbs) ...@@ -171,9 +182,10 @@ int modem_connect(struct bbslist *bbs)
/* Wait for "CONNECT" */ /* Wait for "CONNECT" */
while(1) { while(1) {
if(modem_response(respbuf, sizeof(respbuf), 30)) { if((ret=modem_response(respbuf, sizeof(respbuf), 30))!=0) {
modem_close(); modem_close();
uifc.pop(NULL); uifc.pop(NULL);
if(ret<0)
uifcmsg("No Answer", "`No Answer`\n\n" uifcmsg("No Answer", "`No Answer`\n\n"
"The modem did not connect within 30 seconds.\n"); "The modem did not connect within 30 seconds.\n");
conn_api.terminate=-1; conn_api.terminate=-1;
...@@ -181,14 +193,6 @@ int modem_connect(struct bbslist *bbs) ...@@ -181,14 +193,6 @@ int modem_connect(struct bbslist *bbs)
} }
if(strstr(respbuf, bbs->addr)) /* Dial command echoed */ if(strstr(respbuf, bbs->addr)) /* Dial command echoed */
continue; continue;
/* Abort with keystroke */
if(kbhit()) {
modem_close();
uifc.pop(NULL);
uifcmsg("Aborted", "Dialing aborted");
conn_api.terminate=-1;
return(-1);
}
break; break;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment