home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2775 < prev    next >
Encoding:
Internet Message Format  |  1991-02-17  |  12.4 KB

  1. From: wht@n4hgf.Mt-Park.GA.US (Warren Tucker)
  2. Newsgroups: alt.sources
  3. Subject: X386MON part 06/06
  4. Message-ID: <326@n4hgf.Mt-Park.GA.US>
  5. Date: 16 Feb 91 19:36:32 GMT
  6.  
  7. Submitted-by: wht@n4hgf
  8. Archive-name: x386monx100/part06
  9.  
  10. #!/bin/sh
  11. # This is part 06 of x386monx100
  12. # ============= x386mon/x386mon.h ==============
  13. if test ! -d 'x386mon'; then
  14.     echo 'x - creating directory x386mon'
  15.     mkdir 'x386mon'
  16. fi
  17. if test -f 'x386mon/x386mon.h' -a X"$1" != X"-c"; then
  18.     echo 'x - skipping x386mon/x386mon.h (File already exists)'
  19. else
  20. echo 'x - extracting x386mon/x386mon.h (Text)'
  21. sed 's/^X//' << 'SHAR_EOF' > 'x386mon/x386mon.h' &&
  22. X/*+-------------------------------------------------------------------------
  23. X    x386mon.h - SCO ODT (UNIX 386) system watcher definitions
  24. X    wht@n4hgf.Mt-Park.GA.US
  25. X--------------------------------------------------------------------------*/
  26. X/*+:EDITS:*/
  27. X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */
  28. X
  29. X#include <X11/Intrinsic.h>
  30. X#include "config.h"
  31. X
  32. Xchar *getenv();
  33. X
  34. Xtypedef struct myresources
  35. X{
  36. X    char *geometry;
  37. X    char *background;
  38. X    char *foreground;
  39. X    char *font;
  40. X    int busyAlarmThreshhold;
  41. X    int busyWarningThreshhold;
  42. X    int breakAlarmThreshhold;
  43. X    int breakWarningThreshhold;
  44. X    int waitAlarmThreshhold;
  45. X    int waitWarningThreshhold;
  46. X    int swapAlarmThreshhold;
  47. X    int swapWarningThreshhold;
  48. X} MyResources;
  49. X
  50. Xextern MyResources res;
  51. X
  52. Xtypedef struct myfontstruct
  53. X{
  54. X    char *name;
  55. X    int width;
  56. X    int height;
  57. X    int gap;
  58. X    int win_height_threshhold;
  59. X    Font fid;
  60. X    XFontStruct *font_struct;
  61. X} MyFontStruct;
  62. Xextern MyFontStruct *currentMyFont;
  63. X
  64. X#define FASCENT        (currentMyFont->font_struct->ascent)
  65. X#define FHEIGHT        (currentMyFont->height)
  66. X#define FWIDTH        (currentMyFont->width)
  67. X#define FGAP        (currentMyFont->gap)
  68. X
  69. X#define BORDER_EXTRA_WIDTH    (FGAP)
  70. X
  71. X#define MyButton_TLX    0
  72. X#define MyButton_TLY    1
  73. X
  74. X#define Tod_WIDTH        (FWIDTH * 8)
  75. X#define Tod_TLX            (DrawAreaXYWH.width - Tod_WIDTH - FGAP)
  76. X#define Tod_TLY            0
  77. X
  78. X#define StatPeriod_WIDTH    (FWIDTH * 10)
  79. X#define StatPeriod_TLX        (Tod_TLX - StatPeriod_WIDTH - (FWIDTH * 2))
  80. X#define StatPeriod_TLY        0
  81. X
  82. X#ifdef LABELLED_STAT_TIMES
  83. X#define StatPeriodL_WIDTH    (FWIDTH * 7)
  84. X#else
  85. X#define StatPeriodL_WIDTH    (FWIDTH * 0)
  86. X#endif
  87. X#define StatPeriodL_TLX        (StatPeriod_TLX - StatPeriodL_WIDTH)
  88. X#define StatPeriodL_TLY        0
  89. X
  90. X#define StatCycle_WIDTH        (FWIDTH * 7)
  91. X#define StatCycle_TLX        (StatPeriodL_TLX - StatCycle_WIDTH - (FWIDTH * 2))
  92. X#define StatCycle_TLY        0
  93. X
  94. X#ifdef LABELLED_STAT_TIMES
  95. X#define StatCycleL_WIDTH    (FWIDTH * 6)
  96. X#else
  97. X#define StatCycleL_WIDTH    (FWIDTH * 0)
  98. X#endif
  99. X#define StatCycleL_TLX        (StatCycle_TLX - StatCycleL_WIDTH)
  100. X#define StatCycleL_TLY        0
  101. X
  102. X#define CpuScale_TLX    0
  103. X#define CpuScale_TLY    (FHEIGHT * 2)
  104. X
  105. X#define WaitScale_TLX    0
  106. X#define WaitScale_TLY    (FHEIGHT * 6)
  107. X
  108. X/* Sysinfo/Minfo per second area */
  109. X#define Sysinfo_TLY        (FHEIGHT * 10)    /* absolute ... */
  110. X#define Sysinfo_TLX        (FWIDTH * 0)    /* ... positions */
  111. X#define Sysinfo1_TLX    (FWIDTH * 0)    /* offsets */
  112. X#define Sysinfo2_TLX    (FWIDTH * 18)
  113. X#define Sysinfo3_TLX    (FWIDTH * 35)
  114. X#define Sysinfo4_TLX    (FWIDTH * 51)
  115. X#define Sysinfo5_TLX    (FWIDTH * 66)
  116. X
  117. X/* extra info area */
  118. X#define EXTRA_TLY        (FHEIGHT * 24)    /* absolute ... */
  119. X#define EXTRA_TLX        (FWIDTH * 0)    /* ... positions */
  120. X#define EXTRA1_TLX        (FWIDTH * 0)    /* offsets */
  121. X#define EXTRA2_TLX        (FWIDTH * 18)
  122. X#define EXTRA3_TLX        (FWIDTH * 43)
  123. X#define EXTRA4_TLX        (FWIDTH * 62)
  124. X
  125. X#define Var_TLX            (EXTRA_TLX + EXTRA1_TLX)
  126. X#define Var_TLY            EXTRA_TLY
  127. X
  128. X#define Bootinfo_TLX    (EXTRA_TLX + EXTRA2_TLX)
  129. X#define Bootinfo_TLY    EXTRA_TLY
  130. X
  131. X#define Tune_TLX        (EXTRA_TLX + EXTRA3_TLX)
  132. X#define Tune_TLY        EXTRA_TLY
  133. X
  134. X#define Proc_TLX        (EXTRA_TLX + EXTRA4_TLX)
  135. X#define Proc_TLY        EXTRA_TLY
  136. X
  137. X
  138. X#define MIN_PCT_SCALE_WIDTH 100
  139. X
  140. X/* 6 == 6x10, 20 == number of characters to left of pct scales */
  141. X/*
  142. X0000000000111111111122222222223333333333444444444455555555556666666666777777777
  143. X0123456789012345678901234567890123456789012345678901234567890123456789012345678
  144. X 1  93 100 000 000 uuuuuuuuuuuuuuuuuuuuuuuuuuukkkkkkkkkkkkkkkkkkk     
  145. X 5  87 100 000 000 uuuuuuuuuuuuukkkkkkkkkkkkkkkkkkkkkkkkkkkkkk        
  146. X10  89  45  44   0 uuuuuuuuuuuuuuuuuuuuuukkkkkkkkkkkkkkkkkkkkkk       
  147. X*/
  148. X#define DrawArea_MIN_WIDTH    100
  149. X
  150. X/* 6 == 6x10, 29 == number of characters to left of pct scales */
  151. X/*
  152. X0000000000111111111122222222223333333333444444444455555555556666666666777777777
  153. X0123456789012345678901234567890123456789012345678901234567890123456789012345678
  154. X Instant %    93  54  39   0 uuuuuuuuuuuuuuuuuuuuuuuuuuukkkkkkkkkkkkkkkkkkk     
  155. X 5 Sec Avg %  87  26  61   0 uuuuuuuuuuuuukkkkkkkkkkkkkkkkkkkkkkkkkkkkkk        
  156. X10 Sec Avg %  89  45  44   0 uuuuuuuuuuuuuuuuuuuuuukkkkkkkkkkkkkkkkkkkkkk       
  157. X*/
  158. X#define DrawArea_MIN_HEIGHT    (10 * 10)    /* 10 characters of 6x10 */
  159. X
  160. X#define DrawArea_DEFAULT_WIDTH    (80 * 6)
  161. X#define DrawArea_DEFAULT_HEIGHT    (43 * 10)
  162. X#define DrawArea_DEFAULT_TLX        5
  163. X#define DrawArea_DEFAULT_TLY        5
  164. X
  165. X#define CPU_AVG_MAX        10
  166. X#define WAIT_AVG_MAX    10
  167. X
  168. Xextern XtAppContext appcon;
  169. Xextern Widget AppShellW;
  170. Xextern Widget MainWindowW;
  171. Xextern Widget DrawAreaW;
  172. Xextern XWindowAttributes DrawAreaXYWH;
  173. Xextern Display *display;
  174. Xextern Window window;
  175. Xextern GC gc;
  176. Xextern Colormap cmap;
  177. Xextern int screen;
  178. Xextern Window root_window;
  179. X
  180. Xextern MyResources res;
  181. Xextern XColor colorBackground;
  182. Xextern XColor colorForeground;
  183. Xextern XColor colorBlack;
  184. Xextern XColor colorRed;
  185. Xextern XColor colorOrange;
  186. Xextern XColor colorYellow;
  187. Xextern XColor colorGreen;
  188. Xextern XColor colorBlue;
  189. Xextern XColor colorSlate;
  190. Xextern XColor colorCyan;
  191. Xextern unsigned long foreground;
  192. Xextern unsigned long background;
  193. X
  194. Xextern int current_display_mode;
  195. Xextern int queued_display_mode;
  196. Xextern int redrawing_entire_DrawArea;
  197. X
  198. Xextern int MyButtons_next_tlx;
  199. Xextern int DispMsg_tlx;
  200. X
  201. X#if defined(WANT_MON_EXTERNS)
  202. Xextern unsigned long StatCycle_msec;
  203. X
  204. X#define sysidelta(x) (sysinfo.x - sysinfo_last.x)
  205. Xextern struct sysinfo sysinfo;
  206. Xextern struct sysinfo sysinfo_last;
  207. X
  208. X#define midelta(x) (minfo.x - minfo_last.x)
  209. Xextern struct minfo minfo;
  210. Xextern struct minfo minfo_last;
  211. Xextern struct bootinfo bootinfo;
  212. Xextern swpt_t swaptab [];
  213. Xextern swpi_t swapin;
  214. Xextern struct tune tune;
  215. Xextern struct utsname utsname;
  216. Xextern struct var v;
  217. Xextern struct timeb timeb_cycle_start;
  218. Xextern struct timeb timeb_cycle_end;
  219. Xextern struct timeb timeb_info_read;
  220. Xextern struct timeb timeb_last_info_read;
  221. Xextern int hz;
  222. Xextern int nswap;    /* seems to be in units of NBPSCTR bytes */
  223. Xextern int maxmem;
  224. Xextern int freemem;
  225. Xextern daddr_t myreadlen;
  226. Xextern int myreadcnt;
  227. Xextern int cpu_avg_init;
  228. Xextern time_t *cpu_avg[];
  229. Xextern time_t cpu_ticks[];
  230. Xextern int wait_avg_init;
  231. Xextern time_t *wait_avg[];
  232. Xextern time_t wait_ticks[];
  233. X#endif /* defined(WANT_MON_EXTERNS) */
  234. X
  235. X/* vi: set tabstop=4 shiftwidth=4: */
  236. X/* end of x386mon.h */
  237. SHAR_EOF
  238. chmod 0644 x386mon/x386mon.h ||
  239. echo 'restore of x386mon/x386mon.h failed'
  240. Wc_c="`wc -c < 'x386mon/x386mon.h'`"
  241. test 6070 -eq "$Wc_c" ||
  242.     echo 'x386mon/x386mon.h: original size 6070, current size' "$Wc_c"
  243. fi
  244. # ============= x386mon/xincs.h ==============
  245. if test -f 'x386mon/xincs.h' -a X"$1" != X"-c"; then
  246.     echo 'x - skipping x386mon/xincs.h (File already exists)'
  247. else
  248. echo 'x - extracting x386mon/xincs.h (Text)'
  249. sed 's/^X//' << 'SHAR_EOF' > 'x386mon/xincs.h' &&
  250. X/*+-------------------------------------------------------------------------
  251. X    xincs.h
  252. X    wht@n4hgf.Mt-Park.GA.US
  253. X--------------------------------------------------------------------------*/
  254. X/*+:EDITS:*/
  255. X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */
  256. X
  257. X#include <X11/Xlib.h>
  258. X#include <X11/Xutil.h>
  259. X#include <X11/Intrinsic.h>
  260. X#include <X11/Shell.h>
  261. X#include <Xm/MainW.h>
  262. X#include <Xm/BulletinB.h>
  263. X#include <Xm/PushB.h>
  264. X
  265. X/* vi: set tabstop=4 shiftwidth=4: */
  266. X/* end of xincs.h */
  267. SHAR_EOF
  268. chmod 0644 x386mon/xincs.h ||
  269. echo 'restore of x386mon/xincs.h failed'
  270. Wc_c="`wc -c < 'x386mon/xincs.h'`"
  271. test 489 -eq "$Wc_c" ||
  272.     echo 'x386mon/xincs.h: original size 489, current size' "$Wc_c"
  273. fi
  274. # ============= x386mon/xprocs.c ==============
  275. if test -f 'x386mon/xprocs.c' -a X"$1" != X"-c"; then
  276.     echo 'x - skipping x386mon/xprocs.c (File already exists)'
  277. else
  278. echo 'x - extracting x386mon/xprocs.c (Text)'
  279. sed 's/^X//' << 'SHAR_EOF' > 'x386mon/xprocs.c' &&
  280. X/*+-------------------------------------------------------------------------
  281. X    xprocs.c - X386MON X interface (fonts, colors)
  282. X    wht@n4hgf.Mt-Park.GA.US
  283. X
  284. X  Defined functions:
  285. X    alloc_color(color_name,rtn)
  286. X    choose_MyFont()
  287. X    init_MyFonts()
  288. X    init_color()
  289. X    use_MyFont(num)
  290. X
  291. X--------------------------------------------------------------------------*/
  292. X/*+:EDITS:*/
  293. X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */
  294. X
  295. X#include "x386mon.h"
  296. X
  297. XXColor colorBackground;
  298. XXColor colorForeground;
  299. XXColor colorBlack;
  300. XXColor colorRed;
  301. XXColor colorOrange;
  302. XXColor colorYellow;
  303. XXColor colorGreen;
  304. XXColor colorBlue;
  305. XXColor colorSlate;
  306. XXColor colorCyan;
  307. X
  308. Xunsigned long foreground;
  309. Xunsigned long background;
  310. X
  311. XMyFontStruct my_fonts[] =
  312. X{
  313. X    {"6x10"},
  314. X    {(char *)0}
  315. X};
  316. X#define MyFont_QUANTITY  4
  317. X
  318. XMyFontStruct *currentMyFont = (MyFontStruct *)0;
  319. X
  320. X/*+-------------------------------------------------------------------------
  321. X    use_MyFont(num)
  322. X--------------------------------------------------------------------------*/
  323. Xvoid
  324. Xuse_MyFont(num)
  325. Xint num;
  326. X{
  327. X    currentMyFont = &my_fonts[num];
  328. X    XSetFont(display,gc,currentMyFont->fid);
  329. X
  330. X}    /* end of use_MyFont */
  331. X
  332. X/*+-------------------------------------------------------------------------
  333. X    choose_MyFont() - choose font based on current window size
  334. X--------------------------------------------------------------------------*/
  335. Xvoid
  336. Xchoose_MyFont()
  337. X{
  338. X}    /* end of choose_MyFont */
  339. X
  340. X/*+-------------------------------------------------------------------------
  341. X    init_MyFonts()
  342. X--------------------------------------------------------------------------*/
  343. Xvoid
  344. Xinit_MyFonts()
  345. X{
  346. Xregister MyFontStruct *thisMyFont = my_fonts;
  347. X
  348. X    while(thisMyFont->name)
  349. X    {
  350. X        if((thisMyFont->fid = XLoadFont(display,thisMyFont->name)) != BadName)
  351. X        {
  352. X            thisMyFont->font_struct = XQueryFont(display,thisMyFont->fid);
  353. X            thisMyFont->width = thisMyFont->font_struct->max_bounds.width;
  354. X            thisMyFont->height =
  355. X                thisMyFont->font_struct->max_bounds.ascent +
  356. X                thisMyFont->font_struct->max_bounds.descent;
  357. X            thisMyFont->gap = thisMyFont->height / 3;
  358. X        }
  359. X        else
  360. X            thisMyFont->width = 0;
  361. X        thisMyFont++;
  362. X    }
  363. X
  364. X    use_MyFont(0);
  365. X
  366. X}    /* end of init_MyFonts */
  367. X
  368. X/*+-------------------------------------------------------------------------
  369. X    alloc_color(color_name,rtn)
  370. X--------------------------------------------------------------------------*/
  371. Xint
  372. Xalloc_color(color_name,rtn)
  373. Xregister char *color_name;
  374. XXColor *rtn;
  375. X{
  376. X    XColor exact;
  377. X    XColor color;
  378. X    Status ret;
  379. X
  380. X    if( ((ret = XAllocNamedColor(display,cmap,color_name,
  381. X            &exact,&color)) == BadColor) || (ret == BadValue))
  382. X    {
  383. X        *rtn = colorBlack;
  384. X        return(-1);
  385. X    }
  386. X    *rtn = exact;
  387. X    return(0);
  388. X
  389. X}    /* end of alloc_color */
  390. X
  391. X/*+-------------------------------------------------------------------------
  392. X    init_color()
  393. X--------------------------------------------------------------------------*/
  394. Xvoid
  395. Xinit_color()
  396. X{
  397. X    alloc_color("black",&colorBlack);    /* first */
  398. X
  399. X    alloc_color(res.background,&colorBackground);
  400. X    background = colorBackground.pixel;
  401. X
  402. X    alloc_color(res.foreground,&colorForeground);
  403. X    foreground = colorForeground.pixel;
  404. X
  405. X    alloc_color("gray",&colorSlate);
  406. X
  407. X    if(alloc_color("red",&colorRed))
  408. X        colorRed = colorForeground;
  409. X
  410. X    if(alloc_color("yellow",&colorYellow))
  411. X        colorRed = colorForeground;
  412. X
  413. X    if(alloc_color("green",&colorGreen))
  414. X        colorGreen = colorForeground;
  415. X
  416. X    if(alloc_color("blue",&colorBlue))
  417. X        colorBlue = colorForeground;
  418. X
  419. X    if(alloc_color("cyan",&colorCyan))
  420. X        colorCyan = colorForeground;
  421. X
  422. X    if(alloc_color("orange",&colorOrange))
  423. X        colorOrange = colorForeground;
  424. X
  425. X}    /* end of init_color */
  426. X
  427. X/* vi: set tabstop=4 shiftwidth=4: */
  428. X/* end of xprocs.c */
  429. SHAR_EOF
  430. chmod 0644 x386mon/xprocs.c ||
  431. echo 'restore of x386mon/xprocs.c failed'
  432. Wc_c="`wc -c < 'x386mon/xprocs.c'`"
  433. test 3597 -eq "$Wc_c" ||
  434.     echo 'x386mon/xprocs.c: original size 3597, current size' "$Wc_c"
  435. fi
  436. exit 0
  437.  
  438. -----------------------------------------------------------------------
  439. Warren Tucker, TuckerWare   gatech!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US
  440. Many [Nobel physics] prizes  have been given  to people for  telling us
  441. the universe is not as simple as we thought it was. -Stephen Hawking in
  442. A Brief History of Time     In computing, there are no such prizes. -me
  443.