/************************************************************************/
/*	Copyright 1988-1994 by Chuck Musciano and Harris Corporation	*/
/*									*/
/*	Permission to use, copy, modify, and distribute this software	*/
/*	and its documentation for any purpose and without fee is	*/
/*	hereby granted, provided that the above copyright notice	*/
/*	appear in all copies and that both that copyright notice and	*/
/*	this permission notice appear in supporting documentation, and	*/
/*	that the name of Chuck Musciano and Harris Corporation not be	*/
/*	used in advertising or publicity pertaining to distribution	*/
/*	of the software without specific, written prior permission.	*/
/*	Chuck Musciano and Harris Corporation make no representations	*/
/*	about the suitability of this software for any purpose.  It is	*/
/*	provided "as is" without express or implied warranty.  This 	*/
/*	software may not be sold without the prior explicit permission	*/
/*	of Harris Corporation.						*/
/************************************************************************/

     Contool Version 3.3a
     
     Contool will capture and display system console messages with timestamps.
It is a replacement for the standard Sun console, which is created with 
"cmdtool -C".  Contool will flash its icon and beep when messages are written
to the icon, so you can keep it closed on your desktop until a message arrives.
You can modify this beeping and flashing behavior; see the man page for more
details.

     You can instruct contool to filter and ignore certain common console
messages.  The man page explains how to create a file of filters in ~/.contool;
the included sample.filter is how my filters are set up.  You can modify this
to suit yourself, and copy it to ~/.contool.

     This version of contool will only work with Open Windows 3.x, from Sun,
or the XView 3.x libraries available on the X11R5 contrib tape or via
anonymous FTP from ftp.x.org.  Regardless, you'll need to be running
some version of X Windows.

     Contool is shipped with both an Imakefile and a regular makefile named
Makefile.std.  You can use Makefile.std if you don't have or don't care to 
use xmkmf with the Imakefile.  

     Before building contool, you need to check several site dependencies
in Makefile.std or Imakefile.  The dependencies are:

	In Makefile.std:
		BIN		Where the executable will go, normally
				/usr/local/bin. (Makefile only)

		MAN		Where the man page will go, normally
				/usr/man/manl. (Makefile only)

		MANEXT		The man page extension, usually 'l',
				for local man pages.  You may want to
				make MANDIR /usr/man/man1, in which case
				MANEXT should be '1'. (Makefile only)

	In Makefile.std and Imakefile:
		MAILER		The full path of your system mailer.
				SunOS users can leave this set to 
				/usr/ucb/mail.  Solaris 2.0 and SVR4
				users should change this to /usr/bin/mailx.

		OPENWINHOME	Where you installed Open Windows.
				Alternately, where you installed the
				XView toolkit shipped with X11R4.  Must
				be a directory with a child directory
				named "include" that contains X and
				XView include files.

		ICON_PATH	Path to search (at runtime) for other
				icon files.  This path will only be used
				if the user does not have the ICON_PATH
				environment variable defined.  Should
				consist of a various directories
				separated by colons.

		HELPDIR		Where the context-sensitive help file
				will be stored.

		LDOPTIONS	Where ld can find your XView libraries.
				If you compile with Open Windows, the
				default value should be correct.  If you
				are using the X11 XView libraries, you
				may need to modify this value.  If you are
				running under SunOS 4.x, use the first
				version of LDOPTIONS.  If you are running
				under Solaris 2.0 with Sun's unbundled
				compiler, use the second version, with the
				-R option.

		EXTRA_INCLUDES	Where cpp can find your XView include
				files.  If you compile with Open Windows,
				the default value should be correct.  If
				you are using the X11 XView toolkit, you
				may need to modify this value.

		CDEBUGFLAGS	Change to suit your desired level of
				optimization.  You might add other options
				that make your local compiler happy.

		CC		Depending on your environment, you'll
		YACC		need to select one of three compilers.
		SPECIAL_DEFINES	If you are running a Sun compiler under
				under SunOS 4.x, uncomment *only* the first
				group of definitions.  If you are running
				Sun's unbundled C compiler under Solaris
				2.0, uncomment *only* the second group.
				If you are running gcc under Solaris 2.0,
				uncomment *only* the third group.  If you
				are running some other compiler, set these
				variables to match your environment.
				
		** NOTE ** --->	If you are using gcc for Solaris 2.0, you
			** --->	must fix an error in the gcc include files.
			** --->	The gcc install scripts break the regexp.h
			** --->	include file, and prevent contool from
			** --->	compiling.  You must remove regexp.h from
			** --->	the gcc include directory.  If you installed
			** --->	gcc in /opt/cygnus, you should remove
			** --->	/opt/cygnus/lib/gcc-lib/sparc-sun-solaris2/cygnus-2.0.2/include/regexp.h
			** --->	before compiling contool.
				
