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

📄 main.c

📁 wget (command line browser) source code
💻 C
📖 第 1 页 / 共 2 页
字号:
	  exit (0);	  break;	case 'K':	  setoptval ("backupconverted", "on");	  break;	case 'k':	  setoptval ("convertlinks", "on");	  break;	case 'L':	  setoptval ("relativeonly", "on");	  break;	case 'm':	  setoptval ("mirror", "on");	  break;	case 'N':	  setoptval ("timestamping", "on");	  break;	case 'p':	  setoptval ("pagerequisites", "on");	  break;	case 'S':	  setoptval ("serverresponse", "on");	  break;	case 's':	  setoptval ("saveheaders", "on");	  break;	case 'q':	  setoptval ("quiet", "on");	  break;	case 'r':	  setoptval ("recursive", "on");	  break;	case 'V':	  printf ("GNU Wget %s\n\n", version_string);	  printf ("%s", _("\Copyright (C) 2003 Free Software Foundation, Inc.\n"));	  printf ("%s", _("\This program is distributed in the hope that it will be useful,\n\but WITHOUT ANY WARRANTY; without even the implied warranty of\n\MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n\GNU General Public License for more details.\n"));	  printf (_("\nOriginally written by Hrvoje Niksic <hniksic@xemacs.org>.\n"));	  exit (0);	  break;	case 'v':	  setoptval ("verbose", "on");	  break;	case 'x':	  setoptval ("dirstruct", "on");	  break;	case 174:	  setoptval ("retryconnrefused", "on");	  break;	case 177:	  setoptval ("strictcomments", "on");	  break;	  /* Options accepting an argument: */	case 129:	  setoptval ("httpuser", optarg);	  break;	case 130:	  setoptval ("httppasswd", optarg);	  break;	case 131:	  setoptval ("header", optarg);	  break;	case 134:	  setoptval ("dotstyle", optarg);	  break;	case 135:	  setoptval ("htmlify", optarg);	  break;	case 140:	  setoptval ("excludedomains", optarg);	  break;	case 143:	  setoptval ("proxyuser", optarg);	  break;	case 144:	  setoptval ("proxypasswd", optarg);	  break;	case 151:	  setoptval ("backups", optarg);	  break;	case 152:	  setoptval ("waitretry", optarg);	  break;	case 153:	  setoptval ("followtags", optarg);	  break;	case 160:	  setoptval ("cookies", optarg);	  break;	case 161:	  setoptval ("loadcookies", optarg);	  break;	case 162:	  setoptval ("savecookies", optarg);	  break;	case 163:	  setoptval ("progress", optarg);	  break;	case 164:	  setoptval ("limitrate", optarg);	  break;	case 157:	  setoptval ("referer", optarg);	  break;#ifdef HAVE_SSL	case 158:	  setoptval ("sslcertfile", optarg);	  break;	case 159:	  setoptval ("sslcertkey", optarg);	  break;	case 166:	  setoptval ("egdfile", optarg);	  break;	case 169:	  setoptval ("sslcadir", optarg);	  break;	case 170:	  setoptval ("sslcafile", optarg);	  break;	case 171:	  setoptval ("sslcerttype", optarg);	  break;	case 172:	  setoptval ("sslcheckcert", optarg);	  break;	case 173:	  setoptval ("sslprotocol", optarg);	  break;#endif /* HAVE_SSL */	case 167:	  setoptval ("postdata", optarg);	  break;	case 168:	  setoptval ("postfile", optarg);	  break;	case 175:	  setoptval ("dnscache", optarg);	  break;	case 176:	  setoptval ("restrictfilenames", optarg);	  break;	case 178:	  setoptval ("dnstimeout", optarg);	  break;	case 179:	  setoptval ("readtimeout", optarg);	  break;	case 180:	  setoptval ("connecttimeout", optarg);	  break;	case 'A':	  setoptval ("accept", optarg);	  break;	case 'a':	  setoptval ("logfile", optarg);	  append_to_log = 1;	  break;	case 'B':	  setoptval ("base", optarg);	  break;	case 'C':	  setoptval ("cache", optarg);	  break;	case 'D':	  setoptval ("domains", optarg);	  break;	case 'e':	  run_command (optarg);	  break;	case 'G':	  setoptval ("ignoretags", optarg);	  break;	case 'g':	  setoptval ("glob", optarg);	  break;	case 'I':	  setoptval ("includedirectories", optarg);	  break;	case 'i':	  setoptval ("input", optarg);	  break;	case 'l':	  setoptval ("reclevel", optarg);	  break;	case 'n':	  {	    /* #### What we really want here is --no-foo. */	    char *p;	    for (p = optarg; *p; p++)	      switch (*p)		{		case 'v':		  setoptval ("verbose", "off");		  break;		case 'H':		  setoptval ("addhostdir", "off");		  break;		case 'd':		  setoptval ("dirstruct", "off");		  break;		case 'c':		  setoptval ("noclobber", "on");		  break;		case 'r':		  setoptval ("removelisting", "off");		  break;		case 'p':		  setoptval ("noparent", "on");		  break;		case 'k':		  setoptval ("httpkeepalive", "off");		  break;		default:		  printf (_("%s: illegal option -- `-n%c'\n"), exec_name, *p);		  print_usage ();		  printf ("\n");		  printf (_("Try `%s --help\' for more options.\n"), exec_name);		  exit (1);		}	    break;	  }	case 'O':	  setoptval ("outputdocument", optarg);	  break;	case 'o':	  setoptval ("logfile", optarg);	  break;	case 'P':	  setoptval ("dirprefix", optarg);	  break;	case 'Q':	  setoptval ("quota", optarg);	  break;	case 'R':	  setoptval ("reject", optarg);	  break;	case 'T':	  setoptval ("timeout", optarg);	  break;	case 't':	  setoptval ("tries", optarg);	  break;	case 'U':	  setoptval ("useragent", optarg);	  break;	case 'w':	  setoptval ("wait", optarg);	  break;	case 'X':	  setoptval ("excludedirectories", optarg);	  break;	case 'Y':	  setoptval ("useproxy", optarg);	  break;	case '?':	  print_usage ();	  printf ("\n");	  printf (_("Try `%s --help' for more options.\n"), exec_name);	  exit (0);	  break;	}    }  /* All user options have now been processed, so it's now safe to do     interoption dependency checks. */  if (opt.reclevel == 0)    opt.reclevel = INFINITE_RECURSION;  /* see wget.h for commentary on this */  if (opt.page_requisites && !opt.recursive)    {      opt.recursive = TRUE;      opt.reclevel = 0;      if (!opt.no_dirstruct)	opt.dirstruct = TRUE;  /* usually handled by cmd_spec_recursive() */    }  if (opt.verbose == -1)    opt.verbose = !opt.quiet;  /* Sanity checks.  */  if (opt.verbose && opt.quiet)    {      printf (_("Can't be verbose and quiet at the same time.\n"));      print_usage ();      exit (1);    }  if (opt.timestamping && opt.noclobber)    {      printf (_("\Can't timestamp and not clobber old files at the same time.\n"));      print_usage ();      exit (1);    }  nurl = argc - optind;  if (!nurl && !opt.input_filename)    {      /* No URL specified.  */      printf (_("%s: missing URL\n"), exec_name);      print_usage ();      printf ("\n");      /* #### Something nicer should be printed here -- similar to the	 pre-1.5 `--help' page.  */      printf (_("Try `%s --help' for more options.\n"), exec_name);      exit (1);    }  if (opt.background)    fork_to_background ();  /* Initialize progress.  Have to do this after the options are     processed so we know where the log file is.  */  if (opt.verbose)    set_progress_implementation (opt.progress_type);  /* Fill in the arguments.  */  url = alloca_array (char *, nurl + 1);  for (i = 0; i < nurl; i++, optind++)    {      char *rewritten = rewrite_shorthand_url (argv[optind]);      if (rewritten)	url[i] = rewritten;      else	url[i] = xstrdup (argv[optind]);    }  url[i] = NULL;  /* Change the title of console window on Windows.  #### I think this     statement should belong to retrieve_url().  --hniksic.  */#ifdef WINDOWS  ws_changetitle (*url, nurl);#endif  /* Initialize logging.  */  log_init (opt.lfilename, append_to_log);  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)    {      if (HYPHENP (opt.output_document))	opt.dfp = stdout;      else	{	  struct stat st;	  opt.dfp = fopen (opt.output_document, opt.always_rest ? "ab" : "wb");	  if (opt.dfp == NULL)	    {	      perror (opt.output_document);	      exit (1);	    }	  if (fstat (fileno (opt.dfp), &st) == 0 && S_ISREG (st.st_mode))	    opt.od_known_regular = 1;	}    }#ifdef WINDOWS  ws_startup ();#endif  /* Setup the signal handler to redirect output when hangup is     received.  */#ifdef HAVE_SIGNAL  if (signal(SIGHUP, SIG_IGN) != SIG_IGN)    signal(SIGHUP, redirect_output_signal);  /* ...and do the same for SIGUSR1.  */  signal (SIGUSR1, redirect_output_signal);  /* Writing to a closed socket normally signals SIGPIPE, and the     process exits.  What we want is to ignore SIGPIPE and just check     for the return value of write().  */  signal (SIGPIPE, SIG_IGN);#ifdef SIGWINCH  signal (SIGWINCH, progress_handle_sigwinch);#endif#endif /* HAVE_SIGNAL */#ifdef HAVE_SSL  /* Must call this before resolving any URLs because it has the power     to disable `https'.  */  ssl_init_prng ();#endif  status = RETROK;		/* initialize it, just-in-case */  /* Retrieve the URLs from argument list.  */  for (t = url; *t; t++)    {      char *filename = NULL, *redirected_URL = NULL;      int dt;      if (opt.recursive && url_scheme (*t) != SCHEME_FTP)	status = retrieve_tree (*t);      else	status = retrieve_url (*t, &filename, &redirected_URL, NULL, &dt);      if (opt.delete_after && file_exists_p(filename))	{	  DEBUGP (("Removing file due to --delete-after in main():\n"));	  logprintf (LOG_VERBOSE, _("Removing %s.\n"), filename);	  if (unlink (filename))	    logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno));	}      FREE_MAYBE (redirected_URL);      FREE_MAYBE (filename);    }  /* And then from the input file, if any.  */  if (opt.input_filename)    {      int count;      status = retrieve_from_file (opt.input_filename, opt.force_html, &count);      if (!count)	logprintf (LOG_NOTQUIET, _("No URLs found in %s.\n"),		   opt.input_filename);    }  /* Print the downloaded sum.  */  if (opt.recursive      || nurl > 1      || (opt.input_filename && total_downloaded_bytes != 0))    {      logprintf (LOG_NOTQUIET,		 _("\nFINISHED --%s--\nDownloaded: %s bytes in %d files\n"),		 time_str (NULL), legible_large_int (total_downloaded_bytes),		 opt.numurls);      /* Print quota warning, if exceeded.  */      if (opt.quota && total_downloaded_bytes > opt.quota)	logprintf (LOG_NOTQUIET,		   _("Download quota (%s bytes) EXCEEDED!\n"),		   legible (opt.quota));    }  if (opt.cookies_output && wget_cookie_jar)    cookie_jar_save (wget_cookie_jar, opt.cookies_output);  if (opt.convert_links && !opt.delete_after)    convert_all_links ();  log_close ();  for (i = 0; i < nurl; i++)    xfree (url[i]);  cleanup ();#ifdef DEBUG_MALLOC  print_malloc_debug_stats ();#endif  if (status == RETROK)    return 0;  else    return 1;}#ifdef HAVE_SIGNAL/* Hangup signal handler.  When wget receives SIGHUP or SIGUSR1, it   will proceed operation as usual, trying to write into a log file.   If that is impossible, the output will be turned off.   #### It is unsafe to do call libc functions from a signal handler.   What we should do is, set a global variable, and have the code in   log.c pick it up.  */static RETSIGTYPEredirect_output_signal (int sig){  char *signal_name = (sig == SIGHUP ? "SIGHUP" :		       (sig == SIGUSR1 ? "SIGUSR1" :			"WTF?!"));  log_request_redirect_output (signal_name);  progress_schedule_redirect ();  signal (sig, redirect_output_signal);}#endif /* HAVE_SIGNAL */

⌨️ 快捷键说明

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