Newsgroups: alt.sources
Path: qiclab!psgrain!charnel!rat!usc!zaphod.mps.ohio-state.edu!darwin.sura.net!Sirius.dfn.de!dct.zrz.tu-berlin.de!news.netmbx.de!Germany.EU.net!isaak.isa.de!omega!av
From: av@omega.ssw.de (Andreas Vogel)
Subject: u386mon for SVR4
Message-ID: <1992Oct2.181353.4183@omega.ssw.de>
Date: Fri, 2 Oct 1992 18:13:53 GMT
Organization: Omega Softlab
Lines: 2074

Submitted-by: av@ssw.de
Archive-name: av386mon/part05

#!/bin/sh
# this is av386mon.shar.05 (part 5 of av386mon)
# do not concatenate these parts, unpack them in order with /bin/sh
# file libmem.h continued
#
if test ! -r _shar_seq_.tmp; then
	echo 'Please unpack part 1 first!'
	exit 1
fi
(read Scheck
 if test "$Scheck" != 5; then
	echo Please unpack part "$Scheck" next!
	exit 1
 else
	exit 0
 fi
) < _shar_seq_.tmp || exit 1
if test ! -f _shar_wnt_.tmp; then
	echo 'x - still skipping libmem.h'
else
echo 'x - continuing file libmem.h'
sed 's/^X//' << 'SHAR_EOF' >> 'libmem.h' &&
/*:06-27-1990-01:57-wht@n4hgf-1.10-incorporate suggestions from alpha testers */
/*:06-25-1990-04:14-wht@n4hgf-1.02-better error handling */
/*:06-24-1990-20:53-wht@n4hgf-v1.01-add ISC support thanks to peter@radig.de */
/*:06-21-1990-14:26-r@n4hgf-version x0.12 seems bug free */
/*:10-28-1988-14:46-afterlint-creation */
X
#ifndef BUILDING_LINT_ARGS
#ifdef LINT_ARGS
X
/* libmem.c */
void minit(int );
void mread(char  *,long ,int );
void mwrite(long ,char  *,int );
X
#else		/* compiler doesn't mnow about prototyping */
X
/* libmem.c */
void minit();
void mread();
void mwrite();
X
#endif /* LINT_ARGS */
#endif /* BUILDING_LINT_ARGS */
X
/* end of libmem.h */
SHAR_EOF
echo 'File libmem.h is complete' &&
chmod 0644 libmem.h ||
echo 'restore of libmem.h failed'
Wc_c="`wc -c < 'libmem.h'`"
test 1188 -eq "$Wc_c" ||
	echo 'libmem.h: original size 1188, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= libpanel.h ==============
if test -f 'libpanel.h' -a X"$1" != X"-c"; then
	echo 'x - skipping libpanel.h (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting libpanel.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'libpanel.h' &&
X
/*+-------------------------------------------------------------------------
X	libpanel.h - libpanel.c <panel.h> surrogate
X	wht@n4hgf.Mt-Park.GA.US
--------------------------------------------------------------------------*/
/*+:EDITS:*/
/*:08-01-1991-23:34-wht@n4hgf-release 2.40 source control point */
/*:08-10-1990-14:12-jmd@p1so/wht@n4hgf-2.20-add Tandem Integrity S2 */
/*:08-07-1990-14:24-wht@n4hgf-nba@sysware.dk SVR31 updates */
/*:08-02-1990-15:36-wht@n4hgf-2.12-old curses hacks+minor 3.2 formalizations */
/*:07-31-1990-08:18-wht@n4hgf-some cpps wont take #error even in untrue ifdef */
/*:07-28-1990-18:06-wht@n4hgf-2.10 release */
/*:07-23-1990-00:56-wht@n4hgf-full library working */
/*:07-21-1990-15:42-wht-creation */
X
#ifdef NATIVE_PANELS
# include <panel.h>
#else
X
typedef struct panelobs
{
X	struct panelobs *above;
X	struct panel *pan;
} PANELOBS;
X
typedef struct panel
{
X	WINDOW *win;
X	int wstarty;
X	int wendy;
X	int wstartx;
X	int wendx;
X	struct panel *below;
X	struct panel *above;
X	char *user;
X	struct panelobs *obscure;
} PANEL;
X
#ifndef BUILDING_LINT_ARGS
#ifdef LINT_ARGS
X
extern  WINDOW *panel_window(PANEL *pan);
extern  void update_panels(void );
extern  int hide_panel(PANEL *pan);
extern  int show_panel(PANEL *pan);
extern  int del_panel(PANEL *pan);
extern  int top_panel(PANEL *pan);
extern  int bottom_panel(PANEL *pan);
extern  PANEL *new_panel(WINDOW *win);
extern  PANEL *panel_above(PANEL *pan);
extern  PANEL *panel_below(PANEL *pan);
extern  int set_panel_userptr(PANEL *pan,char *uptr);
extern  char *panel_userptr(PANEL *pan);
extern  int move_panel(PANEL *pan,int starty,int startx);
extern  int replace_panel(PANEL *pan,WINDOW *win);
X
#else		/* compiler doesn't know about prototyping */
X
extern  WINDOW *panel_window();
extern  void update_panels();
extern  int hide_panel();
extern  int show_panel();
extern  int del_panel();
extern  int top_panel();
extern  int bottom_panel();
extern  PANEL *new_panel();
extern  PANEL *panel_above();
extern  PANEL *panel_below();
extern  int set_panel_userptr();
extern  char *panel_userptr();
extern  int move_panel();
extern  int replace_panel();
X
#endif /* LINT_ARGS */
#endif /* BUILDING_LINT_ARGS */
X
#endif	/* NATIVE_PANELS */
X
/* end of function declarations */
/* vi: set tabstop=4 shiftwidth=4: */
/* end of libpanel.h */
SHAR_EOF
chmod 0644 libpanel.h ||
echo 'restore of libpanel.h failed'
Wc_c="`wc -c < 'libpanel.h'`"
test 2312 -eq "$Wc_c" ||
	echo 'libpanel.h: original size 2312, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= libswap.h ==============
if test -f 'libswap.h' -a X"$1" != X"-c"; then
	echo 'x - skipping libswap.h (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting libswap.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'libswap.h' &&
/*+-----------------------------------------------------------------------
X	libswap.h
X	...!{gatech,emory}!n4hgf!wht
------------------------------------------------------------------------*/
/*+:EDITS:*/
/*:08-01-1991-23:34-wht@n4hgf-release 2.40 source control point */
/*:08-10-1990-14:12-jmd@p1so/wht@n4hgf-2.20-add Tandem Integrity S2 */
/*:08-07-1990-14:24-wht@n4hgf-nba@sysware.dk SVR31 updates */
/*:08-02-1990-15:36-wht@n4hgf-2.12-old curses hacks+minor 3.2 formalizations */
/*:07-28-1990-18:06-wht@n4hgf-2.10 release */
/*:06-27-1990-01:57-wht@n4hgf-1.10-incorporate suggestions from alpha testers */
/*:06-25-1990-04:14-wht@n4hgf-1.02-better error handling */
/*:06-24-1990-20:53-wht@n4hgf-v1.01-add ISC support thanks to peter@radig.de */
/*:06-22-1990-02:03-root@n4hgf-creation from libmem */
X
#ifndef BUILDING_LINT_ARGS
#ifdef LINT_ARGS
X
/* libswap.c */
void sinit(void );
void sread(char  *,long ,int );
X
#else		/* compiler doesn't mnow about prototyping */
X
/* libswap.c */
void sinit();
void sread();
void swrite();
X
#endif /* LINT_ARGS */
#endif /* BUILDING_LINT_ARGS */
X
/* end of libswap.h */
SHAR_EOF
chmod 0644 libswap.h ||
echo 'restore of libswap.h failed'
Wc_c="`wc -c < 'libswap.h'`"
test 1113 -eq "$Wc_c" ||
	echo 'libswap.h: original size 1113, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= libnlsym.h ==============
if test -f 'libnlsym.h' -a X"$1" != X"-c"; then
	echo 'x - skipping libnlsym.h (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting libnlsym.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'libnlsym.h' &&
/*+-----------------------------------------------------------------------
X	libnlsym.h
X	...!{gatech,emory}!n4hgf!wht
------------------------------------------------------------------------*/
/*+:EDITS:*/
/*:08-01-1991-23:34-wht@n4hgf-release 2.40 source control point */
/*:08-10-1990-14:12-jmd@p1so/wht@n4hgf-2.20-add Tandem Integrity S2 */
/*:08-07-1990-14:24-wht@n4hgf-nba@sysware.dk SVR31 updates */
/*:08-02-1990-15:36-wht@n4hgf-2.12-old curses hacks+minor 3.2 formalizations */
/*:07-28-1990-18:06-wht@n4hgf-2.10 release */
/*:06-27-1990-01:57-wht@n4hgf-1.10-incorporate suggestions from alpha testers */
/*:06-25-1990-04:14-wht@n4hgf-1.02-better error handling */
/*:06-24-1990-20:53-wht@n4hgf-v1.01-add ISC support thanks to peter@radig.de */
/*:06-21-1990-14:26-r@n4hgf-version x0.12 seems bug free */
/*:10-28-1988-14:47-afterlint-creation */
X
#ifndef BUILDING_LINT_ARGS
#ifdef LINT_ARGS
X
/* libnlsym.c */
void nlsym_error(char * );
void nlsym_read(void);
X
#else		/* compiler doesn't know about prototyping */
X
/* libnlsym.c */
void nlsym_error();
void nlsym_read();
X
#endif /* LINT_ARGS */
#endif /* BUILDING_LINT_ARGS */
X
/* end of libnlsym.h */
SHAR_EOF
chmod 0644 libnlsym.h ||
echo 'restore of libnlsym.h failed'
Wc_c="`wc -c < 'libnlsym.h'`"
test 1159 -eq "$Wc_c" ||
	echo 'libnlsym.h: original size 1159, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= lint_args.h ==============
if test -f 'lint_args.h' -a X"$1" != X"-c"; then
	echo 'x - skipping lint_args.h (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting lint_args.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'lint_args.h' &&
/*+-----------------------------------------------------------------------
X	lint_args.h
------------------------------------------------------------------------*/
/*+:EDITS:*/
/*:08-01-1991-23:34-wht@n4hgf-release 2.40 source control point */
/*:08-10-1990-14:12-jmd@p1so/wht@n4hgf-2.20-add Tandem Integrity S2 */
/*:08-07-1990-14:24-wht@n4hgf-nba@sysware.dk SVR31 updates */
/*:08-02-1990-15:36-wht@n4hgf-2.12-old curses hacks+minor 3.2 formalizations */
/*:07-28-1990-18:06-wht@n4hgf-2.10 release */
/*:07-21-1990-16:01-afterlint-creation */
X
#ifndef BUILDING_LINT_ARGS
#ifdef LINT_ARGS
X
/* bootinfo.c */
extern  char *bmemf_text(unsigned long flags);
extern  void display_bootinfo(struct _win_st *win,int y,int x);
/* det_proc.c */
extern  char *get_cpu_time_str(long ticks);
extern  char *pgrp_to_ttyname(int pgrp);
extern  char *uid_to_name(unsigned short uid);
extern  int det_proc_init(void );
extern  int get_user(struct proc *tproc,struct user *tuser);
extern  int getpwent_and_enter(unsigned short uid);
extern  int ppproc_pid_compare(struct proc * *ppp1,struct proc * *ppp2);
extern  int uid_name_enter(unsigned short uid,char *name);
extern  struct utmp *find_utmp_for_pgrp(int pgrp);
extern  void display_proc_stat(struct _win_st *win,int iproc,int initial);
extern  void display_proc_stats(struct _win_st *win,int initial);
extern  void init_uid_name_hash(void );
extern  void read_and_sort_procs(int initial);
extern  void read_utmp(void );
/* det_sio.c */
extern  char *B_to_baud_rate(int code);
extern  char *cflag_to_baud_d_p_s(int cflag);
extern  int display_sio_summary(struct _win_st *win,int initial);
extern  int tty_slot_compare(struct tty *sio1,struct tty *sio2);
extern  void display_siofull_init(struct _win_st *win,int tly,int tlx,int show_flag);
extern  void display_siofull_update(struct _win_st *win,int tly,int tlx,struct tty *tsio);
extern  void display_siosum_update(struct _win_st *win,int y,struct tty *tsio);
extern  void grok_sio_tty(void );
/* detail.c */
extern  void detail_init(void );
extern  void detail_panel_cmd(unsigned long cmd);
extern  void detail_panel_update(void );
extern  void detpanel_destroy(void );
extern  void detpanel_extra_init(void );
extern  void detpanel_extra_update(void );
extern  void detpanel_ps_init(int full43);
extern  void detpanel_ps_update(void );
extern  void detpanel_sio_init(void );
extern  void detpanel_sio_update(void );
/* disputil.c */
extern  PANEL *mkpanel(int rows,int cols,int tly,int tlx,char *userp);
extern  void clear_area(struct _win_st *win,int y,int x,int len);
extern  void clear_area_char(struct _win_st *win,int y,int x,int len,unsigned char fillchar);
extern  void disp_info_int(struct _win_st *win,char *label,char *fmt,int value);
extern  void disp_info_long(struct _win_st *win,char *label,char *fmt,long value);
extern  void disp_msg(unsigned long cp,char *msg);
extern  void disp_static_int(struct _win_st *win,char *label,char *fmt,int value);
extern  void disp_static_long(struct _win_st *win,char *label,char *fmt,long value);
extern  void pflush(void );
extern  void wperror(struct _win_st *win,char *desc);
/* libkmem.c */
extern  void kinit(int write_needed);
extern  void kread(char *caddr,long kaddr,int len);
/* libmem.c */
extern  void minit(int write_needed);
extern  void mread(char *caddr,long maddr,int len);
/* libnlsym.c */
extern  void nlsym_error(char *text);
extern  void nlsym_read(void );
/* libswap.c */
extern  void sinit(void );
extern  void sread(char *caddr,long maddr,int len);
/* nlsym.c */
extern  int main(int argc,char * *argv,char * *envp);
extern  void nlsym_write_error(int code);
/* proc.c */
extern  char *pstat_text(char pstat);
extern  void display_proc(struct _win_st *win,int y,int x);
extern  void grok_proc(void );
/* tune.c */
extern  void display_tune(struct _win_st *win,int y,int x);
/* u386mon.c */
extern  char *get_elapsed_time(long elapsed_seconds);
extern  int get_cpu_avg(long *cpu_ticks,int period);
extern  int get_wait_avg(long *wait_ticks,int period);
extern  int main(int argc,char * *argv,char * *envp);
extern  long update_cpuscale(struct _win_st *win,int y,int x,int width,long *per_state);
extern  long update_waitscale(struct _win_st *win,int y,int x,int width,long *per_state,long total_ticks);
extern  void calc_cpu_avg(long *per_state);
extern  void calc_wait_avg(long *per_state);
extern  void caught_signal(int sig);
extern  void draw_cpuscale_literals(struct _win_st *win,int y,int x);
extern  void draw_per_sec_literals(struct _win_st *win,int y,int x);
extern  void draw_waitscale_literals(struct _win_st *win,int y,int x);
extern  void extra_info_stuff(void );
extern  void extra_static_stuff(void );
extern  void leave(int exit_code);
extern  void leave_text(char *text,int exit_code);
extern  void leaving(void );
extern  void read_sysinfo_and_minfo(void );
/* var.c */
extern  void display_var(struct _win_st *win,int y,int x);
X
#else		/* compiler doesn't know about prototyping */
X
/* bootinfo.c */
extern  char *bmemf_text();
extern  void display_bootinfo();
/* det_proc.c */
extern  char *get_cpu_time_str();
extern  char *pgrp_to_ttyname();
extern  char *uid_to_name();
extern  int det_proc_init();
extern  int get_user();
extern  int getpwent_and_enter();
extern  int ppproc_pid_compare();
extern  int uid_name_enter();
extern  struct utmp *find_utmp_for_pgrp();
extern  void display_proc_stat();
extern  void display_proc_stats();
extern  void init_uid_name_hash();
extern  void read_and_sort_procs();
extern  void read_utmp();
/* det_sio.c */
extern  char *B_to_baud_rate();
extern  char *cflag_to_baud_d_p_s();
extern  int display_sio_summary();
extern  int tty_slot_compare();
extern  void display_siofull_init();
extern  void display_siofull_update();
extern  void display_siosum_update();
extern  void grok_sio_tty();
/* detail.c */
extern  void detail_init();
extern  void detail_panel_cmd();
extern  void detail_panel_update();
extern  void detpanel_destroy();
extern  void detpanel_extra_init();
extern  void detpanel_extra_update();
extern  void detpanel_ps_init();
extern  void detpanel_ps_update();
extern  void detpanel_sio_init();
extern  void detpanel_sio_update();
/* disputil.c */
extern  PANEL *mkpanel();
extern  void clear_area();
extern  void clear_area_char();
extern  void disp_info_int();
extern  void disp_info_long();
extern  void disp_msg();
extern  void disp_static_int();
extern  void disp_static_long();
extern  void pflush();
extern  void wperror();
/* libkmem.c */
extern  void kinit();
extern  void kread();
/* libmem.c */
extern  void minit();
extern  void mread();
/* libnlsym.c */
extern  void nlsym_error();
extern  void nlsym_read();
/* libswap.c */
extern  void sinit();
extern  void sread();
/* nlsym.c */
extern  int main();
extern  void nlsym_write_error();
/* proc.c */
extern  char *pstat_text();
extern  void display_proc();
extern  void grok_proc();
/* tune.c */
extern  void display_tune();
/* u386mon.c */
extern  char *get_elapsed_time();
extern  int get_cpu_avg();
extern  int get_wait_avg();
extern  int main();
extern  long update_cpuscale();
extern  long update_waitscale();
extern  void calc_cpu_avg();
extern  void calc_wait_avg();
extern  void caught_signal();
extern  void draw_cpuscale_literals();
extern  void draw_per_sec_literals();
extern  void draw_waitscale_literals();
extern  void extra_info_stuff();
extern  void extra_static_stuff();
extern  void leave();
extern  void leave_text();
extern  void leaving();
extern  void read_sysinfo_and_minfo();
/* var.c */
extern  void display_var();
X
#endif /* LINT_ARGS */
#endif /* BUILDING_LINT_ARGS */
X
/* end of lint_args.h */
SHAR_EOF
chmod 0644 lint_args.h ||
echo 'restore of lint_args.h failed'
Wc_c="`wc -c < 'lint_args.h'`"
test 7620 -eq "$Wc_c" ||
	echo 'lint_args.h: original size 7620, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= nlsym.h ==============