Once you have adjusted these values, run xmkmf if you are using the
Imakefile, and just type "make contool" or "make install".  

     Contool honors window command line options, described in xview(1),
so you can change the default window size, icon position, etc.  We like
to bring contool up closed, using "-Wi".

     Fun with sounds: if your machine can play sounds, you can use the
"Execute command with message" feature to produce all sorts of audible
signals when messages arrive.  Ellery Chan here at Harris found a nifty
use of sound: he plays the sound /usr/demo/SOUND/sounds/splat.au as the
default action when a message arrives, and has the window open.  When a
message arrives, he gets a satisfying "splat!" sound and contool appears
on his screen.  If you are running on a SPARCstation (or otherwise have
a copy of splat.au for your machine) give it a try.

     Comments, bugs, to me, please.  I would be very interested in your 
impressions of contool and any suggestions you might have to make it better.
By the way, there are a few convenient untility routines in misc.c you might
find useful in other programs you are writing.

Chuck Musciano				ARPA: chuck@trantor.harris-atd.com
Harris Corporation 			AOL : CMusciano
PO Box 37, MS 16/1912			AT&T: (407) 727-6131
Melbourne, FL 32902			Fax : (407) 729-3363

A good newspaper is never good enough,
	but a lousy newspaper is a joy forever.		-- Garrison Keillor

******************************** KNOWN XVIEW BUG ********************************
*										*
*      It is a known bug in XView that if you bring up a dialog box with the	*
* pushpin out (the default) and display a menu without selecting an item from	*
* the menu, the dialog box will be closed.  This can be demonstrated in contool	*
* by bringing up the edit filters window, and displaying the "edit" menu 	*
* without selecting an action.							*
*										*
*      This bug has been reported to Sun, but will not be fixed until version	*
* 3.0 of XView.									*
*										*
*********************************************************************************

