From dcbf78a9a1a1ef704004a1fb9c2a18a7b27eb9cc Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Wed, 1 Sep 2010 07:52:27 +0200 Subject: [PATCH] Add new -O option --- man/proz.1 | 4 ++++ src/main.cpp | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/man/proz.1 b/man/proz.1 index 0da4fda..041b0cc 100644 --- a/man/proz.1 +++ b/man/proz.1 @@ -31,6 +31,10 @@ Increase the amount of information sent to stdout .TP \-\-no\-curses Don't use the Curses interface, but the traditional plain text interface +.SH "Filess:" +.TP +\-P, \-\-output\-document=FILE +write documents to FILE .SH "Directories:" .TP \-P, \-\-directory\-prefix=DIR diff --git a/src/main.cpp b/src/main.cpp index 4cda243..1a02ea7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -59,6 +59,7 @@ struct option long_opts[] = { {"tries", required_argument, NULL, 't'}, {"force", no_argument, NULL, 'f'}, {"version", no_argument, NULL, 'v'}, + {"output-document", required_argument, NULL, 'O'}, {"directory-prefix", required_argument, NULL, 'P'}, {"use-port", no_argument, NULL, 129}, {"retry-delay", required_argument, NULL, 130}, @@ -133,6 +134,9 @@ help (void) " -v,--verbose Increase the amount of information sent to stdout\n" " --no-curses Don't use Curses, plain text to stdout\n" "\n" + "Files:\n" + " -O, --output-document=FILE write documents to FILE\n" + "\n" "Directories:\n" " -P, --directory-prefix=DIR save the generated file to DIR/\n" "\n" @@ -216,12 +220,13 @@ main (int argc, char **argv) { int c; int ret; + char *opt_file = NULL; proz_init (argc, argv); //init libprozilla set_defaults (); //set some reasonable defaults load_prefs (); //load values from the config file while ((c = - getopt_long (argc, argv, "?hvrfk:1Lt:VgsP:", long_opts, + getopt_long (argc, argv, "?hvrfk:1Lt:VgsP:O:", long_opts, NULL)) != EOF) { switch (c) @@ -274,7 +279,12 @@ main (int argc, char **argv) */ rt.use_netrc = FALSE; break; - + case 'O': + /* + * Output file name + */ + opt_file = kstrdup(optarg); + break; case 'P': /* * Save the downloaded file to DIR @@ -503,6 +513,9 @@ main (int argc, char **argv) exit (0); } + if (opt_file) + url_data->file=opt_file; + PrintMessage("Starting....."); //In to %s\n",url_data->host); // start the download