--- projects/libstatgrab/src/saidar/saidar.c 2006/12/01 00:38:39 1.37 +++ projects/libstatgrab/src/saidar/saidar.c 2010/10/03 18:35:58 1.42 @@ -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.37 2006/12/01 00:38:39 tdb Exp $ + * $Id: saidar.c,v 1.42 2010/10/03 18:35:58 tdb Exp $ */ #ifdef HAVE_CONFIG_H @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -37,12 +36,16 @@ #include #include #include +#ifdef AIX +#include +#else +#include +#endif #ifdef HAVE_NCURSES_H -#include -#else -#include +#define COLOR_SUPPORT #endif +#include CURSES_HEADER_FILE #define THRESHOLD_LOAD 1.0 @@ -60,6 +63,8 @@ #define THRESHOLD_WARN_DISK 75.0 #define THRESHOLD_ALERT_DISK 90.0 +int sig_winch_flag = 0; + typedef struct{ sg_cpu_percents *cpu_percents; sg_mem_stats *mem_stats; @@ -533,9 +538,7 @@ void display_data(int colors){ } void sig_winch_handler(int dummy){ - clear(); - display_headings(); - display_data(0); + sig_winch_flag = 1; signal(SIGWINCH, sig_winch_handler); } @@ -562,9 +565,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); @@ -590,7 +599,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); @@ -599,9 +612,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; @@ -615,6 +630,7 @@ int main(int argc, char **argv){ signal(SIGWINCH, sig_winch_handler); initscr(); +#ifdef COLOR_SUPPORT /* turn on colour */ if (colouron) { if (has_colors()) { @@ -631,7 +647,9 @@ int main(int argc, char **argv){ colouron = 0; } } +#endif nonl(); + curs_set(0); cbreak(); noecho(); timeout(delay * 1000); @@ -662,6 +680,12 @@ int main(int argc, char **argv){ get_stats(); } last_update = now; + + if(sig_winch_flag) { + clear(); + display_headings(); + sig_winch_flag = 0; + } display_data(colouron); }