uustatus 1.1 - realtime display for HDB UUCP status

Ed Carp erc at unisec.usi.com
Thu Jan 26 12:56:19 AEST 1989


#! /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:  README basename.fun dirent.h findpath.1 findpath.c
#   findpath.doc findpath.prt makedocs strrep.fun touch.fun unback.c
#   uustatus.1 uustatus.c uustatus.doc uustatus.h uustatus.prt
# Wrapped by erc at unisec on Wed Jan 25 21:52:52 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f README -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"README\"
else
echo shar: Extracting \"README\" \(6022 characters\)
sed "s/^X//" >README <<'END_OF_README'
Xuustatus - by Ed Carp
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.
XLooking for a job in Austin has been taking up most of my spare time lately.
X
XDoug Blair
XGordon Moffett
XJohan Vromans
XRobert J. Granvin
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.
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:
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 at unisec
X           UniSecure Systems, Inc.;		OS/2, Just say No!
X           Round Rock,  Tx; (home) (512) 834-2507
X           UUCP:  erc at unisec
X           Snail Mail:  2001A Pipersfield
X                        Austin, Tx  78758
X
X	Be ye therefore kind one to another, tenderhearted, forgiving
X	one another, even as God for Christ's sake hath forgiven you.
X
X				-- Ephesians 4:32
END_OF_README
if test 6022 -ne `wc -c <README`; then
    echo shar: \"README\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f basename.fun -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"basename.fun\"
else
echo shar: Extracting \"basename.fun\" \(530 characters\)
sed "s/^X//" >basename.fun <<'END_OF_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_basename.fun
if test 530 -ne `wc -c <basename.fun`; then
    echo shar: \"basename.fun\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f dirent.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"dirent.h\"
else
echo shar: Extracting \"dirent.h\" \(559 characters\)
sed "s/^X//" >dirent.h <<'END_OF_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_dirent.h
if test 559 -ne `wc -c <dirent.h`; then
    echo shar: \"dirent.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f findpath.1 -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"findpath.1\"
else
echo shar: Extracting \"findpath.1\" \(636 characters\)
sed "s/^X//" >findpath.1 <<'END_OF_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
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)
X.SH CREDITS
XThis utility was written by Ed Carp.
END_OF_findpath.1
if test 636 -ne `wc -c <findpath.1`; then
    echo shar: \"findpath.1\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f findpath.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"findpath.c\"
else
echo shar: Extracting \"findpath.c\" \(1695 characters\)
sed "s/^X//" >findpath.c <<'END_OF_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#include <dirent.h>
X#include "basename.fun"
X#include "strrep.fun"
X
Xchar *getenv();
X
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X{
X   DIR *d;
X   struct dirent *dire;
X   char *dir, *ptr, path[512], home[64];
X   int i=1, vflag=0, pflag=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   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(strcmp(dire->d_name, argv[i]) == 0)
X               printf("%s/%s\n", dir, argv[i]);
X         }
X      }
X      closedir(d);
X   }
X}
END_OF_findpath.c
if test 1695 -ne `wc -c <findpath.c`; then
    echo shar: \"findpath.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f findpath.doc -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"findpath.doc\"
else
echo shar: Extracting \"findpath.doc\" \(914 characters\)
sed "s/^X//" >findpath.doc <<'END_OF_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_findpath.doc
if test 914 -ne `wc -c <findpath.doc`; then
    echo shar: \"findpath.doc\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f findpath.prt -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"findpath.prt\"
else
echo shar: Extracting \"findpath.prt\" \(970 characters\)
sed "s/^X//" >findpath.prt <<'END_OF_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_findpath.prt
echo shar: 28 control characters may be missing from \"findpath.prt\"
if test 970 -ne `wc -c <findpath.prt`; then
    echo shar: \"findpath.prt\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f makedocs -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"makedocs\"
else
echo shar: Extracting \"makedocs\" \(225 characters\)
sed "s/^X//" >makedocs <<'END_OF_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_makedocs
if test 225 -ne `wc -c <makedocs`; then
    echo shar: \"makedocs\" unpacked with wrong size!
