inline bool hash_commented_file_reader::read_to_next_valid_line() { if( file_is_open() ) { while( !(read_next_line()) && !finished_reading_flag ) { /* just keep reading in lines until either a valid line is found, * or we run out of file to read. when the loop is done, * finished_reading_flag is true if we didn't find a new valid * line, so we should return false, or it is false if we did, so we * should return true. */ } } return !finished_reading_flag; }
static int get_command (char *line, char *prompt, char *extension) { char *pos; char *c_status; int status; if (file_is_open()) { c_status = fgets (line, MAX_STRING, current_file->fp); if (c_status == NULL) status = NULL; else status = 1; /* get rid of newline character at end of line */ for (pos = line; *pos != '\0'; pos++) if (*pos == '\n') *pos = '\0'; /* if we are at EOF, get a line elsewhere */ if (status == NULL) { close_file(); status = get_command (line, prompt, extension); } else if (echo_on) printf ("%s>%s%s\n", prompt, extension, line); } else { printf ("%s%s", prompt, extension); c_status = gets (line); if (c_status == NULL) status = NULL; else status = 1; if (status == NULL) input_done = TRUE; } /* write command line to audit file if auditing */ if (audit_on && status) fprintf (audit_file, "%s\n", line); return (status); }