From f8b61244e3490003c1419447f5ec2232adc9a844 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Mon, 6 Apr 2015 16:20:20 +0200 Subject: CLI can take host and port parameter as arguments now --- src/biruda.c | 11 ++++++++++- src/cli.c | 8 ++++---- src/cli.h | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/biruda.c b/src/biruda.c index 8479aa5..1a25a05 100644 --- a/src/biruda.c +++ b/src/biruda.c @@ -383,7 +383,16 @@ int main( int argc, char *argv[] ) port = cfg_getint( webserver_cfg, "port" ); } } - ret = start_interactive( ( in == stdin ) ? !args_info.no_colors_given : false, port, in ); + + const char *host = DEFAULT_WEBSERVER_HOST; + if( args_info.inputs_num >= 1 ) { + host = args_info.inputs[0]; + } + if( args_info.inputs_num >= 2 ) { + port = atoi( args_info.inputs[1] ); + } + + ret = start_interactive( ( in == stdin ) ? !args_info.no_colors_given : false, host, port, in ); #else if( args_info.filename_given ) { ret = start_interactive( false, in ); diff --git a/src/cli.c b/src/cli.c index f882c3b..194abd1 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1,7 +1,7 @@ #include "cli.h" #ifdef _WIN32 -int start_interactive( bool colors, FILE *in ) +int start_interactive( bool colors, const char *host, unsigned short port, FILE *in ) { fprintf( stderr, "ERROR: Not implemented on Windows!\n" ); return EXIT_FAILURE; @@ -255,13 +255,13 @@ static void stop_worker( const char *worker_name ) } } -int start_interactive( bool colors, unsigned short port, FILE *in ) +int start_interactive( bool colors, const char *host, unsigned short port, FILE *in ) { char history_filename[1024]; // for http_tidy, tell it where to issue requests to - http_server = "localhost"; // server is hard-coded - http_port = port; // port not + http_server = (char *)host; + http_port = port; is_interactive = isatty( fileno( in ) ); print_colors = is_interactive ? colors : false; diff --git a/src/cli.h b/src/cli.h index 4086686..4c1d48f 100644 --- a/src/cli.h +++ b/src/cli.h @@ -5,6 +5,6 @@ #include -int start_interactive( bool colors, unsigned short port, FILE *in ); +int start_interactive( bool colors, const char *host, unsigned short port, FILE *in ); #endif -- cgit v1.2.3-54-g00ecf