home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume20 / xmps / part03 < prev    next >
Encoding:
Text File  |  1993-06-14  |  25.5 KB  |  962 lines

  1. Newsgroups: comp.sources.x
  2. From: jjm@hplb.hpl.hp.com (Jean-Jacques Moreau)
  3. Subject: v20i028:  xmps - Motif process monitor, Part03/03
  4. Message-ID: <1993Jun15.140937.17117@sparky.imd.sterling.com>
  5. X-Md4-Signature: 61b1c64b20828928881a15fd32b4e875
  6. Sender: chris@sparky.imd.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Tue, 15 Jun 1993 14:09:37 GMT
  9. Approved: chris@sparky.imd.sterling.com
  10.  
  11. Submitted-by: jjm@hplb.hpl.hp.com (Jean-Jacques Moreau)
  12. Posting-number: Volume 20, Issue 28
  13. Archive-name: xmps/part03
  14. Environment: HP-UX, X11. OSF/Motif
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then feed it
  18. # into a shell via "sh file" or similar.  To overwrite existing files,
  19. # type "sh file -c".
  20. # Contents:  Makefile.std TODO XmPs.ad cursor.c error.c exit.c option.c
  21. #   options.h patchlevel.h print.c timer.c util.c xutil.c
  22. # Wrapped by chris@sparky on Tue Jun 15 08:52:05 1993
  23. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 3 (of 3)."'
  26. if test -f 'Makefile.std' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'Makefile.std'\"
  28. else
  29.   echo shar: Extracting \"'Makefile.std'\" \(1298 characters\)
  30.   sed "s/^X//" >'Makefile.std' <<'END_OF_FILE'
  31. X#
  32. X# Define rules
  33. X#
  34. X
  35. X
  36. X.c.o:
  37. X    -$(RM) $@
  38. X    $(CC) -c $(CFLAGS) $< -o $@
  39. X
  40. X#
  41. X
  42. X.c:
  43. X    -$(RM) $@
  44. X    $(CC) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
  45. X
  46. X#
  47. X# Define objects needed to build this program
  48. X#
  49. XCC= cc
  50. XOBJS= xmps.o process.o search.o snapshot.o print.o status.o format.o \
  51. X      option.o cursor.o timer.o error.o exit.o command.o xutil.o util.o
  52. XPROGRAM= xmps
  53. X
  54. X#
  55. X# Define build flags
  56. X#
  57. XINCLUDES= -I/usr/include/X11R5 -I/usr/include/Motif1.2
  58. XCFLAGS = -O -DSYSV $(INCLUDES)
  59. XLDFLAGS= -L /usr/lib/X11R5 -L /usr/lib/Motif1.2
  60. XLIBS= -lXm -lXt -lX11
  61. X
  62. X#
  63. X# Define installation flags
  64. X#
  65. XRM= rm -f
  66. XRMDIR= rmdir
  67. X
  68. XINSTALL_BIN_DIR= /usr/local/bin/X11
  69. XINSTALL_MAN_DIR= /usr/local/man/man1
  70. XINSTALL_XDEFAULT_DIR= /usr/lib/X11/app-defaults
  71. X
  72. X
  73. Xall:: $(PROGRAM)
  74. Xclean:: clean.local 
  75. Xinstall:: do.install
  76. Xuninstall:: clean.install
  77. X
  78. X
  79. Xxmps: $(OBJS)
  80. X    -$(RM) $@
  81. X    $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
  82. X
  83. X
  84. Xclean.local:
  85. X    -$(RM) a.out core *.o $(PROGRAMS)
  86. X
  87. Xclean.install:
  88. X    -$(RM) $(INSTALL_BIN_DIR)/$(PROGRAM)
  89. X    -$(RM) $(INSTALL_MAN_DIR)/$(PROGRAM).1
  90. X    -$(RM) $(INSTALL_XDEFAULT_DIR)/XmPs
  91. X
  92. X
  93. Xdo.install::
  94. X    install -f $(INSTALL_BIN_DIR) $(PROGRAM) `pwd`
  95. X    -cp $(PROGRAM).man $(PROGRAM).1
  96. X    install -f $(INSTALL_MAN_DIR) $(PROGRAM).man `pwd`
  97. X    -$(RM) $(PROGRAM).1
  98. X    -cp XmPs.ad XmPs
  99. X    install -f $(INSTALL_XDEFAULT_DIR) XmPs `pwd`
  100. X    -$(RM) XmPs
  101. END_OF_FILE
  102.   if test 1298 -ne `wc -c <'Makefile.std'`; then
  103.     echo shar: \"'Makefile.std'\" unpacked with wrong size!
  104.   fi
  105.   # end of 'Makefile.std'
  106. fi
  107. if test -f 'TODO' -a "${1}" != "-c" ; then 
  108.   echo shar: Will not clobber existing file \"'TODO'\"
  109. else
  110.   echo shar: Extracting \"'TODO'\" \(415 characters\)
  111.   sed "s/^X//" >'TODO' <<'END_OF_FILE'
  112. X
  113. X                XMPS TODO LIST
  114. X                   ----------------
  115. X
  116. X
  117. XTo do
  118. X-----
  119. XThe following things could be done to enhance XmPs :
  120. X   
  121. X * add the ability to create a new process view without having to run XmPs
  122. X   twice (i.e. store all global variables in a single, per application
  123. X   context, structure);
  124. X
  125. X * add a SaveToFile button to the snapshot windows;
  126. X   
  127. X * disable completely the selection capacity of the snapshot windows;
  128. END_OF_FILE
  129.   if test 415 -ne `wc -c <'TODO'`; then
  130.     echo shar: \"'TODO'\" unpacked with wrong size!
  131.   fi
  132.   # end of 'TODO'
  133. fi
  134. if test -f 'XmPs.ad' -a "${1}" != "-c" ; then 
  135.   echo shar: Will not clobber existing file \"'XmPs.ad'\"
  136. else
  137.   echo shar: Extracting \"'XmPs.ad'\" \(329 characters\)
  138.   sed "s/^X//" >'XmPs.ad' <<'END_OF_FILE'
  139. X!XmPs*hosts:                localhost,anotherhost
  140. X!XmPs*actions:                kill,kill -TERM,kill -KILL
  141. X
  142. XXmPs*geometry:                =620x420
  143. XXmPs*processArea*fontList:        -*-prestige-medium-r-normal-*-120-*
  144. X
  145. XXmPs*snapshotTopWindow.snapshotButtonArea*height: 100
  146. X
  147. X!XmPs*psCommand:            /bin/ps
  148. X!XmPs*beautifyCommand:            /usr/local/bin/pspp
  149. X!XmPs*rshCommand:            remsh
  150. END_OF_FILE
  151.   if test 329 -ne `wc -c <'XmPs.ad'`; then
  152.     echo shar: \"'XmPs.ad'\" unpacked with wrong size!
  153.   fi
  154.   # end of 'XmPs.ad'
  155. fi
  156. if test -f 'cursor.c' -a "${1}" != "-c" ; then 
  157.   echo shar: Will not clobber existing file \"'cursor.c'\"
  158. else
  159.   echo shar: Extracting \"'cursor.c'\" \(423 characters\)
  160.   sed "s/^X//" >'cursor.c' <<'END_OF_FILE'
  161. X#include <X11/Xlib.h>
  162. X#include <X11/cursorfont.h>
  163. X#include <Xm/Xm.h>
  164. X
  165. X#include "xmps.h"
  166. X
  167. X
  168. Xvoid setCursor (widget, newCursor)
  169. X     Widget widget;
  170. X     Cursor newCursor;
  171. X{
  172. X     XDefineCursor (XtDisplay (widget), XtWindow (widget), newCursor);
  173. X     XFlush (XtDisplay(widget));
  174. X}
  175. X
  176. X
  177. Xvoid setBusyIndicator ()
  178. X{
  179. X     setCursor (topLevel, busyCursor);
  180. X}
  181. X
  182. X
  183. Xvoid unsetBusyIndicator ()
  184. X{
  185. X     setCursor (topLevel, (Cursor) NULL);
  186. X}
  187. X
  188. X
  189. END_OF_FILE
  190.   if test 423 -ne `wc -c <'cursor.c'`; then
  191.     echo shar: \"'cursor.c'\" unpacked with wrong size!
  192.   fi
  193.   # end of 'cursor.c'
  194. fi
  195. if test -f 'error.c' -a "${1}" != "-c" ; then 
  196.   echo shar: Will not clobber existing file \"'error.c'\"
  197. else
  198.   echo shar: Extracting \"'error.c'\" \(1885 characters\)
  199.   sed "s/^X//" >'error.c' <<'END_OF_FILE'
  200. X#include <Xm/Xm.h>
  201. X#include <Xm/XmStrDefs.h>
  202. X
  203. X#include <stdio.h>
  204. X#include <stdlib.h>
  205. X#include <string.h>
  206. X#include <varargs.h>
  207. X
  208. X#include "xmps.h"
  209. X
  210. X
  211. Xint destroyErrorDialog (widget, unused, callData)
  212. X     Widget widget;
  213. X     int unused;
  214. X     caddr_t callData;
  215. X{
  216. X     XtDestroyWidget (widget);
  217. X}
  218. X
  219. X
  220. Xvoid error (va_alist)
  221. X     va_dcl
  222. X{
  223. X     Widget errorDialog;
  224. X
  225. X     va_list args;
  226. X     char *format;
  227. X     char s[512];
  228. X     XmString title;
  229. X     XmString message;
  230. X     
  231. X     Arg arglist[2];
  232. X     Cardinal i;
  233. X
  234. X      
  235. X     /*
  236. X      * We need to create a new dialog widget each time this
  237. X      * function is called, because a function may return
  238. X      * more than one error message during a single call.
  239. X      */
  240. X     title = XmStringCreateLtoR ("Error Dialog",
  241. X                 XmSTRING_DEFAULT_CHARSET);
  242. X     
  243. X     i = 0;
  244. X     XtSetArg (arglist[i], XmNdialogTitle,  title); i++;
  245. X     XtSetArg (arglist[i], XmNdialogStyle, XmDIALOG_MODELESS); i++;
  246. X     errorDialog = (Widget) XmCreateErrorDialog (topLevel, "errorDialog",
  247. X                         arglist, i);
  248. X
  249. X     XtAddCallback (errorDialog,
  250. X            XmNokCallback,
  251. X            (XtCallbackProc) destroyErrorDialog, NULL);
  252. X
  253. X     /*
  254. X      * Get rid of the Cancel and Help button.
  255. X      */
  256. X     XtUnmanageChild ((Widget) XmMessageBoxGetChild (errorDialog,
  257. X                             XmDIALOG_CANCEL_BUTTON));
  258. X     XtUnmanageChild ((Widget) XmMessageBoxGetChild (errorDialog,
  259. X                             XmDIALOG_HELP_BUTTON));
  260. X
  261. X     XmStringFree (title);
  262. X
  263. X     /*
  264. X      * Format the message.
  265. X      */
  266. X     va_start (args);
  267. X     
  268. X     format = (char *) va_arg (args, char *);
  269. X     vsprintf (s, format, args);
  270. X
  271. X     va_end (args);
  272. X     
  273. X     /*
  274. X      * Display it.
  275. X      */
  276. X     message = XmStringCreateLtoR (s, XmSTRING_DEFAULT_CHARSET);
  277. X
  278. X     i = 0;
  279. X     XtSetArg (arglist[i], XmNmessageString, message); i++;
  280. X     XtSetValues (errorDialog, arglist, i);
  281. X
  282. X     XmStringFree (message);
  283. X
  284. X     XtManageChild (errorDialog);
  285. X}
  286. END_OF_FILE
  287.   if test 1885 -ne `wc -c <'error.c'`; then
  288.     echo shar: \"'error.c'\" unpacked with wrong size!
  289.   fi
  290.   # end of 'error.c'
  291. fi
  292. if test -f 'exit.c' -a "${1}" != "-c" ; then 
  293.   echo shar: Will not clobber existing file \"'exit.c'\"
  294. else
  295.   echo shar: Extracting \"'exit.c'\" \(194 characters\)
  296.   sed "s/^X//" >'exit.c' <<'END_OF_FILE'
  297. X#include <Xm/Xm.h>
  298. X
  299. X#include <stdlib.h>
  300. X
  301. X#include "xmps.h"
  302. X
  303. X
  304. Xint exitXmPs (widget, clientData, callData)
  305. X     Widget widget;
  306. X     caddr_t clientData;
  307. X     caddr_t callData;
  308. X{
  309. X     exit (0);
  310. X}
  311. X
  312. X
  313. END_OF_FILE
  314.   if test 194 -ne `wc -c <'exit.c'`; then
  315.     echo shar: \"'exit.c'\" unpacked with wrong size!
  316.   fi
  317.   # end of 'exit.c'
  318. fi
  319. if test -f 'option.c' -a "${1}" != "-c" ; then 
  320.   echo shar: Will not clobber existing file \"'option.c'\"
  321. else
  322.   echo shar: Extracting \"'option.c'\" \(5298 characters\)
  323.   sed "s/^X//" >'option.c' <<'END_OF_FILE'
  324. X#include <Xm/Xm.h>
  325. X#include <Xm/XmStrDefs.h>
  326. X#include <Xm/ToggleBG.h>
  327. X
  328. X#include <stdio.h>
  329. X#include <stdlib.h>
  330. X#include <sys/types.h>
  331. X#include <sys/stat.h>
  332. X
  333. X#include "xmps.h"
  334. X
  335. X
  336. Xvoid verifyOptions ()
  337. X{
  338. X     struct stat ps;
  339. X
  340. X     if (stat (resources.psCommand, &ps) == -1) {
  341. X      error ("No such ps command :\n%s",
  342. X         resources.psCommand, (char *) 0);
  343. X      exit (-1);
  344. X     }
  345. X
  346. X     if (resources.beautify) {
  347. X      if (strlen (resources.beautifyCommand)) {
  348. X           struct stat pspp;
  349. X
  350. X           if (stat (resources.beautifyCommand, &pspp) == -1) {
  351. X            error ("No such beautifier :\n%s",
  352. X               resources.beautifyCommand, (char *) 0);
  353. X            resources.beautify = False;
  354. X           }
  355. X      } else
  356. X           internalBeautifier = True;
  357. X     }
  358. X     
  359. X     if (resources.fullListing && resources.longListing)
  360. X      resources.fullListing = False;
  361. X
  362. X     if (resources.noNonTerminal && ! resources.noGroupLeader)
  363. X      resources.noGroupLeader = True;
  364. X     
  365. X     if (resources.allProcesses && resources.noNonTerminal) {
  366. X      resources.noNonTerminal = False;
  367. X      resources.noGroupLeader = False;
  368. X     }
  369. X
  370. X     if (resources.allProcesses && resources.noGroupLeader)
  371. X      resources.noGroupLeader = False;
  372. X
  373. X     if (resources.periodicRefresh)
  374. X      setTimer (True);
  375. X}
  376. X
  377. X
  378. Xint changeOption (widget, menuSelected, buttonInfo)
  379. X     Widget widget;
  380. X     int menuSelected;
  381. X     XmToggleButtonCallbackStruct *buttonInfo;
  382. X{
  383. X     switch (menuSelected) {
  384. X    case MENU_AUTOMATIC_REFRESH:
  385. X      resources.automaticRefresh = buttonInfo->set;
  386. X      break;
  387. X      
  388. X    case MENU_PERIODIC_REFRESH:
  389. X      resources.periodicRefresh = buttonInfo->set;
  390. X      setTimer (buttonInfo->set);
  391. X      break;
  392. X      
  393. X    case MENU_AUTOMATIC_MEMORY:
  394. X      resources.automaticMemory = buttonInfo->set;
  395. X      break;
  396. X      
  397. X    case MENU_BEAUTIFY:
  398. X      if (buttonInfo->set == True) {
  399. X           if (!internalBeautifier) {
  400. X            struct stat pspp;
  401. X
  402. X            if (stat (resources.beautifyCommand, &pspp) == -1) {
  403. X             error ("No beautify command :\n%s",
  404. X                resources.beautifyCommand, (char *) 0);
  405. X            } else
  406. X             resources.beautify = True;
  407. X           } else
  408. X            resources.beautify = True;
  409. X      } else
  410. X           resources.beautify = False;
  411. X
  412. X      reDisplayProcessesIfNecessary ();
  413. X      break;
  414. X
  415. X    case MENU_MULTIPLE_OCCURRENCES:
  416. X      resources.multipleOccurrences = buttonInfo->set;
  417. X      break;
  418. X      
  419. X    case MENU_IGNORE_CASE:
  420. X      resources.ignoreCase = buttonInfo->set;
  421. X      break;
  422. X
  423. X    case MENU_PRINT_SELECTED:
  424. X      resources.printSelected = buttonInfo->set;
  425. X      break;
  426. X      
  427. X    case MENU_FULL_LISTING:
  428. X      if (buttonInfo->set == True) {
  429. X           resources.fullListing = True;
  430. X           resources.longListing = False;
  431. X           XmToggleButtonSetState (XtNameToWidget (viewPane,
  432. X                               "longListing"),
  433. X                       False, False);
  434. X      } else
  435. X           resources.fullListing = False;
  436. X
  437. X      reDisplayProcessesIfNecessary ();
  438. X      break;
  439. X
  440. X    case MENU_LONG_LISTING:
  441. X      if (buttonInfo->set == True) {
  442. X           resources.fullListing = False;
  443. X           resources.longListing = True;
  444. X           XmToggleButtonSetState (XtNameToWidget (viewPane,
  445. X                               "fullListing"),
  446. X                       False, False);
  447. X      } else
  448. X           resources.longListing = False;
  449. X
  450. X      reDisplayProcessesIfNecessary ();
  451. X      break;
  452. X
  453. X    case MENU_ALL_PROCESSES:
  454. X      if (buttonInfo->set == True) {
  455. X           resources.allProcesses = True;
  456. X           resources.noGroupLeader = False;
  457. X           resources.noNonTerminal = False;
  458. X           XmToggleButtonSetState (XtNameToWidget (viewPane,
  459. X                               "noGroupLeader"),
  460. X                       False, False);
  461. X           XmToggleButtonSetState (XtNameToWidget (viewPane,
  462. X                               "noNonTerminal"),
  463. X                       False, False);
  464. X           disableUser ();
  465. X           disableGroup ();
  466. X           disableTerminal ();
  467. X      } else {
  468. X           resources.allProcesses = False;
  469. X           enableUser ();
  470. X           enableGroup ();
  471. X           enableTerminal ();
  472. X      }
  473. X
  474. X      reDisplayProcessesIfNecessary ();
  475. X      break;
  476. X
  477. X    case MENU_NO_GROUP_LEADER:
  478. X      if (buttonInfo->set == True) {
  479. X           resources.allProcesses = False;
  480. X           resources.noGroupLeader = True;
  481. X           XmToggleButtonSetState (XtNameToWidget (viewPane,
  482. X                               "allProcesses"),
  483. X                       False, False);
  484. X           disableUser ();
  485. X           disableGroup ();
  486. X           disableTerminal ();
  487. X      } else {
  488. X           resources.noGroupLeader = False;
  489. X           if (resources.noNonTerminal == True) {
  490. X            resources.noNonTerminal = False;
  491. X            XmToggleButtonSetState (XtNameToWidget (viewPane,
  492. X                                "noNonTerminal"),
  493. X                        False, False);
  494. X           }
  495. X           enableUser ();
  496. X           enableGroup ();
  497. X           enableTerminal ();
  498. X      }
  499. X
  500. X      reDisplayProcessesIfNecessary ();
  501. X      break;
  502. X
  503. X    case MENU_NO_NON_TERMINAL:
  504. X      if (buttonInfo->set == True) {
  505. X           resources.allProcesses = False;
  506. X           resources.noGroupLeader = True;
  507. X           resources.noNonTerminal = True;
  508. X           XmToggleButtonSetState (XtNameToWidget (viewPane,
  509. X                               "allProcesses"),
  510. X                       False, False);
  511. X           XmToggleButtonSetState (XtNameToWidget (viewPane,
  512. X                               "noGroupLeader"),
  513. X                       True, False);
  514. X           disableUser ();
  515. X           disableGroup ();
  516. X           disableTerminal ();
  517. X      } else {
  518. X           resources.noNonTerminal = False;
  519. X           if (! resources.noGroupLeader) {
  520. X            enableUser ();
  521. X            enableGroup ();
  522. X            enableTerminal ();
  523. X           }
  524. X      }
  525. X
  526. X      reDisplayProcessesIfNecessary ();
  527. X      break;
  528. X
  529. X
  530. X    default:
  531. X      error ("Invalid menu selection :\ninternal error", (char *) 0);
  532. X      break;
  533. X     }
  534. X}
  535. X
  536. X
  537. END_OF_FILE
  538.   if test 5298 -ne `wc -c <'option.c'`; then
  539.     echo shar: \"'option.c'\" unpacked with wrong size!
  540.   fi
  541.   # end of 'option.c'
  542. fi
  543. if test -f 'options.h' -a "${1}" != "-c" ; then 
  544.   echo shar: Will not clobber existing file \"'options.h'\"
  545. else
  546.   echo shar: Extracting \"'options.h'\" \(5135 characters\)
  547.   sed "s/^X//" >'options.h' <<'END_OF_FILE'
  548. XXrmOptionDescRec xmPsOptions[] = {
  549. X     { "-hosts", "*hosts", XrmoptionSepArg, (caddr_t) "localhost" },
  550. X     { "-actions", "*actions", XrmoptionSepArg, (caddr_t) "kill" },
  551. X     { "-users", "*users", XrmoptionSepArg, (caddr_t) "all" },
  552. X     { "-groups", "*groups", XrmoptionSepArg, (caddr_t) "all" },
  553. X     { "-terminals", "*terminals", XrmoptionSepArg, (caddr_t) "" },
  554. X     { "-ps", "*psCommand", XrmoptionSepArg, (caddr_t) "/bin/ps" },
  555. X     { "-pspp", "*beautifyCommand", XrmoptionSepArg, (caddr_t) "" },
  556. X     { "-rsh", "*rshCommand", XrmoptionSepArg, (caddr_t) "remsh" },
  557. X};
  558. X
  559. XXtResource xmPsResources[] = {
  560. X     { "hosts", "Hosts", XtRString,
  561. X      sizeof (String), XtOffset (ResourceRec, hosts),
  562. X          XtRString, (caddr_t) "localhost" },
  563. X     { "actions", "Actions", XtRString,
  564. X      sizeof (String), XtOffset (ResourceRec, actions),
  565. X          XtRString, (caddr_t) "kill" },
  566. X
  567. X     { "users", "Users", XtRString,
  568. X      sizeof (String), XtOffset (ResourceRec, users),
  569. X          XtRString, (caddr_t) "all" },
  570. X     { "usersOption", "UsersOption", XtRString,
  571. X      sizeof (String), XtOffset (ResourceRec, usersOption),
  572. X          XtRString, (caddr_t) "u" },
  573. X     { "groups", "groups", XtRString,
  574. X      sizeof (String), XtOffset (ResourceRec, groups),
  575. X          XtRString, (caddr_t) "all" },
  576. X     { "groupsOption", "GroupsOption", XtRString,
  577. X      sizeof (String), XtOffset (ResourceRec, groupsOption),
  578. X          XtRString, (caddr_t) "g" },
  579. X     { "terminals", "terminals", XtRString,
  580. X      sizeof (String), XtOffset (ResourceRec, terminals),
  581. X          XtRString, (caddr_t) "" },
  582. X     { "terminalsOption", "TerminalsOption", XtRString,
  583. X      sizeof (String), XtOffset (ResourceRec, terminalsOption),
  584. X          XtRString, (caddr_t) "t" },
  585. X
  586. X     { "psCommand", "PsCommand", XtRString,
  587. X      sizeof (String), XtOffset (ResourceRec, psCommand),
  588. X          XtRString, (caddr_t) "/bin/ps" },
  589. X     { "rshCommand", "RshCommand", XtRString,
  590. X      sizeof (String), XtOffset (ResourceRec, rshCommand),
  591. X          XtRString, (caddr_t) "remsh" },
  592. X     { "printCommand", "PrintCommand", XtRString,
  593. X      sizeof (String), XtOffset (ResourceRec, printCommand),
  594. X          XtRString, (caddr_t) "lp %s" },
  595. X     { "beautifyCommand", "BeautifyCommand", XtRString,
  596. X      sizeof (String), XtOffset (ResourceRec, beautifyCommand),
  597. X          XtRString, (caddr_t) "" },
  598. X
  599. X     { "refreshPeriod", "RefreshPeriod", XtRInt,
  600. X      sizeof (int), XtOffset (ResourceRec, refreshPeriod),
  601. X          XtRString, (caddr_t) "600" },
  602. X
  603. X     { "automaticRefresh", "AutomaticRefresh", XtRBoolean,
  604. X      sizeof (Boolean), XtOffset (ResourceRec, automaticRefresh),
  605. X          XtRString, (caddr_t) "True" },
  606. X     { "periodicRefresh", "PeriodicRefresh", XtRBoolean,
  607. X      sizeof (Boolean), XtOffset (ResourceRec, periodicRefresh),
  608. X          XtRString, (caddr_t) "False" },
  609. X     { "automaticMemory", "AutomaticMemory", XtRBoolean,
  610. X      sizeof (Boolean), XtOffset (ResourceRec, automaticMemory),
  611. X          XtRString, (caddr_t) "True" },
  612. X     { "beautify", "Beautify", XtRBoolean,
  613. X      sizeof (Boolean), XtOffset (ResourceRec, beautify),
  614. X          XtRString, (caddr_t) "True" },
  615. X     { "multipleOccurrences", "MultipleOccurrences", XtRBoolean,
  616. X      sizeof (Boolean), XtOffset (ResourceRec, multipleOccurrences),
  617. X          XtRString, (caddr_t) "False" },
  618. X     { "ignoreCase", "IgnoreCase", XtRBoolean,
  619. X      sizeof (Boolean), XtOffset (ResourceRec, ignoreCase),
  620. X          XtRString, (caddr_t) "True" },
  621. X     { "printSelected", "PrintSelected", XtRBoolean,
  622. X      sizeof (Boolean), XtOffset (ResourceRec, printSelected),
  623. X          XtRString, (caddr_t) "False" },
  624. X
  625. X     { "allProcesses", "AllProcesses", XtRBoolean,
  626. X      sizeof (Boolean), XtOffset (ResourceRec, allProcesses),
  627. X          XtRString, (caddr_t) "True" },
  628. X     { "noGroupLeader", "NoGroupLeader", XtRBoolean,
  629. X      sizeof (Boolean), XtOffset (ResourceRec, noGroupLeader),
  630. X          XtRString, (caddr_t) "False" },
  631. X     { "noNonTerminal", "NoNonTerminal", XtRBoolean,
  632. X      sizeof (Boolean), XtOffset (ResourceRec, noNonTerminal),
  633. X          XtRString, (caddr_t) "False" },
  634. X
  635. X     { "allProcessesOption", "AllProcessesOption", XtRString,
  636. X      sizeof (String), XtOffset (ResourceRec, allProcessesOption),
  637. X          XtRString, (caddr_t) "e" },
  638. X     { "noGroupLeaderOption", "NoGroupLeaderOption", XtRString,
  639. X      sizeof (String), XtOffset (ResourceRec, noGroupLeaderOption),
  640. X          XtRString, (caddr_t) "d" },
  641. X     { "noNonTerminalOption", "NoNonTerminalOption", XtRString,
  642. X      sizeof (String), XtOffset (ResourceRec, noNonTerminalOption),
  643. X          XtRString, (caddr_t) "a" },
  644. X
  645. X     { "fullListing", "FullListing", XtRBoolean,
  646. X      sizeof (Boolean), XtOffset (ResourceRec, fullListing),
  647. X          XtRString, (caddr_t) "True" },
  648. X     { "longListing", "LongListing", XtRBoolean,
  649. X      sizeof (Boolean), XtOffset (ResourceRec, longListing),
  650. X          XtRString, (caddr_t) "False" },
  651. X
  652. X     { "fullListingOption", "FullListingOption", XtRString,
  653. X      sizeof (String), XtOffset (ResourceRec, fullListingOption),
  654. X          XtRString, (caddr_t) "f" },
  655. X     { "longListingOption", "LongListingOption", XtRString,
  656. X      sizeof (String), XtOffset (ResourceRec, longListingOption),
  657. X          XtRString, (caddr_t) "l" },
  658. X};
  659. X
  660. X
  661. END_OF_FILE
  662.   if test 5135 -ne `wc -c <'options.h'`; then
  663.     echo shar: \"'options.h'\" unpacked with wrong size!
  664.   fi
  665.   # end of 'options.h'
  666. fi
  667. if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  668.   echo shar: Will not clobber existing file \"'patchlevel.h'\"
  669. else
  670.   echo shar: Extracting \"'patchlevel.h'\" \(21 characters\)
  671.   sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
  672. X#define PATCHLEVEL 0
  673. END_OF_FILE
  674.   if test 21 -ne `wc -c <'patchlevel.h'`; then
  675.     echo shar: \"'patchlevel.h'\" unpacked with wrong size!
  676.   fi
  677.   # end of 'patchlevel.h'
  678. fi
  679. if test -f 'print.c' -a "${1}" != "-c" ; then 
  680.   echo shar: Will not clobber existing file \"'print.c'\"
  681. else
  682.   echo shar: Extracting \"'print.c'\" \(1649 characters\)
  683.   sed "s/^X//" >'print.c' <<'END_OF_FILE'
  684. X#include <Xm/Xm.h>
  685. X#include <Xm/XmStrDefs.h>
  686. X#include <Xm/List.h>
  687. X
  688. X#include <stdio.h>
  689. X#include <stdlib.h>
  690. X
  691. X#include "xmps.h"
  692. X
  693. X
  694. Xint printProcesses () {
  695. X     printProcessesFrom (listArea);
  696. X}
  697. X
  698. X
  699. Xvoid printProcessesFrom (listArea)
  700. X     Widget listArea;
  701. X{
  702. X     XmStringTable items;
  703. X     int itemCount;
  704. X     String line;
  705. X     int current;
  706. X
  707. X     String tempname;
  708. X     FILE *tempfile;
  709. X     char command[512];
  710. X
  711. X     Arg arglist[4];
  712. X     Cardinal i;
  713. X
  714. X     /*
  715. X      * Open a temporary file.
  716. X      */
  717. X     tempname = tmpnam (NULL);
  718. X     if ((tempfile = fopen (tempname, "w")) == NULL)
  719. X      error ("Cannot open temporary file :\n%s", 
  720. X         tempname, (char *) 0);
  721. X
  722. X     /*
  723. X      * Print the process information into the temp file.
  724. X      */
  725. X     i = 0;
  726. X     if (resources.printSelected) {
  727. X      XtSetArg (arglist[i], XmNselectedItems, &items); i++;
  728. X      XtSetArg (arglist[i], XmNselectedItemCount, &itemCount); i++;
  729. X     } else {
  730. X      XtSetArg (arglist[i], XmNitems, &items); i++;
  731. X      XtSetArg (arglist[i], XmNitemCount, &itemCount); i++;
  732. X     }
  733. X     XtGetValues (listArea, arglist, i);
  734. X
  735. X     for (current = 0; current <= itemCount-1; current++) {
  736. X      XmStringGetLtoR (items[current],
  737. X               XmSTRING_DEFAULT_CHARSET,
  738. X               &line);
  739. X      fprintf (tempfile, "%s\n", line);
  740. X      XtFree (line);
  741. X     }
  742. X
  743. X     /*
  744. X      * Print the temp file.
  745. X      */
  746. X     if (fflush (tempfile) != NULL)
  747. X      error ("Cannot flush temporary file :\n%s", 
  748. X         tempname, (char *) 0);
  749. X
  750. X     if (fclose (tempfile) != NULL)
  751. X      error ("Cannot close temporary file :\n%s",
  752. X         tempname, (char *) 0);
  753. X
  754. X     sprintf (command, resources.printCommand, tempname);
  755. X     system (command);
  756. X
  757. X     (void) unlink (tempname);
  758. X}
  759. X
  760. X
  761. END_OF_FILE
  762.   if test 1649 -ne `wc -c <'print.c'`; then
  763.     echo shar: \"'print.c'\" unpacked with wrong size!
  764.   fi
  765.   # end of 'print.c'
  766. fi
  767. if test -f 'timer.c' -a "${1}" != "-c" ; then 
  768.   echo shar: Will not clobber existing file \"'timer.c'\"
  769. else
  770.   echo shar: Extracting \"'timer.c'\" \(310 characters\)
  771.   sed "s/^X//" >'timer.c' <<'END_OF_FILE'
  772. X#include <Xm/Xm.h>
  773. X
  774. X#include "xmps.h"
  775. X
  776. X
  777. Xvoid setTimer (set)
  778. X     Boolean set;
  779. X{
  780. X     static XtIntervalId timer;
  781. X     
  782. X     if (set) {
  783. X      timer = XtAddTimeOut ((long) (resources.refreshPeriod * 1000),
  784. X                (XtTimerCallbackProc) reDisplayProcesses,
  785. X                NULL);
  786. X     } else {
  787. X      XtRemoveTimeOut (timer);
  788. X     }
  789. X}
  790. X
  791. X
  792. END_OF_FILE
  793.   if test 310 -ne `wc -c <'timer.c'`; then
  794.     echo shar: \"'timer.c'\" unpacked with wrong size!
  795.   fi
  796.   # end of 'timer.c'
  797. fi
  798. if test -f 'util.c' -a "${1}" != "-c" ; then 
  799.   echo shar: Will not clobber existing file \"'util.c'\"
  800. else
  801.   echo shar: Extracting \"'util.c'\" \(472 characters\)
  802.   sed "s/^X//" >'util.c' <<'END_OF_FILE'
  803. X#include <Xm/Xm.h>
  804. X#include <Xm/XmStrDefs.h>
  805. X
  806. X#include <stdio.h>
  807. X#include <stdlib.h>
  808. X#include <string.h>
  809. X
  810. X#include "xmps.h"
  811. X
  812. XString concat (string1, string2)
  813. X     String string1;
  814. X     String string2;
  815. X{
  816. X     String buffer;
  817. X
  818. X     buffer = (String) XtMalloc ((strlen (string1) + strlen (string2) + 1)
  819. X                 * sizeof (char));
  820. X     strcpy (buffer, string1);
  821. X     if (buffer[0] < 'a')
  822. X      buffer[0] = buffer[0] - 'A' + 'a';
  823. X     strcat (buffer, string2);
  824. X
  825. X     return (buffer);
  826. X}
  827. END_OF_FILE
  828.   if test 472 -ne `wc -c <'util.c'`; then
  829.     echo shar: \"'util.c'\" unpacked with wrong size!
  830.   fi
  831.   # end of 'util.c'
  832. fi
  833. if test -f 'xutil.c' -a "${1}" != "-c" ; then 
  834.   echo shar: Will not clobber existing file \"'xutil.c'\"
  835. else
  836.   echo shar: Extracting \"'xutil.c'\" \(1594 characters\)
  837.   sed "s/^X//" >'xutil.c' <<'END_OF_FILE'
  838. X#include <Xm/Xm.h>
  839. X#include <Xm/XmStrDefs.h>
  840. X#include <Xm/RowColumn.h>
  841. X#include <Xm/Text.h>
  842. X
  843. X#include <stdio.h>
  844. X
  845. X#include "xmps.h"
  846. X
  847. X
  848. Xvoid toggleSetState (widget, newState)
  849. X     Widget widget;
  850. X     Boolean newState;
  851. X{
  852. X     Arg arglist[2];
  853. X     Cardinal i;
  854. X     
  855. X     if (XmIsRowColumn (widget)) {
  856. X      unsigned char widgetType;
  857. X      
  858. X      i = 0;
  859. X      XtSetArg (arglist[i], XmNrowColumnType, &widgetType); i++;
  860. X      XtGetValues (widget, arglist, i);
  861. X
  862. X      if (widgetType == XmMENU_OPTION)
  863. X           widget = XmOptionButtonGadget (widget);
  864. X     }
  865. X
  866. X     if (XmIsText (widget)) {
  867. X      XmTextSetEditable (widget, newState);
  868. X      if (newState == True)
  869. X           XtMapWidget (widget);
  870. X      else
  871. X           XtUnmapWidget (widget);
  872. X     } else {
  873. X      i = 0;
  874. X      XtSetArg (arglist[i], XmNsensitive, newState); i++;
  875. X      XtSetValues (widget, arglist, i);
  876. X     }
  877. X}
  878. X
  879. X
  880. Xvoid enableUser ()
  881. X{
  882. X     toggleSetState
  883. X      (XtNameToWidget (topLevel,
  884. X               "topWindow.menuArea.userMenu"),
  885. X       True);
  886. X}
  887. X
  888. X
  889. Xvoid disableUser ()
  890. X{
  891. X     toggleSetState
  892. X      (XtNameToWidget (topLevel,
  893. X               "topWindow.menuArea.userMenu"),
  894. X       False);
  895. X}
  896. X
  897. X
  898. Xvoid enableGroup ()
  899. X{
  900. X     toggleSetState
  901. X      (XtNameToWidget (topLevel,
  902. X               "topWindow.menuArea.groupMenu"),
  903. X       True);
  904. X}
  905. X
  906. X
  907. Xvoid disableGroup ()
  908. X{
  909. X     toggleSetState
  910. X      (XtNameToWidget (topLevel,
  911. X               "topWindow.menuArea.groupMenu"),
  912. X       False);
  913. X}
  914. X
  915. X
  916. Xvoid enableTerminal ()
  917. X{
  918. X     toggleSetState
  919. X      (XtNameToWidget (topLevel,
  920. X               "topWindow.menuArea.terminalMenu"),
  921. X       True);
  922. X}
  923. X
  924. X
  925. Xvoid disableTerminal ()
  926. X{
  927. X     toggleSetState
  928. X      (XtNameToWidget (topLevel,
  929. X               "topWindow.menuArea.terminalMenu"),
  930. X       False);
  931. X}
  932. X
  933. X
  934. END_OF_FILE
  935.   if test 1594 -ne `wc -c <'xutil.c'`; then
  936.     echo shar: \"'xutil.c'\" unpacked with wrong size!
  937.   fi
  938.   # end of 'xutil.c'
  939. fi
  940. echo shar: End of archive 3 \(of 3\).
  941. cp /dev/null ark3isdone
  942. MISSING=""
  943. for I in 1 2 3 ; do
  944.     if test ! -f ark${I}isdone ; then
  945.     MISSING="${MISSING} ${I}"
  946.     fi
  947. done
  948. if test "${MISSING}" = "" ; then
  949.     echo You have unpacked all 3 archives.
  950.     rm -f ark[1-9]isdone
  951. else
  952.     echo You still must unpack the following archives:
  953.     echo "        " ${MISSING}
  954. fi
  955. exit 0
  956. exit 0 # Just in case...
  957. -- 
  958.   // chris@IMD.Sterling.COM       | Send comp.sources.x submissions to:
  959. \X/  Amiga - The only way to fly! |    sources-x@imd.sterling.com
  960.  "It's intuitively obvious to the |
  961.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  962.