fi
chmod +x makedocs
# end of overwriting check
fi
if test -f strrep.fun -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"strrep.fun\"
else
echo shar: Extracting \"strrep.fun\" \(576 characters\)
sed "s/^X//" >strrep.fun <<'END_OF_strrep.fun'
X/*
X*
X* strrep - replace first 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}
END_OF_strrep.fun
if test 576 -ne `wc -c <strrep.fun`; then
    echo shar: \"strrep.fun\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f touch.fun -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"touch.fun\"
else
echo shar: Extracting \"touch.fun\" \(380 characters\)
sed "s/^X//" >touch.fun <<'END_OF_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_touch.fun
if test 380 -ne `wc -c <touch.fun`; then
    echo shar: \"touch.fun\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f unback.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"unback.c\"
else
echo shar: Extracting \"unback.c\" \(711 characters\)
sed "s/^X//" >unback.c <<'END_OF_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_unback.c
if test 711 -ne `wc -c <unback.c`; then
    echo shar: \"unback.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus.1 -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus.1\"
else
echo shar: Extracting \"uustatus.1\" \(591 characters\)
sed "s/^X//" >uustatus.1 <<'END_OF_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.1
if test 591 -ne `wc -c <uustatus.1`; then
    echo shar: \"uustatus.1\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus.c\"
else
echo shar: Extracting \"uustatus.c\" \(8650 characters\)
sed "s/^X//" >uustatus.c <<'END_OF_uustatus.c'
X/*
X*
X* uustatus - display UUCP communications status for HDB systems
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*/
X
Xchar *sccsid = "uustatus, version 1.1  01/25/89  Copyright 1989 by Edwin R. Carp";
X#include <stdio.h>
X#include <sys/types.h>
X#include <curses.h>
X#ifdef hpux || XENIX
X#include <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];
X
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X{
X   char line[128], lock[64], cretries[6], *lptr;
X   char cfiles[6], work[64], name[DIRSIZ+1], tname[64];
X   int i, status, ifiles, ofiles, files, retries, bye();
X   int systems, expflag, display, ret, tnameset=0;
X   long secs, retryt, curr;
X   struct tm *t1, *t2;
X
X   printf("%s\n", sccsid);
X   if(argc > 2)
X   {
X      printf("usage: %s\n", basename(argv[0]));
X      exit(1);
X   }
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, "23 0 %ld 0 %s", time(0L), errortext[23]);
X            fclose(tin);
X            chmod(line, 0666);
X            chown(line, UUCPOWN, UUCPGRP);
X         }
X      }
X      fclose(in);
X   }
X   fflush(stdout);
X   sleep(2);
X   initscr();
X   while(1)
X   {
X      move(0, 0);
X      if((din=opendir(".")) == (DIR *)NULL)
X      {
X         perror(STATUS);
X         exit(1);
X      }
X      printw("SYSTEM       RETRY IO FIL   LAST TRY     NEXT TRY      STATUS");
X      time(&curr);
X      if(LOGON) fprintf(exp, "%s", ctime(&curr));
X      display = systems = 0;
X      move(0, COLS-(1+strlen(WAITMSG)));
X      standout();
X      addstr(WAITMSG);
X      standend();
X      move(1, 0);
X      refresh();
X      clrtobot();
X      *tname = NULL;
X      while((dp=readdir(din)) != (struct dirent *)NULL)
X      {
X         if(display > LLIMIT) 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            printw("%-14s  %-3s%c%c %-3s ",
X                name, cretries, ifiles==0?' ':'I', ofiles==0?' ':'O', cfiles);
X         else if(LOGON) fprintf(exp, "%-14s  %-3d ", name, retries);
X         t1 = localtime(&secs);
X         if(expflag == 0) printw("%02d/%02d %02d:%02d  ",
X             t1->tm_mon+1, t1->tm_mday, t1->tm_hour, t1->tm_min);
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) printw("%02d/%02d %02d:%02d ",
X             t2->tm_mon+1, t2->tm_mday, t2->tm_hour, t2->tm_min);
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               printw("* ");
X            }
X            else printw("  ");
X            standout();
X         }
X         else printw("  ");
X         if(expflag == 0) printw("%s\n", errortext[status]);
X         else if(LOGON) fprintf(exp, "%s\n", errortext[status]);
X         if(status == 3 || status == 22) standend();
X         display++;
X      }
X      tnameset = 0;
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(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   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.c
if test 8650 -ne `wc -c <uustatus.c`; then
    echo shar: \"uustatus.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus.doc -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus.doc\"
else
echo shar: Extracting \"uustatus.doc\" \(847 characters\)
sed "s/^X//" >uustatus.doc <<'END_OF_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.doc
if test 847 -ne `wc -c <uustatus.doc`; then
    echo shar: \"uustatus.doc\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus.h\"
else
echo shar: Extracting \"uustatus.h\" \(1436 characters\)
sed "s/^X//" >uustatus.h <<'END_OF_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 14 /* 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   "CALL IN PROGRESS",
X   "STATUS UNKNOWN",
X};
END_OF_uustatus.h
if test 1436 -ne `wc -c <uustatus.h`; then
    echo shar: \"uustatus.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uustatus.prt -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uustatus.prt\"
else
echo shar: Extracting \"uustatus.prt\" \(863 characters\)
sed "s/^X//" >uustatus.prt <<'END_OF_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.prt
echo shar: 8 control characters may be missing from \"uustatus.prt\"
if test 863 -ne `wc -c <uustatus.prt`; then
    echo shar: \"uustatus.prt\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0



More information about the Alt.sources mailing list