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

📄 lygetfile.c

📁 基于rtos开发的浏览器!
💻 C
📖 第 1 页 / 共 3 页
字号:
			sprintf(buf,				EXECUTION_DISABLED_FOR_FILE,				key_for_func(LYK_OPTIONS));			_statusline(buf);			sleep(AlertSecs);		     }#else /* no exec_links */		     _statusline(EXECUTION_NOT_COMPILED);		     sleep(MessageSecs);#endif /* EXEC_LINKS */		     return(NULLFILE);		} else if (url_type == MAILTO_URL_TYPE) {		    if (no_mail) {			_statusline(MAIL_DISABLED);			sleep(MessageSecs);		    } else {			HTParentAnchor *tmpanchor;			CONST char *title;			title = "";			if ((tmpanchor = HTAnchor_parent(						HTAnchor_findAddress(&WWWDoc)							)) != NULL) {			    if (HTAnchor_title(tmpanchor)) {				title = HTAnchor_title(tmpanchor);			    }			}			cp = (char *)strchr(doc->address,':')+1;			reply_by_mail(cp,				      ((HTMainAnchor && !LYUserSpecifiedURL) ?				       (char *)HTMainAnchor->address :				       (char *)doc->address),				      title);		    }		    return(NULLFILE);		/*		 *  From here on we could have a remote host,		 *  so check if that's allowed.		 */		} else if (local_host_only &&			   url_type != NEWS_URL_TYPE &&			   url_type != LYNXKEYMAP_URL_TYPE &&			   url_type != LYNXIMGMAP_URL_TYPE &&			   url_type != LYNXCOOKIE_URL_TYPE &&			   url_type != LYNXCGI_URL_TYPE &&			   !(LYisLocalHost(doc->address) ||			     LYisLocalAlias(doc->address))) {		    statusline(ACCESS_ONLY_LOCALHOST);		    sleep(MessageSecs);		    return(NULLFILE);		/*		 *  Disable www telnet access if not telnet_ok.		 */		} else if (url_type == TELNET_URL_TYPE ||			   url_type == TN3270_URL_TYPE ||			   url_type == TELNET_GOPHER_URL_TYPE) {		    if (!telnet_ok) {			_statusline(TELNET_DISABLED);			sleep(MessageSecs);		    } else if (no_telnet_port && strchr(doc->address+7, ':')) {			statusline(TELNET_PORT_SPECS_DISABLED);			sleep(MessageSecs);		    } else {			stop_curses();			HTLoadAbsolute(&WWWDoc);			start_curses();			fflush(stdout);			LYAddVisitedLink(doc);		    }		    return(NULLFILE);		/*		 *  Disable www news access if not news_ok.		 */		} else if (url_type == NEWS_URL_TYPE && !news_ok) {		    _statusline(NEWS_DISABLED);		    sleep(MessageSecs);		    return(NULLFILE);		} else if (url_type == RLOGIN_URL_TYPE) {		    if (!rlogin_ok) {			statusline(RLOGIN_DISABLED);			sleep(MessageSecs);		    } else {			stop_curses();			HTLoadAbsolute(&WWWDoc);			fflush(stdout);			start_curses();			LYAddVisitedLink(doc);		    }		    return(NULLFILE);		/*		 *  If its a gopher index type and there isn't a search		 *  term already attached then do this.  Otherwise		 *  just load it!		 */		} else if (url_type == INDEX_GOPHER_URL_TYPE &&					strchr(doc->address,'?') == NULL) {		    int status;		    /*		     *	Make sure we don't have a gopher+ escaped tab		     *	instead of a gopher0 question mark delimiting		     *	the search term. - FM		     */		    if ((cp = strstr(doc->address, "%09")) != NULL) {			*cp = '\0';			StrAllocCopy(temp, doc->address);			cp += 3;			if (*cp && strncmp(cp, "%09", 3)) {			    StrAllocCat(temp, "?");			    StrAllocCat(temp, cp);			    if ((cp = strstr(temp, "%09")) != NULL) {				*cp = '\0';			    }			}			StrAllocCopy(doc->address, temp);			FREE(temp);			goto Try_Redirected_URL;		    }		    /*		     *	Load it because the do_www_search routine		     *	uses the base url of the currently loaded		     *	document :(		     */		    if (!HTLoadAbsolute(&WWWDoc))			return(NOT_FOUND);		    status = do_www_search(doc);		    if (status == NULLFILE) {			LYpop(doc);			WWWDoc.address = doc->address;			WWWDoc.post_data = doc->post_data;			WWWDoc.post_content_type = doc->post_content_type;			WWWDoc.bookmark = doc->bookmark;			WWWDoc.isHEAD = doc->isHEAD;			WWWDoc.safe = doc->safe;			status = HTLoadAbsolute(&WWWDoc);		    }		    return(status);		} else {		    if (url_type == FTP_URL_TYPE && !ftp_ok) {			statusline(FTP_DISABLED);			sleep(MessageSecs);			return(NULLFILE);		    }		    if (url_type == HTML_GOPHER_URL_TYPE) {			char *tmp=NULL;		       /*			*  If tuple's Path=GET%20/... convert to an http URL.			*/			if ((cp=strchr(doc->address+9, '/')) != NULL &&			   0==strncmp(++cp, "hGET%20/", 8)) {			    StrAllocCopy(tmp, "http://");			    if (TRACE)				fprintf(stderr,					"getfile: URL '%s'\n",					doc->address);			    *cp = '\0';			    StrAllocCat(tmp, doc->address+9);			   /*			    *  If the port is defaulted, it should stay 70.			    */			    if (strchr(tmp+6, ':') == NULL) {				StrAllocCat(tmp, "70/");				tmp[strlen(tmp)-4] = ':';			    }			    if (strlen(cp+7) > 1)				StrAllocCat(tmp, cp+8);			    StrAllocCopy(doc->address, tmp);			    if (TRACE)				fprintf(stderr, "  changed to '%s'\n",						doc->address);			    FREE(tmp);			    url_type = HTTP_URL_TYPE;			}		    }		    if (url_type == HTTP_URL_TYPE ||			url_type == HTTPS_URL_TYPE ||			url_type == FTP_URL_TYPE ||			url_type == CSO_URL_TYPE)			fix_http_urls(doc);		    WWWDoc.address = doc->address;  /* possible reload */#ifdef DIRED_SUPPORT		    lynx_edit_mode = FALSE;#endif /* DIRED_SUPPORT */		    if (url_type == FILE_URL_TYPE) {			/*			 *  If a file URL has a '~' as the lead character			 *  of its first symbolic element, convert the '~'			 *  to Home_Dir(), then append the rest of of path,			 *  if present, skipping "user" if "~user" was			 *  entered, simplifying, and eliminating any			 *  residual relative elements. - FM			 */			if (((cp = HTParse(doc->address, "",				   PARSE_PATH+PARSE_ANCHOR+PARSE_PUNCTUATION))			      != NULL) &&			    !strncmp(cp, "/~", 2)) {			    char *cp1 = strstr(doc->address, "/~");			    char *cp2;			    if (TRACE)				fprintf(stderr, "getfile: URL '%s'\n",						doc->address);			    *cp1 = '\0';			    cp1 += 2;			    StrAllocCopy(temp, doc->address);#ifdef DOSPATH			    StrAllocCat(temp, "/");			    StrAllocCat(temp, HTDOS_wwwName((char *)Home_Dir()));#else#ifdef VMS			    StrAllocCat(temp,					HTVMS_wwwName((char *)Home_Dir()));#else			    StrAllocCat(temp, Home_Dir());#endif /* VMS */#endif /* DOSPATH */			    if ((cp2 = strchr(cp1, '/')) != NULL) {				LYTrimRelFromAbsPath(cp2);				StrAllocCat(temp, cp2);			    }			    StrAllocCopy(doc->address, temp);			    FREE(temp);			    if (TRACE)				fprintf(stderr, "  changed to '%s'\n",						doc->address);			    WWWDoc.address = doc->address;			}			FREE(cp);		    }		    if (TRACE && LYTraceLogFP == NULL)			sleep(MessageSecs);		    user_message(WWW_WAIT_MESSAGE, doc->address);#ifdef NOTDEFINED		    sleep(InfoSecs);#endif /* NOTDEFINED */		    if (TRACE) {#ifdef USE_SLANG			if (LYCursesON) {			    addstr("*\n");			    refresh();			}#endif /* USE_SLANG */			fprintf(stderr,"\n");		    }		    if ((LYNoRefererHeader == FALSE &&			 LYNoRefererForThis == FALSE) &&			(url_type == HTTP_URL_TYPE ||			 url_type == HTTPS_URL_TYPE) &&			(cp = strchr(HTLoadedDocumentURL(), '?')) != NULL &&			strchr(cp, '=') != NULL) {			/*			 *  Don't send a Referer header if the URL is			 *  the reply from a form with method GET, in			 *  case the content has personal data (e.g.,			 *  a password or credit card number) which			 *  would become visible in logs. - FM			 */			LYNoRefererForThis = TRUE;		    }		    cp = NULL;		    if (!HTLoadAbsolute(&WWWDoc)) {			/*			 *  Check for redirection.			 */			if (use_this_url_instead != NULL) {			    char *pound;			    if (!is_url(use_this_url_instead)) {				/*				 *  The server did not return a complete				 *  URL in its Location: header, probably				 *  due to a FORM or other CGI script written				 *  by someone who doesn't know that the http				 *  protocol requires that it be a complete				 *  URL, or using a server which does not treat				 *  such a redirect string from the script as				 *  an instruction to resolve it versus the				 *  initial request, check authentication with				 *  that URL, and then act on it without				 *  returning redirection to us.  We'll				 *  violate the http protocol and resolve it				 *  ourselves using the URL of the original				 *  request as the BASE, rather than doing				 *  the RIGHT thing and returning an invalid				 *  address message. - FM				 */				HTAlert(LOCATION_NOT_ABSOLUTE);				temp = HTParse(use_this_url_instead,					       WWWDoc.address,					       PARSE_ALL);				if (temp && *temp) {				    StrAllocCopy(use_this_url_instead, temp);				}				FREE(temp);			    }			    HTMLSetCharacterHandling(current_char_set);			    url_type = is_url(use_this_url_instead);			    if (url_type == LYNXDOWNLOAD_URL_TYPE ||				url_type == LYNXEXEC_URL_TYPE ||				url_type == LYNXPROG_URL_TYPE ||#ifdef DIRED_SUPPORT				url_type == LYNXDIRED_URL_TYPE ||#endif /* DIRED_SUPPORT */				url_type == LYNXPRINT_URL_TYPE ||				url_type == LYNXHIST_URL_TYPE ||				url_type == LYNXCOOKIE_URL_TYPE ||				(LYValidate &&				 url_type != HTTP_URL_TYPE &&				 url_type != HTTPS_URL_TYPE) ||				((no_file_url || no_goto_file) &&				 url_type == FILE_URL_TYPE) ||				(no_goto_lynxcgi &&				 url_type == LYNXCGI_URL_TYPE) ||				(no_goto_cso &&				 url_type == CSO_URL_TYPE) ||				(no_goto_finger &&				 url_type == FINGER_URL_TYPE) ||				(no_goto_ftp &&				 url_type == FTP_URL_TYPE) ||				(no_goto_gopher &&				 url_type == GOPHER_URL_TYPE) ||				(no_goto_http &&				 url_type == HTTP_URL_TYPE) ||				(no_goto_https &&				 url_type == HTTPS_URL_TYPE) ||				(no_goto_mailto &&				 url_type == MAILTO_URL_TYPE) ||				(no_goto_news &&				 url_type == NEWS_URL_TYPE) ||				(no_goto_nntp &&				 url_type == NNTP_URL_TYPE) ||				(no_goto_rlogin &&				 url_type == RLOGIN_URL_TYPE) ||				(no_goto_snews &&				 url_type == SNEWS_URL_TYPE) ||				(no_goto_telnet &&				 url_type == TELNET_URL_TYPE) ||				(no_goto_tn3270 &&				 url_type == TN3270_URL_TYPE) ||				(no_goto_wais &&				 url_type == WAIS_URL_TYPE)) {				/*				 *  Some schemes are not acceptable from				 *  server redirections. - KW & FM				 */				HTAlert(ILLEGAL_REDIRECTION_URL);				if (LYCursesON) {				    _user_message(WWW_ILLEGAL_URL_MESSAGE,						  use_this_url_instead);				    sleep(AlertSecs);				} else {				    fprintf(stderr,					    "Illegal Redirection URL: %s",					    use_this_url_instead);				}				FREE(use_this_url_instead);				return(NULLFILE);			    }			    if ((pound = strchr(doc->address, '#')) != NULL &&				strchr(use_this_url_instead, '#') == NULL) {				/*				 *  Our requested URL had a fragment				 *  associated with it, and the redirection				 *  URL doesn't, so we'll append the fragment				 *  associated with the original request.  If				 *  it's bogus for the redirection URL, we'll				 *  be positioned at the top of that document,				 *  so there's no harm done. - FM				 */				if (TRACE) {				    fprintf(stderr,			"getfile: Adding fragment '%s' to redirection URL.\n",				    pound);				}				StrAllocCat(use_this_url_instead, pound);			    }			    if (TRACE && LYTraceLogFP == NULL)				sleep(MessageSecs);			    _user_message(WWW_USING_MESSAGE,					  use_this_url_instead);			    sleep(InfoSecs);			    if (TRACE)				fprintf(stderr, "\n");			    StrAllocCopy(doc->address,					use_this_url_instead);			    FREE(use_this_url_instead);			    if (redirect_post_content == FALSE) {				/*				 *  Freeing the content also yields				 *  a GET request. - FM				 */				FREE(doc->post_data);				FREE(doc->post_content_type);			    }			    /*			     *	Go to top to check for URL's which get			     *	special handling and/or security checks			     *	in Lynx. - FM			     */			    goto Try_Redirected_URL;			}			HTMLSetCharacterHandling(current_char_set);			return(NOT_FOUND);		    }		    lynx_mode = NORMAL_LYNX_MODE;		    /*		     *	Some URL's don't actually return a document		     *	compare doc->address with the document that is		     *	actually loaded and return NULL if not		     *	loaded.  If www_search_result is not -1		     *	then this is a reference to a named anchor		     *	within the same document.  Do NOT return		     *	NULL.		     */		    {			char *pound;			/*			 *  Check for a #fragment selector.			 */			pound = (char *)strchr(doc->address, '#');			/*			 *  Check to see if there is a temp			 *  file waiting for us to download.			 */			if (WWW_Download_File) {			    HTParentAnchor *tmpanchor;			    char *fname = NULL;			    HTMLSetCharacterHandling(current_char_set);			    /*			     *	Check for a suggested filename from			     *	the Content-Dispostion header. - FM			     */			    if (((tmpanchor = HTAnchor_parent(						HTAnchor_findAddress(&WWWDoc)							     )) != NULL) &&				HTAnchor_SugFname(tmpanchor) != NULL) {				StrAllocCopy(fname,					     HTAnchor_SugFname(tmpanchor));			    } else {				StrAllocCopy(fname, doc->address);			    }			    /*			     *	Check whether this is a compressed file,			     *	which we don't uncompress for downloads,			     *	and adjust any suffix appropriately. - FM			     */			    if (tmpanchor != NULL) {				HTCheckFnameForCompression(&fname, tmpanchor,							   FALSE);			    }			    if (LYdownload_options(&fname,

⌨️ 快捷键说明

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