]> sjero.net Git - wget/blobdiff - src/main.c
[svn] Implement better sorting and matching of cookies.
[wget] / src / main.c
index 250ac8873c3b9bdd8b7dba82ea20a2599716ef62..360d67e1fe7d8dd85c44548e93983bb742105097 100644 (file)
@@ -49,6 +49,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "retr.h"
 #include "recur.h"
 #include "host.h"
+#include "cookies.h"
 
 #ifndef PATH_SEPARATOR
 # define PATH_SEPARATOR '/'
@@ -193,6 +194,9 @@ HTTP options:\n\
        --referer=URL         include `Referer: URL\' header in HTTP request.\n\
   -s,  --save-headers        save the HTTP headers to file.\n\
   -U,  --user-agent=AGENT    identify as AGENT instead of Wget/VERSION.\n\
+       --cookies=no         don't use cookies.\n\
+       --load-cookies=FILE   load cookies from FILE before session.\n\
+       --save-cookies=FILE   save cookies to FILE after session.\n\
 \n"), stdout);
   fputs (_("\
 FTP options:\n\
@@ -242,9 +246,10 @@ main (int argc, char *const *argv)
   {
     /* Options without arguments: */
     { "background", no_argument, NULL, 'b' },
+    { "backup-converted", no_argument, NULL, 'K' },
     { "continue", no_argument, NULL, 'c' },
     { "convert-links", no_argument, NULL, 'k' },
-    { "backup-converted", no_argument, NULL, 'K' },
+    { "cookies", no_argument, NULL, 160 },
     { "debug", no_argument, NULL, 'd' },
     { "delete-after", no_argument, NULL, 136 },
     { "dont-remove-listing", no_argument, NULL, 149 },
@@ -302,6 +307,7 @@ main (int argc, char *const *argv)
     { "include-directories", required_argument, NULL, 'I' },
     { "input-file", required_argument, NULL, 'i' },
     { "level", required_argument, NULL, 'l' },
+    { "load-cookies", required_argument, NULL, 161 },
     { "no", required_argument, NULL, 'n' },
     { "output-document", required_argument, NULL, 'O' },
     { "output-file", required_argument, NULL, 'o' },
@@ -310,6 +316,7 @@ main (int argc, char *const *argv)
     { "proxy-user", required_argument, NULL, 143 },
     { "quota", required_argument, NULL, 'Q' },
     { "reject", required_argument, NULL, 'R' },
+    { "save-cookies", required_argument, NULL, 162 },
     { "timeout", required_argument, NULL, 'T' },
     { "tries", required_argument, NULL, 't' },
     { "user-agent", required_argument, NULL, 'U' },
@@ -347,7 +354,7 @@ main (int argc, char *const *argv)
       that the options with required arguments must be followed by a ':'.
       -- Dan Harkless <wget@harkless.org>] */
   while ((c = getopt_long (argc, argv, "\
-hpVqvdkKsxmNWrHSLcFbEY:G:g:T:U:O:l:n:i:o:a:t:D:A:R:P:B:e:Q:X:I:w:",
+hpVqvdkKsxmNWrHSLcFbEY:G:g:T:U:O:l:n:i:o:a:t:D:A:R:P:B:e:Q:X:I:w:C:",
                           long_options, (int *)0)) != EOF)
     {
       switch (c)
@@ -519,6 +526,15 @@ GNU General Public License for more details.\n"));
        case 153:
          setval ("followtags", optarg);
          break;
+       case 160:
+         setval ("cookies", "on");
+         break;
+       case 161:
+         setval ("loadcookies", optarg);
+         break;
+       case 162:
+         setval ("savecookies", optarg);
+         break;
        case 157:
          setval ("referer", optarg);
          break;
@@ -744,6 +760,7 @@ Can't timestamp and not clobber old files at the same time.\n"));
 
   DEBUGP (("DEBUG output created by Wget %s on %s.\n\n", version_string,
           OS_TYPE));
+
   /* Open the output filename if necessary.  */
   if (opt.output_document)
     {
@@ -752,7 +769,7 @@ Can't timestamp and not clobber old files at the same time.\n"));
       else
        {
          struct stat st;
-         opt.dfp = fopen (opt.output_document, "wb");
+         opt.dfp = fopen (opt.output_document, opt.always_rest ? "ab" : "wb");
          if (opt.dfp == NULL)
            {
              perror (opt.output_document);
@@ -831,6 +848,10 @@ Can't timestamp and not clobber old files at the same time.\n"));
                   _("Download quota (%s bytes) EXCEEDED!\n"),
                   legible (opt.quota));
     }
+
+  if (opt.cookies_output)
+    save_cookies (opt.cookies_output);
+
   if (opt.convert_links && !opt.delete_after)
     {
       convert_all_links ();