⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 init.c

📁 wget讓你可以在console介面下
💻 C
📖 第 1 页 / 共 3 页
字号:
    }  *(SUM_SIZE_INT *) place = (SUM_SIZE_INT) byte_value;  return 1;}/* Store the value of VAL to *OUT.  The value is a time period, by   default expressed in seconds, but also accepting suffixes "m", "h",   "d", and "w" for minutes, hours, days, and weeks respectively.  */static intcmd_time (const char *com, const char *val, void *place){  double number, mult;  const char *end = val + strlen (val);  /* Strip trailing whitespace.  */  while (val < end && ISSPACE (end[-1]))    --end;  if (val == end)    {    err:      fprintf (stderr, _("%s: %s: Invalid time period `%s'\n"),	       exec_name, com, val);      return 0;    }  switch (TOLOWER (end[-1]))    {    case 's':      --end, mult = 1;		/* seconds */      break;    case 'm':      --end, mult = 60;		/* minutes */      break;    case 'h':      --end, mult = 3600;	/* hours */      break;    case 'd':      --end, mult = 86400.0;	/* days */      break;    case 'w':      --end, mult = 604800.0;	/* weeks */      break;    default:      /* Not a recognized suffix: assume it belongs to the number.	 (If not, simple_atof will raise an error.)  */      mult = 1;    }  /* Skip leading and trailing whitespace. */  while (val < end && ISSPACE (*val))    ++val;  while (val < end && ISSPACE (end[-1]))    --end;  if (val == end)    goto err;  if (!simple_atof (val, end, &number))    goto err;  *(double *)place = number * mult;  return 1;}#ifdef HAVE_SSLstatic intcmd_cert_type (const char *com, const char *val, void *place){  static const struct decode_item choices[] = {    { "pem", keyfile_pem },    { "der", keyfile_asn1 },    { "asn1", keyfile_asn1 },  };  int ok = decode_string (val, choices, countof (choices), place);  if (!ok)    fprintf (stderr, _("%s: %s: Invalid value `%s'.\n"), exec_name, com, val);  return ok;}#endif/* Specialized helper functions, used by `commands' to handle some   options specially.  */static int check_user_specified_header PARAMS ((const char *));static intcmd_spec_dirstruct (const char *com, const char *val, void *place_ignored){  if (!cmd_boolean (com, val, &opt.dirstruct))    return 0;  /* Since dirstruct behaviour is explicitly changed, no_dirstruct     must be affected inversely.  */  if (opt.dirstruct)    opt.no_dirstruct = 0;  else    opt.no_dirstruct = 1;  return 1;}static intcmd_spec_header (const char *com, const char *val, void *place_ignored){  /* Empty value means reset the list of headers. */  if (*val == '\0')    {      free_vec (opt.user_headers);      opt.user_headers = NULL;      return 1;    }  if (!check_user_specified_header (val))    {      fprintf (stderr, _("%s: %s: Invalid header `%s'.\n"),	       exec_name, com, val);      return 0;    }  opt.user_headers = vec_append (opt.user_headers, val);  return 1;}static intcmd_spec_htmlify (const char *com, const char *val, void *place_ignored){  int flag = cmd_boolean (com, val, &opt.htmlify);  if (flag && !opt.htmlify)    opt.remove_listing = 0;  return flag;}/* Set the "mirror" mode.  It means: recursive download, timestamping,   no limit on max. recursion depth, and don't remove listings.  */static intcmd_spec_mirror (const char *com, const char *val, void *place_ignored){  int mirror;  if (!cmd_boolean (com, val, &mirror))    return 0;  if (mirror)    {      opt.recursive = 1;      if (!opt.no_dirstruct)	opt.dirstruct = 1;      opt.timestamping = 1;      opt.reclevel = INFINITE_RECURSION;      opt.remove_listing = 0;    }  return 1;}/* Validate --prefer-family and set the choice.  Allowed values are   "IPv4", "IPv6", and "none".  */static intcmd_spec_prefer_family (const char *com, const char *val, void *place_ignored){  static const struct decode_item choices[] = {    { "IPv4", prefer_ipv4 },    { "IPv6", prefer_ipv6 },    { "none", prefer_none },  };  int ok = decode_string (val, choices, countof (choices),			  (int *) &opt.prefer_family);  if (!ok)    fprintf (stderr, _("%s: %s: Invalid value `%s'.\n"), exec_name, com, val);  return ok;}/* Set progress.type to VAL, but verify that it's a valid progress   implementation before that.  */static intcmd_spec_progress (const char *com, const char *val, void *place_ignored){  if (!valid_progress_implementation_p (val))    {      fprintf (stderr, _("%s: %s: Invalid progress type `%s'.\n"),	       exec_name, com, val);      return 0;    }  xfree_null (opt.progress_type);  /* Don't call set_progress_implementation here.  It will be called     in main() when it becomes clear what the log output is.  */  opt.progress_type = xstrdup (val);  return 1;}/* Set opt.recursive to VAL as with cmd_boolean.  If opt.recursive is   set to true, also set opt.dirstruct to 1, unless opt.no_dirstruct   is specified.  */static intcmd_spec_recursive (const char *com, const char *val, void *place_ignored){  if (!cmd_boolean (com, val, &opt.recursive))    return 0;  else    {      if (opt.recursive && !opt.no_dirstruct)	opt.dirstruct = 1;    }  return 1;}static intcmd_spec_restrict_file_names (const char *com, const char *val, void *place_ignored){  int restrict_os = opt.restrict_files_os;  int restrict_ctrl = opt.restrict_files_ctrl;  const char *end = strchr (val, ',');  if (!end)    end = val + strlen (val);#define VAL_IS(string_literal) BOUNDED_EQUAL (val, end, string_literal)  if (VAL_IS ("unix"))    restrict_os = restrict_unix;  else if (VAL_IS ("windows"))    restrict_os = restrict_windows;  else if (VAL_IS ("nocontrol"))    restrict_ctrl = 0;  else    {    err:      fprintf (stderr,	       _("%s: %s: Invalid restriction `%s', use `unix' or `windows'.\n"),	       exec_name, com, val);      return 0;    }#undef VAL_IS  if (*end)    {      if (!strcmp (end + 1, "nocontrol"))	restrict_ctrl = 0;      else	goto err;    }  opt.restrict_files_os = restrict_os;  opt.restrict_files_ctrl = restrict_ctrl;  return 1;}#ifdef HAVE_SSLstatic intcmd_spec_secure_protocol (const char *com, const char *val, void *place){  static const struct decode_item choices[] = {    { "auto", secure_protocol_auto },    { "sslv2", secure_protocol_sslv2 },    { "sslv3", secure_protocol_sslv3 },    { "tlsv1", secure_protocol_tlsv1 },  };  int ok = decode_string (val, choices, countof (choices), place);  if (!ok)    fprintf (stderr, _("%s: %s: Invalid value `%s'.\n"), exec_name, com, val);  return ok;}#endif/* Set all three timeout values. */static intcmd_spec_timeout (const char *com, const char *val, void *place_ignored){  double value;  if (!cmd_time (com, val, &value))    return 0;  opt.read_timeout = value;  opt.connect_timeout = value;  opt.dns_timeout = value;  return 1;}static intcmd_spec_useragent (const char *com, const char *val, void *place_ignored){  /* Disallow embedded newlines.  */  if (strchr (val, '\n'))    {      fprintf (stderr, _("%s: %s: Invalid value `%s'.\n"),	       exec_name, com, val);      return 0;    }  xfree_null (opt.useragent);  opt.useragent = xstrdup (val);  return 1;}/* Miscellaneous useful routines.  *//* A very simple atoi clone, more useful than atoi because it works on   delimited strings, and has error reportage.  Returns 1 on success,   0 on failure.  If successful, stores result to *DEST.  */static intsimple_atoi (const char *beg, const char *end, int *dest){  int result = 0;  int negative = 0;  const char *p = beg;  while (p < end && ISSPACE (*p))    ++p;  if (p < end && (*p == '-' || *p == '+'))    {      negative = (*p == '-');      ++p;    }  if (p == end)    return 0;  /* Read negative numbers in a separate loop because the most     negative integer cannot be represented as a positive number.  */  if (!negative)    for (; p < end && ISDIGIT (*p); p++)      {	int next = (10 * result) + (*p - '0');	if (next < result)	  return 0;		/* overflow */	result = next;      }  else    for (; p < end && ISDIGIT (*p); p++)      {	int next = (10 * result) - (*p - '0');	if (next > result)	  return 0;		/* underflow */	result = next;      }  if (p != end)    return 0;  *dest = result;  return 1;}/* Trivial atof, with error reporting.  Handles "<digits>[.<digits>]",   doesn't handle exponential notation.  Returns 1 on success, 0 on   failure.  In case of success, stores its result to *DEST.  */static intsimple_atof (const char *beg, const char *end, double *dest){  double result = 0;  int negative = 0;  int seen_dot = 0;  int seen_digit = 0;  double divider = 1;  const char *p = beg;  while (p < end && ISSPACE (*p))    ++p;  if (p < end && (*p == '-' || *p == '+'))    {      negative = (*p == '-');      ++p;    }  for (; p < end; p++)    {      char ch = *p;      if (ISDIGIT (ch))	{	  if (!seen_dot)	    result = (10 * result) + (ch - '0');	  else	    result += (ch - '0') / (divider *= 10);	  seen_digit = 1;	}      else if (ch == '.')	{	  if (!seen_dot)	    seen_dot = 1;	  else	    return 0;	}      else	return 0;    }  if (!seen_digit)    return 0;  if (negative)    result = -result;  *dest = result;  return 1;}/* Verify that the user-specified header in S is valid.  It must   contain a colon preceded by non-white-space characters and must not   contain newlines.  */static intcheck_user_specified_header (const char *s){  const char *p;  for (p = s; *p && *p != ':' && !ISSPACE (*p); p++);  /* The header MUST contain `:' preceded by at least one     non-whitespace character.  */  if (*p != ':' || p == s)    return 0;  /* The header MUST NOT contain newlines.  */  if (strchr (s, '\n'))    return 0;  return 1;}/* Decode VAL into a number, according to ITEMS. */static intdecode_string (const char *val, const struct decode_item *items, int itemcount,	       int *place){  int i;  for (i = 0; i < itemcount; i++)    if (0 == strcasecmp (val, items[i].name))      {	*place = items[i].code;	return 1;      }  return 0;}void cleanup_html_url PARAMS ((void));void http_cleanup PARAMS ((void));/* Free the memory allocated by global variables.  */voidcleanup (void){  /* Free external resources, close files, etc. */  {    extern FILE *output_stream;    if (output_stream)      fclose (output_stream);    /* No need to check for error because Wget flushes its output (and       checks for errors) after any data arrives.  */  }  /* We're exiting anyway so there's no real need to call free()     hundreds of times.  Skipping the frees will make Wget exit     faster.     However, when detecting leaks, it's crucial to free() everything     because then you can find the real leaks, i.e. the allocated     memory which grows with the size of the program.  */#ifdef DEBUG_MALLOC  convert_cleanup ();  res_cleanup ();  http_cleanup ();  cleanup_html_url ();  host_cleanup ();  log_cleanup ();  {    extern acc_t *netrc_list;    free_netrc (netrc_list);  }  xfree_null (opt.lfilename);  xfree_null (opt.dir_prefix);  xfree_null (opt.input_filename);  xfree_null (opt.output_document);  free_vec (opt.accepts);  free_vec (opt.rejects);  free_vec (opt.excludes);  free_vec (opt.includes);  free_vec (opt.domains);  free_vec (opt.follow_tags);  free_vec (opt.ignore_tags);  xfree_null (opt.progress_type);  xfree_null (opt.ftp_user);  xfree_null (opt.ftp_passwd);  xfree_null (opt.ftp_proxy);  xfree_null (opt.https_proxy);  xfree_null (opt.http_proxy);  free_vec (opt.no_proxy);  xfree_null (opt.useragent);  xfree_null (opt.referer);  xfree_null (opt.http_user);  xfree_null (opt.http_passwd);  free_vec (opt.user_headers);# ifdef HAVE_SSL  xfree_null (opt.cert_file);  xfree_null (opt.private_key);  xfree_null (opt.ca_directory);  xfree_null (opt.ca_cert);  xfree_null (opt.random_file);  xfree_null (opt.egd_file);# endif  xfree_null (opt.bind_address);  xfree_null (opt.cookies_input);  xfree_null (opt.cookies_output);  xfree_null (opt.user);  xfree_null (opt.passwd);#endif /* DEBUG_MALLOC */}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -