Aittvax.114 net.unix-wizards utzoo!decvax!ittvax!swatt Sun Aug 30 18:00:57 1981 4.1bsd carrier enable program 4.1bsd hassles: whose got a carrier signal this week? This is for all of you 4.1bsd users who have flakey cables and don't want to build the system again each time you discover a new one. I don't have a manual page for it, but the options are obvious. carrier enable tty ... will enable HARDWARE carrier detection on the specified lines (the device name with the initial "/dev/" omitted). carrier disable tty ... will disable HARDWARE carrier detection on the specified lines (will use a software carrier bit that is ALWAYS set). carrier print tty ... will show the current status of the named lines. The special line name "all" will apply to all lines. This version only handles DZ devices (sigh). - Alan S. Watt (decvax!ittvax!swatt) :::::::::::: carrier.c :::::::::::: #include #include #include #include #ifdef lint # define IGNORE(X) __void__=(int)(X) int __void__; #else # define IGNORE(X) X #endif /* set/clear carrier required status for * dz terminals (KLUDGE) */ int cmd; int todo; int maxdev; char devices[128]; char USAGE[] = "usage: \"carrier {enable|disable|print} {all|ttyname ...}\"."; char sysname[] = "/vmunix"; char kmem[] = "/dev/kmem"; extern char *sys_errlisg[]; extern errno; #define ENABLE 1 #define DISABLE 0 #define PRINT 2 char *strcpy(), *strcat(); long lseek(); main (argc, argv) int argc; char **argv; { register i; if (argc 0; argc--, argv++) bldcarrier (*argv); if (todo == 0) error ("no termials to fix"); fixterms (); } /* VARARGS1 */ fperror (gripe, args) char *gripe; { extern int errno; extern char *sys_errlist[]; int sverrno = errno; _doprnt (gripe, &args, stderr); error (": %s", sys_errlist[sverrno]); } /* VARARGS1 */ remark (fmt, args) char *fmt; { _doprnt (fmt, &args, stderr); IGNORE (putc ('\n', stderr)); } /* VARARGS1 */ error(gripe, args) char *gripe; { _doprnt (gripe, &args, stderr); IGNORE (putc ('\n', stderr)); exit (-1); } bldcarrier (term) char *term; { static char devdir[] = "/dev/"; char devbuf[64]; struct stat sb; int devno; if (stat (term, (struct stat *)&sb) == -1 && errno == ENOENT) { strcpy (devbuf, devdir); strcat (devbuf, term); if (stat (devbuf, (struct stat *)&sb) == -1) { remark ("device %s not found (skipped)", term); return; } } devno = minor (sb.st_rdev); if (devno > maxdev) maxdev = devno; devices[devno] = 1; todo += 1; } #include struct nlist nl[] ={ { "_dzsoftCAR" }, /* Software carrier present bit array */ #define SOFTCAR 0 { "_dz_cnt" }, /* count of DZ devices configured in system */ #define DZCOUNT 1 0 }; #define BITSET(i, base) (base[i>>3]|=(1<<(I%8))) BASE) #DEFINE (BASE[I BITCLR(I,>>3]&= ~(1<<(I%8))) BASE) #DEFINE (BASE[I BITTST(I,>>3]&(1<<(I%8))) (MFD, SIZEOF DZCOUNT)); PRINT) 0)); MODE; FILE SYSNAME); IGNORE ((MFD="open" ERROR (MAXDEV KMEM); 0 /* : < ? GET FPERROR MODE="(cmd=" (NL[0].N_TYPE="0)" () 0) CHAR NL); DZCARRIER[64]; (READ FIXTERMS OPEN GO SYMBOL { (LONG)NL[DZCOUNT].N_VALUE, REGISTER (CHAR SYMBOLS ("CANNOT */ WITH (LSEEK DZCOUNT; I; %S", NLIST *)&DZCOUNT, 2; IF MUCK (KMEM, (LONG)NL[SOFTCAR].N_VALUE, DZCARRIER, FROM /DEV/MEM INT MFD; (SYSNAME, MODE))> dzcount) remark ("warning: only %d dz devices in system", dzcount); for (i = 0 ; i
This Usenet Oldnews Archive article may be copied and distributed freely, provided:

1. There is no money collected for the text(s) of the articles.
2. The following notice remains appended to each copy:

The Usenet Oldnews Archive: Compilation Copyright© 1981, 1996
Bruce Jones, Henry Spencer, David Wiseman.


Goto NEXT article in NET.unix-wizards Newsgroup
Return to NET.unix-wizards index
Return to the Usenet Oldnews Archive index ----------------------------------------------------------------- gopher://quux.org/ conversion by John Goerzen of http://communication.ucsd.edu/A-News/ This Usenet Oldnews Archive article may be copied and distributed freely, provided: 1. There is no money collected for the text(s) of the articles. 2. The following notice remains appended to each copy: The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996 Bruce Jones, Henry Spencer, David Wiseman.