]> git.ozlabs.org Git - ppp.git/blobdiff - chat/chat.c
don't recurse in terminate()
[ppp.git] / chat / chat.c
index 1b744a958c8fc6448d6633f0a66bc984032b58e5..5ce1336e381329afb811bb71e209efd840ade535 100644 (file)
@@ -78,7 +78,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: chat.c,v 1.17 1997/11/27 06:37:15 paulus Exp $";
+static char rcsid[] = "$Id: chat.c,v 1.20 1999/03/31 12:28:16 paulus Exp $";
 #endif
 
 #include <stdio.h>
@@ -130,9 +130,17 @@ static char rcsid[] = "$Id: chat.c,v 1.17 1997/11/27 06:37:15 paulus Exp $";
 #define O_NONBLOCK     O_NDELAY
 #endif
 
+#ifdef SUNOS
+extern int sys_nerr;
+extern char *sys_errlist[];
+#define memmove(to, from, n)   bcopy(from, to, n)
+#define strerror(n)            ((unsigned)(n) < sys_nerr? sys_errlist[(n)] :\
+                                "unknown error")
+#endif
+
 /*************** Micro getopt() *********************************************/
 #define        OPTION(c,v)     (_O&2&&**v?*(*v)++:!c||_O&4?0:(!(_O&1)&& \
-                               ((--c,++v),_O=4,c)&&**v=='-'&&v[0][1]?*++*v=='-'\
+                               (--c,++v),_O=4,c&&**v=='-'&&v[0][1]?*++*v=='-'\
                                &&!v[0][1]?(--c,++v,0):(_O=2,*(*v)++):0))
 #define        OPTARG(c,v)     (_O&2?**v||(++v,--c)?(_O=1,--c,*v++): \
                                (_O=4,(char*)0):(char*)0)
@@ -598,6 +606,11 @@ void break_sequence()
 void terminate(status)
 int status;
 {
+    static int terminating = 0;
+
+    if (terminating)
+       exit(status);
+    terminating = 1;
     echo_stderr(-1);
     if (report_file != (char *) 0 && report_fp != (FILE *) NULL) {
 /*
@@ -1004,7 +1017,6 @@ register char *s;
 
     if (clear_abort_next) {
        char *s1;
-       char *s2 = s;
        int   i;
         int   old_max;
        int   pack = 0;
@@ -1055,7 +1067,6 @@ register char *s;
 
     if (clear_report_next) {
        char *s1;
-        char *s2 = s;
        int   i;
        int   old_max;
        int   pack = 0;
@@ -1408,6 +1419,16 @@ register char *string;
     return (0);
 }
 
+/*
+ * Gross kludge to handle Solaris versions >= 2.6 having usleep.
+ */
+#ifdef SOL2
+#include <sys/param.h>
+#if MAXUID > 65536             /* then this is Solaris 2.6 or later */
+#undef NO_USLEEP
+#endif
+#endif /* SOL2 */
+
 #ifdef NO_USLEEP
 #include <sys/types.h>
 #include <sys/time.h>
@@ -1478,7 +1499,6 @@ vfmtmsg(buf, buflen, fmt, args)
     const char *f;
     unsigned char *p;
     char num[32];
-    time_t t;
     static char hexchars[] = "0123456789abcdef";
 
     buf0 = buf;