Commit 1e47dafb authored by benoit's avatar benoit

Make ffserver use parse_options().

Patch by Stefano Sabatini stefano sabatini-lala poste it


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@13219 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent ce687bc1
...@@ -59,6 +59,8 @@ ...@@ -59,6 +59,8 @@
static const char program_name[] = "FFserver"; static const char program_name[] = "FFserver";
static const int program_birth_year = 2000; static const int program_birth_year = 2000;
static const OptionDef options[];
/* maximum number of simultaneous HTTP connections */ /* maximum number of simultaneous HTTP connections */
#define HTTP_MAX_CONNECTIONS 2000 #define HTTP_MAX_CONNECTIONS 2000
...@@ -288,6 +290,7 @@ static int rtp_new_av_stream(HTTPContext *c, ...@@ -288,6 +290,7 @@ static int rtp_new_av_stream(HTTPContext *c,
static const char *my_program_name; static const char *my_program_name;
static const char *my_program_dir; static const char *my_program_dir;
static const char *config_filename;
static int ffserver_debug; static int ffserver_debug;
static int ffserver_daemon; static int ffserver_daemon;
static int no_launch; static int no_launch;
...@@ -4303,17 +4306,6 @@ static int parse_ffconfig(const char *filename) ...@@ -4303,17 +4306,6 @@ static int parse_ffconfig(const char *filename)
return 0; return 0;
} }
static void show_help(void)
{
printf("usage: ffserver [-L] [-h] [-f configfile]\n"
"Hyper fast multi format Audio/Video streaming server\n"
"\n"
"-L show license\n"
"-h show help\n"
"-f configfile use configfile instead of /etc/ffserver.conf\n"
);
}
static void handle_child_exit(int sig) static void handle_child_exit(int sig)
{ {
pid_t pid; pid_t pid;
...@@ -4339,10 +4331,38 @@ static void handle_child_exit(int sig) ...@@ -4339,10 +4331,38 @@ static void handle_child_exit(int sig)
need_to_start_children = 1; need_to_start_children = 1;
} }
static void opt_show_license(void)
{
show_license();
exit(0);
}
static void opt_debug()
{
ffserver_debug = 1;
ffserver_daemon = 0;
}
static void opt_show_help(void)
{
printf("usage: ffserver [options]\n"
"Hyper fast multi format Audio/Video streaming server\n");
printf("\n");
show_help_options(options, "Main options:\n", 0, 0);
exit(0);
}
static const OptionDef options[] = {
{ "h", 0, {(void*)opt_show_help}, "show help" },
{ "L", 0, {(void*)opt_show_license}, "show license" },
{ "n", OPT_BOOL, {(void *)&no_launch }, "enable no-launch mode" },
{ "d", 0, {(void*)opt_debug}, "enable debug mode" },
{ "f", HAS_ARG | OPT_STRING, {(void*)&config_filename }, "use configfile instead of /etc/ffserver.conf", "configfile" },
{ NULL },
};
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
const char *config_filename;
int c;
struct sigaction sigact; struct sigaction sigact;
av_register_all(); av_register_all();
...@@ -4355,32 +4375,7 @@ int main(int argc, char **argv) ...@@ -4355,32 +4375,7 @@ int main(int argc, char **argv)
my_program_dir = getcwd(0, 0); my_program_dir = getcwd(0, 0);
ffserver_daemon = 1; ffserver_daemon = 1;
for(;;) { parse_options(argc, argv, options, NULL);
c = getopt(argc, argv, "ndLh?f:");
if (c == -1)
break;
switch(c) {
case 'L':
show_license();
exit(0);
case '?':
case 'h':
show_help();
exit(0);
case 'n':
no_launch = 1;
break;
case 'd':
ffserver_debug = 1;
ffserver_daemon = 0;
break;
case 'f':
config_filename = optarg;
break;
default:
exit(2);
}
}
putenv("http_proxy"); /* Kill the http_proxy */ putenv("http_proxy"); /* Kill the http_proxy */
......
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