if test -f 'nlsym.h' -a X"$1" != X"-c"; then
	echo 'x - skipping nlsym.h (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting nlsym.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'nlsym.h' &&
/*+-------------------------------------------------------------------------
X	nlsym.h -- utility nlist - fast access to kernel /dev/kmem offsets
X	...!{gatech,emory}!n4hgf!wht
X
The nlsym file contains three records:
1.  struct stat unixstat - stat buffer from /unix at file creation time
2.  struct nlist nlsym - the structure of nlist'd information
3.  long unique - a unique identifier to help ensure correct nlsym length
X
--------------------------------------------------------------------------*/
/*+:EDITS:*/
/*:08-14-1991-13:04-wht@n4hgf-STREAMS and table works for ISC 2.2 */
/*:08-01-1991-23:34-wht@n4hgf-release 2.40 source control point */
/*:05-15-1991-17:22-wht@n4hgf-2.3 patches for SVR31 from nba@sysware.dk */
/*:04-16-1991-02:25-martin@hppcmart additions for SCO 3.2.2 */
/*:08-10-1990-14:12-jmd@p1so/wht@n4hgf-2.20-add Tandem Integrity S2 */
/*:08-07-1990-14:24-wht@n4hgf-nba@sysware.dk SVR31 updates */
/*:08-02-1990-15:36-wht@n4hgf-2.12-old curses hacks+minor 3.2 formalizations */
/*:07-28-1990-18:06-wht@n4hgf-2.10 release */
/*:06-27-1990-01:57-wht@n4hgf-1.10-incorporate suggestions from alpha testers */
/*:06-27-1990-01:55-wht@n4hgf-use 64 bits of unique check */
/*:06-25-1990-04:14-wht@n4hgf-1.02-better error handling */
/*:06-24-1990-20:53-wht@n4hgf-v1.01-add ISC support thanks to peter@radig.de */
/*:06-21-1990-14:26-r@n4hgf-version x0.12 seems bug free */
/*:10-27-1988-11:07-wht-creation */
X
#define UNIX_KERNEL		"/unix"
#define UNIX_NLSYM		"/unix.nlsym"
#define NLSYM_UNIQUE1	0x1BADD00DL
#define NLSYM_UNIQUE2	0xDEADB1FFL
X
#define Nindex_AVAILRMEM            0
#define Nindex_AVAILSMEM            1
#define Nindex_BDEVCNT              2
#define Nindex_BDEVSW               3
#if defined(HAS_BOOTINFO)
#define Nindex_BOOTINFO             4
#else
#endif
#define Nindex_CDEVCNT              5
#define Nindex_CDEVSW               6
#define Nindex_CFREE                7
#define Nindex_CFREECNT             8
#define Nindex_CFREELIST            9
#define Nindex_CONSSW              10
#define Nindex_CURPROC             11
#ifdef SVR4
#else
#define Nindex_DINFO               12
#endif
#define Nindex_DSTFLAG             13
#define Nindex_DUMPDEV             14
#define Nindex_EMAP                15
#ifdef SVR4
#else
#define Nindex_FFREELIST           16
#endif
#define Nindex_FILE                17
#define Nindex_FMODCNT             18
#define Nindex_FMODSW              19
#define Nindex_FREEMEM             20
#ifdef SVR4
#else
#define Nindex_FSINFO              21
#endif
#ifdef SVR4
#else
#define Nindex_FSTYPSW             22
#endif
#define Nindex_HZ                  23
#ifdef SVR4
#else
#define Nindex_IDLESERVER          24
#endif
#define Nindex_IFREELIST           25
#define Nindex_INODE               26
#define Nindex_KPTBL               27
#define Nindex_LBOLT               28
#define Nindex_LINECNT             29
#define Nindex_LINESW              30
#define Nindex_MAXCLICK            31
#define Nindex_MAXMEM              32
#define Nindex_MINFO               33
#define Nindex_MOUNT               34
#ifdef SVR4
#else
#define Nindex_MSGLISTCNT          35
#endif
#ifdef SVR4
#else
#define Nindex_NFSTYP              36
#endif
#define Nindex_NPTALLOCED          37
#define Nindex_NPTFREE             38
#ifdef SVR4
#else
#define Nindex_NSERVERS            39
#endif
#define Nindex_NSWAP               40
#ifdef SVR4
#else
#define Nindex_NSYSENT             41
#endif
#define Nindex_OLDPROC             42
#define Nindex_OLD_CURPROC         43
#define Nindex_PANICSTR            44
#define Nindex_PHYSMEM             45
#define Nindex_PIPEDEV             46
#define Nindex_PROC                47
#ifdef SVR4
#else
#define Nindex_RCINFO              48
#endif
#define Nindex_ROOTDEV             49
#define Nindex_RUNQ                50
#define Nindex_SHLBINFO            51
#define Nindex_SWAPDEV             52
#define Nindex_SWPLO               53
#define Nindex_SYSERR              54
#define Nindex_SYSINFO             55
#ifdef SVR4
#else
#define Nindex_SYSSEGS             56
#endif
#define Nindex_SYSWAIT             57
#define Nindex_TIME                58
#define Nindex_TIMEZONE            59
#define Nindex_TTHIWAT             60
#define Nindex_TTLOWAT             61
#define Nindex_TUNE                62
#ifdef SVR4
#else
#define Nindex_U                   63
#endif
#define Nindex_USERTABLE           64
#define Nindex_V                   65
#ifdef SVR4
#define Nindex_TOTAL               66
#else
#define Nindex_WIN_UBLK            66
#endif
#ifdef SVR4
#define Nindex_ANONINFO            67
#else
#define Nindex_REGION              67
#endif
#if defined(M_UNIX)
#define Nindex_SIO_TTY             68
#endif
#if defined(M_UNIX) || defined(SVR31) || defined(ISC22)
#define Nindex_STRST		   69
#define Nindex_RBSIZE		   70
#define Nindex_NMBLOCK		   71
#define Nindex_FLCKINFO		   72
#define Nindex_RACTIVE		   73
#define Nindex_CALLOUT		   74
#ifdef SCO322
#define Nindex_FLSTATS		   75
#define Nindex_WD1010STATS	   76
#endif
#endif
X
#if defined(HAS_BOOTINFO)
#define bootinfoaddr (nlsym[Nindex_BOOTINFO].n_value)
#endif
#define freememaddr (nlsym[Nindex_FREEMEM].n_value)
#define lboltaddr (nlsym[Nindex_LBOLT].n_value)
#define maxmemaddr (nlsym[Nindex_MAXMEM].n_value)
#define minfoaddr (nlsym[Nindex_MINFO].n_value)
#define nswapaddr (nlsym[Nindex_NSWAP].n_value)
#define physmemaddr (nlsym[Nindex_PHYSMEM].n_value)
#define procaddr (nlsym[Nindex_PROC].n_value)
#ifdef SVR4
#define totaladdr (nlsym[Nindex_TOTAL].n_value)
#define anoninfoaddr (nlsym[Nindex_ANONINFO].n_value)
#else
#define regionaddr (nlsym[Nindex_REGION].n_value)
#endif
#define sysinfoaddr (nlsym[Nindex_SYSINFO].n_value)
#define tuneaddr (nlsym[Nindex_TUNE].n_value)
#define vaddr (nlsym[Nindex_V].n_value)
#if defined(M_UNIX)
#define sio_ttyaddr (nlsym[Nindex_SIO_TTY].n_value)
#endif
#if defined(M_UNIX) || defined(SVR31) || defined(ISC22)
#define strstaddr (nlsym[Nindex_STRST].n_value)
#define rbsizeaddr (nlsym[Nindex_RBSIZE].n_value)
#define nmblockaddr (nlsym[Nindex_NMBLOCK].n_value)
#define flckinfoaddr (nlsym[Nindex_FLCKINFO].n_value)
#define fileaddr (nlsym[Nindex_FILE].n_value)
#define ifreelistaddr (nlsym[Nindex_IFREELIST].n_value)
#define inodeaddr (nlsym[Nindex_INODE].n_value)
#define ffreelistaddr (nlsym[Nindex_FFREELIST].n_value)
#define ractiveaddr (nlsym[Nindex_RACTIVE].n_value)
#define cfreecntaddr (nlsym[Nindex_CFREECNT].n_value)
#define calloutaddr (nlsym[Nindex_CALLOUT].n_value)
#endif /* defined(M_UNIX) || defined(SVR31) || defined(ISC22) */
#ifdef SCO322
#define flstatsaddr (nlsym[Nindex_FLSTATS].n_value)
#define wd1010statsaddr (nlsym[Nindex_WD1010STATS].n_value)
#endif /* SCO322 */
X
#ifdef DEFINE_NLSYM
struct nlist nlsym[] =
{
X	{ "availrmem" },
X	{ "availsmem" },
X	{ "bdevcnt" },
X	{ "bdevsw" },
#if defined(HAS_BOOTINFO)
X	{ "bootinfo" },
#else
X	{ "spl" },	/*
X				 * dummy argument: unique text symbol present in all
X				 * implimenations (function name helps ensure uniqueness
X				 * since we don't "do" text)
X				 */
#endif
X	{ "cdevcnt" },
X	{ "cdevsw" },
X	{ "cfree" },
X	{ "cfreecnt" },
X	{ "cfreelist" },
X	{ "conssw" },
X	{ "curproc" },
#ifdef SVR4
X	{ "spl" },
#else
X	{ "dinfo" },
#endif
X	{ "Dstflag" },
X	{ "dumpdev" },
X	{ "emap" },
#ifdef SVR4
X	{ "spl" },
#else
X	{ "ffreelist" },
#endif
X	{ "file" },
X	{ "fmodcnt" },
X	{ "fmodsw" },
X	{ "freemem" },
#ifdef SVR4
X	{ "spl" },
#else
X	{ "fsinfo" },
#endif
#ifdef SVR4
X	{ "spl" },
#else
X	{ "fstypsw" },
#endif
X	{ "Hz" },
#ifdef SVR4
X	{ "spl" },
#else
X	{ "idleserver" },
#endif
X	{ "ifreelist" },
X	{ "inode" },
X	{ "kptbl" },
X	{ "lbolt" },
X	{ "linecnt" },
X	{ "linesw" },
X	{ "maxclick" },
X	{ "maxmem" },
X	{ "minfo" },
X	{ "mount" },
#ifdef SVR4
X	{ "spl" },
#else
X	{ "msglistcnt" },
#endif
#ifdef SVR4
X	{ "spl" },
#else
X	{ "nfstyp" },
#endif
X	{ "nptalloced" },
X	{ "nptfree" },
#ifdef SVR4
X	{ "spl" },
#else
X	{ "nservers" },
#endif
X	{ "nswap" },
#ifdef SVR4
X	{ "spl" },
#else
X	{ "nsysent" },
#endif
X	{ "oldproc" },
X	{ "old_curproc" },
X	{ "panicstr" },
X	{ "physmem" },
X	{ "pipedev" },
#ifdef SVR4
X	{ "practive" },
#else
X	{ "proc" },
#endif
#ifdef SVR4
X	{ "spl" },
#else
X	{ "rcinfo" },
#endif
X	{ "rootdev" },
X	{ "runq" },
X	{ "shlbinfo" },
X	{ "swapdev" },
X	{ "swplo" },
X	{ "syserr" },
X	{ "sysinfo" },
#ifdef SVR4
X	{ "spl" },
#else
X	{ "syssegs" },
#endif
X	{ "syswait" },
X	{ "time" },
X	{ "Timezone" },
X	{ "tthiwat" },
X	{ "ttlowat" },
X	{ "tune" },
#ifdef SVR4
X	{ "spl" },
#else
X	{ "u" },
#endif
X	{ "usertable" },
X	{ "v" },
#ifdef SVR4
X	{ "total" },
#else
X	{ "win_ublk" },
#endif
#ifdef SVR4
X	{ "anoninfo" },
#else
X	{ "region" },
#endif
#if defined(M_UNIX)
X	{ "sio_tty" },
#else
X	{ "spl" },
#endif
#if defined(M_UNIX) || defined(SVR31) || defined(ISC22)
X	{ "strst" },
X	{ "rbsize" },
X	{ "nmblock" },
X	{ "flckinfo" },
X	{ "ractive" },
X	{ "callout" },
#ifdef SCO322
X	{ "flstats" },
X	{ "wd1010stats" },
#endif
#endif
X	{ (char *)0 }
};
#else
extern struct nlist nlsym[];
#endif
X
/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
chmod 0644 nlsym.h ||
echo 'restore of nlsym.h failed'
Wc_c="`wc -c < 'nlsym.h'`"
test 8915 -eq "$Wc_c" ||
	echo 'nlsym.h: original size 8915, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= u386mon.h ==============
