dave@galaxia.Newport.RI.US (David H. Brierley) (02/20/89)
Here is a handy little patch to the sysinfo program. In version 2.0 Lenny introduced a new compile time option called CHGWIND which would cause the status line display to follow the currently active window. This is really handy if you use windy or any other windowing software. However, it can be a pain in the neck if you occasionaly bring up a window that wants to use the label lines for it's own purpose. What this patch does is to have the program check to see if it's ok to use the label lines before writing all over them. The program defines "ok to write" as either of the following two conditions: the label lines are blank or the label lines contain info written by the sysinfo program. This patch is kinda-sorta an official patch. I developed the patch, sent a copy of it to Lenny, he made a few changes and sent it back to me along with his blessing to go ahead and post it. --- cut here for Patch to sysinfo.c --- --- cut here for Patch to sysinfo.c --- *** sysinfo.orig Sun Feb 19 01:44:47 1989 --- sysinfo.c Sun Feb 19 01:44:46 1989 *************** *** 2,8 ** ** ** Program name: sysinfo.c (System Info) ** ** Programmer: Lenny Tropiano UUCP: ...icus!lenny ** ! ** Organization: ICUS Software Systems (c)1988 ** ** Date: January 23, 1988 ** ** Version 2.0: June 27, 1988 ** ** ** --- 2,8 ----- ** ** ** Program name: sysinfo.c (System Info) ** ** Programmer: Lenny Tropiano UUCP: ...icus!lenny ** ! ** Organization: ICUS Software Systems (c)1988, 1989 ** ** Date: January 23, 1988 ** ** Version 2.0: June 27, 1988 ** ** Version 2.1: Februrary 19, 1989 (Revision Level 4) ** *************** *** 5,10 ** Organization: ICUS Software Systems (c)1988 ** ** Date: January 23, 1988 ** ** Version 2.0: June 27, 1988 ** ** ** ** Revision Level: 1 [Updated to switch to current window] ** ** Revision Level: 2 [Updated to show load average in the window] ** --- 5,11 ----- ** Organization: ICUS Software Systems (c)1988, 1989 ** ** Date: January 23, 1988 ** ** Version 2.0: June 27, 1988 ** + ** Version 2.1: Februrary 19, 1989 (Revision Level 4) ** ** ** ** Revision Level: 1 [Updated to switch to current window] ** ** Revision Level: 2 [Updated to show load average in the window] ** *************** *** 9,15 ** Revision Level: 1 [Updated to switch to current window] ** ** Revision Level: 2 [Updated to show load average in the window] ** ** Revision Level: 3 [Updated to available main memory in the window] ** ! ** Revision Level: 4 [Updated to available main memory in the window] ** ** ** ************************************************************************** ** ** --- 10,21 ----- ** Revision Level: 1 [Updated to switch to current window] ** ** Revision Level: 2 [Updated to show load average in the window] ** ** Revision Level: 3 [Updated to available main memory in the window] ** ! ** Revision Level: 4 [Updated by David H. Brierley to check the the ** ! ** current status of the SLK lines for existing ** ! ** information and not display the sysinfo lines ** ! ** over those SLK's if in CHGWIND #define'd, good ** ! ** for use with the UA and Telephone Manager F-key ** ! ** SLK definitions] -- dave@galaxia.Newport.RI.US ** ** ** ************************************************************************** ** ** *************** *** 56,61 { NULL } }; #define UNIX "/unix" #define KMEM "/dev/kmem" #define MINUTE 60L --- 62,70 ----- { NULL } }; + static char *LINE_1 = "%-20.20s %-25.25s up %2d day%1.1s %2d hour%1.1s %2d minute%1.1s"; + static char *LINE_2 = "Filesystem: %6ld free %6ld total %2d%% available %5d i-nodes %4.2fMB memory"; + #define UNIX "/unix" #define KMEM "/dev/kmem" #define MINUTE 60L *************** *** 65,72 #define NICE 5 /* Niceness value */ #define MEGABYTE 1048576.0 - #define LINE_1 "%-20.20s %-25.25s up %2d day%1.1s %2d hour%1.1s %2d minute%1.1s" - #define LINE_2 "Filesystem: %6ld free %6ld total %2d%% available %5d i-nodes %4.2fMB memory" #define FILESYS "/dev/rfp002" #ifndef TRUE #define TRUE 1 --- 74,79 ----- #define NICE 5 /* Niceness value */ #define MEGABYTE 1048576.0 #define FILESYS "/dev/rfp002" #ifndef TRUE #define TRUE 1 *************** *** 159,168 open_current_window(); #endif ! filestatus(); ! uptime(); ! mailcheck(mailbuffer); ! loadaverage(loadbuf); utd.ut_num = WTXTSLK1; sprintf(utd.ut_text,LINE_1, --- 166,176 ----- open_current_window(); #endif ! if (slktest(wd) == 0) { ! filestatus(); ! uptime(); ! mailcheck(mailbuffer); ! loadaverage(loadbuf); utd.ut_num = WTXTSLK1; sprintf(utd.ut_text,LINE_1, *************** *** 164,177 mailcheck(mailbuffer); loadaverage(loadbuf); ! utd.ut_num = WTXTSLK1; ! sprintf(utd.ut_text,LINE_1, ! mailbuffer, loadbuf, ! days,(days == 1) ? " " : "s", ! hrs, (hrs == 1) ? " " : "s", ! mins,(mins == 1) ? " " : "s" ! ); ! ioctl(wd, WIOCSETTEXT, &utd); utd.ut_num = WTXTSLK2; freemem = memory() / MEGABYTE; --- 172,185 ----- mailcheck(mailbuffer); loadaverage(loadbuf); ! utd.ut_num = WTXTSLK1; ! sprintf(utd.ut_text,LINE_1, ! mailbuffer, loadbuf, ! days,(days == 1) ? " " : "s", ! hrs, (hrs == 1) ? " " : "s", ! mins,(mins == 1) ? " " : "s" ! ); ! ioctl(wd, WIOCSETTEXT, &utd); utd.ut_num = WTXTSLK2; freemem = memory() / MEGABYTE; *************** *** 173,186 ); ioctl(wd, WIOCSETTEXT, &utd); ! utd.ut_num = WTXTSLK2; ! freemem = memory() / MEGABYTE; ! sprintf(utd.ut_text,LINE_2, ! fs.s_tfree * 2, fs.s_fsize * 2, ! (int)((((float)fs.s_tfree / (float)fs.s_fsize) + 0.005) ! * 100.0), fs.s_tinode, freemem ! ); ! ioctl(wd, WIOCSETTEXT, &utd); #ifdef CHGWIND close(wd); #endif --- 181,195 ----- ); ioctl(wd, WIOCSETTEXT, &utd); ! utd.ut_num = WTXTSLK2; ! freemem = memory() / MEGABYTE; ! sprintf(utd.ut_text,LINE_2, ! fs.s_tfree * 2, fs.s_fsize * 2, ! (int)((((float)fs.s_tfree / (float)fs.s_fsize) + 0.005) ! * 100.0), fs.s_tinode, freemem ! ); ! ioctl(wd, WIOCSETTEXT, &utd); ! } #ifdef CHGWIND close(wd); #endif *************** *** 329,331 return(ctob(mem)); } --- 338,393 ----- return(ctob(mem)); } + slktest (wd) + int wd; + { + /* + * check the SLK lines for the existence of anything currently there + * if found two blank SLK lines or some remaining sysinfo information, + * denoted by "Filesystem" in the second line, then return 0, else + * return -1 + * Developed by David H. Brierley (dave@galaxia.Newport.RI.US) + */ + + int rvalue; + int n; + + rvalue = 0; + utd.ut_num = WTXTSLK1; + ioctl (wd, WIOCGETTEXT, &utd); + if (utd.ut_text[0] == '\0') + ++rvalue; + else + for (n = 0; n < WTXTLEN; ++n) + if ((utd.ut_text[n] != '\0') && + (utd.ut_text[n] != ' ')) + break; + + if (n == WTXTLEN) + ++rvalue; + + utd.ut_num = WTXTSLK2; + ioctl (wd, WIOCGETTEXT, &utd); + if (utd.ut_text[0] == '\0') + ++rvalue; + else + for (n = 0; n < WTXTLEN; ++n) + if ((utd.ut_text[n] != '\0') && + (utd.ut_text[n] != ' ')) + break; + + if (n == WTXTLEN) + ++rvalue; + + if (rvalue == 2) /* two blank lines */ + return (0); + + /* found the beginning of LINE_2 */ + + if (strncmp (utd.ut_text, LINE_2, 12) == 0) + return (0); + + /* not blank, return -1 */ + return (-1); + + } -- David H. Brierley Home: dave@galaxia.Newport.RI.US {rayssd,xanth,lazlo,jclyde}!galaxia!dave Work: dhb@rayssd.ray.com {sun,decuac,gatech,necntc,ukma}!rayssd!dhb