]> sjero.net Git - wget/blobdiff - src/init.c
added option --https-only
[wget] / src / init.c
index b4336502057a425143a60d318cb49fff52b26cb6..033da4f7634159396cc18a4632b32ead857c9a80 100644 (file)
@@ -194,6 +194,9 @@ static const struct {
   { "httppasswd",       &opt.http_passwd,       cmd_string }, /* deprecated */
   { "httppassword",     &opt.http_passwd,       cmd_string },
   { "httpproxy",        &opt.http_proxy,        cmd_string },
+#ifdef HAVE_SSL
+  { "httpsonly",        &opt.https_only,        cmd_boolean },
+#endif
   { "httpsproxy",       &opt.https_proxy,       cmd_string },
   { "httpuser",         &opt.http_user,         cmd_string },
   { "ignorecase",       &opt.ignore_case,       cmd_boolean },
@@ -574,7 +577,8 @@ bool
 run_wgetrc (const char *file)
 {
   FILE *fp;
-  char *line;
+  char *line = NULL;
+  size_t bufsize = 0;
   int ln;
   int errcnt = 0;
 
@@ -586,7 +590,7 @@ run_wgetrc (const char *file)
       return true;                      /* not a fatal error */
     }
   ln = 1;
-  while ((line = read_whole_line (fp)) != NULL)
+  while (getline (&line, &bufsize, fp) > 0)
     {
       char *com = NULL, *val = NULL;
       int comind;
@@ -620,9 +624,9 @@ run_wgetrc (const char *file)
         }
       xfree_null (com);
       xfree_null (val);
-      xfree (line);
       ++ln;
     }
+  xfree (line);
   fclose (fp);
 
   return errcnt == 0;
@@ -964,15 +968,16 @@ cmd_string (const char *com, const char *val, void *place)
 static bool
 cmd_string_uppercase (const char *com, const char *val, void *place)
 {
-  char *q;
-  bool ret = cmd_string (com, val, place);
-  q = *((char **) place);
-  if (!ret || q == NULL)
-    return false;
+  char *q, **pstring;
+  pstring = (char **)place;
+  xfree_null (*pstring);
+
+  *pstring = xmalloc (strlen (val) + 1);
 
-  while (*q)
-    *q++ = c_toupper (*q);
+  for (q = *pstring; *val; val++, q++)
+    *q = c_toupper (*val);
 
+  *q = '\0';
   return true;
 }