| 33 |  | #include <libxml/xmlmemory.h> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 34 |  | #include <libxml/parser.h> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 35 |  | #include "genmergesort.h" | 
 
 
 
 
 
 
 
 | 36 | + |  | 
 
 
 
 
 
 
 
 | 37 | + | #ifdef HAVE_NCURSES_H | 
 
 
 
 
 
 
 
 | 38 | + | #include <ncurses.h> | 
 
 
 
 
 
 
 
 | 39 | + | #else | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 40 |  | #include <curses.h> | 
 
 
 
 
 
 
 
 | 41 | + | #endif | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 42 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 43 |  | struct host_line_t{ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 44 |  | char *hostname; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 692 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 693 |  | int main(int argc, char **argv){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 694 |  | WINDOW *window; | 
 
 
 
 
 
 
 
 | 695 | + | fd_set infds; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 696 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 697 |  | FILE *control; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 698 |  | FILE *data; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 717 |  | display_config_t display_config; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 718 |  | char ch; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 719 |  |  | 
 
 
 
 
 
 
 
 | 720 | + | int data_fileno, stdin_fileno, biggest_fileno; | 
 
 
 
 
 
 
 
 | 721 | + |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 722 |  | sortby_ptr=NULL; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 723 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 724 |  | /* What to display defaults */ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 856 |  | echo(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 857 |  | window=newwin(0, 0, 0, 0); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 858 |  |  | 
 
 
 
 
 
 
 
 | 859 | + | stdin_fileno=fileno(stdin); | 
 
 
 
 
 
 
 
 | 860 | + | data_fileno=fileno(data); | 
 
 
 
 
 
 
 
 | 861 | + | biggest_fileno=(data_fileno>stdin_fileno) ? (data_fileno+1) : (stdin_fileno+1); | 
 
 
 
 
 
 
 
 | 862 | + |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 863 |  | for(;;){ | 
 
 
 
 
 
 
 
 
 
 
 | 864 | < | response=fpgetline(data); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 865 | < | if (response==NULL){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 866 | < | errf("Failed to read data (%m)"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 867 | < | exit(1); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 864 | > | FD_ZERO(&infds); | 
 
 
 
 
 | 865 | > | FD_SET(stdin_fileno, &infds); | 
 
 
 
 
 | 866 | > | FD_SET(data_fileno, &infds); | 
 
 
 
 
 | 867 | > | select(biggest_fileno, &infds, NULL, NULL, NULL); | 
 
 
 
 
 | 868 | > |  | 
 
 
 
 
 | 869 | > | if(FD_ISSET(stdin_fileno, &infds)){ | 
 
 
 
 
 | 870 | > |  | 
 
 
 
 
 | 871 | > | ch=getc(stdin); | 
 
 
 
 
 | 872 | > |  | 
 
 
 
 
 | 873 | > | if(ch=='q'){ | 
 
 
 
 
 | 874 | > | endwin(); | 
 
 
 
 
 | 875 | > | exit(0); | 
 
 
 
 
 | 876 | > | } | 
 
 
 
 
 
 
 
 
 
 
 | 877 |  | } | 
 
 
 
 
 
 
 
 | 878 | + | if(FD_ISSET(data_fileno, &infds)){ | 
 
 
 
 
 
 
 
 | 879 | + | response=fpgetline(data); | 
 
 
 
 
 
 
 
 | 880 | + | if (response==NULL){ | 
 
 
 
 
 
 
 
 | 881 | + | errf("Failed to read data (%m)"); | 
 
 
 
 
 
 
 
 | 882 | + | exit(1); | 
 
 
 
 
 
 
 
 | 883 | + | } | 
 
 
 
 
 
 
 
 | 884 | + | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 885 |  |  | 
 
 
 
 
 
 
 
 
 | 858 | – | /*              ch=getc(stdin); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 886 |  |  | 
 
 
 
 
 
 
 
 
 | 860 | – | if(ch=='q'){ | 
 
 
 
 
 
 
 
 
 | 861 | – | endwin(); | 
 
 
 
 
 
 
 
 
 | 862 | – | exit(0); | 
 
 
 
 
 
 
 
 
 | 863 | – | } | 
 
 
 
 
 
 
 
 
 | 864 | – | */ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 887 |  | num_hosts=parse_xml(response, &machine_data_list); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 888 |  | if(num_hosts==-1) continue; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 889 |  | machine_data_list=sort_machine_stats(machine_data_list, num_hosts, sortby_ptr); |