use syslog for errors, use getopt
[unix-history] / usr / src / usr.bin / uucp / acucntrl / acucntrl.c
index 71db3d2..4735e2c 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)acucntrl.c 5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)acucntrl.c 5.11 (Berkeley) %G%";
 #endif
 
 /*  acucntrl - turn around tty line between dialin and dialout
 #endif
 
 /*  acucntrl - turn around tty line between dialin and dialout
@@ -50,11 +50,13 @@ static char sccsid[] = "@(#)acucntrl.c      5.7 (Berkeley) %G%";
 #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>
@@ -173,8 +175,10 @@ int argc; char *argv[];
 
        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) {
@@ -229,13 +233,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]);
@@ -257,13 +271,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)) {
@@ -312,6 +329,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]);
@@ -550,6 +574,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;
@@ -591,6 +619,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.
@@ -718,6 +757,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;
@@ -729,4 +769,9 @@ prefix(s1, s2)
                        return (1);
        return (c == '\0');
 }
                        return (1);
        return (c == '\0');
 }
-#endif DIALINOUT
+#else  /* !DIALINOUT */
+main()
+{
+       fprintf(stderr,"acucntrl is not supported on this system\n");
+}
+#endif /* !DIALINOUT */