if test -f 'u386mon.h' -a X"$1" != X"-c"; then
	echo 'x - skipping u386mon.h (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting u386mon.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'u386mon.h' &&
/*+-------------------------------------------------------------------------
X	u386mon.h - UNIX 386 system monitor definitions
X	wht@n4hgf.Mt-Park.GA.US
--------------------------------------------------------------------------*/
/*+:EDITS:*/
/*:08-01-1991-23:35-wht@n4hgf-release 2.40 source control point */
/*:08-10-1990-14:12-jmd@p1so/wht@n4hgf-2.20-add Tandem Integrity S2 */
/*:08-07-1990-14:24-wht@n4hgf-nba@sysware.dk SVR31 updates */
/*:08-02-1990-15:36-wht@n4hgf-2.12-old curses hacks+minor 3.2 formalizations */
/*:07-28-1990-18:06-wht@n4hgf-2.10 release */
/*:07-10-1990-19:06-root@n4hgf-redesign attributes/color pairs */
/*:07-10-1990-18:33-root@n4hgf-move pio wait to medium alert */
/*:07-03-1990-03:21-root@n4hgf-add cpBANWARN and renumber */
/*:06-27-1990-01:57-wht@n4hgf-1.10-incorporate suggestions from alpha testers */
/*:06-25-1990-04:14-wht@n4hgf-1.02-better error handling */
/*:06-24-1990-20:53-wht@n4hgf-v1.01-add ISC support thanks to peter@radig.de */
/*:06-21-1990-14:27-r@n4hgf-version x0.12 seems bug free */
/*:06-20-1990-03:03-root@n4hgf-trick use_cp into making bright fgnd colors */
/*:06-19-1990-21:35-wht-get ready for release */
X
#ifndef M_SYSV	/* for ISC */
#define u_char unsigned char
#define u_long unsigned long
#endif
X
char *getenv();
char *strchr();
char *strrchr();
#ifdef __STDC__
void *malloc();
#else
char *malloc();
#endif
X
#define pW(pan) panel_window(pan)
#define W WINDOW
#define P PANEL
X
/* color numbers for EGA/VGA */
#ifdef COLOR_16_TERMINFO	/* wht 16-color fgnd/bgnd terminfo */
#define cHIBIT	8
#define cBLK	0
#define cBLU	1
#define cGRN	2
#define cCYN	3
#define cRED	4
#define cMAG	5
#define cBRN	6
#define cWHT	7
#define cGRY	(cBLK | cHIBIT)
#define cLTB	(cBLU | cHIBIT)
#define cLTG	(cGRN | cHIBIT)
#define cLTC	(cCYN | cHIBIT)
#define cLTR	(cRED | cHIBIT)
#define cLTM	(cMAG | cHIBIT)
#define cYEL	(cBRN | cHIBIT)
#define cHIW	(cWHT | cHIBIT)
#else
#ifdef	COLOR_BLACK
#define cBLK	COLOR_BLACK
#define cBLU	COLOR_BLUE
#define cGRN	COLOR_GREEN
#define cCYN	COLOR_CYAN
#define cRED	COLOR_RED
#define cMAG	COLOR_MAGENTA
#define cBRN	COLOR_YELLOW
#define cWHT	COLOR_WHITE
#define cGRY	COLOR_BLACK
#define cLTB	COLOR_BLUE
#define cLTG	COLOR_GREEN
#define cLTC	COLOR_CYAN
#define cLTR	COLOR_RED
#define cLTM	COLOR_MAGENTA
#define cYEL	COLOR_YELLOW
#define cHIW	COLOR_WHITE
#endif
#endif
X
#define sTL		0xDA
#define sTR		0xBF
#define sBL		0xC0
#define sBR		0xD9
#define sLT		0xC3	/* left hand T */
#define sRT		0xB4	/* right hand T */
#define sVR		0xB3	/* vertical rule */
#define sHR		0xC4	/* horizontal rule */
X
/* color pairs */
#ifdef COLOR_16_TERMINFO	/* wht 16-color fgnd/bgnd terminfo */
#define use_cp(win,cp) wattrset(win,COLOR_PAIR(cp))
#else
#ifdef COLOR_PAIR
#define use_cp(win,cp) wattrset(win,\
X	(color_avail) ? color_attr[cp] : mono_attr[cp])
#else
#define use_cp(win,cp) wattrset(win,mono_attr[cp])
#endif
#endif
X
/*
X * for SVR31
X */
#ifndef getcury
#define getcury(win)        ((win)->_cury)
#endif
#ifndef getcurx
#define getcurx(win)        ((win)->_curx)
#endif
#ifndef getbegy
#define getbegy(win)        ((win)->_begy)
#endif
#ifndef getbegx
#define getbegx(win)        ((win)->_begx)
#endif
#ifndef getbegyx
#define getbegyx(win,y,x)   ((y)=getbegy(win),(x)=getbegx(win))
#endif
#ifndef getmaxy
#define getmaxy(win)        ((win)->_maxy)
#endif
#ifndef getmaxx
#define getmaxx(win)        ((win)->_maxx)
#endif
#ifndef getmaxyx
#define getmaxyx(win,y,x)   ((y)=getmaxy(win),(x)=getmaxx(win))
#endif
X
/* 
X * if color par numbers are changed, disputil.c
X * color_attr and mono_attr tables
X * must also be changed
X */
X
#define cpINFO		1	/* information field */
#define cpREVERSE	2	/* "reverse video" */
#define cpBANWARN	3	/* banner warning */
#define cpLOW		4	/* low/user/io */
#define cpMED		5	/* medium/kernel/pio */
#define cpHIGH		6	/* high/brk/swp */
#define cpBANNER	7	/* banner */
#define cpLIT		8	/* field literals */
extern int color_avail;
#ifdef COLOR_PAIR
extern long color_attr[];
#endif
extern long mono_attr[];
X
#define MSG_TLY		(LINES - 2)
#define CMD_TLY		(LINES - 1)
#define LVMSG_Y		MSG_TLY
#define LVMSG_X		0
X
#define CPUSCALE_TLY		1
#define CPUSCALE_SX			13
#define CPUSCALE_WIDTH		50
X
#define WAITSCALE_TLY		5
#define WAITSCALE_SX		13
#define WAITSCALE_WIDTH		50
X
/* Sysinfo/Minfo per second area */
#define PER_SEC_TLY			9
#define PER_SEC1_TLX		0
#define PER_SEC2_TLX		18
#define PER_SEC3_TLX		35
#define PER_SEC4_TLX		51
#define PER_SEC5_TLX		66
X
/* extra info area */
#define EXTRA_TLY			26
#define EXTRA1_TLX			0
#define EXTRA2_TLX			18
#define EXTRA3_TLX			43
#define EXTRA4_TLX			62
X
#include "lint_args.h"
X
/* vi: set tabstop=4 shiftwidth=4: */
/* end of u386mon.h */
SHAR_EOF
chmod 0644 u386mon.h ||
echo 'restore of u386mon.h failed'
Wc_c="`wc -c < 'u386mon.h'`"
test 4671 -eq "$Wc_c" ||
	echo 'u386mon.h: original size 4671, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= renice/Makefile ==============
