[comp.sources.bugs] Official patch #10 for faces v1.3; please apply iy.

richb@sunchat.oz (Rich Burridge) (02/22/89)

It adds the following enhancement:

A "-e progname" option has been added. This allows the user to supply
a program or shell script which generates fixed format records that the
faces program reads, and faces then displays the appropriate faces.

This option is needed to allow individual sites to add extra monitoring
options. The format of the face information records is given in the faces
man page. Note that this is a first implementation of this option, and the
minimum amount of effort and change was used. It will probably be adjusted
and modified in the next general release of faces which will occur when the
View2 and NDE toolkits become available. I welcome comments and suggestions
for improving this. In the next general release the printer and user options
will definitely be rewritten as shell scripts, and possibly the mail
monitoring options as well.

There will be one more significant change in the next patch, and a couple
of minor ones, then that's it until later in the year.

Feed this file to Larry Walls' patch program, then recompile.

    Rich.

------CUT HERE------CUT HERE------
*** original/README	Sat Feb 18 22:02:23 1989
--- README	Wed Feb 22 15:16:45 1989
***************
*** 30,36 ****
  run it on any other system.
  
  
! Faces has four different modes of operation:
  
  The default will monitor for new mail. Only the last ten messages are
  displayed. In its iconic form, it is also possible to display the timestamp
--- 30,36 ----
  run it on any other system.
  
  
! Faces has five different modes of operation:
  
  The default will monitor for new mail. Only the last ten messages are
  displayed. In its iconic form, it is also possible to display the timestamp
***************
*** 48,56 ****
  Opening the window will show all the jobs in the queue with the owners' name
  and the size of the job in bytes.
  
! Finally you can monitor who is logged in a machine. For each user, a face image
! is displayed. The iconic form displays login time, and the window format gives
! the username.
  
  Faces is based on the AT&T v8 face server called vismon, but is not derived
  from vismon sources. With this version comes vismon compatibility. Note
--- 48,61 ----
  Opening the window will show all the jobs in the queue with the owners' name
  and the size of the job in bytes.
  
! With the fourth mode, you can monitor who is logged in a machine. For each
! user, a face image is displayed. The iconic form displays login time, and the
! window format gives the username.
! 
! Finally you can specify a program or shell script to run. The standard output
! from this program will be read by the faces program, and the appropriate faces
! displayed using the information provided. The format of this face information
! is given in the faces manual page.
  
  Faces is based on the AT&T v8 face server called vismon, but is not derived
  from vismon sources. With this version comes vismon compatibility. Note
*** original/extern.h	Sun Feb  5 22:11:29 1989
--- extern.h	Wed Feb 22 15:16:43 1989
***************
*** 1,5 ****
  
! /*  @(#)extern.h 1.6 89/02/05
   *
   *  Contains the external variable definitions used by faces.
   *
--- 1,5 ----
  
! /*  @(#)extern.h 1.7 89/02/22
   *
   *  Contains the external variable definitions used by faces.
   *
***************
*** 48,53 ****
--- 48,54 ----
  extern char progname[] ;   /* Name of this program. */
  extern char revtable[] ;   /* Table for reversing the bits in a byte. */
  extern char spoolfile[] ;  /* Full pathname of users current mail. */
+ extern char userprog[] ;   /* User supplied program to run. */
  
  extern int beeps ;         /* Number of beeps for arrival of new mail. */
  extern int column ;        /* Column number for next icon. */
*** original/faces.1	Sat Feb 18 22:02:23 1989
--- faces.1	Wed Feb 22 15:16:45 1989
***************
*** 1,4 ****
! .\" @(#)faces.1 1.7 89/02/18
  .TH FACES 1L "2 December 1988"
  .SH NAME
  faces \- visual mail, user and print face server.
--- 1,4 ----
! .\" @(#)faces.1 1.8 89/02/22
  .TH FACES 1L "2 December 1988"
  .SH NAME
  faces \- visual mail, user and print face server.
