687 |
|
|
688 |
|
int main(int argc, char **argv){ |
689 |
|
WINDOW *window; |
690 |
+ |
fd_set infds; |
691 |
|
|
692 |
|
FILE *control; |
693 |
|
FILE *data; |
712 |
|
display_config_t display_config; |
713 |
|
char ch; |
714 |
|
|
715 |
+ |
int data_fileno, stdin_fileno, biggest_fileno; |
716 |
+ |
|
717 |
|
sortby_ptr=NULL; |
718 |
|
|
719 |
|
/* What to display defaults */ |
851 |
|
echo(); |
852 |
|
window=newwin(0, 0, 0, 0); |
853 |
|
|
854 |
+ |
stdin_fileno=fileno(stdin); |
855 |
+ |
data_fileno=fileno(data); |
856 |
+ |
biggest_fileno=(data_fileno>stdin_fileno) ? (data_fileno+1) : (stdin_fileno+1); |
857 |
+ |
|
858 |
|
for(;;){ |
859 |
< |
response=fpgetline(data); |
860 |
< |
if (response==NULL){ |
861 |
< |
errf("Failed to read data (%m)"); |
862 |
< |
exit(1); |
859 |
> |
FD_ZERO(&infds); |
860 |
> |
FD_SET(stdin_fileno, &infds); |
861 |
> |
FD_SET(data_fileno, &infds); |
862 |
> |
select(biggest_fileno, &infds, NULL, NULL, NULL); |
863 |
> |
|
864 |
> |
if(FD_ISSET(stdin_fileno, &infds)){ |
865 |
> |
|
866 |
> |
ch=getc(stdin); |
867 |
> |
|
868 |
> |
if(ch=='q'){ |
869 |
> |
endwin(); |
870 |
> |
exit(0); |
871 |
> |
} |
872 |
|
} |
873 |
+ |
if(FD_ISSET(data_fileno, &infds)){ |
874 |
+ |
response=fpgetline(data); |
875 |
+ |
if (response==NULL){ |
876 |
+ |
errf("Failed to read data (%m)"); |
877 |
+ |
exit(1); |
878 |
+ |
} |
879 |
+ |
} |
880 |
|
|
858 |
– |
/* ch=getc(stdin); |
881 |
|
|
860 |
– |
if(ch=='q'){ |
861 |
– |
endwin(); |
862 |
– |
exit(0); |
863 |
– |
} |
864 |
– |
*/ |
882 |
|
num_hosts=parse_xml(response, &machine_data_list); |
883 |
|
if(num_hosts==-1) continue; |
884 |
|
machine_data_list=sort_machine_stats(machine_data_list, num_hosts, sortby_ptr); |