home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sources / unix / 284 < prev    next >
Encoding:
Internet Message Format  |  1992-12-31  |  46.2 KB

  1. Path: sparky!uunet!haven.umd.edu!decuac!pa.dec.com!vixie
  2. From: boyd@prl.dec.com (Boyd Roberts)
  3. Newsgroups: comp.sources.unix
  4. Subject: v26i083: xwhosup - X11 R5 program to graphically display "rwho" activity, Part01/01
  5. Date: 31 Dec 1992 21:20:53 GMT
  6. Organization: Digital Equipment Corporation Palo Alto, CA
  7. Lines: 1777
  8. Sender: unix-sources-moderator@pa.dec.com
  9. Approved: vixie@pa.dec.com
  10. Message-ID: <1hvo7lINN7gr@usenet.pa.dec.com>
  11. NNTP-Posting-Host: cognition.pa.dec.com
  12. Originator: vixie@cognition.pa.dec.com
  13.  
  14. Submitted-By: boyd@prl.dec.com (Boyd Roberts)
  15. Posting-Number: Volume 26, Issue 84
  16. Archive-Name: xwhosup/part01
  17.  
  18. [ i totally blew it on this one the first time out.  "findsrc" doesn't seem
  19.   to like files with names like "s.h" because it left it out of the previous
  20.   kit.  also, i used the wrong name in the title.  sorry, boyd..   --vix ]
  21.  
  22. Originally:
  23.  
  24.     A snapshot performance monitor. Originally written to watch the load
  25.     distribution on the CPU's on an Silicon Graphics Iris4d/240, it can be
  26.     adapted to display a large variety of changing system statistics.
  27.     
  28.         - moraes@cs.toronto.edu (Mark Moraes)
  29.  
  30. Modified to snoop for rwhod(8) packets using Jeff Mogul's packetfilter(4)
  31. and display the 5 minute load average on a log scale, or alternating 
  32. yellow/black diagonal stripes if a host hasn't been heard from.
  33.  
  34. I have some grander plan to turn it into a general purpose resource
  35. monitor, but that'll have to wait.  For the moment I just want have
  36. some rough idea of what our machines are doing.
  37.  
  38. The X knowledgable will realise that the X code in this is pretty naive
  39. because I hate X and _refuse_ to learn about it -- what a disaster.  I just
  40. want the bits on the screen, without having to read through a pile of overly
  41. verbose and tedious documentation.  The (original) X code is Mark Moreas' work.
  42.  
  43.     - Boyd Roberts <boyd@prl.dec.com>
  44.       December '91
  45.       Digital PRL
  46.  
  47. #! /bin/sh
  48. # This is a shell archive.  Remove anything before this line, then unpack
  49. # it by saving it into a file and typing "sh file".  To overwrite existing
  50. # files, type "sh file -c".  You can also feed this as standard input via
  51. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  52. # will see the following message at the end:
  53. #        "End of archive 1 (of 1)."
  54. # Contents:  BUGS Bar.c Bar.h BarP.h COPYRIGHT MANIFEST Makefile README
  55. #   csu.diffs s-pfilt-rwho.c s.h xwhosup.1 xwhosup.c
  56. # Wrapped by vixie@cognition.pa.dec.com on Thu Dec 31 13:11:40 1992
  57. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  58. if test -f 'BUGS' -a "${1}" != "-c" ; then 
  59.   echo shar: Will not clobber existing file \"'BUGS'\"
  60. else
  61. echo shar: Extracting \"'BUGS'\" \(55 characters\)
  62. sed "s/^X//" >'BUGS' <<'END_OF_FILE'
  63. Resizing it vertically causes havoc, I'm not sure why.
  64. END_OF_FILE
  65. if test 55 -ne `wc -c <'BUGS'`; then
  66.     echo shar: \"'BUGS'\" unpacked with wrong size!
  67. fi
  68. # end of 'BUGS'
  69. fi
  70. if test -f 'Bar.c' -a "${1}" != "-c" ; then 
  71.   echo shar: Will not clobber existing file \"'Bar.c'\"
  72. else
  73. echo shar: Extracting \"'Bar.c'\" \(10785 characters\)
  74. sed "s/^X//" >'Bar.c' <<'END_OF_FILE'
  75. X#include <X11/copyright.h>
  76. X
  77. X/* $XConsortium: Bar.c,v 1.2 88/10/25 17:40:25 swick Exp $ */
  78. X/* Copyright    Massachusetts Institute of Technology    1987, 1988 */
  79. X
  80. X#include <X11/IntrinsicP.h>
  81. X#include <X11/StringDefs.h>
  82. X#include "BarP.h"
  83. X
  84. static Dimension def_dimension    = ~0;
  85. static XtOrientation def_orient = XtorientHorizontal;
  86. X#define DEF_LENGTH  ((Dimension) 200)
  87. X#define DEF_THICKNESS    ((Dimension) 15)
  88. X
  89. static XtResource resources[] = {
  90. X#define offset(field) XtOffset(BarWidget, bar.field)
  91. X#define Offset(field) XtOffset(BarWidget, field)
  92. X    /* {name, class, type, size, offset, default_type, default_addr}, */
  93. X    /*
  94. X     * We define these core class values to set defaults, so we can
  95. X     * initialize correctly
  96. X     */
  97. X    {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension),
  98. X    Offset(core.width), XtRDimension, (caddr_t)&def_dimension},
  99. X    {XtNheight, XtCHeight, XtRDimension, sizeof(Dimension),
  100. X    Offset(core.height), XtRDimension, (caddr_t)&def_dimension},
  101. X    /* Private bar widget resources */
  102. X    {XtNlength, XtCLength, XtRDimension, sizeof(Dimension),
  103. X    offset(length), XtRDimension, (caddr_t) &def_dimension},
  104. X    {XtNthickness, XtCThickness, XtRDimension, sizeof(Dimension),
  105. X    offset(thickness), XtRDimension, (caddr_t) &def_dimension},
  106. X    {XtNorientation, XtCOrientation, XtROrientation, sizeof(XtOrientation),
  107. X    offset(orientation), XtROrientation, (caddr_t) &def_orient},
  108. X#undef offset
  109. X#undef Offset
  110. X};
  111. X
  112. static void ClassInitialize();
  113. static void Initialize();
  114. static void Resize();
  115. static void Redisplay();
  116. X
  117. BarClassRec barClassRec = {
  118. X  { /* core fields */
  119. X    /* superclass        */    (WidgetClass) &widgetClassRec,
  120. X    /* class_name        */    "Bar",
  121. X    /* widget_size        */    sizeof(BarRec),
  122. X    /* class_initialize        */    ClassInitialize,
  123. X    /* class_part_initialize    */    NULL,
  124. X    /* class_inited        */    FALSE,
  125. X    /* initialize        */    Initialize,
  126. X    /* initialize_hook        */    NULL,
  127. X    /* realize            */    XtInheritRealize,
  128. X    /* actions            */    NULL,
  129. X    /* num_actions        */    0,
  130. X    /* resources        */    resources,
  131. X    /* num_resources        */    XtNumber(resources),
  132. X    /* xrm_class        */    NULLQUARK,
  133. X    /* compress_motion        */    TRUE,
  134. X    /* compress_exposure    */    TRUE,
  135. X    /* compress_enterleave    */    TRUE,
  136. X    /* visible_interest        */    FALSE,
  137. X    /* destroy            */    NULL,
  138. X    /* resize            */    Resize,
  139. X    /* expose            */    Redisplay,
  140. X    /* set_values        */    NULL,
  141. X    /* set_values_hook        */    NULL,
  142. X    /* set_values_almost    */    XtInheritSetValuesAlmost,
  143. X    /* get_values_hook        */    NULL,
  144. X    /* accept_focus        */    NULL,
  145. X    /* version            */    XtVersion,
  146. X    /* callback_private        */    NULL,
  147. X    /* tm_table            */    NULL,
  148. X    /* query_geometry        */    XtInheritQueryGeometry,
  149. X    /* display_accelerator    */    XtInheritDisplayAccelerator,
  150. X    /* extension        */    NULL
  151. X  },
  152. X  { /* bar fields */
  153. X    /* gray            */    NULL
  154. X  }
  155. X};
  156. X
  157. WidgetClass barWidgetClass = (WidgetClass)&barClassRec;
  158. X
  159. X#ifdef    UGLY_GRAYS
  160. static char gray0_bits[] = {
  161. X   0x00, 0x00, 0x00};
  162. static char gray1_bits[] = {
  163. X   0x00, 0x02, 0x00};
  164. static char gray2_bits[] = {
  165. X   0x00, 0x03, 0x00};
  166. static char gray3_bits[] = {
  167. X   0x00, 0x03, 0x02};
  168. static char gray4_bits[] = {
  169. X   0x00, 0x07, 0x02};
  170. static char gray5_bits[] = {
  171. X   0x04, 0x07, 0x02};
  172. static char gray6_bits[] = {
  173. X   0x04, 0x07, 0x03};
  174. static char gray7_bits[] = {
  175. X   0x05, 0x07, 0x03};
  176. static char gray8_bits[] = {
  177. X   0x05, 0x07, 0x07};
  178. static char gray9_bits[] = {
  179. X   0xff, 0xff, 0xff};
  180. X
  181. static char *gray_bits[MAXGRAY] = {
  182. X    gray0_bits,
  183. X    gray1_bits,
  184. X    gray2_bits,
  185. X    gray3_bits,
  186. X    gray4_bits,
  187. X    gray5_bits,
  188. X    gray6_bits,
  189. X    gray7_bits,
  190. X    gray8_bits,
  191. X    gray9_bits,
  192. X};
  193. X#else
  194. static char gray0_bits[] = {
  195. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  196. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  197. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  198. static char gray1_bits[] = {
  199. X   0x22, 0x22, 0x88, 0x88, 0x22, 0x22, 0x88, 0x88, 0x22, 0x22, 0x88, 0x88,
  200. X   0x22, 0x22, 0x88, 0x88, 0x22, 0x22, 0x88, 0x88, 0x22, 0x22, 0x88, 0x88,
  201. X   0x22, 0x22, 0x88, 0x88, 0x22, 0x22, 0x88, 0x88};
  202. static char gray2_bits[] = {
  203. X   0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55,
  204. X   0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55,
  205. X   0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55};
  206. static char gray3_bits[] = {
  207. X   0xdd, 0xdd, 0x77, 0x77, 0xdd, 0xdd, 0x77, 0x77, 0xdd, 0xdd, 0x77, 0x77,
  208. X   0xdd, 0xdd, 0x77, 0x77, 0xdd, 0xdd, 0x77, 0x77, 0xdd, 0xdd, 0x77, 0x77,
  209. X   0xdd, 0xdd, 0x77, 0x77, 0xdd, 0xdd, 0x77, 0x77};
  210. static char gray4_bits[] = {
  211. X   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  212. X   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  213. X   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  214. X
  215. static char *gray_bits[MAXGRAY] = {
  216. X    gray0_bits,
  217. X    gray1_bits,
  218. X    gray2_bits,
  219. X    gray3_bits,
  220. X    gray4_bits,
  221. X};
  222. X#endif
  223. X
  224. X#define stripe_width 14
  225. X#define stripe_height 14
  226. static char stripe_bits[] = {
  227. X   0x0f, 0x3c, 0x07, 0x3e, 0x03, 0x3f, 0x81, 0x3f, 0xc0, 0x3f, 0xe0, 0x1f,
  228. X   0xf0, 0x0f, 0xf8, 0x07, 0xfc, 0x03, 0xfe, 0x01, 0xff, 0x00, 0x7f, 0x20,
  229. X   0x3f, 0x30, 0x1f, 0x38};
  230. X
  231. static void
  232. ClassInitialize()
  233. X{
  234. X    XtAddConverter( XtRString, XtROrientation, XmuCvtStringToOrientation,
  235. X            NULL, (Cardinal)0 );
  236. X}
  237. X
  238. static void
  239. SetDimensions(w)
  240. BarWidget w;
  241. X{
  242. X    if (w->bar.orientation == XtorientVertical) {
  243. X    w->bar.length = w->core.height;
  244. X    w->bar.thickness = w->core.width;
  245. X    }
  246. X    else {
  247. X    w->bar.length = w->core.width;
  248. X    w->bar.thickness = w->core.height;
  249. X    }
  250. X}
  251. X
  252. X/* ARGSUSED */
  253. static void
  254. Initialize(request, new)
  255. Widget request;        /* what the client asked for */
  256. Widget new;        /* what we're going to give him */
  257. X{
  258. X    BarWidget w = (BarWidget) new;
  259. X    XGCValues gcValues;
  260. X    BarClassPart *bcp = &(barClassRec.bar_class);
  261. X    int i;
  262. X    XColor color, exact;
  263. X
  264. X    if (bcp->gray == (Pixmap *) NULL) {
  265. X    /*
  266. X     *  We initialize this here instead of ClassInitialize because
  267. X     *  we need a window to initialize this in. A cleaner way to do
  268. X     *  this would be to use a separate set of Pixmaps for each
  269. X     *  widget, so that widgets can be on different screen/visuals.
  270. X     *  But then we'd have to fix it so this thing understood
  271. X     *  colours, visuals, more resources...  Laziness wins.
  272. X     */
  273. X    bcp->gray = (Pixmap *) XtMalloc(MAXGRAY * sizeof(Pixmap));
  274. X    for(i = 0; i < MAXGRAY; i++) {
  275. X        bcp->gray[i] = XCreatePixmapFromBitmapData(XtDisplay(new),
  276. X         DefaultRootWindow(XtDisplay(new)), gray_bits[i],
  277. X#ifdef    UGLY_GRAYS
  278. X                                  3, 3,
  279. X#else
  280. X                                  16, 16,
  281. X#endif
  282. X         WhitePixelOfScreen(XtScreen(new)),
  283. X         BlackPixelOfScreen(XtScreen(new)), 1);
  284. X    }
  285. X    XAllocNamedColor(XtDisplay(new),
  286. X             DefaultColormap(XtDisplay(new), DefaultScreen(XtDisplay(new))),
  287. X             "Yellow", &color, &exact);
  288. X    bcp->stripe = XCreatePixmapFromBitmapData(XtDisplay(new),
  289. X         DefaultRootWindow(XtDisplay(new)), stripe_bits, stripe_width,
  290. X         stripe_height, color.pixel,
  291. X         BlackPixelOfScreen(XtScreen(new)),
  292. X         DefaultDepth(XtDisplay(new), DefaultScreen(XtDisplay(new))));
  293. X    }
  294. X    gcValues.stipple = bcp->gray[0];
  295. X    gcValues.fill_style = FillOpaqueStippled;
  296. X    w->bar.gc = XCreateGC(XtDisplay(new), DefaultRootWindow(XtDisplay(new)),
  297. X     GCFillStyle | GCStipple, &gcValues);
  298. X    /* Width and height override length and thickness */
  299. X    if (w->bar.length == def_dimension)
  300. X    w->bar.length = DEF_LENGTH;
  301. X    
  302. X    if (w->bar.thickness == def_dimension)
  303. X    w->bar.thickness = DEF_THICKNESS;
  304. X    
  305. X    if (w->core.width == def_dimension)
  306. X    w->core.width = (w->bar.orientation == XtorientVertical)
  307. X        ? w->bar.thickness : w->bar.length;
  308. X
  309. X    if (w->core.height == def_dimension)
  310. X    w->core.height = (w->bar.orientation == XtorientHorizontal)
  311. X        ? w->bar.thickness : w->bar.length;
  312. X    w->bar.striped = 0;
  313. X    w->bar.values = NULL;
  314. X    w->bar.nvalues = 0;
  315. X
  316. X    SetDimensions(w);
  317. X}
  318. X
  319. X/* ARGSUSED */
  320. static void
  321. Resize(gw)
  322. Widget gw;
  323. X{
  324. X    SetDimensions((BarWidget)gw);
  325. X    Redisplay(gw, (XEvent*)NULL, (Region)NULL);
  326. X}
  327. X
  328. X/* ARGSUSED */
  329. static void
  330. Redisplay(gw, event, region)
  331. Widget gw;
  332. XXEvent *event;
  333. Region region;
  334. X{
  335. X    BarWidget w = (BarWidget) gw;
  336. X    int x, y;
  337. X    unsigned int width, height;
  338. X    int maxvalue, i;
  339. X    int inc_gray;
  340. X    int igray; 
  341. X    int vertical = (w->bar.orientation == XtorientVertical);;
  342. X
  343. X    if (! XtIsRealized(gw))
  344. X    return;
  345. X
  346. X    if (w->bar.striped)
  347. X    {
  348. X    if(vertical) {
  349. X        width = w->bar.thickness;
  350. X        height = w->core.height;
  351. X    }
  352. X    else {
  353. X        height = w->bar.thickness;
  354. X        width = w->core.width;
  355. X    }
  356. X    XSetTile(XtDisplay(gw), w->bar.gc, barClassRec.bar_class.stripe);
  357. X    XSetFillStyle(XtDisplay(gw), w->bar.gc, FillTiled);
  358. X    XFillRectangle(XtDisplay(gw), XtWindow(gw), w->bar.gc,
  359. X           0, 0, width, height);
  360. X    XSetFillStyle(XtDisplay(gw), w->bar.gc, FillOpaqueStippled);
  361. X    return;
  362. X    }
  363. X
  364. X    for(maxvalue = 0, i = 0; i < w->bar.nvalues; i++)
  365. X    maxvalue += w->bar.values[i];
  366. X    if(maxvalue <= 0)
  367. X    return;
  368. X    x = y = 0;
  369. X    if(vertical)
  370. X    width = w->bar.thickness;
  371. X    else
  372. X    height = w->bar.thickness;
  373. X    inc_gray = (w->bar.nvalues > 1) ? (MAXGRAY - 1) / (w->bar.nvalues - 1) :
  374. X    MAXGRAY - 1;
  375. X    for(igray = 0, i = 0; i < w->bar.nvalues; i++, igray += inc_gray) {
  376. X    unsigned int rectlen = (w->bar.length * w->bar.values[i] +
  377. X                maxvalue / 2) / maxvalue;
  378. X    if (rectlen == 0)
  379. X        continue;
  380. X    if (i == w->bar.nvalues - 1) {
  381. X        if (vertical)
  382. X        rectlen = w->core.height - y;
  383. X        else
  384. X        rectlen = w->core.width - x;
  385. X#ifndef    UGLY_GRAYS
  386. X        igray = MAXGRAY - 1;
  387. X#endif
  388. X    }
  389. X    XSetStipple(XtDisplay(gw), w->bar.gc, barClassRec.bar_class.gray[igray]);
  390. X    if(vertical) {
  391. X        XFillRectangle(XtDisplay(gw), XtWindow(gw), w->bar.gc,
  392. X         x, y, width, rectlen);
  393. X        y += rectlen;
  394. X    } else {
  395. X        XFillRectangle(XtDisplay(gw), XtWindow(gw), w->bar.gc,
  396. X         x, y, rectlen, height);
  397. X        x += rectlen;
  398. X    }
  399. X    }
  400. X}
  401. X
  402. X/* Public routines. */
  403. void
  404. SetBarValues(gw, values, nvalues)
  405. Widget gw;
  406. int *values;
  407. int nvalues;
  408. X{
  409. X    BarWidget w = (BarWidget) gw;
  410. X    int i;
  411. X
  412. X    if (nvalues > MAXGRAY) {
  413. X#define ERRFMT "Tried to set %d values for bar - maximum is %d\n"
  414. X    char errbuf[sizeof(ERRFMT) + 32];
  415. X    (void) sprintf(errbuf, ERRFMT, nvalues, MAXGRAY);
  416. X#undef ERRFMT
  417. X    XtWarning(errbuf);
  418. X    nvalues = MAXGRAY;
  419. X    }
  420. X    if (nvalues < 0) {
  421. X#define ERRFMT "Tried to set %d values for bar - it must be > 0\n"
  422. X    char errbuf[sizeof(ERRFMT) + 32];
  423. X    (void) sprintf(errbuf, ERRFMT, nvalues);
  424. X    XtWarning(errbuf);
  425. X#undef ERRFMT
  426. X    return;
  427. X    }
  428. X    w->bar.nvalues = nvalues;
  429. X    if (w->bar.values != NULL)
  430. X    XtFree((char *) w->bar.values);
  431. X    if (nvalues != 0)
  432. X    w->bar.values = (int *) XtMalloc(nvalues * sizeof(int));
  433. X    for(i = 0; i < nvalues; i++)
  434. X    w->bar.values[i] = values[i];
  435. X    w->bar.striped = 0;
  436. X    Redisplay( gw, (XEvent*)NULL, (Region)NULL );
  437. X}
  438. X
  439. void
  440. SetBarStripe(gw)
  441. Widget gw;
  442. X{
  443. X    BarWidget w = (BarWidget) gw;
  444. X    int i;
  445. X
  446. X    w->bar.striped = 1;
  447. X    Redisplay( gw, (XEvent*)NULL, (Region)NULL );
  448. X}
  449. END_OF_FILE
  450. if test 10785 -ne `wc -c <'Bar.c'`; then
  451.     echo shar: \"'Bar.c'\" unpacked with wrong size!
  452. fi
  453. # end of 'Bar.c'
  454. fi
  455. if test -f 'Bar.h' -a "${1}" != "-c" ; then 
  456.   echo shar: Will not clobber existing file \"'Bar.h'\"
  457. else
  458. echo shar: Extracting \"'Bar.h'\" \(1187 characters\)
  459. sed "s/^X//" >'Bar.h' <<'END_OF_FILE'
  460. X#include <X11/copyright.h>
  461. X
  462. X/* $XConsortium: Bar.h,v 1.2 88/10/25 17:22:09 swick Exp $ */
  463. X/* Copyright    Massachusetts Institute of Technology    1987, 1988 */
  464. X
  465. X#ifndef _Bar_h
  466. X#define _Bar_h
  467. X
  468. X/****************************************************************
  469. X *
  470. X * Bar widget
  471. X *
  472. X ****************************************************************/
  473. X
  474. X/* Resources:
  475. X
  476. X Name             Class        RepType        Default Value
  477. X ----             -----        -------        -------------
  478. X background         Background        Pixel        XtDefaultBackground
  479. X border             BorderColor    Pixel        XtDefaultForeground
  480. X borderWidth         BorderWidth    Dimension    1
  481. X destroyCallback     Callback        Pointer        NULL
  482. X height             Height        Dimension    0
  483. X mappedWhenManaged   MappedWhenManaged    Boolean        True
  484. X sensitive         Sensitive        Boolean        True
  485. X width             Width        Dimension    0
  486. X x             Position        Position    0
  487. X y             Position        Position    0
  488. X
  489. X*/
  490. X
  491. X/* declare specific BarWidget class and instance datatypes */
  492. X
  493. typedef struct _BarClassRec*    BarWidgetClass;
  494. typedef struct _BarRec*        BarWidget;
  495. X
  496. X/* declare the class constant */
  497. X
  498. extern WidgetClass barWidgetClass;
  499. X
  500. X/* Public procedures */
  501. extern void SetBarValues(/* BarWidget w, int *values, int nvalues */);
  502. X
  503. X#endif  _Bar_h
  504. END_OF_FILE
  505. if test 1187 -ne `wc -c <'Bar.h'`; then
  506.     echo shar: \"'Bar.h'\" unpacked with wrong size!
  507. fi
  508. # end of 'Bar.h'
  509. fi
  510. if test -f 'BarP.h' -a "${1}" != "-c" ; then 
  511.   echo shar: Will not clobber existing file \"'BarP.h'\"
  512. else
  513. echo shar: Extracting \"'BarP.h'\" \(1160 characters\)
  514. sed "s/^X//" >'BarP.h' <<'END_OF_FILE'
  515. X#include <X11/copyright.h>
  516. X
  517. X/* $XConsortium: BarP.h,v 1.2 88/10/25 17:37:59 swick Exp $ */
  518. X/* Copyright    Massachusetts Institute of Technology    1987, 1988 */
  519. X
  520. X#ifndef _BarP_h
  521. X#define _BarP_h
  522. X
  523. X#include <X11/Xmu/Xmu.h>
  524. X#include "Bar.h"
  525. X/* include superclass private header file */
  526. X#include <X11/CoreP.h>
  527. X
  528. X/* define unique representation types not found in <X11/StringDefs.h> */
  529. X
  530. X#ifdef UGLY_GRAYS
  531. X#define MAXGRAY 10
  532. X#else
  533. X#define MAXGRAY 5
  534. X#endif
  535. X
  536. typedef struct {
  537. X    Pixmap *gray;
  538. X    Pixmap stripe;
  539. X} BarClassPart;
  540. X
  541. typedef struct _BarClassRec {
  542. X    CoreClassPart    core_class;
  543. X    BarClassPart    bar_class;
  544. X} BarClassRec;
  545. X
  546. extern BarClassRec barClassRec;
  547. X
  548. typedef struct {
  549. X    /* private state */
  550. X    int striped;        /* In the striped state? */
  551. X    int *values;        /* Array of values displayed in bar */
  552. X    int nvalues;        /* Number of elements in values */
  553. X    XtOrientation orientation;    /* XtorientHorizontal or XtorientVertical */
  554. X    Dimension      length;    /* either height or width */
  555. X    Dimension      thickness;    /* either width or height */
  556. X    GC          gc;        /* a gc */
  557. X} BarPart;
  558. X
  559. typedef struct _BarRec {
  560. X    CorePart    core;
  561. X    BarPart    bar;
  562. X} BarRec;
  563. X
  564. X#endif  _BarP_h
  565. END_OF_FILE
  566. if test 1160 -ne `wc -c <'BarP.h'`; then
  567.     echo shar: \"'BarP.h'\" unpacked with wrong size!
  568. fi
  569. # end of 'BarP.h'
  570. fi
  571. if test -f 'COPYRIGHT' -a "${1}" != "-c" ; then 
  572.   echo shar: Will not clobber existing file \"'COPYRIGHT'\"
  573. else
  574. echo shar: Extracting \"'COPYRIGHT'\" \(915 characters\)
  575. sed "s/^X//" >'COPYRIGHT' <<'END_OF_FILE'
  576. X/*
  577. X * Copyright University of Toronto 1988, 1989.
  578. X * Written by Mark Moraes
  579. X *
  580. X * Permission is granted to anyone to use this software for any purpose on
  581. X * any computer system, and to alter it and redistribute it freely, subject
  582. X * to the following restrictions:
  583. X *
  584. X * 1. The author and the University of Toronto are not responsible 
  585. X *    for the consequences of use of this software, no matter how awful, 
  586. X *    even if they arise from flaws in it.
  587. X *
  588. X * 2. The origin of this software must not be misrepresented, either by
  589. X *    explicit claim or by omission.  Since few users ever read sources,
  590. X *    credits must appear in the documentation.
  591. X *
  592. X * 3. Altered versions must be plainly marked as such, and must not be
  593. X *    misrepresented as being the original software.  Since few users
  594. X *    ever read sources, credits must appear in the documentation.
  595. X *
  596. X * 4. This notice may not be removed or altered.
  597. X */
  598. END_OF_FILE
  599. if test 915 -ne `wc -c <'COPYRIGHT'`; then
  600.     echo shar: \"'COPYRIGHT'\" unpacked with wrong size!
  601. fi
  602. # end of 'COPYRIGHT'
  603. fi
  604. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  605.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  606. else
  607. echo shar: Extracting \"'MANIFEST'\" \(499 characters\)
  608. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  609. X   File Name        Archive #    Description
  610. X-----------------------------------------------------------
  611. X BUGS                       1    
  612. X Bar.c                      1    
  613. X Bar.h                      1    
  614. X BarP.h                     1    
  615. X COPYRIGHT                  1    
  616. X MANIFEST                   1    
  617. X Makefile                   1    
  618. X README                     1    
  619. X csu.diffs                  1    
  620. X s-pfilt-rwho.c             1    
  621. X s.h                        1    
  622. X xwhosup.1                  1    
  623. X xwhosup.c                  1    
  624. END_OF_FILE
  625. if test 499 -ne `wc -c <'MANIFEST'`; then
  626.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  627. fi
  628. # end of 'MANIFEST'
  629. fi
  630. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  631.   echo shar: Will not clobber existing file \"'Makefile'\"
  632. else
  633. echo shar: Extracting \"'Makefile'\" \(1165 characters\)
  634. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  635. DESTROOT =
  636. DESTPATH = $(DESTROOT)/contrib
  637. DESTSHR = $(DESTPATH)/share
  638. DESTSYS = $(DESTPATH)/system
  639. MAND = $(DESTSHR)/man
  640. BIND = $(DESTSYS)/bin
  641. X
  642. SRCROOT =
  643. SRCPATH = $(SRCROOT)/contrib
  644. SRCSHR = $(SRCPATH)/share
  645. SRCSYS = $(SRCPATH)/system
  646. INCD = $(SRCSHR)/include
  647. LIBD = $(SRCSYS)/lib
  648. X
  649. X#(decnet needed by xlib?)
  650. XXLIB = -lX11 -ldnet
  651. X#(nope)
  652. X#XLIB = -lX11
  653. X
  654. PROGRAM        = xwhosup
  655. MANPAGE        = xwhosup.1
  656. X
  657. H        = \
  658. X        Bar.h \
  659. X        BarP.h \
  660. X        s.h
  661. X
  662. SRC        = \
  663. X        BUGS \
  664. X        COPYRIGHT \
  665. X        Makefile \
  666. X        README \
  667. X        $(MANPAGE) \
  668. X        $(H) \
  669. X        Bar.c \
  670. X        s-pfilt-rwho.c \
  671. X        xwhosup.c
  672. X
  673. OBJS         = \
  674. X        Bar.o \
  675. X        s-pfilt-rwho.o \
  676. X        xwhosup.o
  677. X
  678. X#(gcc)
  679. CC        = gcc
  680. CDEBUG        = -O -g
  681. X#(other)
  682. CC        = cc
  683. CDEBUG        = -O
  684. X
  685. INC        = -I$(INCD)
  686. CFLAGS        = $(INC) $(CDEBUG)
  687. LIBS        = -L$(LIBD) -lXaw -lXmu -lXt -lXext $(XLIB) -lm
  688. X
  689. all        : $(PROGRAM)
  690. X
  691. X$(PROGRAM)    : $(OBJS)
  692. X        $(CC) -o $(PROGRAM) $(OBJS) $(LIBS)
  693. X
  694. install        : $(PROGRAM) $(MANPAGE)
  695. X        install -c -s $(PROGRAM) $(BIND)/$(PROGRAM)
  696. X        install -c    $(MANPAGE) $(MAND)/man1/$(MANPAGE)
  697. X
  698. shar        :
  699. X        shar $(SRC) > $(PROGRAM).shar
  700. X
  701. clean        :
  702. X        -rm -f $(OBJS) $(PROGRAM).shar $(PROGRAM)
  703. X
  704. Bar.o        : Bar.c BarP.h Bar.h
  705. xwhosup.o    : xwhosup.c Bar.h s.h
  706. s-pfilt-rwho.o    : s-pfilt-rwho.c 
  707. END_OF_FILE
  708. if test 1165 -ne `wc -c <'Makefile'`; then
  709.     echo shar: \"'Makefile'\" unpacked with wrong size!
  710. fi
  711. # end of 'Makefile'
  712. fi
  713. if test -f 'README' -a "${1}" != "-c" ; then 
  714.   echo shar: Will not clobber existing file \"'README'\"
  715. else
  716. echo shar: Extracting \"'README'\" \(1056 characters\)
  717. sed "s/^X//" >'README' <<'END_OF_FILE'
  718. Originally:
  719. X
  720. X    A snapshot performance monitor. Originally written to watch the load
  721. X    distribution on the CPU's on an Silicon Graphics Iris4d/240, it can be
  722. X    adapted to display a large variety of changing system statistics.
  723. X    
  724. X        - moraes@cs.toronto.edu (Mark Moraes)
  725. X
  726. Modified to snoop for rwhod(8) packets using Jeff Mogul's packetfilter(4)
  727. and display the 5 minute load average on a log scale, or alternating 
  728. yellow/black diagonal stripes if a host hasn't been heard from.
  729. X
  730. I have some grander plan to turn it into a general purpose resource
  731. monitor, but that'll have to wait.  For the moment I just want have
  732. some rough idea of what our machines are doing.
  733. X
  734. The X knowledgable will realise that the X code in this is pretty naive
  735. because I hate X and _refuse_ to learn about it -- what a disaster.  I just
  736. want the bits on the screen, without having to read through a pile of overly
  737. verbose and tedious documentation.  The (original) X code is Mark Moreas' work.
  738. X
  739. X
  740. X    - Boyd Roberts <boyd@prl.dec.com>
  741. X      December '91
  742. X      Digital PRL
  743. END_OF_FILE
  744. if test 1056 -ne `wc -c <'README'`; then
  745.     echo shar: \"'README'\" unpacked with wrong size!
  746. fi
  747. # end of 'README'
  748. fi
  749. if test -f 'csu.diffs' -a "${1}" != "-c" ; then 
  750.   echo shar: Will not clobber existing file \"'csu.diffs'\"
  751. else
  752. echo shar: Extracting \"'csu.diffs'\" \(1465 characters\)
  753. sed "s/^X//" >'csu.diffs' <<'END_OF_FILE'
  754. X*** Makefile.orig    Wed Dec 30 10:19:09 1992
  755. X--- Makefile    Wed Dec 30 11:01:00 1992
  756. X***************
  757. X*** 1,2 ****
  758. X--- 1,21 ----
  759. X+ DESTROOT =
  760. X+ DESTPATH = $(DESTROOT)/contrib
  761. X+ DESTSHR = $(DESTPATH)/share
  762. X+ DESTSYS = $(DESTPATH)/system
  763. X+ MAND = $(DESTSHR)/man
  764. X+ BIND = $(DESTSYS)/bin
  765. X+ 
  766. X+ SRCROOT =
  767. X+ SRCPATH = $(SRCROOT)/contrib
  768. X+ SRCSHR = $(SRCPATH)/share
  769. X+ SRCSYS = $(SRCPATH)/system
  770. X+ INCD = $(SRCSHR)/include
  771. X+ LIBD = $(SRCSYS)/lib
  772. X+ 
  773. X+ #(decnet needed by xlib?)
  774. X+ XLIB = -lX11 -ldnet
  775. X+ #(nope)
  776. X+ #XLIB = -lX11
  777. X+ 
  778. X  PROGRAM        = xwhosup
  779. X  MANPAGE        = xwhosup.1
  780. X***************
  781. X*** 23,30 ****
  782. X          xwhosup.o
  783. X  
  784. X! INC        = -I/usr/local/include
  785. X! CFLAGS        = $(INC) -O -g
  786. X! LIBS        = -lXaw -lXmu -lXt -lXext -lX11 -lm
  787. X  
  788. X  all        : $(PROGRAM)
  789. X  
  790. X--- 42,56 ----
  791. X          xwhosup.o
  792. X  
  793. X! #(gcc)
  794. X! CC        = gcc
  795. X! CDEBUG        = -O -g
  796. X! #(other)
  797. X! CC        = cc
  798. X! CDEBUG        = -O
  799. X  
  800. X+ INC        = -I$(INCD)
  801. X+ CFLAGS        = $(INC) $(CDEBUG)
  802. X+ LIBS        = -L$(LIBD) -lXaw -lXmu -lXt -lXext $(XLIB) -lm
  803. X+ 
  804. X  all        : $(PROGRAM)
  805. X  
  806. X***************
  807. X*** 32,35 ****
  808. X--- 58,65 ----
  809. X          $(CC) -o $(PROGRAM) $(OBJS) $(LIBS)
  810. X  
  811. X+ install        : $(PROGRAM) $(MANPAGE)
  812. X+         install -c -s $(PROGRAM) $(BIND)/$(PROGRAM)
  813. X+         install -c    $(MANPAGE) $(MAND)/man1/$(MANPAGE)
  814. X+ 
  815. X  shar        :
  816. X          shar $(SRC) > $(PROGRAM).shar
  817. X***************
  818. X*** 36,40 ****
  819. X  
  820. X  clean        :
  821. X!         -rm -f $(OBJS) $(PROGRAM).shar
  822. X  
  823. X  Bar.o        : Bar.c BarP.h Bar.h
  824. X--- 66,70 ----
  825. X  
  826. X  clean        :
  827. X!         -rm -f $(OBJS) $(PROGRAM).shar $(PROGRAM)
  828. X  
  829. X  Bar.o        : Bar.c BarP.h Bar.h
  830. END_OF_FILE
  831. if test 1465 -ne `wc -c <'csu.diffs'`; then
  832.     echo shar: \"'csu.diffs'\" unpacked with wrong size!
  833. fi
  834. # end of 'csu.diffs'
  835. fi
  836. if test -f 's-pfilt-rwho.c' -a "${1}" != "-c" ; then 
  837.   echo shar: Will not clobber existing file \"'s-pfilt-rwho.c'\"
  838. else
  839. echo shar: Extracting \"'s-pfilt-rwho.c'\" \(11679 characters\)
  840. sed "s/^X//" >'s-pfilt-rwho.c' <<'END_OF_FILE'
  841. X/*
  842. X *    packetfilter(4) support for rwhod(8) packets in the style of
  843. X *    the original `system dependant' s.c file.
  844. X *
  845. X *    Boyd Roberts <boyd@prl.dec.com>
  846. X *    December '91
  847. X *    Digital PRL
  848. X */
  849. X
  850. X#include        <stdio.h>
  851. X#include        <sys/types.h>
  852. X#include        <sys/socket.h>
  853. X#include        <fcntl.h>
  854. X#include    <netdb.h>
  855. X#include    <time.h>
  856. X#include        <net/pfilt.h>
  857. X#include        <net/if.h>
  858. X#include        <netinet/in_systm.h>
  859. X#include        <netinet/in.h>
  860. X#include        <netinet/if_ether.h>
  861. X#include        <netinet/ip.h>
  862. X#include        <netinet/udp.h>
  863. X#include    <protocols/rwhod.h>
  864. X#include    <ctype.h>
  865. X#include    <math.h>
  866. X
  867. X#include    <X11/Xos.h>
  868. X#include    <X11/StringDefs.h>
  869. X#include    <X11/Intrinsic.h>
  870. X#include    <X11/Xaw/Form.h>
  871. X#include    <X11/Xaw/Label.h>
  872. X#include    <X11/Xmu/Xmu.h>
  873. X
  874. X/*
  875. X *    rwho strings for getservbyname(3).
  876. X */
  877. X#define     RWHO_SERVICE    "who"
  878. X#define     RWHO_PROTOCOL    "udp"
  879. X
  880. X/*
  881. X *    Number of load average ints.
  882. X */
  883. X#define        NLOADAV        3
  884. X
  885. X/*
  886. X *    Timeout (in seconds) for marking a host dead.
  887. X */
  888. X#define        HOSTTIMEUP    (2 * 60)
  889. X
  890. X/*
  891. X *    Simple host data structure.
  892. X */
  893. struct host
  894. X{
  895. X    char        *h_name;
  896. X    time_t        h_when;
  897. X    int        h_loadav[NLOADAV];
  898. X    int        h_state;
  899. X};
  900. X
  901. X/*
  902. X *    Host states.
  903. X */
  904. X#define HS_INIT        0        /* not heard from yet */
  905. X#define HS_UP        1        /* heard from */
  906. X#define HS_DOWN        2        /* not heard from for HOSTIMEUP */
  907. X
  908. X/*
  909. X *    Host array and number.
  910. X *
  911. X *    I could add a hashtable here to point into the host array,
  912. X *    but the search of the table (on receipt of a packet) will
  913. X *    probably be quick because there will only be a small
  914. X *    number of hosts; how much screen real estate have you got?
  915. X */
  916. static struct host    *hosts;
  917. static int        nhosts;
  918. X
  919. X/*
  920. X *    packetfilter(4) file descriptor.
  921. X */
  922. int            Clnt_multi_sock;
  923. X
  924. X/*
  925. X *    Highest bar value and the value of one point on the bar.
  926. X */
  927. X#define BAREND        1000
  928. X#define BARPOINT    250
  929. X
  930. extern char        *progname;
  931. X
  932. X/*
  933. X *    System error message.
  934. X */
  935. char    *
  936. sysmess()
  937. X{
  938. X    extern int    errno;
  939. X    extern int    sys_nerr;
  940. X    extern char    *sys_errlist[];
  941. X
  942. X    return errno <= 0 || errno > sys_nerr ? "Unknown error" : sys_errlist[errno];
  943. X}
  944. X
  945. X/*
  946. X *    Add a packetfilter(4) expression.
  947. X */
  948. X#define add(x)    f.enf_Filter[i++] = (x)
  949. X
  950. X
  951. X/*
  952. X *    Set up a packetfilter(4) filter for rwhod(8) packets.
  953. X */
  954. int
  955. rwho_filter()
  956. X{
  957. X    int        fd;
  958. X    u_short        bits;
  959. X    int        i;
  960. X    struct servent    *rwho;
  961. X    struct enfilter    f;
  962. X
  963. X    if ((fd = pfopen((char *)0, O_RDONLY)) == -1)
  964. X    {
  965. X        fprintf(stderr, "%s: Could not open packetfilter.", progname, sysmess());
  966. X        exit(1);
  967. X        /* NOTREACHED */
  968. X    }
  969. X
  970. X    /*
  971. X     *    Match promiscuoslsy received packets non-exclusively
  972. X     *    and return them prepended by a `struct enstamp'.
  973. X     */
  974. X    bits = ENPROMISC | ENNONEXCL | ENTSTAMP;
  975. X
  976. X    if (ioctl(fd, EIOCMBIS, (char *)&bits) == -1)
  977. X    {
  978. X        fprintf(stderr, "%s: Could not ioctl packetfilter. %s", progname, sysmess());
  979. X        exit(1);
  980. X        /* NOTREACHED */
  981. X    }
  982. X
  983. X    /*
  984. X     *    Grab the rwhod(8) service info.
  985. X     */
  986. X    if ((rwho = getservbyname(RWHO_SERVICE, RWHO_PROTOCOL)) == (struct servent *)0)
  987. X    {
  988. X        fprintf(stderr, "%s: No rwho UDP service. %s", progname, sysmess());
  989. X        exit(1);
  990. X        /* NOTREACHED */
  991. X    }
  992. X
  993. X    /*
  994. X     *    Build and ioctl(2) the filter.
  995. X     */
  996. X    f.enf_Priority = 0;
  997. X    i = 0;
  998. X
  999. X    add(ENF_PUSHWORD + 6);        /* packet type */
  1000. X    add(ENF_PUSHLIT);
  1001. X    add(htons((u_short)ETHERTYPE_IP));
  1002. X    add(ENF_EQ);            /* IP? */
  1003. X
  1004. X    add(ENF_PUSHWORD + 11);        /* protocol type */
  1005. X    add(ENF_PUSHLIT);
  1006. X    add(htons((u_short)0x00FF));
  1007. X    add(ENF_AND);            /* in low byte */
  1008. X    add(ENF_PUSHLIT);
  1009. X    add(htons((u_short)IPPROTO_UDP));
  1010. X    add(ENF_EQ);            /* UDP? */
  1011. X
  1012. X    add(ENF_CAND);            /* IP && UDP ? */
  1013. X
  1014. X    add(ENF_PUSHWORD + 17);        /* src port */
  1015. X    add(ENF_PUSHLIT);
  1016. X    add((u_short)rwho->s_port);
  1017. X
  1018. X    add(ENF_EQ);            /* rwho? */
  1019. X
  1020. X    f.enf_FilterLen = i;
  1021. X
  1022. X    if (ioctl(fd, EIOCSETF, &f) == -1)
  1023. X    {
  1024. X        fprintf(stderr, "%s: Could not ioctl packetfilter. %s", progname, sysmess());
  1025. X        exit(1);
  1026. X        /* NOTREACHED */
  1027. X    }
  1028. X
  1029. X    return fd;
  1030. X}
  1031. X
  1032. X/*
  1033. X *    Return the ASCII representation of an Ethernet address.
  1034. X */
  1035. char    *
  1036. ether_addr(a)
  1037. u_char    *a;
  1038. X{
  1039. X    static char    buf[18];
  1040. X
  1041. X    sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x", a[0], a[1], a[2], a[3], a[4], a[5]);
  1042. X
  1043. X    return buf;
  1044. X}
  1045. X
  1046. X/*
  1047. X *    Process a rwhod(8) packet.  Do _a lot_ of sanity checking, trashing
  1048. X *    any packets that look weird.  Various extraneous IP structs are
  1049. X *    initialised here for debugging.
  1050. X */
  1051. static struct whod    *
  1052. rwho(fd)
  1053. X{
  1054. X    unsigned char        *p;
  1055. X    int            n;
  1056. X    int            i;
  1057. X    struct ether_header    *ether;
  1058. X    struct ip        *ip;
  1059. X    struct udphdr        *udp;
  1060. X    static struct whod    whop;
  1061. X    struct enstamp        stamp;
  1062. X    unsigned char        buf[4096];
  1063. X    extern Bool        noisy;
  1064. X    int            true_length;
  1065. X    extern char        *progname;
  1066. X
  1067. X    switch (n = read(fd, (char *)buf, sizeof buf))
  1068. X    {
  1069. X    case 0:
  1070. X        if (noisy)
  1071. X            fprintf(stderr, "%s: End of file on packetfilter.\n", progname);
  1072. X
  1073. X        return (struct whod *)0;
  1074. X
  1075. X    case -1:
  1076. X        if (noisy)
  1077. X            fprintf(stderr, "%s: Could not read packetfilter. %s\n", progname, sysmess());
  1078. X
  1079. X        return (struct whod *)0;
  1080. X    
  1081. X    default:
  1082. X        break;
  1083. X    }
  1084. X
  1085. X    p = buf;
  1086. X
  1087. X    /* peek at the stamp and copy it */
  1088. X
  1089. X    if (n <= sizeof(stamp.ens_stamplen) || n <= ((struct enstamp *)p)->ens_stamplen)
  1090. X    {
  1091. X        if (noisy)
  1092. X            fprintf(stderr, "%s: Short packetfilter read of %d bytes.\n", progname, n);
  1093. X
  1094. X        return (struct whod *)0;
  1095. X    }
  1096. X
  1097. X    bcopy((char *)p, (char *)&stamp, (int)((struct enstamp *)p)->ens_stamplen);
  1098. X
  1099. X    n -= stamp.ens_stamplen;
  1100. X    true_length = n;
  1101. X
  1102. X    if (n < 0)
  1103. X    {
  1104. X        if (noisy)
  1105. X            fprintf(stderr, "%s: %d byte packet missing enstamp.\n", progname, true_length);
  1106. X
  1107. X        return (struct whod *)0;
  1108. X    }
  1109. X
  1110. X    p += stamp.ens_stamplen;
  1111. X    n -= sizeof (struct ether_header);
  1112. X
  1113. X    if (n < 0)
  1114. X    {
  1115. X        if (noisy)
  1116. X            fprintf(stderr, "%s: %d byte packet missing Ethernet header.\n", progname, true_length);
  1117. X
  1118. X        return (struct whod *)0;
  1119. X    }
  1120. X
  1121. X    /* now we have an ethernet packet */
  1122. X
  1123. X    ether = (struct ether_header *)p;
  1124. X    p += sizeof (struct ether_header);
  1125. X
  1126. X    n -= sizeof (struct ip);
  1127. X
  1128. X    if (n < 0)
  1129. X    {
  1130. X        if (noisy)
  1131. X            fprintf(stderr, "%s: %d byte packet from %s missing IP header.\n", progname, true_length, ether_addr(ether->ether_shost));
  1132. X
  1133. X        return (struct whod *)0;
  1134. X    }
  1135. X
  1136. X    /* now we have an IP packet */
  1137. X
  1138. X    ip = (struct ip *)p;
  1139. X    p += sizeof (struct ip);
  1140. X
  1141. X    if (n <= sizeof (struct udphdr))
  1142. X    {
  1143. X        if (noisy)
  1144. X            fprintf(stderr, "%s: %d byte packet from %s missing UDP header.\n", progname, true_length, inet_ntoa(ip->ip_src));
  1145. X
  1146. X        return (struct whod *)0;
  1147. X    }
  1148. X
  1149. X    /* now we have a UDP packet */
  1150. X
  1151. X    udp = (struct udphdr *)p;
  1152. X
  1153. X    /* check the UDP datalength with the length returned by read(2) */
  1154. X
  1155. X    if (n != ntohs(udp->uh_ulen))
  1156. X    {
  1157. X        if (noisy)
  1158. X            fprintf(stderr, "%s: %d byte packet from %s UDP length %d, should be %d.\n", progname, true_length, inet_ntoa(ip->ip_src), ntohs(udp->uh_ulen), n);
  1159. X
  1160. X        return (struct whod *)0;
  1161. X    }
  1162. X
  1163. X    p += sizeof (struct udphdr);        /* rwho packet */
  1164. X    n -= sizeof (struct udphdr);        /* rwho packet length */
  1165. X
  1166. X        /* make _sure_ that we have the bits of the rwho we want */
  1167. X
  1168. X    if ((unsigned char *)&((struct whod *)p)->wd_we[0] - p > n)
  1169. X    {
  1170. X        if (noisy)
  1171. X            fprintf(stderr, "%s: %d byte rwho packet from %s truncated.\n", progname, true_length, inet_ntoa(ip->ip_src));
  1172. X
  1173. X        return (struct whod *)0;
  1174. X    }
  1175. X
  1176. X    bcopy((char *)p, (char *)&whop, n);        /* rwho packet */
  1177. X
  1178. X    /*
  1179. X     *    Verify and turn into host byte order.
  1180. X     */
  1181. X    if (whop.wd_vers != WHODVERSION)
  1182. X    {
  1183. X        if (noisy)
  1184. X            fprintf(stderr, "%s: %d byte rwho packet version %d from %s should be version %d.\n", progname, true_length, whop.wd_vers, inet_ntoa(ip->ip_src), WHODVERSION);
  1185. X
  1186. X        return (struct whod *)0;
  1187. X    }
  1188. X
  1189. X    whop.wd_sendtime = (int)ntohl(whop.wd_sendtime);
  1190. X
  1191. X    /* use the receive time in the packet stamp */
  1192. X    whop.wd_recvtime = stamp.ens_tstamp.tv_sec;
  1193. X
  1194. X    for (i = 0; i < sizeof(whop.wd_hostname); i++)
  1195. X    {
  1196. X        unsigned char    c;
  1197. X
  1198. X        if ((c = whop.wd_hostname[i]) == '\0')
  1199. X            break;
  1200. X
  1201. X        if (!isprint(c))
  1202. X        {
  1203. X            if (noisy)
  1204. X                fprintf(stderr, "%s: Unprintable hostname character 0%03o in rwho packet from %s.\n", progname, c, inet_ntoa(ip->ip_src));
  1205. X
  1206. X            return (struct whod *)0;
  1207. X        }
  1208. X    }
  1209. X
  1210. X    if (noisy)
  1211. X    {
  1212. X        for (i = 0; i < sizeof(whop.wd_hostname); i++)
  1213. X        {
  1214. X            unsigned char    c;
  1215. X
  1216. X            if ((c = whop.wd_hostname[i]) == '\0')
  1217. X                break;
  1218. X
  1219. X            putchar(c);
  1220. X        }
  1221. X    }
  1222. X
  1223. X    for (i = 0; i < NLOADAV; i++)
  1224. X    {
  1225. X        whop.wd_loadav[i] = (int)ntohl(whop.wd_loadav[i]);
  1226. X
  1227. X        if (noisy)
  1228. X            printf(" %.3f", (double)whop.wd_loadav[i] / 100.0);
  1229. X    }
  1230. X
  1231. X    whop.wd_boottime = (int)ntohl(whop.wd_boottime);
  1232. X
  1233. X    if (noisy)
  1234. X        printf("\n");
  1235. X
  1236. X    /* forget about the utmp data -- it's too ugly */
  1237. X
  1238. X    return &whop;
  1239. X}
  1240. X
  1241. X/*
  1242. X *    Called when XtMainLoop gets seltrue on the packetfilter descriptor.
  1243. X */
  1244. X
  1245. X/* ARGSUSED */
  1246. XXtInputCallbackProc
  1247. get_socket_msg(client_data, source, id)
  1248. caddr_t client_data;
  1249. int *source;
  1250. XXtInputId *id;
  1251. X{
  1252. X    int        i;
  1253. X    struct whod    *whop;
  1254. X
  1255. X    /*
  1256. X     *    Grab packet in host byte order.
  1257. X     */
  1258. X    if ((whop = rwho(Clnt_multi_sock)) == (struct whod *)0)
  1259. X        return;
  1260. X
  1261. X    /*
  1262. X     *    Find host slot in table and update it.  A linear search,
  1263. X     *    but I could add a hashtable.
  1264. X     */
  1265. X    for (i = 0; i < nhosts; i++)
  1266. X    {
  1267. X        int        j;
  1268. X        struct host    *hp;
  1269. X        double        d;
  1270. X        int        bars[4];
  1271. X
  1272. X        hp = &hosts[i];
  1273. X
  1274. X        if (strncmp(whop->wd_hostname, hp->h_name, sizeof (whop->wd_hostname)) != 0)
  1275. X            continue;
  1276. X
  1277. X        /* copy load averages and mark up */
  1278. X        for (j = 0; j < NLOADAV; j++)
  1279. X            hp->h_loadav[j] = whop->wd_loadav[j];
  1280. X
  1281. X        hp->h_when = whop->wd_recvtime;
  1282. X        hp->h_state = HS_UP;
  1283. X
  1284. X        /*
  1285. X         *    Logarithmic bar display from 1..BAREND but linear from 0..1
  1286. X         */
  1287. X        bars[0] = 0;
  1288. X
  1289. X        if ((d = (double)hp->h_loadav[0] / 100.0) > 1.0)
  1290. X            bars[1] = log10(d) * BARPOINT + BARPOINT;
  1291. X        else
  1292. X            bars[1] = d * BARPOINT;
  1293. X
  1294. X        if (bars[1] > BAREND)
  1295. X            bars[1] = BAREND;
  1296. X
  1297. X        bars[2] = BAREND - bars[1];
  1298. X        bars[3] = 0;
  1299. X
  1300. X        draw_bar(i, &bars[0], sizeof bars / sizeof bars[0]);
  1301. X        break;
  1302. X    }
  1303. X}
  1304. X
  1305. X/*
  1306. X *    Called every HOSTTIMEUP seconds to scan for dead hosts.
  1307. X */
  1308. X/* ARGSUSED */
  1309. XXtTimerCallbackProc
  1310. host_down(closure, id)
  1311. caddr_t closure;
  1312. XXtIntervalId *id;
  1313. X{
  1314. X    int        i;
  1315. X    struct timeval    t;
  1316. X    struct timezone    tz;
  1317. X
  1318. X    if (gettimeofday(&t, &tz) == -1)
  1319. X        t.tv_sec = 0x7FFFFFFF;        /* cannot happen */
  1320. X
  1321. X    for (i = 0; i < nhosts; i++)
  1322. X    {
  1323. X        struct host    *hp;
  1324. X
  1325. X        hp = &hosts[i];
  1326. X
  1327. X        switch (hp->h_state)
  1328. X        {
  1329. X        case HS_INIT:
  1330. X        case HS_UP:
  1331. X            if (t.tv_sec > hp->h_when + HOSTTIMEUP)
  1332. X            {
  1333. X                extern Widget *bar;
  1334. X
  1335. X                hp->h_state = HS_DOWN;
  1336. X
  1337. X#if    DEBUG
  1338. X                printf("%s DOWN\n", hp->h_name);
  1339. X#endif
  1340. X
  1341. X                SetBarStripe(bar[i]);
  1342. X            }
  1343. X            break;
  1344. X
  1345. X        case HS_DOWN:
  1346. X            break;
  1347. X        }
  1348. X    }
  1349. X
  1350. X    /* set up next call */
  1351. X    XtAddTimeOut((unsigned long)(HOSTTIMEUP * 1000), host_down, (caddr_t)0);
  1352. X}
  1353. X
  1354. X/*
  1355. X *    Look at argv for the number of hosts (bars).
  1356. X */
  1357. X/* ARGSUSED */
  1358. int
  1359. num_bars(argc, argv)
  1360. int    argc;
  1361. char    *argv[];
  1362. X{
  1363. X    if (argc < 2)
  1364. X    {
  1365. X        extern void    usage();
  1366. X
  1367. X        usage();
  1368. X        /* NOTREACHED */
  1369. X    }
  1370. X
  1371. X    return argc - 1;
  1372. X}
  1373. X
  1374. X/*
  1375. X *    Initialise (in some sense).
  1376. X */
  1377. X/* ARGSUSED */
  1378. void
  1379. init_bars(n)
  1380. int    n;
  1381. X{
  1382. X    Clnt_multi_sock = rwho_filter();
  1383. X
  1384. X    XtAddTimeOut((unsigned long)(HOSTTIMEUP * 1000), host_down, (caddr_t)0);
  1385. X}
  1386. X
  1387. X/*
  1388. X *    Called after num_bars to ask for the bar names.
  1389. X *
  1390. X *    I use a naive algorithm to match hostnames without the domain part.
  1391. X *    If the domain is present, it's stripped.  Use of /etc/hosts or any
  1392. X *    form of nameserver is explicitly avoided; it's simpler and more
  1393. X *    robust just to use strcmp(3) to match/verify hostnames.
  1394. X */
  1395. X/* ARGSUSED */
  1396. char **
  1397. label_bars(nbars, argc, argv)
  1398. int nbars;
  1399. int argc;
  1400. char **argv;
  1401. X{
  1402. X    int        i;
  1403. X    char        **hostv;
  1404. X    char        **n;
  1405. X    extern char    *xmalloc();
  1406. X
  1407. X    nhosts = nbars;
  1408. X    hosts = (struct host *)xmalloc(nhosts * sizeof (struct host));
  1409. X    argv++;
  1410. X
  1411. X    n = hostv = (char **)xmalloc(nhosts * sizeof (char *));
  1412. X
  1413. X    for (i = 0; i < nhosts; i++)
  1414. X    {
  1415. X        char        *p;
  1416. X        int        j;
  1417. X        struct host    *hp;
  1418. X        extern char    *strchr();
  1419. X        extern char    *strncpy();
  1420. X
  1421. X        hp = &hosts[i];
  1422. X
  1423. X        /* hack off domain part */
  1424. X        if ((p = strchr(argv[i], '.')) != (char *)0)
  1425. X            j = p - argv[i];
  1426. X        else
  1427. X            j = strlen(argv[i]);
  1428. X
  1429. X        hp->h_name = *n++ = strncpy(xmalloc(j + 1), argv[i], j);
  1430. X        hp->h_name[j] = '\0';
  1431. X        hp->h_when = 0;
  1432. X
  1433. X        for (j = 0; j < NLOADAV; j++)
  1434. X            hp->h_loadav[j] = 0;
  1435. X    
  1436. X        hp->h_state = HS_INIT;    
  1437. X    }
  1438. X
  1439. X    return hostv;
  1440. X}
  1441. END_OF_FILE
  1442. if test 11679 -ne `wc -c <'s-pfilt-rwho.c'`; then
  1443.     echo shar: \"'s-pfilt-rwho.c'\" unpacked with wrong size!
  1444. fi
  1445. # end of 's-pfilt-rwho.c'
  1446. fi
  1447. if test -f 's.h' -a "${1}" != "-c" ; then 
  1448.   echo shar: Will not clobber existing file \"'s.h'\"
  1449. else
  1450. echo shar: Extracting \"'s.h'\" \(262 characters\)
  1451. sed "s/^X//" >'s.h' <<'END_OF_FILE'
  1452. X/*
  1453. X *  Any system dependent file must implement these routines. See s-bsd.c
  1454. X *  and s-iris4d.c for examples.
  1455. X */
  1456. extern int num_bars();
  1457. extern char **label_bars(/* int nbars */);
  1458. extern void init_bars(/* int nbars */);
  1459. extern void display_bars(/* int nbars */);
  1460. END_OF_FILE
  1461. if test 262 -ne `wc -c <'s.h'`; then
  1462.     echo shar: \"'s.h'\" unpacked with wrong size!
  1463. fi
  1464. # end of 's.h'
  1465. fi
  1466. if test -f 'xwhosup.1' -a "${1}" != "-c" ; then 
  1467.   echo shar: Will not clobber existing file \"'xwhosup.1'\"
  1468. else
  1469. echo shar: Extracting \"'xwhosup.1'\" \(2136 characters\)
  1470. sed "s/^X//" >'xwhosup.1' <<'END_OF_FILE'
  1471. X.TH XWHOSUP 1
  1472. X.SH NAME
  1473. xwhosup - display rwho based host up/down status
  1474. X.SH SYNTAX
  1475. X\fBxwhosup\fP [\fI\-toolkitoption\fP ...] [\fI-noisy\fP] host ...
  1476. X.SH DESCRIPTION
  1477. X.I Xwhosup
  1478. displays a logarithmic bar graph showing
  1479. X.I host
  1480. load average.  This data is gathered from network
  1481. X.IR rwhod (8)
  1482. broadcasts collected via
  1483. X.IR packetfilter (4).
  1484. Hosts can be specified by either their hostname, or by their fully qualified
  1485. domain name.  If the domain is supplied it is stripped and ignored.
  1486. X.PP
  1487. Initially no bar graph is displayed until either a packet is received or the
  1488. host alive timer expires.  The bar graph displays the 5 minute load average
  1489. for a host.  The scale is logarithmic with a maximum value of 1000.  For values
  1490. between 0 to 1 the scale is linear.
  1491. X.PP
  1492. If a host has not been heard from after some interval it is as marked down.
  1493. This is indicated by a bar consisting of alternating yellow/black diagonal
  1494. stripes.
  1495. X.PP
  1496. If the
  1497. X.I -noisy
  1498. option is specified
  1499. X.I xwhosup
  1500. prints a one line summary (hostname and load averages) for each
  1501. X.IR rwho (8)
  1502. broadcast received.  If a corrupted packet is received this option
  1503. causes debugging information to be written to standard error.
  1504. X.SH SEE ALSO
  1505. X.IR ruptime (1),
  1506. X.IR rwho (1),
  1507. X.IR xcpustate (1),
  1508. X.IR packetfilter (4),
  1509. X.IR rwhod (8).
  1510. X.SH BUGS
  1511. Vertical re-sizing doesn't work well and horizontal re-sizing is
  1512. X.IR interesting .
  1513. X.PP
  1514. More concern has been placed on network snooping than X programming, as the
  1515. later does not interest the author.
  1516. X.PP
  1517. The linear 0 to 1 scale is provided so that the graph is more interesting
  1518. because most of our hosts are basically idle.
  1519. X.SH AUTHOR
  1520. Boyd Roberts <boyd@prl.dec.com>
  1521. X.PP
  1522. X.I Xwhosup
  1523. is based on the code from Mark Moraes' 
  1524. X.IR xcpustate (1)
  1525. X.SM CPU
  1526. user/system/idle time monitor.  This 
  1527. X.IR packetfilter (4)
  1528. interface was written to provide a simple indication of the
  1529. status of network host(s).
  1530. X.PP
  1531. Originally authored by Mark Moraes, University of Toronto.
  1532. Thanks to Chris Siebenmann for the code for BSD systems.
  1533. Thanks to Walter D. Poxon from Cray Research for the code for Cray X/MP and
  1534. Y/MPs.
  1535. X.SH "LOCAL PROPRIETOR"
  1536. Boyd Roberts <boyd@prl.dec.com>
  1537. END_OF_FILE
  1538. if test 2136 -ne `wc -c <'xwhosup.1'`; then
  1539.     echo shar: \"'xwhosup.1'\" unpacked with wrong size!
  1540. fi
  1541. # end of 'xwhosup.1'
  1542. fi
  1543. if test -f 'xwhosup.c' -a "${1}" != "-c" ; then 
  1544.   echo shar: Will not clobber existing file \"'xwhosup.c'\"
  1545. else
  1546. echo shar: Extracting \"'xwhosup.c'\" \(5923 characters\)
  1547. sed "s/^X//" >'xwhosup.c' <<'END_OF_FILE'
  1548. X/*
  1549. X*  Displays CPU state distribution
  1550. X*/
  1551. X#ifndef lint
  1552. static char rcsid[] = "$Header: /ai/lambda/X.V11R4/contrib/clients/xcpustate/RCS/xcpustate.c,v 1.2 90/02/20 00:33:36 xwindows Exp $";
  1553. X#endif /*lint*/
  1554. X
  1555. X#include <stdio.h>
  1556. X
  1557. X#include <X11/Xos.h>
  1558. X#include <X11/StringDefs.h>
  1559. X#include <X11/Intrinsic.h>
  1560. X#include <X11/Xaw/Form.h>
  1561. X#include <X11/Xaw/Label.h>
  1562. X#include <X11/Xmu/Xmu.h>
  1563. X#include "Bar.h"
  1564. X#include "s.h"
  1565. X
  1566. X#define MAXSTR 512
  1567. X#define DEF_INTERVAL    1
  1568. X#define DEF_COUNT        -1
  1569. X
  1570. char *progname;
  1571. static int defaultInterval = DEF_INTERVAL;
  1572. static int defaultCount = DEF_COUNT;
  1573. static Bool defaultNoisy = False;
  1574. int count, interval;
  1575. Bool noisy;
  1576. X
  1577. X/* Application Resources - no particular widget */
  1578. static XtResource application_resources[] = {
  1579. X    {"interval", "Interval", XtRInt, sizeof(int),
  1580. X        (Cardinal)&interval, XtRInt, (caddr_t) &defaultInterval},
  1581. X    {"count", "Count", XtRInt, sizeof(int),
  1582. X        (Cardinal)&count, XtRInt, (caddr_t) &defaultCount},
  1583. X    {"noisy", "Noisy", XtRBoolean, sizeof(Bool),
  1584. X        (Cardinal)&noisy, XtRBoolean, (caddr_t) &defaultNoisy},
  1585. X};
  1586. X
  1587. X/*
  1588. X*  Command line options table. The command line is parsed for these,
  1589. X*  and it sets/overrides the appropriate values in the resource
  1590. X*  database
  1591. X*/
  1592. static XrmOptionDescRec optionDescList[] = {
  1593. X    {"-interval",   ".interval",    XrmoptionSepArg,    (caddr_t) NULL},
  1594. X    {"-count",        ".count",        XrmoptionSepArg,    (caddr_t) NULL},
  1595. X    {"-noisy",        ".noisy",        XrmoptionNoArg,     (caddr_t) "True"},
  1596. X};
  1597. X
  1598. X/*
  1599. X*  DON'T CHANGE THE ORDER OF THE ARGS IN THE VARIOUS ARG STRUCTS. IF
  1600. X*  YOU WANT TO ADD STUFF, ADD IT AT THE END OF THE STRUCT, BECAUSE WE
  1601. X*  REFER TO SOME OF THE ELEMENTS BY POSITION IN THE CODE.
  1602. X*/
  1603. X/* No spacing between the widgets on the Form */
  1604. static Arg form_args[] = {
  1605. X    {XtNdefaultDistance, (XtArgVal) 0},
  1606. X};
  1607. X
  1608. static Arg subform_args[] = {
  1609. X    {XtNfromVert, (XtArgVal) 0},
  1610. X    {XtNdefaultDistance, (XtArgVal) 2},
  1611. X    {XtNborderWidth, (XtArgVal) 0},
  1612. X    {XtNtop, (XtArgVal) XtChainTop},
  1613. X    {XtNbottom, (XtArgVal) XtChainTop}, /* ChainBottom causes strange resize */
  1614. X    {XtNright, (XtArgVal) XtChainRight},
  1615. X    {XtNleft, (XtArgVal) XtChainLeft},
  1616. X};
  1617. X
  1618. static Arg bar_args[] = {
  1619. X/*    {XtNfromHoriz, (XtArgVal) 0}, */
  1620. X    {XtNorientation, (XtArgVal) XtorientHorizontal},
  1621. X    {XtNborderWidth, (XtArgVal) 1},
  1622. X    {XtNlength, (XtArgVal) ((Dimension) 200)},
  1623. X    {XtNthickness, (XtArgVal) ((Dimension) 20)},
  1624. X    {XtNtop, (XtArgVal) XtChainTop},
  1625. X    {XtNbottom, (XtArgVal) XtChainTop},
  1626. X    {XtNright, (XtArgVal) XtChainRight},
  1627. X    {XtNleft, (XtArgVal) XtChainRight},
  1628. X    {XtNvertDistance, (XtArgVal) 0},
  1629. X/*    {XtNhorizDistance, (XtArgVal) 0}, */
  1630. X    {XtNresizable, (XtArgVal) FALSE},
  1631. X};
  1632. X
  1633. static Arg label_args[] = {
  1634. X    {XtNlabel, (XtArgVal) 0},
  1635. X    {XtNjustify, (XtArgVal) XtJustifyLeft},
  1636. X    {XtNborderWidth, (XtArgVal) 0},
  1637. X    {XtNtop, (XtArgVal) XtChainTop},
  1638. X    {XtNbottom, (XtArgVal) XtChainTop},
  1639. X    {XtNright, (XtArgVal) XtChainLeft},
  1640. X    {XtNleft, (XtArgVal) XtChainLeft},
  1641. X    {XtNvertDistance, (XtArgVal) 0},
  1642. X    {XtNhorizDistance, (XtArgVal) 0},
  1643. X    {XtNresizable, (XtArgVal) FALSE},
  1644. X};
  1645. X
  1646. static Arg gwid_args[] = {
  1647. X    {XtNwidth, (XtArgVal)0},
  1648. X};
  1649. X
  1650. static Arg sx_args[] = {
  1651. X    {XtNhorizDistance, (XtArgVal)0},
  1652. X};
  1653. X
  1654. void
  1655. usage()
  1656. X{
  1657. X    (void) fprintf(stderr,
  1658. X"usage: %s [Xt options] [-count iterations] [-interval delay_seconds] [-noisy] host ...\n",
  1659. X     progname);
  1660. X    exit(-1);
  1661. X}
  1662. X
  1663. char *
  1664. xmalloc(n)
  1665. int n;
  1666. X{
  1667. X    extern char *malloc();
  1668. X    char *cp = malloc((unsigned) n);
  1669. X    if (cp == NULL) {
  1670. X        (void) fprintf(stderr, "%s: Ran out of memory.\n", progname);
  1671. X        exit(-1);
  1672. X    }
  1673. X    return cp;
  1674. X}
  1675. X
  1676. extern XtInputCallbackProc    get_socket_msg();
  1677. X
  1678. static int nbars;
  1679. Widget *bar;
  1680. static char **barnames;
  1681. X    
  1682. main(argc, argv)
  1683. int argc;
  1684. char **argv;
  1685. X{
  1686. X    int i;
  1687. X    Widget topLevel;
  1688. X    Widget form, label;
  1689. X    Widget subform = NULL;
  1690. X    extern char *strchr(/* const char *, char */);
  1691. X    int maxwid;
  1692. X    extern int Clnt_multi_sock;
  1693. X
  1694. X    if ((progname = strchr(argv[0], '/')) == NULL)
  1695. X    progname = argv[0];
  1696. X    else
  1697. X    progname++;
  1698. X
  1699. X
  1700. X    topLevel = XtInitialize(progname, "RWHOHostMonitor",
  1701. X                optionDescList, XtNumber(optionDescList),
  1702. X                &argc, argv);
  1703. X
  1704. X    nbars = num_bars(argc, argv);
  1705. X    if (nbars == 0) {
  1706. X    (void) fprintf(stderr, "num_bars returned 0 - something is wrong\n");
  1707. X    exit(-1);
  1708. X    }
  1709. X    bar = (Widget *) xmalloc(nbars * sizeof(Widget));
  1710. X    barnames = label_bars(nbars, argc, argv);
  1711. X    
  1712. X    XtGetApplicationResources(topLevel, 0, application_resources,
  1713. X                  XtNumber(application_resources), NULL, 0 );
  1714. X
  1715. X    form = XtCreateManagedWidget("form", formWidgetClass, topLevel,
  1716. X                 form_args, XtNumber(form_args));
  1717. X    
  1718. X    maxwid = 0;
  1719. X    for(i = 0; i < nbars; i++) {
  1720. X#define FORMNAMEFMT    "form%d"
  1721. X    char formname[sizeof(FORMNAMEFMT) + 32];
  1722. X#define BARNAMEFMT    "bar%d"
  1723. X    char barname[sizeof(BARNAMEFMT) + 32];
  1724. X
  1725. X    if (i > 0)
  1726. X        subform_args[0].value = (XtArgVal) subform;
  1727. X    (void) sprintf(formname, FORMNAMEFMT, i);
  1728. X    subform = XtCreateManagedWidget(formname, formWidgetClass, form,
  1729. X                 subform_args, XtNumber(subform_args));
  1730. X    label_args[0].value = (XtArgVal) barnames[i];
  1731. X    label = XtCreateManagedWidget(barnames[i], labelWidgetClass, subform,
  1732. X                      label_args, XtNumber(label_args));
  1733. X    XtSetArg(gwid_args[0], XtNwidth, 0);
  1734. X    XtGetValues(label, gwid_args, 1);
  1735. X    if (gwid_args[0].value > maxwid)
  1736. X        maxwid = gwid_args[0].value;
  1737. X    (void) sprintf(barname, BARNAMEFMT, i);
  1738. X/*    bar_args[0].value = (XtArgVal) label; */
  1739. X    bar[i] = XtCreateManagedWidget(barname, barWidgetClass, subform,
  1740. X                    bar_args, XtNumber(bar_args));
  1741. X    }
  1742. X    sx_args[0].value = (XtArgVal)(maxwid + 2);
  1743. X    for(i = 0; i < nbars; i++)
  1744. X    XtSetValues(bar[i], sx_args, 1);
  1745. X
  1746. X    XtRealizeWidget(topLevel);
  1747. X
  1748. X    init_bars(nbars);
  1749. X
  1750. X    XtAddInput(Clnt_multi_sock, XtInputReadMask, get_socket_msg, (caddr_t)0);
  1751. X
  1752. X    XtMainLoop();
  1753. X}
  1754. X
  1755. void
  1756. draw_bar(i, states, nstates)
  1757. int i;
  1758. int states[];
  1759. int nstates;
  1760. X{
  1761. X    SetBarValues((Widget) bar[i], states, nstates);
  1762. X}
  1763. END_OF_FILE
  1764. if test 5923 -ne `wc -c <'xwhosup.c'`; then
  1765.     echo shar: \"'xwhosup.c'\" unpacked with wrong size!
  1766. fi
  1767. # end of 'xwhosup.c'
  1768. fi
  1769. echo shar: End of archive 1 \(of 1\).
  1770. cp /dev/null ark1isdone
  1771. MISSING=""
  1772. for I in 1 ; do
  1773.     if test ! -f ark${I}isdone ; then
  1774.     MISSING="${MISSING} ${I}"
  1775.     fi
  1776. done
  1777. if test "${MISSING}" = "" ; then
  1778.     echo You have the archive.
  1779.     rm -f ark[1-9]isdone
  1780. else
  1781.     echo You still need to unpack the following archives:
  1782.     echo "        " ${MISSING}
  1783. fi
  1784. ##  End of shell archive.
  1785. exit 0
  1786. -- 
  1787. Paul Vixie, DEC Network Systems Lab    
  1788. Palo Alto, California, USA             "Don't be a rebel, or a conformist;
  1789. <vixie@pa.dec.com> decwrl!vixie        they're the same thing, anyway.  Find
  1790. <paul@vix.com>     vixie!paul        your own path, and stay on it."  -me
  1791.