[comp.sources.bugs] Official patch #8 for faces v1.1.

richb@sunaus.oz (Rich Burridge) (08/22/88)

This is official patch #8 for faces v1.1, please apply it.
 
It makes the following changes:

1. Corrects the handling of the -W SunView command line
   window options. Thanks to Ian Darwin <sun!sq.sq.com!ian>
   for this change.

2. Correctly sizes the offscreen memory pixrects, and the open
   window sizes with the -a and -P command line options.

3. The faces program does not come up in iconic form initially
   anymore. This should be achieved with the -Wi command line
   option. Thanks to Jim Wight <Jim_Wight@newcastle.ac.uk@munnari.oz>
   for this suggestion.

4. A -u command line option has been added. When this is given, the
   username is not displayed over the face icon in the open window
   display. The Makefile and manual pages have also been updated.
   Thanks also to Jim Wight for this suggestion.

Note that the hooks for the NeWS version of faces have been added to
the Makefile. I am still working on this, and with real work
permitting, hope to make it available in the next few weeks.

Use Larry Walls' patch program to apply these changes.

    Rich.

------CUT HERE------CUT HERE------CUT HERE------
*** original/Makefile	Fri Aug 12 21:24:09 1988
--- Makefile	Mon Aug 22 10:19:46 1988
***************
*** 53,84 ****
  #  If nonzero, do not show timestamp on the face icon.
  #
  DONTSHOWTIME     = -DDONTSHOWTIME=0
  #-------------------------------------------------------------------
  
  VARIABLES       = $(MONTYPE) $(PRINTMON) $(FACEDIR) $(DEFHOST) \
!                   $(INTERVAL) $(DONTSHOWNO) $(SPOOLFILE) $(DONTSHOWTIME)
! BINARIES        = faces
  BINDIR          = /usr/local/bin
  MANDIR          = /usr/man/man$(MANSECT)
  MANSECT         = l
! CFLAGS          = -g $(VARIABLES)
  HDRS            = extern.h faces.h patchlevel.h
  IMAGES          = bounced.icon noface.icon nomail.icon \
                    noprint.icon nopaper.icon
  
! LIBS            = -lsuntool -lsunwindow -lpixrect
! OBJS            = get.o main.o mon.o rec.o sunview.o
! SRCS            = get.c main.c mon.c rec.c sunview.c
  
! OTHERS          = faces.1 Makefile README
  
  all:            $(BINARIES)
  
! faces:          $(OBJS)
! 		cc -o faces $(CFLAGS) $(OBJS) $(LIBS)
  
  install:        $(BINARIES)
  		install -s -m 751 faces $(BINDIR)
  		install -c -m 644 faces.1 $(MANDIR)/faces.$(MANSECT)
  
  backup:;	cp $(SRCS) $(HDRS) $(IMAGES) $(OTHERS) backdir
--- 53,106 ----
  #  If nonzero, do not show timestamp on the face icon.
  #
  DONTSHOWTIME     = -DDONTSHOWTIME=0
+ #
+ #  If nonzero, do not show username on the face icon.
+ #
+ DONTSHOWUSER     = -DDONTSHOWUSER=0
  #-------------------------------------------------------------------
  
  VARIABLES       = $(MONTYPE) $(PRINTMON) $(FACEDIR) $(DEFHOST) \
!                   $(INTERVAL) $(DONTSHOWNO) $(SPOOLFILE) \
! 		  $(DONTSHOWTIME) $(DONTSHOWUSER)
! BINARIES        = ps_faces sv_faces
  BINDIR          = /usr/local/bin
+ LIBDIR          = .
+ NEWSFILE        = -DNEWSGIVEN -DNEWSFILE=\"$(LIBDIR)/faces.ps\"
  MANDIR          = /usr/man/man$(MANSECT)
  MANSECT         = l
! CFLAGS          = -g $(NEWSFILE) $(VARIABLES)
  HDRS            = extern.h faces.h patchlevel.h
  IMAGES          = bounced.icon noface.icon nomail.icon \
                    noprint.icon nopaper.icon
  
! PSLIBS          = $$NEWSHOME/lib/libcps.a
! PSOBJS          = get.o main.o mon.o news.o rec.o
! PSSRCS          = get.c main.c mon.c news.c rec.c
  
! SVLIBS          = -lsuntool -lsunwindow -lpixrect
! SVOBJS          = get.o main.o mon.o rec.o sunview.o
! SVSRCS          = get.c main.c mon.c rec.c sunview.c
  
+ OTHERS          = faces.1 faces.ps Makefile README
+ SRCS            = get.c main.c mon.c news.c rec.c sunview.c
+ 
  all:            $(BINARIES)
  
! news:           ps_faces
! 		cp ps_faces faces
  
