|
|
1.1 ! root 1: /* add_dial.c: This will function just like add_port.c. It draws a ! 2: * template to be used by a user to add a dial entry and ! 3: * then gets the user's data. ! 4: */ ! 5: ! 6: #include "uuinstall.h" ! 7: ! 8: /* add_port calls the functions to draw a dial entry template, get the ! 9: * data and finally to write the entry to the dial file. ! 10: */ ! 11: ! 12: add_dial() ! 13: { ! 14: char b; ! 15: FILE * dialfd; ! 16: ! 17: dial_template(); ! 18: wrefresh(portwin); ! 19: ! 20: b = get_dial_data(); ! 21: ! 22: /* time to save the data to the dial file */ ! 23: if(b == 'y'){ ! 24: if ( (dialfd = fopen(DIALFILE,"a")) == NULL){ ! 25: mvwaddstr(portwin,12,28,"Error opening dial file!"); ! 26: wrefresh(portwin); ! 27: sleep(1); ! 28: wclear(portwin); ! 29: wrefresh(portwin); ! 30: return; ! 31: } ! 32: ! 33: wclear(portwin); ! 34: mvwaddstr(portwin,12,32,"Adding entry..."); ! 35: wrefresh(portwin); ! 36: sleep(1); ! 37: ! 38: fprintf(dialfd,"\n%s\n",dialname); ! 39: fprintf(dialfd,"%s\n",dialchat); ! 40: fprintf(dialfd,"%s\n",dialtout); ! 41: ! 42: if (strlen(dialfail1) != 0) ! 43: fprintf(dialfd,"%s\n",dialfail1); ! 44: ! 45: if (strlen(dialfail2) != 0) ! 46: fprintf(dialfd,"%s\n",dialfail2); ! 47: ! 48: if (strlen(dialfail3) != 0) ! 49: fprintf(dialfd,"%s\n",dialfail3); ! 50: ! 51: if(strlen(dialplete) > 0) ! 52: fprintf(dialfd,"%s\n",dialplete); ! 53: if(strlen(dialabort) > 0) ! 54: fprintf(dialfd,"%s\n",dialabort); ! 55: ! 56: fclose(dialfd); ! 57: } ! 58: ! 59: wclear(portwin); ! 60: wrefresh(portwin); ! 61: } ! 62: ! 63: ! 64: ! 65: /* dial_template(): draw a template for a dial entry */ ! 66: ! 67: dial_template() ! 68: { ! 69: ! 70: /* label our fields */ ! 71: ! 72: wclear(portwin); ! 73: mvwaddstr(portwin,3,1,"dialer"); ! 74: mvwaddstr(portwin,4,1,"chat"); ! 75: mvwaddstr(portwin,5,1,"chat-timeout"); ! 76: mvwaddstr(portwin,6,1,"chat-fail"); ! 77: mvwaddstr(portwin,7,1,"chat-fail"); ! 78: mvwaddstr(portwin,8,1,"chat-fail"); ! 79: mvwaddstr(portwin,9,1,"complete-chat"); ! 80: mvwaddstr(portwin,10,1,"abort-chat"); ! 81: ! 82: /* highlight our fields */ ! 83: wstandout(portwin); ! 84: mvwaddstr(portwin,0,29,"Dial File Entry Screen"); ! 85: mvwaddstr(portwin,3,16," "); ! 86: mvwaddstr(portwin,4,16," "); ! 87: mvwaddstr(portwin,5,16," "); ! 88: mvwaddstr(portwin,6,16," "); ! 89: mvwaddstr(portwin,7,16," "); ! 90: mvwaddstr(portwin,8,16," "); ! 91: mvwaddstr(portwin,9,16," "); ! 92: mvwaddstr(portwin,10,16," "); ! 93: wstandend(portwin); ! 94: } ! 95: ! 96: ! 97: /* get_dial_data(): this will position our cursor to get data for ! 98: * the fields we will fill. ! 99: */ ! 100: ! 101: get_dial_data() ! 102: { ! 103: char * workstring; ! 104: char b; ! 105: ! 106: /* initialize the fields we will fill */ ! 107: ! 108: strcpy(dialname,"dialer "); ! 109: strcpy(dialchat,"chat "); ! 110: strcpy(dialtout,"chat-timeout "); ! 111: strcpy(dialplete,"complete-chat "); ! 112: strcpy(dialabort,"abort-chat "); ! 113: ! 114: /* get our dialer name */ ! 115: ! 116: mvwaddstr(portwin,20,0,"Enter the name of the dialer that"); ! 117: mvwaddstr(portwin,21,0,"this entry describes."); ! 118: mvwaddstr(portwin,22,0,"Leaving this field blank aborts entry."); ! 119: wrefresh(portwin); ! 120: workstring = get_data(portwin,3,16,14,0,1); ! 121: if (strlen(workstring) == 0) ! 122: return('n'); ! 123: strcat(dialname,workstring); ! 124: ! 125: /* get our chat information */ ! 126: wmove(portwin,20,0); ! 127: wclrtobot(portwin); ! 128: mvwaddstr(portwin,12,1,"Enter the chat script used to talk to the modem to set up its registers"); ! 129: mvwaddstr(portwin,13,1,"and dial out. The format of a chat script is: expect_msg <SPACE> send_msg."); ! 130: mvwaddstr(portwin,14,1,"For example, a chat script of:"); ! 131: wstandout(portwin); ! 132: mvwaddstr(portwin,14,38,"\"\" ATQ0E1V1L2M1DT\\D CONNECT\\s2400"); ! 133: wstandend(portwin); ! 134: mvwaddstr(portwin,15,1,"tells uucico to expect NOTHING (\"\") and then sends the appropriate commands"); ! 135: mvwaddstr(portwin,16,1,"to the modem to turn on ECHO and VERBAL RESULT CODES, sets speaker volume and"); ! 136: mvwaddstr(portwin,17,1,"speaker duration and finally to dial the phone number from a system's"); ! 137: mvwaddstr(portwin,18,1,"entry in the sys file (\\D). The final message to expect is the message the"); ! 138: mvwaddstr(portwin,19,1,"modem will send when it has connected to another modem."); ! 139: wstandout(portwin); ! 140: mvwaddstr(portwin,21,1,"Important:"); ! 141: wstandend(portwin); ! 142: mvwaddstr(portwin,21,11," Expect_msgs and send_msgs are separated by spaces. To represent a"); ! 143: mvwaddstr(portwin,22,1,"space in an expect_msg or send_msg, enter a \\s instead of a space."); ! 144: wrefresh(portwin); ! 145: ! 146: workstring = get_data(portwin,4,16,60,1,0); ! 147: strcat(dialchat, workstring); ! 148: ! 149: wmove(portwin,12,0); ! 150: wclrtobot(portwin); ! 151: ! 152: /* get a chat timeout value */ ! 153: ! 154: do{ ! 155: wmove(portwin,20,0); ! 156: wclrtobot(portwin); ! 157: mvwaddstr(portwin,20,0,"Enter the seconds uucico should wait for"); ! 158: mvwaddstr(portwin,21,0,"when expecting a chat message before giving"); ! 159: mvwaddstr(portwin,22,0,"up attempting to establish a connection."); ! 160: wrefresh(portwin); ! 161: ! 162: workstring = get_data(portwin,5,16,3,1,0); ! 163: } ! 164: while(0 == atoi(workstring) ); ! 165: strcat(dialtout,workstring); ! 166: ! 167: /* now get some dial-fail strings */ ! 168: ! 169: wmove(portwin,20,0); ! 170: wclrtobot(portwin); ! 171: mvwaddstr(portwin,20,0,"Optional: Enter a message that the modem"); ! 172: mvwaddstr(portwin,21,0,"might return if the dial attempt failed."); ! 173: mvwaddstr(portwin,22,0,"Examples:"); ! 174: wstandout(portwin); ! 175: mvwaddstr(portwin,22,11,"NO\\sDIALTONE BUSY NO\\sCARRIER"); ! 176: wstandend(portwin); ! 177: wrefresh(portwin); ! 178: ! 179: strcpy(workstring,""); ! 180: workstring = get_data(portwin,6,16,22,0,2); ! 181: if (strlen(workstring) == 0) ! 182: strcpy(dialfail1,""); ! 183: else{ ! 184: strcpy(dialfail1,"chat-fail "); ! 185: strcat(dialfail1,workstring); ! 186: } ! 187: ! 188: strcpy(workstring,""); ! 189: workstring = get_data(portwin,7,16,22,0,2); ! 190: if (strlen(workstring) == 0) ! 191: strcpy(dialfail2,""); ! 192: else{ ! 193: strcpy(dialfail2,"chat-fail "); ! 194: strcat(dialfail2,workstring); ! 195: } ! 196: ! 197: strcpy(workstring,""); ! 198: workstring = get_data(portwin,8,16,22,0,2); ! 199: if (strlen(workstring) == 0) ! 200: strcpy(dialfail3,""); ! 201: else{ ! 202: strcpy(dialfail3,"chat-fail "); ! 203: strcat(dialfail3,workstring); ! 204: } ! 205: ! 206: ! 207: /* now for abort-chat and complete-chat */ ! 208: ! 209: wmove(portwin,20,0); ! 210: wclrtobot(portwin); ! 211: mvwaddstr(portwin,12,0,"Optional: Enter a chat script to be used to set the modem after a call has"); ! 212: mvwaddstr(portwin,13,0,"successfully completed. The purpose of this might be to ensure that the modem"); ! 213: mvwaddstr(portwin,14,0,"hangs up the line, although this would be done automatically under an ideal"); ! 214: mvwaddstr(portwin,15,0,"modem configuration. Remember, expect_msgs and send_msgs are separated by"); ! 215: mvwaddstr(portwin,16,0,"spaces. To represent a space within an expect_msg or send_msg, use \\s."); ! 216: mvwaddstr(portwin,17,0,"Example:"); ! 217: wstandout(portwin); ! 218: mvwaddstr(portwin,17,12,"\"\" +++ OK AT\\sH0\\sE0"); ! 219: wstandend(portwin); ! 220: mvwaddstr(portwin,18,0,"This tells uucico to expect NOTHING (\"\"), send a command to put the modem "); ! 221: mvwaddstr(portwin,19,0,"into command mode (+++), expect OK from the modem, then send a hangup command."); ! 222: wrefresh(portwin); ! 223: ! 224: workstring = get_data(portwin,9,16,80,0,0); ! 225: if(strlen(workstring) == 0) ! 226: strcpy(dialplete,""); ! 227: else ! 228: strcat(dialplete, workstring); ! 229: ! 230: wmove(portwin,13,0); ! 231: wclrtoeol(portwin); ! 232: mvwaddstr(portwin,13,0,"abnormally completed. The purpose of this might be to ensure that the modem"); ! 233: wrefresh(portwin); ! 234: ! 235: workstring = get_data(portwin,10,16,80,0,0); ! 236: if(strlen(workstring) == 0) ! 237: strcpy(dialabort,""); ! 238: else ! 239: strcat(dialabort,workstring); ! 240: ! 241: wmove(portwin,12,0); ! 242: wclrtobot(portwin); ! 243: mvwaddstr(portwin,17,23,"Do you wish to save this entry? (y/n)"); ! 244: wrefresh(portwin); ! 245: ! 246: do{ ! 247: b = wgetch(portwin); ! 248: } ! 249: while ((b != 'n') && (b != 'y')); ! 250: ! 251: return(b); ! 252: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.