]> sjero.net Git - wget/blobdiff - src/init.c
[svn] Applied Philipp Thomas's safe-ctype patch. Published in
[wget] / src / init.c
index 773f98681cdcfc5f417034cf8544828ce19a2579..ffda428ad15244a3ec8cc24cf95b37235fb1546c 100644 (file)
@@ -20,7 +20,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <config.h>
 
 #include <stdio.h>
-#include <ctype.h>
 #include <sys/types.h>
 #include <stdlib.h>
 #ifdef HAVE_UNISTD_H
@@ -125,6 +124,7 @@ static struct {
   { "httpkeepalive",   &opt.http_keep_alive,   cmd_boolean },
   { "httppasswd",      &opt.http_passwd,       cmd_string },
   { "httpproxy",       &opt.http_proxy,        cmd_string },
+  { "httpsproxy",      &opt.https_proxy,       cmd_string },
   { "httpuser",                &opt.http_user,         cmd_string },
   { "ignorelength",    &opt.ignore_length,     cmd_boolean },
   { "ignoretags",      &opt.ignore_tags,       cmd_vector },
@@ -160,6 +160,10 @@ static struct {
   { "simplehostcheck", &opt.simple_check,      cmd_boolean },
   { "spanhosts",       &opt.spanhost,          cmd_boolean },
   { "spider",          &opt.spider,            cmd_boolean },
+#ifdef HAVE_SSL
+  { "sslcertfile",     &opt.sslcertfile,       cmd_string },
+  { "sslcertkey",      &opt.sslcertkey,        cmd_string },
+#endif /* HAVE_SSL */
   { "timeout",         &opt.timeout,           cmd_time },
   { "timestamping",    &opt.timestamping,      cmd_boolean },
   { "tries",           &opt.ntry,              cmd_number_inf },
@@ -492,28 +496,21 @@ static int myatoi PARAMS ((const char *s));
 static int
 cmd_address (const char *com, const char *val, void *closure)
 {
-    struct sockaddr_in *sin;
-    
-    sin = (struct sockaddr_in *) malloc(sizeof *sin);
-    if (sin == NULL)
-    {
-       fprintf (stderr, _("%s: Out of memory.\n"), exec_name);
-       return 0;
-    }
-    
-    if (!store_hostaddress ((unsigned char *)&sin->sin_addr, val))
-    {
-       fprintf (stderr, _("%s: %s: Cannot convert `%s' to an IP address.\n"),
-                exec_name, com, val);
-       return 0;
-    }
-    
-    sin->sin_family = AF_INET;
-    sin->sin_port = 0;
-    
-    * (struct sockaddr_in **) closure = sin;
-    
-    return 1;
+  struct sockaddr_in sin;
+
+  if (!store_hostaddress ((unsigned char *)&sin.sin_addr, val))
+    {
+      fprintf (stderr, _("%s: %s: Cannot convert `%s' to an IP address.\n"),
+              exec_name, com, val);
+      return 0;
+    }
+
+  sin.sin_family = AF_INET;
+  sin.sin_port = 0;
+
+  memcpy (closure, &sin, sizeof (sin));
+
+  return 1;
 }
 
 /* Store the boolean value from VAL to CLOSURE.  COM is ignored,
@@ -981,6 +978,10 @@ check_user_specified_header (const char *s)
   return 1;
 }
 \f
+void cleanup_html_url PARAMS ((void));
+void downloaded_files_free PARAMS ((void));
+
+
 /* Free the memory allocated by global variables.  */
 void
 cleanup (void)
@@ -992,6 +993,8 @@ cleanup (void)
   free_netrc (netrc_list);
   if (opt.dfp)
     fclose (opt.dfp);
+  cleanup_html_url ();
+  downloaded_files_free ();
   FREE_MAYBE (opt.lfilename);
   xfree (opt.dir_prefix);
   FREE_MAYBE (opt.input_filename);
@@ -1004,8 +1007,9 @@ cleanup (void)
   free_vec (opt.follow_tags);
   free_vec (opt.ignore_tags);
   xfree (opt.ftp_acc);
-  xfree (opt.ftp_pass);
+  FREE_MAYBE (opt.ftp_pass);
   FREE_MAYBE (opt.ftp_proxy);
+  FREE_MAYBE (opt.https_proxy);
   FREE_MAYBE (opt.http_proxy);
   free_vec (opt.no_proxy);
   FREE_MAYBE (opt.useragent);
@@ -1013,4 +1017,8 @@ cleanup (void)
   FREE_MAYBE (opt.http_user);
   FREE_MAYBE (opt.http_passwd);
   FREE_MAYBE (opt.user_header);
+#ifdef HAVE_SSL
+  FREE_MAYBE (opt.sslcertkey);
+  FREE_MAYBE (opt.sslcertfile);
+#endif /* HAVE_SSL */
 }