--- projects/libstatgrab/src/saidar/saidar.c 2006/11/30 23:42:43 1.36 +++ projects/libstatgrab/src/saidar/saidar.c 2006/12/17 01:06:16 1.40 @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Id: saidar.c,v 1.36 2006/11/30 23:42:43 tdb Exp $ + * $Id: saidar.c,v 1.40 2006/12/17 01:06:16 tdb Exp $ */ #ifdef HAVE_CONFIG_H @@ -39,10 +39,9 @@ #include #ifdef HAVE_NCURSES_H -#include -#else -#include +#define COLOR_SUPPORT #endif +#include CURSES_HEADER_FILE #define THRESHOLD_LOAD 1.0 @@ -310,6 +309,7 @@ void display_data(int colors){ move(4,33); if (colors && stats.cpu_percents->user + stats.cpu_percents->nice > THRESHOLD_ALERT_CPU) { attron(A_STANDOUT); + attron(A_BOLD); } else if (colors && stats.cpu_percents->user + stats.cpu_percents->nice > THRESHOLD_WARN_CPU) { attron(A_BOLD); @@ -329,11 +329,12 @@ void display_data(int colors){ move(2,74); if (colors && stats.process_count->zombie > THRESHOLD_WARN_ZMB) { attron(A_STANDOUT); + attron(A_BOLD); } printw("%5d", stats.process_count->zombie); if(colors) { attroff(A_STANDOUT); - attron(COLOR_PAIR(6)); + attroff(A_BOLD); } move(3, 54); printw("%5d", stats.process_count->sleeping); @@ -376,6 +377,7 @@ void display_data(int colors){ float f = 100.00 * (float)(stats.mem_stats->used)/stats.mem_stats->total; if (colors && f > THRESHOLD_ALERT_MEM) { attron(A_STANDOUT); + attron(A_BOLD); } else if (colors && f > THRESHOLD_WARN_MEM) { attron(A_BOLD); @@ -392,6 +394,7 @@ void display_data(int colors){ float f = 100.00 * (float)(stats.swap_stats->used)/stats.swap_stats->total; if (colors && f > THRESHOLD_ALERT_SWAP) { attron(A_STANDOUT); + attron(A_BOLD); } else if (colors && f > THRESHOLD_WARN_SWAP) { attron(A_BOLD); @@ -510,6 +513,7 @@ void display_data(int colors){ move(line, 73); if(colors && 100.00 * ((float) disk_stat_ptr->used / (float) (disk_stat_ptr->used + disk_stat_ptr->avail)) > THRESHOLD_ALERT_DISK) { attron(A_STANDOUT); + attron(A_BOLD); } else if (colors && 100.00 * ((float) disk_stat_ptr->used / (float) (disk_stat_ptr->used + disk_stat_ptr->avail)) > THRESHOLD_WARN_DISK) { attron(A_BOLD); } @@ -557,9 +561,15 @@ void version_num(char *progname){ } void usage(char *progname){ +#ifdef COLOR_SUPPORT fprintf(stderr, "Usage: %s [-d delay] [-c] [-v] [-h]\n\n", progname); +#else + fprintf(stderr, "Usage: %s [-d delay] [-v] [-h]\n\n", progname); +#endif fprintf(stderr, " -d Sets the update time in seconds\n"); +#ifdef COLOR_SUPPORT fprintf(stderr, " -c Enables coloured output\n"); +#endif fprintf(stderr, " -v Prints version number\n"); fprintf(stderr, " -h Displays this help information.\n"); fprintf(stderr, "\nReport bugs to <%s>.\n", PACKAGE_BUGREPORT); @@ -585,7 +595,11 @@ int main(int argc, char **argv){ return 1; } +#ifdef COLOR_SUPPORT while ((c = getopt(argc, argv, "d:cvh")) != -1){ +#else + while ((c = getopt(argc, argv, "d:vh")) != -1){ +#endif switch (c){ case 'd': delay = atoi(optarg); @@ -594,9 +608,11 @@ int main(int argc, char **argv){ exit(1); } break; +#ifdef COLOR_SUPPORT case 'c': colouron = 1; break; +#endif case 'v': version_num(argv[0]); break; @@ -610,6 +626,7 @@ int main(int argc, char **argv){ signal(SIGWINCH, sig_winch_handler); initscr(); +#ifdef COLOR_SUPPORT /* turn on colour */ if (colouron) { if (has_colors()) { @@ -626,7 +643,9 @@ int main(int argc, char **argv){ colouron = 0; } } +#endif nonl(); + curs_set(0); cbreak(); noecho(); timeout(delay * 1000);