***************
*** 23,28 ****
--- 23,32 ----
  .I display
  ]
  [
+ .B \-e
+ .I program
+ ]
+ [
  .B \-f
  .I facedir
  ]
***************
*** 71,77 ****
  .SH DESCRIPTION
  .B faces
  is a window based tool for monitoring mail, users or print queues. It contains
! graphical interfaces for MGR, NeWS, SunView, and X11. It has four different
  modes of operation:
  .LP
  The default will monitor for new mail. Only the last ten messages are
--- 75,81 ----
  .SH DESCRIPTION
  .B faces
  is a window based tool for monitoring mail, users or print queues. It contains
! graphical interfaces for MGR, NeWS, SunView, and X11. It has five different
  modes of operation:
  .LP
  The default will monitor for new mail. Only the last ten messages are
***************
*** 92,101 ****
  Opening the window will show all the jobs in the queue with the owners' name
  and the size of the job in bytes.
  .LP
! Finally you can monitor who is logged in a machine. For each user, a face image
! is displayed. The iconic form displays login time, and the window format gives
! the username.
  .LP
  With the MGR version, swapping between the open window and the iconic versions
  is done with the right mouse button.
  .LP
--- 96,110 ----
  Opening the window will show all the jobs in the queue with the owners' name
  and the size of the job in bytes.
  .LP
! With the fourth mode, you can monitor who is logged in a machine. For each
! user, a face image is displayed. The iconic form displays login time, and the
! window format gives the username.
  .LP
+ Finally you can specify a program or shell script to run. The standard output
+ from this program will be read by the faces program, and the appropriate faces
+ displayed using the information provided. The format of this face information
+ is given in the faces manual page.
+ .LP
  With the MGR version, swapping between the open window and the iconic versions
  is done with the right mouse button.
  .LP
***************
*** 217,223 ****
--- 226,264 ----
  	The final image will be translated to a 64 x 64 square image at
  .br
  	the appropriate position in the faces display.
+ .LP
+ If you are using the
+ .B \-e
+ option, then the user program or shell script should firstly generate a
+ single record with the following fixed format, beginning at column 1:
  .br
+ 	Cols=mm Rows=nn
+ .br
+ where mm is the size in columns for the faces window and icon, and
+ nn is the size in rows. A window will be generated with these dimensions.
+ .LP
+ This record is followed by the face information records, which are again
+ in fixed format. As well as providing the username and hostname, there are
+ four other fields which can be filled in, which denote what is displayed
+ on the left or the right sides of the bottom area of the window and icon
+ displays. The format for these records is:
+ .nf
+ 
+ 	Description	Start column	Number of columns.
+ 	----------------------------------------------------------------------
+ 	username	1		20
+ 	hostname	21		20
+ 	window left	41		10
+ 	window right	51		10
+ 	icon left  	61		10
+ 	icon right	71		10
+ .fi
+ .LP
+ Any of these fields may be left blank. There are also four special usernames,
+ which will display the appropriate standard icons. These are
+ .B "NOMAIL, NOPAPER, NOPRINT "
+ and
+ .B "NOUSERS."
  .SH OPTIONS
  .TP
  .B \-MH
***************
*** 243,248 ****
--- 284,295 ----
  .TP
  .BI \-d " display"
  Used with the X11 variant of faces to give a display type.
+ .TP
+ .BI \-e " program"
+ Name of the user program to run. This program or shell script will generate
+ lines which the faces program will read, and then display the appropriate
+ face images. The format of these input records is described in a previous
+ section.
  .TP
  .BI \-f " facedir"
  If specified, then this directory is searched first for face images. If
*** original/faces.h	Sun Feb 19 21:57:23 1989
--- faces.h	Wed Feb 22 15:16:43 1989
***************
*** 1,5 ****
  
! /*  @(#)faces.h 1.9 89/02/19
   *
   *  Contains all the global definitions used by faces.
   *
--- 1,5 ----
  
! /*  @(#)faces.h 1.10 89/02/22
   *
   *  Contains all the global definitions used by faces.
   *
***************
*** 58,64 ****
  enum just_type { LEFT, RIGHT } ;
  
  /* Different types of file monitoring performed by this program. */
