v14i052: Official patch #7 for faces v1.4 (part 1 of 2).

Rich Burridge rburridge at Sun.COM
Fri Aug 17 10:51:14 AEST 1990


Posting-number: Volume 14, Issue 52
Submitted-by: rburridge at Sun.COM (Rich Burridge)
Archive-name: faces-1.4.5/patch02

[Please don't include this part with the posting].

Brandon, could you please post this (and the next message) to 
comp.sources.misc ? I've sent a copy to comp.sources.bugs, but I'd like
the patch to be archived. I apologise for the awful format; I'll do it
the Larry Wall way next time.

Thanks.

------CUT HERE------Start of first message------CUT HERE------

/** IMPORTANT NOTE: This patch and the new file (mush.xface.patch)
 ** comes in two parts. You should save these two parts, strip off the
 ** initial header (down to and including the CUT HERE lines), and
 ** anything below (and including) the CUT HERE line at the end of each
 ** file. cat the two files together, and unpack with sh. Use Larry Wall's
 ** patch program to apply, and recompile and reinstall.
 **
 ** I apologise for this; I didn't realise the patch was going to be so
 ** big.
 **/

This is official patch #7 for faces v1.4; please apply it.
It has also been sent to comp.sources.misc for posting there, and
subsequent archiving.

Faces v1.4 was posted to comp.sources.misc about the end of June 1990,
and was already at patchlevel #5. Patch #6 can be obtained via the mail
archive server, by sending a message to rb-archive-server at Aus.Sun.COM
containing the line:

send faces patch6

Note you might need to include a valid path line in this message, in
order for the mail server to get the patch back to you. Such a line might
be:

path uunet.uu.net!hostname!username

Rich Burridge,          DOMAIN: richb at Aus.Sun.COM
Sun Microsystems.       ACSNET: richb at sunaus.sun.oz
PHONE: +61 2 413 2666   UUCP:   {uunet,mcvax,ukc}!munnari!sunaus.oz!richb
-------------------------------------------------------------------------

Faces v1.4 patch #7 makes the following changes:

       * From Chris Steinbroner <hesh at lll-crg.llnl.gov>
         From Bob Posert <psitech.psitech!bob at uunet.UU.NET>
         Incoming mail is not always stored in /usr/spool/mail/username.
         HP-UX and Dell Unix (Interactive 386/ix) store it in
         /usr/mail/username. Another definition (SPOOLDIR), has been added
         to the Makefile. The README file has also been updated.
 
       * From Hugues Leroy <Hugues.Leroy at irisa.fr>
         From Graham Dumpleton <grahamd at otc.otca.oz.au>
         From Peter Chubb <peterc at softway.oz.au>
         From Robert Adams <adams at trim.intel.com>
         The parsefrom() function was not replacing a '\n' at the end of
         a line with '\0' before preceding.
 
       * From Michael Schmidt <michael at uni-paderborn.de>
         The faces window now accepts two more keyboard characters:
            q - to terminate the faces program.
           ^L - to refresh the faces window.
 
       * From Michael Schmidt <michael at uni-paderborn.de>
         Added support for printer monitoring with the PLP printer
         spooling system. Another definition (PLP) has been added to
         the Makefile. The README file has been updated.
 
       * From Chris Steinbroner <hesh at lll-crg.llnl.gov>
         Diffs included to allow faces to run under HP-UX.
 
       * From Robert Adams <adams at trim.intel.com>
         Changed the SYSV definition to SYSV32 because I work with both
         System V.3.2.2 and System V.4.0 from AT&T and they need different
         defines.
 
       * From Robert Adams <adams at trim.intel.com>
         Added -bg and -fg to the parameter string and modified x11.c
         to set the background and foreground colors. Currently this is
         only available with the X11 graphics driver.
 
       * From Robert Adams <adams at trim.intel.com>
         people.tab now accepts the syntax "aliascomm/alias=comm/name"
         to map a whole name (this is one of the TODO points).
         It still accepts the old syntax. As a side effect, the
         people.tab and machine.tab routines were re-written to be
         better parsers and are now forgiving of white space.
 
       * From Robert Adams <adams at trim.intel.com>
         make_iconname was rewritten to get rid of the cut and paste
         code and now is a gaggle of 'for' loops.
 
       * From Robert Adams <adams at trim.intel.com>
         From Michael Schmidt <michael at uni-paderborn.de>
         The domain name parsing code in make_iconname was not working.
         The problem was that the 'old_style' code 'goto'ed out of the
         middle of the domain breakdown loop thus defeating same.
 
       * From Robert Adams <adams at trim.intel.com>
         The code for building the name for people.tab and machine.tab was
         broken if an alternate directory ("-f") was specified (changes
         in rec.c in read_alias and read_machines).

       * From Robert Adams <adams at trim.intel.com>
         If 'host' does not appear in an RFC822 address, the code would
         assume "LOCAL".  The code has been fixed to assume 'hostname'
         instead (fix to parsefrom.c).

       * From Robert Adams <adams at trim.intel.com>
         There was a strange bug that would cause icons on the end of the
         list (after entries were deleted) to get mangled.  This usually
         showed up as the NOMAIL icon not being shown but garbage being
         shown instead.  The problem was that in 'garbage_collect', there
         was a local variable 'last' that was hidding the global variable
         of the same name and thus the global was not getting updated

       * From Pat Lashley <patl at Sun.COM>
         Added code to use the Domain Name Service to attempt to convert
         unqualified hostnames, or hostnames with partial domains to fully
         qualified domain names. Another definition (DNSLOOKUP) has been
         added to the Makefile. The README file has been updated.

       * From Pat Lashley <patl at Sun.COM>
         When no icon is found for a given user, the unknown icon may be
         displayed either with the user name, or labeled as `unknown'.
         The former case provides the most information, the latter allows
         all unknown users within a given community to be lumped into a
         single image. Another definition (NAMEUNKNOWN) has been added to
         the Makefile. The README file has been updated.

       * From Pat Lashley <patl at Sun.COM>
         Support is now included for multiple face directories. Faces
         will search for the environment variable FACEPATH, and use this
         as a list of colon separated face directories. See the manual
         page for more details.

       * Official support for X-Face lines was not included with patch #2
         to mush v7.1. Dan and Bart suggested that instead, a new file
         (mush.xface.patch) should be included with the faces distribution
         which in an unofficial patch to mush v7.1.2, to allow that X-Face
         support. The README, MANIFEST and FILES files have been updated.

       * From Rod Whitby <rwhitby at austek.oz.au>
         faces v.1.4.6 dumps core when the following message (cut down to the
         smallest case) is in my mail box. This was a case of a valid X-Face:
         being followed by a line starting with the word "X-Face ". Faces now
         searches for "X-Face:" rather than "X-Face". This really needs to be
         tightened up some more.

It introduces the following file:

       * mush.xface.patch  - unofficial patch to apply to Mush v7.1.2 to get
                             X-Face: support.

------CUT HERE------CUT HERE------CUT HERE------CUT HERE------
#! /bin/sh
# this is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh to create the files:
#	mush.xface.patch
#	patch.7
# This archive created: Tue Aug 14 07:22:29 EST 1990
#
#
export PATH; PATH=/bin:$PATH
#
if [ -f mush.xface.patch ]
then
echo shar: will not over-write existing file mush.xface.patch
else
echo shar: extracting 'mush.xface.patch',     3336 characters
cat > mush.xface.patch <<'Funky_Stuff'
*** Mushrc.orig	Mon Aug  6 11:32:57 1990
--- Mushrc	Mon Aug  6 11:33:22 1990
***************
*** 29,35 ****
  set newline
  
  # When reading messages, don't bother looking at lengthy, boring headers.
! ignore message-id received via status
  
  # Since mush has csh-like history, you might find it annoying to type
  # things like "mail host\!host1\!host2\!user" from within the mush shell.
--- 29,35 ----
  set newline
  
  # When reading messages, don't bother looking at lengthy, boring headers.
! ignore message-id received via status X-Face
  
  # Since mush has csh-like history, you might find it annoying to type
  # things like "mail host\!host1\!host2\!user" from within the mush shell.
*** init.c.orig	Mon Aug  6 07:57:54 1990
--- init.c	Mon Aug  6 08:01:10 1990
***************
*** 12,20 ****
--- 12,23 ----
  #include <sys/utsname.h>
  #endif /* SYSV */
  
+ char facebuf[1024];	/* For possible compressed X-Face: image. */
+ 
  void
  init()
  {
+     FILE		*fp;
      char 		*home, *realname, *argv[4];
      extern char		*getlogin();
      char		buf[MAXPATHLEN];
***************
*** 135,140 ****
--- 138,153 ----
  	argv[0] = "hostname";
  	argv[2] = buf;
  	(void) add_option(&set_options, argv);
+     }
+ 
+     (void) sprintf(buf, "%s/.face", home);
+     if (fp = fopen(buf, "r")) {
+ 	facebuf[0] = '\0';
+ 	while (fgets(buf, BUFSIZ, fp) != NULL) {
+ 	    if (facebuf[0] != '\0')
+ 		(void) strcat(facebuf, "\t");
+ 	    (void) strcat(facebuf, buf);
+ 	}
      }
  
      init_bindings();
*** config.h-dist.orig	Mon Aug  6 11:38:03 1990
--- config.h-dist	Mon Aug  6 11:39:53 1990
***************
*** 104,110 ****
  /* #define PICKY_MAILER /**/
  
  /* Headers that will NOT be included when forwarding mail */
! #define IGNORE_ON_FWD	"status"	/* comma or space separated list */
  
  #define	MAXMSGS		1000	/* maximum number of messages we can read */
  #define HDRSIZ BUFSIZ	/* This should not be < BUFSIZ! (but can be >) */
--- 104,110 ----
  /* #define PICKY_MAILER /**/
  
  /* Headers that will NOT be included when forwarding mail */
! #define IGNORE_ON_FWD	"status,X-Face"	/* comma or space separated list */
  
  #define	MAXMSGS		1000	/* maximum number of messages we can read */
  #define HDRSIZ BUFSIZ	/* This should not be < BUFSIZ! (but can be >) */
*** mail.c.orig	Mon Aug  6 07:58:05 1990
--- mail.c	Mon Aug  6 09:02:27 1990
***************
*** 1491,1496 ****
--- 1491,1497 ----
      int i, for_editor = (fp == NULL_FILE);
      int got_date = for_editor, got_from = for_editor;
      struct options *opts;
+     extern char facebuf[];
  
      if (for_editor && hfile) {
  	i = file_to_fp(hfile, files[0], "r");
***************
*** 1654,1659 ****
--- 1655,1661 ----
  		    !lcase_strncmp(p, "bcc:", 4) ||
  		    !lcase_strncmp(p, "fcc:", 4) ||
  		    !lcase_strncmp(p, "x-mailer:", 9) ||
+ 		    !lcase_strncmp(p, "x-face:", 7) ||
  		    !lcase_strncmp(p, "status:", 7))
  		    print_hdr = FALSE;
  		else if (!lcase_strncmp(p, "date:", 5))
***************
*** 1720,1725 ****
--- 1722,1729 ----
  #ifdef PICKY_MAILER
  	}
  #endif /* PICKY_MAILER */
+ 	if (facebuf != NULL)
+ 		(void) fprintf(files[i], "X-Face: %s", facebuf);
  	(void) fprintf(files[i], "X-Mailer: %s\n", check_internal("version"));
  	(void) fprintf(files[i], "%sTo: %s\n",
  	    ison(flags, FORWARD) ? "Resent-" : "", To);
Funky_Stuff
len=`wc -c < mush.xface.patch`
if [ $len !=     3336 ] ; then
echo error: mush.xface.patch was $len bytes long, should have been     3336
fi
fi # end of overwriting check
if [ -f patch.7 ]
then
echo shar: will not over-write existing file patch.7
else
echo shar: extracting 'patch.7',   101860 characters
cat > patch.7 <<'Funky_Stuff'

------- get.c -------
*** /tmp/da09664	Tue Aug 14 07:20:14 1990
--- get.c	Wed Aug  8 17:45:12 1990
***************
*** 15,21 ****
--- 15,25 ----
   */
  
  #include <stdio.h>
+ #ifdef SYSV32 || hpux
+ #include <string.h>
+ #else
  #include <strings.h>
+ #endif /* SYSV32 || hpux */
  #include <pwd.h>
  #include <ctype.h>
  #include "faces.h"
***************
*** 136,143 ****
--- 140,154 ----
  int argc ;
  char *argv[] ;
  {
+   char *faceenv ;
    char next[MAXLINE] ;    /* The next command line parameter. */
+   char *pptr ;
+   int i ;
  
+   faceenv = getenv("FACEPATH") ;
+   if (faceenv) STRCPY(facedirs, faceenv) ;
+   else facedirs[0] = (char) NULL ;
+ 
    INC ;
    while (argc > 0)
      {
***************
*** 159,165 ****
                         break ;
              case 'a' : mtype = MONALL ;    /* Monitor all of the spoolfile. */
                         break ;
!             case 'b' : INC ;               /* Alternate background pattern. */
                         getparam(bgicon, argv, "-b needs background icon") ;
                         break ;
              case 'c' : INC ;               /* Number of columns. */
--- 170,182 ----
                         break ;
              case 'a' : mtype = MONALL ;    /* Monitor all of the spoolfile. */
                         break ;
!             case 'b' : if (argv[0][2] == 'g')
!                          {
!                            INC ;           /* Background color. */
!                            getparam(bgcolor, argv, "-bg specifies background color") ;
!                            break ;
!                          }
!                        INC ;               /* Alternate background pattern. */
                         getparam(bgicon, argv, "-b needs background icon") ;
                         break ;
              case 'c' : INC ;               /* Number of columns. */
***************
*** 177,184 ****
                         INC ;
                         getparam(userprog, argv, "-e needs user program") ;
                         break ;
!             case 'f' : INC ;               /* New directory for face icons. */
!                        getparam(facedir, argv, "-f needs face directory") ;
                         break ;
              case 'g' : INC ;               /* X11 geometry information. */
                         getparam(geometry, argv,
--- 194,207 ----
                         INC ;
                         getparam(userprog, argv, "-e needs user program") ;
                         break ;
!             case 'f' : if (argv[0][2] == 'g')
!                          {
!                            INC ;           /* Background color. */
!                            getparam(fgcolor, argv, "-fg specifies foreground color") ;
!                            break ;
!                          }
!                        INC ;               /* New directory for face icons. */
!                        getparam(facedirs, argv, "-f needs face directory path") ;
                         break ;
              case 'g' : INC ;               /* X11 geometry information. */
                         getparam(geometry, argv,
***************
*** 276,281 ****
--- 299,324 ----
            }
        INC ;
      }
+ 
+ /* Parse the face path from the parameter line... */
+ 
+   for (i = 0, pptr = facedirs; pptr && (i <= MAXPATHS); i++)
+     {
+       if ((*pptr == ':') || (*pptr == (char) NULL))
+         {
+ 
+ /* Null entry in face path means insert compiled-in default. */
+ 
+           facepath[i] = FACEDIR ;
+           if (*(pptr++) == (char) NULL) break ;
+         }
+       else
+         {
+           facepath[i] = pptr ;
+           pptr = index(pptr, ':') ;
+           if (pptr) *(pptr++) = (char) NULL ;
+         }
+     }
  }
  
  
***************
*** 492,498 ****
  usage()      /* Print faces usage message. */
  {
    FPRINTF(stderr, "Usage: %s [-MH] [-P printer] [-Wi] [-Wp x y] ", progname) ;
!   FPRINTF(stderr, "[-WP x y] [-b background] [-d display] [-f facedir] ") ;
    FPRINTF(stderr, "[-g geometry] [-i] [-n] [-p period] [-s spoolfile] [-u] ") ;
    FPRINTF(stderr, "[-t] [-v]\n") ;
  }
--- 535,542 ----
  usage()      /* Print faces usage message. */
  {
    FPRINTF(stderr, "Usage: %s [-MH] [-P printer] [-Wi] [-Wp x y] ", progname) ;
!   FPRINTF(stderr, "[-WP x y] [-b background] [-bg background_color] ") ;
!   FPRINTF(stderr, "[-d display] [-f facepath] [-fg foreground_color] ") ;
    FPRINTF(stderr, "[-g geometry] [-i] [-n] [-p period] [-s spoolfile] [-u] ") ;
    FPRINTF(stderr, "[-t] [-v]\n") ;
  }

------- main.c -------
*** /tmp/da09667	Tue Aug 14 07:20:15 1990
--- main.c	Sat Aug  4 23:35:02 1990
***************
*** 17,31 ****
   */
  
  #include <stdio.h>
! #ifdef SYSV
  #include <string.h>
  #else
  #include <strings.h>
! #endif /*SYSV*/
  #include <sys/types.h>
  #include <sys/stat.h>
  #include <netdb.h>
  
  #ifdef NISLOOKUP
  #include <rpcsvc/ypclnt.h>
  #endif /*NISLOOKUP*/
--- 17,37 ----
   */
  
  #include <stdio.h>
! #ifdef SYSV32 || hpux
  #include <string.h>
  #else
  #include <strings.h>
! #endif /* SYSV32 || hpux */
  #include <sys/types.h>
  #include <sys/stat.h>
  #include <netdb.h>
+ #include <ctype.h>
  
+ #ifdef DNSLOOKUP
+ #include <sys/socket.h>
+ #include <netdb.h>
+ #endif /*DNSLOOKUP*/
+ 
  #ifdef NISLOOKUP
  #include <rpcsvc/ypclnt.h>
  #endif /*NISLOOKUP*/
***************
*** 72,77 ****
--- 78,84 ----
  enum gr_type gtype ;                /* Which graphics system is being used. */
  enum mon_type mtype = MONNEW ;      /* Type of monitoring operation to do. */
  
+ char bgcolor[MAXLINE] ;          /* X11 background color. */
  char bgicon[MAXLINE] ;           /* Alternate background pattern. */
  char community[MAXLINE] ;        /* Community name ("real" host name). */
  char defdir[MAXLINE] ;           /* The default face directory. */
***************
*** 81,87 ****
  char face_host[MAXLINE] ;   /* Pointer to host name from the "From" line. */
  char face_ts[MAXLINE] ;     /* Pointer to time stamp from the "From" line. */
  char face_user[MAXLINE] ;   /* Pointer to user name from the "From" line. */
! char facedir[MAXLINE] ;          /* Alternate face image directory. */
  char fname[MAXTYPES][MAXLINE] ;  /* Array of various face name types. */
  char geometry[MAXLINE] ;         /* X11 geometry information. */
  char hostcommunity[MAXLINE] ;    /* The community of the host machine */
--- 88,96 ----
  char face_host[MAXLINE] ;   /* Pointer to host name from the "From" line. */
  char face_ts[MAXLINE] ;     /* Pointer to time stamp from the "From" line. */
  char face_user[MAXLINE] ;   /* Pointer to user name from the "From" line. */
! char facedirs[MAXLINE] ;    /* Colon separated list of face directories. */
! char *facepath[MAXPATHS+1] ;     /* Array of face image directories. */
! char fgcolor[MAXLINE] ;          /* X11 foreground color. */
  char fname[MAXTYPES][MAXLINE] ;  /* Array of various face name types. */
  char geometry[MAXLINE] ;         /* X11 geometry information. */
  char hostcommunity[MAXLINE] ;    /* The community of the host machine */
***************
*** 93,98 ****
--- 102,108 ----
  char peopfile[MAXLINE] ;    /* Name of the people/username file. */
  char printer[MAXLINE] ;     /* Printer name to monitor. */
  char progname[MAXLINE] ;    /* Name of this program. */
+ char realcomm[MAXLINE] ;    /* Real community for this user. */
  char realname[MAXLINE] ;    /* Real username for this user. */
  char spoolfile[MAXLINE] ;   /* Full pathname of users current mail. */
  char update_alias[MAXLINE] ;   /* Name of mail alias for database updates. */
***************
*** 137,142 ****
--- 147,153 ----
  int period = 60 ;   /* Period in seconds for new mail check. */
  int posspec = 0 ;   /* Set if -Wp or -g option is present (for X11) */
  int row ;           /* Row number for next icon. */
+ int toclear = 0 ;   /* Set if faces memory area needs clearing. */
  int update = 0 ;    /* If set, send mail to update faces database. */
  int width ;         /* Width in pixels of faces display. */
  int wx = 0 ;        /* Initial X position of the window. */
***************
*** 220,230 ****
   */
  
    {
!     struct hostent *hp ;
      char hostname[MAXLINE] ;
  
      GETHOSTNAME(hostname, MAXLINE) ;
!     hp = gethostbyname (hostname) ;
      if (hp != NULL) STRCPY(hostname, hp->h_name) ;
      h_to_c(hostname, hostcommunity) ;
    }
--- 231,243 ----
   */
  
    {
!     struct hostent *hp = NULL ;
      char hostname[MAXLINE] ;
  
      GETHOSTNAME(hostname, MAXLINE) ;
! #ifndef SYSV32
!     hp = gethostbyname(hostname) ;
! #endif /*SYSV32*/
      if (hp != NULL) STRCPY(hostname, hp->h_name) ;
      h_to_c(hostname, hostcommunity) ;
    }
***************
*** 233,241 ****
    {
      struct machinfo *temp ;
  
!     yp_get_default_domain (&hostdomain) ;
      STRCPY(domaincommunity, hostdomain) ;
  
  /*  We can't call h_to_c() to setup the default because it expects
   *  it to be set already; so we grovel through the machine/community
   *  association list directly.
--- 246,257 ----
    {
      struct machinfo *temp ;
  
!     yp_get_default_domain(&hostdomain) ;
      STRCPY(domaincommunity, hostdomain) ;
  
+     IF_DEBUG( FPRINTF(stderr, "main: NIS community is `%s`\n",
+                       domaincommunity) ) ;
+ 
  /*  We can't call h_to_c() to setup the default because it expects
   *  it to be set already; so we grovel through the machine/community
   *  association list directly.
***************
*** 242,253 ****
   */
  
      for (temp = machines; temp != NULL; temp = temp->next)
!       if (strcmp(temp->machine, domaincommunity) == 0)
!         {
!           STRCPY(domaincommunity, temp->community) ;
!           break ;
!         }
  
      IF_DEBUG( FPRINTF(stderr, "main: domain community is `%s`\n",
                        domaincommunity) ; )
    }
--- 258,273 ----
   */
  
      for (temp = machines; temp != NULL; temp = temp->next)
!      if (!strcmp(temp->machine, domaincommunity))
!        {
!          char *str ;
  
+          STRCPY(domaincommunity, temp->community) ;
+          for (str = community;  *str;  str++)
+            if (isascii(*str) && isupper(*str)) *str = tolower(*str) ;
+          break ;
+        }
+ 
      IF_DEBUG( FPRINTF(stderr, "main: domain community is `%s`\n",
                        domaincommunity) ; )
    }
***************
*** 260,273 ****
  }
  
  
! a_to_u(community, user, realname)    /* Turn possible alias into username. */
! char *community, *user, *realname ;
  {
    struct comminfo *ctemp ;
    struct peopinfo *ptemp ;
  
!   STRCPY(realname, user) ;      /* In case alias not found. */
!   ctemp = communities ;         /* Point to chain of communities. */
    while (ctemp != NULL)
      if (!strcmp(ctemp->community, community))
        {
--- 280,296 ----
  }
  
  
! /* Turn possible alias into username. */
! 
! a_to_u(community, user, realcomm, realname)
! char *community, *user, *realcomm, *realname ;
  {
    struct comminfo *ctemp ;
    struct peopinfo *ptemp ;
  
!   STRCPY(realname, user) ;         /* In case alias not found. */
!   STRCPY(realcomm, community) ;    /* In case alias not found. */
!   ctemp = communities ;            /* Point to chain of communities. */
    while (ctemp != NULL)
      if (!strcmp(ctemp->community, community))
        {
***************
*** 276,281 ****
--- 299,305 ----
            if (!strcmp(ptemp->alias, user))
              {
                STRCPY(realname, ptemp->username) ;
+               STRCPY(realcomm, ptemp->community) ;
                return ;
              }
            else ptemp = ptemp->next ;
***************
*** 287,295 ****
  
  initialise()
  {
!   STRCPY(facedir, "") ;       /* No alternate face directory by default. */
    STRCPY(display, "") ;       /* X11 display type. */
    STRCPY(geometry, "") ;      /* X11 geometry information. */
  
  #ifdef FBMONTYPE
    mtype = FBMONTYPE ;         /* Type of monitoring to do. */
--- 311,325 ----
  
  initialise()
  {
!   int i ;
! 
!   facepath[0] = FACEDIR ;    /* Default path is single built-in directory. */
!   for (i = 1;  i <= MAXPATHS;  i++) facepath[i] = (char *) NULL ;
! 
    STRCPY(display, "") ;       /* X11 display type. */
    STRCPY(geometry, "") ;      /* X11 geometry information. */
+   STRCPY(fgcolor, "") ;       /* X11 foreground information. */
+   STRCPY(bgcolor, "") ;       /* X11 background information. */
  
  #ifdef FBMONTYPE
    mtype = FBMONTYPE ;         /* Type of monitoring to do. */
***************
*** 301,315 ****
    STRCPY(bgicon, "") ;                  /* Default is to use root gray. */
  #endif /*BACKGROUND*/
  
- #ifdef FACEDIR
-   STRCPY(defdir, FACEDIR) ;            /* Different directory for face icons. */
- #else
-   STRCPY(defdir,"/usr/local/faces") ;  /* Directory for face icons. */
- #endif /*FACEDIR*/
- 
-   SPRINTF(machfile, "%s/%s", defdir, MACHINETAB) ;
-   SPRINTF(peopfile, "%s/%s", defdir, PEOPLETAB) ;
- 
  #ifdef INVERT
    invert = 1 ;               /* Display in reverse video. */
  #endif /*INVERT*/
--- 331,336 ----
***************
*** 329,335 ****
--- 350,360 ----
    else
      {
        username = getname() ;     /* Get users name from passwd entry. */
+ #ifdef SPOOLDIR
+       SPRINTF(spoolfile, "%s/%s", SPOOLDIR, username) ;
+ #else
        SPRINTF(spoolfile, "/usr/spool/mail/%s", username) ;
+ #endif /*SPOOLDIR*/
      }
  #endif /*SPOOLFILE*/
  
***************
*** 380,385 ****
--- 405,442 ----
          return ;
        }
  
+ #ifdef DNSLOOKUP
+   {
+     char *str ;
+     struct hostent *found = gethostbyname(community) ;
+  
+     if (found)
+       {
+          IF_DEBUG( FPRINTF(stderr, "DNSLOOKUP found %s as %s\n",
+                            community, found->h_name) ) ;
+          STRCPY(community, found->h_name) ;
+ 
+          for (str = community;  *str;  str++)
+            if (isascii(*str) && isupper(*str)) *str = tolower(*str) ;
+        
+ /* Grovel through the machine/community association list again
+  * to allow domains to be aliases.
+  */
+ 
+          for (temp = machines; temp != NULL; temp = temp->next)
+            if (!strcmp(temp->machine, community))
+              {
+                STRCPY(community, temp->community) ;
+                IF_DEBUG( FPRINTF(stderr,
+                          "h_to_c(): machine `%s` found in community '%s'\n",
+                          temp->machine, community) ; )
+                return ;
+              }
+          return ;
+       }
+   }
+ #endif /*DNSLOOKUP*/
+ 
  #ifdef NISLOOKUP
  
  /*  yp_match() returns zero on success. We will treat any failure as
***************
*** 389,412 ****
    yp_err = yp_match(hostdomain, "hosts.byname",
                      host, strlen(host), &hostinfo, &len) ;
  
-   if (yp_err == 0)
-     {
- 
  /* We aren't interested in the value returned, only whether the key
   * was found...
   */
  
        STRCPY(community, domaincommunity) ;
!       IF_DEBUG( FPRINTF(stderr, "NISlookup: found %s\n", host) ; )
      }
!   IF_DEBUG( else FPRINTF(stderr, "NISlookup: Error %d\n", yp_err) ; )
!   IF_DEBUG( FPRINTF(stderr, "h_to_c(): community = '%s'\n", community) ; )
  #endif /*NISLOOKUP*/
  }
  
  
! make_iconname(facedir, community, user)    /* Construct the icon name. */
! char *facedir, *community, *user ;
  {
  
  /*  Sets up community and user based on the first successful
--- 446,478 ----
    yp_err = yp_match(hostdomain, "hosts.byname",
                      host, strlen(host), &hostinfo, &len) ;
  
  /* We aren't interested in the value returned, only whether the key
   * was found...
   */
  
+   if (yp_err == 0)
+     {
+       char *str ;
+ 
        STRCPY(community, domaincommunity) ;
!       for (str = community;  *str;  str++)
!         if (isascii(*str) && isupper(*str)) *str = tolower(*str) ;
!  
! /* Don't bother checking for domaincommunity in the machines
!  * alias list - that should have been done when the variable
!  * was initialized.
!  */
!  
!       IF_DEBUG( FPRINTF(stderr, "NISlookup: found %s\n", host) ) ;
      }
!   IF_DEBUG( else FPRINTF(stderr, "NISlookup: Error %d\n", yp_err) ) ;
!   IF_DEBUG( FPRINTF(stderr, "h_to_c(): community = '%s'\n", community) ) ;
  #endif /*NISLOOKUP*/
  }
  
  
! make_iconname(facepath, community, user)    /* Construct the icon name. */
! char *facepath[MAXPATHS+1], *community, *user ;
  {
  
  /*  Sets up community and user based on the first successful
***************
*** 417,647 ****
   *  $(FACEDIR)/community/unknown/[face.ps, sun.icon, 48x48x1, face.xbm]
   *  $(FACEDIR)/misc./unknown/[face.ps, sun.icon, 48x48x1, face.xbm]
   *
!  *  Firstly a check is made for the "old" style; first in a possible
!  *  alternate face directory, then in the default directory. This is
!  *  where the username is not a directory but the ikon in 48x48x1
!  *  format.
   *
   *  If none of these are found, the "blank face" is returned.
   */
  
!   char *cptr ;
!   int i ;
  
    old_style = 0 ;     /* Reset before checking this face. */
  
    IF_DEBUG( FPRINTF(stderr, "make_iconname: %s[%s] ", community, user) ; )
    
!   if (strlen(facedir))
!     for (cptr = community; cptr != NULL; cptr = index(cptr, '.'))
!       for (i = -1; i < maxtypes; i++)
!         {
!           if (*cptr == '.') cptr++ ;
!           if (i < 0)
!             {
!               SPRINTF(iconname, "%s/%s/%s", facedir, cptr, user) ;
!               if (stat(iconname, &buf) == -1) goto mi1 ;
!               if ((buf.st_mode & S_IFMT) == S_IFREG)
!                 {
!                   old_style = 1 ;
!                   IF_DEBUG( FPRINTF(stderr, "found as %s\n", iconname) ; )
!                   return 1 ;
!                 }
!             }
!           else
!             {
!               SPRINTF(iconname, "%s/%s/%s/%s", facedir, cptr, user, fname[i]) ;
!               if (stat(iconname, &buf) != -1)
!                 {
!                   IF_DEBUG( FPRINTF(stderr, "found as %s\n", iconname) ; )
!                   return 1 ;
!                 }
!             }
!         }
! 
! mi1:
!   for (cptr = community; cptr != NULL; cptr = index(cptr, '.'))
!     for (i = -1; i < maxtypes; i++)
!       {
!         if (*cptr == '.') cptr++ ;
!         if (i < 0)
            {
!             SPRINTF(iconname, "%s/%s/%s", defdir, cptr, user) ;
!             if (stat(iconname, &buf) == -1) goto mi2 ;
!             if ((buf.st_mode & S_IFMT) == S_IFREG)
!               {    
!                 IF_DEBUG( FPRINTF(stderr, "found as %s\n", iconname) ; )
!                 old_style = 1 ;
!                 return 1 ;
!               }
!           } 
!         else
!           {
!             SPRINTF(iconname, "%s/%s/%s/%s", defdir, cptr, user, fname[i]) ;
              if (stat(iconname, &buf) != -1)
-               {
-                 IF_DEBUG( FPRINTF(stderr, "found as %s\n", iconname) ; )
-                 return 1 ;
-               }
-           }
-       }
-  
- mi2:
-   if (strlen(facedir))
-     for (i = -1; i < maxtypes; i++)
-       if (i < 0)
-         {
-           SPRINTF(iconname, "%s/misc./%s", facedir, user) ;
-           if (stat(iconname, &buf) == -1) goto mi3 ;
-           if ((buf.st_mode & S_IFMT) == S_IFREG)
-             {
-               IF_DEBUG( FPRINTF(stderr, "found as %s\n", iconname) ; )
-               old_style = 1 ;
-               return 1 ;
-             }
-         }    
-       else
-         { 
-           SPRINTF(iconname, "%s/misc./%s/%s", facedir, user, fname[i]) ;
-           if (stat(iconname, &buf) != -1)
-             {
-               if (!x_face) STRCPY(community, "misc.") ;
-               IF_DEBUG( FPRINTF(stderr, "found as %s\n", iconname) ; )
-               return 1 ;
-             }
-         }
- 
- mi3:
-   for (i = -1; i < maxtypes; i++)
-     if (i < 0)
-       {
-         SPRINTF(iconname, "%s/misc./%s", defdir, user) ;
-         if (stat(iconname, &buf) == -1) goto mi4 ;
-         if ((buf.st_mode & S_IFMT) == S_IFREG)
-           {
-             IF_DEBUG( FPRINTF(stderr, "found as %s\n", iconname) ; )
-             old_style = 1 ;
-             return 1 ;
-           }
-       }    
-     else
-       {
-         SPRINTF(iconname, "%s/misc./%s/%s", defdir, user, fname[i]) ;
-         if (stat(iconname, &buf) != -1)
-           {
-             IF_DEBUG( FPRINTF(stderr, "found as %s\n", iconname) ; )
-             if (!x_face) STRCPY(community, "misc.") ;
-             return 1 ;
-           }
-       }
-  
- mi4:
-   if (strlen(facedir))
-     for (cptr = community; cptr != NULL; cptr = index(cptr, '.'))
-       for (i = -1; i < maxtypes; i++)
-         {
-           if (*cptr == '.') cptr++ ;
-           if (i < 0)
-             {
-               SPRINTF(iconname, "%s/%s/unknown", facedir, cptr) ;
-               if (stat(iconname, &buf) == -1) goto mi5 ;
                if ((buf.st_mode & S_IFMT) == S_IFREG)
-                 {    
-                   IF_DEBUG( FPRINTF(stderr, "found as %s\n", iconname) ; )
-                   old_style = 1 ;
-                   return 1 ;
-                 }
-             } 
-           else
-             {
-               SPRINTF(iconname, "%s/%s/unknown/%s", facedir, cptr, fname[i]) ;
-               if (stat(iconname, &buf) != -1)
                  {
                    IF_DEBUG( FPRINTF(stderr, "found as %s\n", iconname) ; )
-                   if (mtype == MONALL && !x_face) STRCPY(user, "unknown") ;
                    return 1 ;
                  }
!             }
!         }
! 
! mi5:
!   for (cptr = community; cptr != NULL; cptr = index(cptr, '.'))
!     for (i = -1; i < maxtypes; i++)
!       {
!         if (*cptr == '.') cptr++ ;
!         if (i < 0)
!           {
!             SPRINTF(iconname, "%s/%s/unknown", defdir, cptr) ;
!             if (stat(iconname, &buf) == -1) goto mi6 ;
!             if ((buf.st_mode & S_IFMT) == S_IFREG)
!               {    
!                 IF_DEBUG( FPRINTF(stderr, "found as %s\n", iconname) ; )
!                 old_style = 1 ;
!                 return 1 ;
!               }
!           } 
!         else
!           {
!             SPRINTF(iconname, "%s/%s/unknown/%s", defdir, cptr, fname[i]) ;
!             if (stat(iconname, &buf) != -1)
                {
!                 IF_DEBUG( FPRINTF(stderr, "found as %s\n", iconname) ; )
!                 if (mtype == MONALL && !x_face) STRCPY(user, "unknown") ;
!                 return 1 ;
                }
            }
-       }
- 
- mi6:
-   if (strlen(facedir))
-     for (i = -1; i < maxtypes; i++)
-       if (i < 0)
-         {
-           SPRINTF(iconname, "%s/misc./unknown", facedir) ;
-           if (stat(iconname, &buf) == -1) goto mi7 ;
-           if ((buf.st_mode & S_IFMT) == S_IFREG)
-             {
-               IF_DEBUG( FPRINTF(stderr, "found as %s\n", iconname) ; )
-               old_style = 1 ;
-               return 1 ;
-             }
-         }    
-       else
-         {
-           SPRINTF(iconname, "%s/misc./unknown/%s", facedir, fname[i]) ;
-           if (stat(iconname, &buf) != -1)
-             {
-               IF_DEBUG( FPRINTF(stderr, "found as %s\n", iconname) ; )
-               if (!x_face) STRCPY(community, "misc.") ;
-               if (mtype == MONALL && !x_face) STRCPY(user, "unknown") ;
-               return 1 ;
-             }
-         }
- 
- mi7:
-   for (i = -1; i < maxtypes; i++)
-     if (i < 0)
-       {
-         SPRINTF(iconname, "%s/misc./unknown", defdir) ;
-         if (stat(iconname, &buf) == -1) return 0 ;
-         if ((buf.st_mode & S_IFMT) == S_IFREG)
-           {
-             IF_DEBUG( FPRINTF(stderr, "found as %s\n", iconname) ; )
-             old_style = 1 ;
-             return 1 ;
-           }  
-       }    
-     else
-       {
-         SPRINTF(iconname, "%s/misc./unknown/%s", defdir, fname[i]) ;
-         if (stat(iconname, &buf) != -1)
-           {
-             IF_DEBUG( FPRINTF(stderr, "found as %s\n", iconname) ; )
-             if (!x_face) STRCPY(community, "misc.") ;
-             if (mtype == MONALL && !x_face) STRCPY(user, "unknown") ;
-             return 1 ;
-           }
-       }
  
  /* Face icon not found, so the "blank face" should be used. */
  
--- 483,538 ----
   *  $(FACEDIR)/community/unknown/[face.ps, sun.icon, 48x48x1, face.xbm]
   *  $(FACEDIR)/misc./unknown/[face.ps, sun.icon, 48x48x1, face.xbm]
   *
!  *  Firstly a check is made for the "old" style. This is where the username
!  *  is not a directory but the ikon in 48x48x1 format. $(FACEDIR) is
!  *  replaced by all the face directories given.
   *
   *  If none of these are found, the "blank face" is returned.
   */
  
!   char *cptr, *icomm[3], *iuser[3] ;
!   int i, ic, id, iu ;
  
+   icomm[0] = community ;
+   icomm[1] = "misc." ;
+   icomm[2] = "" ;
+ 
+   iuser[0] = user ;
+   iuser[1] = "unknown" ;
+   iuser[2] = "" ;
+ 
    old_style = 0 ;     /* Reset before checking this face. */
  
    IF_DEBUG( FPRINTF(stderr, "make_iconname: %s[%s] ", community, user) ; )
    
!   for (id = 0; strlen(facepath[id]) != 0; id++)
!     for (iu = 0; strlen(iuser[iu]) != 0; iu++)
!       for (ic = 0; strlen(icomm[ic]) != 0; ic++)
!         for (cptr = icomm[ic]; cptr != NULL; cptr = index(cptr, '.'))
            {
!             SPRINTF(iconname, "%s/%s/%s", facepath[id], cptr, iuser[iu]) ;
              if (stat(iconname, &buf) != -1)
                if ((buf.st_mode & S_IFMT) == S_IFREG)
                  {
+                   old_style = 1 ;
                    IF_DEBUG( FPRINTF(stderr, "found as %s\n", iconname) ; )
                    return 1 ;
                  }
!             for (i = 0; i < maxtypes; i++)
                {
!                 if (*cptr == '.') cptr++ ;
!                 SPRINTF(iconname, "%s/%s/%s/%s", 
!                         facepath[id], cptr, iuser[iu], fname[i]) ;
!                 if (stat(iconname, &buf) != -1)
!                   {
!                     IF_DEBUG( FPRINTF(stderr, "found as %s\n", iconname) ; )
! #ifdef NAMEUNKNOWN
!                     if (EQUAL(iser[iu], "unknown")) STRCPY(user, "unknown") ;
! #endif /*NAMEUNKNOWN*/
!                     return 1 ;
!                   }
                }
            }
  
  /* Face icon not found, so the "blank face" should be used. */
  

------- mon.c -------
*** /tmp/da09670	Tue Aug 14 07:20:16 1990
--- mon.c	Tue Aug 14 06:58:10 1990
***************
*** 15,25 ****
   */
  
  #include <stdio.h>
! #ifdef SYSV
  #include <string.h>
  #else
  #include <strings.h>
! #endif /*SYSV*/
  #include <sys/types.h>
  #include <sys/stat.h>
  #include <sys/time.h>
--- 15,25 ----
   */
  
  #include <stdio.h>
! #ifdef SYSV32 || hpux
  #include <string.h>
  #else
  #include <strings.h>
! #endif /* SYSV32 || hpux */
  #include <sys/types.h>
  #include <sys/stat.h>
  #include <sys/time.h>
***************
*** 130,135 ****
--- 130,155 ----
  }
  
  
+ do_key(val)            /* Handle various keyboard options. */
+ int val ;
+ {
+   switch (val)
+     {
+       case KEY_CLEAR   : if (mtype == MONNEW)
+                            {
+                              repl_image(DISP_NAME,  CUROFF, width, height) ;
+                              repl_image(DISP_OTHER, CUROFF, width, height) ;
+                              toclear = 1 ;
+                              do_check() ;
+                            }
+                          break ;
+       case KEY_REFRESH : draw_screen(wdtype) ;
+                          break ;
+       case KEY_QUIT    : exit(0) ;
+     }
+ }
+ 
+ 
  do_mail(mtype)              /* Monitor a mail file for new or all mail. */
  enum mon_type mtype ;
  {        
***************
*** 184,192 ****
            if (froms_found) process_info() ;  /* Process previous mail. */
            process_from() ;                   /* Save new from details. */
          }
!       else if (EQUAL(line, "From:"))  process_from() ;
!       else if (EQUAL(line, "X-Face")) process_face() ;
!       else if (doing_xface)           process_face() ;
      }
    FCLOSE(fp) ;
  
--- 204,212 ----
            if (froms_found) process_info() ;  /* Process previous mail. */
            process_from() ;                   /* Save new from details. */
          }
!       else if (EQUAL(line, "From:"))   process_from() ;
!       else if (EQUAL(line, "X-Face:")) process_face() ;
!       else if (doing_xface)            process_face() ;
      }
    FCLOSE(fp) ;
  
***************
*** 216,221 ****
--- 236,243 ----
        return ;
      }
    column = row = 0 ;          /* Start in top left corner of pixrect. */
+ 
+ #ifndef PLP
    FGETS(nextline, MAXLINE, fp) ;
    if (EQUAL(nextline, "no entries"))
      {
***************
*** 230,245 ****
        text(DISP_ALL, LEFT, printer) ;      /* Output printer name. */
      }
    else
      {
        FGETS(nextline, MAXLINE, fp) ;    /* Skip the next line. */
        while (fgets(nextline, MAXLINE, fp) != NULL)
          {
            SSCANF(&nextline[7], "%s", owner) ;
            SSCANF(&nextline[60], "%d", &size) ;
            h_to_c("", community) ;
!           found = make_iconname(facedir, community, owner) ;
            add_record("", owner, "", size) ;
          }
        make_pixrect(noicons) ;
        this = recs ;
        while (this != NULL)
--- 252,302 ----
        text(DISP_ALL, LEFT, printer) ;      /* Output printer name. */
      }
    else
+ #endif /*PLP*/
      {
        FGETS(nextline, MAXLINE, fp) ;    /* Skip the next line. */
        while (fgets(nextline, MAXLINE, fp) != NULL)
          {
+ #ifdef PLP
+           if ((nextline[0] == '\n')             ||
+               (EQUAL(nextline, "  work done"))  ||
+               (EQUAL(nextline, "  processing")) ||
+               (EQUAL(nextline, "Printer "))     ||
+               (EQUAL(nextline, "Remote printer "))) continue ;
+ 
+           if ((EQUAL(nextline, "  Printer Error: may need attention!")) ||
+               (EQUAL(nextline, "Remote connect to "))) /* for the time being */
+             {
+               make_pixrect(1) ;                 /* Just the "no paper" icon. */
+               add_face(DISP_ALL, NOPAPER, "") ; /* Set to "no paper" icon. */
+               text(DISP_ALL, LEFT, printer) ;   /* Output printer name. */
+               PCLOSE(fp) ;
+               show_display() ;
+               return ;
+ 	    }
+ #endif /*PLP*/
            SSCANF(&nextline[7], "%s", owner) ;
+ #ifdef PLP
+           if (EQUAL(owner, "Owner")) continue ;
+           SSCANF(&nextline[59], "%d", &size) ;
+ #else
            SSCANF(&nextline[60], "%d", &size) ;
+ #endif /*PLP*/
            h_to_c("", community) ;
!           found = make_iconname(facepath, community, owner) ;
            add_record("", owner, "", size) ;
          }
+ #ifdef PLP
+       if (recs == NULL)
+         {
+           make_pixrect(1) ;                    /* Just the "no print" icon. */
+           add_face(DISP_ALL, NOPRINT, "") ;    /* Set to "no print" icon. */
+           text(DISP_ALL, LEFT, printer) ;      /* Output printer name. */
+           PCLOSE(fp) ;
+           show_display() ;
+           return ;
+ 	}
+ #endif /*PLP*/
        make_pixrect(noicons) ;
        this = recs ;
        while (this != NULL)
***************
*** 319,326 ****
              EQUAL(user, "NOPRINT") || EQUAL(user, "NOUSERS")))
          {
            h_to_c(host, community) ;   /* Turn hostname into community name. */
!           a_to_u(community, user, realname) ;
!           found = make_iconname(facedir, community, realname) ;
          }
             if (EQUAL(user, "NOMAIL"))  ftype = NOMAIL ;
        else if (EQUAL(user, "NOPAPER")) ftype = NOPAPER ;
--- 376,383 ----
              EQUAL(user, "NOPRINT") || EQUAL(user, "NOUSERS")))
          {
            h_to_c(host, community) ;   /* Turn hostname into community name. */
!           a_to_u(community, user, realcomm, realname) ;
!           found = make_iconname(facepath, realcomm, realname) ;
          }
             if (EQUAL(user, "NOMAIL"))  ftype = NOMAIL ;
        else if (EQUAL(user, "NOPAPER")) ftype = NOPAPER ;
***************
*** 360,366 ****
        SSCANF(&nextline[0], "%s", username) ;
        SSCANF(&nextline[38], "%s", ts) ;
        h_to_c("", community) ;
!       found = make_iconname(facedir, community, username) ;
        add_record("", username, ts, 0) ;
      }
    if (!noicons)
--- 417,423 ----
        SSCANF(&nextline[0], "%s", username) ;
        SSCANF(&nextline[38], "%s", ts) ;
        h_to_c("", community) ;
!       found = make_iconname(facepath, community, username) ;
        add_record("", username, ts, 0) ;
      }
    if (!noicons)
***************
*** 557,576 ****
    struct recinfo *crec ;    /* Pointer to current mail record for updating. */
  
    h_to_c(face_host, community) ;    /* Turn hostname into community name. */
!   a_to_u(community, face_user, realname) ;
    if (mtype == MONNEW)
      {
        if (x_face)
          {
-           SPRINTF(iconname, "%s/%s/%s/48x48x1",
-                   strlen(facedir) ? facedir : defdir, community, realname) ;
            add_face(DISP_ALL, XFACE, iconname) ;
            if (update) do_face_update(iconname, face_buf) ;
          }
        else
          {
!           if (!(found = make_iconname(facedir, community, realname)))
!             add_face(DISP_ALL, NOFACE, (char *) NULL) ;
            else add_face(DISP_ALL, ORDINARY, iconname) ;
          }
  
--- 614,635 ----
    struct recinfo *crec ;    /* Pointer to current mail record for updating. */
  
    h_to_c(face_host, community) ;    /* Turn hostname into community name. */
!   a_to_u(community, face_user, realcomm, realname) ;
! 
!   found = make_iconname (facepath, community, realname) ;
!   if (x_face && !found)
!     SPRINTF(iconname, "%s/%s/%s/48x48x1", facepath[0], community, realname) ;
! 
    if (mtype == MONNEW)
      {
        if (x_face)
          {
            add_face(DISP_ALL, XFACE, iconname) ;
            if (update) do_face_update(iconname, face_buf) ;
          }
        else
          {
!           if (!found) add_face(DISP_ALL, NOFACE, (char *) NULL) ;
            else add_face(DISP_ALL, ORDINARY, iconname) ;
          }
  
***************
*** 584,600 ****
      }
    else
      {
!       found = make_iconname(facedir, community, realname) ;
!       if (x_face)
!         SPRINTF(iconname, "%s/%s/%s/48x48x1",
!                 strlen(facedir) ? facedir : defdir, community, realname) ;
!       if ((crec = rec_exists(community, realname)) != NULL)
          {
            STRCPY(crec->ts, face_ts) ;
            if (!crec->total) noicons++ ;
            crec->total++ ;
          }
!       else add_record(community, realname, face_ts, 0) ;
      }
    fromc_found = froms_found = x_face = 0 ;  /* Reset for the next message. */
  }
--- 643,655 ----
      }
    else
      {
!       if ((crec = rec_exists(realcomm, realname)) != NULL)
          {
            STRCPY(crec->ts, face_ts) ;
            if (!crec->total) noicons++ ;
            crec->total++ ;
          }
!       else add_record(realcomm, realname, face_ts, 0) ;
      }
    fromc_found = froms_found = x_face = 0 ;  /* Reset for the next message. */
  }

------- rec.c -------
*** /tmp/da09673	Tue Aug 14 07:20:17 1990
--- rec.c	Wed Aug  8 18:02:52 1990
***************
*** 15,25 ****
   */
  
  #include <stdio.h>
! #ifdef SYSV
  #include <string.h>
  #else
  #include <strings.h>
! #endif /*SYSV*/
  #include "faces.h"
  #include "extern.h"
  
--- 15,25 ----
   */
  
  #include <stdio.h>
! #ifdef SYSV32 || hpux
  #include <string.h>
  #else
  #include <strings.h>
! #endif /* SYSV32 || hpux */
  #include "faces.h"
  #include "extern.h"
  
***************
*** 36,44 ****
  }
  
  
! add_alias(crec, username, alias)  /* Add new alias to hostnames' list. */
  struct comminfo *crec ;
! char *username, *alias ;
  {
    struct peopinfo *cptemp, *ptemp ;
  
--- 36,46 ----
  }
  
  
! /* Add new alias to hostnames' list. */
! 
! add_alias(crec, username, realcomm, alias)
  struct comminfo *crec ;
! char *username, *realcomm, *alias ;
  {
    struct peopinfo *cptemp, *ptemp ;
  
***************
*** 47,52 ****
--- 49,56 ----
    STRCPY(ptemp->alias, alias) ;
    ptemp->username = (char *) Malloc(strlen(username)+1) ;
    STRCPY(ptemp->username, username) ;
+   ptemp->community = (char *) Malloc(strlen(realcomm)+1) ;
+   STRCPY(ptemp->community, realcomm) ;
    ptemp->next = NULL ;
  
    if (crec->people == NULL) crec->people = ptemp ;
***************
*** 82,87 ****
--- 86,94 ----
        mlast->next = temp ;     /* Add record to existing chain. */
        mlast = temp ;           /* Point to end of chain. */
      }
+ 
+   IF_DEBUG( FPRINTF(stderr, "add_machine: Added %s ==> %s\n",
+                     temp->machine, temp->community) ) ;
  }
  
  
***************
*** 141,163 ****
  }
  
  
! check_comm(hostname, username, alias)  /* Check community list. */
! char *hostname, *username, *alias ;
  {
    struct comminfo *ctemp ;
   
    ctemp = communities ;      /* Try and find machine record for hostname. */
    while (ctemp != NULL)
!     if (!strcmp(ctemp->community, hostname))
        {  
!         add_alias(ctemp, username, alias) ;
          return ;
        }  
      else ctemp = ctemp->next ;
   
    ctemp = (struct comminfo *) LINT_CAST(Malloc(sizeof(struct comminfo))) ;
!   ctemp->community = (char *) Malloc(strlen(hostname)+1) ;
!   STRCPY(ctemp->community, hostname) ; 
    ctemp->people = NULL ; 
    ctemp->next = NULL ; 
   
--- 148,172 ----
  }
  
  
! /* Check community list. */
! 
! check_comm(hostname, username, aliascomm, alias)
! char *hostname, *username, *aliascomm, *alias ;
  {
    struct comminfo *ctemp ;
   
    ctemp = communities ;      /* Try and find machine record for hostname. */
    while (ctemp != NULL)
!     if (!strcmp(ctemp->community, aliascomm))
        {  
!         add_alias(ctemp, username, hostname, alias) ;
          return ;
        }  
      else ctemp = ctemp->next ;
   
    ctemp = (struct comminfo *) LINT_CAST(Malloc(sizeof(struct comminfo))) ;
!   ctemp->community = (char *) Malloc(strlen(aliascomm)+1) ;
!   STRCPY(ctemp->community, aliascomm) ; 
    ctemp->people = NULL ; 
    ctemp->next = NULL ; 
   
***************
*** 167,173 ****
        clast->next = ctemp ;   /* Add record to existing chain. */
        clast = ctemp ;         /* Point to end of chain. */
      }
!   add_alias(ctemp, username, alias) ;
  }
  
  
--- 176,182 ----
        clast->next = ctemp ;   /* Add record to existing chain. */
        clast = ctemp ;         /* Point to end of chain. */
      }
!   add_alias(ctemp, username, hostname, alias) ;
  }
  
  
***************
*** 175,181 ****
  
  garbage_collect()
  {
!   struct recinfo *last, *this, *next ;
  
    last = NULL ;
    this = recs ;
--- 184,190 ----
  
  garbage_collect()
  {
!   struct recinfo *this, *next ;
  
    last = NULL ;
    this = recs ;
***************
*** 198,242 ****
  }
  
  
  read_aliases()     /* Setup the hostname aliases subchains. */
  {
    char alias[MAXLINE] ;      /* Alias for this community/username. */
    char hostname[MAXLINE] ;   /* This records' hostname. */
    char username[MAXLINE] ;   /* This records real username. */
    char *ptr1, *ptr2 ;
    FILE *fd ;
  
!   if (strlen(facedir)) SPRINTF(peopfile, "%s/PEOPLETAB", facedir) ;
!   if ((fd = fopen(peopfile, "r")) == NULL)   /* Open people file. */
      {
!       if (strlen(facedir))
          {
!           SPRINTF(peopfile, "%s/machine.tab", defdir) ;
!           fd = fopen(peopfile, "r") ;
          }
!       if (fd == NULL)
!         {
!           FPRINTF(stderr,"%s: cannot open %s\n", progname, peopfile) ;
!           return ;
!         }
      }
-   while (fgets(nextline, MAXLINE, fd) != NULL)
-     {
-       if (nextline[0] == '\n' || nextline[0] == '#') continue ;
-       ptr1 = index(nextline, '/') ;
-       if (((int) (ptr1-nextline)) <= 0) continue ;  /* Ignore if no length. */
-       STRNCPY(hostname, nextline, (int) (ptr1-nextline)) ;
-       hostname[(int) (ptr1-nextline)] = '\0' ;
-       ptr2 = index(nextline, '=') ;
-       if (((int) (ptr2-ptr1-1)) <= 0) continue ;    /* Ignore if no length. */
-       STRNCPY(alias, ptr1+1, (int) (ptr2-ptr1-1)) ;
-       alias[(int) (ptr2-ptr1-1)] = '\0' ;
-       if ((strlen(ptr2)-2) <= 0) continue ;         /* Ignore if no length. */
-       STRNCPY(username, ptr2+1, strlen(ptr2)-2) ;
-       username[strlen(ptr2)-2] = '\0' ;
-       check_comm(hostname, username, alias) ;
-     }
-   FCLOSE(fd) ;
  }
  
  
--- 207,273 ----
  }
  
  
+ #define  MAXTOKENLEN  100
+ static char ptoken[MAXTOKENLEN] ;
+ 
+ char *
+ get_token(pntr)
+ char *pntr ;
+ {
+   int i = 0 ;
+ 
+   while (*pntr=='\t' || *pntr == ' ') pntr++ ;
+   while ((i < MAXTOKENLEN) && (!strchr("/= \t#",*pntr)))
+     ptoken[i++] = *(pntr++) ;
+   while (*pntr=='\t' || *pntr == ' ') pntr++ ;
+   ptoken[i] = '\0' ;
+   return(pntr) ;
+ }
+ 
+ 
  read_aliases()     /* Setup the hostname aliases subchains. */
  {
    char alias[MAXLINE] ;      /* Alias for this community/username. */
+   char aliascomm[MAXLINE] ;  /* Alias for this community/username. */
    char hostname[MAXLINE] ;   /* This records' hostname. */
    char username[MAXLINE] ;   /* This records real username. */
    char *ptr1, *ptr2 ;
+   int i ;
    FILE *fd ;
  
!   for (i = 0; facepath[i] != NULL; i++)
      {
!       SPRINTF(peopfile, "%s/%s", facepath[i], PEOPLETAB) ;
!       if ((fd = fopen(peopfile, "r")) == NULL) continue ;
! 
!       while (fgets(nextline, MAXLINE, fd) != NULL)
          {
!           if (nextline[0] == '\n' || nextline[0] == '#') continue ;
!           nextline[strlen(nextline)-1] = '\0' ;
!           ptr1 = get_token(nextline) ;
!           if (!strlen(ptoken) || *ptr1 != '/') continue ;
!           STRCPY(aliascomm, ptoken) ;
!           ptr1 = get_token(++ptr1) ;
!           if (!strlen(ptoken) || *ptr1 != '=') continue ;
!           STRCPY(alias, ptoken) ;
!           ptr1 = get_token(++ptr1) ;
!           if (!strlen(ptoken)) continue ;
!           if (*ptr1 == '/')
!             {
!               STRCPY(hostname, ptoken) ;
!               ptr1 = get_token(++ptr1) ;
!               if (!strlen(ptoken)) continue ;
!               STRCPY(username, ptoken) ;
!             }
!           else
!             {
!               STRCPY(hostname, aliascomm) ;
!               STRCPY(username, ptoken) ;
!             }
!          check_comm(hostname, username, aliascomm, alias) ;
          }
!       FCLOSE(fd) ;
      }
  }
  
  
***************
*** 245,279 ****
    char community[MAXLINE] ;   /* This records' community. */
    char machine[MAXLINE] ;     /* This records' machine name. */
    char *ptr ;
    FILE *fd ;
  
!   if (strlen(facedir)) SPRINTF(machfile, "%s/MACHINETAB", facedir) ;
!   if ((fd = fopen(machfile, "r")) == NULL)   /* Open machine file. */
      {
!       if (strlen(facedir))
          {
!           SPRINTF(machfile, "%s/machine.tab", defdir) ;
!           fd = fopen(machfile, "r") ;
          }
!       if (fd == NULL)
!         {
!           FPRINTF(stderr,"%s: cannot open %s\n", progname, machfile) ;
!           return ;
!         }
      }
-   while (fgets(nextline, MAXLINE, fd) != NULL)
-     {
-       if (nextline[0] == '\n' || nextline[0] == '#') continue ;
-       ptr = index(nextline, '=') ;
-       if (((int) (ptr-nextline)) <= 0) continue ;  /* Ignore if no length. */
-       STRNCPY(machine, nextline, (int) (ptr-nextline)) ;
-       machine[(int) (ptr-nextline)] = '\0' ;
-       if (strlen(ptr)-2 <= 0) continue ;           /* Ignore if no length. */
-       STRNCPY(community, ptr+1, strlen(ptr)-2) ;
-       community[strlen(ptr)-2] = '\0' ;
-       add_machine(machine, community) ;
-     }
-   FCLOSE(fd) ;
  }
  
  
--- 276,303 ----
    char community[MAXLINE] ;   /* This records' community. */
    char machine[MAXLINE] ;     /* This records' machine name. */
    char *ptr ;
+   int i ;
    FILE *fd ;
  
!   for (i = 0; facepath[i] != NULL; i++)
      {
!       SPRINTF(machfile, "%s/%s", facepath[i], MACHINETAB) ;
!       if ((fd = fopen(machfile, "r")) == NULL) continue ;
! 
!       while (fgets(nextline, MAXLINE, fd) != NULL)
          {
!           if (nextline[0] == '\n' || nextline[0] == '#') continue ;
!           nextline[strlen(nextline)-1] = '\0' ;
!           ptr = get_token(nextline) ;
!           if (!strlen(ptoken) || *ptr != '=') continue ;
!           STRCPY(machine, ptoken) ;
!           ptr = get_token(++ptr) ;
!           if (!strlen(ptoken)) continue ;
!           STRCPY(community, ptoken) ;
!           add_machine(machine, community) ;
          }
!       FCLOSE(fd) ;
      }
  }
  
  

------CUT HERE------CUT HERE------CUT HERE------CUT HERE------

Rich Burridge,          DOMAIN: richb at Aus.Sun.COM
Sun Microsystems.       ACSNET: richb at sunaus.sun.oz
PHONE: +61 2 413 2666   UUCP:   {uunet,mcvax,ukc}!munnari!sunaus.oz!richb



More information about the Comp.sources.misc mailing list