ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/saidar/saidar.c
(Generate patch)

Comparing projects/libstatgrab/src/saidar/saidar.c (file contents):
Revision 1.37 by tdb, Fri Dec 1 00:38:39 2006 UTC vs.
Revision 1.42 by tdb, Sun Oct 3 18:35:58 2010 UTC

# Line 29 | Line 29
29   #include <sys/ioctl.h>
30   #include <unistd.h>
31   #include <stdlib.h>
32 #include <sys/termios.h>
32   #include <signal.h>
33   #include <errno.h>
34   #include <statgrab.h>
# Line 37 | Line 36
36   #include <limits.h>
37   #include <time.h>
38   #include <math.h>
39 + #ifdef AIX
40 + #include <termios.h>
41 + #else
42 + #include <sys/termios.h>
43 + #endif
44  
45   #ifdef HAVE_NCURSES_H
46 < #include <ncurses.h>
43 < #else
44 < #include <curses.h>
46 > #define COLOR_SUPPORT
47   #endif
48 + #include CURSES_HEADER_FILE
49  
50   #define THRESHOLD_LOAD 1.0
51  
# Line 60 | Line 63
63   #define THRESHOLD_WARN_DISK 75.0
64   #define THRESHOLD_ALERT_DISK 90.0
65  
66 + int sig_winch_flag = 0;
67 +
68   typedef struct{
69          sg_cpu_percents *cpu_percents;
70          sg_mem_stats *mem_stats;
# Line 533 | Line 538 | void display_data(int colors){
538   }
539  
540   void sig_winch_handler(int dummy){
541 <        clear();
537 <        display_headings();
538 <        display_data(0);
541 >        sig_winch_flag = 1;
542          signal(SIGWINCH, sig_winch_handler);
543   }
544  
# Line 562 | Line 565 | void version_num(char *progname){
565   }
566  
567   void usage(char *progname){
568 + #ifdef COLOR_SUPPORT
569          fprintf(stderr, "Usage: %s [-d delay] [-c] [-v] [-h]\n\n", progname);
570 + #else
571 +        fprintf(stderr, "Usage: %s [-d delay] [-v] [-h]\n\n", progname);
572 + #endif
573          fprintf(stderr, "  -d    Sets the update time in seconds\n");
574 + #ifdef COLOR_SUPPORT
575          fprintf(stderr, "  -c    Enables coloured output\n");
576 + #endif
577          fprintf(stderr, "  -v    Prints version number\n");
578          fprintf(stderr, "  -h    Displays this help information.\n");
579          fprintf(stderr, "\nReport bugs to <%s>.\n", PACKAGE_BUGREPORT);
# Line 590 | Line 599 | int main(int argc, char **argv){
599                  return 1;
600          }
601  
602 + #ifdef COLOR_SUPPORT
603          while ((c = getopt(argc, argv, "d:cvh")) != -1){
604 + #else
605 +        while ((c = getopt(argc, argv, "d:vh")) != -1){
606 + #endif
607                  switch (c){
608                          case 'd':
609                                  delay = atoi(optarg);
# Line 599 | Line 612 | int main(int argc, char **argv){
612                                          exit(1);
613                                  }
614                                  break;
615 + #ifdef COLOR_SUPPORT
616                          case 'c':
617                                  colouron = 1;
618                                  break;
619 + #endif
620                          case 'v':
621                                  version_num(argv[0]);
622                                  break;
# Line 615 | Line 630 | int main(int argc, char **argv){
630  
631          signal(SIGWINCH, sig_winch_handler);
632          initscr();
633 + #ifdef COLOR_SUPPORT
634          /* turn on colour */
635          if (colouron) {
636                  if (has_colors()) {
# Line 631 | Line 647 | int main(int argc, char **argv){
647                          colouron = 0;
648                  }
649          }
650 + #endif
651          nonl();
652 +        curs_set(0);
653          cbreak();
654          noecho();
655          timeout(delay * 1000);
# Line 662 | Line 680 | int main(int argc, char **argv){
680                          get_stats();
681                  }
682                  last_update = now;
683 +
684 +                if(sig_winch_flag) {
685 +                        clear();
686 +                        display_headings();
687 +                        sig_winch_flag = 0;
688 +                }
689  
690                  display_data(colouron);
691          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines