Index: c/src/ChangeLog
===================================================================
--- c/src/ChangeLog	(revision 982c61cc6777d1010717779ed642c98624e863f3)
+++ c/src/ChangeLog	(revision 4ca43d72e1e6af22688f868463e4ccf429e3f5c9)
@@ -1,2 +1,10 @@
+2005-01-20	Joel Sherrill <joel@OARcorp.com>
+
+	PR 736/pppd
+	* libnetworking/pppd/chat.c, libnetworking/pppd/demand.c,
+	libnetworking/pppd/pppd.h, libnetworking/pppd/rtemsmain.c,
+	libnetworking/pppd/sys-rtems.c, libnetworking/pppd/utils.c: ttyfd
+	should not be static and should have a name more specific to pppd.
+
 2005-01-07	Ralf Corsepius <ralf.corsepius@rtems.org>
 
Index: c/src/libnetworking/pppd/chat.c
===================================================================
--- c/src/libnetworking/pppd/chat.c	(revision 982c61cc6777d1010717779ed642c98624e863f3)
+++ c/src/libnetworking/pppd/chat.c	(revision 4ca43d72e1e6af22688f868463e4ccf429e3f5c9)
@@ -164,5 +164,5 @@
 static char *phone_num      = (char *) 0;
 static char *phone_num2     = (char *) 0;
-static int ttyfd;
+/* static */ int pppd_ttyfd;
 static int timeout   = DEFAULT_CHAT_TIMEOUT;
 
@@ -247,5 +247,5 @@
   /* initialize exit code */
   exit_code = 0;
-  ttyfd     = fd;
+  pppd_ttyfd     = fd;
 
   script=pScript;
@@ -272,5 +272,5 @@
     }
   }
-  ttyfd = (int)-1;
+  pppd_ttyfd = (int)-1;
 
   return ( exit_code );
@@ -279,5 +279,5 @@
 void break_sequence()
 {
-  tcsendbreak(ttyfd, 0);
+  tcsendbreak(pppd_ttyfd, 0);
 }
 
@@ -700,5 +700,5 @@
 	while(tries)
 	{
-	    status = read(ttyfd, &c, 1);
+	    status = read(pppd_ttyfd, &c, 1);
 	    switch (status) {
 		   case 1:
@@ -716,5 +716,5 @@
   char ch = c;
 
-  return(write(ttyfd, &ch, 1));
+  return(write(pppd_ttyfd, &ch, 1));
 }
 
@@ -792,8 +792,8 @@
     memset(temp2, 0, sizeof(temp2));
 
-    tcgetattr(ttyfd, &tios);
+    tcgetattr(pppd_ttyfd, &tios);
     tios.c_cc[VMIN] = 0;
     tios.c_cc[VTIME] = timeout*10/MAX_TIMEOUTS;
-    tcsetattr(ttyfd, TCSANOW, &tios);
+    tcsetattr(pppd_ttyfd, TCSANOW, &tios);
 		
     string = clean(in_string, 0);
Index: c/src/libnetworking/pppd/demand.c
===================================================================
--- c/src/libnetworking/pppd/demand.c	(revision 982c61cc6777d1010717779ed642c98624e863f3)
+++ c/src/libnetworking/pppd/demand.c	(revision 4ca43d72e1e6af22688f868463e4ccf429e3f5c9)
@@ -46,5 +46,5 @@
 static const char rcsid[] = RCSID;
 
-static char *frame;
+static unsigned char *frame;
 static int framelen;
 static int framemax;
Index: c/src/libnetworking/pppd/pppd.h
===================================================================
--- c/src/libnetworking/pppd/pppd.h	(revision 982c61cc6777d1010717779ed642c98624e863f3)
+++ c/src/libnetworking/pppd/pppd.h	(revision 4ca43d72e1e6af22688f868463e4ccf429e3f5c9)
@@ -142,5 +142,5 @@
 extern int	pppifunit;	/* Interface unit number */
 extern char	ifname[];	/* Interface name */
-extern int	ttyfd;		/* Serial device file descriptor */
+extern int	pppd_ttyfd;	/* Serial device file descriptor */
 extern char	hostname[];	/* Our hostname */
 extern u_char	outpacket_buf[]; /* Buffer for outgoing packets */
@@ -302,5 +302,5 @@
 void log_packet __P((u_char *, int, char *, int));
 				/* Format a packet and log it with syslog */
-void print_string __P((char *, int,  void (*) (void *, char *, ...),
+void print_string __P((void *, int,  void (*) (void *, char *, ...),
 		void *));	/* Format a string for output */
 int slprintf __P((char *, int, char *, ...));		/* sprintf++ */
Index: c/src/libnetworking/pppd/rtemsmain.c
===================================================================
--- c/src/libnetworking/pppd/rtemsmain.c	(revision 982c61cc6777d1010717779ed642c98624e863f3)
+++ c/src/libnetworking/pppd/rtemsmain.c	(revision 4ca43d72e1e6af22688f868463e4ccf429e3f5c9)
@@ -78,5 +78,5 @@
 static char ppp_devnam[MAXPATHLEN]; /* name of PPP tty (maybe ttypx) */
 
-int ttyfd;			/* Serial port file descriptor */
+/* int pppd_ttyfd;			* Serial port file descriptor */
 int baud_rate;			/* Actual bits/second for serial device */
 int hungup;			/* terminal has been hung up */
@@ -233,5 +233,5 @@
 
 	need_holdoff = 1;
-	ttyfd = -1;
+	pppd_ttyfd = -1;
 	real_ttyfd = -1;
 	pppd_status = EXIT_OK;
@@ -265,7 +265,7 @@
 		   user before opening it. */
 		int err;
-		ttyfd = open(devnam, O_NONBLOCK | O_RDWR, 0);
+		pppd_ttyfd = open(devnam, O_NONBLOCK | O_RDWR, 0);
 		err = errno;
-		if (ttyfd >= 0) {
+		if (pppd_ttyfd >= 0) {
 		    break;
 		}
@@ -278,6 +278,6 @@
 		    goto fail;
 	    }
-	    if ((fdflags = fcntl(ttyfd, F_GETFL)) == -1
-		|| fcntl(ttyfd, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
+	    if ((fdflags = fcntl(pppd_ttyfd, F_GETFL)) == -1
+		|| fcntl(pppd_ttyfd, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
 		warn("Couldn't reset non-blocking mode on device: %m");
 
@@ -292,7 +292,7 @@
 	     * we could clear CLOCAL at this point.
 	     */
-	    set_up_tty(ttyfd, ((connector != NULL && connector[0] != 0)
+	    set_up_tty(pppd_ttyfd, ((connector != NULL && connector[0] != 0)
 			       || initializer != NULL));
-	    real_ttyfd = ttyfd;
+	    real_ttyfd = pppd_ttyfd;
 	}
 
@@ -309,5 +309,5 @@
 
 	    if (initializer && initializer[0]) {
-		if (device_script(ttyfd, DIALER_INIT, initializer) < 0) {
+		if (device_script(pppd_ttyfd, DIALER_INIT, initializer) < 0) {
 		    error("Initializer script failed");
 		    pppd_status = EXIT_INIT_FAILED;
@@ -321,5 +321,5 @@
 
 	    if (connector && connector[0]) {
-		if (device_script(ttyfd, DIALER_CONNECT, connector) < 0) {
+		if (device_script(pppd_ttyfd, DIALER_CONNECT, connector) < 0) {
 		    error("Connect script failed");
 		    pppd_status = EXIT_CONNECT_FAILED;
@@ -361,10 +361,10 @@
 	/* run welcome script, if any */
 	if (welcomer && welcomer[0]) {
-	    if (device_script(ttyfd, DIALER_WELCOME, welcomer) < 0)
+	    if (device_script(pppd_ttyfd, DIALER_WELCOME, welcomer) < 0)
 		warn("Welcome script failed");
 	}
 
 	/* set up the serial device as a ppp interface */
-	fd_ppp = establish_ppp(ttyfd);
+	fd_ppp = establish_ppp(pppd_ttyfd);
 	if (fd_ppp < 0) {
 	    pppd_status = EXIT_FATAL_ERROR;
@@ -416,5 +416,5 @@
 	if (demand)
 	    restore_loop();
-	disestablish_ppp(ttyfd);
+	disestablish_ppp(pppd_ttyfd);
 	fd_ppp = -1;
 	if (!hungup)
@@ -430,5 +430,5 @@
 	    if (real_ttyfd >= 0)
 		set_up_tty(real_ttyfd, 1);
-	    if (device_script(ttyfd, DIALER_DISCONNECT, disconnect_script) < 0) {
+	    if (device_script(pppd_ttyfd, DIALER_DISCONNECT, disconnect_script) < 0) {
 		warn("disconnect script failed");
 	    } else {
@@ -686,5 +686,5 @@
 
     if (fd_ppp >= 0)
-	disestablish_ppp(ttyfd);
+	disestablish_ppp(pppd_ttyfd);
     if (real_ttyfd >= 0)
 	close_tty();
Index: c/src/libnetworking/pppd/sys-rtems.c
===================================================================
--- c/src/libnetworking/pppd/sys-rtems.c	(revision 982c61cc6777d1010717779ed642c98624e863f3)
+++ c/src/libnetworking/pppd/sys-rtems.c	(revision 4ca43d72e1e6af22688f868463e4ccf429e3f5c9)
@@ -489,5 +489,5 @@
 /*    printf("sent packet [%d]\n", len); */
 
-    if (write(ttyfd, p, len) < 0) {
+    if (write(pppd_ttyfd, p, len) < 0) {
 	if (errno != EIO)
 	    error("write: %m");
@@ -532,5 +532,5 @@
     int len;
 
-    if ((len = read(ttyfd, buf, PPP_MTU + PPP_HDRLEN)) < 0) {
+    if ((len = read(pppd_ttyfd, buf, PPP_MTU + PPP_HDRLEN)) < 0) {
 	if (errno == EWOULDBLOCK || errno == EINTR) len = -1;
 	/*fatal("read: %m"); */
@@ -650,5 +650,5 @@
     data.length = opt_len;
     data.transmit = for_transmit;
-    if (ioctl(ttyfd, PPPIOCSCOMPRESS, (caddr_t) &data) >= 0)
+    if (ioctl(pppd_ttyfd, PPPIOCSCOMPRESS, (caddr_t) &data) >= 0)
 	return 1;
     return (errno == ENOBUFS)? 0: -1;
Index: c/src/libnetworking/pppd/utils.c
===================================================================
--- c/src/libnetworking/pppd/utils.c	(revision 982c61cc6777d1010717779ed642c98624e863f3)
+++ c/src/libnetworking/pppd/utils.c	(revision 4ca43d72e1e6af22688f868463e4ccf429e3f5c9)
@@ -469,6 +469,6 @@
  */
 void
-print_string(p, len, printer, arg)
-    char *p;
+print_string(p_arg, len, printer, arg)
+    void *p_arg;
     int len;
     void (*printer) __P((void *, char *, ...));
@@ -476,4 +476,5 @@
 {
     int c;
+    unsigned char *p = (unsigned char *)p_arg;
 
     printer(arg, "\"");
Index: cpukit/pppd/chat.c
===================================================================
--- cpukit/pppd/chat.c	(revision 982c61cc6777d1010717779ed642c98624e863f3)
+++ cpukit/pppd/chat.c	(revision 4ca43d72e1e6af22688f868463e4ccf429e3f5c9)
@@ -164,5 +164,5 @@
 static char *phone_num      = (char *) 0;
 static char *phone_num2     = (char *) 0;
-static int ttyfd;
+/* static */ int pppd_ttyfd;
 static int timeout   = DEFAULT_CHAT_TIMEOUT;
 
@@ -247,5 +247,5 @@
   /* initialize exit code */
   exit_code = 0;
-  ttyfd     = fd;
+  pppd_ttyfd     = fd;
 
   script=pScript;
@@ -272,5 +272,5 @@
     }
   }
-  ttyfd = (int)-1;
+  pppd_ttyfd = (int)-1;
 
   return ( exit_code );
@@ -279,5 +279,5 @@
 void break_sequence()
 {
-  tcsendbreak(ttyfd, 0);
+  tcsendbreak(pppd_ttyfd, 0);
 }
 
@@ -700,5 +700,5 @@
 	while(tries)
 	{
-	    status = read(ttyfd, &c, 1);
+	    status = read(pppd_ttyfd, &c, 1);
 	    switch (status) {
 		   case 1:
@@ -716,5 +716,5 @@
   char ch = c;
 
-  return(write(ttyfd, &ch, 1));
+  return(write(pppd_ttyfd, &ch, 1));
 }
 
@@ -792,8 +792,8 @@
     memset(temp2, 0, sizeof(temp2));
 
-    tcgetattr(ttyfd, &tios);
+    tcgetattr(pppd_ttyfd, &tios);
     tios.c_cc[VMIN] = 0;
     tios.c_cc[VTIME] = timeout*10/MAX_TIMEOUTS;
-    tcsetattr(ttyfd, TCSANOW, &tios);
+    tcsetattr(pppd_ttyfd, TCSANOW, &tios);
 		
     string = clean(in_string, 0);
Index: cpukit/pppd/demand.c
===================================================================
--- cpukit/pppd/demand.c	(revision 982c61cc6777d1010717779ed642c98624e863f3)
+++ cpukit/pppd/demand.c	(revision 4ca43d72e1e6af22688f868463e4ccf429e3f5c9)
@@ -46,5 +46,5 @@
 static const char rcsid[] = RCSID;
 
-static char *frame;
+static unsigned char *frame;
 static int framelen;
 static int framemax;
Index: cpukit/pppd/pppd.h
===================================================================
--- cpukit/pppd/pppd.h	(revision 982c61cc6777d1010717779ed642c98624e863f3)
+++ cpukit/pppd/pppd.h	(revision 4ca43d72e1e6af22688f868463e4ccf429e3f5c9)
@@ -142,5 +142,5 @@
 extern int	pppifunit;	/* Interface unit number */
 extern char	ifname[];	/* Interface name */
-extern int	ttyfd;		/* Serial device file descriptor */
+extern int	pppd_ttyfd;	/* Serial device file descriptor */
 extern char	hostname[];	/* Our hostname */
 extern u_char	outpacket_buf[]; /* Buffer for outgoing packets */
@@ -302,5 +302,5 @@
 void log_packet __P((u_char *, int, char *, int));
 				/* Format a packet and log it with syslog */
-void print_string __P((char *, int,  void (*) (void *, char *, ...),
+void print_string __P((void *, int,  void (*) (void *, char *, ...),
 		void *));	/* Format a string for output */
 int slprintf __P((char *, int, char *, ...));		/* sprintf++ */
Index: cpukit/pppd/rtemsmain.c
===================================================================
--- cpukit/pppd/rtemsmain.c	(revision 982c61cc6777d1010717779ed642c98624e863f3)
+++ cpukit/pppd/rtemsmain.c	(revision 4ca43d72e1e6af22688f868463e4ccf429e3f5c9)
@@ -78,5 +78,5 @@
 static char ppp_devnam[MAXPATHLEN]; /* name of PPP tty (maybe ttypx) */
 
-int ttyfd;			/* Serial port file descriptor */
+/* int pppd_ttyfd;			* Serial port file descriptor */
 int baud_rate;			/* Actual bits/second for serial device */
 int hungup;			/* terminal has been hung up */
@@ -233,5 +233,5 @@
 
 	need_holdoff = 1;
-	ttyfd = -1;
+	pppd_ttyfd = -1;
 	real_ttyfd = -1;
 	pppd_status = EXIT_OK;
@@ -265,7 +265,7 @@
 		   user before opening it. */
 		int err;
-		ttyfd = open(devnam, O_NONBLOCK | O_RDWR, 0);
+		pppd_ttyfd = open(devnam, O_NONBLOCK | O_RDWR, 0);
 		err = errno;
-		if (ttyfd >= 0) {
+		if (pppd_ttyfd >= 0) {
 		    break;
 		}
@@ -278,6 +278,6 @@
 		    goto fail;
 	    }
-	    if ((fdflags = fcntl(ttyfd, F_GETFL)) == -1
-		|| fcntl(ttyfd, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
+	    if ((fdflags = fcntl(pppd_ttyfd, F_GETFL)) == -1
+		|| fcntl(pppd_ttyfd, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
 		warn("Couldn't reset non-blocking mode on device: %m");
 
@@ -292,7 +292,7 @@
 	     * we could clear CLOCAL at this point.
 	     */
-	    set_up_tty(ttyfd, ((connector != NULL && connector[0] != 0)
+	    set_up_tty(pppd_ttyfd, ((connector != NULL && connector[0] != 0)
 			       || initializer != NULL));
-	    real_ttyfd = ttyfd;
+	    real_ttyfd = pppd_ttyfd;
 	}
 
@@ -309,5 +309,5 @@
 
 	    if (initializer && initializer[0]) {
-		if (device_script(ttyfd, DIALER_INIT, initializer) < 0) {
+		if (device_script(pppd_ttyfd, DIALER_INIT, initializer) < 0) {
 		    error("Initializer script failed");
 		    pppd_status = EXIT_INIT_FAILED;
@@ -321,5 +321,5 @@
 
 	    if (connector && connector[0]) {
-		if (device_script(ttyfd, DIALER_CONNECT, connector) < 0) {
+		if (device_script(pppd_ttyfd, DIALER_CONNECT, connector) < 0) {
 		    error("Connect script failed");
 		    pppd_status = EXIT_CONNECT_FAILED;
@@ -361,10 +361,10 @@
 	/* run welcome script, if any */
 	if (welcomer && welcomer[0]) {
-	    if (device_script(ttyfd, DIALER_WELCOME, welcomer) < 0)
+	    if (device_script(pppd_ttyfd, DIALER_WELCOME, welcomer) < 0)
 		warn("Welcome script failed");
 	}
 
 	/* set up the serial device as a ppp interface */
-	fd_ppp = establish_ppp(ttyfd);
+	fd_ppp = establish_ppp(pppd_ttyfd);
 	if (fd_ppp < 0) {
 	    pppd_status = EXIT_FATAL_ERROR;
@@ -416,5 +416,5 @@
 	if (demand)
 	    restore_loop();
-	disestablish_ppp(ttyfd);
+	disestablish_ppp(pppd_ttyfd);
 	fd_ppp = -1;
 	if (!hungup)
@@ -430,5 +430,5 @@
 	    if (real_ttyfd >= 0)
 		set_up_tty(real_ttyfd, 1);
-	    if (device_script(ttyfd, DIALER_DISCONNECT, disconnect_script) < 0) {
+	    if (device_script(pppd_ttyfd, DIALER_DISCONNECT, disconnect_script) < 0) {
 		warn("disconnect script failed");
 	    } else {
@@ -686,5 +686,5 @@
 
     if (fd_ppp >= 0)
-	disestablish_ppp(ttyfd);
+	disestablish_ppp(pppd_ttyfd);
     if (real_ttyfd >= 0)
 	close_tty();
Index: cpukit/pppd/sys-rtems.c
===================================================================
--- cpukit/pppd/sys-rtems.c	(revision 982c61cc6777d1010717779ed642c98624e863f3)
+++ cpukit/pppd/sys-rtems.c	(revision 4ca43d72e1e6af22688f868463e4ccf429e3f5c9)
@@ -489,5 +489,5 @@
 /*    printf("sent packet [%d]\n", len); */
 
-    if (write(ttyfd, p, len) < 0) {
+    if (write(pppd_ttyfd, p, len) < 0) {
 	if (errno != EIO)
 	    error("write: %m");
@@ -532,5 +532,5 @@
     int len;
 
-    if ((len = read(ttyfd, buf, PPP_MTU + PPP_HDRLEN)) < 0) {
+    if ((len = read(pppd_ttyfd, buf, PPP_MTU + PPP_HDRLEN)) < 0) {
 	if (errno == EWOULDBLOCK || errno == EINTR) len = -1;
 	/*fatal("read: %m"); */
@@ -650,5 +650,5 @@
     data.length = opt_len;
     data.transmit = for_transmit;
-    if (ioctl(ttyfd, PPPIOCSCOMPRESS, (caddr_t) &data) >= 0)
+    if (ioctl(pppd_ttyfd, PPPIOCSCOMPRESS, (caddr_t) &data) >= 0)
 	return 1;
     return (errno == ENOBUFS)? 0: -1;
Index: cpukit/pppd/utils.c
===================================================================
--- cpukit/pppd/utils.c	(revision 982c61cc6777d1010717779ed642c98624e863f3)
+++ cpukit/pppd/utils.c	(revision 4ca43d72e1e6af22688f868463e4ccf429e3f5c9)
@@ -469,6 +469,6 @@
  */
 void
-print_string(p, len, printer, arg)
-    char *p;
+print_string(p_arg, len, printer, arg)
+    void *p_arg;
     int len;
     void (*printer) __P((void *, char *, ...));
@@ -476,4 +476,5 @@
 {
     int c;
+    unsigned char *p = (unsigned char *)p_arg;
 
     printer(arg, "\"");
