void doControlThread(TMANAGER *m, tid_t id, TCTRL *ctrl, void *p) { control_data_t *status = p; while(TMANAGER_running(m)) { TCTRL_check(ctrl); switch(readTerminal()) { case 'q': case 'Q': TMANAGER_shutdown(m); return; case '1': TMANAGER_toggle(m, status->p1); break; case '2': TMANAGER_toggle(m, status->p2); break; case 'c': case 'C': TMANAGER_toggle(m, status->c); break; } updateStatus(m, status->p1, status->p2, status->c); } }
int main(int argc, char ** argv) { FILE * f; if( argc == 1 ) { if( !feof(stdin) ) readTerminal(); else return EXIT_FAILURE; } else if( argc > 1 ) { for( int i=1; i < argc; i++ ) { f = fopen(argv[i],"r"); if( f == NULL ) { perror("Could not open file"); free(f); return EXIT_FAILURE; } else { readFile(f); } } } if (fclose(f) != 0) { perror("Failed to close the input file!"); return EXIT_FAILURE; } return EXIT_SUCCESS; }