More formatting updates. Reduced whitespace, looks even better.

This commit is contained in:
William Ferrell
2000-03-30 20:43:33 +00:00
parent a98c8109a8
commit ddfd41f53e
78 changed files with 0 additions and 590 deletions
-10
View File
@@ -13,7 +13,6 @@
int batt_fd = 0;
static int get_batt_stat (int *acstat, int *battstat, int *battflag, int *percent);
static int
@@ -39,8 +38,6 @@ get_batt_stat (int *acstat, int *battstat, int *battflag, int *percent)
}
int
batt_init ()
{
@@ -64,7 +61,6 @@ batt_close ()
return 0;
}
////////////////////////////////////////////////////////////////////////
// Battery Screen shows apm battery status...
//
@@ -82,7 +78,6 @@ battery_screen (int rep, int display)
int acstat = 0, battstat = 0, battflag = 0, percent = 0;
if (first) {
first = 0;
@@ -107,7 +102,6 @@ battery_screen (int rep, int display)
get_batt_stat (&acstat, &battstat, &battflag, &percent);
if (percent >= 0)
sprintf (buffer, "%i%%", percent);
else
@@ -117,7 +111,6 @@ battery_screen (int rep, int display)
if (display)
sock_send_string (sock, tmp);
if (lcd_hgt >= 4) // 4-line version of the screen
{
sprintf (tmp, "widget_set B one 1 2 {");
@@ -139,8 +132,6 @@ battery_screen (int rep, int display)
if (display)
sock_send_string (sock, tmp);
sprintf (tmp, "widget_set B two 1 3 {");
if (battflag == 0xff) {
sprintf (tmp + strlen (tmp), "Battery Stat Unknown");
@@ -161,7 +152,6 @@ battery_screen (int rep, int display)
if (display)
sock_send_string (sock, tmp);
if (percent > 0) {
sprintf (tmp, "widget_set B gauge 2 4 %i\n", (percent * ((lcd_wid - 2) * lcd_cellwid) / 100));
if (display)
-1
View File
@@ -6,5 +6,4 @@ int batt_close ();
int battery_screen (int rep, int display);
#endif
-33
View File
@@ -20,7 +20,6 @@ static char sysname[SYS_NMLN];
static double get_uptime (double *up, double *idle);
static double
get_uptime (double *up, double *idle)
{
@@ -34,7 +33,6 @@ get_uptime (double *up, double *idle)
return uptime;
}
// A couple of tables for later use...
static char *days[] = {
"Sunday, ",
@@ -84,8 +82,6 @@ static char *shortmonths[] = {
"Dec",
};
int
chrono_init ()
{
@@ -113,14 +109,11 @@ chrono_init ()
free (unamebuf);
}
return 0;
}
int
chrono_close ()
{
@@ -132,8 +125,6 @@ chrono_close ()
return 0;
}
//////////////////////////////////////////////////////////////////////
// Time Screen displays current time and date, uptime, OS ver...
//
@@ -158,8 +149,6 @@ time_screen (int rep, int display)
int i = 0;
char colon;
if (first) {
first = 0;
@@ -178,17 +167,14 @@ time_screen (int rep, int display)
}
}
if (colons)
colon = ':';
else
colon = ' ';
time (&thetime);
rtime = localtime (&thetime);
if (TwentyFourHour) {
sprintf (hr, "%02d", rtime->tm_hour);
} else {
@@ -211,12 +197,9 @@ time_screen (int rep, int display)
sprintf (min, "%02d", rtime->tm_min);
sprintf (sec, "%02d", rtime->tm_sec);
strcpy (day, shortdays[rtime->tm_wday]);
strcpy (month, shortmonths[rtime->tm_mon]);
///////////////////// Write the title bar (os name and version)
if (lcd_hgt >= 4) {
@@ -225,13 +208,11 @@ time_screen (int rep, int display)
if (display)
sock_send_string (sock, tmp);
}
/////////////////////// Display the time...
if (lcd_hgt >= 4) {
get_uptime (&uptime, &idle);
idle = (idle * 100) / uptime;
if (TwentyFourHour)
sprintf (tmp, "%s%c%s%c%s %2i%% idle", hr, colon, min, colon, sec, (int) idle);
else
@@ -242,14 +223,11 @@ time_screen (int rep, int display)
if (display)
sock_send_string (sock, buffer);
sprintf (tmp, "%s %s %d, %d", day, month, rtime->tm_mday, (rtime->tm_year + 1900));
sprintf (buffer, "widget_set T two 3 3 {%s}\n", tmp);
if (display)
sock_send_string (sock, buffer);
/////////////////////// Display the uptime...
i = (int) uptime / 86400;
sprintf (day, "Up %d day%s,", i, (i != 1 ? "s" : ""));
@@ -269,7 +247,6 @@ time_screen (int rep, int display)
if (display)
sock_send_string (sock, buffer);
} else // 20x2 version of the screen
{
sprintf (tmp, "widget_set T one 1 2 {");
@@ -285,15 +262,11 @@ time_screen (int rep, int display)
sock_send_string (sock, tmp);
}
colons = colons ^ 1;
return 0;
} // End time_screen()
//////////////////////////////////////////////////////////////////////
// Clock Screen displays current time and date...
//
@@ -332,7 +305,6 @@ clock_screen (int rep, int display)
}
}
if (colons)
colon = ':';
else
@@ -365,7 +337,6 @@ clock_screen (int rep, int display)
}
strcpy (month, months[rtime->tm_mon]);
if (lcd_hgt >= 4) // 4-line version of the screen
{
sprintf (tmp, "widget_set O two 1 3 {");
@@ -377,7 +348,6 @@ clock_screen (int rep, int display)
if (display)
sock_send_string (sock, tmp);
sprintf (tmp, "widget_set O three 2 4 {");
sprintf (tmp + strlen (tmp), "%s %d, %d", month, rtime->tm_mday, (rtime->tm_year + 1900));
sprintf (tmp + strlen (tmp), "}\n");
@@ -401,8 +371,6 @@ clock_screen (int rep, int display)
return 0;
} // End clock_screen()
////////////////////////////////////////////////////////////////////
// Uptime Screen shows info about system uptime and OS version
//
@@ -469,7 +437,6 @@ uptime_screen (int rep, int display)
return 0;
} // End uptime_screen()
//////////////////////////////////////////////////////////////////////
// Big Clock Screen displays current time...
//
-15
View File
@@ -18,7 +18,6 @@ struct load {
int load_fd = 0;
static void get_load (struct load *result);
static void
get_load (struct load *result)
{
@@ -40,8 +39,6 @@ get_load (struct load *result)
last_load.idle = curr_load.idle;
}
int
cpu_init ()
{
@@ -63,7 +60,6 @@ cpu_close ()
return 0;
}
//////////////////////////////////////////////////////////////////////////
// CPU screen shows info about percentage of the CPU being used
//
@@ -78,7 +74,6 @@ cpu_screen (int rep, int display)
static float cpu[CPU_BUF_SIZE + 1][5]; // last buffer is scratch
struct load load;
if (first) {
first = 0;
@@ -148,7 +143,6 @@ cpu_screen (int rep, int display)
*/
}
// Average values for final result
for (i = 0; i < 5; i++) {
value = 0;
@@ -159,7 +153,6 @@ cpu_screen (int rep, int display)
cpu[CPU_BUF_SIZE][i] = value;
}
if (lcd_hgt >= 4) {
value = cpu[CPU_BUF_SIZE][4];
n = (int) (value * 70.0);
@@ -264,8 +257,6 @@ cpu_screen (int rep, int display)
return 0;
} // End cpu_screen()
//////////////////////////////////////////////////////////////////////////
// Cpu Graph Screen shows a quick-moving histogram of CPU use.
//
@@ -282,7 +273,6 @@ cpu_graph_screen (int rep, int display)
struct load load;
int status = 0;
if (first) {
first = 0;
sock_send_string (sock, "screen_add G\n");
@@ -314,7 +304,6 @@ cpu_graph_screen (int rep, int display)
// Read new data
cpu[CPU_BUF_SIZE - 1] = ((float) load.user + (float) load.system + (float) load.nice) / (float) load.total;
// Only clear on first display...
if (!rep) {
/*
@@ -323,7 +312,6 @@ cpu_graph_screen (int rep, int display)
cpu[i] = cpu[CPU_BUF_SIZE-1];
*/
}
// Average values for final result
value = 0;
for (j = 0; j < CPU_BUF_SIZE; j++) {
@@ -332,7 +320,6 @@ cpu_graph_screen (int rep, int display)
value /= (float) CPU_BUF_SIZE;
cpu[CPU_BUF_SIZE] = value;
maxload = 0;
for (i = 0; i < lcd_wid - 1; i++) {
cpu_past[i] = cpu_past[i + 1];
@@ -357,8 +344,6 @@ cpu_graph_screen (int rep, int display)
if (display)
sock_send_string (sock, tmp);
if (n > maxload)
maxload = n;
-2
View File
@@ -1,11 +1,9 @@
#ifndef CPU_H
#define CPU_H
int cpu_init ();
int cpu_close ();
int cpu_screen (int rep, int display);
int cpu_graph_screen (int rep, int display);
-3
View File
@@ -106,7 +106,6 @@ get_load (struct load *result, int *numcpus)
}
}
int
cpu_smp_init ()
{
@@ -128,7 +127,6 @@ cpu_smp_close ()
return 0;
}
//////////////////////////////////////////////////////////////////////////
// CPU screen shows info about percentage of the CPU being used
//
@@ -212,7 +210,6 @@ cpu_smp_screen (int rep, int display)
#endif
cpu[z][CPU_BUF_SIZE - 1][4] = (((float) load[z].user + (float) load[z].system + (float) load[z].nice) / (float) load[z].total) * 100.0;
// Average values for final result
for (i = 4; i < 5; i++) {
value = 0;
-2
View File
@@ -1,11 +1,9 @@
#ifndef CPU_SMP_H
#define CPU_SMP_H
int cpu_smp_init ();
int cpu_smp_close ();
int cpu_smp_screen (int rep, int display);
#endif
-11
View File
@@ -27,7 +27,6 @@
#include <sys/statfs.h>
#endif
#include "../../shared/sockets.h"
#include "main.h"
@@ -36,14 +35,11 @@
FILE *mtab_fd;
typedef struct mounts {
char dev[256], type[64], mpoint[256];
long bsize, blocks, bfree, files, ffree;
} mounts;
static int
get_fs (mounts fs[])
{
@@ -115,7 +111,6 @@ disk_close ()
return 0;
}
///////////////////////////////////////////////////////////////////////////
// Gives disk stats.
//
@@ -143,7 +138,6 @@ disk_screen (int rep, int display)
#define huge long long int
huge size;
if (first) {
first = 0;
@@ -163,7 +157,6 @@ disk_screen (int rep, int display)
sock_send_string (sock, "widget_set D err2 5 3 {Filesystems}\n");
}
// Grab disk stats on first display, and fill "table".
// Get rid of old, unmounted filesystems...
memset (table, 0, sizeof (struct disp) * 256);
@@ -210,14 +203,11 @@ disk_screen (int rep, int display)
}
}
if (!count) {
sock_send_string (sock, "widget_set D err1 1 2 {Error Retrieving}\n");
sock_send_string (sock, "widget_set D err2 1 3 {Filesystem Stats}\n");
return 0;
}
// Display stuff... (show for two seconds, then scroll once per
// second, then hold at the end for two seconds)
sprintf (buffer, "widget_set D f 1 2 %i %i %i %i v 12\n", lcd_wid, lcd_hgt, lcd_wid, count);
@@ -249,7 +239,6 @@ disk_screen (int rep, int display)
sock_send_string (sock, tmp);
}
num_disks = count;
#undef huge
-7
View File
@@ -24,7 +24,6 @@ get_loadavg (void)
return load;
}
int
load_init ()
{
@@ -45,7 +44,6 @@ load_close ()
return 0;
}
///////////////////////////////////////////////////////////////////////////
// Shows a display very similar to "xload"'s histogram.
//
@@ -59,7 +57,6 @@ xload_screen (int rep, int display)
float loadmax = 0, factor, x;
int status = 0;
if (first) // Only the first time this is ever called...
{
first = 0;
@@ -92,8 +89,6 @@ xload_screen (int rep, int display)
sock_send_string (sock, tmp);
}
for (n = 0; n < (lcd_wid - 2); n++)
loads[n] = loads[n + 1];
loads[lcd_wid - 2] = get_loadavg ();
@@ -110,7 +105,6 @@ xload_screen (int rep, int display)
//if(display) sock_send_string(sock, tmp);
sock_send_string (sock, tmp);
if (loadmax < 1.0)
factor = (float) (lcd_cellhgt) * ((lcd_hgt == 2) ? 2.0 : 3.0);
else
@@ -141,6 +135,5 @@ xload_screen (int rep, int display)
//if(display) sock_send_string(sock, tmp);
sock_send_string (sock, tmp);
return status;
} // End xload_screen()
-3
View File
@@ -8,12 +8,9 @@
#define LOAD_MIN 0.5
#endif
int load_init ();
int load_close ();
int xload_screen (int rep, int display);
#endif
-13
View File
@@ -18,10 +18,8 @@
#include "../../shared/sockets.h"
#include "../../shared/debug.h"
// TODO: Commenting... Everything!
int Quit = 0;
int sock;
@@ -33,7 +31,6 @@ int lcd_hgt;
int lcd_cellwid;
int lcd_cellhgt;
/*
Mode List:
See below... (default_sequence[])
@@ -47,7 +44,6 @@ void main_loop (mode * sequence);
// 1/8th second is a single time unit...
#define TIME_UNIT 125000
// Contains a list of modes to run
mode default_sequence[] = {
// which on off inv timer/visible
@@ -75,7 +71,6 @@ mode default_sequence[] = {
// TODO: Config file; not just command line
int
main (int argc, char **argv)
{
@@ -97,8 +92,6 @@ main (int argc, char **argv)
// and just in case, "kill -KILL" (which cannot be trapped; but oh well)
signal (SIGKILL, exit_program);
// Command line
memcpy (sequence, default_sequence, sizeof (default_sequence));
for (i = 1, j = 0; i < argc; i++) {
@@ -157,7 +150,6 @@ main (int argc, char **argv)
}
}
// Connect to the server...
usleep (500000); // wait for the server to start up
sock = sock_connect (server, port);
@@ -168,7 +160,6 @@ main (int argc, char **argv)
sock_send_string (sock, "hello\n");
usleep (500000); // wait for the server to say hi.
// We grab the real values below, from the "connect" line.
lcd_wid = 20;
lcd_hgt = 4;
@@ -186,7 +177,6 @@ main (int argc, char **argv)
return 0;
}
void
HelpScreen ()
{
@@ -203,7 +193,6 @@ HelpScreen ()
exit (0);
}
///////////////////////////////////////////////////////////////////
// Called upon TERM and INTR signals...
//
@@ -216,7 +205,6 @@ exit_program (int val)
exit (0);
}
///////////////////////////////////////////////////////////////////
// Main program loop...
//
@@ -230,7 +218,6 @@ main_loop (mode * sequence)
int argc, newtoken;
int len;
// Main loop
// Run whatever screen we want, then wait. Woo-hoo!
while (!Quit) {
-4
View File
@@ -11,7 +11,6 @@ extern int lcd_hgt;
extern int lcd_cellwid;
extern int lcd_cellhgt;
typedef struct mode {
char which; // Which screen is it?
int on_time; // How often to update while visible?
@@ -21,8 +20,6 @@ typedef struct mode {
int visible; // Can we be seen right now?
} mode;
#define BLINK_ON 0x10
#define BLINK_OFF 0x11
#define BACKLIGHT_OFF 0x20
@@ -30,7 +27,6 @@ typedef struct mode {
#define HOLD_SCREEN 0x30
#define CONTINUE 0x31
#define LCD_MAX_WIDTH 80
#define LCD_MAX_HEIGHT 80
-22
View File
@@ -38,7 +38,6 @@ get_mem_info (struct meminfo *result)
result[1].free = getentry ("SwapFree:", buffer);
}
int
mem_init ()
{
@@ -60,7 +59,6 @@ mem_close ()
return 0;
}
/////////////////////////////////////////////////////////////////////////
// Mem Screen displays info about memory and swap usage...
//
@@ -121,10 +119,8 @@ mem_screen (int rep, int display)
//sock_send_string(sock, "\n");
}
get_mem_info (mem);
// flip the title back and forth...
if (lcd_hgt >= 4) {
if (which_title & 4) {
@@ -134,7 +130,6 @@ mem_screen (int rep, int display)
sock_send_string (sock, "widget_set M title { MEM -==- SWAP}\n");
which_title = (which_title + 1) & 7;
// Total memory
sprintf (tmp, "widget_set M memtotl 1 2 {%6dk}\n", mem[0].total);
if (display)
@@ -155,7 +150,6 @@ mem_screen (int rep, int display)
if (display)
sock_send_string (sock, tmp);
// Free memory graph
n = (int) (35.0 - ((float) mem[0].free + (float) mem[0].buffers + (float) mem[0].cache)
/ (float) mem[0].total * 35.0);
@@ -179,7 +173,6 @@ mem_screen (int rep, int display)
if (display)
sock_send_string (sock, tmp);
// Free memory graph
value = ((float) mem[0].free + (float) mem[0].buffers + (float) mem[0].cache)
/ (float) mem[0].total;
@@ -217,16 +210,11 @@ mem_screen (int rep, int display)
if (display)
sock_send_string (sock, tmp);
}
return 0;
} // End mem_screen()
typedef struct proc_mem_info {
char name[16]; // Is this really long enough?
// Size isn't used any more...
@@ -235,7 +223,6 @@ typedef struct proc_mem_info {
int number;
} proc_mem_info;
static int
sort_procs (void *a, void *b)
{
@@ -252,7 +239,6 @@ sort_procs (void *a, void *b)
return (two->totl > one->totl);
}
int
mem_top_screen (int rep, int display)
{
@@ -271,7 +257,6 @@ mem_top_screen (int rep, int display)
const int
NameLineLen = strlen (NameLine), VmSizeLineLen = strlen (VmSizeLine), VmDataLineLen = strlen (VmDataLine), VmStkLineLen = strlen (VmStkLine), VmExeLineLen = strlen (VmExeLine), VmRSSLineLen = strlen (VmRSSLine);
int threshold = 400, unique;
int i;
proc_mem_info *p;
@@ -299,14 +284,12 @@ mem_top_screen (int rep, int display)
sock_send_string (sock, "widget_set S 1 1 1 Checking...\n");
}
procs = LL_new ();
if (!procs) {
fprintf (stderr, "mem_top_screen: Error allocating list\n");
return -1;
}
if ((proc = opendir ("/proc")) == NULL) {
fprintf (stderr, "mem_top_screen: unable to open /proc");
perror ("");
@@ -383,7 +366,6 @@ mem_top_screen (int rep, int display)
}
closedir (proc);
// Now, print some info...
LL_Rewind (procs);
LL_Sort (procs, sort_procs);
@@ -408,9 +390,6 @@ mem_top_screen (int rep, int display)
LL_Next (procs);
}
end: // Ack! I hate using labels!
// Now clean it all up...
LL_Rewind (procs);
@@ -423,7 +402,6 @@ mem_top_screen (int rep, int display)
} while (LL_Next (procs) == 0);
LL_Destroy (procs);
return 0;
} // End mem_top_screen()
-1
View File
@@ -7,5 +7,4 @@ int mem_close ();
int mem_screen (int rep, int display);
int mem_top_screen (int rep, int display);
#endif
-10
View File
@@ -29,7 +29,6 @@
#include "load.h"
#include "mem.h"
int ELLIPSIS = '-';
// TODO: Clean this up... Support multiple display sizes..
@@ -40,7 +39,6 @@ char host[16];
void reread (int f, char *errmsg);
int getentry (const char *tag, const char *bufptr);
int
mode_init (mode * sequence)
{
@@ -120,8 +118,6 @@ mode_init (mode * sequence)
}
}
return 0;
}
@@ -137,7 +133,6 @@ mode_close ()
cpu_smp_close ();
}
int
update_screen (mode * m, int display)
{
@@ -224,7 +219,6 @@ update_screen (mode * m, int display)
}
void
reread (int f, char *errmsg)
{
@@ -255,7 +249,6 @@ getentry (const char *tag, const char *bufptr)
return -1;
}
///////////////////////////////////////////////////////////////////////////
//////////////////////// Let the Modes Begin! /////////////////////////////
///////////////////////////////////////////////////////////////////////////
@@ -264,9 +257,6 @@ getentry (const char *tag, const char *bufptr)
char tmp[1024];
////////////////////////////////////////////////////////////////////////
// Credit Screen shows who wrote this...
//
-1
View File
@@ -23,7 +23,6 @@ int update_screen (mode * m, int display);
int credit_screen (int rep, int display);
// These are for the modescreens' use only..
void reread (int f, char *errmsg);
int getentry (const char *tag, const char *bufptr);