if test ! -d 'renice'; then
    echo 'x - creating directory renice'
    mkdir 'renice'
fi
if test -f 'renice/Makefile' -a X"$1" != X"-c"; then
	echo 'x - skipping renice/Makefile (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting renice/Makefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'renice/Makefile' &&
#  CHK=0xD897
#+-------------------------------------------------------------------
#  Makefile for renice for SCO UNIX V/386
#  ...!emory!n4hgf!wht
#--------------------------------------------------------------------
#+:EDITS:*/
#:06-25-1990-04:14-wht@n4hgf-1.03-better error handling
#:06-21-1990-14:27-r@n4hgf-version x0.12 seems bug free
#:06-19-1990-21:37-wht@n4hgf-get ready for 0.08 release
X
#------------> CFLAGS 
CFLAGS = -c -Octl -DLINT_ARGS
#CFLAGS = -c -O
X
#------------> BINDIR
BINDIR = /usr/local/bin
X
#LDFLAGS = -s
X
X
#handle Sys V make "feature" of using SHELL
SHELL = /bin/sh
X
#FCRC = fcrc -u $*.c ;
.c.o:;	$(FCRC) $(CC) $(CFLAGS) $*.c 
X
SRC = \
X	renice.c
X
RENICE_OBJ =\
X	renice.o\
X	../libnlsym.o\
X	libkmem-w.o
X
all: renice
X
#must run as root
install: all
X	mv renice $(BINDIR)
X	chmod 4711 $(BINDIR)/renice
X	chown root $(BINDIR)/renice
X	@echo ' ';echo 'csh users rehash before executing'
X
renice: $(RENICE_OBJ)
X	$(CC) $(LDFLAGS) -o $@ $(RENICE_OBJ) $(LIB)
X
libkmem-w.o: ../libkmem.c
X	cc $(CFLAGS) -I .. -DKWRITE_NEEDED ../libkmem.c; mv libkmem.o libkmem-w.o
X
../libnlsym.o: ../libnlsym.c
X	cd ..;make libnlsym.o
X
clean:
X	rm -f renice.o libkmem-w.o core 
X
clobber: clean
X	rm -f renice
X
SHAR_EOF
chmod 0644 renice/Makefile ||
echo 'restore of renice/Makefile failed'
Wc_c="`wc -c < 'renice/Makefile'`"
test 1200 -eq "$Wc_c" ||
	echo 'renice/Makefile: original size 1200, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= renice/renice.c ==============