! enum mon_type { MONALL, MONNEW, MONPRINTER, MONUSERS } ;
  
  /* Different graphics systems. Appropriate one set in gtype. */
  enum gr_type { SVIEW, NEWS, X11, MGR } ;
--- 58,64 ----
  enum just_type { LEFT, RIGHT } ;
  
  /* Different types of file monitoring performed by this program. */
! enum mon_type { MONALL, MONNEW, MONPRINTER, MONPROG, MONUSERS } ;
  
  /* Different graphics systems. Appropriate one set in gtype. */
  enum gr_type { SVIEW, NEWS, X11, MGR } ;
*** original/get.c	Sun Feb 19 21:57:23 1989
--- get.c	Wed Feb 22 15:16:38 1989
***************
*** 1,6 ****
  /*LINTLIBRARY*/
  #ifndef lint
! static char sccsid[] = "@(#)get.c 1.9 89/02/19" ;
  #endif
  	
  /*  Extraction routines used by faces.
--- 1,6 ----
  /*LINTLIBRARY*/
  #ifndef lint
! static char sccsid[] = "@(#)get.c 1.10 89/02/22" ;
  #endif
  	
  /*  Extraction routines used by faces.
***************
*** 199,204 ****
--- 199,208 ----
                         break ;
              case 'd' : INC ;                 /* X11 display information. */
                         getparam(display, argv, "-d needs display information") ;
+                        break ;
+             case 'e' : mtype = MONPROG ;     /* User specified program. */
+                        INC ;
+                        getparam(userprog, argv, "-e needs user program") ;
                         break ;
              case 'f' : INC ;                 /* New directory for face icons. */
                         getparam(facedir, argv, "-f needs face directory") ;
*** original/main.c	Sun Feb  5 22:11:29 1989
--- main.c	Wed Feb 22 15:16:39 1989
***************
*** 1,5 ****
  #ifndef lint
! static char sccsid[] = "@(#)main.c 1.7 89/02/05" ;
  #endif
  
  /*  Icon face server for monitoring mail and print jobs.
--- 1,5 ----
  #ifndef lint
! static char sccsid[] = "@(#)main.c 1.8 89/02/22" ;
  #endif
  
  /*  Icon face server for monitoring mail and print jobs.
***************
*** 53,58 ****
--- 53,59 ----
  char progname[MAXLINE] ;    /* Name of this program. */
  char spoolfile[MAXLINE] ;   /* Full pathname of users current mail. */
  char *username ;            /* This users name. */
+ char userprog[MAXLINE] ;    /* User supplied program to run. */
  
  int beeps ;         /* Number of beeps for arrival of new mail. */
  int column ;        /* Column number for next icon. */
*** original/mgr.c	Sat Feb 18 22:02:23 1989
--- mgr.c	Wed Feb 22 15:16:47 1989
***************
*** 1,6 ****
  /*LINTLIBRARY*/
  #ifndef lint
! static char sccsid[] = "@(#)mgr.c 1.2 89/02/18" ;
  #endif
  
  /*  MGR dependent graphics routines used by faces,
--- 1,6 ----
  /*LINTLIBRARY*/
  #ifndef lint
! static char sccsid[] = "@(#)mgr.c 1.3 89/02/22" ;
  #endif
  
  /*  MGR dependent graphics routines used by faces,
***************
*** 121,132 ****
    m_func(B_COPY) ;
    switch ((int) mtype)
      {
!       case MONNEW     : m_bitcopyto(64, 0, (NO_PER_ROW-1)*ICONWIDTH,
!                                     ICONHEIGHT, 0, 0, fpr, fpr) ;
!       case MONALL     :
!       case MONPRINTER :
!       case MONUSERS   : m_bitcopyto(column*ICONWIDTH, row*ICONHEIGHT,
!                               ICONWIDTH, ICONHEIGHT, 0, 0,  fpr, face_pr) ;
      }
    m_flush() ;
  }
--- 121,130 ----
    m_func(B_COPY) ;
    switch ((int) mtype)
      {
!       case MONNEW : m_bitcopyto(64, 0, (NO_PER_ROW-1)*ICONWIDTH,
!                                 ICONHEIGHT, 0, 0, fpr, fpr) ;
!       default     : m_bitcopyto(column*ICONWIDTH, row*ICONHEIGHT,
!                                 ICONWIDTH, ICONHEIGHT, 0, 0,  fpr, face_pr) ;
      }
    m_flush() ;
  }
*** original/mon.c	Sun Feb 19 21:57:23 1989
--- mon.c	Wed Feb 22 15:16:40 1989
***************
*** 1,6 ****
  /*LINTLIBRARY*/
  #ifndef lint
