BSD 4_3_Tahoe release
[unix-history] / usr / src / usr.bin / uucp / acucntrl.c
index b092a79..580ec7c 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)acucntrl.c 5.8 (Berkeley) 2/12/86";
+static char sccsid[] = "@(#)acucntrl.c 5.15    (Berkeley) 5/4/88";
 #endif
 
 /*  acucntrl - turn around tty line between dialin and dialout
 #endif
 
 /*  acucntrl - turn around tty line between dialin and dialout
@@ -46,14 +46,17 @@ static char sccsid[] = "@(#)acucntrl.c      5.8 (Berkeley) 2/12/86";
 /* #define SENSECARRIER */
 
 #include "uucp.h"
 /* #define SENSECARRIER */
 
 #include "uucp.h"
+#ifdef DIALINOUT
 #include <sys/buf.h>
 #include <signal.h>
 #include <sys/conf.h>
 #include <sys/buf.h>
 #include <signal.h>
 #include <sys/conf.h>
+#ifdef vax
 #ifdef BSD4_2
 #include <vaxuba/ubavar.h>
 #else
 #include <sys/ubavar.h>
 #endif
 #ifdef BSD4_2
 #include <vaxuba/ubavar.h>
 #else
 #include <sys/ubavar.h>
 #endif
+#endif /* vax */
 #include <sys/stat.h>
 #include <nlist.h>
 #include <sgtty.h>
 #include <sys/stat.h>
 #include <nlist.h>
 #include <sgtty.h>
@@ -125,6 +128,9 @@ char resettty, resetmodem;
 int etcutmp;
 off_t utmploc;
 off_t ttyslnbeg;
 int etcutmp;
 off_t utmploc;
 off_t ttyslnbeg;
+extern int errno;
+extern char *sys_errlist[];
+off_t lseek();
 
 #define NAMSIZ sizeof(utmp.ut_name)
 #define        LINSIZ  sizeof(utmp.ut_line)
 
 #define NAMSIZ sizeof(utmp.ut_name)
 #define        LINSIZ  sizeof(utmp.ut_line)
@@ -139,14 +145,11 @@ int argc; char *argv[];
        char *device;
        int devfile;
        int uid, gid;
        char *device;
        int devfile;
        int uid, gid;
-       off_t lseek();
        struct passwd *getpwuid();
        char *rindex();
        struct passwd *getpwuid();
        char *rindex();
-       extern int errno;
-       extern char *sys_errlist[];
 
        /* check input arguments */
 
        /* check input arguments */
-       if (argc!=3) {
+       if (argc!=3 && argc != 4) {
                fprintf(stderr, usage);
                exit(1);
        }
                fprintf(stderr, usage);
                exit(1);
        }
@@ -164,16 +167,12 @@ int argc; char *argv[];
        device = rindex(argv[2], '/');
        device = (device == NULL) ? argv[2]: device+1;
 
        device = rindex(argv[2], '/');
        device = (device == NULL) ? argv[2]: device+1;
 
-       /* only recognize devices of the form ttydX */
-       if (strncmp(device, "ttyd", 4)!=0) {
-               fprintf(stderr, "Bad Device Name %s", device);
-               exit(1);
-       }
-
        opnttys(device);
 
        opnttys(device);
 
+#ifdef vax
        /* Get nlist info */
        nlist("/vmunix", nl);
        /* Get nlist info */
        nlist("/vmunix", nl);
+#endif vax
 
        /* Chdir to /dev */
        if(chdir(Devhome) < 0) {
 
        /* Chdir to /dev */
        if(chdir(Devhome) < 0) {
@@ -192,14 +191,15 @@ int argc; char *argv[];
                exit(1);
        }
 
                exit(1);
        }
 
+       if (strcmp(p, "uucp") == 0 && argc == 4)
+               p = argv[3];
+
        /*  to upper case */
        i = 0;
        do {
                uname[i] = *p;
        /*  to upper case */
        i = 0;
        do {
                uname[i] = *p;
-               Uname[i] = (*p>='a' && *p<='z') ? (*p - ('a'-'A')) : *p;
-               i++; p++;
-       } while (*p && i<NAMSIZ);
-
+               Uname[i++] = (*p>='a' && *p<='z') ? (*p - ('a'-'A')) : *p;
+       } while (*p++ && i<NAMSIZ);
 
        /* check to see if line is being used */
        if( (etcutmp = open(Etcutmp, 2)) < 0) {
 
        /* check to see if line is being used */
        if( (etcutmp = open(Etcutmp, 2)) < 0) {
@@ -228,13 +228,23 @@ int argc; char *argv[];
                exit(2);
        }
 
                exit(2);
        }
 
+#ifndef sequent
        /* Disable modem control */
        if (setmodem(device, DISABLE) < 0) {
                fprintf(stderr, "Unable to disable modem control\n");
                exit(1);
        }
        /* Disable modem control */
        if (setmodem(device, DISABLE) < 0) {
                fprintf(stderr, "Unable to disable modem control\n");
                exit(1);
        }