if test -f 'renice/renice.c' -a X"$1" != X"-c"; then
	echo 'x - skipping renice/renice.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting renice/renice.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'renice/renice.c' &&
/* CHK=0xE998 */
/*+-------------------------------------------------------------------------
X	renice.c - UNIX 386 renice
X
X * This program was written by me, Mike "Ford" Ditto, and
X * I hereby release it into the public domain in the interest
X * of promoting the development of free, quality software
X * for the hackers and users of the world.
X *
X * Feel free to use, copy, modify, improve, and redistribute
X * this program, but keep in mind the spirit of this
X * contribution; always provide source, and always allow
X * free redistribution (shareware is fine with me).  If
X * you use a significant part of this code in a program of
X * yours, I would appreciate being given the appropriate
X * amount of credit.
X *				-=] Ford [=-
X *
--------------------------------------------------------------------------*/
/*+:EDITS:*/
/*:06-26-1990-15:09-wht@n4hgf-adapt Ford's work to UNIX 386 */
X
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#undef NGROUPS_MAX
#undef NULL
#include <sys/param.h>
#include <sys/immu.h>
#include <sys/region.h>
#include <sys/proc.h>
#include <sys/var.h>
#include <nlist.h>
#include "../nlsym.h"
#include "../libkmem.h"
#include "../libnlsym.h"
X
struct var v;
struct proc tproc;
int myuid;
char *progname;
char s128[128];
int myreadcnt = 0;			/* see libkmem.c, libmem.c, libswap.c */
daddr_t myreadlen = 0;
X
/*+-------------------------------------------------------------------------
X	leave_text(text,exit_code)
If exit_code == 255, do perror
--------------------------------------------------------------------------*/
void
leave_text(text,exit_code)
char *text;
int exit_code;
{
X	if(exit_code == 255)
X		perror(text);
X	else
X	{
X		fputs(text,stderr);
X		fputs("\n",stderr);
X	}
X	exit(exit_code);
}	/* end of leave_text */
X
/*+-------------------------------------------------------------------------
X	renice(pid,value,relative) - change nice of process `pid'
based on 'value' and 'relative'
--------------------------------------------------------------------------*/
renice(pid,value,relative)
int pid;
int value;
int relative;
{
X	register i;
X	int tmpnice;
X
X	for(i = 0; i < v.v_proc; i++)
X	{
X		kread((caddr_t)&tproc,(daddr_t)((struct proc *)procaddr + i),
X		    sizeof(struct proc));
X		if(tproc.p_pid == pid)
X		{
#ifdef DEBUG
X			fprintf(stderr,"Found it!  proc[%d], p_uid is %d\n",
X			    i,tproc.p_uid);
X
X			fprintf(stderr,"Old p_nice was %d\n",tproc.p_nice);
#endif /* DEBUG */
X
X			tmpnice = tproc.p_nice;
X
X			if(relative)
X				tmpnice += value;
X			else
X				tmpnice = value;
X
X			if(tmpnice >= 40)
X				tmpnice = 40;
X			if(tmpnice < 0)
X				tmpnice = 0;
X
#ifdef DEBUG
X			fprintf(stderr,"New p_nice is %d\n",tmpnice);
#endif /* DEBUG */
X
X			if( 
#ifdef WHT
X				(myuid && (myuid != 201))
#else
X				myuid
#endif
X			 	&& ((myuid != tproc.p_uid) || (tmpnice < tproc.p_nice)))
X			{
X				errno = EACCES;
X				sprintf(s128,"%s: can't renice process %d",progname,pid);
X				perror(s128);
X				return 1;
X			}
X
X			tproc.p_nice = tmpnice;
X
X			kwrite((daddr_t)&((struct proc *)procaddr)[i]
X			    + ( ((caddr_t)&tproc.p_nice) - (caddr_t)&tproc ),
X			    (caddr_t)&tproc.p_nice,sizeof(tproc.p_nice));
X			return(0);
X		}
X	}
X	fprintf(stderr,"%s: process %d not found.\n",progname,pid);
X
X	return(1);
}	/* end of renice */
X
/*+-------------------------------------------------------------------------
X	usage()
--------------------------------------------------------------------------*/
void
usage()
{
X    fprintf(stderr,"usage: %s [{+-}inc] [=prio] pid ...\n",progname);
X    exit(-1);
}	/* end of usage */
X
/*+-------------------------------------------------------------------------
X	main(argc,argv)
--------------------------------------------------------------------------*/
main(argc,argv)
int argc;
char **argv;
{
X	int status=0;
X	int pid;
X	int relative = 1;
X	int value = 0;
X
X	progname = *argv;
X	if(argc < 2)
X		usage();
X
X	myuid = getuid();
X	nlsym_read();
X	kinit(1);
X	kread((caddr_t)&v,vaddr,sizeof(v));
X
X	while(++argv,--argc)
X	{
X		switch(**argv)
X		{
X		case '-':
X			if(sscanf(*argv+1,"%d",&value) != 1)
X				usage();
X			relative = 1;
X			break;
X		case '+':
X			if(sscanf(*argv+1,"%d",&value) != 1)
X				usage();
X			value = -value;
X			relative = 1;
X			break;
X		case '=':
X			if(sscanf(*argv+1,"%d",&value) != 1)
X				usage();
X			relative = 0;
X			break;
X		default:
X			if(sscanf(*argv,"%d",&pid) != 1)
X				usage();
X			status += renice(pid,value,relative);
X		}
X	}
X
X	exit(status);
}	/* end of main */
X
/* vi: set tabstop=4 shiftwidth=4: */
/* end of renice.c */
SHAR_EOF
chmod 0644 renice/renice.c ||
echo 'restore of renice/renice.c failed'
Wc_c="`wc -c < 'renice/renice.c'`"
test 4465 -eq "$Wc_c" ||
	echo 'renice/renice.c: original size 4465, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= panel/README ==============
if test ! -d 'panel'; then
    echo 'x - creating directory panel'
    mkdir 'panel'
fi
if test -f 'panel/README' -a X"$1" != X"-c"; then
	echo 'x - skipping panel/README (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting panel/README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'panel/README' &&
LIBPANEL 1.2 README - last revised Wed Jul 25 01:07:33 EDT 1990
X
This is a public domain implementation of the S5R3 terminfo
curses panels layer.  It was written primarily to assist in
porting u386mon 2.0 (comp.sources.misc v14i001-4) to systems
lacking panels support.  It meets those needs and may be
useful in other applications.  u386mon 2.10 and beyond use
the package.
X
FUNCTIONALITY
-------------
X
Panels are terminfo curses(3) windows with the added feature of depth.
Panel functions allow the use of stacked windows and ensure the proper
portions of each window and the curses stdscr window are hidden or
displayed when panels are added, moved, modified or removed.  The set
of currently visible panels is the stack of panels.  Stdscr beneath
all panels, and is not considered part of the stack.
X
A window is associated with every panel.  The panel routines enable
you to create, move, hides, and show panels, as well as position a
panel at an appropriate position in the stack.
X
Panel routines are a functional layer added to terminfo curses(3),
make only high-level curses calls, and work anywhere terminfo curses
does.
X
COMPATIBILITY
-------------
X
Reasonable care has been taken to ensure compatibility with the native
panel facility introducted with S5R3.2.  The PANEL data structures are
merely similar.  The programmer is cautioned not to directly use
'PANEL' fields.
X
The functions show_panel() and top_panel() are identical in thes
implementation, and work equally well with displayed or hidden panels.
In the native implementation, show_panel() is intended for making a
hidden panel visible (at the top of the stack) and top_panel() is
intended for making an already-visible panel move to the top of the
stack.  You are cautioned to use the correct function to ensure
compatibility with native panel libraries.
X
USE
---
X
To make this panels implementation work for you, install
panel.h in /usr/include or modify each of your panel-using
sources in a fashion similar to:
X
old:
#include <curses.h>
#include <panel.h>
X
new:
#include <curses.h>
#ifdef NATIVE_PANELS
#include <panel.h>
#else
#include "panel.h"
#endif
X
Include libpanel.o in your link line and panel away.
X
COMPILE TIME SWITCHES
---------------------
__STDC__ is used to detect nouveau compilers.  Depending on who/where
you are, on what day of the week, The Great Programmer help you.
I only use it to satisfy lint that malloc is a good function to use.
X
LINT_ARGS causes a Microsoft 5.1 flavor of function prototypes to
be used.
X
NATIVE_PANELS is detected by panel.h.  If NATIVE_PANELS *is* defined,
then an error is emited to keep you from using the wrong panel.h.
X
TESTING
-------
X
A rudimentary test program, PTEST, is supplied.  It requires
the nap() system call.  If You do not have nap, add -DNONAP
to your CFLAGS line.
X
X
Comments are appreciated, especially bug fixes and information
helping to port the module to another system.
X
NO FSF, LPF, FOO or LSD -- just free.
X
Warren Tucker N4HGF
{gatech,emory}!n4hgf!wht -or- wht@n4hgf.Mt-Park.GA.US
SHAR_EOF
chmod 0644 panel/README ||
echo 'restore of panel/README failed'
Wc_c="`wc -c < 'panel/README'`"
test 3033 -eq "$Wc_c" ||
	echo 'panel/README: original size 3033, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= panel/panel.3 ==============