*********************************************************************************
*				Change history					*
*********************************************************************************

     	1.0	20 Jun 88	Original release
     	1.1	30 Jun 88	Added -p option to pop open when messages
     				   arrive.  Suggested by Doug Lind
     				   (lind@perron.ms.washington.edu).
     				Added alternate icon sets for more attractive
     				   appearance when messages arrive.  Alternate
     				   set two is from David Eckelcamp 
     				   (eckelcamp@mcc.com).
     				Cleaned up Makefile.  Again, courtesy of
     				   David Eckelcamp.
	2.0	23 Aug 88	Added automatic reload of filters when
				   filter file is modified.  Suggested by
				   Craig Musicant (cmusican@stanford.prime.com).
				Filter strings are now regular expressions.
				   Provided by jqj@hogg.cc.uoregon.edu.
				Reworked frame menu, based upon diffs posted
				   to sun-source@titan.rice.edu.
				Added protection from overflowing the text edit
				   window when too many messages arrive.
				Filters can now be read from any file, not
				   just ~/.contool.
	2.1	10 Feb 89	Added logging capability, courtesy of
				   Gregory Bond (gnb@melba.bby.oz.au).
	2.2	19 Sep 89	Added filter editing.
				Added icon pathname completion, courtesy of
				   Mike Arms (sandia!marms@unmvax.cs.unm.edu).
				Added moving the blinking icon to the front,
				   courtesy of Peter Lennevi
				   (etxlevi@solsta.ericsson.se).
				Changed icon loading to use ICON_PATH, and
				   supported ~ expansion, suggested by
				   Larry Virden (osu-cis!chemabs!lwv27).
				Fixed multiple message alert handling,
				   as suggested by Ellery Chan
				   (ellery@trantor.harris-atd.com).
	3.0	 6 Jun 90	Ported to XView toolkit, running under
				   Open Windows 2.0.
				Reworked interface to be OPEN LOOK
				   compliant.
				Added saving of default actions to
				   filter file.
				Removed large number of command line
				   options in lieu of properties
				   dialog box.
				Added ability to associate a command
				   to be executed when a message arrives.
				Added explicit filter reset capability.
				Added the ability to print the contents
				   of the console.  Suggested by 
				   Danielle Heinzer
				   (ESC1298%ESOC.BITNET@cunyvm.cuny.edu).
				Reworked console overflow handling,
				   courtesy of Matt Cohen
				   (sysnmc@magic706.chron.com).
	3.0a	18 Oct 90	Allowed reading of 1.0 filter files.
				Fixed handling of custom default icon
				   when blinking stops.
				Tweaked Makefile slightly.
				Fixed handling of dialog boxes under
				   window managers other than olwm.
				Add Imakefile.
	3.0b	 1 Nov 90	Fixed "tiny icon" bug.
				Added "About contool..." dialog.
				Source restructuring for maintainability.
	3.0c	15 Jan 91	Added -n option to prevent console
				   acquisition on startup.
				Fixed bugs in send mail dialog.
				Changed send mail "Cancel" to close window.
				Updated help for "File" button.
				Dialogs no longer come up clipped by the
				   bottom of the screen.
	3.1	24 May 91	Added syntax to support control characters
				   in filters.
				Reworked handling of "Other:" mail address.
				Added filter versions.
				Missing end patterns are now flagged.
				Contool now sets its class and name hints.
				Sending SIGUSR1 (30) to contool stops blinking,
				   suggested by Frank Peters.
				Sending SIGHUP (1) closes and reopens the log
				   file.
				Added "Apply and Save" button to filter dialog.
				Added individual message logging.
				Finally fixed overflow handling.
				Added multi-line filter timeout.
	3.1a	24 Jul 91	Added support for WIN_CMDLINE attribute,
				   from Tomas Stephanson
				   (Tomas.Stephanson@eua.ericsson.se)
				Fixed handling of messages without trailing
				   newlines, suggested by Ellery Chan
				   (ellery@trantor.harris-atd.com)
				Fixed typos in the man page
	3.2	16 Oct 91	Added -i option to allow reading messages
				   from other sources.
				Fixed minor error in abend() code.
				Fixed bug in masking alternative icons.
				Added message archiving.
				Added -f option to make contool fork after acquiring 
				   the console.

	3.2a	27 Feb 92	Fixed minor bug in passing multi-line filters
				   to a command thanks to Michael Mealling
				   (ccoprmm@prism.gatech.edu)
				Fixed a variety of problems between the README,
				   Makefile, and Imakefile.

	3.2b	24 Mar 92	Fixed small problems with cond_free() and
				   ungetc to avoid compiler complaints on
				   some systems.
				Fixed a problem in the Imakefile for XView
				   include files, provided by David Bremner
				   (bremner@cs.sfu.ca).
				Fixed a bug in filter editing, found by P G Griffiths
				   (P.G.Griffiths@daresbury.ac.uk).
				Moved the regular Makefile to Makefile.std.

	3.3	 6 Nov 92	Port to Solaris 2.0
				Added support for environment variables,
				   suggested by Michael Mealling
				   (ccoprmm@prism.gatech.edu)
				Add icon masks for custom icons
				Fixed bug in opening slave ptys, found by
				   Igor Khurgin (igor@cae.wisc.edu)
				Added support for X bitmap icon files

	3.3a	24 Feb 94	Fixed bug in updating utmp when acquiring console
				   fix supplied by Greg Jumper (jumper@spf.trw.com).
				Doubled number of ptys tried for BSD version
				   suggested by Gerald Justice (justice@dao.nrc.ca).
				Catch EINTR during pty open and retry that pty.
				Updated the "About" window to describe what contool
				   actually does!

