home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume16 / contol3a / part01 < prev    next >
Encoding:
Text File  |  1992-03-04  |  46.2 KB  |  1,480 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!think.com!mips!msi!dcmartin
  3. From: Chuck Musciano <chuck@trantor.harris-atd.com>
  4. Subject: v16i100: contool 3.2A (Final Release), Part01/07
  5. Message-ID: <csx-16i100-contool-3.2a@uunet.UU.NET>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. Date: Thu, 5 Mar 1992 21:47:19 GMT
  10. Approved: dcmartin@msi.com
  11.  
  12. Submitted-by: Chuck Musciano <chuck@trantor.harris-atd.com>
  13. Posting-number: Volume 16, Issue 100
  14. Archive-name: contool-3.2a/part01
  15.  
  16. fixes those problems.  If you had difficulty installing 3.2, replace your
  17. sources with 3.2a and things should go much more smoothly.
  18.  
  19.      Contool is an alternative to the console windows supplied with X and
  20. Sun's OpenWindows.  It offers flexible console message filtering, including
  21. the ability to beep, flash the icon, log messages, and execute arbitrary
  22. commands upon receipt of a specific message.
  23.  
  24.      You'll need the XView 3.0 libraries to compile contool.  These libraries
  25. come with OpenWindows 3.0, and are available on the X11R5 contrib tape, and
  26. via FTP from a number of sites around the world.
  27.  
  28.      As stated, this version, 3.2a, is intended to replace version 3.2.  All
  29. subsequent patches will be made against this release, *not* against 3.2.  My
  30. apologies for any difficulties caused by the erroneous first posting.
  31.  
  32.  
  33. Chuck Musciano                ARPA  : chuck@trantor.harris-atd.com
  34. Harris Corporation             Usenet: ...!uunet!x102a!trantor!chuck
  35. PO Box 37, MS 3A/1912            AT&T  : (407) 727-6131
  36. Melbourne, FL 32902            FAX   : (407) 729-3363
  37.  
  38. A good newspaper is never good enough,
  39.     but a lousy newspaper is a joy forever.        -- Garrison Keillor
  40.  
  41. ---- Cut Here and feed the following to sh ----
  42. #!/bin/sh
  43. # This is a shell archive (produced by shar 3.49)
  44. # To extract the files from this archive, save it to a file, remove
  45. # everything above the "!/bin/sh" line above, and type "sh file_name".
  46. #
  47. # made 03/05/1992 14:41 UTC by chuck@melmac
  48. # Source directory /home/chuck/projects/release/contool/3.2
  49. #
  50. # existing files will NOT be overwritten unless -c is specified
  51. #
  52. # This is part 1 of a multipart archive                                    
  53. # do not concatenate these parts, unpack them in order with /bin/sh        
  54. #
  55. # This shar contains:
  56. # length  mode       name
  57. # ------ ---------- ------------------------------------------
  58. #  10152 -rw-r--r-- README
  59. #   1218 -rw-r--r-- Imakefile
  60. #   2303 -rw-r--r-- Makefile
  61. #   2556 -rw-r--r-- sample.filter
  62. #   2001 -rw-r--r-- about.c
  63. #   5379 -rw-r--r-- archive.c
  64. #   2165 -rw-r--r-- busy.c
  65. #  23859 -rw-r--r-- contool.c
  66. #  62728 -rw-rw-r-- contool_ui.c
  67. #   2036 -rw-r--r-- error.c
  68. #   3112 -rw-r--r-- expand.c
  69. #   2146 -rw-r--r-- filename_completion.c
  70. #  28125 -rw-r--r-- filters.c
  71. #   1926 -rw-r--r-- getopt.c
  72. #   6716 -rw-r--r-- lex.c
  73. #   3392 -rw-r--r-- load.c
  74. #   2201 -rw-r--r-- load_icon.c
  75. #   4060 -rw-r--r-- logging.c
  76. #   5391 -rw-r--r-- misc.c
  77. #   2118 -rw-r--r-- pinned_menu_notify.c
  78. #   2563 -rw-r--r-- place_dialog.c
  79. #   9038 -rw-r--r-- props.c
  80. #   3963 -rw-r--r-- regexp.c
  81. #   4316 -rw-r--r-- send_mail.c
  82. #   6340 -rw-r--r-- store.c
  83. #   2457 -rw-r--r-- contool.h
  84. #   8425 -rw-r--r-- contool_ui.h
  85. #   1647 -rw-r--r-- manifest.h
  86. #   1402 -rw-r--r-- patchlevel.h
  87. #   8184 -rw-r--r-- parse.y
  88. #  22873 -rw-r--r-- contool.man
  89. #  28621 -rw-r--r-- contool.info
  90. #   1997 -rw-r--r-- icons/default_bad.icon
  91. #   1997 -rw-r--r-- icons/default_flash.icon
  92. #   1997 -rw-r--r-- icons/default_good.icon
  93. #   1997 -rw-r--r-- icons/mask.icon
  94. #    193 -rw-r--r-- images/empty.icon
  95. #    193 -rw-r--r-- images/range.icon
  96. #    193 -rw-r--r-- images/single.icon
  97. #
  98. if test -r _shar_seq_.tmp; then
  99.     echo 'Must unpack archives in sequence!'
  100.     echo Please unpack part `cat _shar_seq_.tmp` next
  101.     exit 1
  102. fi
  103. # ============= README ==============
  104. if test -f 'README' -a X"$1" != X"-c"; then
  105.     echo 'x - skipping README (File already exists)'
  106.     rm -f _shar_wnt_.tmp
  107. else
  108. > _shar_wnt_.tmp
  109. echo 'x - extracting README (Text)'
  110. sed 's/^X//' << 'SHAR_EOF' > 'README' &&
  111. /************************************************************************/
  112. /*    Copyright 1988-1992 by Chuck Musciano and Harris Corporation    */
  113. /*                                    */
  114. /*    Permission to use, copy, modify, and distribute this software    */
  115. /*    and its documentation for any purpose and without fee is    */
  116. /*    hereby granted, provided that the above copyright notice    */
  117. /*    appear in all copies and that both that copyright notice and    */
  118. /*    this permission notice appear in supporting documentation, and    */
  119. /*    that the name of Chuck Musciano and Harris Corporation not be    */
  120. /*    used in advertising or publicity pertaining to distribution    */
  121. /*    of the software without specific, written prior permission.    */
  122. /*    Chuck Musciano and Harris Corporation make no representations    */
  123. /*    about the suitability of this software for any purpose.  It is    */
  124. /*    provided "as is" without express or implied warranty.  This     */
  125. /*    software may not be sold without the prior explicit permission    */
  126. /*    of Harris Corporation.                        */
  127. /************************************************************************/
  128. X
  129. X     Contool Version 3.2a
  130. X     
  131. X     Contool will capture and display system console messages with timestamps.
  132. It is a replacement for the standard Sun console, which is created with 
  133. "cmdtool -C".  Contool will flash its icon and beep when messages are written
  134. to the icon, so you can keep it closed on your desktop until a message arrives.
  135. You can modify this beeping and flashing behavior; see the man page for more
  136. details.
  137. X
  138. X     You can instruct contool to filter and ignore certain common console
  139. messages.  The man page explains how to create a file of filters in 
  140. ~/.contool; the included sample.filter is how my filters are set up.  You
  141. can modify this to suit yourself, and copy it to ~/.contool.
  142. X
  143. X     This version of contool will only work with Open Windows 2.0, from Sun,
  144. or the XView 2.0 libraries available via anonymous FTP from expo.lcs.mit.edu.
  145. In either case, obviously, you'll need to be running some version of X Windows.
  146. X
  147. X     There are no plans to produce a SunView version of contool 3.0.
  148. X     
  149. X     Before building contool, you need to check several site dependencies
  150. in the Makefile or the Imakefile.  These dependencies are:
  151. X
  152. X    In Makefile:
  153. X        BIN        Where the executable will go, normally
  154. X                /usr/local/bin. (Makefile only)
  155. X
  156. X        MAN        Where the man page will go, normally
  157. X                /usr/man/manl. (Makefile only)
  158. X
  159. X        MANEXT        The man page extension, usually 'l',
  160. X                for local man pages.  You may want to
  161. X                make MANDIR /usr/man/man1, in which case
  162. X                MANEXT should be '1'. (Makefile only)
  163. X
  164. X        MAILER        The full path of your system mailer.
  165. X
  166. X        ICON_PATH    Path to search (at runtime) for other
  167. X                icon files.  This path will only be used
  168. X                if the user does not have the ICON_PATH
  169. X                environment variable defined.  Should
  170. X                consist of a various directories
  171. X                separated by colons.
  172. X
  173. X        OPENWINHOME    Where you installed Open Windows.
  174. X                Alternately, where you installed the
  175. X                XView toolkit shipped with X11R4.  Must
  176. X                be a directory with a child directory
  177. X                named "include" that contains X and
  178. X                XView include files.
  179. X
  180. X        HELPDIR        Where the context-sensitive help file
  181. X                will be stored.
  182. X
  183. X        LDOPTIONS    Where ld can find your XView libraries.
  184. X                If you compile with Open Windows, the
  185. X                default value should be correct.  If you
  186. X                are using the X11 XView libraries, you
  187. X                may need to modify this value.
  188. X
  189. X        EXTRA_INCLUDES    Where cpp can find your XView include
  190. X                files.  If you compile with Open Windows,
  191. X                the default value should be correct.  If
  192. X                you are using the X11 XView toolkit, you
  193. X                may need to modify this value.
  194. X
  195. X        CFLAGS        First option, -O, dictates optimization
  196. X                level.  Change to suit your taste.  Do
  197. X                not modify or delete the -D options.
  198. X
  199. Once you have adjusted these values, run xmkmf if you are using the
  200. Imakefile, and just type "make contool" or "make install".  
  201. X
  202. X     Contool honors window command line options, described in xview(1),
  203. so you can change the default window size, icon position, etc.  We like
  204. to bring contool up closed, using "-Wi".
  205. X
  206. X     Fun with sounds: if your machine can play sounds, you can use the
  207. "Execute command with message" feature to produce all sorts of audible
  208. signals when messages arrive.  Ellery Chan here at Harris found a nifty
  209. use of sound: he plays the sound /usr/demo/SOUND/sounds/splat.au as the
  210. default action when a message arrives, and has the window open.  When a
  211. message arrives, he gets a satisfying "splat!" sound and contool appears
  212. on his screen.  If you are running on a SPARCstation (or otherwise have
  213. a copy of splat.au for your machine) give it a try.
  214. X
  215. X     Comments, bugs, to me, please.  I would be very interested in your 
  216. impressions of contool and any suggestions you might have to make it better.
  217. By the way, there are a few convenient untility routines in misc.c you might
  218. find useful in other programs you are writing.
  219. X
  220. Chuck Musciano
  221. Advanced Technology Department
  222. Harris Corporation
  223. PO Box 37, MS 3A/1912
  224. Melbourne, FL 32902
  225. (407) 727-6131
  226. chuck@trantor.harris-atd.com
  227. X
  228. ******************************** KNOWN XVIEW BUG ********************************
  229. *                                        *
  230. *      It is a known bug in XView that if you bring up a dialog box with the    *
  231. * pushpin out (the default) and display a menu without selecting an item from    *
  232. * the menu, the dialog box will be closed.  This can be demonstrated in contool    *
  233. * by bringing up the edit filters window, and displaying the "edit" menu     *
  234. * without selecting an action.                            *
  235. *                                        *
  236. *      This bug has been reported to Sun, but will not be fixed until version    *
  237. * 3.0 of XView.                                    *
  238. *                                        *
  239. *********************************************************************************
  240. X
  241. *********************************************************************************
  242. *                Change history                    *
  243. *********************************************************************************
  244. X
  245. X         1.0    20 Jun 88    Original release
  246. X         1.1    30 Jun 88    Added -p option to pop open when messages
  247. X                        arrive.  Suggested by Doug Lind
  248. X                        (lind@perron.ms.washington.edu).
  249. X                     Added alternate icon sets for more attractive
  250. X                        appearance when messages arrive.  Alternate
  251. X                        set two is from David Eckelcamp 
  252. X                        (eckelcamp@mcc.com).
  253. X                     Cleaned up Makefile.  Again, courtesy of
  254. X                        David Eckelcamp.
  255. X    2.0    23 Aug 88    Added automatic reload of filters when
  256. X                   filter file is modified.  Suggested by
  257. X                   Craig Musicant (cmusican@stanford.prime.com).
  258. X                Filter strings are now regular expressions.
  259. X                   Provided by jqj@hogg.cc.uoregon.edu.
  260. X                Reworked frame menu, based upon diffs posted
  261. X                   to sun-source@titan.rice.edu.
  262. X                Added protection from overflowing the text edit
  263. X                   window when too many messages arrive.
  264. X                Filters can now be read from any file, not
  265. X                   just ~/.contool.
  266. X    2.1    10 Feb 89    Added logging capability, courtesy of
  267. X                   Gregory Bond (gnb@melba.bby.oz.au).
  268. X    2.2    19 Sep 89    Added filter editing.
  269. X                Added icon pathname completion, courtesy of
  270. X                   Mike Arms (sandia!marms@unmvax.cs.unm.edu).
  271. X                Added moving the blinking icon to the front,
  272. X                   courtesy of Peter Lennevi
  273. X                   (etxlevi@solsta.ericsson.se).
  274. X                Changed icon loading to use ICON_PATH, and
  275. X                   supported ~ expansion, suggested by
  276. X                   Larry Virden (osu-cis!chemabs!lwv27).
  277. X                Fixed multiple message alert handling,
  278. X                   as suggested by Ellery Chan
  279. X                   (ellery@trantor.harris-atd.com).
  280. X    3.0     6 Jun 90    Ported to XView toolkit, running under
  281. X                   Open Windows 2.0.
  282. X                Reworked interface to be OPEN LOOK
  283. X                   compliant.
  284. X                Added saving of default actions to
  285. X                   filter file.
  286. X                Removed large number of command line
  287. X                   options in lieu of properties
  288. X                   dialog box.
  289. X                Added ability to associate a command
  290. X                   to be executed when a message arrives.
  291. X                Added explicit filter reset capability.
  292. X                Added the ability to print the contents
  293. X                   of the console.  Suggested by 
  294. X                   Danielle Heinzer
  295. X                   (ESC1298%ESOC.BITNET@cunyvm.cuny.edu).
  296. X                Reworked console overflow handling,
  297. X                   courtesy of Matt Cohen
  298. X                   (sysnmc@magic706.chron.com).
  299. X    3.0a    18 Oct 90    Allowed reading of 1.0 filter files.
  300. X                Fixed handling of custom default icon
  301. X                   when blinking stops.
  302. X                Tweaked Makefile slightly.
  303. X                Fixed handling of dialog boxes under
  304. X                   window managers other than olwm.
  305. X                Add Imakefile.
  306. X    3.0b     1 Nov 90    Fixed "tiny icon" bug.
  307. X                Added "About contool..." dialog.
  308. X                Source restructuring for maintainability.
  309. X    3.0c    15 Jan 91    Added -n option to prevent console
  310. X                   acquisition on startup.
  311. X                Fixed bugs in send mail dialog.
  312. X                Changed send mail "Cancel" to close window.
  313. X                Updated help for "File" button.
  314. X                Dialogs no longer come up clipped by the
  315. X                   bottom of the screen.
  316. X    3.1    24 May 91    Added syntax to support control characters
  317. X                   in filters.
  318. X                Reworked handling of "Other:" mail address.
  319. X                Added filter versions.
  320. X                Missing end patterns are now flagged.
  321. X                Contool now sets its class and name hints.
  322. X                Sending SIGUSR1 (30) to contool stops blinking,
  323. X                   suggested by Frank Peters.
  324. X                Sending SIGHUP (1) closes and reopens the log
  325. X                   file.
  326. X                Added "Apply and Save" button to filter dialog.
  327. X                Added individual message logging.
  328. X                Finally fixed overflow handling.
  329. X                Added multi-line filter timeout.
  330. X    3.1a    24 Jul 91    Added support for WIN_CMDLINE attribute,
  331. X                   from Tomas Stephanson
  332. X                   (Tomas.Stephanson@eua.ericsson.se)
  333. X                Fixed handling of messages without trailing
  334. X                   newlines, suggested by Ellery Chan
  335. X                   (ellery@trantor.harris-atd.com)
  336. X                Fixed typos in the man page
  337. X    3.2    16 Oct 91    Added -i option to allow reading messages
  338. X                   from other sources.
  339. X                Fixed minor error in abend() code.
  340. X                Fixed bug in masking alternative icons.
  341. X                Added message archiving.
  342. X                Added -f option to make contool fork after acquiring 
  343. X                   the console.
  344. X
  345. X    3.2a    27 Feb 92    Fixed minor bug in passing multi-line filters
  346. X                   to a command thanks to Michael Mealling
  347. X                   (ccoprmm@prism.gatech.edu)
  348. X                Fixed a variety of problems between the README,
  349. X                   Makefile, and Imakefile.
  350. SHAR_EOF
  351. chmod 0644 README ||
  352. echo 'restore of README failed'
  353. Wc_c="`wc -c < 'README'`"
  354. test 10152 -eq "$Wc_c" ||
  355.     echo 'README: original size 10152, current size' "$Wc_c"
  356. rm -f _shar_wnt_.tmp
  357. fi
  358. # ============= Imakefile ==============
  359. if test -f 'Imakefile' -a X"$1" != X"-c"; then
  360.     echo 'x - skipping Imakefile (File already exists)'
  361.     rm -f _shar_wnt_.tmp
  362. else
  363. > _shar_wnt_.tmp
  364. echo 'x - extracting Imakefile (Text)'
  365. sed 's/^X//' << 'SHAR_EOF' > 'Imakefile' &&
  366. # Mailer you use
  367. MAILER        = /usr/ucb/mail
  368. X
  369. # Paths to be searched for icons
  370. ICON_PATH    = .:./icons:/usr/local/images:/usr/include/images
  371. X
  372. # Where you installed Open Windows
  373. OPENWINHOME    = /usr/openwin
  374. X
  375. # Where to install the help file
  376. HELPDIR        = /usr/local/lib/help
  377. X
  378. # Where your XView libraries are installed
  379. LDOPTIONS    = -L$(OPENWINHOME)/lib
  380. X
  381. # Where your XView include files are installed
  382. EXTRA_INCLUDES    = -I$(OPENWINHOME)/include
  383. X
  384. # Fix this if you don't want optimization
  385. CFLAGS        = -O -DMAILER=\"$(MAILER)\" -DICON_PATH=\"$(ICON_PATH)\"
  386. X
  387. SRCS        = about.c archive.c busy.c contool.c contool_ui.c error.c expand.c filename_completion.c \
  388. X          filters.c getopt.c load.c load_icon.c logging.c misc.c parse.y \
  389. X          pinned_menu_notify.c place_dialog.c props.c regexp.c send_mail.c store.c
  390. X
  391. OBJS        = about.o archive.o busy.o contool.o contool_ui.o error.o expand.o filename_completion.o \
  392. X          filters.o getopt.o load.o load_icon.o logging.o misc.o parse.o \
  393. X          pinned_menu_notify.o place_dialog.o props.o regexp.o send_mail.o store.o
  394. X
  395. LOCAL_LIBRARIES = -lxview -lolgx $(XLIB)
  396. X
  397. ComplexProgramTarget(contool)
  398. X
  399. install:: install.man install.help
  400. X
  401. install.help:
  402. X    $(INSTALL) -c $(INSTMANFLAGS) contool.info $(HELPDIR)/contool.info
  403. SHAR_EOF
  404. chmod 0644 Imakefile ||
  405. echo 'restore of Imakefile failed'
  406. Wc_c="`wc -c < 'Imakefile'`"
  407. test 1218 -eq "$Wc_c" ||
  408.     echo 'Imakefile: original size 1218, current size' "$Wc_c"
  409. rm -f _shar_wnt_.tmp
  410. fi
  411. # ============= Makefile ==============
  412. if test -f 'Makefile' -a X"$1" != X"-c"; then
  413.     echo 'x - skipping Makefile (File already exists)'
  414.     rm -f _shar_wnt_.tmp
  415. else
  416. > _shar_wnt_.tmp
  417. echo 'x - extracting Makefile (Text)'
  418. sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
  419. # Where to put the executable
  420. BIN        = /usr/local/bin
  421. X
  422. # Where to put the man page
  423. MAN        = /usr/man/manl
  424. MANEXT        = l
  425. X
  426. # Mailer you use
  427. MAILER        = /usr/ucb/mail
  428. X
  429. # Paths to be searched for icons
  430. ICON_PATH    = .:./icons:/usr/local/images:/usr/include/images
  431. X
  432. # Where you installed Open Windows
  433. OPENWINHOME    = /usr/openwin
  434. X
  435. # Where to install the help file
  436. HELPDIR        = /usr/local/lib/help
  437. X
  438. # Where your XView libraries are installed
  439. LDOPTIONS    = -L$(OPENWINHOME)/lib
  440. X
  441. # Where your XView include files are installed
  442. EXTRA_INCLUDES    = -I$(OPENWINHOME)/include
  443. X
  444. # Fix this if you don't want optimization
  445. CFLAGS        = -O -DMAILER=\"$(MAILER)\" -DICON_PATH=\"$(ICON_PATH)\"
  446. X
  447. CONTOOL        = about.o archive.o busy.o contool.o contool_ui.o error.o expand.o filename_completion.o \
  448. X          filters.o getopt.o load.o load_icon.o logging.o misc.o parse.o \
  449. X          pinned_menu_notify.o place_dialog.o props.o regexp.o send_mail.o store.o
  450. X
  451. LOCAL_LIBRARIES = -lxview -lolgx -lX
  452. X
  453. .c.o:
  454. X    cc $(CFLAGS) $(EXTRA_INCLUDES) -c $<
  455. X
  456. .y.o:
  457. X    yacc $<
  458. X    cc $(CFLAGS) $(EXTRA_INCLUDES) -c -o $*.o y.tab.c
  459. X    rm y.tab.c
  460. X
  461. contool: $(CONTOOL)
  462. X    cc $(CFLAGS) $(EXTRA_INCLUDES) -o contool $(CONTOOL) $(LDOPTIONS) $(LOCAL_LIBRARIES)
  463. X
  464. install: contool $(MAN)/contool.$(MANEXT)
  465. X    cp contool $(BIN)
  466. X    chmod 755 $(BIN)/contool
  467. X    cp contool.info $(HELPDIR)
  468. X
  469. $(MAN)/contool.$(MANEXT): contool.man
  470. X    cp -p contool.man $(MAN)/contool.$(MANEXT)
  471. X
  472. clean:
  473. X    rm -f *~ *.o contool core
  474. X
  475. #dependencies
  476. X
  477. about.o: contool_ui.h manifest.h
  478. X
  479. archive.o: manifest.h contool.h contool_ui.h
  480. X
  481. busy.o: manifest.h
  482. X
  483. contool.o: manifest.h contool.h contool_ui.h icons/default_good.icon \
  484. X     icons/default_bad.icon icons/default_flash.icon icons/mask.icon
  485. X
  486. contool_ui.o: contool_ui.h
  487. X
  488. error.o: manifest.h contool_ui.h
  489. X
  490. expand.o: manifest.h
  491. X
  492. filename_completion.o: manifest.h
  493. X
  494. filters.o: manifest.h contool.h contool_ui.h images/single.icon \
  495. X     images/range.icon images/empty.icon
  496. X
  497. getopt.o: manifest.h
  498. X
  499. load.o: manifest.h contool.h contool_ui.h
  500. X
  501. load_icon.o: manifest.h
  502. X
  503. logging.o: manifest.h contool.h contool_ui.h
  504. X
  505. misc.o: manifest.h contool.h
  506. X
  507. parse.o: manifest.h contool.h lex.c
  508. X
  509. pinned_menu_notify.o: manifest.h
  510. X
  511. place_dialog.o: manifest.h
  512. X
  513. props.o: manifest.h contool.h contool_ui.h
  514. X
  515. regexp.o: manifest.h contool.h
  516. X
  517. send_mail.o: contool_ui.h manifest.h
  518. X
  519. store.o: manifest.h contool.h contool_ui.h
  520. SHAR_EOF
  521. chmod 0644 Makefile ||
  522. echo 'restore of Makefile failed'
  523. Wc_c="`wc -c < 'Makefile'`"
  524. test 2303 -eq "$Wc_c" ||
  525.     echo 'Makefile: original size 2303, current size' "$Wc_c"
  526. rm -f _shar_wnt_.tmp
  527. fi
  528. # ============= sample.filter ==============
  529. if test -f 'sample.filter' -a X"$1" != X"-c"; then
  530.     echo 'x - skipping sample.filter (File already exists)'
  531.     rm -f _shar_wnt_.tmp
  532. else
  533. > _shar_wnt_.tmp
  534. echo 'x - extracting sample.filter (Text)'
  535. sed 's/^X//' << 'SHAR_EOF' > 'sample.filter' &&
  536. version 320
  537. defaults {
  538. X   beep                 3
  539. X   command              ""
  540. X   flash                yes
  541. X   log                  yes
  542. X   open                 no
  543. X   stamp                yes
  544. X   archive              0
  545. X   good_icon            ""
  546. X   check_icon           ""
  547. X   flash_icon           ""
  548. X   print                "lpr"
  549. X   log_file             ""
  550. X   log_before_filtering no
  551. X   timestamp            10
  552. X   display              32768
  553. X   delete               1024
  554. }
  555. filters {
  556. X   {
  557. X      match   "su: chuck"
  558. X      comment "Track myself becoming super user"
  559. X      ignore  no
  560. X      beep    0
  561. X      command ""
  562. X      flash   no
  563. X      log     yes
  564. X      open    no
  565. X      stamp   yes
  566. X   }
  567. X   {
  568. X      match   "su:"
  569. X      comment "Get excited about anyone else becoming superuser"
  570. X      ignore  no
  571. X      beep    4
  572. X      command ""
  573. X      flash   no
  574. X      log     yes
  575. X      open    yes
  576. X      stamp   yes
  577. X   }
  578. X   {
  579. X      match   "Window data lock"
  580. X      to      "The offending process"
  581. X      timeout 30
  582. X      comment "Ignore spurious window system messages"
  583. X      ignore  yes
  584. X   }
  585. X   {
  586. X      match   "win ioctl number"
  587. X      comment "Ignore spurious window system messages"
  588. X      ignore  no
  589. X      beep    0
  590. X      command ""
  591. X      flash   no
  592. X      log     yes
  593. X      open    no
  594. X      stamp   yes
  595. X   }
  596. X   {
  597. X      match   "A tty window"
  598. X      to      "Its child"
  599. X      timeout 30
  600. X      comment "Ignore spurious window system messages"
  601. X      ignore  no
  602. X      beep    0
  603. X      command ""
  604. X      flash   no
  605. X      log     yes
  606. X      open    no
  607. X      stamp   yes
  608. X   }
  609. X   {
  610. X      match   "Too large a window number"
  611. X      comment "Ignore spurious window system messages"
  612. X      ignore  yes
  613. X   }
  614. X   {
  615. X      match   "NFS server"
  616. X      comment "Track NFS server message"
  617. X      ignore  no
  618. X      beep    0
  619. X      command ""
  620. X      flash   no
  621. X      log     yes
  622. X      open    no
  623. X      stamp   yes
  624. X   }
  625. X   {
  626. X      match   "yp:"
  627. X      comment "Track YP server problems"
  628. X      ignore  no
  629. X      beep    0
  630. X      command ""
  631. X      flash   no
  632. X      log     yes
  633. X      open    no
  634. X      stamp   yes
  635. X   }
  636. X   {
  637. X      match   "/usr/local/frame"
  638. X      comment "Ignore various noisy Frame messages"
  639. X      ignore  yes
  640. X   }
  641. X   {
  642. X      match   "starting maker"
  643. X      to      "maker: Finished"
  644. X      timeout 120
  645. X      comment "Ignore various noisy Frame messages"
  646. X      ignore  yes
  647. X   }
  648. X   {
  649. X      match   "maker:"
  650. X      comment "Ignore various noisy Frame messages"
  651. X      ignore  yes
  652. X   }
  653. X   {
  654. X      match   "fmprintdriver.ps: Using"
  655. X      comment "Ignore various noisy Frame messages"
  656. X      ignore  yes
  657. X   }
  658. }
  659. SHAR_EOF
  660. chmod 0644 sample.filter ||
  661. echo 'restore of sample.filter failed'
  662. Wc_c="`wc -c < 'sample.filter'`"
  663. test 2556 -eq "$Wc_c" ||
  664.     echo 'sample.filter: original size 2556, current size' "$Wc_c"
  665. rm -f _shar_wnt_.tmp
  666. fi
  667. # ============= about.c ==============
  668. if test -f 'about.c' -a X"$1" != X"-c"; then
  669.     echo 'x - skipping about.c (File already exists)'
  670.     rm -f _shar_wnt_.tmp
  671. else
  672. > _shar_wnt_.tmp
  673. echo 'x - extracting about.c (Text)'
  674. sed 's/^X//' << 'SHAR_EOF' > 'about.c' &&
  675. /************************************************************************/
  676. /*    Copyright 1987-1992 by Chuck Musciano and Harris Corporation     */
  677. /*                                    */
  678. /*    Full ownership of this software, and all rights pertaining to     */
  679. /*    the for-profit distribution of this software, are retained by     */
  680. /*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  681. /*    use this software without fee.  This software is provided "as     */
  682. /*    is" without express or implied warranty.  You may redistribute     */
  683. /*    this software, provided that this copyright notice is retained,    */
  684. /*    and that the software is not distributed for profit.  If you     */
  685. /*    wish to use this software in a profit-making venture, you must     */
  686. /*    first license this code and its underlying technology from     */
  687. /*    Harris Corporation.                         */
  688. /*                                    */
  689. /*    Bottom line: you can have this software, you can use it, you     */
  690. /*    can give it away.  You just can't sell any or all parts of it     */
  691. /*    without prior permission from Harris Corporation.         */
  692. /************************************************************************/
  693. X
  694. /************************************************************************/
  695. /*                                    */
  696. /*    about.c        display a little information window        */
  697. /*                                    */
  698. /************************************************************************/
  699. X
  700. #include    <stdio.h>
  701. #include    <sys/param.h>
  702. #include    <sys/types.h>
  703. #include    <xview/xview.h>
  704. #include    <xview/panel.h>
  705. #include    "contool_ui.h"
  706. X
  707. #include    "manifest.h"
  708. X
  709. PUBLIC    contool_base_objects    *contool_base;
  710. X
  711. PRIVATE    contool_about_objects    *dialog = NULL;
  712. X
  713. /************************************************************************/
  714. EXPORT    Menu_item    popup_about_contool(item, op)
  715. X
  716. Menu_item    item;
  717. Menu_generate    op;
  718. X
  719. {
  720. X    if (op == MENU_NOTIFY) {
  721. X       if (dialog == NULL) {
  722. X          dialog = contool_about_objects_initialize(NULL, contool_base->base);
  723. X          place_dialog(contool_base->base, dialog->about);
  724. X          }
  725. X       xv_set(dialog->about, XV_SHOW, TRUE, NULL);
  726. X       }
  727. X    return item;
  728. }
  729. SHAR_EOF
  730. chmod 0644 about.c ||
  731. echo 'restore of about.c failed'
  732. Wc_c="`wc -c < 'about.c'`"
  733. test 2001 -eq "$Wc_c" ||
  734.     echo 'about.c: original size 2001, current size' "$Wc_c"
  735. rm -f _shar_wnt_.tmp
  736. fi
  737. # ============= archive.c ==============
  738. if test -f 'archive.c' -a X"$1" != X"-c"; then
  739.     echo 'x - skipping archive.c (File already exists)'
  740.     rm -f _shar_wnt_.tmp
  741. else
  742. > _shar_wnt_.tmp
  743. echo 'x - extracting archive.c (Text)'
  744. sed 's/^X//' << 'SHAR_EOF' > 'archive.c' &&
  745. /************************************************************************/
  746. /*    Copyright 1987-1992 by Chuck Musciano and Harris Corporation     */
  747. /*                                    */
  748. /*    Full ownership of this software, and all rights pertaining to     */
  749. /*    the for-profit distribution of this software, are retained by     */
  750. /*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  751. /*    use this software without fee.  This software is provided "as     */
  752. /*    is" without express or implied warranty.  You may redistribute     */
  753. /*    this software, provided that this copyright notice is retained,    */
  754. /*    and that the software is not distributed for profit.  If you     */
  755. /*    wish to use this software in a profit-making venture, you must     */
  756. /*    first license this code and its underlying technology from     */
  757. /*    Harris Corporation.                         */
  758. /*                                    */
  759. /*    Bottom line: you can have this software, you can use it, you     */
  760. /*    can give it away.  You just can't sell any or all parts of it     */
  761. /*    without prior permission from Harris Corporation.         */
  762. /************************************************************************/
  763. X
  764. /************************************************************************/
  765. /*                                    */
  766. /*    archive.c    contool message archive manager            */
  767. /*                                    */
  768. /************************************************************************/
  769. X
  770. #include    <stdio.h>
  771. #include    <sys/param.h>
  772. #include    <sys/types.h>
  773. #include    <xview/xview.h>
  774. #include    <xview/panel.h>
  775. #include    <xview/textsw.h>
  776. X
  777. #include    "manifest.h"
  778. #include    "contool.h"
  779. #include    "contool_ui.h"
  780. X
  781. PUBLIC    contool_base_objects    *contool_base;
  782. X
  783. PRIVATE    contool_message_archive_objects    *dialog = NULL;
  784. X
  785. /************************************************************************/
  786. PRIVATE    void    stamp_archive(s)
  787. X
  788. char    *s;
  789. X
  790. {    int    t;
  791. X    char    msg[128];
  792. X
  793. X    t = time(0);
  794. X    sprintf(msg, "%s %.25s", s, ctime(&t));
  795. X    xv_set(dialog->message_archive, FRAME_LEFT_FOOTER, msg, NULL);
  796. }
  797. X
  798. /************************************************************************/
  799. EXPORT    void    reset_archive_size()
  800. X
  801. {    int    sw_len;
  802. X    char    *temp;
  803. X
  804. X    if (dialog) {
  805. X       sw_len = (int) xv_get(dialog->archive, TEXTSW_LENGTH);
  806. X       temp = (char *) malloc((unsigned) sw_len);
  807. X       xv_get(dialog->archive, TEXTSW_CONTENTS, 0, temp, sw_len);
  808. X       xv_set(dialog->archive, TEXTSW_MEMORY_MAXIMUM, defaults.max_size * 11, NULL);
  809. X       textsw_reset(dialog->archive, 0, 0);
  810. X       if (sw_len > defaults.max_size * 10)
  811. X          textsw_insert(dialog->archive, temp + sw_len - defaults.max_size * 10, defaults.max_size * 10);
  812. X       else
  813. X          textsw_insert(dialog->archive, temp, sw_len);
  814. X       free(temp);
  815. X       }
  816. }
  817. X
  818. /************************************************************************/
  819. EXPORT    void    create_archive()
  820. X
  821. {
  822. X    if (dialog == NULL) {
  823. X       dialog = contool_message_archive_objects_initialize(NULL, contool_base->base);
  824. X       place_dialog(contool_base->base, dialog->message_archive);
  825. X       reset_archive_size();
  826. X       }
  827. }
  828. X
  829. /************************************************************************/
  830. EXPORT    Menu_item    popup_archive(item, op)
  831. X
  832. Menu_item    item;
  833. Menu_generate    op;
  834. X
  835. {
  836. X    if (op == MENU_NOTIFY) {
  837. X       create_archive();
  838. X       xv_set(dialog->message_archive, XV_SHOW, TRUE, NULL);
  839. X       }
  840. X    return(item);
  841. }
  842. X
  843. /************************************************************************/
  844. EXPORT    void    clear_archive()
  845. X
  846. {
  847. X    textsw_reset(dialog->archive, 0, 0);
  848. X    stamp_archive("Archive cleared");
  849. }
  850. X
  851. /************************************************************************/
  852. EXPORT    void    print_archive()
  853. X
  854. {    int    size;
  855. X    char    *buf;
  856. X    FILE    *cmd;
  857. X
  858. X    if (is_empty(defaults.print_filter))
  859. X       error("You must specify a printer command in the Properties dialog");
  860. X    else if ((cmd = popen(defaults.print_filter, "w")) == NULL)
  861. X       error("Could not execute %s", defaults.print_filter);
  862. X    else {
  863. X       lets_get_busy(contool_base->base, TRUE, NULL);
  864. X       size = (int) xv_get(dialog->archive, TEXTSW_LENGTH);
  865. X       buf = (char *) malloc(size);
  866. X       xv_get(dialog->archive, TEXTSW_CONTENTS, 0, buf, size);
  867. X       if (fwrite(buf, 1, size, cmd) != size)
  868. X          error("Could not write console contents to printer");
  869. X       pclose(cmd);
  870. X       free(buf);
  871. X       lets_get_busy(contool_base->base, FALSE, NULL);
  872. X       }
  873. }
  874. X
  875. /************************************************************************/
  876. EXPORT    void    archive_messages()
  877. X
  878. {    int    size, first, last, sw_len;
  879. X    char    *temp, *buf;
  880. X
  881. X    create_archive();
  882. X    size = (int) xv_get(contool_base->display, TEXTSW_LENGTH);
  883. X    buf = (char *) malloc(size);
  884. X    xv_get(contool_base->display, TEXTSW_CONTENTS, 0, buf, size);
  885. X    while ((int) xv_get(dialog->archive, TEXTSW_LENGTH) + size > defaults.max_size * 10) {
  886. X       sw_len = (int) xv_get(dialog->archive, TEXTSW_LENGTH);
  887. X       first = 1;
  888. X       last = TEXTSW_INFINITY;
  889. X       if (textsw_find_bytes(dialog->archive, &first, &last, "\n<<<", 4, 0) == -1 || first == 0)
  890. X          if (textsw_find_bytes(dialog->archive, &first, &last, "\n", 1, 0) == -1 || first == 0)
  891. X             first = (defaults.delete_amount < sw_len)? defaults.delete_amount : sw_len;
  892. X       temp = (char *) malloc((unsigned) sw_len);
  893. X       xv_get(dialog->archive, TEXTSW_CONTENTS, 0, temp, sw_len);
  894. X       textsw_reset(dialog->archive, 0, 0);
  895. X       textsw_insert(dialog->archive, temp + first, sw_len - first);
  896. X       free(temp);
  897. X       }
  898. X    xv_set(dialog->archive, TEXTSW_INSERTION_POINT, TEXTSW_INFINITY, NULL);
  899. X    textsw_insert(dialog->archive, buf, size);
  900. X    free(buf);
  901. X    stamp_archive("Messages last archived");
  902. X    textsw_reset(contool_base->display, 0, 0);
  903. }
  904. SHAR_EOF
  905. chmod 0644 archive.c ||
  906. echo 'restore of archive.c failed'
  907. Wc_c="`wc -c < 'archive.c'`"
  908. test 5379 -eq "$Wc_c" ||
  909.     echo 'archive.c: original size 5379, current size' "$Wc_c"
  910. rm -f _shar_wnt_.tmp
  911. fi
  912. # ============= busy.c ==============
  913. if test -f 'busy.c' -a X"$1" != X"-c"; then
  914.     echo 'x - skipping busy.c (File already exists)'
  915.     rm -f _shar_wnt_.tmp
  916. else
  917. > _shar_wnt_.tmp
  918. echo 'x - extracting busy.c (Text)'
  919. sed 's/^X//' << 'SHAR_EOF' > 'busy.c' &&
  920. /************************************************************************/
  921. /*    Copyright 1987-1992 by Chuck Musciano and Harris Corporation     */
  922. /*                                    */
  923. /*    Full ownership of this software, and all rights pertaining to     */
  924. /*    the for-profit distribution of this software, are retained by     */
  925. /*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  926. /*    use this software without fee.  This software is provided "as     */
  927. /*    is" without express or implied warranty.  You may redistribute     */
  928. /*    this software, provided that this copyright notice is retained,    */
  929. /*    and that the software is not distributed for profit.  If you     */
  930. /*    wish to use this software in a profit-making venture, you must     */
  931. /*    first license this code and its underlying technology from     */
  932. /*    Harris Corporation.                         */
  933. /*                                    */
  934. /*    Bottom line: you can have this software, you can use it, you     */
  935. /*    can give it away.  You just can't sell any or all parts of it     */
  936. /*    without prior permission from Harris Corporation.         */
  937. /************************************************************************/
  938. X
  939. /************************************************************************/
  940. /*                                    */
  941. /*    busy.c    turn frame busy attribute on and off            */
  942. /*                                    */
  943. /************************************************************************/
  944. X
  945. #include    <stdio.h>
  946. #include    <xview/xview.h>
  947. #include    <xview/panel.h>
  948. X
  949. #include    "manifest.h"
  950. X
  951. /************************************************************************/
  952. PRIVATE    set_busy(base, busy, skip)
  953. X
  954. Frame    base;
  955. int    busy;
  956. Frame    skip;
  957. X
  958. {    Frame    subframe;
  959. X    int    i;
  960. X
  961. X    for (i = 1; subframe = (Frame) xv_get(base, FRAME_NTH_SUBFRAME, i); i++)
  962. X       if (subframe != skip)
  963. X          if (xv_get(subframe, XV_SHOW))
  964. X             xv_set(subframe, FRAME_BUSY, busy, NULL);
  965. X    xv_set(base, FRAME_BUSY, busy, NULL);
  966. }
  967. X
  968. /************************************************************************/
  969. EXPORT    lets_get_busy(base, busy, skip)
  970. X
  971. Frame    base;
  972. int    busy;
  973. Frame    skip;
  974. X
  975. {    static    int    depth = 0;
  976. X
  977. X    if (busy) {
  978. X       if (depth == 0)
  979. X          set_busy(base, TRUE, skip);
  980. X       depth++;
  981. X       }
  982. X    else if (depth > 0)
  983. X       if (--depth == 0)
  984. X          set_busy(base, FALSE, NULL);
  985. }
  986. SHAR_EOF
  987. chmod 0644 busy.c ||
  988. echo 'restore of busy.c failed'
  989. Wc_c="`wc -c < 'busy.c'`"
  990. test 2165 -eq "$Wc_c" ||
  991.     echo 'busy.c: original size 2165, current size' "$Wc_c"
  992. rm -f _shar_wnt_.tmp
  993. fi
  994. # ============= contool.c ==============
  995. if test -f 'contool.c' -a X"$1" != X"-c"; then
  996.     echo 'x - skipping contool.c (File already exists)'
  997.     rm -f _shar_wnt_.tmp
  998. else
  999. > _shar_wnt_.tmp
  1000. echo 'x - extracting contool.c (Text)'
  1001. sed 's/^X//' << 'SHAR_EOF' > 'contool.c' &&
  1002. /************************************************************************/
  1003. /*    Copyright 1987-1992 by Chuck Musciano and Harris Corporation     */
  1004. /*                                    */
  1005. /*    Full ownership of this software, and all rights pertaining to     */
  1006. /*    the for-profit distribution of this software, are retained by     */
  1007. /*    Chuck Musciano and Harris Corporation.  You are permitted to     */
  1008. /*    use this software without fee.  This software is provided "as     */
  1009. /*    is" without express or implied warranty.  You may redistribute     */
  1010. /*    this software, provided that this copyright notice is retained,    */
  1011. /*    and that the software is not distributed for profit.  If you     */
  1012. /*    wish to use this software in a profit-making venture, you must     */
  1013. /*    first license this code and its underlying technology from     */
  1014. /*    Harris Corporation.                         */
  1015. /*                                    */
  1016. /*    Bottom line: you can have this software, you can use it, you     */
  1017. /*    can give it away.  You just can't sell any or all parts of it     */
  1018. /*    without prior permission from Harris Corporation.         */
  1019. /************************************************************************/
  1020. X
  1021. /************************************************************************/
  1022. /*                                    */
  1023. /*    contool.c    main contool driver                */
  1024. /*                                    */
  1025. /************************************************************************/
  1026. X
  1027. #include    <stdio.h>
  1028. #include    <fcntl.h>
  1029. #include    <strings.h>
  1030. #include    <sys/ioctl.h>
  1031. #include    <sys/file.h>
  1032. #include    <sys/types.h>
  1033. #include    <sys/stat.h>
  1034. #include    <sys/param.h>
  1035. X
  1036. #include    <X11/Xlib.h>
  1037. #include    <X11/Xutil.h>
  1038. X
  1039. #include    <xview/xview.h>
  1040. #include    <xview/icon.h>
  1041. #include    <xview/panel.h>
  1042. #include    <xview/textsw.h>
  1043. #include    <xview/notify.h>
  1044. X
  1045. #include    "manifest.h"
  1046. #include    "contool.h"
  1047. #include    "contool_ui.h"
  1048. X
  1049. #define        update_value(old, new)        ((old) = ((new) > (old))? (new) : (old))
  1050. X
  1051. #define        INPUT_BUFFER_SIZE        4096
  1052. X
  1053. EXPORT    Attr_attribute    INSTANCE;
  1054. X
  1055. EXPORT    contool_base_objects    *contool_base;
  1056. EXPORT    char            *filter_file;
  1057. X
  1058. PUBLIC    Server_image        load_icon();
  1059. X
  1060. PRIVATE    Notify_value        blink_proc();
  1061. X
  1062. PRIVATE    short    good_bits[]  = {
  1063. #include    "icons/default_good.icon"
  1064. X                   };
  1065. PRIVATE    short    bad_bits[]   = {
  1066. #include    "icons/default_bad.icon"
  1067. X                   };
  1068. PRIVATE    short    flash_bits[] = {
  1069. #include    "icons/default_flash.icon"
  1070. X                   };
  1071. PRIVATE    short    mask_bits[] = {
  1072. #include    "icons/mask.icon"
  1073. X                   };
  1074. X
  1075. PRIVATE    char            *ct_usage = "usage: contool [-c <file>] [-f] [-i <file>] [-l] [-L <file>] [-n]\n";
  1076. X
  1077. PRIVATE    Server_image        default_good_icon, good = NULL;
  1078. PRIVATE    Server_image        default_bad_icon, bad = NULL;
  1079. PRIVATE    Server_image        default_flash_icon, flash = NULL;
  1080. PRIVATE    Server_image        icon_mask;
  1081. X
  1082. PRIVATE    int            bad_is_up;
  1083. PRIVATE    int            beep_count;
  1084. PRIVATE    int            blinking = FALSE;
  1085. PRIVATE    FILE            *command = NULL;
  1086. PRIVATE    Filter            *curr_filter = NULL;
  1087. PRIVATE    int            event_in_progress = FALSE;
  1088. PRIVATE    int            explicit_filters = FALSE;
  1089. PRIVATE    int            fork_into_background = FALSE;
  1090. PRIVATE    int            masking_works;
  1091. PRIVATE    FILE            *master = NULL;
  1092. PRIVATE    int            no_console = FALSE;
  1093. PRIVATE    int            old_time = 0;
  1094. PRIVATE    char            *program;
  1095. PRIVATE    FILE            *slave = NULL;
  1096. PRIVATE    int            filter_timeout = 0;
  1097. X
  1098. PRIVATE    struct    itimerval    timer = {{0, 500000}, {0, 500000}};
  1099. X
  1100. /************************************************************************/
  1101. /*    Manage piping console output to a command             */
  1102. /************************************************************************/
  1103. X
  1104. /************************************************************************/
  1105. PRIVATE    start_command(cmd)
  1106. X
  1107. char    *cmd;
  1108. X
  1109. {
  1110. X    if (command)
  1111. X       pclose(command);
  1112. X    if ((command = popen(cmd, "w")) == NULL)
  1113. X       internal_error("could not execute \"%s\"", cmd);
  1114. }
  1115. X
  1116. /************************************************************************/
  1117. PRIVATE    continue_command(buf)
  1118. X
  1119. char    *buf;
  1120. X
  1121. {
  1122. X    if (command)
  1123. X       fputs(buf, command);
  1124. }
  1125. X
  1126. /************************************************************************/
  1127. PRIVATE    end_command()
  1128. X
  1129. {
  1130. X    if (command)
  1131. X       pclose(command);
  1132. }
  1133. X
  1134. /************************************************************************/
  1135. /*    Some basic console utility routines                 */
  1136. /************************************************************************/
  1137. X
  1138. /************************************************************************/
  1139. PRIVATE    stop_blinking()
  1140. X
  1141. {
  1142. X    if (filter_timeout <= 0)
  1143. X       notify_set_itimer_func(contool_base->base, blink_proc, ITIMER_REAL, NULL, NULL);
  1144. X    change_icon(good, good == default_good_icon);
  1145. X    blinking = FALSE;
  1146. }
  1147. X
  1148. /************************************************************************/
  1149. EXPORT    acquire_console()
  1150. X
  1151. {
  1152. X    if (slave)
  1153. X       if (ioctl(fileno(slave), TIOCCONS, NULL) == -1)
  1154. X          abend("%s: could not attach to /dev/console", program);
  1155. }
  1156. X
  1157. /************************************************************************/
  1158. EXPORT    filters_changed()
  1159. X
  1160. {
  1161. X    curr_filter = NULL;
  1162. X    xv_set(contool_base->base, FRAME_LEFT_FOOTER, "", NULL);
  1163. X    end_command();
  1164. X    filter_timeout = 0;
  1165. X    if (!blinking && beep_count == 0)
  1166. X       notify_set_itimer_func(contool_base->base, blink_proc, ITIMER_REAL, NULL, NULL);
  1167. }
  1168. X
  1169. /************************************************************************/
  1170. EXPORT    adjust_window_limit()
  1171. X
  1172. {    int    sw_len;
  1173. X    char    *temp;
  1174. X
  1175. X    sw_len = (int) xv_get(contool_base->display, TEXTSW_LENGTH);
  1176. X    temp = (char *) malloc((unsigned) sw_len);
  1177. X    xv_get(contool_base->display, TEXTSW_CONTENTS, 0, temp, sw_len);
  1178. X    xv_set(contool_base->display, TEXTSW_MEMORY_MAXIMUM, defaults.max_size + defaults.max_size / 10, NULL);
  1179. X    textsw_reset(contool_base->display, 0, 0);
  1180. X    if (sw_len > defaults.max_size)
  1181. X       textsw_insert(contool_base->display, temp + sw_len - defaults.max_size, defaults.max_size);
  1182. X    else
  1183. X       textsw_insert(contool_base->display, temp, sw_len);
  1184. X    free(temp);
  1185. X    reset_archive_size();
  1186. }
  1187. X
  1188. /************************************************************************/
  1189. /*    Various small features                        */
  1190. /************************************************************************/
  1191. X
  1192. /************************************************************************/
  1193. EXPORT    Menu_item    print_messages(item, op)
  1194. X
  1195. Menu_item    item;
  1196. Menu_generate    op;
  1197. X
  1198. {    int    size;
  1199. X    char    *buf;
  1200. X    FILE    *cmd;
  1201. X
  1202. X    if (op == MENU_NOTIFY) {
  1203. X       if (is_empty(defaults.print_filter))
  1204. X          error("You must specify a printer command in the Properties dialog");
  1205. X       else if ((cmd = popen(defaults.print_filter, "w")) == NULL)
  1206. X          error("Could not execute %s", defaults.print_filter);
  1207. X       else {
  1208. X          lets_get_busy(contool_base->base, TRUE, NULL);
  1209. X          size = (int) xv_get(contool_base->display, TEXTSW_LENGTH);
  1210. X          buf = (char *) malloc(size);
  1211. X          xv_get(contool_base->display, TEXTSW_CONTENTS, 0, buf, size);
  1212. X          if (fwrite(buf, 1, size, cmd) != size)
  1213. X             error("Could not write console contents to printer");
  1214. X          pclose(cmd);
  1215. X          free(buf);
  1216. X          lets_get_busy(contool_base->base, FALSE, NULL);
  1217. X          }
  1218. X       }
  1219. X    return item;
  1220. }
  1221. X
  1222. /************************************************************************/
  1223. EXPORT    Menu_item    become_console(item, op)
  1224. X
  1225. Menu_item    item;
  1226. Menu_generate    op;
  1227. X
  1228. {
  1229. X    if (op == MENU_NOTIFY)
  1230. X       acquire_console();
  1231. X    return item;
  1232. }
  1233. X
  1234. /************************************************************************/
  1235. EXPORT    Menu_item    clear_messages(item, op)
  1236. X
  1237. Menu_item    item;
  1238. Menu_generate    op;
  1239. X
  1240. {
  1241. X    if (op == MENU_NOTIFY) {
  1242. X       textsw_reset(contool_base->display, 0, 0);
  1243. X       old_time = 0;
  1244. X       }
  1245. X    return item;
  1246. }
  1247. X
  1248. /************************************************************************/
  1249. EXPORT    Menu_item    reset_filter(item, op)
  1250. X
  1251. Menu_item    item;
  1252. Menu_generate    op;
  1253. X
  1254. {
  1255. X    if (op == MENU_NOTIFY)
  1256. X       filters_changed();
  1257. X    return item;
  1258. }
  1259. X
  1260. /************************************************************************/
  1261. EXPORT    Menu_item    save_to_archive(item, op)
  1262. X
  1263. Menu_item    item;
  1264. Menu_generate    op;
  1265. X
  1266. {
  1267. X    if (op == MENU_NOTIFY)
  1268. X       archive_messages();
  1269. X    return(item);
  1270. }
  1271. X
  1272. /************************************************************************/
  1273. PRIVATE    change_icon(image, use_mask)
  1274. X
  1275. Server_image    image;
  1276. int        use_mask;
  1277. X
  1278. {    Icon    icon;
  1279. X
  1280. X    icon = (Icon) xv_get(contool_base->base, FRAME_ICON);
  1281. X    xv_set(icon,
  1282. X          ICON_IMAGE, image,
  1283. X          ICON_MASK_IMAGE, NULL,
  1284. X          XV_WIDTH, (int) xv_get(image, XV_WIDTH),
  1285. X          XV_HEIGHT, (int) xv_get(image, XV_HEIGHT),
  1286. X           NULL);
  1287. X    if (masking_works && use_mask)
  1288. X       xv_set(icon, ICON_MASK_IMAGE, icon_mask, NULL);
  1289. X    xv_set(contool_base->base, FRAME_ICON, icon, NULL);
  1290. }
  1291. X
  1292. /************************************************************************/
  1293. EXPORT    update_icons()
  1294. X
  1295. {    char    msg[1024];
  1296. X
  1297. X    if (good && good != default_good_icon)
  1298. X       xv_destroy(good);
  1299. X    if (bad && bad != default_bad_icon)
  1300. X       xv_destroy(bad);
  1301. X    if (flash && flash != default_flash_icon)
  1302. X       xv_destroy(flash);
  1303. X
  1304. X    good = (defaults.good_icon == NULL)? default_good_icon : load_icon(defaults.good_icon, msg);
  1305. X    if (good == NULL) {
  1306. X       internal_error("Cannot load default \"All is well\" icon %s: %s", defaults.good_icon, msg);
  1307. X       good = default_good_icon;
  1308. X       }
  1309. X    bad = (defaults.bad_icon == NULL)? default_bad_icon : load_icon(defaults.bad_icon, msg);
  1310. X    if (bad == NULL) {
  1311. X       internal_error("Cannot load default \"Check console\" icon %s: %s", defaults.bad_icon, msg);
  1312. X       bad = default_bad_icon;
  1313. X       }
  1314. X    flash = (defaults.flash_icon == NULL)? default_flash_icon : load_icon(defaults.flash_icon, msg);
  1315. X    if (flash == NULL) {
  1316. X       internal_error("Cannot load default \"Flash\" icon %s: %s", defaults.flash_icon, msg);
  1317. X       flash = default_flash_icon;
  1318. X       }
  1319. X
  1320. X    if (!blinking)
  1321. X       change_icon(good, good == default_good_icon);
  1322. }
  1323. X
  1324. /************************************************************************/
  1325. /*    Now, filter handlers                        */
  1326. /************************************************************************/
  1327. X
  1328. /************************************************************************/
  1329. PRIVATE    internal_message(a, b, c, d, e, f)
  1330. X
  1331. int    a, b, c, d, e, f;
  1332. X
  1333. {    char    buf[1024];
  1334. X
  1335. X    sprintf(buf, a, b, c, d, e, f);
  1336. X    time_stamp();
  1337. X    write_log(buf);
  1338. X    do_insertion(buf, strlen(buf));
  1339. }
  1340. X
  1341. /************************************************************************/
  1342. PRIVATE    internal_error(a, b, c, d, e, f)
  1343. X
  1344. int    a, b, c, d, e, f;
  1345. X
  1346. {    char    buf[1024];
  1347. X
  1348. X    sprintf(buf, a, b, c, d, e, f);
  1349. X    time_stamp();
  1350. X    fprintf(stderr, "*** %s: %s\n", program, buf);
  1351. }
  1352. X
  1353. /************************************************************************/
  1354. PRIVATE    load_filters()
  1355. X
  1356. {    struct    stat    sb;
  1357. X    static    int    load_time = 0;
  1358. X
  1359. X    if (access(filter_file, R_OK) == -1) {
  1360. X       if (explicit_filters && load_time == 0) {
  1361. X          internal_error("filter file %s cannot be accessed", filter_file);
  1362. X          load_time = 1;
  1363. X          }
  1364. X       }
  1365. X    else if (stat(filter_file, &sb) == 0 && sb.st_mtime > load_time)
  1366. X       if (lex_init(filter_file)) {
  1367. X          yyparse();
  1368. X          if (!parse_errors_occured) {
  1369. X             free_list(filters);
  1370. X             free(parsed_defaults);
  1371. X             filters = parsed_filters;
  1372. X             internal_message("*** filters loaded from %s\n", filter_file);
  1373. X             load_time = sb.st_mtime;
  1374. X             }
  1375. X          }
  1376. X       else {
  1377. X          internal_error("error accessing configuration file %s", filter_file);
  1378. X          load_time = 1;
  1379. X          }
  1380. }
  1381. X
  1382. /************************************************************************/
  1383. /*    Various event handlers for the console frame            */
  1384. /************************************************************************/
  1385. X
  1386. /************************************************************************/
  1387. PRIVATE    Notify_value    blink_proc(me, which)
  1388. X
  1389. int    *me;
  1390. int    which;
  1391. X
  1392. {
  1393. X    if (event_in_progress)
  1394. X       return(NOTIFY_DONE);
  1395. X    if (beep_count > 0) {
  1396. X       window_bell(contool_base->base);
  1397. X       beep_count--;
  1398. X       }
  1399. X    if (blinking) {
  1400. X       if (bad_is_up)
  1401. X          change_icon(flash, flash == default_flash_icon);
  1402. X       else
  1403. X          change_icon(bad, bad == default_bad_icon);
  1404. X       bad_is_up = !bad_is_up;
  1405. X       }
  1406. X    if (filter_timeout > 0)
  1407. X       if (--filter_timeout <= 0)
  1408. X          filters_changed();
  1409. X    if (beep_count == 0 && !blinking && filter_timeout <= 0)
  1410. X       notify_set_itimer_func(contool_base->base, blink_proc, ITIMER_REAL, NULL, NULL);
  1411. X    return(NOTIFY_DONE);
  1412. }
  1413. X
  1414. /************************************************************************/
  1415. PRIVATE    Notify_value    close_proc(frame, event, arg, type)
  1416. X
  1417. Frame    frame;
  1418. Event    *event;
  1419. Notify_arg    arg;
  1420. Notify_event_type    type;
  1421. X
  1422. {
  1423. X    event_in_progress = TRUE;
  1424. X    if (event_action(event) == ACTION_OPEN) {
  1425. X       if (blinking)
  1426. X          stop_blinking();
  1427. X       create_archive();
  1428. X       }
  1429. X    if (event_action(event) == ACTION_CLOSE && defaults.archive_style == ARCHIVE_ON_CLOSE)
  1430. X       archive_messages();
  1431. X    event_in_progress = FALSE;
  1432. X    return(notify_next_event_func(frame, event, arg, type));
  1433. }
  1434. X
  1435. /************************************************************************/
  1436. PRIVATE    Notify_value    destroy_proc(frame, status)
  1437. X
  1438. Frame    frame;
  1439. Destroy_status    status;
  1440. X
  1441. {
  1442. X    if (status == DESTROY_CHECKING) {
  1443. X       textsw_reset(contool_base->display, 0, 0);
  1444. X       return(NOTIFY_DONE);
  1445. X       }
  1446. X    else
  1447. X       return(notify_next_destroy_func(frame, status));
  1448. }
  1449. X
  1450. /************************************************************************/
  1451. PRIVATE    Notify_value    signal_proc(frame, sig, when)
  1452. X
  1453. Frame    frame;
  1454. int    sig;
  1455. Notify_signal_mode    when;
  1456. X
  1457. {
  1458. X    if (sig == SIGUSR1)
  1459. X       stop_blinking();
  1460. X    else if (sig == SIGHUP)
  1461. X       update_logging();
  1462. X    return(NOTIFY_DONE);
  1463. }
  1464. X
  1465. /************************************************************************/
  1466. /*    Routines which handle capturing and displaying messages        */
  1467. /************************************************************************/
  1468. SHAR_EOF
  1469. true || echo 'restore of contool.c failed'
  1470. fi
  1471. echo 'End of  part 1'
  1472. echo 'File contool.c is continued in part 2'
  1473. echo 2 > _shar_seq_.tmp
  1474. exit 0
  1475. -- 
  1476. --
  1477. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  1478. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  1479. Sunnyvale, California 94086            at&t: 408/522-9236
  1480.