! static char sccsid[] = "@(#)mon.c 1.8 89/02/19" ;
  #endif
  
  /*  Monitoring routines used by the faces program.
--- 1,6 ----
  /*LINTLIBRARY*/
  #ifndef lint
! static char sccsid[] = "@(#)mon.c 1.9 89/02/22" ;
  #endif
  
  /*  Monitoring routines used by the faces program.
***************
*** 56,61 ****
--- 56,63 ----
                          break ;
        case MONPRINTER : do_printer() ;     /* Monitor the print queue. */
                          break ;
+       case MONPROG    : do_prog() ;        /* Run user supplied program. */
+                         break ;
        case MONUSERS   : do_users() ;       /* Monitor users on a machine. */
      }
    firsttime = 0 ;
***************
*** 220,225 ****
--- 222,297 ----
            this = next ;
          }
        recs = last = NULL ;
+     }
+   PCLOSE(fp) ;
+   show_display() ;
+ }
+ 
+ 
+ do_prog()                   /* Run user supplied program or script. */
+ {
+   FILE *fp ;                /* File descriptor for users command output. */
+   enum icon_type ftype ;    /* Type of the current face. */
+   char host[MAXLINE] ;      /* Pointer to host name from the "From" line. */
+   char ileft[MAXLINE] ;     /* Text for left side of icon display. */
+   char iright[MAXLINE] ;    /* Text for right side of icon display. */
+   char realname[MAXLINE] ;  /* Real username for this user. */
+   char user[MAXLINE] ;      /* Pointer to user name from the "From" line. */
+   char wleft[MAXLINE] ;     /* Text for left side of window display. */
+   char wright[MAXLINE] ;    /* Text for right side of window display. */
+   int cols = 10 ;           /* Maximum number of columns for display. */
+   int rows = 1 ;            /* Maximum number of rows for display. */
+ 
+   if ((fp = popen(userprog, "r")) == NULL)   /* Connect to user program. */
+     {
+       FPRINTF(stderr,"%s: couldn't get program (%s) information.\n",
+               progname, userprog) ;
+       return ;
+     }
+   FGETS(nextline, MAXLINE, fp) ;
+   SSCANF(nextline, "Cols=%d Rows=%d", &cols, &rows) ;
+   if (cols < 1) cols = 10 ;
+   if (rows < 1) rows = 1 ;
+ 
+   create_pixrects(cols * ICONWIDTH, rows * ICONHEIGHT) ;
+   while (fgets(nextline, MAXLINE, fp) != NULL)
+     {
+       nextline[80] = '\0' ;
+       if (!sscanf(&nextline[70], "%s", iright)) iright[0] = '\0' ;
+       nextline[70] = '\0' ;
+       if (!sscanf(&nextline[60], "%s", ileft)) ileft[0] = '\0' ;
+       nextline[60] = '\0' ;
+       if (!sscanf(&nextline[50], "%s", wright)) wright[0] = '\0' ;
+       nextline[50] = '\0' ;
+       if (!sscanf(&nextline[40], "%s", wleft)) wleft[0] = '\0' ;
+       nextline[40] = '\0' ;
+       if (!sscanf(&nextline[20], "%s", host)) host[0] = '\0' ;
+       nextline[20] = '\0' ;
+       if (!sscanf(&nextline[0], "%s", user)) user[0] = '\0' ;
+ 
+       STRCPY(community, "") ;
+       if (!(EQUAL(user, "NOMAIL")  || EQUAL(user, "NOPAPER") ||
+             EQUAL(user, "NOPRINT") || EQUAL(user, "NOUSERS")))
+         {
+           h_to_c(host, community) ;   /* Turn hostname into community name. */
+           a_to_u(community, user, realname) ;
+           if (strlen(facedir))
+             found = make_iconname(facedir, community, realname) ;
+           else found = make_iconname(defdir, community, realname) ;
+           if (!found && strlen(facedir))
+             found = make_iconname(defdir, community, realname) ;
+         }
+            if (EQUAL(user, "NOMAIL")) ftype = NOMAIL ;
+       else if (EQUAL(user, "NOPAPER")) ftype = NOPAPER ;
+       else if (EQUAL(user, "NOPRINT")) ftype = NOPRINT ;
+       else if (EQUAL(user, "NOUSERS")) ftype = NOUSERS ;
+       else ftype = ORDINARY ;
+       add_face(BOTH, ftype, iconname) ;
+       if (strlen(ileft)) text(ICON, LEFT, ileft) ;
+       if (strlen(iright)) text(ICON, RIGHT, iright) ;
+       if (strlen(wleft)) text(WINDOW, LEFT, wleft) ;
+       if (strlen(wright)) text(WINDOW, RIGHT, wright) ;
+       adjust() ;             /* Adjust column and row. */
      }
    PCLOSE(fp) ;
    show_display() ;
*** original/news.c	Sun Feb  5 22:11:29 1989
--- news.c	Wed Feb 22 15:16:41 1989
***************
*** 1,6 ****
  /*LINTLIBRARY*/
  #ifndef lint
! static char sccsid[] = "@(#)news.c 1.7 89/02/05" ;
  #endif
  
  /*  NeWS dependent graphics routines used by faces,
--- 1,6 ----
  /*LINTLIBRARY*/
  #ifndef lint
! static char sccsid[] = "@(#)news.c 1.8 89/02/22" ;
  #endif
  
  /*  NeWS dependent graphics routines used by faces,
***************
*** 108,128 ****
  {
    switch ((int) mtype)
      {
!       case MONNEW     : FPRINTF(PostScript, "%d 0 %d %d %s ShiftImage\n",
!                                 ICONWIDTH, (NO_PER_ROW-1)*ICONWIDTH, ICONHEIGHT,
!                                 dest) ;
!                         if (facetype == NEWSTYPE)
!                           {
!                             FPRINTF(PostScript, "%d %d %d %d %s ClearBox\n",
!                                     column*ICONWIDTH, row*ICONHEIGHT,
!                                     ICONWIDTH, ICONHEIGHT, dest) ;
!                             return ;
!                           }
!       case MONALL     :
!       case MONPRINTER :
!       case MONUSERS   : FPRINTF(PostScript,"%s %d %d %d %d %s MoveImage\n",
!                                 face, ICONWIDTH, ICONHEIGHT,
!                                 column*ICONWIDTH, row*ICONHEIGHT, dest) ;
      }
  }
  
--- 108,126 ----
  {
    switch ((int) mtype)
      {
!       case MONNEW : FPRINTF(PostScript, "%d 0 %d %d %s ShiftImage\n",
!                             ICONWIDTH, (NO_PER_ROW-1)*ICONWIDTH, ICONHEIGHT,
!                             dest) ;
!                     if (facetype == NEWSTYPE)
!                       {
!                         FPRINTF(PostScript, "%d %d %d %d %s ClearBox\n",
!                                 column*ICONWIDTH, row*ICONHEIGHT,
!                                 ICONWIDTH, ICONHEIGHT, dest) ;
!                         return ;
!                       }
!       default     : FPRINTF(PostScript,"%s %d %d %d %d %s MoveImage\n",
!                             face, ICONWIDTH, ICONHEIGHT,
!                             column*ICONWIDTH, row*ICONHEIGHT, dest) ;
      }
  }
  
*** original/patchlevel.h	Sun Feb 19 21:57:23 1989
--- patchlevel.h	Wed Feb 22 15:16:44 1989
***************
*** 1,5 ****
   
! /*  @(#)patchlevel.h 1.10 89/02/19
   *
   *  This is the current patch level for this version of faces.
   *
--- 1,5 ----
   
! /*  @(#)patchlevel.h 1.11 89/02/22
   *
   *  This is the current patch level for this version of faces.
   *
***************
*** 14,17 ****
   *  reported to me then an attempt will be made to fix them.
   */
  
! #define  PATCHLEVEL  9
--- 14,17 ----
   *  reported to me then an attempt will be made to fix them.
   */
  
! #define  PATCHLEVEL  10
*** original/sunview.c	Sun Feb 19 21:57:23 1989
--- sunview.c	Wed Feb 22 15:16:42 1989
***************
*** 1,6 ****
  /*LINTLIBRARY*/
  #ifndef lint
! static char sccsid[] = "@(#)sunview.c 1.6 89/02/19" ;
  #endif
  
  /*  SunView dependent graphics routines used by faces,
--- 1,6 ----
  /*LINTLIBRARY*/
  #ifndef lint
! static char sccsid[] = "@(#)sunview.c 1.7 89/02/22" ;
  #endif
  
  /*  SunView dependent graphics routines used by faces,
***************
*** 137,147 ****
  {
    switch ((int) mtype)
      {
!       case MONNEW     : PR_ROP(fpr, 64, 0, 640-64, 64, PIX_SRC, fpr, 0, 0) ;
!       case MONALL     :
!       case MONPRINTER :
!       case MONUSERS   :  PR_ROP(fpr, column*ICONWIDTH, row*ICONHEIGHT,
!                                ICONWIDTH, ICONHEIGHT, PIX_SRC, face_pr, 0, 0) ;
      }
  }
  
--- 137,145 ----
  {
    switch ((int) mtype)
      {
!       case MONNEW : PR_ROP(fpr, 64, 0, 640-64, 64, PIX_SRC, fpr, 0, 0) ;
!       default     : PR_ROP(fpr, column*ICONWIDTH, row*ICONHEIGHT,
!                            ICONWIDTH, ICONHEIGHT, PIX_SRC, face_pr, 0, 0) ;
      }
  }
  
*** original/x11.c	Sun Feb  5 22:11:45 1989
--- x11.c	Wed Feb 22 15:16:46 1989
***************
*** 1,6 ****
  /*LINTLIBRARY*/
  #ifndef lint
! static char sccsid[] = "@(#)x11.c 1.5 89/02/05" ;
  #endif
  
  /*  X11 dependent graphics routines used by faces,
--- 1,6 ----
  /*LINTLIBRARY*/
  #ifndef lint
! static char sccsid[] = "@(#)x11.c 1.6 89/02/22" ;
  #endif
  
  /*  X11 dependent graphics routines used by faces,
***************
*** 127,138 ****
  {
    switch ((int) mtype)
      {
!       case MONNEW     : XCopyArea(dpy, fpr, fpr, gc, 0, 0,
                            (NO_PER_ROW-1)*ICONWIDTH, ICONHEIGHT, ICONWIDTH, 0) ;
!       case MONALL     :
!       case MONPRINTER :
!       case MONUSERS   : XCopyArea(dpy, face_pr, fpr, gc, 0, 0,
!                           ICONWIDTH, ICONHEIGHT, column*ICONWIDTH, row*ICONHEIGHT) ;
      }
  }
  
--- 127,137 ----
  {
    switch ((int) mtype)
      {
!       case MONNEW : XCopyArea(dpy, fpr, fpr, gc, 0, 0,
                            (NO_PER_ROW-1)*ICONWIDTH, ICONHEIGHT, ICONWIDTH, 0) ;
!       default     : XCopyArea(dpy, face_pr, fpr, gc, 0, 0,
!                               ICONWIDTH, ICONHEIGHT,
!                               column*ICONWIDTH, row*ICONHEIGHT) ;
      }
  }