[comp.sources.misc] v09i057: uustatus 1.1.f -- curses-oriented uustat

allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc) (12/08/89)

Posting-number: Volume 9, Issue 57
Submitted-by: erc@khijol.UUCP (Edwin R. Carp)
Archive-name: uustatus

Here is a report of uustatus, which was posted about a year ago.  I mentioned
it on the net a gew days ago, and have had lots of requests for it.
----------------------------------- cut here -----------------------------------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  uustatus uustatus/Makefile uustatus/README
#   uustatus/basename.fun uustatus/dirent.h uustatus/findpath.1
#   uustatus/findpath.c uustatus/findpath.doc uustatus/findpath.prt
#   uustatus/makedocs uustatus/strrep.fun uustatus/touch.fun
#   uustatus/unback.c uustatus/uustatus.1 uustatus/uustatus.c
#   uustatus/uustatus.doc uustatus/uustatus.h uustatus/uustatus.prt
# Wrapped by erc@khijol on Mon Dec  4 01:40:49 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test ! -d uustatus ; then
    echo shar: Creating directory \"uustatus\"
    mkdir uustatus
fi
if test -f uustatus/Makefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus/Makefile\"
else
echo shar: Extracting \"uustatus/Makefile\" \(1255 characters\)
sed "s/^X//" >uustatus/Makefile <<'END_OF_uustatus/Makefile'
X#
X#	Makefile for uustatus and findpath
X#	...by Robert J. Granvin
X#	January 26, 1989
X#
X
X
X#
X#	You will need to be root to make the install.
X#
X#	If you want uustatus to display sites marked as WRONG TIME TO CALL,
X#	add -DWTTC to the FLAGS line.  (This is only valid for uustatus).
X#
X#	Add -DNEEDDIRENT to FLAGS if you don't have /usr/include/dirent.h,
X#	or want to use the supplied dirent.h.
X#
X#	Define OWNER and GROUP to be the same as UUCPOWN and UUCPGRP as
X#	defined in uustatus.h
X#
X#	Define BINDIR to where you want the binaries installed.
X#
X
X# FLAGS=-O -DM_XENIX -DWTTC -DNEEDDIRENT
XFLAGS=-O -DM_XENIX -DWTTC
X# LIBS=-lcurses -ltermcap
XLIBS=-lcurses -ldir
XOWNER=uucp
XGROUP=uucp
XBINDIR=/usr/local/bin
XCC=cc
X
X
Xall:	uustatus findpath
X
X
Xuustatus:	uustatus.c uustatus.h basename.fun touch.fun
X	$(CC) $(FLAGS) -o uustatus uustatus.c $(LIBS)
X
Xfindpath:	findpath.c basename.fun strrep.fun
X	$(CC) $(FLAGS) -o findpath findpath.c
X
Xclean:
X	rm -f *.o core
X
Xclobber: clean
X	rm -f uustatus findpath
X
Xinstall: all
X	rm -f $(BINDIR)/uustatus $(BINDIR)/findpath
X	strip uustatus
X	strip findpath
X	cp uustatus $(BINDIR)
X	cp findpath $(BINDIR)
X	chown $(OWNER) $(BINDIR)/uustatus
X	chgrp $(GROUP) $(BINDIR)/uustatus
X	chmod 4755 $(BINDIR)/uustatus
X	chmod 755 $(BINDIR)/findpath
X
END_OF_uustatus/Makefile
if test 1255 -ne `wc -c <uustatus/Makefile`; then
    echo shar: \"uustatus/Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus/README -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus/README\"