if test -f 'panel/panel.3' -a X"$1" != X"-c"; then
	echo 'x - skipping panel/panel.3 (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting panel/panel.3 (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'panel/panel.3' &&
.\" @(#)panel.3	1.1 7/23/90
.TH PANEL 3 "23 July 1990" "wht@n4hgf"
.SH NAME
panel - surrogate PANEL library routines
.SH SYNTAX
.B "include "panel.h"
X
.B "cc [flags] sourcefiles libpanel.[co] -lcurses -[otherlibs]
X
.B "PANEL *new_panel(win);"
.br
WINDOW *win;
X
.B "int bottom_panel(pan);"
.br
PANEL *pan;
X
.B "int top_panel(pan);"
.br
PANEL *pan;
X
.B "int show_panel(pan);"
.br
PANEL *pan;
X
.B "void update_panels();"
X
.B "int hide_panel(pan);"
.br
PANEL *pan;
X
.B "WINDOW *panel_window(pan);"
.br
PANEL *pan;
X
.B "int replace_panel(pan,window);"
.br
PANEL *pan;
.br
WINDOW *window;
X
.B "int move_panel(pan,starty,startx);"
.br
PANEL *pan;
.br
int starty;
.br
int startx;
X
.B "int panel_hidden(pan);"
.br
PANEL *pan;
X
.B "PANEL *panel_above(pan);"
.br
PANEL *pan;
X
.B "PANEL *panel_below(pan);"
.br
PANEL *pan;
X
.B "int set_panel_userptr(pan,ptr);"
.br
PANEL *pan;
.br
char *ptr;
X
.B "char *panel_userptr(pan);"
.br
PANEL *pan;
X
.B "int del_panel(pan);"
.br
PANEL *pan;
X
.SH DESCRIPTION
Panels are terminfo curses(3) windows with the added feature of
depth.  Panel functions allow the use of stacked windows and
ensure the proper portions of each window and the curses stdscr
window are hidden or displayed when panels are added, moved,
modified or removed.  The set of currently visible panels is the
stack of panels.  Stdscr beneath all panels, and is not
considered part of the stack.
X
A window is associated with every panel.  The panel routines
enable you to create, move, hides, and show panels, as well as
position a panel at an appropriate position in the stack.
X
Panel routines are a functional layer added to terminfo curses(3), make
only high-level curses calls, and work anywhere terminfo curses does.
X
.SH FUNCTIONS
.B "new_panel(win)"
allocates a 'PANEL',
assovciates it with win,
places the panel on the top of the stack (causes it to be dispalyed
above any other panel) and
returns a pointer to the new panel.
X
.B "void update_panels()"
refreshes the virtual screen to reflect the relations between the
panels in the stack, but does not call doupdate() to refresh the
physical screen.  Use this function and not wrefresh or wnoutrefresh.
update_panels() may be called more than once before a call to
doupdate(), but doupdate() is the function responsible for
updating the physical screen.
.br
e.g.,
.br
update_panels();   /* panel(3) call */
.br
doupdate();        /* curses(3) call */
X
.B "del_panel(pan)"
removes pan from the stack,
deletes the 'PANEL', but not its associated window.
X
.B "hide_panel(pan)"
removes the panel from the panel stack and thus hides it
from view.  The 'PANEL' is not lost, merely removed
from the stack.
X
.B "show_panel(pan)"
makes a hidden panel visible by placing it on top of
the panels in the panel stack.
See COMPATIBILITY below.
X
.B "top_panel(pan)"
puts the given visible panel on top of all panels in the stack.
See COMPATIBILITY below.
X
.B "bottom_panel(pan)"
puts panel at the bottom of all panels.
X
.B "move_panel(pan,starty,startx)"
moves the given panel window so that
its upper-left corner is at starty, startx.  
It does not change the position of the panel in the stack.
Be sure to use this function, not mvwin(), to move a panel window.
X
.B "replace_panel(pan,window)"
replaces the current window of panel with window.
It does not change the position of the panel in the stack.
X
.B "panel_above(pan)"
returns a pointer to the panel above pan.  If
the panel argument is (PANEL *)0, it returns a pointer to the
bottom panel in the stack.
X
.B "panel_below(pan)"
returns a pointer to the panel just below pan.
If the panel argument is (PANEL *)0,
it returns a pointer to the top panel in the stack.
X
.B "set_panel_userptr(pan,ptr)"
sets the panel's user pointer.
X
.B "panel_userptr(pan)"
returns the user pointer for a given panel.
X
.B "panel_window(pan)"
returns a pointer to the window of panel.
X
.SH DIAGNOSTICS
Each routine that returns a pointer returns NULL if an error
occurs.  Each routine that returns an int value returns OK if it
executes successfully and ERR if not.
X
.SH COMPATIBILITY
Reasonable care has been taken to ensure compatibility with
the native panel facility introducted with S5R3.2.  The PANEL
data structures are merely  similar.  The programmer
is cautioned not to directly use 'PANEL' fields.
X
The functions show_panel() and top_panel() are identical
in thes implementation, and work equally well with
displayed or hidden panels.
In the native implementation,
show_panel() is intended for making a hidden panel visible
(at the top of the stack) and top_panel() is intended for
making an already-visible panel move to the top of the stack.
You are cautioned to use the correct function to ensure
compatibility with native panel libraries.
X
.SH FILES
panel.h
.br
libpanel.c
X
.SH "SEE ALSO"
curses(3)
X
.SH "AUTHOR"
wht@n4hgf.Mt-Park.GA.US ({emory,gatech}!n4hgf!wht), primarily
to assist in porting u386mon to systems without a native
panels library.
SHAR_EOF
chmod 0644 panel/panel.3 ||
echo 'restore of panel/panel.3 failed'
Wc_c="`wc -c < 'panel/panel.3'`"
test 4935 -eq "$Wc_c" ||
	echo 'panel/panel.3: original size 4935, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= panel/ptest.c ==============
if test -f 'panel/ptest.c' -a X"$1" != X"-c"; then
	echo 'x - skipping panel/ptest.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting panel/ptest.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'panel/ptest.c' &&
