diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2001-08-16 20:42:09 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2001-08-16 20:42:09 +0000 |
commit | 2f1b9304ac4ba89a2dcb6047cb584a5603a33987 (patch) | |
tree | f2339e3f2230b73ee4818d55d4154795e712d803 /c/src/libnetworking/pppd/chat.c | |
parent | 2001-08-16 Mike Siers <mikes@poliac.com> (diff) | |
download | rtems-2f1b9304ac4ba89a2dcb6047cb584a5603a33987.tar.bz2 |
2001-08-16 Mike Siers <mikes@poliac.com>
* Update of PPPD to 2.3.11 from 2.3.5 and addition of an example
application. Mike's notes on the modifications:
- renamed error() function because of namespace problems
- removed calls to the exit() funciton
- removed extra files from the pppd source directory
- defined pppd task constant values in rtemspppd.h
- modifyied example code to get actual tick per second value
- placed the pppd 2.3.11 man page file (pppd.8) into the pppd
directory
* pppd/cbcp.c, pppd/cbcp.h, pppd/main.c, pppd/ppp_tty.c,
pppd/pppmain.c, pppd/rtems-ppp.c, pppd/rtems-ppp.c: Deleted.
* pppd/pppd.8, pppd/rtemsmain.c, pppd/rtemspppd.c, pppd/rtemspppd.h,
pppd/sys-rtems.c, pppd/utils.c, pppd/example/Makefile,
pppd/example/README, pppd/example/init.c, pppd/example/netconfig.h,
pppd/example/ppp.conf, pppd/example/pppdapp.c, pppd/example/system.h:
New files.
* modem/ppp_tty.c, net/if_ppp.h, pppd/Makefile.am, pppd/README,
pppd/STATUS, pppd/auth.c, pppd/ccp.c, pppd/ccp.h, pppd/chap.c,
pppd/chap.h, pppd/chap_ms.c, pppd/chap_ms.h, pppd/chat.c,
pppd/demand.c, pppd/fsm.c, pppd/fsm.h, pppd/ipcp.c, pppd/ipcp.h,
pppd/ipxcp.c, pppd/ipxcp.h, pppd/lcp.c, pppd/lcp.h, pppd/magic.c,
pppd/magic.h, pppd/options.c, pppd/patchlevel.h,
pppd/pathnames.h, pppd/pppd.h, pppd/upap.c, pppd/upap.h: Modified.
Diffstat (limited to 'c/src/libnetworking/pppd/chat.c')
-rw-r--r-- | c/src/libnetworking/pppd/chat.c | 146 |
1 files changed, 34 insertions, 112 deletions
diff --git a/c/src/libnetworking/pppd/chat.c b/c/src/libnetworking/pppd/chat.c index eca2066e93..31273714b4 100644 --- a/c/src/libnetworking/pppd/chat.c +++ b/c/src/libnetworking/pppd/chat.c @@ -156,7 +156,6 @@ int Verbose = 0; int quiet = 0; int report = 0; int exit_code = 0; -static int speed=0; char *report_file = (char *) 0; char *chat_file = (char *) 0; char *phone_num = (char *) 0; @@ -167,8 +166,8 @@ int have_tty_parameters = 0; #ifdef TERMIOS #define term_parms struct termios -#define get_term_param(param) tcgetattr(modem_fd, param) -#define set_term_param(param) tcsetattr(modem_fd, TCSANOW, param) +#define get_term_param(param) tcgetattr(ttyfd, param) +#define set_term_param(param) tcsetattr(ttyfd, TCSANOW, param) struct termios saved_tty_parameters; #endif @@ -260,52 +259,35 @@ char *getnextcommand(char **string) } -extern int modem_fd; -int - chatmain(argv) - char *argv; +extern int ttyfd; +int chatmain(argv) +char *argv; { - char *arg; - int i; - char *t; - exit_code=0; - speed=0; -/* - * Default the report file to the stderr location - */ -/* if (report_fp == NULL) - report_fp = stderr; -*/ - init(); - while ( (arg = getnextcommand(&argv)) != NULL) { - chat_expect(arg); - if (exit_code>0) break; - t=temp2; - - while(*t) - { - if (strncmp("CARRIER",t,7)==0) - {/* parse speed information */ - i=0; - while(!isdigit(t[i])) - i++; - t=&t[i]; - i=0; - while(isdigit(t[i])) - i++; - t[i]=0; - sscanf(t,"%d",&speed); - break; - } - t++; - } - if ((arg = getnextcommand(&argv)) != NULL) - chat_send(arg); - if (exit_code>0) break; - } + char *arg; + + /* initialize exit code */ + exit_code = 0; + +printf("chat_main: %s\n", argv); + + /* get first expect string */ + arg = getnextcommand(&argv); + while ( arg != NULL ) { + /* process the expect string */ + chat_expect(arg); + + /* get the next send string */ + arg = getnextcommand(&argv); + if ( arg != NULL ) { + /* process the send string */ + chat_send(arg); + + /* get the next expect string */ + arg = getnextcommand(&argv); + } + } - if (exit_code) return exit_code; - return -speed; + return 0; } @@ -317,7 +299,6 @@ int void init() { set_tty_parameters(); - speed=0; } void set_tty_parameters() @@ -657,7 +638,7 @@ register char *s; if (say_next) { say_next = 0; s = clean(s,0); - write(modem_fd, s, strlen(s)); + write(ttyfd, s, strlen(s)); free(s); return; } @@ -682,63 +663,6 @@ register char *s; return; } - -/* if (report_next) { - char *s1; - - report_next = 0; - if (n_reports >= MAX_REPORTS) - { - exit_code=2; - return; - } - - s1 = clean(s, 0); - - if (strlen(s1) > strlen(s) || strlen(s1) > sizeof fail_buffer - 1) - { - exit_code=1; - return; - } - - report_string[n_reports++] = s1; - - return; - } -*/ -/* if (clear_report_next) { - char *s1; - int i; - int old_max; - int pack = 0; - - clear_report_next = 0; - - s1 = clean(s, 0); - - if (strlen(s1) > strlen(s) || strlen(s1) > sizeof fail_buffer - 1) - { - exit_code=1; - return; - } - - old_max = n_reports; - for (i=0; i < n_reports; i++) { - if ( strcmp(s1,report_string[i]) == 0 ) { - free(report_string[i]); - report_string[i] = NULL; - pack++; - n_reports--; - } - } - free(s1); - if (pack) - pack_array(report_string,old_max); - - return; - } -*/ - if (timeout_next) { timeout=atoi(s); timeout_next = 0; @@ -770,7 +694,7 @@ int get_char() while(tries) { - status = read(modem_fd, &c, 1); + status = read(ttyfd, &c, 1); switch (status) { case 1: return ((int)c & 0x7F); @@ -789,7 +713,7 @@ int c; /* inter-character typing delay (?) */ - status = write(modem_fd, &ch, 1); + status = write(ttyfd, &ch, 1); switch (status) { case 1: @@ -814,8 +738,6 @@ int c; int put_string (s) register char *s; { - - quiet = 0; s = clean(s, 1); while (*s) { @@ -898,10 +820,10 @@ register char *string; char *logged = temp2; struct termios tios; - tcgetattr(modem_fd, &tios); + tcgetattr(ttyfd, &tios); tios.c_cc[VMIN] = 0; tios.c_cc[VTIME] = timeout*10/MAX_TIMEOUTS; - tcsetattr(modem_fd, TCSANOW, &tios); + tcsetattr(ttyfd, TCSANOW, &tios); string = clean(string, 0); len = strlen(string); |