mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2024-12-24 11:53:25 +00:00
printing output on SIGINT
This commit is contained in:
parent
4635329a5b
commit
faa879801e
@ -7,6 +7,7 @@ License: GPL 2.0
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <signal.h>
|
||||||
#include "ffmpeg_intgr.h"
|
#include "ffmpeg_intgr.h"
|
||||||
|
|
||||||
void xds_cea608_test();
|
void xds_cea608_test();
|
||||||
@ -200,6 +201,13 @@ int main_telxcc (int argc, char *argv[]);
|
|||||||
#endif
|
#endif
|
||||||
LLONG process_raw_with_field (void);
|
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[])
|
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");
|
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)
|
while (switch_to_next_file(0) && !processed_enough)
|
||||||
{
|
{
|
||||||
prepare_for_new_file();
|
prepare_for_new_file();
|
||||||
|
@ -317,6 +317,7 @@ int hex2int (char high, char low);
|
|||||||
void timestamp_to_srttime(uint64_t timestamp, char *buffer);
|
void timestamp_to_srttime(uint64_t timestamp, char *buffer);
|
||||||
void millis_to_date (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);
|
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);
|
unsigned encode_line (unsigned char *buffer, unsigned char *text);
|
||||||
|
@ -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")
|
#define Y_N(cond) ((cond) ? "Yes" : "No")
|
||||||
|
|
||||||
@ -212,6 +212,12 @@ void print_file_report(void)
|
|||||||
switch (ccx_options.input_source)
|
switch (ccx_options.input_source)
|
||||||
{
|
{
|
||||||
case CCX_DS_FILE:
|
case CCX_DS_FILE:
|
||||||
|
if (current_file < 0)
|
||||||
|
{
|
||||||
|
printf("file is not openened yet\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
printf("%s\n", inputfile[current_file]);
|
printf("%s\n", inputfile[current_file]);
|
||||||
break;
|
break;
|
||||||
case CCX_DS_STDIN:
|
case CCX_DS_STDIN:
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <signal.h>
|
||||||
#include "ccextractor.h"
|
#include "ccextractor.h"
|
||||||
|
|
||||||
static char *text;
|
static char *text;
|
||||||
@ -244,3 +245,16 @@ int hex2int (char high, char low)
|
|||||||
return -1;
|
return -1;
|
||||||
return h*16+l;
|
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;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user