purge debug crap
authorBill Joy <root@ucbvax.Berkeley.EDU>
Wed, 24 Mar 1982 06:42:20 +0000 (22:42 -0800)
committerBill Joy <root@ucbvax.Berkeley.EDU>
Wed, 24 Mar 1982 06:42:20 +0000 (22:42 -0800)
SCCS-vsn: libexec/telnetd/telnetd.c 4.5

usr/src/libexec/telnetd/telnetd.c

index 34d8b19..45fb0dc 100644 (file)
@@ -1,4 +1,7 @@
-static char sccsid[] = "@(#)telnetd.c  4.4 (Berkeley) %G%";
+#ifndef lint
+static char sccsid[] = "@(#)telnetd.c  4.5 82/03/23";
+#endif
+
 /*
  * Stripped-down telnet server.
  */
 /*
  * Stripped-down telnet server.
  */
@@ -14,7 +17,6 @@ static char sccsid[] = "@(#)telnetd.c 4.4 (Berkeley) %G%";
 
 #define        INFINITY        10000000
 #define        BELL            '\07'
 
 #define        INFINITY        10000000
 #define        BELL            '\07'
-#define        swab(x)         ((((x) >> 8) | ((x) << 8)) & 0xffff)
 
 char   hisopts[256];
 char   myopts[256];
 
 char   hisopts[256];
 char   myopts[256];
@@ -40,18 +42,9 @@ int  inter;
 extern int errno;
 char   line[] = "/dev/ptyp0";
 
 extern int errno;
 char   line[] = "/dev/ptyp0";
 
-struct sockaddr_in sin = { AF_INET, swab(IPPORT_TELNET) };
+struct sockaddr_in sin = { AF_INET, IPPORT_TELNET };
 int    options = SO_ACCEPTCONN|SO_KEEPALIVE;
 
 int    options = SO_ACCEPTCONN|SO_KEEPALIVE;
 
-/*
- * Debugging hooks.  Turned on with a SIGTERM.
- * Successive SIGTERM's toggle the switch.
- */
-int    toggle();
-int    debug;
-FILE   *log;
-char   logfile[80] = "/tmp/teldebugx";
-
 main(argc, argv)
        char *argv[];
 {
 main(argc, argv)
        char *argv[];
 {
@@ -61,6 +54,9 @@ main(argc, argv)
        argc--, argv++;
        if (argc > 0 && !strcmp(argv[0], "-d"))
                options |= SO_DEBUG;
        argc--, argv++;
        if (argc > 0 && !strcmp(argv[0], "-d"))
                options |= SO_DEBUG;
+#if vax || pdp11
+       sin.sin_port = htons(sin.sin_port);
+#endif
        for (;;) {
                errno = 0;
                if ((s = socket(SOCK_STREAM, 0, &sin, options)) < 0) {
        for (;;) {
                errno = 0;
                if ((s = socket(SOCK_STREAM, 0, &sin, options)) < 0) {
@@ -106,7 +102,6 @@ doit(f)
        printf("All network ports in use.\n");
        exit(1);
 gotpty:
        printf("All network ports in use.\n");
        exit(1);
 gotpty:
-       logfile[strlen("/tmp/teldebug")] = "0123456789abcdef"[i];
        dup2(f, 0);
        cp[strlen("/dev/")] = 't';
        t = open("/dev/tty", 2);
        dup2(f, 0);
        cp[strlen("/dev/")] = 't';
        t = open("/dev/tty", 2);
@@ -154,7 +149,6 @@ telnet(f, p)
        ioctl(p, FIONBIO, &on);
        signal(SIGTSTP, SIG_IGN);
        sigset(SIGCHLD, cleanup);
        ioctl(p, FIONBIO, &on);
        signal(SIGTSTP, SIG_IGN);
        sigset(SIGCHLD, cleanup);
-       sigset(SIGTERM, toggle);
 
        for (;;) {
                int ibits = 0, obits = 0;
 
        for (;;) {
                int ibits = 0, obits = 0;
@@ -174,12 +168,7 @@ telnet(f, p)
                        ibits |= (1 << f);
                if (ncc < 0 && pcc < 0)
                        break;
                        ibits |= (1 << f);
                if (ncc < 0 && pcc < 0)
                        break;
-               if (debug)
-                       fprintf(log, "select: ibits=%d, obits=%d\n",
-                               ibits, obits);
                select(32, &ibits, &obits, INFINITY);
                select(32, &ibits, &obits, INFINITY);
-               if (debug)
-                       fprintf(log, "ibits=%d, obits=%d\n", ibits, obits);
                if (ibits == 0 && obits == 0) {
                        sleep(5);
                        continue;
                if (ibits == 0 && obits == 0) {
                        sleep(5);
                        continue;
@@ -190,8 +179,6 @@ telnet(f, p)
                 */
                if (ibits & (1 << f)) {
                        ncc = read(f, netibuf, BUFSIZ);
                 */
                if (ibits & (1 << f)) {
                        ncc = read(f, netibuf, BUFSIZ);
-                       if (debug)
-                               fprintf(log, "read %d from net\n", ncc);
                        if (ncc < 0 && errno == EWOULDBLOCK)
                                ncc = 0;
                        else {
                        if (ncc < 0 && errno == EWOULDBLOCK)
                                ncc = 0;
                        else {
@@ -206,8 +193,6 @@ telnet(f, p)
                 */
                if (ibits & (1 << p)) {
                        pcc = read(p, ptyibuf, BUFSIZ);
                 */
                if (ibits & (1 << p)) {
                        pcc = read(p, ptyibuf, BUFSIZ);
-                       if (debug)
-                               fprintf(log, "read %d from pty\n", pcc);
                        if (pcc < 0 && errno == EWOULDBLOCK)
                                pcc = 0;
                        else {
                        if (pcc < 0 && errno == EWOULDBLOCK)
                                pcc = 0;
                        else {
@@ -531,23 +516,6 @@ netflush()
                nbackp = nfrontp = netobuf;
 }
 
                nbackp = nfrontp = netobuf;
 }
 
-toggle()
-{
-       if (debug) {
-               fprintf(log, "log stopped\n");
-               if (log)
-                       fclose(log);
-       } else {
-               if ((log = fopen(logfile, "a")) != NULL) {
-                       setbuf(log, 0);
-                       fprintf(log, "log started on /dev/pty%c\n",
-                               logfile[strlen("/tmp/teldebug")]);
-                       fprintf(log, "net=%d, pty=%d\n", net, pty);
-               }
-       }
-       debug = !debug;
-}
-
 cleanup()
 {
        int how = 2;
 cleanup()
 {
        int how = 2;