Commit dad09ff9 authored by Anton Khirnov's avatar Anton Khirnov

cmdutils: move exit_program() declaration to cmdutils from avconv

Allows cmdutils to call each tool's own cleanup function.
parent 346ea9e2
......@@ -433,7 +433,7 @@ static int decode_interrupt_cb(void)
return received_nb_signals > 1;
}
static int exit_program(int ret)
void exit_program(int ret)
{
int i;
......@@ -483,7 +483,6 @@ static int exit_program(int ret)
}
exit(ret); /* not all OS-es handle main() return value */
return ret;
}
static void assert_avoptions(AVDictionary *m)
......@@ -4192,5 +4191,6 @@ int main(int argc, char **argv)
printf("bench: utime=%0.3fs maxrss=%ikB\n", ti / 1000000.0, maxrss);
}
return exit_program(0);
exit_program(0);
return 0;
}
......@@ -278,6 +278,11 @@ static AVPacket flush_pkt;
static SDL_Surface *screen;
void exit_program(int ret)
{
exit(ret);
}
static int packet_queue_put(PacketQueue *q, AVPacket *pkt);
/* packet queue handling */
......
......@@ -56,6 +56,11 @@ static const char *unit_hertz_str = "Hz" ;
static const char *unit_byte_str = "byte" ;
static const char *unit_bit_per_second_str = "bit/s";
void exit_program(int ret)
{
exit(ret);
}
static char *value_string(char *buf, int buf_size, double val, const char *unit)
{
if (unit == unit_second_str && use_value_sexagesimal_format) {
......
......@@ -320,6 +320,11 @@ static AVLFG random_state;
static FILE *logfile = NULL;
void exit_program(int ret)
{
exit(ret);
}
/* FIXME: make avserver work with IPv6 */
/* resolve host with also IP address parsing */
static int resolve_host(struct in_addr *sin_addr, const char *hostname)
......
......@@ -92,7 +92,8 @@ double parse_number_or_die(const char *context, const char *numstr, int type, do
else
return d;
fprintf(stderr, error, context, numstr, min, max);
exit(1);
exit_program(1);
return 0;
}
int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration)
......@@ -101,7 +102,7 @@ int64_t parse_time_or_die(const char *context, const char *timestr, int is_durat
if (av_parse_time(&us, timestr, is_duration) < 0) {
fprintf(stderr, "Invalid %s specification for %s: %s\n",
is_duration ? "duration" : "date", context, timestr);
exit(1);
exit_program(1);
}
return us;
}
......@@ -237,14 +238,14 @@ void parse_options(int argc, char **argv, const OptionDef *options,
if (!po->name) {
unknown_opt:
fprintf(stderr, "%s: unrecognized option '%s'\n", argv[0], opt);
exit(1);
exit_program(1);
}
arg = NULL;
if (po->flags & HAS_ARG) {
arg = argv[optindex++];
if (!arg) {
fprintf(stderr, "%s: missing argument for option '%s'\n", argv[0], opt);
exit(1);
exit_program(1);
}
}
if (po->flags & OPT_STRING) {
......@@ -262,11 +263,11 @@ unknown_opt:
} else if (po->u.func_arg) {
if (po->u.func_arg(opt, arg) < 0) {
fprintf(stderr, "%s: failed to set value '%s' for option '%s'\n", argv[0], arg, opt);
exit(1);
exit_program(1);
}
}
if(po->flags & OPT_EXIT)
exit(0);
exit_program(0);
} else {
if (parse_arg_function)
parse_arg_function(opt);
......@@ -336,7 +337,7 @@ int opt_loglevel(const char *opt, const char *arg)
"Possible levels are numbers or:\n", arg);
for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++)
fprintf(stderr, "\"%s\"\n", log_levels[i].name);
exit(1);
exit_program(1);
}
av_log_set_level(level);
return 0;
......
......@@ -327,4 +327,10 @@ extern AVFilter ffsink;
int get_filtered_video_frame(AVFilterContext *sink, AVFrame *frame,
AVFilterBufferRef **picref, AVRational *pts_tb);
/**
* Do all the necessary cleanup and abort.
* This function is implemented in the avtools, not cmdutils.
*/
void exit_program(int ret);
#endif /* LIBAV_CMDUTILS_H */
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment