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

📄 lybookmark.c

📁 基于rtos开发的浏览器!
💻 C
📖 第 1 页 / 共 2 页
字号:
    }#ifdef VMS    sprintf(newfile, "%s-%d", filename_buffer, getpid());#else    tempname(newfile, NEW_FILE);#endif /* VMS */    if ((nfp = LYNewTxtFile(newfile)) == NULL) {	fclose(fp);#ifdef VMS	_statusline(BOOKSCRA_OPEN_FAILED_FOR_DEL);#else	_statusline(BOOKTEMP_OPEN_FAILED_FOR_DEL);#endif /* VMS */	sleep(AlertSecs);	return;    }#ifdef UNIX    /*     *  Explicitly preserve bookmark file mode on Unix. - DSL     */    if (stat(filename_buffer, &stat_buf) == 0) {	mode = ((stat_buf.st_mode & 0777) | HIDE_CHMOD);	(void) fclose(nfp);	nfp = NULL;	(void) chmod(newfile, mode);	if ((nfp = fopen(newfile, "a")) == NULL) {	    (void) fclose(fp);	    _statusline(BOOKTEMP_REOPEN_FAIL_FOR_DEL);	    sleep(AlertSecs);	    return;	}    }#endif /* UNIX */    if (is_mosaic_hotlist) {	int del_line = cur*2;  /* two lines per entry */	n = -3;  /* skip past cookie and name lines */        while (fgets(buf, sizeof(buf), fp) != NULL) {	    n++;	    if (n == del_line || n == del_line+1) 		continue;  /* remove two lines */            if (fputs(buf, nfp) == EOF)                goto failure;	}    } else {	char *cp;	BOOLEAN retain;	int seen;        n = -1;        while (fgets(buf, sizeof(buf), fp) != NULL) {	    retain = TRUE;	    seen = 0;	    cp = buf;            while (n < cur && (cp = LYstrstr(cp, "<a href="))) {		seen++;                if (++n == cur) {		    if (seen != 1 || !LYstrstr(buf, "</a>") ||			LYstrstr((cp + 1), "<a href=")) {			_statusline(BOOKMARK_LINK_NOT_ONE_LINE);			sleep(AlertSecs);			goto failure;		    }		    if (TRACE)	    		fprintf(stderr,				"remove_bookmark_link: skipping link %d\n", n);                    retain = FALSE;		}		cp += 8;            }            if (retain && fputs(buf, nfp) == EOF)                goto failure;        }    }    if (TRACE)	fprintf(stderr, "remove_bookmark_link: files: %s %s\n",			newfile, filename_buffer);    fclose(fp);    fp = NULL;    fclose(nfp);    nfp = NULL;#ifdef DOSPATH    remove(filename_buffer);#endif /* DOSPATH */    if (rename(newfile, filename_buffer) != -1) {#ifdef VMS	char VMSfilename[256];	/*	 *  Purge lower version of file.	 */	sprintf(VMSfilename, "%s;-1", filename_buffer);        while (remove(VMSfilename) == 0)	    ;	/*	 *  Reset version number.	 */	sprintf(VMSfilename, "%s;1", filename_buffer);	rename(filename_buffer, VMSfilename);#endif /* VMS */        return;    } else {#ifndef VMS	/*	 *  Rename won't work across file systems.	 *  Check if this is the case and do something appropriate.	 *  Used to be ODD_RENAME	 */#ifdef _WINDOWS        if (errno == ENOTSAM) {#else	if (errno == EXDEV) {#endif /* WINDOWS */ 	    char buffer[2048];	    sprintf(buffer, "%s %s %s", MV_PATH, newfile, filename_buffer);	    system(buffer);	    return;	}#endif /* !VMS */#ifdef VMS	_statusline(ERROR_RENAMING_SCRA);#else	_statusline(ERROR_RENAMING_TEMP);#endif /* VMS */	if (TRACE)	    perror("renaming the file");	sleep(AlertSecs);    }	   failure:    _statusline(BOOKMARK_DEL_FAILED);    sleep(AlertSecs);    if (nfp != NULL)	fclose(nfp);    if (fp != NULL)        fclose(fp);    remove(newfile);}/* *  Allows user to select sub-bookmarks files. - FMG & FM */PUBLIC int select_multi_bookmarks NOARGS{    int c;    /*     *  If not enabled, pick the "default" (0).     */    if (LYMultiBookmarks == FALSE || LYHaveSubBookmarks() == FALSE) {	if (MBM_A_subbookmark[0]) /* If it exists! */            return(0);	else            return(-1);    }    /*     *  For ADVANCED users, we can just mess with the status line to save     *  the 2 redraws of the screen, if LYMBMAdvnced is TRUE.  '=' will     *  still show the screen and let them do it the "long" way.     */    if (LYMBMAdvanced && user_mode == ADVANCED_MODE) {	LYMBM_statusline(MULTIBOOKMARKS_SELECT);get_advanced_choice:	c = LYgetch();#ifdef VMS	if (HadVMSInterrupt) {	    HadVMSInterrupt = FALSE;	    c = 7;        }#endif /* VMS */	if (LYisNonAlnumKeyname(c, LYK_PREV_DOC) ||	    c == 7 || c == 3) {	    /*	     *  Treat left-arrow, ^G, or ^C as cancel.	     */	    return(-2);	}	if (LYisNonAlnumKeyname(c, LYK_REFRESH)) {	    /*	     *  Refresh the screen.	     */	    lynx_force_repaint();	    refresh();	    goto get_advanced_choice;	}	if (LYisNonAlnumKeyname(c, LYK_ACTIVATE)) {	    /*	     *  Assume default bookmark file on ENTER or right-arrow.	     */	    return (MBM_A_subbookmark[0] ? 0 : -1);	}	switch (c) {	    case '=':	        /*		 *  Get the choice via the menu.		 */		return(select_menu_multi_bookmarks());	    default:	        /*		 *  Convert to an array index, act on it if valid.		 *  Otherwise, get another keystroke.		 */		c = TOUPPER(c) - 'A';		if (c < 0 || c > MBM_V_MAXFILES) {		    goto get_advanced_choice;		}	}	/*	 *  See if we have a bookmark like that.	 */	return (MBM_A_subbookmark[c] ? c : -1);    } else {        /*	 *  Get the choice via the menu.	 */	return(select_menu_multi_bookmarks());    }}/* *  Allows user to select sub-bookmarks files. - FMG & FM */PUBLIC int select_menu_multi_bookmarks NOARGS{    int c, MBM_tmp_count, MBM_allow;    int MBM_screens, MBM_from, MBM_to, MBM_current;    char string_buffer[256];    char shead_buffer[256];    /*     *  If not enabled, pick the "default" (0).     */    if (LYMultiBookmarks == FALSE)	return(0);    /*     *  Filip M. Gieszczykiewicz (filipg@paranoia.com) & FM     *  ---------------------------------------------------     *  LYMultiBookmarks - TRUE when multi_support enabled.     *     *  MBM_A_subbookmark[n] - Hold values of the respective     *  "multi_bookmarkn" in the lynxrc file.     *     *  MBM_A_subdescript[n] - Hold description entries in the     *  lynxrc file.     *     *  Note: MBM_A_subbookmark[0] is defined to be same value as     *        "bookmark_file" in the lynxrc file and/or the startup     *        "bookmark_page".     *     *  We make the display of bookmarks depend on rows we have     *  available.     *     *  We load BookmarkPage with the valid MBM_A_subbookmark[n]     *  via get_bookmark_filename().  Otherwise, that function     *  returns a zero-length string to indicate a cancel, a     *  single space to indicate an invalid choice, or NULL to     *  indicate an inaccessible file.     */    MBM_allow=(LYlines-7);	/* We need 7 for header and footer */    /*     *  Screen big enough?     */    if (MBM_allow <= 0) {        /*	 *  Too small.	 */	_statusline(MULTIBOOKMARKS_SMALL);	sleep(AlertSecs);	return (-2);    }    /*     *  Load the bad choice message buffer.     */    sprintf(string_buffer,    	    BOOKMARK_FILE_NOT_DEFINED,	    key_for_func(LYK_OPTIONS));    MBM_screens = (MBM_V_MAXFILES/MBM_allow)+1; /* int rounds off low. */    MBM_current = 1; /* Gotta start somewhere :-) */draw_bookmark_choices:    MBM_from = MBM_allow * MBM_current - MBM_allow;    if (MBM_from < 0)	MBM_from = 0; /* 0 is default bookmark... */    if (MBM_current != 1)	MBM_from++;    MBM_to = (MBM_allow * MBM_current);    if (MBM_to > MBM_V_MAXFILES)	MBM_to = MBM_V_MAXFILES;    /*     *  Display menu of bookmarks.  NOTE that we avoid printw()'s     *  to increase the chances that any non-ASCII or multibyte/CJK     *  characters will be handled properly. - FM     */    clear();    move(1, 5);    lynx_start_h1_color ();    if (MBM_screens > 1) {        sprintf(shead_buffer,		MULTIBOOKMARKS_SHEAD_MASK, MBM_current, MBM_screens);	addstr(shead_buffer);    } else {        addstr(MULTIBOOKMARKS_SHEAD);    }      lynx_stop_h1_color ();    MBM_tmp_count = 0;    for (c = MBM_from; c <= MBM_to; c++) {	move(3+MBM_tmp_count, 5);	addch((unsigned char)(c + 'A'));	addstr(" : ");	if (MBM_A_subdescript[c])	    addstr(MBM_A_subdescript[c]);	move(3+MBM_tmp_count,36);	addch('(');	if (MBM_A_subbookmark[c])	    addstr(MBM_A_subbookmark[c]);	addch(')');	MBM_tmp_count++;    }    /*     *  Don't need to show it if it all fits on one screen!     */    if (MBM_screens > 1) {	move(LYlines-2, 0);	addstr("'");	standout();	addstr("[");	standend();	addstr("' ");	addstr(PREVIOUS);	addstr(", '");	standout();	addstr("]");	standend();	addstr("' ");	addstr(NEXT_SCREEN);    }    LYMBM_statusline(MULTIBOOKMARKS_SAVE);get_bookmark_choice:    c = LYgetch();#ifdef VMS    if (HadVMSInterrupt) {	HadVMSInterrupt = FALSE;	c = 7;    }#endif /* VMS */    if (LYisNonAlnumKeyname(c, LYK_PREV_DOC) ||	c == 7 || c == 3) {	/*	 *  Treat left-arrow, ^G, or ^C as cancel.	 */	return(-2);    }    if (LYisNonAlnumKeyname(c, LYK_REFRESH)) {	/*	 *  Refresh the screen.	 */	lynx_force_repaint();	refresh();	goto get_bookmark_choice;    }    if (LYisNonAlnumKeyname(c, LYK_ACTIVATE)) {	/*	 *  Assume default bookmark file on ENTER or right-arrow.	 */	return(MBM_A_subbookmark[0] ? 0 : -1);    }    /*     *  Next range, if available.     */    if ((c == ']' ||  LYisNonAlnumKeyname(c, LYK_NEXT_PAGE)) &&        MBM_screens > 1) {	if (++MBM_current > MBM_screens)	    MBM_current = 1;	goto draw_bookmark_choices;    }    /*     *  Previous range, if available.     */    if ((c == '[' ||  LYisNonAlnumKeyname(c, LYK_PREV_PAGE)) &&        MBM_screens > 1) {	if (--MBM_current <= 0)	    MBM_current = MBM_screens;	goto draw_bookmark_choices;    }    c = TOUPPER(c) - 'A';    /*     *  See if we have a bookmark like that.     */    if (c < 0 || c > MBM_V_MAXFILES) {	goto get_bookmark_choice;    } else if (!MBM_A_subbookmark[c]) { 	LYMBM_statusline(string_buffer);	sleep(AlertSecs);	LYMBM_statusline(MULTIBOOKMARKS_SAVE);	goto get_bookmark_choice;    } else {	return(c);    }}/* *  This function returns TRUE if we have sub-bookmarks defined. *  Otherwise (i.e., only the default bookmark file is defined), *  it returns FALSE. - FM */PUBLIC BOOLEAN LYHaveSubBookmarks NOARGS{    int i;    for (i = 1; i < MBM_V_MAXFILES; i++) {        if (MBM_A_subbookmark[i] != NULL && *MBM_A_subbookmark[i] != '\0')	    return(TRUE);    }    return(FALSE);}/* *  This function passes a string to _statusline(), making *  sure it is at the bottom of the screen if LYMultiBookmarks *  is TRUE, otherwise, letting it go to the normal statusline *  position based on the current user mode.  We want to use *  _statusline() so that any multibyte/CJK characters in the *  string will be handled properly. - FM */ PUBLIC void LYMBM_statusline  ARGS1( 	char *,		text){    if (LYMultiBookmarks == TRUE && user_mode == NOVICE_MODE) {	LYStatusLine = (LYlines - 1);        _statusline(text);	LYStatusLine = -1;    } else {        _statusline(text);    }}

⌨️ 快捷键说明

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