home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume22 / u386mon / part07 < prev    next >
Text File  |  1991-08-13  |  47KB  |  1,701 lines

  1. Newsgroups: comp.sources.misc
  2. From: Warren Tucker <wht@n4hgf.Mt-Park.GA.US>
  3. Subject:  v22i009:  u386mon - Sys V Rel 3.x Performance Monitor rev 2.40, Part07/07
  4. Message-ID: <1991Aug14.011750.15522@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 3293eec8bbc4bc4dbf8a01f5206a90b9
  6. Date: Wed, 14 Aug 1991 01:17:50 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Warren Tucker <wht@n4hgf.Mt-Park.GA.US>
  10. Posting-number: Volume 22, Issue 9
  11. Archive-name: u386mon/part07
  12. Environment: SYSVR3
  13. Supersedes: u386mon-2.20: Volume 14, Issue 54-58
  14.  
  15. #!/bin/sh
  16. # This is part 07 of u386mon.3.40
  17. # ============= lint_args.h ==============
  18. if test -f 'lint_args.h' -a X"$1" != X"-c"; then
  19.     echo 'x - skipping lint_args.h (File already exists)'
  20. else
  21. echo 'x - extracting lint_args.h (Text)'
  22. sed 's/^X//' << 'SHAR_EOF' > 'lint_args.h' &&
  23. X/*+-----------------------------------------------------------------------
  24. X    lint_args.h
  25. X------------------------------------------------------------------------*/
  26. X/*+:EDITS:*/
  27. X/*:08-01-1991-23:34-wht@n4hgf-release 3.40 source control point */
  28. X/*:08-10-1990-14:12-jmd@p1so/wht@n4hgf-2.20-add Tandem Integrity S2 */
  29. X/*:08-07-1990-14:24-wht@n4hgf-nba@sysware.dk SVR31 updates */
  30. X/*:08-02-1990-15:36-wht@n4hgf-2.12-old curses hacks+minor 3.2 formalizations */
  31. X/*:07-28-1990-18:06-wht@n4hgf-2.10 release */
  32. X/*:07-21-1990-16:01-afterlint-creation */
  33. X
  34. X#ifndef BUILDING_LINT_ARGS
  35. X#ifdef LINT_ARGS
  36. X
  37. X/* bootinfo.c */
  38. Xextern  char *bmemf_text(unsigned long flags);
  39. Xextern  void display_bootinfo(struct _win_st *win,int y,int x);
  40. X/* det_proc.c */
  41. Xextern  char *get_cpu_time_str(long ticks);
  42. Xextern  char *pgrp_to_ttyname(int pgrp);
  43. Xextern  char *uid_to_name(unsigned short uid);
  44. Xextern  int det_proc_init(void );
  45. Xextern  int get_user(struct proc *tproc,struct user *tuser);
  46. Xextern  int getpwent_and_enter(unsigned short uid);
  47. Xextern  int ppproc_pid_compare(struct proc * *ppp1,struct proc * *ppp2);
  48. Xextern  int uid_name_enter(unsigned short uid,char *name);
  49. Xextern  struct utmp *find_utmp_for_pgrp(int pgrp);
  50. Xextern  void display_proc_stat(struct _win_st *win,int iproc,int initial);
  51. Xextern  void display_proc_stats(struct _win_st *win,int initial);
  52. Xextern  void init_uid_name_hash(void );
  53. Xextern  void read_and_sort_procs(int initial);
  54. Xextern  void read_utmp(void );
  55. X/* det_sio.c */
  56. Xextern  char *B_to_baud_rate(int code);
  57. Xextern  char *cflag_to_baud_d_p_s(int cflag);
  58. Xextern  int display_sio_summary(struct _win_st *win,int initial);
  59. Xextern  int tty_slot_compare(struct tty *sio1,struct tty *sio2);
  60. Xextern  void display_siofull_init(struct _win_st *win,int tly,int tlx,int show_flag);
  61. Xextern  void display_siofull_update(struct _win_st *win,int tly,int tlx,struct tty *tsio);
  62. Xextern  void display_siosum_update(struct _win_st *win,int y,struct tty *tsio);
  63. Xextern  void grok_sio_tty(void );
  64. X/* detail.c */
  65. Xextern  void detail_init(void );
  66. Xextern  void detail_panel_cmd(unsigned long cmd);
  67. Xextern  void detail_panel_update(void );
  68. Xextern  void detpanel_destroy(void );
  69. Xextern  void detpanel_extra_init(void );
  70. Xextern  void detpanel_extra_update(void );
  71. Xextern  void detpanel_ps_init(int full43);
  72. Xextern  void detpanel_ps_update(void );
  73. Xextern  void detpanel_sio_init(void );
  74. Xextern  void detpanel_sio_update(void );
  75. X/* disputil.c */
  76. Xextern  PANEL *mkpanel(int rows,int cols,int tly,int tlx,char *userp);
  77. Xextern  void clear_area(struct _win_st *win,int y,int x,int len);
  78. Xextern  void clear_area_char(struct _win_st *win,int y,int x,int len,unsigned char fillchar);
  79. Xextern  void disp_info_int(struct _win_st *win,char *label,char *fmt,int value);
  80. Xextern  void disp_info_long(struct _win_st *win,char *label,char *fmt,long value);
  81. Xextern  void disp_msg(unsigned long cp,char *msg);
  82. Xextern  void disp_static_int(struct _win_st *win,char *label,char *fmt,int value);
  83. Xextern  void disp_static_long(struct _win_st *win,char *label,char *fmt,long value);
  84. Xextern  void pflush(void );
  85. Xextern  void wperror(struct _win_st *win,char *desc);
  86. X/* libkmem.c */
  87. Xextern  void kinit(int write_needed);
  88. Xextern  void kread(char *caddr,long kaddr,int len);
  89. X/* libmem.c */
  90. Xextern  void minit(int write_needed);
  91. Xextern  void mread(char *caddr,long maddr,int len);
  92. X/* libnlsym.c */
  93. Xextern  void nlsym_error(char *text);
  94. Xextern  void nlsym_read(void );
  95. X/* libswap.c */
  96. Xextern  void sinit(void );
  97. Xextern  void sread(char *caddr,long maddr,int len);
  98. X/* nlsym.c */
  99. Xextern  int main(int argc,char * *argv,char * *envp);
  100. Xextern  void nlsym_write_error(int code);
  101. X/* proc.c */
  102. Xextern  char *pstat_text(char pstat);
  103. Xextern  void display_proc(struct _win_st *win,int y,int x);
  104. Xextern  void grok_proc(void );
  105. X/* tune.c */
  106. Xextern  void display_tune(struct _win_st *win,int y,int x);
  107. X/* u386mon.c */
  108. Xextern  char *get_elapsed_time(long elapsed_seconds);
  109. Xextern  int get_cpu_avg(long *cpu_ticks,int period);
  110. Xextern  int get_wait_avg(long *wait_ticks,int period);
  111. Xextern  int main(int argc,char * *argv,char * *envp);
  112. Xextern  long update_cpuscale(struct _win_st *win,int y,int x,int width,long *per_state);
  113. Xextern  long update_waitscale(struct _win_st *win,int y,int x,int width,long *per_state,long total_ticks);
  114. Xextern  void calc_cpu_avg(long *per_state);
  115. Xextern  void calc_wait_avg(long *per_state);
  116. Xextern  void caught_signal(int sig);
  117. Xextern  void draw_cpuscale_literals(struct _win_st *win,int y,int x);
  118. Xextern  void draw_per_sec_literals(struct _win_st *win,int y,int x);
  119. Xextern  void draw_waitscale_literals(struct _win_st *win,int y,int x);
  120. Xextern  void extra_info_stuff(void );
  121. Xextern  void extra_static_stuff(void );
  122. Xextern  void leave(int exit_code);
  123. Xextern  void leave_text(char *text,int exit_code);
  124. Xextern  void leaving(void );
  125. Xextern  void read_sysinfo_and_minfo(void );
  126. X/* var.c */
  127. Xextern  void display_var(struct _win_st *win,int y,int x);
  128. X
  129. X#else        /* compiler doesn't know about prototyping */
  130. X
  131. X/* bootinfo.c */
  132. Xextern  char *bmemf_text();
  133. Xextern  void display_bootinfo();
  134. X/* det_proc.c */
  135. Xextern  char *get_cpu_time_str();
  136. Xextern  char *pgrp_to_ttyname();
  137. Xextern  char *uid_to_name();
  138. Xextern  int det_proc_init();
  139. Xextern  int get_user();
  140. Xextern  int getpwent_and_enter();
  141. Xextern  int ppproc_pid_compare();
  142. Xextern  int uid_name_enter();
  143. Xextern  struct utmp *find_utmp_for_pgrp();
  144. Xextern  void display_proc_stat();
  145. Xextern  void display_proc_stats();
  146. Xextern  void init_uid_name_hash();
  147. Xextern  void read_and_sort_procs();
  148. Xextern  void read_utmp();
  149. X/* det_sio.c */
  150. Xextern  char *B_to_baud_rate();
  151. Xextern  char *cflag_to_baud_d_p_s();
  152. Xextern  int display_sio_summary();
  153. Xextern  int tty_slot_compare();
  154. Xextern  void display_siofull_init();
  155. Xextern  void display_siofull_update();
  156. Xextern  void display_siosum_update();
  157. Xextern  void grok_sio_tty();
  158. X/* detail.c */
  159. Xextern  void detail_init();
  160. Xextern  void detail_panel_cmd();
  161. Xextern  void detail_panel_update();
  162. Xextern  void detpanel_destroy();
  163. Xextern  void detpanel_extra_init();
  164. Xextern  void detpanel_extra_update();
  165. Xextern  void detpanel_ps_init();
  166. Xextern  void detpanel_ps_update();
  167. Xextern  void detpanel_sio_init();
  168. Xextern  void detpanel_sio_update();
  169. X/* disputil.c */
  170. Xextern  PANEL *mkpanel();
  171. Xextern  void clear_area();
  172. Xextern  void clear_area_char();
  173. Xextern  void disp_info_int();
  174. Xextern  void disp_info_long();
  175. Xextern  void disp_msg();
  176. Xextern  void disp_static_int();
  177. Xextern  void disp_static_long();
  178. Xextern  void pflush();
  179. Xextern  void wperror();
  180. X/* libkmem.c */
  181. Xextern  void kinit();
  182. Xextern  void kread();
  183. X/* libmem.c */
  184. Xextern  void minit();
  185. Xextern  void mread();
  186. X/* libnlsym.c */
  187. Xextern  void nlsym_error();
  188. Xextern  void nlsym_read();
  189. X/* libswap.c */
  190. Xextern  void sinit();
  191. Xextern  void sread();
  192. X/* nlsym.c */
  193. Xextern  int main();
  194. Xextern  void nlsym_write_error();
  195. X/* proc.c */
  196. Xextern  char *pstat_text();
  197. Xextern  void display_proc();
  198. Xextern  void grok_proc();
  199. X/* tune.c */
  200. Xextern  void display_tune();
  201. X/* u386mon.c */
  202. Xextern  char *get_elapsed_time();
  203. Xextern  int get_cpu_avg();
  204. Xextern  int get_wait_avg();
  205. Xextern  int main();
  206. Xextern  long update_cpuscale();
  207. Xextern  long update_waitscale();
  208. Xextern  void calc_cpu_avg();
  209. Xextern  void calc_wait_avg();
  210. Xextern  void caught_signal();
  211. Xextern  void draw_cpuscale_literals();
  212. Xextern  void draw_per_sec_literals();
  213. Xextern  void draw_waitscale_literals();
  214. Xextern  void extra_info_stuff();
  215. Xextern  void extra_static_stuff();
  216. Xextern  void leave();
  217. Xextern  void leave_text();
  218. Xextern  void leaving();
  219. Xextern  void read_sysinfo_and_minfo();
  220. X/* var.c */
  221. Xextern  void display_var();
  222. X
  223. X#endif /* LINT_ARGS */
  224. X#endif /* BUILDING_LINT_ARGS */
  225. X
  226. X/* end of lint_args.h */
  227. SHAR_EOF
  228. chmod 0644 lint_args.h ||
  229. echo 'restore of lint_args.h failed'
  230. Wc_c="`wc -c < 'lint_args.h'`"
  231. test 7620 -eq "$Wc_c" ||
  232.     echo 'lint_args.h: original size 7620, current size' "$Wc_c"
  233. fi
  234. # ============= nlsym.h ==============
  235. if test -f 'nlsym.h' -a X"$1" != X"-c"; then
  236.     echo 'x - skipping nlsym.h (File already exists)'
  237. else
  238. echo 'x - extracting nlsym.h (Text)'
  239. sed 's/^X//' << 'SHAR_EOF' > 'nlsym.h' &&
  240. X/*+-------------------------------------------------------------------------
  241. X    nlsym.h -- utility nlist - fast access to kernel /dev/kmem offsets
  242. X    ...!{gatech,emory}!n4hgf!wht
  243. X
  244. XThe nlsym file contains three records:
  245. X1.  struct stat unixstat - stat buffer from /unix at file creation time
  246. X2.  struct nlist nlsym - the structure of nlist'd information
  247. X3.  long unique - a unique identifier to help ensure correct nlsym length
  248. X
  249. X--------------------------------------------------------------------------*/
  250. X/*+:EDITS:*/
  251. X/*:08-01-1991-23:34-wht@n4hgf-release 3.40 source control point */
  252. X/*:05-15-1991-17:22-wht@n4hgf-2.3 patches for SVR31 from nba@sysware.dk */
  253. X/*:04-16-1991-02:25-martin@hppcmart additions for SCO 3.2.2 */
  254. X/*:08-10-1990-14:12-jmd@p1so/wht@n4hgf-2.20-add Tandem Integrity S2 */
  255. X/*:08-07-1990-14:24-wht@n4hgf-nba@sysware.dk SVR31 updates */
  256. X/*:08-02-1990-15:36-wht@n4hgf-2.12-old curses hacks+minor 3.2 formalizations */
  257. X/*:07-28-1990-18:06-wht@n4hgf-2.10 release */
  258. X/*:06-27-1990-01:57-wht@n4hgf-1.10-incorporate suggestions from alpha testers */
  259. X/*:06-27-1990-01:55-wht@n4hgf-use 64 bits of unique check */
  260. X/*:06-25-1990-04:14-wht@n4hgf-1.02-better error handling */
  261. X/*:06-24-1990-20:53-wht@n4hgf-v1.01-add ISC support thanks to peter@radig.de */
  262. X/*:06-21-1990-14:26-r@n4hgf-version x0.12 seems bug free */
  263. X/*:10-27-1988-11:07-wht-creation */
  264. X
  265. X#define UNIX_KERNEL        "/unix"
  266. X#define UNIX_NLSYM        "/unix.nlsym"
  267. X#define NLSYM_UNIQUE1    0x1BADD00DL
  268. X#define NLSYM_UNIQUE2    0xDEADB1FFL
  269. X
  270. X#define Nindex_AVAILRMEM            0
  271. X#define Nindex_AVAILSMEM            1
  272. X#define Nindex_BDEVCNT              2
  273. X#define Nindex_BDEVSW               3
  274. X#if defined(HAS_BOOTINFO)
  275. X#define Nindex_BOOTINFO             4
  276. X#else
  277. X#endif
  278. X#define Nindex_CDEVCNT              5
  279. X#define Nindex_CDEVSW               6
  280. X#define Nindex_CFREE                7
  281. X#define Nindex_CFREECNT             8
  282. X#define Nindex_CFREELIST            9
  283. X#define Nindex_CONSSW              10
  284. X#define Nindex_CURPROC             11
  285. X#define Nindex_DINFO               12
  286. X#define Nindex_DSTFLAG             13
  287. X#define Nindex_DUMPDEV             14
  288. X#define Nindex_EMAP                15
  289. X#define Nindex_FFREELIST           16
  290. X#define Nindex_FILE                17
  291. X#define Nindex_FMODCNT             18
  292. X#define Nindex_FMODSW              19
  293. X#define Nindex_FREEMEM             20
  294. X#define Nindex_FSINFO              21
  295. X#define Nindex_FSTYPSW             22
  296. X#define Nindex_HZ                  23
  297. X#define Nindex_IDLESERVER          24
  298. X#define Nindex_IFREELIST           25
  299. X#define Nindex_INODE               26
  300. X#define Nindex_KPTBL               27
  301. X#define Nindex_LBOLT               28
  302. X#define Nindex_LINECNT             29
  303. X#define Nindex_LINESW              30
  304. X#define Nindex_MAXCLICK            31
  305. X#define Nindex_MAXMEM              32
  306. X#define Nindex_MINFO               33
  307. X#define Nindex_MOUNT               34
  308. X#define Nindex_MSGLISTCNT          35
  309. X#define Nindex_NFSTYP              36
  310. X#define Nindex_NPTALLOCED          37
  311. X#define Nindex_NPTFREE             38
  312. X#define Nindex_NSERVERS            39
  313. X#define Nindex_NSWAP               40
  314. X#define Nindex_NSYSENT             41
  315. X#define Nindex_OLDPROC             42
  316. X#define Nindex_OLD_CURPROC         43
  317. X#define Nindex_PANICSTR            44
  318. X#define Nindex_PHYSMEM             45
  319. X#define Nindex_PIPEDEV             46
  320. X#define Nindex_PROC                47
  321. X#define Nindex_RCINFO              48
  322. X#define Nindex_ROOTDEV             49
  323. X#define Nindex_RUNQ                50
  324. X#define Nindex_SHLBINFO            51
  325. X#define Nindex_SWAPDEV             52
  326. X#define Nindex_SWPLO               53
  327. X#define Nindex_SYSERR              54
  328. X#define Nindex_SYSINFO             55
  329. X#define Nindex_SYSSEGS             56
  330. X#define Nindex_SYSWAIT             57
  331. X#define Nindex_TIME                58
  332. X#define Nindex_TIMEZONE            59
  333. X#define Nindex_TTHIWAT             60
  334. X#define Nindex_TTLOWAT             61
  335. X#define Nindex_TUNE                62
  336. X#define Nindex_U                   63
  337. X#define Nindex_USERTABLE           64
  338. X#define Nindex_V                   65
  339. X#define Nindex_WIN_UBLK            66
  340. X#define Nindex_REGION              67
  341. X#if defined(M_UNIX)
  342. X#define Nindex_SIO_TTY             68
  343. X#endif
  344. X#if defined(M_UNIX) || defined(SVR31)
  345. X#define Nindex_STRST           69
  346. X#define Nindex_RBSIZE           70
  347. X#define Nindex_NMBLOCK           71
  348. X#define Nindex_FLCKINFO           72
  349. X#define Nindex_RACTIVE           73
  350. X#define Nindex_CALLOUT           74
  351. X#ifdef SCO322
  352. X#define Nindex_FLSTATS           75
  353. X#define Nindex_WD1010STATS       76
  354. X#endif
  355. X#endif
  356. X
  357. X#if defined(HAS_BOOTINFO)
  358. X#define bootinfoaddr (nlsym[Nindex_BOOTINFO].n_value)
  359. X#endif
  360. X#define freememaddr (nlsym[Nindex_FREEMEM].n_value)
  361. X#define lboltaddr (nlsym[Nindex_LBOLT].n_value)
  362. X#define maxmemaddr (nlsym[Nindex_MAXMEM].n_value)
  363. X#define minfoaddr (nlsym[Nindex_MINFO].n_value)
  364. X#define nswapaddr (nlsym[Nindex_NSWAP].n_value)
  365. X#define physmemaddr (nlsym[Nindex_PHYSMEM].n_value)
  366. X#define procaddr (nlsym[Nindex_PROC].n_value)
  367. X#define regionaddr (nlsym[Nindex_REGION].n_value)
  368. X#define sysinfoaddr (nlsym[Nindex_SYSINFO].n_value)
  369. X#define tuneaddr (nlsym[Nindex_TUNE].n_value)
  370. X#define vaddr (nlsym[Nindex_V].n_value)
  371. X#if defined(M_UNIX)
  372. X#define sio_ttyaddr (nlsym[Nindex_SIO_TTY].n_value)
  373. X#endif
  374. X#if defined(M_UNIX) || defined(SVR31)
  375. X#define strstaddr (nlsym[Nindex_STRST].n_value)
  376. X#define rbsizeaddr (nlsym[Nindex_RBSIZE].n_value)
  377. X#define nmblockaddr (nlsym[Nindex_NMBLOCK].n_value)
  378. X#define flckinfoaddr (nlsym[Nindex_FLCKINFO].n_value)
  379. X#define fileaddr (nlsym[Nindex_FILE].n_value)
  380. X#define ifreelistaddr (nlsym[Nindex_IFREELIST].n_value)
  381. X#define inodeaddr (nlsym[Nindex_INODE].n_value)
  382. X#define ffreelistaddr (nlsym[Nindex_FFREELIST].n_value)
  383. X#define ractiveaddr (nlsym[Nindex_RACTIVE].n_value)
  384. X#define cfreecntaddr (nlsym[Nindex_CFREECNT].n_value)
  385. X#define calloutaddr (nlsym[Nindex_CALLOUT].n_value)
  386. X#endif /* defined(M_UNIX) || defined(SVR31) */
  387. X#ifdef SCO322
  388. X#define flstatsaddr (nlsym[Nindex_FLSTATS].n_value)
  389. X#define wd1010statsaddr (nlsym[Nindex_WD1010STATS].n_value)
  390. X#endif /* SCO322 */
  391. X
  392. X#ifdef DEFINE_NLSYM
  393. Xstruct nlist nlsym[] =
  394. X{
  395. X    { "availrmem" },
  396. X    { "availsmem" },
  397. X    { "bdevcnt" },
  398. X    { "bdevsw" },
  399. X#if defined(HAS_BOOTINFO)
  400. X    { "bootinfo" },
  401. X#else
  402. X    { "spl" },    /*
  403. X                 * dummy argument: unique text symbol present in all
  404. X                 * implimenations (function name helps ensure uniqueness
  405. X                 * since we don't "do" text)
  406. X                 */
  407. X#endif
  408. X    { "cdevcnt" },
  409. X    { "cdevsw" },
  410. X    { "cfree" },
  411. X    { "cfreecnt" },
  412. X    { "cfreelist" },
  413. X    { "conssw" },
  414. X    { "curproc" },
  415. X    { "dinfo" },
  416. X    { "Dstflag" },
  417. X    { "dumpdev" },
  418. X    { "emap" },
  419. X    { "ffreelist" },
  420. X    { "file" },
  421. X    { "fmodcnt" },
  422. X    { "fmodsw" },
  423. X    { "freemem" },
  424. X    { "fsinfo" },
  425. X    { "fstypsw" },
  426. X    { "Hz" },
  427. X    { "idleserver" },
  428. X    { "ifreelist" },
  429. X    { "inode" },
  430. X    { "kptbl" },
  431. X    { "lbolt" },
  432. X    { "linecnt" },
  433. X    { "linesw" },
  434. X    { "maxclick" },
  435. X    { "maxmem" },
  436. X    { "minfo" },
  437. X    { "mount" },
  438. X    { "msglistcnt" },
  439. X    { "nfstyp" },
  440. X    { "nptalloced" },
  441. X    { "nptfree" },
  442. X    { "nservers" },
  443. X    { "nswap" },
  444. X    { "nsysent" },
  445. X    { "oldproc" },
  446. X    { "old_curproc" },
  447. X    { "panicstr" },
  448. X    { "physmem" },
  449. X    { "pipedev" },
  450. X    { "proc" },
  451. X    { "rcinfo" },
  452. X    { "rootdev" },
  453. X    { "runq" },
  454. X    { "shlbinfo" },
  455. X    { "swapdev" },
  456. X    { "swplo" },
  457. X    { "syserr" },
  458. X    { "sysinfo" },
  459. X    { "syssegs" },
  460. X    { "syswait" },
  461. X    { "time" },
  462. X    { "Timezone" },
  463. X    { "tthiwat" },
  464. X    { "ttlowat" },
  465. X    { "tune" },
  466. X    { "u" },
  467. X    { "usertable" },
  468. X    { "v" },
  469. X    { "win_ublk" },
  470. X    { "region" },
  471. X#if defined(M_UNIX)
  472. X    { "sio_tty" },
  473. X#else
  474. X    { "spl" },
  475. X#endif
  476. X#if defined(M_UNIX) || defined(SVR31)
  477. X    { "strst" },
  478. X    { "rbsize" },
  479. X    { "nmblock" },
  480. X    { "flckinfo" },
  481. X    { "ractive" },
  482. X    { "callout" },
  483. X#ifdef SCO322
  484. X    { "flstats" },
  485. X    { "wd1010stats" },
  486. X#endif
  487. X#endif
  488. X    { (char *)0 }
  489. X};
  490. X#else
  491. Xextern struct nlist nlsym[];
  492. X#endif
  493. X
  494. X/* vi: set tabstop=4 shiftwidth=4: */
  495. SHAR_EOF
  496. chmod 0644 nlsym.h ||
  497. echo 'restore of nlsym.h failed'
  498. Wc_c="`wc -c < 'nlsym.h'`"
  499. test 7654 -eq "$Wc_c" ||
  500.     echo 'nlsym.h: original size 7654, current size' "$Wc_c"
  501. fi
  502. # ============= u386mon.h ==============
  503. if test -f 'u386mon.h' -a X"$1" != X"-c"; then
  504.     echo 'x - skipping u386mon.h (File already exists)'
  505. else
  506. echo 'x - extracting u386mon.h (Text)'
  507. sed 's/^X//' << 'SHAR_EOF' > 'u386mon.h' &&
  508. X/*+-------------------------------------------------------------------------
  509. X    u386mon.h - UNIX 386 system monitor definitions
  510. X    wht@n4hgf.Mt-Park.GA.US
  511. X--------------------------------------------------------------------------*/
  512. X/*+:EDITS:*/
  513. X/*:08-01-1991-23:35-wht@n4hgf-release 3.40 source control point */
  514. X/*:08-10-1990-14:12-jmd@p1so/wht@n4hgf-2.20-add Tandem Integrity S2 */
  515. X/*:08-07-1990-14:24-wht@n4hgf-nba@sysware.dk SVR31 updates */
  516. X/*:08-02-1990-15:36-wht@n4hgf-2.12-old curses hacks+minor 3.2 formalizations */
  517. X/*:07-28-1990-18:06-wht@n4hgf-2.10 release */
  518. X/*:07-10-1990-19:06-root@n4hgf-redesign attributes/color pairs */
  519. X/*:07-10-1990-18:33-root@n4hgf-move pio wait to medium alert */
  520. X/*:07-03-1990-03:21-root@n4hgf-add cpBANWARN and renumber */
  521. X/*:06-27-1990-01:57-wht@n4hgf-1.10-incorporate suggestions from alpha testers */
  522. X/*:06-25-1990-04:14-wht@n4hgf-1.02-better error handling */
  523. X/*:06-24-1990-20:53-wht@n4hgf-v1.01-add ISC support thanks to peter@radig.de */
  524. X/*:06-21-1990-14:27-r@n4hgf-version x0.12 seems bug free */
  525. X/*:06-20-1990-03:03-root@n4hgf-trick use_cp into making bright fgnd colors */
  526. X/*:06-19-1990-21:35-wht-get ready for release */
  527. X
  528. X#ifndef M_SYSV    /* for ISC */
  529. X#define u_char unsigned char
  530. X#define u_long unsigned long
  531. X#endif
  532. X
  533. Xchar *getenv();
  534. Xchar *strchr();
  535. Xchar *strrchr();
  536. X#ifdef __STDC__
  537. Xvoid *malloc();
  538. X#else
  539. Xchar *malloc();
  540. X#endif
  541. X
  542. X#define pW(pan) panel_window(pan)
  543. X#define W WINDOW
  544. X#define P PANEL
  545. X
  546. X/* color numbers for EGA/VGA */
  547. X#ifdef COLOR_16_TERMINFO    /* wht 16-color fgnd/bgnd terminfo */
  548. X#define cHIBIT    8
  549. X#define cBLK    0
  550. X#define cBLU    1
  551. X#define cGRN    2
  552. X#define cCYN    3
  553. X#define cRED    4
  554. X#define cMAG    5
  555. X#define cBRN    6
  556. X#define cWHT    7
  557. X#define cGRY    (cBLK | cHIBIT)
  558. X#define cLTB    (cBLU | cHIBIT)
  559. X#define cLTG    (cGRN | cHIBIT)
  560. X#define cLTC    (cCYN | cHIBIT)
  561. X#define cLTR    (cRED | cHIBIT)
  562. X#define cLTM    (cMAG | cHIBIT)
  563. X#define cYEL    (cBRN | cHIBIT)
  564. X#define cHIW    (cWHT | cHIBIT)
  565. X#else
  566. X#ifdef    COLOR_BLACK
  567. X#define cBLK    COLOR_BLACK
  568. X#define cBLU    COLOR_BLUE
  569. X#define cGRN    COLOR_GREEN
  570. X#define cCYN    COLOR_CYAN
  571. X#define cRED    COLOR_RED
  572. X#define cMAG    COLOR_MAGENTA
  573. X#define cBRN    COLOR_YELLOW
  574. X#define cWHT    COLOR_WHITE
  575. X#define cGRY    COLOR_BLACK
  576. X#define cLTB    COLOR_BLUE
  577. X#define cLTG    COLOR_GREEN
  578. X#define cLTC    COLOR_CYAN
  579. X#define cLTR    COLOR_RED
  580. X#define cLTM    COLOR_MAGENTA
  581. X#define cYEL    COLOR_YELLOW
  582. X#define cHIW    COLOR_WHITE
  583. X#endif
  584. X#endif
  585. X
  586. X#define sTL        0xDA
  587. X#define sTR        0xBF
  588. X#define sBL        0xC0
  589. X#define sBR        0xD9
  590. X#define sLT        0xC3    /* left hand T */
  591. X#define sRT        0xB4    /* right hand T */
  592. X#define sVR        0xB3    /* vertical rule */
  593. X#define sHR        0xC4    /* horizontal rule */
  594. X
  595. X/* color pairs */
  596. X#ifdef COLOR_16_TERMINFO    /* wht 16-color fgnd/bgnd terminfo */
  597. X#define use_cp(win,cp) wattrset(win,COLOR_PAIR(cp))
  598. X#else
  599. X#ifdef COLOR_PAIR
  600. X#define use_cp(win,cp) wattrset(win,\
  601. X    (color_avail) ? color_attr[cp] : mono_attr[cp])
  602. X#else
  603. X#define use_cp(win,cp) wattrset(win,mono_attr[cp])
  604. X#endif
  605. X#endif
  606. X
  607. X/*
  608. X * for SVR31
  609. X */
  610. X#ifndef getcury
  611. X#define getcury(win)        ((win)->_cury)
  612. X#endif
  613. X#ifndef getcurx
  614. X#define getcurx(win)        ((win)->_curx)
  615. X#endif
  616. X#ifndef getbegy
  617. X#define getbegy(win)        ((win)->_begy)
  618. X#endif
  619. X#ifndef getbegx
  620. X#define getbegx(win)        ((win)->_begx)
  621. X#endif
  622. X#ifndef getbegyx
  623. X#define getbegyx(win,y,x)   ((y)=getbegy(win),(x)=getbegx(win))
  624. X#endif
  625. X#ifndef getmaxy
  626. X#define getmaxy(win)        ((win)->_maxy)
  627. X#endif
  628. X#ifndef getmaxx
  629. X#define getmaxx(win)        ((win)->_maxx)
  630. X#endif
  631. X#ifndef getmaxyx
  632. X#define getmaxyx(win,y,x)   ((y)=getmaxy(win),(x)=getmaxx(win))
  633. X#endif
  634. X
  635. X/* 
  636. X * if color par numbers are changed, disputil.c
  637. X * color_attr and mono_attr tables
  638. X * must also be changed
  639. X */
  640. X
  641. X#define cpINFO        1    /* information field */
  642. X#define cpREVERSE    2    /* "reverse video" */
  643. X#define cpBANWARN    3    /* banner warning */
  644. X#define cpLOW        4    /* low/user/io */
  645. X#define cpMED        5    /* medium/kernel/pio */
  646. X#define cpHIGH        6    /* high/brk/swp */
  647. X#define cpBANNER    7    /* banner */
  648. X#define cpLIT        8    /* field literals */
  649. Xextern int color_avail;
  650. X#ifdef COLOR_PAIR
  651. Xextern long color_attr[];
  652. X#endif
  653. Xextern long mono_attr[];
  654. X
  655. X#define MSG_TLY        (LINES - 2)
  656. X#define CMD_TLY        (LINES - 1)
  657. X#define LVMSG_Y        MSG_TLY
  658. X#define LVMSG_X        0
  659. X
  660. X#define CPUSCALE_TLY        1
  661. X#define CPUSCALE_SX            13
  662. X#define CPUSCALE_WIDTH        50
  663. X
  664. X#define WAITSCALE_TLY        5
  665. X#define WAITSCALE_SX        13
  666. X#define WAITSCALE_WIDTH        50
  667. X
  668. X/* Sysinfo/Minfo per second area */
  669. X#define PER_SEC_TLY            9
  670. X#define PER_SEC1_TLX        0
  671. X#define PER_SEC2_TLX        18
  672. X#define PER_SEC3_TLX        35
  673. X#define PER_SEC4_TLX        51
  674. X#define PER_SEC5_TLX        66
  675. X
  676. X/* extra info area */
  677. X#define EXTRA_TLY            26
  678. X#define EXTRA1_TLX            0
  679. X#define EXTRA2_TLX            18
  680. X#define EXTRA3_TLX            43
  681. X#define EXTRA4_TLX            62
  682. X
  683. X#include "lint_args.h"
  684. X
  685. X/* vi: set tabstop=4 shiftwidth=4: */
  686. X/* end of u386mon.h */
  687. SHAR_EOF
  688. chmod 0644 u386mon.h ||
  689. echo 'restore of u386mon.h failed'
  690. Wc_c="`wc -c < 'u386mon.h'`"
  691. test 4671 -eq "$Wc_c" ||
  692.     echo 'u386mon.h: original size 4671, current size' "$Wc_c"
  693. fi
  694. # ============= renice/Makefile ==============
  695. if test ! -d 'renice'; then
  696.     echo 'x - creating directory renice'
  697.     mkdir 'renice'
  698. fi
  699. if test -f 'renice/Makefile' -a X"$1" != X"-c"; then
  700.     echo 'x - skipping renice/Makefile (File already exists)'
  701. else
  702. echo 'x - extracting renice/Makefile (Text)'
  703. sed 's/^X//' << 'SHAR_EOF' > 'renice/Makefile' &&
  704. X#  CHK=0xD897
  705. X#+-------------------------------------------------------------------
  706. X#  Makefile for renice for SCO UNIX V/386
  707. X#  ...!emory!n4hgf!wht
  708. X#--------------------------------------------------------------------
  709. X#+:EDITS:*/
  710. X#:06-25-1990-04:14-wht@n4hgf-1.03-better error handling
  711. X#:06-21-1990-14:27-r@n4hgf-version x0.12 seems bug free
  712. X#:06-19-1990-21:37-wht@n4hgf-get ready for 0.08 release
  713. X
  714. X#------------> CFLAGS 
  715. XCFLAGS = -c -Octl -DLINT_ARGS
  716. X#CFLAGS = -c -O
  717. X
  718. X#------------> BINDIR
  719. XBINDIR = /usr/local/bin
  720. X
  721. X#LDFLAGS = -s
  722. X
  723. X
  724. X#handle Sys V make "feature" of using SHELL
  725. XSHELL = /bin/sh
  726. X
  727. X#FCRC = fcrc -u $*.c ;
  728. X.c.o:;    $(FCRC) $(CC) $(CFLAGS) $*.c 
  729. X
  730. XSRC = \
  731. X    renice.c
  732. X
  733. XRENICE_OBJ =\
  734. X    renice.o\
  735. X    ../libnlsym.o\
  736. X    libkmem-w.o
  737. X
  738. Xall: renice
  739. X
  740. X#must run as root
  741. Xinstall: all
  742. X    mv renice $(BINDIR)
  743. X    chmod 4711 $(BINDIR)/renice
  744. X    chown root $(BINDIR)/renice
  745. X    @echo ' ';echo 'csh users rehash before executing'
  746. X
  747. Xrenice: $(RENICE_OBJ)
  748. X    $(CC) $(LDFLAGS) -o $@ $(RENICE_OBJ) $(LIB)
  749. X
  750. Xlibkmem-w.o: ../libkmem.c
  751. X    cc $(CFLAGS) -I .. -DKWRITE_NEEDED ../libkmem.c; mv libkmem.o libkmem-w.o
  752. X
  753. X../libnlsym.o: ../libnlsym.c
  754. X    cd ..;make libnlsym.o
  755. X
  756. Xclean:
  757. X    rm -f renice.o libkmem-w.o core 
  758. X
  759. Xclobber: clean
  760. X    rm -f renice
  761. X
  762. SHAR_EOF
  763. chmod 0644 renice/Makefile ||
  764. echo 'restore of renice/Makefile failed'
  765. Wc_c="`wc -c < 'renice/Makefile'`"
  766. test 1200 -eq "$Wc_c" ||
  767.     echo 'renice/Makefile: original size 1200, current size' "$Wc_c"
  768. fi
  769. # ============= renice/renice.c ==============
  770. if test -f 'renice/renice.c' -a X"$1" != X"-c"; then
  771.     echo 'x - skipping renice/renice.c (File already exists)'
  772. else
  773. echo 'x - extracting renice/renice.c (Text)'
  774. sed 's/^X//' << 'SHAR_EOF' > 'renice/renice.c' &&
  775. X/* CHK=0xE998 */
  776. X/*+-------------------------------------------------------------------------
  777. X    renice.c - UNIX 386 renice
  778. X
  779. X * This program was written by me, Mike "Ford" Ditto, and
  780. X * I hereby release it into the public domain in the interest
  781. X * of promoting the development of free, quality software
  782. X * for the hackers and users of the world.
  783. X *
  784. X * Feel free to use, copy, modify, improve, and redistribute
  785. X * this program, but keep in mind the spirit of this
  786. X * contribution; always provide source, and always allow
  787. X * free redistribution (shareware is fine with me).  If
  788. X * you use a significant part of this code in a program of
  789. X * yours, I would appreciate being given the appropriate
  790. X * amount of credit.
  791. X *                -=] Ford [=-
  792. X *
  793. X--------------------------------------------------------------------------*/
  794. X/*+:EDITS:*/
  795. X/*:06-26-1990-15:09-wht@n4hgf-adapt Ford's work to UNIX 386 */
  796. X
  797. X#include <stdio.h>
  798. X#include <errno.h>
  799. X#include <sys/types.h>
  800. X#undef NGROUPS_MAX
  801. X#undef NULL
  802. X#include <sys/param.h>
  803. X#include <sys/immu.h>
  804. X#include <sys/region.h>
  805. X#include <sys/proc.h>
  806. X#include <sys/var.h>
  807. X#include <nlist.h>
  808. X#include "../nlsym.h"
  809. X#include "../libkmem.h"
  810. X#include "../libnlsym.h"
  811. X
  812. Xstruct var v;
  813. Xstruct proc tproc;
  814. Xint myuid;
  815. Xchar *progname;
  816. Xchar s128[128];
  817. Xint myreadcnt = 0;            /* see libkmem.c, libmem.c, libswap.c */
  818. Xdaddr_t myreadlen = 0;
  819. X
  820. X/*+-------------------------------------------------------------------------
  821. X    leave_text(text,exit_code)
  822. XIf exit_code == 255, do perror
  823. X--------------------------------------------------------------------------*/
  824. Xvoid
  825. Xleave_text(text,exit_code)
  826. Xchar *text;
  827. Xint exit_code;
  828. X{
  829. X    if(exit_code == 255)
  830. X        perror(text);
  831. X    else
  832. X    {
  833. X        fputs(text,stderr);
  834. X        fputs("\n",stderr);
  835. X    }
  836. X    exit(exit_code);
  837. X}    /* end of leave_text */
  838. X
  839. X/*+-------------------------------------------------------------------------
  840. X    renice(pid,value,relative) - change nice of process `pid'
  841. Xbased on 'value' and 'relative'
  842. X--------------------------------------------------------------------------*/
  843. Xrenice(pid,value,relative)
  844. Xint pid;
  845. Xint value;
  846. Xint relative;
  847. X{
  848. X    register i;
  849. X    int tmpnice;
  850. X
  851. X    for(i = 0; i < v.v_proc; i++)
  852. X    {
  853. X        kread((caddr_t)&tproc,(daddr_t)((struct proc *)procaddr + i),
  854. X            sizeof(struct proc));
  855. X        if(tproc.p_pid == pid)
  856. X        {
  857. X#ifdef DEBUG
  858. X            fprintf(stderr,"Found it!  proc[%d], p_uid is %d\n",
  859. X                i,tproc.p_uid);
  860. X
  861. X            fprintf(stderr,"Old p_nice was %d\n",tproc.p_nice);
  862. X#endif /* DEBUG */
  863. X
  864. X            tmpnice = tproc.p_nice;
  865. X
  866. X            if(relative)
  867. X                tmpnice += value;
  868. X            else
  869. X                tmpnice = value;
  870. X
  871. X            if(tmpnice >= 40)
  872. X                tmpnice = 40;
  873. X            if(tmpnice < 0)
  874. X                tmpnice = 0;
  875. X
  876. X#ifdef DEBUG
  877. X            fprintf(stderr,"New p_nice is %d\n",tmpnice);
  878. X#endif /* DEBUG */
  879. X
  880. X            if( 
  881. X#ifdef WHT
  882. X                (myuid && (myuid != 201))
  883. X#else
  884. X                myuid
  885. X#endif
  886. X                 && ((myuid != tproc.p_uid) || (tmpnice < tproc.p_nice)))
  887. X            {
  888. X                errno = EACCES;
  889. X                sprintf(s128,"%s: can't renice process %d",progname,pid);
  890. X                perror(s128);
  891. X                return 1;
  892. X            }
  893. X
  894. X            tproc.p_nice = tmpnice;
  895. X
  896. X            kwrite((daddr_t)&((struct proc *)procaddr)[i]
  897. X                + ( ((caddr_t)&tproc.p_nice) - (caddr_t)&tproc ),
  898. X                (caddr_t)&tproc.p_nice,sizeof(tproc.p_nice));
  899. X            return(0);
  900. X        }
  901. X    }
  902. X    fprintf(stderr,"%s: process %d not found.\n",progname,pid);
  903. X
  904. X    return(1);
  905. X}    /* end of renice */
  906. X
  907. X/*+-------------------------------------------------------------------------
  908. X    usage()
  909. X--------------------------------------------------------------------------*/
  910. Xvoid
  911. Xusage()
  912. X{
  913. X    fprintf(stderr,"usage: %s [{+-}inc] [=prio] pid ...\n",progname);
  914. X    exit(-1);
  915. X}    /* end of usage */
  916. X
  917. X/*+-------------------------------------------------------------------------
  918. X    main(argc,argv)
  919. X--------------------------------------------------------------------------*/
  920. Xmain(argc,argv)
  921. Xint argc;
  922. Xchar **argv;
  923. X{
  924. X    int status=0;
  925. X    int pid;
  926. X    int relative = 1;
  927. X    int value = 0;
  928. X
  929. X    progname = *argv;
  930. X    if(argc < 2)
  931. X        usage();
  932. X
  933. X    myuid = getuid();
  934. X    nlsym_read();
  935. X    kinit(1);
  936. X    kread((caddr_t)&v,vaddr,sizeof(v));
  937. X
  938. X    while(++argv,--argc)
  939. X    {
  940. X        switch(**argv)
  941. X        {
  942. X        case '-':
  943. X            if(sscanf(*argv+1,"%d",&value) != 1)
  944. X                usage();
  945. X            relative = 1;
  946. X            break;
  947. X        case '+':
  948. X            if(sscanf(*argv+1,"%d",&value) != 1)
  949. X                usage();
  950. X            value = -value;
  951. X            relative = 1;
  952. X            break;
  953. X        case '=':
  954. X            if(sscanf(*argv+1,"%d",&value) != 1)
  955. X                usage();
  956. X            relative = 0;
  957. X            break;
  958. X        default:
  959. X            if(sscanf(*argv,"%d",&pid) != 1)
  960. X                usage();
  961. X            status += renice(pid,value,relative);
  962. X        }
  963. X    }
  964. X
  965. X    exit(status);
  966. X}    /* end of main */
  967. X
  968. X/* vi: set tabstop=4 shiftwidth=4: */
  969. X/* end of renice.c */
  970. SHAR_EOF
  971. chmod 0644 renice/renice.c ||
  972. echo 'restore of renice/renice.c failed'
  973. Wc_c="`wc -c < 'renice/renice.c'`"
  974. test 4465 -eq "$Wc_c" ||
  975.     echo 'renice/renice.c: original size 4465, current size' "$Wc_c"
  976. fi
  977. # ============= panel/README ==============
  978. if test ! -d 'panel'; then
  979.     echo 'x - creating directory panel'
  980.     mkdir 'panel'
  981. fi
  982. if test -f 'panel/README' -a X"$1" != X"-c"; then
  983.     echo 'x - skipping panel/README (File already exists)'
  984. else
  985. echo 'x - extracting panel/README (Text)'
  986. sed 's/^X//' << 'SHAR_EOF' > 'panel/README' &&
  987. XLIBPANEL 1.2 README - last revised Wed Jul 25 01:07:33 EDT 1990
  988. X
  989. XThis is a public domain implementation of the S5R3 terminfo
  990. Xcurses panels layer.  It was written primarily to assist in
  991. Xporting u386mon 2.0 (comp.sources.misc v14i001-4) to systems
  992. Xlacking panels support.  It meets those needs and may be
  993. Xuseful in other applications.  u386mon 2.10 and beyond use
  994. Xthe package.
  995. X
  996. XFUNCTIONALITY
  997. X-------------
  998. X
  999. XPanels are terminfo curses(3) windows with the added feature of depth.
  1000. XPanel functions allow the use of stacked windows and ensure the proper
  1001. Xportions of each window and the curses stdscr window are hidden or
  1002. Xdisplayed when panels are added, moved, modified or removed.  The set
  1003. Xof currently visible panels is the stack of panels.  Stdscr beneath
  1004. Xall panels, and is not considered part of the stack.
  1005. X
  1006. XA window is associated with every panel.  The panel routines enable
  1007. Xyou to create, move, hides, and show panels, as well as position a
  1008. Xpanel at an appropriate position in the stack.
  1009. X
  1010. XPanel routines are a functional layer added to terminfo curses(3),
  1011. Xmake only high-level curses calls, and work anywhere terminfo curses
  1012. Xdoes.
  1013. X
  1014. XCOMPATIBILITY
  1015. X-------------
  1016. X
  1017. XReasonable care has been taken to ensure compatibility with the native
  1018. Xpanel facility introducted with S5R3.2.  The PANEL data structures are
  1019. Xmerely similar.  The programmer is cautioned not to directly use
  1020. X'PANEL' fields.
  1021. X
  1022. XThe functions show_panel() and top_panel() are identical in thes
  1023. Ximplementation, and work equally well with displayed or hidden panels.
  1024. XIn the native implementation, show_panel() is intended for making a
  1025. Xhidden panel visible (at the top of the stack) and top_panel() is
  1026. Xintended for making an already-visible panel move to the top of the
  1027. Xstack.  You are cautioned to use the correct function to ensure
  1028. Xcompatibility with native panel libraries.
  1029. X
  1030. XUSE
  1031. X---
  1032. X
  1033. XTo make this panels implementation work for you, install
  1034. Xpanel.h in /usr/include or modify each of your panel-using
  1035. Xsources in a fashion similar to:
  1036. X
  1037. Xold:
  1038. X#include <curses.h>
  1039. X#include <panel.h>
  1040. X
  1041. Xnew:
  1042. X#include <curses.h>
  1043. X#ifdef NATIVE_PANELS
  1044. X#include <panel.h>
  1045. X#else
  1046. X#include "panel.h"
  1047. X#endif
  1048. X
  1049. XInclude libpanel.o in your link line and panel away.
  1050. X
  1051. XCOMPILE TIME SWITCHES
  1052. X---------------------
  1053. X__STDC__ is used to detect nouveau compilers.  Depending on who/where
  1054. Xyou are, on what day of the week, The Great Programmer help you.
  1055. XI only use it to satisfy lint that malloc is a good function to use.
  1056. X
  1057. XLINT_ARGS causes a Microsoft 5.1 flavor of function prototypes to
  1058. Xbe used.
  1059. X
  1060. XNATIVE_PANELS is detected by panel.h.  If NATIVE_PANELS *is* defined,
  1061. Xthen an error is emited to keep you from using the wrong panel.h.
  1062. X
  1063. XTESTING
  1064. X-------
  1065. X
  1066. XA rudimentary test program, PTEST, is supplied.  It requires
  1067. Xthe nap() system call.  If You do not have nap, add -DNONAP
  1068. Xto your CFLAGS line.
  1069. X
  1070. X
  1071. XComments are appreciated, especially bug fixes and information
  1072. Xhelping to port the module to another system.
  1073. X
  1074. XNO FSF, LPF, FOO or LSD -- just free.
  1075. X
  1076. XWarren Tucker N4HGF
  1077. X{gatech,emory}!n4hgf!wht -or- wht@n4hgf.Mt-Park.GA.US
  1078. SHAR_EOF
  1079. chmod 0644 panel/README ||
  1080. echo 'restore of panel/README failed'
  1081. Wc_c="`wc -c < 'panel/README'`"
  1082. test 3033 -eq "$Wc_c" ||
  1083.     echo 'panel/README: original size 3033, current size' "$Wc_c"
  1084. fi
  1085. # ============= panel/panel.3 ==============
  1086. if test -f 'panel/panel.3' -a X"$1" != X"-c"; then
  1087.     echo 'x - skipping panel/panel.3 (File already exists)'
  1088. else
  1089. echo 'x - extracting panel/panel.3 (Text)'
  1090. sed 's/^X//' << 'SHAR_EOF' > 'panel/panel.3' &&
  1091. X.\" @(#)panel.3    1.1 7/23/90
  1092. X.TH PANEL 3 "23 July 1990" "wht@n4hgf"
  1093. X.SH NAME
  1094. Xpanel - surrogate PANEL library routines
  1095. X.SH SYNTAX
  1096. X.B "include "panel.h"
  1097. X
  1098. X.B "cc [flags] sourcefiles libpanel.[co] -lcurses -[otherlibs]
  1099. X
  1100. X.B "PANEL *new_panel(win);"
  1101. X.br
  1102. XWINDOW *win;
  1103. X
  1104. X.B "int bottom_panel(pan);"
  1105. X.br
  1106. XPANEL *pan;
  1107. X
  1108. X.B "int top_panel(pan);"
  1109. X.br
  1110. XPANEL *pan;
  1111. X
  1112. X.B "int show_panel(pan);"
  1113. X.br
  1114. XPANEL *pan;
  1115. X
  1116. X.B "void update_panels();"
  1117. X
  1118. X.B "int hide_panel(pan);"
  1119. X.br
  1120. XPANEL *pan;
  1121. X
  1122. X.B "WINDOW *panel_window(pan);"
  1123. X.br
  1124. XPANEL *pan;
  1125. X
  1126. X.B "int replace_panel(pan,window);"
  1127. X.br
  1128. XPANEL *pan;
  1129. X.br
  1130. XWINDOW *window;
  1131. X
  1132. X.B "int move_panel(pan,starty,startx);"
  1133. X.br
  1134. XPANEL *pan;
  1135. X.br
  1136. Xint starty;
  1137. X.br
  1138. Xint startx;
  1139. X
  1140. X.B "int panel_hidden(pan);"
  1141. X.br
  1142. XPANEL *pan;
  1143. X
  1144. X.B "PANEL *panel_above(pan);"
  1145. X.br
  1146. XPANEL *pan;
  1147. X
  1148. X.B "PANEL *panel_below(pan);"
  1149. X.br
  1150. XPANEL *pan;
  1151. X
  1152. X.B "int set_panel_userptr(pan,ptr);"
  1153. X.br
  1154. XPANEL *pan;
  1155. X.br
  1156. Xchar *ptr;
  1157. X
  1158. X.B "char *panel_userptr(pan);"
  1159. X.br
  1160. XPANEL *pan;
  1161. X
  1162. X.B "int del_panel(pan);"
  1163. X.br
  1164. XPANEL *pan;
  1165. X
  1166. X.SH DESCRIPTION
  1167. XPanels are terminfo curses(3) windows with the added feature of
  1168. Xdepth.  Panel functions allow the use of stacked windows and
  1169. Xensure the proper portions of each window and the curses stdscr
  1170. Xwindow are hidden or displayed when panels are added, moved,
  1171. Xmodified or removed.  The set of currently visible panels is the
  1172. Xstack of panels.  Stdscr beneath all panels, and is not
  1173. Xconsidered part of the stack.
  1174. X
  1175. XA window is associated with every panel.  The panel routines
  1176. Xenable you to create, move, hides, and show panels, as well as
  1177. Xposition a panel at an appropriate position in the stack.
  1178. X
  1179. XPanel routines are a functional layer added to terminfo curses(3), make
  1180. Xonly high-level curses calls, and work anywhere terminfo curses does.
  1181. X
  1182. X.SH FUNCTIONS
  1183. X.B "new_panel(win)"
  1184. Xallocates a 'PANEL',
  1185. Xassovciates it with win,
  1186. Xplaces the panel on the top of the stack (causes it to be dispalyed
  1187. Xabove any other panel) and
  1188. Xreturns a pointer to the new panel.
  1189. X
  1190. X.B "void update_panels()"
  1191. Xrefreshes the virtual screen to reflect the relations between the
  1192. Xpanels in the stack, but does not call doupdate() to refresh the
  1193. Xphysical screen.  Use this function and not wrefresh or wnoutrefresh.
  1194. Xupdate_panels() may be called more than once before a call to
  1195. Xdoupdate(), but doupdate() is the function responsible for
  1196. Xupdating the physical screen.
  1197. X.br
  1198. Xe.g.,
  1199. X.br
  1200. Xupdate_panels();   /* panel(3) call */
  1201. X.br
  1202. Xdoupdate();        /* curses(3) call */
  1203. X
  1204. X.B "del_panel(pan)"
  1205. Xremoves pan from the stack,
  1206. Xdeletes the 'PANEL', but not its associated window.
  1207. X
  1208. X.B "hide_panel(pan)"
  1209. Xremoves the panel from the panel stack and thus hides it
  1210. Xfrom view.  The 'PANEL' is not lost, merely removed
  1211. Xfrom the stack.
  1212. X
  1213. X.B "show_panel(pan)"
  1214. Xmakes a hidden panel visible by placing it on top of
  1215. Xthe panels in the panel stack.
  1216. XSee COMPATIBILITY below.
  1217. X
  1218. X.B "top_panel(pan)"
  1219. Xputs the given visible panel on top of all panels in the stack.
  1220. XSee COMPATIBILITY below.
  1221. X
  1222. X.B "bottom_panel(pan)"
  1223. Xputs panel at the bottom of all panels.
  1224. X
  1225. X.B "move_panel(pan,starty,startx)"
  1226. Xmoves the given panel window so that
  1227. Xits upper-left corner is at starty, startx.  
  1228. XIt does not change the position of the panel in the stack.
  1229. XBe sure to use this function, not mvwin(), to move a panel window.
  1230. X
  1231. X.B "replace_panel(pan,window)"
  1232. Xreplaces the current window of panel with window.
  1233. XIt does not change the position of the panel in the stack.
  1234. X
  1235. X.B "panel_above(pan)"
  1236. Xreturns a pointer to the panel above pan.  If
  1237. Xthe panel argument is (PANEL *)0, it returns a pointer to the
  1238. Xbottom panel in the stack.
  1239. X
  1240. X.B "panel_below(pan)"
  1241. Xreturns a pointer to the panel just below pan.
  1242. XIf the panel argument is (PANEL *)0,
  1243. Xit returns a pointer to the top panel in the stack.
  1244. X
  1245. X.B "set_panel_userptr(pan,ptr)"
  1246. Xsets the panel's user pointer.
  1247. X
  1248. X.B "panel_userptr(pan)"
  1249. Xreturns the user pointer for a given panel.
  1250. X
  1251. X.B "panel_window(pan)"
  1252. Xreturns a pointer to the window of panel.
  1253. X
  1254. X.SH DIAGNOSTICS
  1255. XEach routine that returns a pointer returns NULL if an error
  1256. Xoccurs.  Each routine that returns an int value returns OK if it
  1257. Xexecutes successfully and ERR if not.
  1258. X
  1259. X.SH COMPATIBILITY
  1260. XReasonable care has been taken to ensure compatibility with
  1261. Xthe native panel facility introducted with S5R3.2.  The PANEL
  1262. Xdata structures are merely  similar.  The programmer
  1263. Xis cautioned not to directly use 'PANEL' fields.
  1264. X
  1265. XThe functions show_panel() and top_panel() are identical
  1266. Xin thes implementation, and work equally well with
  1267. Xdisplayed or hidden panels.
  1268. XIn the native implementation,
  1269. Xshow_panel() is intended for making a hidden panel visible
  1270. X(at the top of the stack) and top_panel() is intended for
  1271. Xmaking an already-visible panel move to the top of the stack.
  1272. XYou are cautioned to use the correct function to ensure
  1273. Xcompatibility with native panel libraries.
  1274. X
  1275. X.SH FILES
  1276. Xpanel.h
  1277. X.br
  1278. Xlibpanel.c
  1279. X
  1280. X.SH "SEE ALSO"
  1281. Xcurses(3)
  1282. X
  1283. X.SH "AUTHOR"
  1284. Xwht@n4hgf.Mt-Park.GA.US ({emory,gatech}!n4hgf!wht), primarily
  1285. Xto assist in porting u386mon to systems without a native
  1286. Xpanels library.
  1287. SHAR_EOF
  1288. chmod 0644 panel/panel.3 ||
  1289. echo 'restore of panel/panel.3 failed'
  1290. Wc_c="`wc -c < 'panel/panel.3'`"
  1291. test 4935 -eq "$Wc_c" ||
  1292.     echo 'panel/panel.3: original size 4935, current size' "$Wc_c"
  1293. fi
  1294. # ============= panel/ptest.c ==============
  1295. if test -f 'panel/ptest.c' -a X"$1" != X"-c"; then
  1296.     echo 'x - skipping panel/ptest.c (File already exists)'
  1297. else
  1298. echo 'x - extracting panel/ptest.c (Text)'
  1299. sed 's/^X//' << 'SHAR_EOF' > 'panel/ptest.c' &&
  1300. X/*+-------------------------------------------------------------------------
  1301. X    ptest.c
  1302. X--------------------------------------------------------------------------*/
  1303. X/*+:EDITS:*/
  1304. X/*:07-24-1990-23:20-wht@n4hgf-move debug code to libpanel.c */
  1305. X/*:07-20-1990-18:28-wht-creation */
  1306. X
  1307. X#define M_TERMINFO
  1308. X#include <curses.h>
  1309. X#include "libpanel.h"
  1310. X
  1311. XPANEL *p1;
  1312. XPANEL *p2;
  1313. XPANEL *p3;
  1314. XPANEL *p4;
  1315. XPANEL *p5;
  1316. XWINDOW *w1;
  1317. XWINDOW *w2;
  1318. XWINDOW *w3;
  1319. XWINDOW *w4;
  1320. XWINDOW *w5;
  1321. X
  1322. Xlong nap_msec = 500L;
  1323. X
  1324. Xchar *mod[] = 
  1325. X{
  1326. X    "test ",
  1327. X    "TEST ",
  1328. X    "(**) ",
  1329. X    "*()* ",
  1330. X    "<--> ",
  1331. X    "LAST "
  1332. X};
  1333. X
  1334. X/*+-------------------------------------------------------------------------
  1335. X    wait_a_while(msec)
  1336. X--------------------------------------------------------------------------*/
  1337. Xvoid
  1338. Xwait_a_while(msec)
  1339. Xlong msec;
  1340. X{
  1341. X#ifdef NONAP
  1342. X    if(nap_msec == 1)
  1343. X        getchar();
  1344. X    else if(msec > 1000L)
  1345. X        sleep((int)msec/1000L);
  1346. X    else
  1347. X        sleep(1);
  1348. X#else
  1349. X    if(nap_msec == 1)
  1350. X        getchar();
  1351. X    else
  1352. X        nap(nap_msec);
  1353. X#endif
  1354. X}    /* end of wait_a_while */
  1355. X
  1356. X/*+-------------------------------------------------------------------------
  1357. X    saywhat(text)
  1358. X--------------------------------------------------------------------------*/
  1359. Xvoid
  1360. Xsaywhat(text)
  1361. Xchar *text;
  1362. X{
  1363. Xint y,x;
  1364. X
  1365. X#ifdef PANEL_DEBUG
  1366. X    if(!dfp)
  1367. X    {
  1368. X        dfp = fopen("p.log","w");
  1369. X        fputs("-------\n",dfp);
  1370. X    }
  1371. X    fprintf(dfp,"\n--> %s\n",text);
  1372. X#endif
  1373. X
  1374. X    wmove(stdscr,LINES - 1,0);
  1375. X    wprintw(stdscr,"%-20.20s",text);
  1376. X
  1377. X}    /* end of saywhat */
  1378. X
  1379. X/*+-------------------------------------------------------------------------
  1380. X    mkpanel(rows,cols,tly,tlx) - alloc a win and panel and associate them
  1381. X--------------------------------------------------------------------------*/
  1382. XPANEL *
  1383. Xmkpanel(rows,cols,tly,tlx)
  1384. Xint rows;
  1385. Xint cols;
  1386. Xint tly;
  1387. Xint tlx;
  1388. X{
  1389. XWINDOW *win = newwin(rows,cols,tly,tlx);
  1390. XPANEL *pan;
  1391. X
  1392. X    if(!win)
  1393. X        return((PANEL *)0);
  1394. X    if(pan = new_panel(win))
  1395. X        return(pan);
  1396. X    delwin(win);
  1397. X    return((PANEL *)0);
  1398. X}    /* end of mkpanel */
  1399. X
  1400. X/*+-------------------------------------------------------------------------
  1401. X    rmpanel(pan)
  1402. X--------------------------------------------------------------------------*/
  1403. Xvoid
  1404. Xrmpanel(pan)
  1405. XPANEL *pan;
  1406. X{
  1407. XWINDOW *win = pan->win;
  1408. X    del_panel(pan);
  1409. X    delwin(win);
  1410. X}    /* end of rmpanel */
  1411. X
  1412. X/*+-------------------------------------------------------------------------
  1413. X    pflush()
  1414. X--------------------------------------------------------------------------*/
  1415. Xvoid
  1416. Xpflush()
  1417. X{
  1418. X    update_panels();
  1419. X    doupdate();
  1420. X}    /* end of pflush */
  1421. X
  1422. X/*+-------------------------------------------------------------------------
  1423. X    fill_panel(win)
  1424. X--------------------------------------------------------------------------*/
  1425. Xfill_panel(pan)
  1426. XPANEL *pan;
  1427. X{
  1428. XWINDOW *win = pan->win;
  1429. Xchar num = *(pan->user + 1);
  1430. Xint y,x;
  1431. X
  1432. X    box(win,'|','-');
  1433. X    wmove(win,1,1);
  1434. X    wprintw(win,"-pan%c-",num);
  1435. X    for(y = 2; y < getmaxy(win) - 1; y++)
  1436. X    {
  1437. X        for(x = 1; x < getmaxx(win) - 1; x++)
  1438. X        {
  1439. X            wmove(win,y,x);
  1440. X            waddch(win,num);
  1441. X        }
  1442. X    }
  1443. X}    /* end of fill_panel */
  1444. X
  1445. X/*+-------------------------------------------------------------------------
  1446. X    main(argc,argv)
  1447. X--------------------------------------------------------------------------*/
  1448. Xmain(argc,argv)
  1449. Xint argc;
  1450. Xchar **argv;
  1451. X{
  1452. Xint itmp;
  1453. Xregister y,x;
  1454. Xlong atol();
  1455. X
  1456. X    if((argc > 1) && atol(argv[1]))
  1457. X        nap_msec = atol(argv[1]);
  1458. X
  1459. X    initscr();
  1460. X
  1461. X    for(y = 0; y < LINES - 1; y++)
  1462. X    {
  1463. X        for(x = 0; x < COLS; x++)
  1464. X            wprintw(stdscr,"%d",(y + x) % 10);
  1465. X    }
  1466. X    for(y = 0; y < 5; y++)
  1467. X    {
  1468. X        p1 = mkpanel(10,10,0,0);
  1469. X        w1 = panel_window(p1);
  1470. X        set_panel_userptr(p1,"p1");
  1471. X
  1472. X        p2 = mkpanel(14,14,5,5);
  1473. X        w2 = panel_window(p2);
  1474. X        set_panel_userptr(p2,"p2");
  1475. X
  1476. X        p3 = mkpanel(6,8,12,12);
  1477. X        w3 = panel_window(p3);
  1478. X        set_panel_userptr(p3,"p3");
  1479. X
  1480. X        p4 = mkpanel(10,10,10,30);
  1481. X        w4 = panel_window(p4);
  1482. X        set_panel_userptr(p4,"p4");
  1483. X
  1484. X        p5 = mkpanel(10,10,13,37);
  1485. X        w5 = panel_window(p5);
  1486. X        set_panel_userptr(p5,"p5");
  1487. X
  1488. X        fill_panel(p1);
  1489. X        fill_panel(p2);
  1490. X        fill_panel(p3);
  1491. X        fill_panel(p4);
  1492. X        fill_panel(p5);
  1493. X        hide_panel(p4);
  1494. X        hide_panel(p5);
  1495. X        pflush();
  1496. X        wait_a_while(nap_msec);
  1497. X
  1498. X        saywhat("h3 s1 s2 s4 s5;");
  1499. X        move_panel(p1,0,0);
  1500. X        hide_panel(p3);
  1501. X        show_panel(p1);
  1502. X        show_panel(p2);
  1503. X        show_panel(p4);
  1504. X        show_panel(p5);
  1505. X        pflush();
  1506. X        wait_a_while(nap_msec);
  1507. X
  1508. X        saywhat("s1;");
  1509. X        show_panel(p1);
  1510. X        pflush();
  1511. X        wait_a_while(nap_msec);
  1512. X
  1513. X        saywhat("s2;");
  1514. X        show_panel(p2);
  1515. X        pflush();
  1516. X        wait_a_while(nap_msec);
  1517. X
  1518. X        saywhat("m2;");
  1519. X        move_panel(p2,10,10);
  1520. X        pflush();
  1521. X        wait_a_while(nap_msec);
  1522. X
  1523. X        saywhat("s3;");
  1524. X        show_panel(p3);
  1525. X        pflush();
  1526. X        wait_a_while(nap_msec);
  1527. X
  1528. X        saywhat("m3;");
  1529. X        move_panel(p3,5,5);
  1530. X        pflush();
  1531. X        wait_a_while(nap_msec);
  1532. X
  1533. X        saywhat("b3;");
  1534. X        bottom_panel(p3);
  1535. X        pflush();
  1536. X        wait_a_while(nap_msec);
  1537. X
  1538. X        saywhat("s4;");
  1539. X        show_panel(p4);
  1540. X        pflush();
  1541. X        wait_a_while(nap_msec);
  1542. X
  1543. X        saywhat("s5;");
  1544. X        show_panel(p5);
  1545. X        pflush();
  1546. X        wait_a_while(nap_msec);
  1547. X
  1548. X        saywhat("t3;");
  1549. X        top_panel(p3);
  1550. X        pflush();
  1551. X        wait_a_while(nap_msec);
  1552. X
  1553. X        saywhat("t1;");
  1554. X        top_panel(p1);
  1555. X        pflush();
  1556. X        wait_a_while(nap_msec);
  1557. X
  1558. X        saywhat("t2;");
  1559. X        top_panel(p2);
  1560. X        pflush();
  1561. X        wait_a_while(nap_msec);
  1562. X
  1563. X        saywhat("t3;");
  1564. X        top_panel(p3);
  1565. X        pflush();
  1566. X        wait_a_while(nap_msec);
  1567. X
  1568. X        saywhat("t4;");
  1569. X        top_panel(p4);
  1570. X        pflush();
  1571. X        wait_a_while(nap_msec);
  1572. X
  1573. X        for(itmp = 0; itmp < 6; itmp++)
  1574. X        {
  1575. X            saywhat("m4;");
  1576. X            wmove(w4,3,1);
  1577. X            waddstr(w4,mod[itmp]);
  1578. X            move_panel(p4,4,itmp*10);
  1579. X            wmove(w5,4,1);
  1580. X            waddstr(w5,mod[itmp]);
  1581. X            pflush();
  1582. X            wait_a_while(nap_msec);
  1583. X            saywhat("m5;");
  1584. X            wmove(w4,4,1);
  1585. X            waddstr(w4,mod[itmp]);
  1586. X            move_panel(p5,7,(itmp*10) + 6);
  1587. X            wmove(w5,3,1);
  1588. X            waddstr(w5,mod[itmp]);
  1589. X            pflush();
  1590. X            wait_a_while(nap_msec);
  1591. X        }
  1592. X
  1593. X        saywhat("m4;");
  1594. X        move_panel(p4,4,itmp*10);
  1595. X        pflush();
  1596. X        wait_a_while(nap_msec);
  1597. X
  1598. X        saywhat("t5;");
  1599. X        top_panel(p5);
  1600. X        pflush();
  1601. X        wait_a_while(nap_msec);
  1602. X
  1603. X        saywhat("t2;");
  1604. X        top_panel(p2);
  1605. X        pflush();
  1606. X        wait_a_while(nap_msec);
  1607. X
  1608. X        saywhat("t1;");
  1609. X        top_panel(p1);
  1610. X        pflush();
  1611. X        wait_a_while(nap_msec);
  1612. X
  1613. X        saywhat("d2;");
  1614. X        rmpanel(p2);
  1615. X        pflush();
  1616. X        wait_a_while(nap_msec);
  1617. X
  1618. X        saywhat("h3;");
  1619. X        hide_panel(p3);
  1620. X        pflush();
  1621. X        wait_a_while(nap_msec);
  1622. X
  1623. X        saywhat("d1;");
  1624. X        rmpanel(p1);
  1625. X        pflush();
  1626. X        wait_a_while(nap_msec);
  1627. X
  1628. X        saywhat("d4; ");
  1629. X        rmpanel(p4);
  1630. X        pflush();
  1631. X        wait_a_while(nap_msec);
  1632. X
  1633. X        saywhat("d5; ");
  1634. X        rmpanel(p5);
  1635. X        pflush();
  1636. X        wait_a_while(nap_msec);
  1637. X        if(nap_msec == 1)
  1638. X            break;
  1639. X        nap_msec = 100L;
  1640. X    }
  1641. X    endwin();
  1642. X    exit(0);
  1643. X}    /* end of main */
  1644. X
  1645. X/* vi: set tabstop=4 shiftwidth=4: */
  1646. X/* end of ptest.c */
  1647. SHAR_EOF
  1648. chmod 0644 panel/ptest.c ||
  1649. echo 'restore of panel/ptest.c failed'
  1650. Wc_c="`wc -c < 'panel/ptest.c'`"
  1651. test 6321 -eq "$Wc_c" ||
  1652.     echo 'panel/ptest.c: original size 6321, current size' "$Wc_c"
  1653. fi
  1654. # ============= panel/Makefile ==============
  1655. if test -f 'panel/Makefile' -a X"$1" != X"-c"; then
  1656.     echo 'x - skipping panel/Makefile (File already exists)'
  1657. else
  1658. echo 'x - extracting panel/Makefile (Text)'
  1659. sed 's/^X//' << 'SHAR_EOF' > 'panel/Makefile' &&
  1660. XCFLAGS = -O
  1661. X#CFLAGS = -O -DLINT_ARGS
  1662. X
  1663. XSHARFLS = \
  1664. X    README\
  1665. X    Makefile\
  1666. X    panel.3\
  1667. X    config.h\
  1668. X    libpanel.h\
  1669. X    libpanel.c
  1670. X
  1671. XOBJ = ptest.o libpanel.o
  1672. X
  1673. Xptest: $(OBJ)
  1674. X    cc -o $@ $(OBJ) -lcurses -lx
  1675. X
  1676. X$(OBJ): Makefile libpanel.h
  1677. X
  1678. Xshar:
  1679. X    shar -n libpanel -a $(SHARFLS) > libpanel.sh
  1680. X
  1681. Xclean:
  1682. X    rm -rf $(OBJ) core a.out cscope.out tags
  1683. X
  1684. Xclobber: clean
  1685. X    rm -rf ptest
  1686. SHAR_EOF
  1687. chmod 0644 panel/Makefile ||
  1688. echo 'restore of panel/Makefile failed'
  1689. Wc_c="`wc -c < 'panel/Makefile'`"
  1690. test 349 -eq "$Wc_c" ||
  1691.     echo 'panel/Makefile: original size 349, current size' "$Wc_c"
  1692. fi
  1693. exit 0
  1694.  
  1695. exit 0 # Just in case...
  1696. -- 
  1697. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1698. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1699. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1700. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1701.