printing output on SIGINT

This commit is contained in:
Ruslan Kuchumov 2014-09-08 09:02:10 +00:00
parent 4635329a5b
commit faa879801e
4 changed files with 32 additions and 1 deletions

View File

@ -7,6 +7,7 @@ License: GPL 2.0
#include "configuration.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#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();

View File

@ -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);

View File

@ -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:

View File

@ -1,3 +1,4 @@
#include <signal.h>
#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;
}