else
echo shar: Extracting \"uustatus/README\" \(6364 characters\)
sed "s/^X//" >uustatus/README <<'END_OF_uustatus/README'
Xuustatus - by Ed Carp
X
XChanges for version 1.1.f:
X
XUnder certain circumstances, the uucico log files may disappear, causing a core
Xdump when attempting to read these files.  This has been fixed.  This only
Xoccurs when uustatus is running and the uucico log file disappears, then a
Xconversation is attempted.
X
XAlso works on AIX (tested on the PS/2, but should work for the RT and Rios).
X
XChanges for version 1.1.a:
X
XFixed minor bugs - (1) XENIX now properly works, thanks to Sandy,
Xand (2) the Makefile was generously supplied by Robert J. Granvin.
X
XChanges for version 1.1:
X
Xuustatus now provides a realtime display of the uucico log file as the
Xconversation is taking place (much like "tail -f" does, but it doesn't
Xscroll the screen).  This only works for the first system that uustatus
Xfinds that is engaging in a conversation.  An asterisk is placed by the
Xstatus of the system to note that fact.
X
Xuustatus now displays the number of input and output files for each system.
X
XIf there does not exist a status file for a system, the system exists in the
XSystems file, and there are files waiting to be transferred to that system,
Xuustatus will create a dummy status file for that system.
X
XIf a system is currently engaged in a conversation, uustatus will display
Xthe status of the system in reverse video.
X
XThere is now a #define for displaying system status on systems that 
Xcurrently display WRONG TIME TO CALL messages.
X
XThanks to the following people for their suggestions and advice.  If y'all
Xdon't see all of your suggestions implemented, please be patient.
X
XDoug Blair
XGordon Moffett
XJohan Vromans
XRobert J. Granvin
XSandy Zelkovitz
X
X
XIntroduction
X
XHDB UUCP may be a dream to some, but for me it can be a real pain,
Xkeeping up with everything that's happening on my system.  This simple
X(relatively) program dynamically displays the status of your UUCP
Xconnections for you, without you having to cd into all of those
Xpesky directories.  It's also faster than uustat -m, and it's
Xreal-time!
X
XThe best part about this mish-mash, however, is dirent.h.  I liked the
XBSD/XENIX directory routines a lot, but didn't have them on my System V
Xbox.  So, I hacked up a couple of routines that work just as well.
Xopendir(), closedir(), and readdir() are all that are supported, but that
Xwas (and still is) enough for most system programming applications.
X
XBTW, these routines are supported on most systems as of version 1.1.f.
X
XI also have a little gadget that will search your path for a program -
Xhandy if you can get to a program (execute it), but need to know where the
Xdumb thing is, and don't have the time to waste with "find `echo $PATH|tr ...
Xstuff.  It's also MUCH faster, and it's included FREE!
X
XCompiling (you can also hack & use the Makefile):
X
X1.	cc -s -o uustatus uustatus.c -lcurses -ltermcap -O
X	(or whatever libraries your system needs to support curses).
X	cc -s -o findpath findpath.c -O
X
X2.	chown uucp uustatus;chmod 4755 uustatus
X
X
XDocs:
X	The manpage source is in uustatus.1, the nroff'ed output
X	is in uustatus.prt, and the viewable output is in uustatus.doc.
X	I used the -man macro package, so it should work on anyone's
X	system.  If you make changes to the manpage, you can regenerate
X	the docs by running "makedocs".
X
X
XCustomization:
X
X	There are a number of tuneable parameters in uustatus.h
X	that you can play with.
X
X/* #define WTTC */
XIf you want to display status on systems that have this status posted,
Xuncomment this define.
X
X#define STATUS "/usr/spool/uucp/.Status"
XThis is where HDB UUCP puts its status files.  This should not be changed.
X
X#define SYSTEMS "/usr/lib/uucp/Systems"
XThis is where the Systems file resides.  It must be readable by the owner
Xof uustatus.
X
X#define UUCICO "/usr/spool/uucp/.Log/uucico"
XThis is where the uucico log files live.
X
X#define LOCKFILE "/usr/spool/uucp/LCK..%s"
XThis is where the lock files reside.  Don't touch this, either...
X
X#define WORKFILE "/usr/spool/uucp/%s"
XThis is another one of those "don't touch me" parameters...
X
X#define EXPDAYS 14 /* connections older than X days will not be displayed */
XIn this example, UUCP connections older than 14 days will not be displayed,
Xregardless of their status.
X
X#define LOGON NO /* log expired systems? */
XIf you want to log everything that goes on, set this to YES.  Generally
Xuseless except for debugging.
X
X#define LOGFILE "/tmp/uuexp.log"
XThis is where the log output goes.
X
X#define WAITMSG "WAIT"
XStandard wait message.
X
X#define BWAITMSG "    " /* blank wait msg string */
XThis must be the same length as the WAITMSG string (unless you want your screen
Xto wind up looking strange).
X
X#define LLIMIT LINES-5
XThis is how many lines of data we can display on the screen.  Generally
Xa no-no to touch.
X
X#define FLIMIT 50 /* over this many files for site, we quit - must be < 100 */
XWhen we scan the directories for work, we don't want to eat up too many
Xsystem resources if we have a large directory with lots of stuff in it (not
Xtoo uncommon for a large news feed), so after we read FLIMIT file names, we
Xquit that directory and indicate that we have over that many files.
XI set mine to 50, bt you can use a smaller number if your system is very
XI/O bound (like you're running XENIX on an XT with a 65ms hard drive).
X
X#define UUCPOWN "uucp"
X#define UUCPGRP "uucp"
XThese should be set to "uucp".  These are used to create the status files
Xif they do not exist.
X
X#define SLEEPTIME 10 /* time to sleep between samples */
XTime to sleep between samples.  If you have a fast system with caching,
Xyou might want to up this to make it more real-time.  If nothing ever
Xhappens on your system and you want to leave this up in a window, you
Xmight want to set it to something like 30 or 60.
X
X
XThat's it!  Enjoy...and please remember -- if you make any changes or
Xenhancements, please let me know (context diffs are OK).
X
XNo warranty expressed or implied.  I have tried as best I could to make sure
Xthere are no bugs, but you know how that goes...at least it doesn't do
Xanything but read files...
X
XEnhancements:
X
X	Well, a sorted display of systems would be nice...Any other
X	suggestions?
X----------------------------------- cut here -----------------------------------
X           Ed Carp	N7EKG/5 (28.3-28.5)	erc@puzzle!khijol
X           Austin,  Tx; (home) (512) 445-2044
X           Snail Mail:  1800 E. Stassney  #1205
X                        Austin, Tx  78744
END_OF_uustatus/README
if test 6364 -ne `wc -c <uustatus/README`; then
    echo shar: \"uustatus/README\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus/basename.fun -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus/basename.fun\"
else
echo shar: Extracting \"uustatus/basename.fun\" \(530 characters\)
sed "s/^X//" >uustatus/basename.fun <<'END_OF_uustatus/basename.fun'
X/*
X*
X* basename - returns base name of whatever's pass to it
X*            strips off directory info
X*            not for MSDOS
X*
X* Written by Edwin R. Carp
X*
X* Copyright...oh, why bother?
X*
X*/
X
Xchar *basename(string)
Xchar *string;
X{
X   /* strips off directory information from string */
X   char *strrchr();
X   static char outstr[256];
X   char *target, *start;
X
X   start = strrchr(string, '/'); /* find last slash */
X   if(start == NULL) return(string);
X   start++; /* bump past / */
X   strcpy(outstr, start);
X   return(outstr);
X}
END_OF_uustatus/basename.fun
if test 530 -ne `wc -c <uustatus/basename.fun`; then
    echo shar: \"uustatus/basename.fun\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus/dirent.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus/dirent.h\"
else
echo shar: Extracting \"uustatus/dirent.h\" \(559 characters\)
sed "s/^X//" >uustatus/dirent.h <<'END_OF_uustatus/dirent.h'
X/*
X*
X* /usr/include/dirent.h for SYS V (AT&T)
X*
X* Copyright 1989 by Edwin R. Carp
X*
X* kludgy, but it works...
X*
X*/
X
X#define DIR FILE
X#define dirent direct
X#include <sys/dir.h>
Xstatic struct direct wdp;
X
XDIR *opendir(name)
Xchar *name;
X{
X   return(fopen(name, "r"));
X}
X
Xstruct direct *readdir(dp)
XDIR *dp;
X{
Xint ret;
X
X   while(1)
X   {
X      ret=fread(&wdp, 1, sizeof(struct direct), dp);
X      if(ret < sizeof(struct dirent)) return((struct direct *)NULL);
X      if(wdp.d_ino == 0) continue;
X      return(&wdp);
X   }
X}
X
Xclosedir(dp)
XDIR *dp;
X{
X   fclose(dp);
X}
END_OF_uustatus/dirent.h
if test 559 -ne `wc -c <uustatus/dirent.h`; then
    echo shar: \"uustatus/dirent.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus/findpath.1 -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus/findpath.1\"
else
echo shar: Extracting \"uustatus/findpath.1\" \(804 characters\)
sed "s/^X//" >uustatus/findpath.1 <<'END_OF_uustatus/findpath.1'
X.TH FINDPATH 1
X.SH NAME
Xfindpath \- find file in path
Xpath \- display path directories
X.SH SYNOPSIS
X/usr/local/bin/findpath
X.I file
X.SH DESCRIPTION
X.I Findpath
Xwill report on the location of
X.I file,
Xsearching every directory in the path (as defined in the
X$PATH variable), much like the operating system does when searching
X$PATH to execute a program.  It is handy for finding out where in your path
Xa command resides.
X.PP
X.I Findpath
Xaccepts metacharacters (which must be escaped to prevent interpretation by
Xthe shell) according to the rules listed in
X.I regcmp(3).
X.PP
X.I Findpath
Xis linked to
X.I path,
Xwhich simply displays a list of directories to be searched.  It is much
Xfaster than 'echo $PATH|tr ":" " "'.
X.SH SEE ALSO
Xcsh(1), ed(1), regcmp(3).
X.SH CREDITS
XThis utility was written by Ed Carp.
END_OF_uustatus/findpath.1
if test 804 -ne `wc -c <uustatus/findpath.1`; then
    echo shar: \"uustatus/findpath.1\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus/findpath.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus/findpath.c\"
else
echo shar: Extracting \"uustatus/findpath.c\" \(2490 characters\)
sed "s/^X//" >uustatus/findpath.c <<'END_OF_uustatus/findpath.c'
Xstatic char *sccsid = "%Z% %M% %I%    %G% %U%";
X/*
X*
X* findpath - find a command in a path
X*     path - list directories searched in path
X*
X* usage: findpath command(s)
X*            path
X*
X* Written by Ed Carp
X*
X*/
X#include <stdio.h>
X#ifndef BSD
X#include <string.h>
X#else
X#include <strings.h>
X#endif
X#include <sys/types.h>
X#ifdef hpux || M_XENIX
X#include <sys/ndir.h>
X#define dirent direct
X#else
X#include <dirent.h>
X#endif
X#include "basename.fun"
X#include "strrep.fun"
X
X#define CHARS "*[].^$-+{}()"
X
Xchar *getenv(), *regcmp(), *regex();
X
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X{
X   DIR *d;
X   struct dirent *dire;
X   char *dir, *ptr, *ptr2, path[512], home[64], scr[512];
X   char *re;
X   int i=1, vflag=0, pflag=0, rflag=0;
X
X   if(strcmp("path", basename(argv[0])) == 0)
X   {
X      pflag = 1;
X      vflag = 1;
X   }
X   if(argc < 2 && pflag == 0)
X   {
X      fprintf(stderr, "usage: findpath command(s)...\n");
X      exit(1);
X   }
X   if((dir=getenv("path")) == (char *)NULL)
X   {
X      if((dir=getenv("PATH")) == (char *)NULL)
X      {
X         fprintf(stderr, "PATH not set!\n");
X         exit(1);
X      }
X   }
X   /* expand ~ in path to $HOME */
X   strcpy(home, getenv("HOME"));
X   if(home != (char *)EOF)
X   {
X      while((ptr=strrep("~", home, dir)) != (char *)EOF)
X      {
X         strcpy(dir, ptr);
X      }
X   }
X   strcpy(path, dir); /* save it away */
X   ptr = path;
X   if(strpbrk(argv[i], CHARS) != (char *)NULL) rflag = 1;
X   /* printf("DEBUG: rflag = %d\n", rflag); */
X   /* printf("DEBUG: argv[i] = %s\n", argv[i]); */
X   strcpy(scr, "^");
X   strcat(scr, argv[i]);
X   /* printf("DEBUG: scr = %s\n", scr); */
X   if(rflag)
X   {
X      if((char *)NULL == (re = regcmp(scr, 0)))
X      {
X         puts("regcmp: Incorrect argument!");
X         exit(1);
X      }
X   }
X   while((dir=strtok(ptr, ":")) != (char *)NULL)
X   {
X      ptr = NULL;
X      if(!pflag)
X      {
X         if((d=opendir(dir)) == (DIR *)NULL)
X         {
X            perror(dir);
X            continue;
X         }
X      }
X      if(vflag) printf("%s\n", dir);
X      if(!pflag)
X      {
X         while((dire=readdir(d)) != (struct dirent *)NULL)
X         {
X            if(rflag)
X            {
X               if((ptr2=regex(re, dire->d_name)) != (char *)NULL)
X                  printf("%s/%s\n", dir, dire->d_name);
X            }
X            else
X               if(strcmp(dire->d_name, argv[i]) == 0)
X                  printf("%s/%s\n", dir, dire->d_name);
X         }
X      }
X      closedir(d);
X   }
X   if(rflag)
X      free(re);
X}
END_OF_uustatus/findpath.c
if test 2490 -ne `wc -c <uustatus/findpath.c`; then
    echo shar: \"uustatus/findpath.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus/findpath.doc -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus/findpath.doc\"
else
echo shar: Extracting \"uustatus/findpath.doc\" \(914 characters\)
sed "s/^X//" >uustatus/findpath.doc <<'END_OF_uustatus/findpath.doc'
X
X
X
X     FINDPATH(1)                                           FINDPATH(1)
X
X
X
X     NAME
X          findpath - find file in path path - display path directories
X
X     SYNOPSIS
X          /usr/local/bin/findpath file
X
X     DESCRIPTION
X          Findpath will report on the location of file, searching
X          every directory in the path (as defined in the $PATH
X          variable), much like the operating system does when
X          searching $PATH to execute a program.  It is handy for
X          finding out where in your path a command resides.
X
X          Findpath is linked to path, which simply displays a list of
X          directories to be searched.  It is much faster than 'echo
X          $PATH|tr ":" " "'.
X
X     SEE ALSO
X          csh(1)
X
X     CREDITS
X          This utility was written by Ed Carp.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X     Page 1                                          (printed 1/20/89)
X
X
X
END_OF_uustatus/findpath.doc
if test 914 -ne `wc -c <uustatus/findpath.doc`; then
    echo shar: \"uustatus/findpath.doc\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus/findpath.prt -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus/findpath.prt\"
else
echo shar: Extracting \"uustatus/findpath.prt\" \(970 characters\)
sed "s/^X//" >uustatus/findpath.prt <<'END_OF_uustatus/findpath.prt'
X
X
X
X     FINDPATH(1)                                           FINDPATH(1)
X
X
X
X     NAME
X          findpath - find file in path path - display path directories
X
X     SYNOPSIS
X          /usr/local/bin/findpath _f_i_l_e
X
X     DESCRIPTION
X          _F_i_n_d_p_a_t_h will report on the location of _f_i_l_e, searching
X          every directory in the path (as defined in the $PATH
X          variable), much like the operating system does when
X          searching $PATH to execute a program.  It is handy for
X          finding out where in your path a command resides.
X
X          _F_i_n_d_p_a_t_h is linked to _p_a_t_h, which simply displays a list of
X          directories to be searched.  It is much faster than 'echo
X          $PATH|tr ":" " "'.
X
X     SEE ALSO
X          csh(1)
X
X     CREDITS
X          This utility was written by Ed Carp.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X     Page 1                                          (printed 1/20/89)
X
X
X
END_OF_uustatus/findpath.prt
echo shar: 28 control characters may be missing from \"uustatus/findpath.prt\"
if test 970 -ne `wc -c <uustatus/findpath.prt`; then
    echo shar: \"uustatus/findpath.prt\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus/makedocs -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus/makedocs\"
else
echo shar: Extracting \"uustatus/makedocs\" \(225 characters\)
sed "s/^X//" >uustatus/makedocs <<'END_OF_uustatus/makedocs'
Xecho Setting up...
Xcc -s -o unback unback.c -O
Xecho Generating uustatus.prt...
Xnroff -man uustatus.1 > uustatus.prt
Xecho Generating uustatus.doc...
Xnroff -man uustatus.1|./unback>uustatus.doc
Xecho Cleaning up...
Xrm -f unback
END_OF_uustatus/makedocs
if test 225 -ne `wc -c <uustatus/makedocs`; then
    echo shar: \"uustatus/makedocs\" unpacked with wrong size!
fi
chmod +x uustatus/makedocs
# end of overwriting check
fi
if test -f uustatus/strrep.fun -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus/strrep.fun\"
else
echo shar: Extracting \"uustatus/strrep.fun\" \(1119 characters\)
sed "s/^X//" >uustatus/strrep.fun <<'END_OF_uustatus/strrep.fun'
X/*
X*
X* strrep - replace first occurrence of A with B in string C
X* strrepn - replace nth occurrence of A with B in string C
X*
X* Written by Edwin R. Carp
X*
X* Copyright..oh, who cares!
X*
X*/
X
X#ifndef NULL
X#include <stdio.h>
X#endif
X
Xchar *strrep(a, b, c) /* replace first a with b in string c */
Xchar *a, *b, *c;
X{
X   char *pd;
X   static char d[512]; /* yes, yes, could be fancier, I know! */
X
X   *d = NULL;
X   pd = d;
X   while(*c)
X   {
X      if(strncmp(a, c, strlen(a)) == 0) break;
X      *pd++ = *c++;
X   }
X   if(!*c) return((char *)EOF); /* a not found in c */
X   *pd = NULL;
X   strcat(d, b);
X   strcat(d, c+strlen(a));
X   return(d);
X}
X
Xchar *strrepn(a, b, c, n) /* replace nth a with b in string c */
Xchar *a, *b, *c;
Xint n;
X{
X   char *pd;
X   static char d[512]; /* yes, yes, could be fancier, I know! */
X   int i=0;
X
X   if(n < 1) return((char *)EOF);
X   *d = NULL;
X   pd = d;
X   while(*c)
X   {
X      if(strncmp(a, c, strlen(a)) == 0) i++;
X      if(i == n) break;
X      *pd++ = *c++;
X   }
X   if(!*c) return((char *)EOF); /* a not found in c */
X   *pd = NULL;
X   strcat(d, b);
X   strcat(d, c+strlen(a));
X   return(d);
X}
END_OF_uustatus/strrep.fun
if test 1119 -ne `wc -c <uustatus/strrep.fun`; then
    echo shar: \"uustatus/strrep.fun\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus/touch.fun -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus/touch.fun\"
else
echo shar: Extracting \"uustatus/touch.fun\" \(380 characters\)
sed "s/^X//" >uustatus/touch.fun <<'END_OF_uustatus/touch.fun'
X/*
X*
X* touch - (can't you tell?)
X*
X* Written by Edwin R. Carp
X*
X* Copyright...(this is getting old!)
X*
X*/
X
Xint touch(file)
Xchar *file;
X{
X   time_t timea[2];
X   FILE *f;
X
X   if(access(file, 0) == EOF)
X   {
X      if((f=fopen(file, "w")) == (FILE *)NULL) return(EOF);
X      fclose(f);
X      return(NULL);
X   }
X   time(&timea[0]);
X   time(&timea[1]);
X   return(utime(file, timea));
X}
END_OF_uustatus/touch.fun
if test 380 -ne `wc -c <uustatus/touch.fun`; then
    echo shar: \"uustatus/touch.fun\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus/unback.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus/unback.c\"
else
echo shar: Extracting \"uustatus/unback.c\" \(711 characters\)
sed "s/^X//" >uustatus/unback.c <<'END_OF_uustatus/unback.c'
Xstatic char *sccsid = "%Z% %M% %I%    %G% %U%";
X/*
X*
X* unback <input >output
X*
X* unback will make the output of nroff readable from a file
X*
X* written 05/14/87 by Ed Carp
X*
X*/
X#define BACKSPACE 8
X#define EOF (-1)
Xmain()
X{
X   char in[3], c;
X   int i;
X
X   in[0] = in[1] = in[2] = '\0';
X   while((c=getchar()) != EOF)
X   {
X      if(in[0] != '\0') putchar(in[0]);
X      in[0] = in[1];
X      in[1] = in[2];
X      in[2] = c;
X      if(in[0] == '_' && in[1] == BACKSPACE)
X      {
X         in[0] = in[1] = '\0';
X         continue;
X      }
X      if(in[0] != '_' && in[1] == BACKSPACE)
X      {
X         in[1] = in[2] = '\0';
X         continue;
X      }
X   }
X   for(i=0; i<3; i++)
X      if(in[i] != '\0') putchar(in[i]);
X}
X
END_OF_uustatus/unback.c
if test 711 -ne `wc -c <uustatus/unback.c`; then
    echo shar: \"uustatus/unback.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus/uustatus.1 -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus/uustatus.1\"
else
echo shar: Extracting \"uustatus/uustatus.1\" \(591 characters\)
sed "s/^X//" >uustatus/uustatus.1 <<'END_OF_uustatus/uustatus.1'
X.TH UUSTATUS 1L "January 25, 1989" "Version 1.1"
X.ad b
X.SH NAME
Xuustatus \- check UUCP status on HDB systems
X.SH SYNOPSIS
Xuustatus
X.SH DESCRIPTION
X.I Uustatus
Xwill dynamically display the status of ongoing and failed UUCP connections.
XIt is intended to be used with the HDB (HoneyDanBer) UUCP system.
X.SH PORTING
XThis utility was written for System V; however it should run "as is" on
XBSD systems.
X.SH NOTES
XAs distributed, this utility will not display statistics concerning
Xfailed UUCP connections due to "WRONG TIME TO CALL" errors.
X.SH CREDITS
XThis utility was written by Edwin R. Carp.
END_OF_uustatus/uustatus.1
if test 591 -ne `wc -c <uustatus/uustatus.1`; then
    echo shar: \"uustatus/uustatus.1\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus/uustatus.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus/uustatus.c\"
else
echo shar: Extracting \"uustatus/uustatus.c\" \(11353 characters\)
sed "s/^X//" >uustatus/uustatus.c <<'END_OF_uustatus/uustatus.c'
X/*
X*
X* uustatus - display UUCP communications status for HDB systems
X*
X* usage: uustatus [-o] [-b] [-u]
X*
X* Written 01/19/89 by Ed Carp
X*
X* Copyright 1989, by Edwin R. Carp
X*
X* Version     Date     Status       Comments
X*
X*  1.0.c    01/21/89   INTERNAL     IO display, number of IO msgs, uucico log
X*                                   file display, <sys/types.h> include.
X*
X*  1.0.d    01/24/89   PREREL       tails first system talking instead of
X*                                   last, displays star on system tailed,
X*                                   improved method of tailing log files,
X*                                   create status files if they don't exist.
X*                                   now should be owned by uucp or nuucp.
X*
X*  1.1      01/25/89   RELEASE      Released version to USENET.
X*
X*  1.1.a    01/26/89   PREREL       Fixed XENIX defines.
X*
X*  1.1.b    01/28/89   PREREL       Display time/date.
X*
X*  1.1.c    02/03/87   PREREL       Added -b, -o options.
X*
X*  1.1.d    03/02/89   PREREL       Took out 2 second wait before init.
X*
X*  1.1.e    03/08/89   PREREL       -u option kicks off uucico for sites that
X*                                   have files.
X*
X*  1.1.f    12/04/89   REPOST       Fixes case where program dumps core if
X*                                   log file goes away while program is running.
X*
X*/
X
Xchar *sccsid = "uustatus, version 1.1.f  12/04/89  Copyright 1989 by Edwin R. Carp";
X#include <stdio.h>
X#include <sys/types.h>
X#include <curses.h>
X#ifdef hpux || M_XENIX
X#include <sys/ndir.h>
X#define dirent direct
X#else
X#include <dirent.h>
X#endif
X#include <time.h>
X#include <signal.h>
X#define YES 1
X#define NO 0
X#include "uustatus.h"
X#include "basename.fun"
X#include "touch.fun"
X
XDIR *din, *win;
Xstruct dirent *dp, *dpw;
XFILE *in, *exp;
XFILE *tin;
Xchar ltname[64];
Xchar tline[24][80];
Xextern char *optarg;
Xextern int optind, opterr;
Xint bflag=0, oflag=0;
X
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X{
X   char line[512], lock[64], cretries[6], *lptr;
X   char cfiles[6], work[64], name[25], tname[64], c;
X   int i, status, ifiles, ofiles, files, retries, bye();
X   int systems, expflag, display, ret, tnameset=0;
X   int uflag=0;
X   long secs, retryt, curr;
X   struct tm *t1, *t2;
X
X   while((c=getopt(argc, argv, "bou")) != (char)EOF)
X   {
X      switch(c)
X      {
X      case 'b': /* beep on conversation */
X         bflag = 1;
X         break;
X      case 'o': /* oneshot - no curses */
X         oflag = 1;
X         break;
X      case 'u': /* start uucico for each site that has files */
X         uflag = 1;
X         oflag = 1;
X         break;
X      }
X   }
X   if(!uflag) fprintf(stderr, "%s\n", sccsid);
X   chdir(STATUS);
X   for(i=1; i<4; i++)
X      signal(i, bye);
X   if(LOGON) exp = fopen(LOGFILE, "w");
X   *ltname = NULL;
X   /* create status files if they don't exist */
X   if((in=fopen(SYSTEMS, "r")) == (FILE *)NULL)
X      perror(SYSTEMS);
X   else
X   {
X      while(fgets(line, 510, in) != (char *)NULL)
X      {
X         lptr = line;
X         while(*lptr == ' ' || *lptr == TABCHAR) lptr++;
X         if(*lptr == '#') continue;
X         while(*lptr != ' ' && *lptr != TABCHAR && *lptr != NULL) lptr++;
X         *lptr = NULL;
X         ofiles = ifiles = files = 0;
X         sprintf(work, WORKFILE, line);
X         if((win=opendir(work)) != (DIR *)NULL)
X         {
X            /* count the number of C., TM., and X. files */
X            while((dp=readdir(win)) != (struct dirent *)NULL)
X            {
X               if(strncmp(dp->d_name, "C.", 2) == 0) ofiles++;
X               if(strncmp(dp->d_name, "X.", 2) == 0) ifiles++;
X               if(strncmp(dp->d_name, "TM.", 3) == 0) ifiles++;
X               if(ifiles+ofiles > FLIMIT) break;
X            }
X            closedir(win);
X         }
X         if(access(line, 0) != 0 && (ifiles > 0 || ofiles > 0))
X         {
X            if((tin=fopen(line, "w")) == (FILE *)NULL)
X            {
X               perror(line);
X               continue;
X            }
X            fprintf(tin, "24 0 %ld 0 %s", time(0L), errortext[24]);
X            fclose(tin);
X            chmod(line, 0666);
X            chown(line, UUCPOWN, UUCPGRP);
X         }
X         if(uflag && ofiles > 0)
X         {
X            sprintf(work, "/usr/lib/uucp/uucico -r1 -s%s", line);
X            system(work);
X         }
X      }
X      fclose(in);
X   }
X   if(uflag) exit(0);
X   fflush(stdout);
X   if(oflag == 0)
X      initscr();
X   while(1)
X   {
X      if(oflag == 0) move(0, 0);
X      if((din=opendir(".")) == (DIR *)NULL)
X      {
X         perror(STATUS);
X         exit(1);
X      }
X      if(oflag == 0)
X         printw("SYSTEM       RETRY IO FIL   LAST TRY     NEXT TRY    STATUS    ");
X      else
X         printf("SYSTEM       RETRY IO FIL   LAST TRY     NEXT TRY    STATUS    ");
X      time(&curr);
X      t1 = localtime(&curr);
X      if(oflag == 0)
X         printw("%02d/%02d %02d:%02d  ",
X             t1->tm_mon+1, t1->tm_mday, t1->tm_hour, t1->tm_min);
X      else
X         printf("%02d/%02d %02d:%02d\n\n",
X             t1->tm_mon+1, t1->tm_mday, t1->tm_hour, t1->tm_min);
X      if(LOGON) fprintf(exp, "%s", ctime(&curr));
X      display = systems = 0;
X      if(oflag == 0)
X      {
X         move(0, COLS-(1+strlen(WAITMSG)));
X         standout();
X         addstr(WAITMSG);
X         standend();
X         move(1, 0);
X         refresh();
X         clrtobot();
X      }
X      *tname = NULL;
X      while((dp=readdir(din)) != (struct dirent *)NULL)
X      {
X         if(display > LLIMIT && oflag == 0) break;
X         if(*dp->d_name == '.') continue;
X         systems++;
X         if((in=fopen(dp->d_name, "r")) == (FILE *)NULL) continue;
X         fgets(line, 510, in);
X         fclose(in);
X         line[strlen(line)-1] = NULL;
X         sscanf(line, "%d %d %ld %ld", &status, &retries, &secs, &retryt);
X         expflag = 0;
X         strcpy(name, dp->d_name);
X         if((curr - secs) > ((long)EXPDAYS*(long)24*(long)60*(long)60))
X         {
X            if(LOGON) fprintf(exp, "%s EXPIRED! (%ld - %ld) > %ld\n",
X                name, curr, secs,
X                ((long)EXPDAYS*(long)24*(long)60*(long)60));
X            expflag = 1;
X         }
X         sprintf(lock, LOCKFILE, name);
X         sprintf(work, WORKFILE, name);
X         ofiles = ifiles = files = 0;
X         if((win=opendir(work)) != (DIR *)NULL)
X         {
X            /* count the number of C., TM., and X. files */
X            while((dp=readdir(win)) != (struct dirent *)NULL)
X            {
X               if(strncmp(dp->d_name, "C.", 2) == 0) ofiles++;
X               if(strncmp(dp->d_name, "X.", 2) == 0) ifiles++;
X               if(strncmp(dp->d_name, "TM.", 3) == 0) ifiles++;
X               if(ifiles+ofiles > FLIMIT) break;
X            }
X            closedir(win);
X         }
X         files = ifiles + ofiles;
X         if(files != 0) sprintf(cfiles, "%d", files);
X         else strcpy(cfiles, "   ");
X         if(files > FLIMIT) sprintf(cfiles, "%d+", FLIMIT);
X         if(retries != 0) sprintf(cretries, "%d", retries);
X         else strcpy(cretries, "   ");
X         /* kludges for screwy status stuff with HDB */
X         if(access(lock, 0) == 0 && status != 3) status = 22;
X         if(status == 11) status = 13; /* fix bug */
X         /* skip WRONG TIME TO CALL  and STATUS UNKNOWN messages */
X#ifndef WTTC
X         if((status == 23 || status == 2) && files == 0)
X            continue;
X#endif
X         t1 = localtime(&secs);
X         retryt += secs;
X         t2 = localtime(&retryt);
X         move(display+2, 0);
X         if(expflag == 0)
X         {
X            if(oflag == 0)
X               printw("%-14s  %-3s%c%c %-3s ",
X                   name, cretries, ifiles==0?' ':'I', ofiles==0?' ':'O', cfiles);
X            else
X               printf("%-14s  %-3s%c%c %-3s ",
X                   name, cretries, ifiles==0?' ':'I', ofiles==0?' ':'O', cfiles);
X         }
X         else if(LOGON) fprintf(exp, "%-14s  %-3d ", name, retries);
X         t1 = localtime(&secs);
X         if(expflag == 0)
X         {
X            if(oflag == 0)
X               printw("%02d/%02d %02d:%02d  ",
X                   t1->tm_mon+1, t1->tm_mday, t1->tm_hour, t1->tm_min);
X            else
X               printf("%02d/%02d %02d:%02d  ",
X                   t1->tm_mon+1, t1->tm_mday, t1->tm_hour, t1->tm_min);
X         }
X         else if(LOGON) fprintf(exp, "%02d/%02d %02d:%02d  ",
X             t1->tm_mon+1, t1->tm_mday, t1->tm_hour, t1->tm_min);
X         t2 = localtime(&retryt);
X         if(expflag == 0)
X         {
X            if(oflag == 0)
X               printw("%02d/%02d %02d:%02d ",
X                   t2->tm_mon+1, t2->tm_mday, t2->tm_hour, t2->tm_min);
X            else
X               printf("%02d/%02d %02d:%02d ",
X                   t2->tm_mon+1, t2->tm_mday, t2->tm_hour, t2->tm_min);
X         }
X         else if(LOGON) fprintf(exp, "%02d/%02d %02d:%02d  ",
X             t2->tm_mon+1, t2->tm_mday, t2->tm_hour, t2->tm_min);
X         if(status == 3 || status == 22)
X         {
X            if(tnameset == 0)
X            {
X               sprintf(tname, UUCICO, name);
X               tnameset = 1;
X               if(oflag == 0) printw("* ");
X               else printf("* ");
X            }
X            else
X            {
X               if(oflag == 0) printw("  ");
X               else printf("  ");
X            }
X            if(oflag == 0) standout();
X         }
X         else
X         {
X            if(oflag == 0) printw("  ");
X            else printf("  ");
X         }
X         if(expflag == 0)
X         {
X            if(oflag == 0) printw("%s\n", errortext[status]);
X            else printf("%s\n", errortext[status]);
X         }
X         else if(LOGON) fprintf(exp, "%s\n", errortext[status]);
X         if((status == 3 || status == 22) && oflag == 0) standend();
X         display++;
X      }
X      tnameset = 0;
X      if(oflag == 1) break; /* once only */
X      printw("\n%d UUCP connections active", systems);
X      ret = tailfile(tname, display+5, LINES);
X      move(0, COLS-(1+strlen(BWAITMSG)));
X      addstr(BWAITMSG);
X      move(1, 0);
X      refresh();
X      closedir(din);
X      if(ret == NULL)
X         sleep(1);
X      else
X         sleep(SLEEPTIME);
X   }
X}
Xbye(sig)
Xint sig;
X{
X   if(LOGON) fclose(exp);
X   endwin();
X   exit(0);
X}
X
Xtailfile(s, from, to) /* returns NULL if done, EOF if error */
Xchar *s;
Xint from, to;
X{
X   char wrk[512];
X   int i;
X
X   move(from, 0);
X   clrtobot();
X   if(*s == NULL) return(EOF);
X   if(access(s, 0) == EOF) return(EOF);
X   if(strcmp(s, ltname) != 0)
X   {
X      fclose(tin);
X      strcpy(ltname, s);
X      if((tin=fopen(s, "r")) == (FILE *)NULL) return(EOF);
X      /* display the last (to-from) lines of file s */
X      /* must be limited to COLS */
X      for(i=0; i<(to-from)-1; i++) *tline[i] = NULL;
X   }
X   while(fgets(wrk, 510, tin) != (char *)NULL)
X   {
X      if( '\n' != wrk[strlen(wrk)-1])
X      {
X         sleep(1);
X         fseek(tin, (long)strlen(wrk), 1);
X         continue;
X      }
X      wrk[strlen(wrk)-1] = NULL;
X      for(i=0; i<(to-from)-1; i++) strcpy(tline[i], tline[i+1]);
X      strcpy(tline[(to-from)-1],
X          strlen(wrk)>COLS-1?wrk+(strlen(wrk)-(COLS-1)):wrk);
X   }
X   move(from-1, 20);
X   standout();
X   addstr(s);
X   if(bflag) printf("\7");
X   standend();
X   move(from, 0);
X   for(i=0; i<to-from; i++)
X   {
X      if(strlen(tline[i]) > COLS-1)
X         printw("%s\n", tline[i] + (strlen(tline[i]) - (COLS-1)));
X      else printw("%s\n", tline[i]);
X   }
X   return(NULL);
X}
END_OF_uustatus/uustatus.c
if test 11353 -ne `wc -c <uustatus/uustatus.c`; then
    echo shar: \"uustatus/uustatus.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus/uustatus.doc -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus/uustatus.doc\"
else
echo shar: Extracting \"uustatus/uustatus.doc\" \(847 characters\)
sed "s/^X//" >uustatus/uustatus.doc <<'END_OF_uustatus/uustatus.doc'
X
X
X
X     UUSTATUS(1L)               Version 1.1               UUSTATUS(1L)
X
X
X
X     NAME
X          uustatus - check UUCP status on HDB systems
X
X     SYNOPSIS
X          uustatus
X
X     DESCRIPTION
X          Uustatus will dynamically display the status of ongoing  and
X          failed UUCP connections.  It is intended to be used with the
X          HDB (HoneyDanBer) UUCP system.
X
X     PORTING
X          This utility was written for System V; however it should run
X          "as is" on BSD systems.
X
X     NOTES
X          As distributed, this utility  will  not  display  statistics
X          concerning  failed  UUCP  connections  due to "WRONG TIME TO
X          CALL" errors.
X
X     CREDITS
X          This utility was written by Edwin R. Carp.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X     Page 1                 (January 25, 1989)       (printed 1/25/89)
X
X
X
END_OF_uustatus/uustatus.doc
if test 847 -ne `wc -c <uustatus/uustatus.doc`; then
    echo shar: \"uustatus/uustatus.doc\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus/uustatus.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus/uustatus.h\"
else
echo shar: Extracting \"uustatus/uustatus.h\" \(1600 characters\)
sed "s/^X//" >uustatus/uustatus.h <<'END_OF_uustatus/uustatus.h'
X/*
X*
X* tuneable parameters
X*
X*/
X
X/* #define WTTC */
X#define STATUS "/usr/spool/uucp/.Status"
X#define SYSTEMS "/usr/lib/uucp/Systems"
X#define UUCICO "/usr/spool/uucp/.Log/uucico/%s"
X#define LOCKFILE "/usr/spool/uucp/LCK..%s"
X#define WORKFILE "/usr/spool/uucp/%s"
X#define EXPDAYS 999 /* connections older than X days will not be displayed */
X#define LOGON NO /* log expired systems? */
X#define LOGFILE "/tmp/uuexp.log"
X#define WAITMSG "WAIT"
X#define BWAITMSG "    " /* blank wait msg string */
X#define LLIMIT LINES-5
X#define FLIMIT 999 /* over this many files for site, we quit; should be < 100 */
X#define SLEEPTIME 5 /* time to sleep between samples */
X#define UUCPOWN "uucp" /* uucp owner */
X#define UUCPGRP "uucp" /* uucp group */
X#define TABCHAR '	' /* should be a TAB */
X
X/*
X*
X* end of tuneable parameters
X*
X*/
X
Xchar *errortext[] =
X{
X   "SUCCESSFUL",
X   "NO DEVICES AVAILABLE",
X   "WRONG TIME TO CALL",
X   "TALKING",
X   "CONVERSATION FAILED",
X   "BAD SEQUENCE CHECK",
X   "LOGIN FAILED",
X   "DIAL FAILED",
X   "BAD LOGIN/MACHINE COMBINATION",
X   "DEVICE LOCKED",
X   "ASSERT ERROR",
X   "SYSTEM NOT IN Systems FILE",
X   "CAN'T ACCESS DEVICE",
X   "DEVICE FAILED",
X   "WRONG MACHINE NAME",
X   "CALLBACK REQUIRED",
X   "REMOTE HAS A LCK FILE FOR ME",
X   "REMOTE DOES NOT KNOW ME",
X   "REMOTE REJECT AFTER LOGIN",
X   "REMOTE REJECT, UNKNOWN MESSAGE",
X   "STARTUP FAILED",
X   "BUSY OR NO ANSWER",
X/* #ifdef M_XENIX */
X   /* "EXECDIAL LOCAL FAILURE", */
X   /* "EXECDIAL REMOTE FAILURE", */
X   /* "STATUS UNKNOWN", */
X/* #else */
X   "CALL IN PROGRESS",
X   "", /* dummy */
X   "STATUS UNKNOWN",
X/* #endif */
X};
END_OF_uustatus/uustatus.h
if test 1600 -ne `wc -c <uustatus/uustatus.h`; then
    echo shar: \"uustatus/uustatus.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus/uustatus.prt -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus/uustatus.prt\"
else
echo shar: Extracting \"uustatus/uustatus.prt\" \(863 characters\)
sed "s/^X//" >uustatus/uustatus.prt <<'END_OF_uustatus/uustatus.prt'
X
X
X
X     UUSTATUS(1L)               Version 1.1               UUSTATUS(1L)
X
X
X
X     NAME
X          uustatus - check UUCP status on HDB systems
X
X     SYNOPSIS
X          uustatus
X
X     DESCRIPTION
X          _U_u_s_t_a_t_u_s will dynamically display the status of ongoing  and
X          failed UUCP connections.  It is intended to be used with the
X          HDB (HoneyDanBer) UUCP system.
X
X     PORTING
X          This utility was written for System V; however it should run
X          "as is" on BSD systems.
X
X     NOTES
X          As distributed, this utility  will  not  display  statistics
X          concerning  failed  UUCP  connections  due to "WRONG TIME TO
X          CALL" errors.
X
X     CREDITS
X          This utility was written by Edwin R. Carp.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X     Page 1                 (January 25, 1989)       (printed 1/25/89)
X
X
X
END_OF_uustatus/uustatus.prt
echo shar: 8 control characters may be missing from \"uustatus/uustatus.prt\"
if test 863 -ne `wc -c <uustatus/uustatus.prt`; then
    echo shar: \"uustatus/uustatus.prt\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0
----------------------------------- cut here -----------------------------------
           Ed Carp	N7EKG/5 (28.3-28.5)	erc@puzzle!khijol
           Austin,  Tx; (home) (512) 445-2044
           Snail Mail:  1800 E. Stassney  #1205
                        Austin, Tx  78744