if (strstr(newdoc->address, "LYNXOPTIONS:/") && !newdoc->post_data) { int status = gen_options(&newdoc->address); if (status == NOT_FOUND) return(NOT_FOUND);
data = break_data(newdoc->post_data);  if (!data) { int status;   status = gen_options(&newdoc->address); if (status != NORMAL) { HTAlwaysAlert("Unexpected way of accessing", newdoc->address); FREE(newdoc->address); return(status); }
PUBLIC int postoptions ARGS1(    document *,		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)	   edit_bookmarks();	else /* anonymous */	   HTAlert(BOOKMARK_CHANGE_DISALLOWED);	return(NULLFILE);    }    /*-------------------------------------------------     * kludge gen_options() call:     *--------------------------------------------------*/    if (strstr(newdoc->address, "LYNXOPTIONS:/") && !newdoc->post_data) {	int status = gen_options(&newdoc->address);	if (status == NOT_FOUND)	    return(NOT_FOUND);	/* exit to getfile() cyrcle */	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);	return(NORMAL);    }    data = break_data(newdoc->post_data);    for (i = 0; data[i].tag != NULL; i++) {	/*	 * Paranoid security.	 */	if (!strcmp(data[i].tag, secure_string)) {	    if (!secure_value || strcmp(data[i].value, secure_value)) {		/*		 * FIXME: We've been spoofed message here.		 */		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);	}	/* 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 = code) != FALSE) {		set_emacs_keys();	    } else {		reset_emacs_keys();	    }	}	/* Execution links: SELECT */#ifdef ALLOW_USERS_TO_CHANGE_EXEC_WITHIN_OPTIONS	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 /* ALLOW_USERS_TO_CHANGE_EXEC_WITHIN_OPTIONS */	/* 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;	    }	}	/* Line edit style: SELECT */	if (!strcmp(data[i].tag, lineedit_style_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 = 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 = 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, &LYShowColor)) {	    LYChosenShowColor = LYShowColor;	    if (CurrentShowColor != LYShowColor) {		lynx_force_repaint();	    }	    CurrentShowColor = LYShowColor;#ifdef USE_SLANG	    SLtt_Use_Ansi_Colors = (LYShowColor > 1 ? 1 : 0);#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 = code;	}	/* 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;	    }	}	/* 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 = 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 = code) != FALSE) {		set_vi_keys();	    } else {		reset_vi_keys();	    }	}	/* Bookmarks File Menu: SELECT */	if (!strcmp(data[i].tag, mbm_string) && (!LYMBMBlocked)) {	    if (!strcmp(data[i].value, mbm_off_string)) {		LYMultiBookmarks = FALSE;	    } else if (!strcmp(data[i].value, mbm_standard_string)) {		LYMultiBookmarks = TRUE;		LYMBMAdvanced = FALSE;	    } else if (!strcmp(data[i].value, mbm_advanced_string)) {		LYMultiBookmarks = TRUE;		LYMBMAdvanced = TRUE;	    }	}	/* 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;	    }	}	/* 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 = 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 Sort: SELECT */	if (!strcmp(data[i].tag, dired_sort_string)) {	    GetOptValues(dired_values, data[i].value, &dir_list_style);	}#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 = code;	}	/* 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 (LYUserAgent && *LYUserAgent &&		   !strstr(LYUserAgent, "Lynx") &&		   !strstr(LYUserAgent, "lynx")) {		    HTAlert(UA_COPYRIGHT_WARNING);		}	    }	}    } /* end of loop */    /*     * Process the flags:     */     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);	    }	if (assume_char_set_changed) {		LYRawMode = (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?     */    FREE(newdoc->post_data);    FREE(data);    if (save_all) {	_statusline(SAVING_OPTIONS);	if (save_rc()) {	    _statusline(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);    /* comment out to avoid warning when removing forms content... */    /* 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 ||	  strncmp(newdoc->address, "lynxcgi:", 8) == 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()) {#ifndef USE_PSRC	    HTOutputFormat = WWW_SOURCE;#else	    if (LYpsrc)		psrc_view = TRUE;	    else		HTOutputFormat = WWW_SOURCE;#endif	}#ifdef SOURCE_CACHE	if (reloading == FALSE) {	    /* one more attempt to be smart enough: */	    if (HTreparse_document()) {		CTRACE(tfp, "LYOptions.c/postoptions(): now really exit.\n\n");		return(NORMAL);	    }	}#endif	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! **************************************************/}