X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/5ebee54441a7fdb912615b5947d5de033da420c0..ad7871609881e73855d0b04da49b486cd93efca7:/usr/src/usr.bin/uucp/acucntrl/acucntrl.c?ds=inline diff --git a/usr/src/usr.bin/uucp/acucntrl/acucntrl.c b/usr/src/usr.bin/uucp/acucntrl/acucntrl.c index 552d71e7da..deba6bac7d 100644 --- a/usr/src/usr.bin/uucp/acucntrl/acucntrl.c +++ b/usr/src/usr.bin/uucp/acucntrl/acucntrl.c @@ -1,6 +1,45 @@ +/*- + * Copyright (c) 1985, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + #ifndef lint -static char sccsid[] = "@(#)acucntrl.c 5.10 (Berkeley) %G%"; -#endif +static char copyright[] = +"@(#) Copyright (c) 1985, 1986, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)acucntrl.c 8.1 (Berkeley) 6/6/93"; +#endif /* not lint */ /* acucntrl - turn around tty line between dialin and dialout * @@ -19,28 +58,28 @@ static char sccsid[] = "@(#)acucntrl.c 5.10 (Berkeley) %G%"; * Operation: * disable (i.e. setup for dialing out) * (1) check input arguments - * (2) look in /etc/utmp to check that the line is not in use by another + * (2) look in _PATH_UTMP to check that the line is not in use by another * (3) disable modem control on terminal * (4) check for carrier on device * (5) change owner of device to real id - * (6) edit /etc/ttys, changing the first character of the appropriate + * (6) edit _PATH_TTYS, changing the first character of the appropriate * line to 0 * (7) send a hangup to process 1 to poke init to disable getty - * (8) post uid name in capitals in /etc/utmp to let world know device has - * been grabbed + * (8) post uid name in capitals in _PATH_UTMP to let world know device + * has been grabbed * (9) make sure that DTR is on * * enable (i.e.) restore for dialin * (1) check input arguments - * (2) look in /etc/utmp to check that the line is not in use by another + * (2) look in _PATH_UTMP to check that the line is not in use by another * (3) make sure modem control on terminal is disabled * (4) turn off DTR to make sure line is hung up * (5) condition line: clear exclusive use and set hangup on close modes * (6) turn on modem control - * (7) edit /etc/ttys, changing the first character of the appropriate + * (7) edit _PATH_TTYS, changing the first character of the appropriate * line to 1 * (8) send a hangup to process 1 to poke init to enable getty - * (9) clear uid name for /etc/utmp + * (9) clear uid name for _PATH_UTMP */ /* #define SENSECARRIER */ @@ -64,6 +103,7 @@ static char sccsid[] = "@(#)acucntrl.c 5.10 (Berkeley) %G%"; #include #include #include +#include "pathnames.h" #define NDZLINE 8 /* lines/dz */ #define NDHLINE 16 /* lines/dh */ @@ -112,14 +152,13 @@ struct nlist nl[] = { #define ENABLE 1 #define DISABLE 0 -char Etcutmp[] = "/etc/utmp"; -char Etcttys[] = "/etc/ttys"; +char Etcttys[] = _PATH_TTYS; #ifdef BSD4_3 FILE *ttysfile, *nttysfile; -char NEtcttys[] = "/etc/ttys.new"; +char NEtcttys[] = _PATH_NEWTTYS; extern long ftell(); #endif BSD4_3 -char Devhome[] = "/dev"; +char Devhome[] = _PATH_DEV; char usage[] = "Usage: acucntrl {dis|en}able ttydX\n"; @@ -128,6 +167,9 @@ char resettty, resetmodem; 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) @@ -142,14 +184,11 @@ int argc; char *argv[]; char *device; int devfile; int uid, gid; - off_t lseek(); struct passwd *getpwuid(); char *rindex(); - extern int errno; - extern char *sys_errlist[]; /* check input arguments */ - if (argc!=3) { + if (argc!=3 && argc != 4) { fprintf(stderr, usage); exit(1); } @@ -167,17 +206,11 @@ int argc; char *argv[]; 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); #ifdef vax /* Get nlist info */ - nlist("/vmunix", nl); + nlist(_PATH_UNIX, nl); #endif vax /* Chdir to /dev */ @@ -197,19 +230,20 @@ int argc; char *argv[]; exit(1); } + if (strcmp(p, "uucp") == 0 && argc == 4) + p = argv[3]; + /* to upper case */ i = 0; do { uname[i] = *p; - Uname[i] = (*p>='a' && *p<='z') ? (*p - ('a'-'A')) : *p; - i++; p++; - } while (*p && i='a' && *p<='z') ? (*p - ('a'-'A')) : *p; + } while (*p++ && i 0); } @@ -465,7 +499,7 @@ char *device; exit(1); } -/* modify appropriate line in /etc/ttys to turn on/off the device */ +/* modify appropriate line in _PATH_TTYS to turn on/off the device */ settys(enable) int enable; { @@ -499,7 +533,8 @@ int enable; cp++; } if (*cp == '\0') { - fprintf(stderr,"Badly formatted line in /etc/ttys:\n%s", lbuf); + fprintf(stderr,"Badly formatted line in %s:\n%s", + _PATH_TTYS, lbuf); exit(1); } c1 = *--cp; @@ -508,7 +543,8 @@ int enable; while (*cp && *cp != ' ' && *cp != '\t' && *cp != '\n') cp++; if (*cp == '\0') { - fprintf(stderr,"Badly formatted line in /etc/ttys:\n%s", lbuf); + fprintf(stderr,"Badly formatted line in %s:\n%s", + _PATH_TTYS, lbuf); exit(1); } c2 = *cp; @@ -587,7 +623,7 @@ char *device; exit(1); } -/* modify appropriate line in /etc/ttys to turn on/off the device */ +/* modify appropriate line in _PATH_TTYS to turn on/off the device */ settys(enable) int enable; { @@ -662,8 +698,9 @@ char *ttyline; int enable; return(-1); } - if((kmem = open("/dev/kmem", 2)) < 0) { - fprintf(stderr, "/dev/kmem open: %s\n", sys_errlist[errno]); + if((kmem = open(_PATH_KMEM, 2)) < 0) { + fprintf(stderr, "%s open: %s\n", _PATH_KMEM, + sys_errlist[errno]); return(-1); } @@ -749,7 +786,7 @@ char *ttyline; int enable; } 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"); @@ -769,4 +806,9 @@ prefix(s1, s2) return (1); return (c == '\0'); } -#endif /* DIALINOUT */ +#else /* !DIALINOUT */ +main() +{ + fprintf(stderr,"acucntrl is not supported on this system\n"); +} +#endif /* !DIALINOUT */