+ sunview:        sv_faces
+ 		cp sv_faces faces
+ 
+ ps_faces:       $(PSOBJS)
+ 		cc -o ps_faces $(CFLAGS) $(PSOBJS) $(PSLIBS)
+ 
+ sv_faces:       $(SVOBJS)
+ 		cc -o sv_faces $(CFLAGS) $(SVOBJS) $(SVLIBS)
+ 
  install:        $(BINARIES)
  		install -s -m 751 faces $(BINDIR)
+ 		install -c -m 644 faces.ps $(LIBDIR)
  		install -c -m 644 faces.1 $(MANDIR)/faces.$(MANSECT)
  
  backup:;	cp $(SRCS) $(HDRS) $(IMAGES) $(OTHERS) backdir
***************
*** 85,91 ****
  
  clean:;         rm -f *.o $(BINARIES) faces core
  
! lint:;          lint $(SRCS) $(LIBS)
  
  shar:;          shar.script $(SRCS) > archive.1
  		shar.script $(HDRS) $(IMAGES) $(OTHERS) > archive.2
--- 107,114 ----
  
  clean:;         rm -f *.o $(BINARIES) faces core
  
! lint:;          lint $(CFLAGS) $(PSSRCS) $(PSLIBS)
! 		lint $(CFLAGS) $(SVOBJS) $(SVLIBS)
  
  shar:;          shar.script $(SRCS) > archive.1
  		shar.script $(HDRS) $(IMAGES) $(OTHERS) > archive.2
***************
*** 93,97 ****
--- 116,121 ----
  get.o:          get.c faces.h extern.h patchlevel.h
  main.o:         main.c faces.h Makefile
  mon.o:          mon.c faces.h extern.h
+ news.o:         news.c faces.h extern.h
  rec.o:          rec.c faces.h extern.h
  sunview.o:      sunview.c extern.h $(IMAGES)
*** original/extern.h	Wed Aug 10 19:03:30 1988
--- extern.h	Mon Aug 22 10:17:38 1988
***************
*** 38,45 ****
  
  extern int bounced ;       /* Number of bounced MAILER-DAEMONS. */
  extern int column ;        /* Column number for next icon. */
! extern int dontshowno ;    /* Set if number of messages is to be shown. */
! extern int dontshowtime ;  /* Set if timestamp for new mail is to be shown. */
  extern int height ;        /* Height in pixels of faces display. */
  extern int interval ;      /* Interval in seconds for checking new mail. */
  extern int noicons ;       /* Number of faces this time around. */
--- 38,46 ----
  
  extern int bounced ;       /* Number of bounced MAILER-DAEMONS. */
  extern int column ;        /* Column number for next icon. */
! extern int dontshowno ;    /* Indicates if number of messages should be displayed. */
! extern int dontshowtime ;  /* Indicates if timestamp for new mail should be shown. */
! extern int dontshowuser ;  /* Indicates if username for new mail should be shown. */
  extern int height ;        /* Height in pixels of faces display. */
  extern int interval ;      /* Interval in seconds for checking new mail. */
  extern int noicons ;       /* Number of faces this time around. */
*** original/faces.1	Wed Aug 10 19:03:09 1988
--- faces.1	Mon Aug 22 10:24:08 1988
***************
*** 34,39 ****
--- 34,42 ----
  .B \-t
  ]
  [
+ .B \-u
+ ]
+ [
  .B \-v
  ]
  [
***************
*** 142,147 ****
--- 145,155 ----
  Do not display a timestamp of the last message from this person. The
  default is to display, and a timestamp is shown at the bottom left
  corner of the face for this person.
+ .TP
+ .B \-u
+ Do not display the username on the face icon. The default is to display,
+ and the username will appear over the face icon, when the window is
+ opened.
  .TP
  .B \-v
  Print the version number of this release of the
*** original/faces.h	Wed Aug 10 19:03:16 1988
--- faces.h	Wed Aug 17 13:37:16 1988
***************
*** 24,33 ****
--- 24,36 ----
  #include <strings.h>
  
  #define  FCLOSE      (void) fclose      /* To make lint happy. */
+ #define  FFLUSH      (void) fflush
  #define  FGETS       (void) fgets
  #define  FPRINTF     (void) fprintf
  #define  FSEEK       (void) fseek
+ #define  LOAD_ICON   (void) load_icon
  #define  PRINTF      (void) printf
+ #define  SIGNAL      (void) signal
  #define  SSCANF      (void) sscanf
  #define  SPRINTF     (void) sprintf
  #define  STAT        (void) stat
***************
*** 34,39 ****
--- 37,43 ----
  #define  STRCAT      (void) strcat
  #define  STRCPY      (void) strcpy
  #define  STRNCAT     (void) strncat
+ #define  STRNCPY     (void) strncpy
  #define  UNLINK      (void) unlink
  
  /* The types of display. */
*** original/get.c	Fri Aug 12 21:24:09 1988
--- get.c	Mon Aug 22 10:15:10 1988
***************
*** 77,82 ****
--- 77,83 ----
    extern char *optarg ;
    int c ;
    char *optlist = "P:af:h:i:ns:tvW:" ;
+   char *p ;
  
    while ((c = getopt(argc, argv, optlist)) != EOF)
      switch (c)
***************
*** 84,90 ****
          case 'P' : mtype = MONPRINTER ;       /* Monitor printer queue. */
                     STRCPY(printer, optarg) ;
                     break ;
-         case 'W' : break ;
          case 'a' : mtype = MONALL ;           /* Monitor the whole of the spoolfile. */
                     break ;
          case 'f' : STRCPY(facedir, optarg) ;  /* Different directory for face icons. */
--- 85,90 ----
***************
*** 99,108 ****
                     break ;
          case 't' : dontshowtime = 1 ;         /* Do not show timestamps. */
                     break ;
          case 'v' : FPRINTF(stderr, "%s version 1.0.%1d\n", progname, PATCHLEVEL) ;
                     exit(1) ;
          default  : FPRINTF(stderr, "Usage: %s [-P printer] [-f facedir] [-h defhost] ", progname) ;
!                    FPRINTF(stderr, "[-i interval] [-n] [-s spoolfile] [-t] [-v] [-?]\n") ;
                     exit(1) ;
        }
  }
