int code;
int code = 0;
PUBLIC int postoptions ARGS1(    DocInfo *,		newdoc){    PostPair *data = 0;    DocAddress WWWDoc;  /* need on exit */    int i;    int code;    BOOLEAN save_all = FALSE;    int display_char_set_old = current_char_set;    BOOLEAN raw_mode_old = LYRawMode;    BOOLEAN assume_char_set_changed = FALSE;    BOOLEAN need_reload = FALSE;    BOOLEAN need_end_reload = FALSE;#if defined(USE_SLANG) || defined(COLOR_CURSES)    int CurrentShowColor = LYShowColor;#endif    /*-------------------------------------------------     * kludge a link from mbm_menu, the URL was:     * "<a href=\"LYNXOPTIONS://MBM_MENU\">Goto multi-bookmark menu</a>\n"     *--------------------------------------------------*/    if (strstr(newdoc->address, "LYNXOPTIONS://MBM_MENU")) {	FREE(newdoc->post_data);	if (no_bookmark) {	   HTAlert(BOOKMARK_CHANGE_DISALLOWED); /* anonymous */	   return(NULLFILE);	} else if (dump_output_immediately) {	    return(NOT_FOUND);	} else {	   edit_bookmarks();	   return(NULLFILE);	}    }    data = break_data(newdoc->post_data);    if (!data) {	int status;	/*-------------------------------------------------	 * kludge gen_options() call:	 *--------------------------------------------------*/	status = gen_options(&newdoc->address);	if (status != NORMAL) {	    HTAlwaysAlert("Unexpected way of accessing", newdoc->address);	    FREE(newdoc->address);	    return(status);	}	/* exit to getfile() cycle */	WWWDoc.address = newdoc->address;	WWWDoc.post_data = newdoc->post_data;	WWWDoc.post_content_type = newdoc->post_content_type;	WWWDoc.bookmark = newdoc->bookmark;	WWWDoc.isHEAD = newdoc->isHEAD;	WWWDoc.safe = newdoc->safe;	if (!HTLoadAbsolute(&WWWDoc))	    return(NOT_FOUND);	LYRegisterUIPage(newdoc->address, UIP_OPTIONS_MENU);#ifdef DIRED_SUPPORT	lynx_edit_mode = FALSE;#endif /* DIRED_SUPPORT */	return(NORMAL);    }    if (!LYIsUIPage3(HTLoadedDocumentURL(), UIP_OPTIONS_MENU, 0) &&	!LYIsUIPage3(HTLoadedDocumentURL(), UIP_VLINKS, 0)) {	char *buf = NULL;	/*  We may have been spoofed? */	HTSprintf0(&buf,		   gettext("Use %s to invoke the Options menu!"),		   key_for_func_ext(LYK_OPTIONS, FOR_PANEL));	HTAlert(buf);	FREE(buf);	FREE(data);	return(NOT_FOUND);    }    for (i = 0; data[i].tag != NULL; i++) {	/*	 *  This isn't really for security, but rather for avoiding that	 *  the user may revisit an older instance from the history stack	 *  and submit stuff which accidentally undoes changes that had	 *  been done from a newer instance. - kw	 */	if (!strcmp(data[i].tag, secure_string)) {	    if (!secure_value || strcmp(data[i].value, secure_value)) {		char *buf = NULL;		/*		 * We probably came from an older instance of the Options		 * page that had been on the history stack. - kw		 */		HTSprintf0(&buf,			   gettext("Use %s to invoke the Options menu!"),			   key_for_func_ext(LYK_OPTIONS, FOR_PANEL));		HTAlert(buf);		FREE(data);		return(NULLFILE);	    }	    FREE(secure_value);	}	/* Save options */	if (!strcmp(data[i].tag, save_options_string) && (!no_option_save)) {	    save_all = TRUE;	}	/* Cookies: SELECT */	if (!strcmp(data[i].tag, cookies_string)) {	    if (!strcmp(data[i].value, cookies_ignore_all_string)) {		LYSetCookies = FALSE;	    } else if (!strcmp(data[i].value, cookies_up_to_user_string)) {		LYSetCookies = TRUE;		LYAcceptAllCookies = FALSE;	    } else if (!strcmp(data[i].value, cookies_accept_all_string)) {		LYSetCookies = TRUE;		LYAcceptAllCookies = TRUE;	    }	}	/* X Display: INPUT */	if (!strcmp(data[i].tag, x_display_string)) {	    LYsetXDisplay(data[i].value);	    validate_x_display();	    summarize_x_display(data[i].value);	}	/* Editor: INPUT */	if (!strcmp(data[i].tag, editor_string)) {	    FREE(editor);	    StrAllocCopy(editor, data[i].value);	}	/* Emacs keys: ON/OFF */	if (!strcmp(data[i].tag, emacs_keys_string)	 && GetOptValues(bool_values, data[i].value, &code)) {	    if ((emacs_keys = (BOOL) code) != FALSE) {		set_emacs_keys();	    } else {		reset_emacs_keys();	    }	}	/* Execution links: SELECT */#if defined(ENABLE_OPTS_CHANGE_EXEC) && (defined(EXEC_LINKS) || defined(EXEC_SCRIPTS))	if (!strcmp(data[i].tag, exec_links_string)	 && GetOptValues(exec_links_values, data[i].value, &code)) {#ifndef NEVER_ALLOW_REMOTE_EXEC	    local_exec = (code == EXEC_ALWAYS);#endif /* !NEVER_ALLOW_REMOTE_EXEC */	    local_exec_on_local_files = (code == EXEC_LOCAL);	}#endif /* ENABLE_OPTS_CHANGE_EXEC */	/* Keypad Mode: SELECT */	if (!strcmp(data[i].tag, keypad_mode_string)) {	    int newval;	    if (GetOptValues(keypad_mode_values, data[i].value, &newval)		 && keypad_mode != newval) {		keypad_mode = newval;		need_reload = TRUE;		if (keypad_mode == NUMBERS_AS_ARROWS) {		    set_numbers_as_arrows();		} else {		    reset_numbers_as_arrows();		}	    }	}	/* Line edit style: SELECT */	if (!strcmp(data[i].tag, lineedit_mode_string)) {	    int newval = atoi(data[i].value);	    int j;	    /* prevent spoofing attempt */	    for (j = 0; LYLineeditNames[j]; j++) {		if (j==newval)	current_lineedit = newval;	    }	}#ifdef EXP_KEYBOARD_LAYOUT	/* Keyboard layout: SELECT */	if (!strcmp(data[i].tag, kblayout_string)) {	    int newval = atoi(data[i].value);	    int j;	    /* prevent spoofing attempt */	    for (j = 0; LYKbLayoutNames[j]; j++) {		if (j==newval)	current_layout = newval;	    }	}#endif /* EXP_KEYBOARD_LAYOUT */	/* Mail Address: INPUT */	if (!strcmp(data[i].tag, mail_address_string)) {	    FREE(personal_mail_address);	    StrAllocCopy(personal_mail_address, data[i].value);	}	/* Search Type: SELECT */	if (!strcmp(data[i].tag, search_type_string)	 && GetOptValues(search_type_values, data[i].value, &code)) {	    case_sensitive = (BOOL) code;	}	/* HTML error tolerance: SELECT */	if (!strcmp(data[i].tag, DTD_recovery_string)	 && GetOptValues(DTD_type_values, data[i].value, &code)) {	    if (Old_DTD != code) {		Old_DTD = code;		HTSwitchDTD(!Old_DTD);		need_reload = TRUE;	    }	}	/* Select Popups: ON/OFF */	if (!strcmp(data[i].tag, select_popups_string)	 && GetOptValues(bool_values, data[i].value, &code)) {	    LYSelectPopups = (BOOL) code;	}#if defined(USE_SLANG) || defined(COLOR_CURSES)	/* Show Color: SELECT */	if (!strcmp(data[i].tag, show_color_string)	 && GetOptValues(show_color_values, data[i].value,			 &LYChosenShowColor)) {	    if (can_do_colors)		LYShowColor = LYChosenShowColor;	    if (CurrentShowColor != LYShowColor) {		lynx_force_repaint();	    }	    CurrentShowColor = LYShowColor;#ifdef USE_SLANG	    SLtt_Use_Ansi_Colors = (LYShowColor > SHOW_COLOR_OFF ? TRUE : FALSE);#endif	}#endif /* USE_SLANG || COLOR_CURSES */	/* Show Cursor: ON/OFF */	if (!strcmp(data[i].tag, show_cursor_string)	 && GetOptValues(bool_values, data[i].value, &code)) {	    LYShowCursor = (BOOL) code;	}	/* Underline links: ON/OFF */	if (!strcmp(data[i].tag, underline_links_string)	 && GetOptValues(bool_values, data[i].value, &code)) {	    LYUnderlineLinks = (BOOL) code;	}#ifdef USE_SCROLLBAR	/* Show Scrollbar: ON/OFF */	if (!strcmp(data[i].tag, show_scrollbar_string)	 && GetOptValues(bool_values, data[i].value, &code)) {	    LYShowScrollbar = (BOOL) code;	}#endif	/* Cookie Prompting: SELECT */	if (!strcmp(data[i].tag, cookie_prompt_string))	    GetOptValues(prompt_values, data[i].value, &cookie_noprompt);#ifdef USE_SSL	/* SSL Prompting: SELECT */	if (!strcmp(data[i].tag, ssl_prompt_string))	    GetOptValues(prompt_values, data[i].value, &ssl_noprompt);#endif	/* User Mode: SELECT */	if (!strcmp(data[i].tag, user_mode_string)	 && GetOptValues(user_mode_values, data[i].value, &user_mode)) {	    if (user_mode == NOVICE_MODE) {		display_lines = (LYlines - 4);	    } else {		display_lines = LYlines-2;	    }	}	/* Type of visited pages page: SELECT */	if (!strcmp(data[i].tag, visited_links_string))	   GetOptValues(visited_links_values, data[i].value, &Visited_Links_As);	/* Show Images: SELECT */	if (!strcmp(data[i].tag, images_string)) {	    if (!strcmp(data[i].value, images_ignore_all_string)			&& !(pseudo_inline_alts == FALSE && clickable_images == FALSE)) {		pseudo_inline_alts = FALSE;		clickable_images = FALSE;		need_reload = TRUE;	    } else if (!strcmp(data[i].value, images_use_label_string)			&& !(pseudo_inline_alts == TRUE && clickable_images == FALSE)) {		pseudo_inline_alts = TRUE;		clickable_images = FALSE;		need_reload = TRUE;	    } else if (!strcmp(data[i].value, images_use_links_string)			&& !(clickable_images == TRUE)) {		clickable_images = TRUE;		need_reload = TRUE;	    }	}	/* Verbose Images: ON/OFF */	if (!strcmp(data[i].tag, verbose_images_string)	 && GetOptValues(verbose_images_type_values, data[i].value, &code)) {	    if (verbose_img != code) {		verbose_img = (BOOL) code;		need_reload = TRUE;	    }	}	/* VI Keys: ON/OFF */	if (!strcmp(data[i].tag, vi_keys_string)	 && GetOptValues(bool_values, data[i].value, &code)) {	    if ((vi_keys = (BOOL) code) != FALSE) {		set_vi_keys();	    } else {		reset_vi_keys();	    }	}	/* Bookmarks File Menu: SELECT */	if (!strcmp(data[i].tag, mbm_string) && (!LYMBMBlocked)) {	    GetOptValues(mbm_values, data[i].value, &LYMultiBookmarks);	}	/* Default Bookmarks filename: INPUT */	if (!strcmp(data[i].tag, single_bookmark_string) && (!no_bookmark)) {	    if (strcmp(data[i].value, "")) {		FREE(bookmark_page);		StrAllocCopy(bookmark_page, data[i].value);	    }	}	/* Assume Character Set: SELECT */	if (!strcmp(data[i].tag, assume_char_set_string)) {	    int newval = UCGetLYhndl_byMIME(data[i].value);	    if (newval >= 0	     && ((raw_mode_old &&		     newval != safeUCGetLYhndl_byMIME(UCAssume_MIMEcharset))	      || (!raw_mode_old &&		     newval != UCLYhndl_for_unspec)		)) {		UCLYhndl_for_unspec = newval;		StrAllocCopy(UCAssume_MIMEcharset, data[i].value);		assume_char_set_changed = TRUE;	    }	}#ifdef EXP_LOCALE_CHARSET	/* Use locale-based character set: ON/OFF */	if (!strcmp(data[i].tag, locale_charset_string)	 && GetOptValues(bool_values, data[i].value, &code)) {	    LYLocaleCharset = (BOOL) code;	}#endif	/* Display Character Set: SELECT */	if (!strcmp(data[i].tag, display_char_set_string)) {	    int newval = atoi(data[i].value);	    int j;	    /* prevent spoofing attempt */	    for (j = 0; LYchar_set_names[j]; j++) {		if (j==newval)	current_char_set = newval;	    }	}	/* Raw Mode: ON/OFF */	if (!strcmp(data[i].tag, raw_mode_string)	 && GetOptValues(bool_values, data[i].value, &code)) {	    LYRawMode = (BOOL) code;	}	/*	 * ftp sort: SELECT	 */	if (!strcmp(data[i].tag, ftp_sort_string)) {	    GetOptValues(ftp_sort_values, data[i].value, &HTfileSortMethod);	}#ifdef DIRED_SUPPORT	/* Local Directory Style: SELECT */	if (!strcmp(data[i].tag, dired_list_string)) {	    GetOptValues(dired_list_values, data[i].value, &dir_list_style);	}#ifdef LONG_LIST	/* Local Directory Order: SELECT */	if (!strcmp(data[i].tag, dired_sort_string)) {	    GetOptValues(dired_sort_values, data[i].value, &dir_list_order);	}#endif /* LONG_LIST */#endif /* DIRED_SUPPORT */	/* Show dot files: ON/OFF */	if (!strcmp(data[i].tag, show_dotfiles_string) && (!no_dotfiles)	 && GetOptValues(bool_values, data[i].value, &code)) {	    show_dotfiles = (BOOL) code;	}#ifdef USE_READPROGRESS	/* Show Transfer Rate: enumerated value */	if (!strcmp(data[i].tag, show_rate_string)	 && GetOptValues(rate_values, data[i].value, &code)) {	    LYTransferRate = code;	}#endif /* USE_READPROGRESS */	/* Preferred Document Character Set: INPUT */	if (!strcmp(data[i].tag, preferred_doc_char_string)) {	    if (strcmp(pref_charset, data[i].value)) {		FREE(pref_charset);		StrAllocCopy(pref_charset, data[i].value);		need_end_reload = TRUE;	   }	}	/* Preferred Document Language: INPUT */	if (!strcmp(data[i].tag, preferred_doc_lang_string)) {	    if (strcmp(language, data[i].value)) {		FREE(language);		StrAllocCopy(language, data[i].value);		need_end_reload = TRUE;	    }	}	/* User Agent: INPUT */	if (!strcmp(data[i].tag, user_agent_string) && (!no_useragent)) {	    if (strcmp(LYUserAgent, data[i].value)) {		need_end_reload = TRUE;		FREE(LYUserAgent);		/* ignore Copyright warning ? */		StrAllocCopy(LYUserAgent,		   *(data[i].value)		   ? data[i].value		   : LYUserAgentDefault);		if (!LYCheckUserAgent()) {		    HTAlert(UA_PLEASE_USE_LYNX);		}	    }	}    } /* end of loop */    /*     * Process the flags:     */#ifdef EXP_LOCALE_CHARSET    LYFindLocaleCharset();#endif    if ( display_char_set_old != current_char_set ||	 raw_mode_old != LYRawMode ||	 assume_char_set_changed ) {	/*	 * charset settings: the order is essential here.	 */	if (display_char_set_old != current_char_set) {	    /*	     *  Set the LYUseDefaultRawMode value and character	     *  handling if LYRawMode was changed. - FM	     */	    LYUseDefaultRawMode = TRUE;	    HTMLUseCharacterSet(current_char_set);#ifdef CAN_SWITCH_DISPLAY_CHARSET	    /* Deduce whether the user wants autoswitch: */	    switch_display_charsets =		 (current_char_set == auto_display_charset		  || current_char_set == auto_other_display_charset);#endif	}	if (assume_char_set_changed && HTCJK != JAPANESE) {	    LYRawMode = (BOOL) (UCLYhndl_for_unspec == current_char_set);	}	if (raw_mode_old != LYRawMode || assume_char_set_changed) {	    /*	     *  Set the raw 8-bit or CJK mode defaults and	     *  character set if changed. - FM	     */	    HTMLSetUseDefaultRawMode(current_char_set, LYRawMode);	    HTMLSetCharacterHandling(current_char_set);	}	need_reload = TRUE;    } /* end of charset settings */    /*     * FIXME: Golly gee, we need to write all of this out now, don't we?     */    BStrFree(newdoc->post_data);    FREE(data);    if (save_all) {	HTInfoMsg(SAVING_OPTIONS);	LYrcShowColor = LYChosenShowColor;	if (save_rc(NULL)) {	    HTInfoMsg(OPTIONS_SAVED);	} else {	    HTAlert(OPTIONS_NOT_SAVED);	}    }    /*     *  Exit: working around the previous document.     *  Being out of mainloop()/getfile() cycle, do things manually.     */    CTRACE((tfp, "\nLYOptions.c/postoptions(): exiting...\n"));    CTRACE((tfp, "                            need_reload = %s\n",		    need_reload ? "TRUE" : "FALSE"));    CTRACE((tfp, "                            need_end_reload = %s\n",		    need_end_reload ? "TRUE" : "FALSE"));    /*  Options menu was pushed before postoptions(), so pop-up. */    LYpop(newdoc);    WWWDoc.address = newdoc->address;    WWWDoc.post_data = newdoc->post_data;    WWWDoc.post_content_type = newdoc->post_content_type;    WWWDoc.bookmark = newdoc->bookmark;    WWWDoc.isHEAD = newdoc->isHEAD;    WWWDoc.safe = newdoc->safe;    LYforce_no_cache = FALSE;   /* ! */    LYoverride_no_cache = TRUE; /* ! */    /*     * Working out of getfile() cycle we reset *no_cache manually here so     * HTLoadAbsolute() will return "Document already in memory":  it was     * forced reloading Options Menu again without this (overhead).     *     * Probably *no_cache was set in a wrong position because of     * the internal page...     */    if (!HTLoadAbsolute(&WWWDoc))	return(NOT_FOUND);    HTuncache_current_document(); /* will never use again */    /*     *  Return to previous doc, not to options menu!     *  Reload the document we had before the options menu     *  but uncache only when necessary (Hurrah, user!):     */    LYpop(newdoc);    WWWDoc.address = newdoc->address;    WWWDoc.post_data = newdoc->post_data;    WWWDoc.post_content_type = newdoc->post_content_type;    WWWDoc.bookmark = newdoc->bookmark;    WWWDoc.isHEAD = newdoc->isHEAD;    WWWDoc.safe = newdoc->safe;    LYforce_no_cache = FALSE;   /* see below */    LYoverride_no_cache = TRUE; /* see below */    /*     * Re-setting of *no_cache is probably not required here but this is a     * guarantee against _double_ reloading over the net in case prev document     * has its own "no cache" attribute and options menu set "need_reload"     * also.  Force this HTLoadAbsolute() to return "Document already in     * memory".     */    if (!HTLoadAbsolute(&WWWDoc))	return(NOT_FOUND);    /*     * Now most interesting part: reload document when necessary.     * **********************************************************     */    reloading = FALSE;  /* set manually */    /*  force end-to-end reload from remote server if change LYUserAgent     *  or language or pref_charset (marked by need_end_reload flag above),     *  from old-style LYK_OPTIONS (mainloop):     */    if ((need_end_reload == TRUE &&	 (strncmp(newdoc->address, "http", 4) == 0 ||	  isLYNXCGI(newdoc->address) == 0))) {	/*	 *  An option has changed which may influence	 *  content negotiation, and the resource is from	 *  a http or https or lynxcgi URL (the only protocols	 *  which currently do anything with this information).	 *  Set reloading = TRUE so that proxy caches will be	 *  flushed, which is necessary until the time when	 *  all proxies understand HTTP 1.1 Vary: and all	 *  Servers properly use it...  Treat like	 *  case LYK_RELOAD (see comments there). - KW	 */	reloading = TRUE;  /* global flag */	need_reload = TRUE;  /* this was probably already TRUE, don't worry */    }    if (need_reload == FALSE) {	/*  no uncache, already loaded */	CTRACE((tfp, "LYOptions.c/postoptions(): now really exit.\n\n"));	return(NORMAL);    } else {	/*  update HText cache */	/*	 *  see LYK_RELOAD & LYK_OPTIONS in mainloop for details...	 */	if (HTisDocumentSource()) {	    srcmode_for_next_retrieval(1);	}#ifdef USE_SOURCE_CACHE	if (reloading == FALSE) {	    /* one more attempt to be smart enough: */	    if (HTcan_reparse_document()) {		if (!HTreparse_document())		    srcmode_for_next_retrieval(0);		CTRACE((tfp, "LYOptions.c/postoptions(): now really exit.\n\n"));		return(NORMAL);	    }	}#endif	if (newdoc->post_data != NULL && !newdoc->safe &&	    confirm_post_resub(newdoc->address, newdoc->title, 2, 1) == FALSE) {	    HTInfoMsg(WILL_NOT_RELOAD_DOC);	    if (HTisDocumentSource()) {		srcmode_for_next_retrieval(0);	    }	    return(NORMAL);	}	HEAD_request = HTLoadedDocumentIsHEAD();	/*  uncache and load again */	HTuncache_current_document();	LYpush(newdoc, FALSE);	CTRACE((tfp, "LYOptions.c/postoptions(): now really exit.\n\n"));	return(NULLFILE);    }    /******** Done! **************************************************/}