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

📄 htbrowse.c

📁 www工具包. 这是W3C官方支持的www支撑库. 其中提供通用目的的客户端的WebAPI: complete HTTP/1.1 (with caching, pipelining, PUT, POS
💻 C
📖 第 1 页 / 共 5 页
字号:
	    /* to -- Final representation */	    } else if (!strcmp(argv[arg], "-to")) {		HTFormat format = (arg+1 < argc && *argv[arg+1] != '-') ?		    HTAtom_for(argv[++arg]) : DEFAULT_FORMAT;		HTRequest_setOutputFormat(request, format);		HTAlert_setInteractive(NO);	    /* reformat html */	    } else if (!strcmp(argv[arg], "-reformat")) {		HTRequest_setOutputFormat(request, WWW_HTML);		lm->flags |= LM_REFORMAT;		HTAlert_setInteractive(NO);	    /* List References */	    } else if (!strncmp(argv[arg], "-list", 5)) {		lm->flags |= LM_REFS;		HTAlert_setInteractive(NO);	    /* original output */	    } else if (!strcmp(argv[arg], "-raw")) {		HTRequest_setOutputFormat(request, WWW_RAW);		HTAlert_setInteractive(NO);	    /* source please */	    } else if (!strcmp(argv[arg], "-source")) {		HTRequest_setOutputFormat(request, WWW_SOURCE);		HTAlert_setInteractive(NO);	    /* HEAD method */	    } else if (!strcasecomp(argv[arg], "-head")) {		HTRequest_setMethod(request, METHOD_HEAD);		HTRequest_setOutputFormat(request, WWW_MIME);		HTAlert_setInteractive(NO);	    /* output filename */	    } else if (!strcmp(argv[arg], "-o")) { 		lm->outputfile = (arg+1 < argc && *argv[arg+1] != '-') ?		    argv[++arg] : DEFAULT_OUTPUT_FILE;		HTAlert_setInteractive(NO);	    /* print version and exit */	    } else if (!strcmp(argv[arg], "-version")) { 		VersionInfo(lm);		Cleanup(lm, 0);	    /* -? or -help: show the command line help page */	    } else if (!strcmp(argv[arg],"-?") || !strcmp(argv[arg],"-help")) {		lm->anchor = (HTParentAnchor *) HTAnchor_findAddress(L_HELP);		keycnt = 1;#ifdef CYRILLIC	    /* HWL 18/7/94: applied patch from agl@glas2.glas.apc.org	       (Anton Tropashko) */	    } else if (!strcmp(argv[arg], "-koi2alt")) {	        doia2k(); OutputData(lm->pView, "Ahak2a!");#endif	    /* Page size */	    } else if (!strncmp(argv[arg], "-p", 2)) {		if (*(argv[arg]+2)) {		    if (sscanf(argv[arg]+2, "%d", &HTScreenHeight) < 1)			HTScreenHeight = -1;				    else {			if(HTScreenHeight < MIN_SCREEN_HEIGHT)			    HTScreenHeight = MIN_SCREEN_HEIGHT;			if(HTScreenHeight > MAX_SCREEN_HEIGHT)			    HTScreenHeight = MAX_SCREEN_HEIGHT;		    }		} else if (arg+1 < argc && *argv[arg+1] != '-') {		    if (sscanf(argv[++arg], "%d", &HTScreenHeight) < 1)			HTScreenHeight = -1;		    else {			if(HTScreenHeight < MIN_SCREEN_HEIGHT)			    HTScreenHeight = MIN_SCREEN_HEIGHT;			if(HTScreenHeight > MAX_SCREEN_HEIGHT)			    HTScreenHeight = MAX_SCREEN_HEIGHT;		    }		}	    /* Page width */	    } else if (!strncmp(argv[arg], "-w", 2)) {		if (*(argv[arg]+2)) {		    if (sscanf(argv[arg]+2, "%d", &HTScreenWidth) < 1)			HTScreenWidth = SCREEN_WIDTH;		} else if (arg+1 < argc && *argv[arg+1] != '-') {		    if (sscanf(argv[++arg], "%d", &HTScreenWidth) < 1)			HTScreenWidth = SCREEN_WIDTH;		}		if(HTScreenWidth < MIN_SCREEN_WIDTH)		    HTScreenWidth = MIN_SCREEN_WIDTH;		if(HTScreenWidth > MAX_SCREEN_WIDTH)		    HTScreenWidth = MAX_SCREEN_WIDTH;		    	    /* Telnet from */	    } else if (!strcmp(argv[arg], "-h")) {		if (arg+1 < argc && *argv[arg+1] != '-') {		    lm->host = argv[++arg]; 		    /* Use host name */		    HTLib_setSecure(YES);		   /* No easy access */		}	    /* log file */	    } else if (!strcmp(argv[arg], "-l")) {		lm->logfile = (arg+1 < argc && *argv[arg+1] != '-') ?		    argv[++arg] : DEFAULT_LOG_FILE;	    /* rule file */	    } else if (!strcmp(argv[arg], "-r")) {		lm->rules = (arg+1 < argc && *argv[arg+1] != '-') ?		    argv[++arg] : DEFAULT_RULE_FILE;	    /* timeout -- Change the default request timeout */	    } else if (!strcmp(argv[arg], "-timeout")) {		int timeout = (arg+1 < argc && *argv[arg+1] != '-') ?		    atoi(argv[++arg]) : -1;		if (timeout > 0) lm->timer = timeout;	    /* PICS user */	    } else if (!strcmp(argv[arg], "-u")) {		picsUser = (arg+1 < argc && *argv[arg+1] != '-') ?		    argv[++arg] : "user";	    } else if (!strcmp(argv[arg], "-unp")) {	        lm->noPICSPasswords = 1;#if 0 /* old version of user list file, still works when enabeled here */	    /* PICS user list */	    } else if (!strcmp(argv[arg], "-ul")) {		picsUserList = (arg+1 < argc && *argv[arg+1] != '-') ?		    argv[++arg] : "users.url";#endif	    /* PICS user list */	    } else if (!strcmp(argv[arg], "-ul")) {		lm->userList = (arg+1 < argc && *argv[arg+1] != '-') ?		    argv[++arg] : DEFAULT_USERLIST_FILE;	    /* PICS mode */	    } else if (!strcmp(argv[arg], "-pics")) {		lm->userList = DEFAULT_USERLIST_FILE;	    /* preemptive or non-preemptive access */	    } else if (!strcmp(argv[arg], "-single")) {		HTRequest_setPreemptive(request, YES);		lm->flags |= LM_PREEMTIVE;	    /* Disconnected operation */	    } else if (!strncmp(argv[arg], "-discon", 7)) {		HTCacheMode_setDisconnected(HT_DISCONNECT_NORMAL);	    /* Disable the cache */	    } else if (!strncmp(argv[arg], "-nocache", 8)) {		HTCacheMode_setEnabled(NO);	    /* Handling of Expire (cache) */	    } else if (!strncmp(argv[arg], "-x", 2)) { 	    	  char *p = argv[arg]+2;		  for(;*p;p++) {		      switch (argv[arg][2]) {		      case 'i':			  HTCacheMode_setExpires(HT_EXPIRES_IGNORE);			  break;		      case 'n':			  HTCacheMode_setExpires(HT_EXPIRES_NOTIFY);			  break;		      case 'a':			  HTCacheMode_setExpires(HT_EXPIRES_AUTO);			  break;		      default:			  if (SHOW_MSG)			      HTPrint("Bad parameter (%s) for option -x\n", argv[arg]);			  break;		      }		  }	    /* Anchor format */	    } else if (!strcmp(argv[arg], "-a")) { 		if (arg+1 < argc && *argv[arg+1] != '-')		    end_reference = argv[++arg];      /* New representation */	    /* Anchor format */	    } else if (!strcmp(argv[arg], "-ar")) { 		if (arg+1 < argc && *argv[arg+1] != '-')		    reference_mark = argv[++arg];  /* Change representation */	    /* Anchor format */	    } else if (!strcmp(argv[arg], "-as")) { 		if (arg+1 < argc && *argv[arg+1] != '-')		    start_reference = argv[++arg]; /* Change representation */	    /* No anchors */	    } else if (!strcmp(argv[arg], "-na")) { 		    display_anchors = NO;#ifndef NO_DIR_OPTIONS	    } else if (!strncmp(argv[arg], "-d", 2)) {	    	char *p = argv[arg]+2;		for(;*p;p++) {		    switch (argv[arg][2]) {		      case 'r':HTFile_setDirReadme(HT_DIR_README_NONE); break;		      case 't':HTFile_setDirReadme(HT_DIR_README_TOP); break;		      case 'b':HTFile_setDirReadme(HT_DIR_README_BOTTOM);break;		      case 'n':HTFile_setDirAccess(HT_DIR_FORBID); break;		      case 's':HTFile_setDirAccess(HT_DIR_SELECTIVE); break;		      case 'y':HTFile_setDirAccess(HT_DIR_OK); break;		      default:			if (SHOW_MSG)			    HTPrint("Bad parameter (%s) in -d option\n",				    argv[arg]);		    }		}#endif#ifdef WWWTRACE	    /* trace flags */	    } else if (!strncmp(argv[arg], "-v", 2)) {		lm->trace = HTSetTraceMessageMask(argv[arg]+2);#endif	    } else {		if (SHOW_MSG) HTPrint("Bad Argument (%s)\n", argv[arg]);	    }	} else {	   /* If no leading `-' then check for main argument */    	    if (!keycnt) {		char * ref = HTParse(argv[arg], lm->cwd, PARSE_ALL);		lm->anchor = HTAnchor_parent(HTAnchor_findAddress(ref));		keycnt = 1;		HT_FREE(ref);	    } else {		   /* Check for successive keyword arguments */		char *escaped = HTEscape(argv[arg], URL_XALPHAS);		if (keycnt++ <= 1)		    keywords = HTChunk_new(128);		else		    HTChunk_putc(keywords, ' ');		HTChunk_puts(keywords, HTStrip(escaped));		HT_FREE(escaped);	    }	}    }#ifdef CATCH_SIG    SetSignal();#endif    /* Set up HText interface callbacks */    if (HTAlert_interactive () ) {	/* interactive mode */	if (!HText_registerCDCallback (LMHText_new, LMHText_delete)) {	    HTPrint("HText new/delete callback registration failed.\n");	    exit (1);	}    } else {	/* non-interactive mode */	if (!HText_registerCDCallback (LMHText_new2, LMHText_delete)) {	    HTPrint("HText new/delete callback registration failed.\n");	    exit (1);	}    }    if (!HText_registerTextCallback (LMHText_addText)) {	HTPrint("HText addText callback registration failed.\n");	exit (2);    }    if (!HText_registerLinkCallback (LMHText_beginAnchor)) {	HTPrint("HText link callback registration failed.\n");	exit (3);    }    if (!HText_registerElementCallback (    	LMHText_beginElement, LMHText_endElement)) {	HTPrint("HText element callback registration failed.\n");	exit (3);    }    /* Make home page address */    if (!lm->anchor) lm->anchor = HTHomeAnchor();    /* Do we need list of presenters? (external viewers) */    if (HTAlert_interactive()) {	lm->presenters = HTList_new();	HTPresenterInit(lm->presenters);	HTRequest_setConversion(request, lm->presenters, NO);    } else {	/*	** Add default content decoder. We insert a through line as it doesn't	** matter that we get an encoding that we don't know when not in	** interactive mode. In interactive mode, we ask the user.	*/	HTFormat_addCoding("*", HTIdentityCoding, HTIdentityCoding, 0.3);    }    if (HTScreenHeight == -1) {				/* Default page size */	if (HTAlert_interactive())	    scrsize(&HTScreenHeight, &HTScreenWidth);	else	    HTScreenHeight = 999999;    }    /* Disable free directory browsing when using telnet host */    if (lm->host && HTFile_dirAccess() == HT_DIR_OK)	HTFile_setDirAccess(HT_DIR_SELECTIVE);    /* Open output file */    if (!HTAlert_interactive()) {#ifndef WWW_WIN_WINDOW	if (lm->outputfile) {	    if ((OUTPUT = fopen(lm->outputfile, "wb")) == NULL) {		if (SHOW_MSG) HTPrint("Can't open `%s'\\n",				       lm->outputfile);		OUTPUT = stdout;	    }	}	HTRequest_setOutputStream(request,				  HTFWriter_new(request, OUTPUT, YES));#endif	/*	** To reformat HTML, just put it through a parser running	** into a regenerator   tbl 940613	*/	if (lm->flags & LM_REFORMAT) {	    HTStructured * html =		HTMLGenerator(request, NULL, WWW_HTML,			      HTRequest_outputFormat(request),			      HTRequest_outputStream(request));	    HTRequest_setOutputStream(request, SGML_new(HTML_dtd(), html));	}    }         /* Log file specifed? */    if (lm->logfile) {	lm->log = HTLog_open(lm->logfile, YES, YES);        if (lm->log) HTNet_addAfter(HTLogFilter, NULL, lm->log, HT_ALL, HT_FILTER_LATE);    }    /* Just convert formats */    if (lm->flags & LM_FILTER) {#ifdef STDIN_FILENO	HTRequest_setAnchor(request, (HTAnchor *) lm->anchor);	HTRequest_setPreemptive(request, YES);	HTLoadSocket(STDIN_FILENO, request);#endif	Cleanup(lm, 0);    }    /* Set timeout on sockets */    if (lm->timer < 0) {	lm->timer = HTAlert_interactive() ?	    DEFAULT_I_TIMEOUT : DEFAULT_NI_TIMEOUT;    }    /* Set the DNS cache timeout */    HTDNS_setTimeout(3600);    /* Rule file specified? */    if (lm->rules) {	char * rules = HTParse(lm->rules, lm->cwd, PARSE_ALL);	if (!HTLoadRules(rules))	    if (SHOW_MSG) HTPrint("Can't access rules\n");	HT_FREE(rules);    }    /* Set up PICS machinary */    CSApp_registerApp(PICSCallback, CSApp_callOnBad, PICS_userCallback, 		      (void *)lm);     /* Add our own filter to update the history list */    HTNet_addBefore(MemoryCacheFilter, NULL, NULL, HT_FILTER_EARLY);    HTNet_addAfter(terminate_handler, NULL, NULL, HT_ALL, HT_FILTER_LAST);    /* Should we load a PICS user profile? */    if (picsUser && !LoadPICSUser(lm, picsUser))        HTPrint("Unable to load PICS user \"%s\".\n", picsUser);    /* PICS user list specified? */    if (lm->userList)        LoadPICSUser(lm, lm->userList);    /* request was registered in Thread_new before command line parsing       loaded the PICS user, so re-register to give it the correct user */    CSApp_unregisterReq(request);    CSApp_registerReq(request, lm->pCSUser, PICSCallback, 		      CSApp_callOnBad, (void *)lm);    /* Start the request */    if (keywords)	status = HTSearchAnchor(keywords, (HTAnchor *) lm->anchor, request);    else	status = HTLoadAnchor((HTAnchor *) lm->anchor, request);    if (keywords) HTChunk_delete(keywords);    if (status != YES) {	if (SHOW_MSG) HTPrint("Couldn't load home page\n");	CSApp_unregisterDefaultUser();	CSApp_unregisterApp();	Cleanup(lm, -1);    }    /* Set up the rest if we are in interactive mode */    if (HTAlert_interactive()) {	/* Start History manager */	lm->history = HTHistory_new();	/*	** Register STDIN as the user socket IF not STDIN is connected to	** /dev/null or other non-terminal devices	*/	ConsoleEvent = HTEvent_new(scan_command, lm->console, HT_PRIORITY_MAX, lm->timer);#ifdef STDIN_FILENO	if (isatty(STDIN_FILENO)) {	    HTEventList_register(STDIN_FILENO, HTEvent_READ, ConsoleEvent);	}#else	HTEventList_register(GetStdHandle(STD_INPUT_HANDLE), HTEvent_READ, ConsoleEvent);#endif    }    /* Go into the event loop... */    HTEventList_loop(request);    /* Only gets here if event loop fails */    Cleanup(lm, 0);    return 0;}

⌨️ 快捷键说明

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