[comp.windows.x] xrload: xrload.h, bug fix

spa@hara.DEC.COM (Salvador Pinto Abreu) (08/18/87)

Sorry about that... here it is. [this is only a problem with the
mutiple file version]
 
A (small) bug fix: xrload doesn't correcly update the window when the
order in which ruptime(1) displays its stuff changes, you may get
garbled host names (esp. if they're shorter than the one that was
there before).
 
remedy: add the line:
	> 
	>     XClear (stat->w);
	>
before
	>
	>    if (stat->state == DOWN) {
	>	 XBitmapBitsPut (stat->w, (ww-down.width)/2 ...
	>
in function "update_sys".
 
here's xrload.h:
----
#include <stdio.h>
#include <signal.h>
#include <string.h>
#include <ctype.h>
#include <setjmp.h>
#include <sys/file.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <netdb.h>
#include <netinet/in.h>
#include <math.h>
 
#include <X/Xlib.h>
 
#define streq(a,b) (!(strcmp(a,b)))
 
#define	TRUE	1
#define	FALSE	0
 
#define	DEFAULT_FONT	"timrom10b"
#define	DEFAULT_DELAY	30
#define	DEFAULT_BWIDTH	2
#define	DEFAULT_SPACING	2
 
#define	MAXNAME	32
#define	MAXSYS	128
 
typedef struct {
    int width, height;
    int x_hot, y_hot;
    short *bits;
} Bitmap_data;
 
extern Pixmap GrayPixmap;
extern Pixmap whitePixmap, blackPixmap;
extern int whitePixel, blackPixel;
extern Bitmap_data gray1, back, down;
 
extern FontInfo *theFont;
extern OpaqueFrame frame;
extern Window mainWindow;
extern WindowInfo mainLoc;
extern char *geometry, defGeometry[];
extern int minWidth, minHeight;
extern Bitmap bitmap;
extern int mapped;
extern int nSystems;
extern int ncols;
extern int dflag;
extern int delay;
extern int border_width;
extern int same_scale;
extern char *font_name;
extern int reverse;
extern int all_hosts;
extern int X_hosts;
extern char *host_names[];
extern int ww, dd, hh, rr;
 
typedef struct {
    char	sys_name[MAXNAME];
    float	load_average[3];
    int		users;
    int		state;
#define	DOWN	0
#define UP	1
    char	how_long[10];
    Window	w;
} sys_stat;
 
extern sys_stat stats[];
 
extern void show_stats ();
extern int get_stats ();
extern void recalc_windows ();
extern void update_sys ();
 
#define max(a,b) (((a)>(b))? (a): (b))
----
 
btw, since I only have monochrome displays around here, I didn't try
playing with color... anyone care to do that?
---
UUCP: ...{mcvax,inria}!inesc!hara.unl.psi!spa	PSI/VMS: PSI%+26805010310::SPA
ARPA: lisvax.dec!unlai!spa@decwrl.dec.com	Phone: + 351 1 295 31 56
 
Snail:	Salvador Pinto Abreu
	Dept. of Computer Science, Universidade Nova de Lisboa
	2825 Monte Caparica, Portugal