--- 99,149 ----
                     break ;
          case 't' : dontshowtime = 1 ;         /* Do not show timestamps. */
                     break ;
+         case 'u' : dontshowuser = 1 ;         /* Do not show usernames. */
+                    break ;
          case 'v' : FPRINTF(stderr, "%s version 1.0.%1d\n", progname, PATCHLEVEL) ;
                     exit(1) ;
+ 
+ /*  Skip over all the Windowing arguments, like -Wp 123 456.
+  *  In theory you can have create_window() strip them by using
+  *  FRAME_ARGC_PTR_ARGV, but in this program we have to parse command
+  *  line options before we create the first window, so we know which
+  *  icon to use!
+  *  So we fake it using getopt, but it makes no attempt to handle the
+  *  -long_verbose_form flags.
+  */
+ 
+         case 'W' : switch(*optarg)
+                      {
+                        case 'H' :           /* -WH, no sub-args follow */
+                        case 'i' :           /* -Wi, no sub-args follow */
+                        case 'g' :           /* -Wg, set default color. */
+                        case 'n' : break ;   /* -Wn, no label at all */
+                        case 'h' :           /* height */
+                        case 'I' :           /* -WI "icon filename" */
+                        case 'l' :           /* -Wl "some window label" */
+                        case 'L' :           /* -Wl "some icon label" */
+                        case 't' :           /* Font filename */
+                        case 'T' :           /* Icon font filename */
+                        case 'w' : argc-- ;  /* Width, in columns. */
+                                   argv++ ;
+                                   break ;
+                        case 'p' :           /* -W[spP] xnum ynum */
+                        case 's' :
+                        case 'P' : argc -= 2 ;
+                                   argv += 2 ;
+                                   break ;
+                        case 'b' :           /* -Wb r g b (bg color spec) */
+                        case 'f' : argc -= 3 ;  /* Same, fg color */
+                                   argv += 3 ;
+                                   break ;
+                        default :  FPRINTF(stderr,"%s: unknown -W argument in %s\n",
+                                                  progname, p) ;
+                                   break ;
+                      }
+                    break ;
          default  : FPRINTF(stderr, "Usage: %s [-P printer] [-f facedir] [-h defhost] ", progname) ;
!                    FPRINTF(stderr, "[-i interval] [-n] [-s spoolfile] [-u] [-t] [-v]\n") ;
                     exit(1) ;
        }
  }
*** original/main.c	Wed Aug 10 19:03:30 1988
--- main.c	Mon Aug 22 10:21:51 1988
***************
*** 44,51 ****
  
  int bounced ;       /* Number of bounced MAILER-DAEMONS. */
  int column ;        /* Column number for next icon. */
! int dontshowno ;    /* Set if number of messages should not be displayed. */
! int dontshowtime ;  /* Set if timestamp for new mail should be displayed. */
  int height ;        /* Height in pixels of faces display. */
  int interval ;      /* Interval in seconds for new mail check. */
  int noicons ;       /* Number of faces this time around. */
--- 44,52 ----
  
  int bounced ;       /* Number of bounced MAILER-DAEMONS. */
  int column ;        /* Column number for next icon. */