/*+-------------------------------------------------------------------------
X	ptest.c
--------------------------------------------------------------------------*/
/*+:EDITS:*/
/*:07-24-1990-23:20-wht@n4hgf-move debug code to libpanel.c */
/*:07-20-1990-18:28-wht-creation */
X
#define M_TERMINFO
#include <curses.h>
#include "libpanel.h"
X
PANEL *p1;
PANEL *p2;
PANEL *p3;
PANEL *p4;
PANEL *p5;
WINDOW *w1;
WINDOW *w2;
WINDOW *w3;
WINDOW *w4;
WINDOW *w5;
X
long nap_msec = 500L;
X
char *mod[] = 
{
X	"test ",
X	"TEST ",
X	"(**) ",
X	"*()* ",
X	"<--> ",
X	"LAST "
};
X
/*+-------------------------------------------------------------------------
X	wait_a_while(msec)
--------------------------------------------------------------------------*/
void
wait_a_while(msec)
long msec;
{
#ifdef NONAP
X	if(nap_msec == 1)
X		getchar();
X	else if(msec > 1000L)
X		sleep((int)msec/1000L);
X	else
X		sleep(1);
#else
X	if(nap_msec == 1)
X		getchar();
X	else
X		nap(nap_msec);
#endif
}	/* end of wait_a_while */
X
/*+-------------------------------------------------------------------------
X	saywhat(text)
--------------------------------------------------------------------------*/
void
saywhat(text)
char *text;
{
int y,x;
X
#ifdef PANEL_DEBUG
X	if(!dfp)
X	{
X		dfp = fopen("p.log","w");
X		fputs("-------\n",dfp);
X	}
X	fprintf(dfp,"\n--> %s\n",text);
#endif
X
X	wmove(stdscr,LINES - 1,0);
X	wprintw(stdscr,"%-20.20s",text);
X
}	/* end of saywhat */
X
/*+-------------------------------------------------------------------------
X	mkpanel(rows,cols,tly,tlx) - alloc a win and panel and associate them
--------------------------------------------------------------------------*/
PANEL *
mkpanel(rows,cols,tly,tlx)
int rows;
int cols;
int tly;
int tlx;
{
WINDOW *win = newwin(rows,cols,tly,tlx);
PANEL *pan;
X
X	if(!win)
X		return((PANEL *)0);
X	if(pan = new_panel(win))
X		return(pan);
X	delwin(win);
X	return((PANEL *)0);
}	/* end of mkpanel */
X
/*+-------------------------------------------------------------------------
X	rmpanel(pan)
--------------------------------------------------------------------------*/
void
rmpanel(pan)
PANEL *pan;
{
WINDOW *win = pan->win;
X	del_panel(pan);
X	delwin(win);
}	/* end of rmpanel */
X
/*+-------------------------------------------------------------------------
X	pflush()
--------------------------------------------------------------------------*/
void
pflush()
{
X	update_panels();
X	doupdate();
}	/* end of pflush */
X
/*+-------------------------------------------------------------------------
X	fill_panel(win)
--------------------------------------------------------------------------*/
fill_panel(pan)
PANEL *pan;
{
WINDOW *win = pan->win;
char num = *(pan->user + 1);
int y,x;
X
X	box(win,'|','-');
X	wmove(win,1,1);
X	wprintw(win,"-pan%c-",num);
X	for(y = 2; y < getmaxy(win) - 1; y++)
X	{
X		for(x = 1; x < getmaxx(win) - 1; x++)
X		{
X			wmove(win,y,x);
X			waddch(win,num);
X		}
X	}
}	/* end of fill_panel */
X
/*+-------------------------------------------------------------------------
X	main(argc,argv)
--------------------------------------------------------------------------*/
main(argc,argv)
int argc;
char **argv;
{
int itmp;
register y,x;
long atol();
X
X	if((argc > 1) && atol(argv[1]))
X		nap_msec = atol(argv[1]);
X
X	initscr();
X
X	for(y = 0; y < LINES - 1; y++)
X	{
X		for(x = 0; x < COLS; x++)
X			wprintw(stdscr,"%d",(y + x) % 10);
X	}
X	for(y = 0; y < 5; y++)
X	{
X		p1 = mkpanel(10,10,0,0);
X		w1 = panel_window(p1);
X		set_panel_userptr(p1,"p1");
X
X		p2 = mkpanel(14,14,5,5);
X		w2 = panel_window(p2);
X		set_panel_userptr(p2,"p2");
X
X		p3 = mkpanel(6,8,12,12);
X		w3 = panel_window(p3);
X		set_panel_userptr(p3,"p3");
X
X		p4 = mkpanel(10,10,10,30);
X		w4 = panel_window(p4);
X		set_panel_userptr(p4,"p4");
X
X		p5 = mkpanel(10,10,13,37);
X		w5 = panel_window(p5);
X		set_panel_userptr(p5,"p5");
X
X		fill_panel(p1);
X		fill_panel(p2);
X		fill_panel(p3);
X		fill_panel(p4);
X		fill_panel(p5);
X		hide_panel(p4);
X		hide_panel(p5);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("h3 s1 s2 s4 s5;");
X		move_panel(p1,0,0);
X		hide_panel(p3);
X		show_panel(p1);
X		show_panel(p2);
X		show_panel(p4);
X		show_panel(p5);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("s1;");
X		show_panel(p1);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("s2;");
X		show_panel(p2);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("m2;");
X		move_panel(p2,10,10);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("s3;");
X		show_panel(p3);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("m3;");
X		move_panel(p3,5,5);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("b3;");
X		bottom_panel(p3);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("s4;");
X		show_panel(p4);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("s5;");
X		show_panel(p5);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("t3;");
X		top_panel(p3);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("t1;");
X		top_panel(p1);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("t2;");
X		top_panel(p2);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("t3;");
X		top_panel(p3);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("t4;");
X		top_panel(p4);
X		pflush();
X		wait_a_while(nap_msec);
X
X		for(itmp = 0; itmp < 6; itmp++)
X		{
X			saywhat("m4;");
X			wmove(w4,3,1);
X			waddstr(w4,mod[itmp]);
X			move_panel(p4,4,itmp*10);
X			wmove(w5,4,1);
X			waddstr(w5,mod[itmp]);
X			pflush();
X			wait_a_while(nap_msec);
X			saywhat("m5;");
X			wmove(w4,4,1);
X			waddstr(w4,mod[itmp]);
X			move_panel(p5,7,(itmp*10) + 6);
X			wmove(w5,3,1);
X			waddstr(w5,mod[itmp]);
X			pflush();
X			wait_a_while(nap_msec);
X		}
X
X		saywhat("m4;");
X		move_panel(p4,4,itmp*10);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("t5;");
X		top_panel(p5);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("t2;");
X		top_panel(p2);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("t1;");
X		top_panel(p1);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("d2;");
X		rmpanel(p2);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("h3;");
X		hide_panel(p3);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("d1;");
X		rmpanel(p1);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("d4; ");
X		rmpanel(p4);
X		pflush();
X		wait_a_while(nap_msec);
X
X		saywhat("d5; ");
X		rmpanel(p5);
X		pflush();
X		wait_a_while(nap_msec);
X		if(nap_msec == 1)
X			break;
X		nap_msec = 100L;
X	}
X	endwin();
X	exit(0);
}	/* end of main */
X
/* vi: set tabstop=4 shiftwidth=4: */
/* end of ptest.c */
SHAR_EOF
chmod 0644 panel/ptest.c ||
echo 'restore of panel/ptest.c failed'
Wc_c="`wc -c < 'panel/ptest.c'`"
test 6321 -eq "$Wc_c" ||
	echo 'panel/ptest.c: original size 6321, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= panel/Makefile ==============
if test -f 'panel/Makefile' -a X"$1" != X"-c"; then
	echo 'x - skipping panel/Makefile (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting panel/Makefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'panel/Makefile' &&
CFLAGS = -O
#CFLAGS = -O -DLINT_ARGS
X
SHARFLS = \
X	README\
X	Makefile\
X	panel.3\
X	config.h\
X	libpanel.h\
X	libpanel.c
X
OBJ = ptest.o libpanel.o
X
ptest: $(OBJ)
X	cc -o $@ $(OBJ) -lcurses -lx
X
$(OBJ): Makefile libpanel.h
X
shar:
X	shar -n libpanel -a $(SHARFLS) > libpanel.sh
X
clean:
X	rm -rf $(OBJ) core a.out cscope.out tags
X
clobber: clean
X	rm -rf ptest
SHAR_EOF
chmod 0644 panel/Makefile ||
echo 'restore of panel/Makefile failed'
Wc_c="`wc -c < 'panel/Makefile'`"
test 349 -eq "$Wc_c" ||
	echo 'panel/Makefile: original size 349, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
rm -f _shar_seq_.tmp
echo You have unpacked the last part
exit 0
-- 
Andreas Vogel                   Bahnhofstr. 13 / D-7300 Esslingen / Germany
				Voice:  +49-711/357613
				E-Mail: av@ssw.de
