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

📄 lymainloop.c

📁 基于rtos开发的浏览器!
💻 C
📖 第 1 页 / 共 5 页
字号:
			0==strncmp(newdoc.address, "LYNXIMGMAP:", 11)) {			try_internal = FALSE;		    } else if (curdoc.address &&			0==strncmp(curdoc.address, "LYNXIMGMAP:", 11)) {			try_internal = FALSE;		    }		}		if (try_internal) {		    char *hashp = strchr(newdoc.address,'#');		    if (hashp) {			HTFindPoundSelector(hashp+1);		    }		    getresult = (HTMainText != NULL) ? NORMAL : NOT_FOUND;		    try_internal = FALSE; /* done */		    /* fix up newdoc.address which may have been fragment-only */		    if (getresult == NORMAL && (!hashp || hashp == newdoc.address)) {			if (!hashp) {			    StrAllocCopy(newdoc.address, HTLoadedDocumentURL());			} else {			    StrAllocCopy(temp, HTLoadedDocumentURL());			    StrAllocCat(temp, hashp); /* append fragment */			    StrAllocCopy(newdoc.address, temp);			    FREE(temp);			}		    }		} else {		    if (newdoc.internal_link && newdoc.address &&			*newdoc.address == '#' && nhist > 0) {			char *cp0;			if (0==strncmp(history[nhist-1].address, "LYNXIMGMAP:", 11))			    cp0 = history[nhist-1].address + 11;			else			    cp0 = history[nhist-1].address;			StrAllocCopy(temp, cp0);			cp0 = strchr(temp, '#');			if (cp0)			    *cp0 = '\0';			StrAllocCat(temp, newdoc.address);			FREE(newdoc.address);			newdoc.address = temp;			temp = NULL;		    }		    getresult = getfile(&newdoc);		}#else  /* TRACK_INTERNAL_LINKS */		getresult = getfile(&newdoc);#endif /* TRACK_INTERNAL_LINKS */		switch(getresult) {		case NOT_FOUND:		    /*		     *	OK! can't find the file, so it must not be around now.		     *	Do any error logging, if appropriate.		     */		    LYoverride_no_cache = FALSE; /* Was TRUE if popped. - FM */		    popped_doc = FALSE; 	 /* Was TRUE if popped. - FM */		    LYinternal_flag = FALSE;	 /* Reset to default. - kw */		    if (trace_mode_flag == TRUE) {			WWW_TraceFlag = TRUE;			trace_mode_flag = FALSE;			fprintf(stderr, "Turning TRACE back on.\n\n");		    }		    if (error_logging &&			first_file && owner_address && !LYCancelledFetch) {			/*			 *  Email a bad link message to the owner of			 *  the document (but NOT to lynx-dev). - FM			 */			if (strncasecomp(owner_address, "mailto:", 7)) {			    if (strncasecomp((owner_address + 7),					     "lynx-dev@", 9)) {				mailmsg(curdoc.link,					(owner_address+7),					history[nhist-1].address,					history[nhist-1].title);			    }			}		    }		    if (traversal && !first_file && !LYCancelledFetch) {			FILE *ofp;			if ((ofp = LYAppendToTxtFile(TRAVERSE_ERRORS)) == NULL) {			    if ((ofp = LYNewTxtFile(TRAVERSE_ERRORS)) == NULL) {				perror(NOOPEN_TRAV_ERR_FILE);#ifndef NOSIGHUP				(void) signal(SIGHUP, SIG_DFL);#endif /* NOSIGHUP */				(void) signal(SIGTERM, SIG_DFL);#ifndef VMS				(void) signal(SIGINT, SIG_DFL);#endif /* !VMS */#ifdef SIGTSTP				if (no_suspend)				    (void) signal(SIGTSTP,SIG_DFL);#endif /* SIGTSTP */				exit(-1);			    }			}			fprintf(ofp, "%s %s\tin %s\n",				     links[curdoc.link].lname,				     links[curdoc.link].target,				     history[nhist-1].address);			fclose(ofp);		    }		    /*		     *	Fall through to do the NULL stuff and reload the		     *	old file, unless the first file wasn't found or		     *	has gone missing.		     */		    if (!nhist) {			/*			 *  If nhist = 0 then it must be the first file.			 */			if (!dump_output_immediately)			    cleanup();#ifdef UNIX			if (dump_output_immediately)			    fprintf(stderr,"\nlynx: Can't access startfile %s\n",			       startfile);			else#endif /* UNIX */			    printf("\nlynx: Can't access startfile %s\n",			       startfile);			if (!dump_output_immediately) {#ifndef NOSIGHUP			    (void) signal(SIGHUP, SIG_DFL);#endif /* NOSIGHUP */			    (void) signal(SIGTERM, SIG_DFL);#ifndef VMS			    (void) signal(SIGINT, SIG_DFL);#endif /* !VMS */#ifdef SIGTSTP			    if (no_suspend)				(void) signal(SIGTSTP,SIG_DFL);#endif /* SIGTSTP */			    exit(-1);			}			return(-1);		    }		case NULLFILE:		    /*		     *	Not supposed to return any file.		     */		    LYoverride_no_cache = FALSE; /* Was TRUE if popped. - FM */		    popped_doc = FALSE; 	 /* Was TRUE if popped. - FM */		    LYinternal_flag = FALSE;	 /* Reset to default. - kw */		    if (trace_mode_flag == TRUE) {			WWW_TraceFlag = TRUE;			trace_mode_flag = FALSE;			fprintf(stderr, "Turning TRACE back on.\n\n");		    }		    FREE(newdoc.address); /* to pop last doc */		    FREE(newdoc.bookmark);		    LYJumpFileURL = FALSE;		    reloading = FALSE;		    LYPermitURL = FALSE;		    LYCancelledFetch = FALSE;		    ForcePush = FALSE;		    LYforce_HTML_mode = FALSE;		    if (traversal) {			crawl_ok = FALSE;			if (traversal_link_to_add) {			    /*			     *	It's a binary file, or the fetch attempt			     *	failed.  Add it to TRAVERSE_REJECT_FILE			     *	so we don't try again in this run.			     */			    if (!lookup_reject(traversal_link_to_add)) {				add_to_reject_list(traversal_link_to_add);			    }			    FREE(traversal_link_to_add);			}		    }		   /*		    *  Make sure the first file was found and		    *  has not gone missing.		    */		   if (!nhist) {		       /*			*  If nhist = 0 then it must be the first file.			*/		       if (first_file && homepage &&#ifdef VMS			   strcasecomp(homepage, startfile) != 0#else			   strcmp(homepage, startfile) != 0#endif /* VMS */			   ) {			   /*			    *  Couldn't return to the first file but there is a			    *  homepage we can use instead. Useful for when the			    *  first URL causes a program to be invoked. - GL			    *			    *  But first make sure homepage is different from			    *  startfile (above), then make it the same (below)			    *  so we don't enter an infinite getfile() loop on			    *  on failures to find the files. - FM			    */			   StrAllocCopy(newdoc.address, homepage);			   FREE(newdoc.post_data);			   FREE(newdoc.post_content_type);			   FREE(newdoc.bookmark);			   StrAllocCopy(startfile, homepage);			   newdoc.isHEAD = FALSE;			   newdoc.safe = FALSE;			   newdoc.internal_link = FALSE;			   goto try_again;		       } else {			   if (!dump_output_immediately)			       cleanup();#ifdef UNIX			   if (dump_output_immediately) {			       fprintf(stderr, "\nlynx: Start file could not be found or is not text/html or text/plain\n");			       fprintf(stderr,"      Exiting...\n");			   } else#endif /* UNIX */			   {			       printf( "\nlynx: Start file could not be found or is not text/html or text/plain\n");			       printf("      Exiting...\n");			   }			   if (!dump_output_immediately) {#ifndef NOSIGHUP				(void) signal(SIGHUP, SIG_DFL);#endif /* NOSIGHUP */				(void) signal(SIGTERM, SIG_DFL);#ifndef VMS				(void) signal(SIGINT, SIG_DFL);#endif /* !VMS */#ifdef SIGTSTP				if (no_suspend)				    (void) signal(SIGTSTP,SIG_DFL);#endif /* SIGTSTP */			       exit(-1);			   }			   return(-1);		       }		    }		   /*		    *  Retrieval of a newdoc just failed, and just		    *  going to try_again would pop the next doc		    *  from history and try to get it without further		    *  questions.  This may not be the right thing to do if		    *  we have POST data, so fake a PREV_DOC key if it seems		    *  that some prompting should be done.  Dunno about the		    *  traversal logic, so I leave that case alone.		    */		   if (history[nhist - 1].post_data &&		       !history[nhist - 1].safe) {		       if (HText_POSTReplyLoaded((document *)&history[(nhist - 1)])) {			   override_LYresubmit_posts = TRUE;			   goto try_again;		       }		       /*  Set newdoc fields, just in case the PREV_DOC			*  gets cancelled. - kw */		       if (!curdoc.address) {			   StrAllocCopy(newdoc.address, HTLoadedDocumentURL());			   StrAllocCopy(newdoc.title, HTLoadedDocumentTitle());			   if (HTMainAnchor && HTMainAnchor->post_data) {			       StrAllocCopy(newdoc.post_data,					    HTMainAnchor->post_data);			       StrAllocCopy(newdoc.post_content_type,					    HTMainAnchor->post_content_type);			   } else {			       FREE(newdoc.post_data);			   }			   newdoc.isHEAD = HTLoadedDocumentIsHEAD();			   newdoc.safe = HTLoadedDocumentIsSafe();			   newdoc.internal_link = FALSE;		       } else {			   StrAllocCopy(newdoc.address, curdoc.address);			   StrAllocCopy(newdoc.title, curdoc.title);			   StrAllocCopy(newdoc.post_data, curdoc.post_data);			   StrAllocCopy(newdoc.post_content_type,					curdoc.post_content_type);			   newdoc.isHEAD = curdoc.isHEAD;			   newdoc.safe = curdoc.safe;			   newdoc.internal_link = curdoc.internal_link;			   newdoc.line = curdoc.line;			   newdoc.link = curdoc.link;		       }		       cmd = LYK_PREV_DOC;		       goto new_cmd;		       }		    override_LYresubmit_posts = TRUE;		    goto try_again;		    break;		case NORMAL:		    /*		     *	Marvelously, we got the document!		     */		    LYoverride_no_cache = FALSE; /* Was TRUE if popped. - FM */		    LYinternal_flag = FALSE;	 /* Reset to default. - kw */		    if (trace_mode_flag == TRUE) {			WWW_TraceFlag = TRUE;			trace_mode_flag = FALSE;			fprintf(stderr, "Turning TRACE back on.\n\n");		    }		    *prev_target = '\0';    /* Reset for this document. - FM */		    /*		     *	If it's the first file and we're interactive,		     *	check whether it's a bookmark file which was		     *	not accessed via the -book switch. - FM		     */		    if (((first_file == TRUE) &&			 (dump_output_immediately == FALSE) &&			 !(newdoc.bookmark && *newdoc.bookmark)) &&			((LYisLocalFile(newdoc.address) == TRUE) &&			 !(strcmp((HText_getTitle() ? HText_getTitle() : ""),				  BOOKMARK_TITLE))) &&			(temp = HTParse(newdoc.address, "",				     PARSE_PATH+PARSE_PUNCTUATION)) != NULL) {#ifdef DOSPATH			cp = HTDOS_wwwName((char *)Home_Dir());#else#ifdef VMS			cp = HTVMS_wwwName((char *)Home_Dir());#else			cp = (char *)Home_Dir();#endif /* VMS */#endif /* DOSPATH */			len = strlen(cp);#ifdef VMS			if (!strncasecomp(temp, cp, len) &&			    strlen(temp) > len)#else			if (!strncmp(temp, cp, len) &&			    strlen(temp) > len)#endif /* VMS */			{			    /*			     *	We're interactive and this might be a			     *	bookmark file entered as a startfile			     *	rather than invoked via -book.	Check			     *	if it's in our bookmark file list, and			     *	if so, reload if with the relevant			     *	bookmark elements set. - FM			     */			    if ((cp = (char *)calloc(1,				  (strlen((char *)&temp[len]) + 2))) == NULL)				outofmem(__FILE__, "mainloop");			    if (temp[len] == '/') {				if (strchr((char *)&temp[(len + 1)], '/')) {				    sprintf(cp, ".%s", (char *)&temp[len]);				} else {				    strcpy(cp, (char *)&temp[(len + 1)]);				}			    } else {				strcpy(cp, (char *)&temp[len]);			    }			    for (i = 0; i <= MBM_V_MAXFILES; i++) {				if (MBM_A_subbookmark[i] &&#ifdef VMS				    !strcasecomp(cp, MBM_A_subbookmark[i])#else				    !strcmp(cp, MBM_A_subbookmark[i])#endif /* VMS */				    ) {				    StrAllocCopy(BookmarkPage,						 MBM_A_subbookmark[i]);				    break;				}			    }			    FREE(cp);			    if (i <= MBM_V_MAXFILES) {				FREE(temp);				if (LYValidate) {				    _statusline(BOOKMARKS_DISABLED);				    sleep(AlertSecs);				    return(-1);				}				if ((temp = HTParse(newdoc.address, "",				 PARSE_ACCESS+PARSE_HOST+PARSE_PUNCTUATION))) {				    StrAllocCopy(newdoc.address, temp);				    HTuncache_current_document();				    FREE(curdoc.address);#ifdef DOSPATH				    StrAllocCat(newdoc.address,					    HTDOS_wwwName((char *)Home_Dir()));#else#ifdef VMS				    StrAllocCat(newdoc.address,					    HTVMS_wwwName((char *)Home_Dir()));#else				    StrAllocCat(newdoc.address, Home_Dir());#endif /* VMS */#endif /* DOSPATH */				    StrAllocCat(newdoc.address, "/");				    StrAllocCat(newdoc.address,					(strncmp(BookmarkPage, "./", 2) ?							   BookmarkPage :							(BookmarkPage + 2)));				    StrAllocCopy(newdoc.title, BOOKMARK_TITLE);				    StrAllocCopy(newdoc.bookmark, BookmarkPage);#ifdef USE_HASH				    if (curdoc.style)					StrAllocCopy(newdoc.style, curdoc.style);#endif				    StrAllocCopy(startrealm, newdoc.address);				    FREE(newdoc.post_data);				    FREE(newdoc.post_content_type);				    newdoc.isHEAD = FALSE;				    newdoc.safe = FALSE;				    FREE(temp);				    if (!strcmp(homepage, startfile))					StrAllocCopy(homepage, newdoc.address);				    StrAllocCopy(startfile, newdoc.address);				    if (TRACE)					fprintf(stderr,						"Reloading as bookmarks=%s\n",						newdoc.address);				    goto try_again;				}			    }			}			cp = NULL;		    }		    FREE(temp);		    if (traversal) {			/*			 *  During traversal build up lists of all links			 *  traversed.	Traversal mode is a special			 *  feature for traversing http links in the web.			 */			if (traversal_link_to_add) {			    /*			     *	Add the address we sought to TRAVERSE_FILE.			     */			    if (!lookup(traversal_link_to_add))				add_to_table(traversal_link_to_add);			    FREE(traversal_link_to_add);			}			if (curdoc.address && curdoc.title &&			    strncmp(curdoc.address, "LYNXIMGMAP:", 11))			    /*			     *	Add the address we got to TRAVERSE_FOUND_FILE.			     */			    add_to_traverse_list(curdoc.address, curdoc.title);		    }		    /*		     *	If this was a LYNXDOWNLOAD, we still have curdoc,		     *	not a newdoc, so reset the address, title and		     *	positioning elements. - FM		     */		    if (newdoc.address && curdoc.address &&			!strncmp(newdoc.address, "LYNXDOWNLOAD:", 13)) {			StrAllocCopy(newdoc.address, curdoc.address);			StrAllocCopy(newdoc.title, (curdoc.title ?						    curdoc.title : ""));			StrAllocCopy(newdoc.bookmark, curdoc.bookmark);			newdoc.line = curdoc.line;			newdoc.link = curdoc.link;			newdoc.internal_link = FALSE; /* can't be true. - kw */		    }		    /*		     *	Set Newline to the saved line.	It contains the		     *	line the user was on if s/he has been in the file		     *	before, or it is 1 if this is a new file.		     */		    Newline = newdoc.line;

⌨️ 快捷键说明

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