! int dontshowno ;    /* Indicates if number of messages should be displayed. */
! int dontshowtime ;  /* Indicates if timestamp for new mail should be shown. */
! int dontshowuser ;  /* Indicates if username for new mail should be shown. */
  int height ;        /* Height in pixels of faces display. */
  int interval ;      /* Interval in seconds for new mail check. */
  int noicons ;       /* Number of faces this time around. */
***************
*** 62,67 ****
--- 63,73 ----
    STRCPY(progname,argv[0]) ;    /* Save this programs name. */
    initialise() ;                /* Set default values for various options. */
    get_options(argc,argv) ;      /* Read and process command line options. */
+   if (init_ws_type())           /* Determine window system type. */
+     {
+       FPRINTF(stderr,"Error initialising window system.\n") ;
+       exit(1) ;
+     }
    make_icon() ;                 /* Create default faces icon. */
    make_frame(argc,argv) ;       /* Create faces window/icon. */
    do_check() ;                  /* Generate initial faces display. */
***************
*** 119,124 ****
--- 125,136 ----
  #else
    dontshowtime = 0 ;         /* Show time stamp for new mail for this face. */
  #endif DONTSHOWTIME
+ 
+ #ifdef DONTSHOWUSER
+   dontshowuser = DONTSHOWUSER ;    /* If nonzero, do not show username. */
+ #else
+   dontshowuser = 0 ;         /* Show username on the face icons. */
+ #endif DONTSHOWUSER
  }
  
  
*** original/mon.c	Wed Aug 10 19:03:09 1988
--- mon.c	Mon Aug 22 10:28:47 1988
***************
*** 187,193 ****
            else add_face(WINDOW, NOFACE, "") ;
            SPRINTF(nextline, "%1d", this->size) ;
            text(WINDOW, BOTTOMRIGHT, nextline) ;    /* Size of print job. */
!           text(WINDOW, TOPLEFT, this->username) ;  /* Owner of print job. */
            if (this == recs)
              {
                if (!stat(this->iconname,&buf))
--- 187,194 ----
            else add_face(WINDOW, NOFACE, "") ;
            SPRINTF(nextline, "%1d", this->size) ;
            text(WINDOW, BOTTOMRIGHT, nextline) ;    /* Size of print job. */
!           if (!dontshowuser)
!             text(WINDOW, TOPLEFT, this->username) ;  /* Owner of print job. */
            if (this == recs)
              {
                if (!stat(this->iconname,&buf))
***************
*** 223,229 ****
      }
    else
      {
!       height = r * ICONHEIGHT ;         /* Height of the icon display. */
        width = NO_PER_ROW * ICONWIDTH ;  /* Yes: full width. */
      }
    create_pixrects() ;          /* Create the new memory pixrects. */
--- 224,230 ----
      }
    else
      {
!       height = (r+1) * ICONHEIGHT ;     /* Height of the icon display. */
        width = NO_PER_ROW * ICONWIDTH ;  /* Yes: full width. */
      }
    create_pixrects() ;          /* Create the new memory pixrects. */
***************
*** 272,278 ****
              {
                add_face(BOTH, ORDINARY, this->iconname) ;
                add_params(this->total, this->ts) ;
!               text(WINDOW, TOPLEFT, this->username) ;
                ADJUST ;
              }
            last = this ;
--- 273,279 ----
              {
                add_face(BOTH, ORDINARY, this->iconname) ;
                add_params(this->total, this->ts) ;
!               if (!dontshowuser) text(WINDOW, TOPLEFT, this->username) ;
                ADJUST ;
              }
            last = this ;
*** original/sunview.c	Wed Aug 10 19:03:30 1988
--- sunview.c	Mon Aug 22 10:13:12 1988
***************
*** 12,18 ****
   * 
   *  Version 1.1 - July 1988.
   *
!  *  No responsibility is taken for any errors on inaccuracies inherent
   *  either to the comments or the code of this program, but if reported
   *  to me, then an attempt will be made to fix them.
   */
--- 12,18 ----
   * 
   *  Version 1.1 - July 1988.
   *
!  *  No responsibility is taken for any errors or inaccuracies inherent
   *  either to the comments or the code of this program, but if reported
   *  to me, then an attempt will be made to fix them.
   */
***************
*** 154,159 ****
--- 154,165 ----
  }
  
  
+ init_ws_type()
+ {
+   return 0 ;
+ }
+ 
+ 
  make_frame(argc,argv)
  int argc ;
  char *argv[] ;
***************
*** 164,170 ****
                          FRAME_SUBWINDOWS_ADJUSTABLE, FALSE,
                          FRAME_NO_CONFIRM, TRUE,
                          FRAME_ARGS, argc,argv,
-                         FRAME_CLOSED, TRUE,
                          0) ;
    canvas = window_create(frame, CANVAS, CANVAS_RETAINED, TRUE, 0) ;
    pw = canvas_pixwin(canvas) ;
--- 170,175 ----