mirror of https://github.com/lindes/ttyload.git
basically, added support for screen-size auto-detect; also added some
unit testing code, etc. Also, Revisiting the height calculations is probably in order... hopefully I'll do that one of these days.
This commit is contained in:
parent
9dc70b48a1
commit
67ca8c70ac
9
Makefile
9
Makefile
|
@ -9,7 +9,9 @@ INSTALLDIR = /usr/local/bin
|
|||
ARCH = `uname -s`
|
||||
LDFLAGS = `./ldflags`
|
||||
|
||||
OBJS = arch/${ARCH}/getload.o arch/default/homebrews.o
|
||||
OBJS = arch/${ARCH}/getload.o \
|
||||
arch/${ARCH}/terminfo.o \
|
||||
arch/default/homebrews.o
|
||||
|
||||
# this is what I use most places...
|
||||
CC=gcc -pedantic -Wall
|
||||
|
@ -36,7 +38,7 @@ test: archbuild
|
|||
./ttyload -i 1
|
||||
|
||||
archbuild:
|
||||
make ttyload ARCH=`uname -s`
|
||||
make ttyload archtest ARCH=`uname -s`
|
||||
|
||||
ttyload.c: ttyload.h Version
|
||||
touch ttyload.c
|
||||
|
@ -45,6 +47,9 @@ ttyload.c: ttyload.h Version
|
|||
ttyload: $(OBJS) ttyload.o
|
||||
$(CC) $(LDFLAGS) -o $@ $(OBJS) ttyload.o
|
||||
|
||||
archtest: $(OBJS) archtest.o
|
||||
$(CC) $(LDFLAGS) -o $@ $(OBJS) archtest.o
|
||||
|
||||
clean:
|
||||
rm -f *.o $(OBJS) core a.out
|
||||
|
||||
|
|
1
TODO
1
TODO
|
@ -2,3 +2,4 @@ Lots of stuff todo... here are a few big items:
|
|||
|
||||
- convert to using curses (or similar, perhaps)
|
||||
- make the clock stamps cleaner when using large -i values
|
||||
- write a man page
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* archtest.c -- simple harness to the arch-specific stuff, so
|
||||
* that we can test those things in relative isolation.
|
||||
*/
|
||||
|
||||
#include "ttyload.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int rows = -1, cols = -1;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
load_list loads;
|
||||
|
||||
gettermsize();
|
||||
printf("termsize: %d rows, %d cols\n", rows, cols);
|
||||
|
||||
getload(&loads);
|
||||
|
||||
printf("Load averages %g, %g, %g\n",
|
||||
(loads.one_minute / 1024.0),
|
||||
(loads.five_minute / 1024.0),
|
||||
(loads.fifteen_minute / 1024.0));
|
||||
|
||||
return(0);
|
||||
}
|
12
ttyload.c
12
ttyload.c
|
@ -6,7 +6,7 @@
|
|||
* Copyright 1996 by David Lindes
|
||||
* all right reserved.
|
||||
*
|
||||
* Version information: $Id: ttyload.c,v 1.20 2001-08-25 06:53:32 lindes Exp $
|
||||
* Version information: $Id: ttyload.c,v 1.21 2001-08-28 01:00:31 lindes Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -23,7 +23,8 @@
|
|||
|
||||
#include "ttyload.h"
|
||||
|
||||
#define HEIGHTPAD 9
|
||||
#define HEIGHTPAD 7 /* 2 lines above;
|
||||
* 4 lines + cursor line below */
|
||||
#define WIDTHPAD 14
|
||||
#define CLOCKWIDTH 7
|
||||
#define HOSTLENGTH 30
|
||||
|
@ -32,7 +33,7 @@
|
|||
#define MINROWS (HEIGHTPAD + 6)
|
||||
#define MINCOLS (WIDTHPAD + 6)
|
||||
|
||||
char *c="$Id: ttyload.c,v 1.20 2001-08-25 06:53:32 lindes Exp $";
|
||||
char *c="$Id: ttyload.c,v 1.21 2001-08-28 01:00:31 lindes Exp $";
|
||||
|
||||
char strbuf[BUFSIZ],
|
||||
*optstring = "i:hvmr:c:",
|
||||
|
@ -87,7 +88,6 @@ int rows = 40,
|
|||
height, width;
|
||||
|
||||
|
||||
void getload(load_list *);
|
||||
int compute_height(load_t, load_t, int);
|
||||
void showloads(load_list *);
|
||||
void clear_screen();
|
||||
|
@ -114,6 +114,8 @@ int main(argc, argv, envp)
|
|||
else
|
||||
basename++; /* go past the '/' */
|
||||
|
||||
gettermsize(); /* sets our globals: rows, cols */
|
||||
|
||||
while((c = getopt(argc, argv, optstring)) != EOF)
|
||||
{
|
||||
switch(c)
|
||||
|
@ -422,7 +424,7 @@ void showloads(loadavgs)
|
|||
}
|
||||
}
|
||||
|
||||
for(j=0;j<=height;j++)
|
||||
for(j = 0; j <= height; j++)
|
||||
{
|
||||
printf("%6.2f ",
|
||||
(((omax)*(height-j)) / (height))
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define TTYLOAD_H_IDENT "$Id: ttyload.h,v 1.5 2001-08-24 07:25:16 lindes Exp $";
|
||||
#define TTYLOAD_H_IDENT "$Id: ttyload.h,v 1.6 2001-08-28 01:00:31 lindes Exp $";
|
||||
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
|
@ -33,3 +33,7 @@ typedef struct clock_info {
|
|||
int pos;
|
||||
char clock[6];
|
||||
} clock_info;
|
||||
|
||||
/* functions in arch-specific files: */
|
||||
extern void getload(load_list *);
|
||||
extern void gettermsize();
|
||||
|
|
Loading…
Reference in New Issue