+#endif !sequent
 
        if (enable) {
 
        if (enable) {
+#ifdef sequent
+               if (setmodem(device, ENABLE) < 0) {
+                       fprintf(stderr, "Cannot Enable modem control\n");
+                       (void)setmodem(device, i);
+                       exit(1);
+               }
+#endif sequent
+#ifndef sequent
                if((devfile = open(device, 1)) < 0) {
                        fprintf(stderr, "On open of %s: %s\n",
                                device, sys_errlist[errno]);
                if((devfile = open(device, 1)) < 0) {
                        fprintf(stderr, "On open of %s: %s\n",
                                device, sys_errlist[errno]);
@@ -256,13 +266,16 @@ int argc; char *argv[];
                            "Cannot set hangup on close on %s: %s\n",
                                device, sys_errlist[errno]);
 
                            "Cannot set hangup on close on %s: %s\n",
                                device, sys_errlist[errno]);
 
+#endif !sequent
                i = resetmodem;
 
                i = resetmodem;
 
+#ifndef sequent
                if (setmodem(device, ENABLE) < 0) {
                        fprintf(stderr, "Cannot Enable modem control\n");
                        (void)setmodem(device, i);
                        exit(1);
                }
                if (setmodem(device, ENABLE) < 0) {
                        fprintf(stderr, "Cannot Enable modem control\n");
                        (void)setmodem(device, i);
                        exit(1);
                }
+#endif sequent
                resetmodem=i;
 
                if (settys(ENABLE)) {
                resetmodem=i;
 
                if (settys(ENABLE)) {
@@ -311,6 +324,13 @@ int argc; char *argv[];
                        pokeinit(device, Uname, enable);
                }
                post(device, Uname);
                        pokeinit(device, Uname, enable);
                }
                post(device, Uname);
+#ifdef sequent
+       /* Disable modem control */
+       if (setmodem(device, DISABLE) < 0) {
+               fprintf(stderr, "Unable to disable modem control\n");
+               exit(1);
+       }
+#endif sequent
                if((devfile = open(device, O_RDWR|O_NDELAY)) < 0) {
                        fprintf(stderr, "On %s open: %s\n",
                                device, sys_errlist[errno]);
                if((devfile = open(device, O_RDWR|O_NDELAY)) < 0) {
                        fprintf(stderr, "On %s open: %s\n",
                                device, sys_errlist[errno]);
@@ -549,6 +569,10 @@ char *device;
                        *p = '\0';
                if(strncmp(device, &linebuf[2], ndevice) == 0) {
                        (void)fclose(ttysfile);
                        *p = '\0';
                if(strncmp(device, &linebuf[2], ndevice) == 0) {
                        (void)fclose(ttysfile);
+#ifdef sequent
+                       /* Why is the sequent off by one? */
+                       utmploc += sizeof(utmp);
+#endif sequent
                        return;
                }
                ttyslnbeg += lnsiz;
                        return;
                }
                ttyslnbeg += lnsiz;
@@ -590,6 +614,17 @@ int enable;
 }
 #endif !BSD4_3
 
 }
 #endif !BSD4_3
 
+#ifdef sequent
+setmodem(ttyline, enable)
+char *ttyline; int enable;
+{
+       char *sysbuf[BUFSIZ];
+       sprintf(sysbuf,"/etc/ttyconfig /dev/%s -special %s", ttyline,
+               enable ? "-carrier" : "-nocarrier");
+       system(sysbuf);
+}
+#endif /* sequent */
+#ifdef vax
 /*
  * Excerpted from (June 8, 1983 W.Sebok)
  * > ttymodem.c - enable/disable modem control for tty lines.
 /*
  * Excerpted from (June 8, 1983 W.Sebok)
  * > ttymodem.c - enable/disable modem control for tty lines.
@@ -709,7 +744,7 @@ char *ttyline; int enable;
                        }
                        cflags = flags;
                        (void)lseek(kmem, (off_t) &(((char *)addr)[unit]), 0);
                        }
                        cflags = flags;
                        (void)lseek(kmem, (off_t) &(((char *)addr)[unit]), 0);
-                       (void)write(kmem, (char *) &flags, sizeof cflags);
+                       (void)write(kmem, (char *) &cflags, sizeof cflags);
                        break;
                default:
                        fprintf(stderr, "Unknown device type\n");
                        break;
                default:
                        fprintf(stderr, "Unknown device type\n");
@@ -717,6 +752,7 @@ char *ttyline; int enable;
        }
        return(0);
 }
        }
        return(0);
 }
+#endif /* vax */
 
 prefix(s1, s2)
        register char *s1, *s2;
 
 prefix(s1, s2)
        register char *s1, *s2;
@@ -728,3 +764,9 @@ prefix(s1, s2)
                        return (1);
        return (c == '\0');
 }
                        return (1);
        return (c == '\0');
 }
+#else  /* !DIALINOUT */
+main()
+{
+       fprintf(stderr,"acucntrl is not supported on this system\n");
+}
+#endif /* !DIALINOUT */