diff --git a/src/ccextractor.c b/src/ccextractor.c index 526f00f5..5f051abc 100644 --- a/src/ccextractor.c +++ b/src/ccextractor.c @@ -7,6 +7,7 @@ License: GPL 2.0 #include "configuration.h" #include #include +#include #include "ffmpeg_intgr.h" void xds_cea608_test(); @@ -200,6 +201,13 @@ int main_telxcc (int argc, char *argv[]); #endif LLONG process_raw_with_field (void); +void sigint_handler() +{ + if (ccx_options.print_file_reports) + print_file_report(); + + exit(EXIT_SUCCESS); +} int main(int argc, char *argv[]) @@ -588,6 +596,8 @@ int main(int argc, char *argv[]) fatal (EXIT_UNABLE_TO_DETERMINE_FILE_SIZE, "Failed to determine total file size.\n"); } + m_signal(SIGINT, sigint_handler); + while (switch_to_next_file(0) && !processed_enough) { prepare_for_new_file(); diff --git a/src/ccextractor.h b/src/ccextractor.h index 1a559087..d6447ecb 100644 --- a/src/ccextractor.h +++ b/src/ccextractor.h @@ -317,6 +317,7 @@ int hex2int (char high, char low); void timestamp_to_srttime(uint64_t timestamp, char *buffer); void millis_to_date (uint64_t timestamp, char *buffer) ; int levenshtein_dist (const uint64_t *s1, const uint64_t *s2, unsigned s1len, unsigned s2len); +void m_signal(int sig, void (*func)(int)); unsigned encode_line (unsigned char *buffer, unsigned char *text); diff --git a/src/params_dump.c b/src/params_dump.c index d459b7a5..bcaae12b 100644 --- a/src/params_dump.c +++ b/src/params_dump.c @@ -204,7 +204,7 @@ void params_dump(void) } -void print_file_report(void) +void print_file_report(void) { #define Y_N(cond) ((cond) ? "Yes" : "No") @@ -212,6 +212,12 @@ void print_file_report(void) switch (ccx_options.input_source) { case CCX_DS_FILE: + if (current_file < 0) + { + printf("file is not openened yet\n"); + return; + } + printf("%s\n", inputfile[current_file]); break; case CCX_DS_STDIN: diff --git a/src/utility.c b/src/utility.c index e5934d56..2a35d789 100644 --- a/src/utility.c +++ b/src/utility.c @@ -1,3 +1,4 @@ +#include #include "ccextractor.h" static char *text; @@ -244,3 +245,16 @@ int hex2int (char high, char low) return -1; return h*16+l; } + +void m_signal(int sig, void (*func)(int)) +{ + struct sigaction act; + act.sa_handler = func; + sigemptyset(&act.sa_mask); + act.sa_flags = 0; + + if (sigaction(sig, &act, NULL)) + perror("sigaction() error"); + + return; +}