keypad_mode = LINKS_ARE_NUMBERED;
if (number_fields) keypad_mode = LINKS_AND_FIELDS_ARE_NUMBERED; else keypad_mode = LINKS_ARE_NUMBERED;
PUBLIC int main ARGS2(	int,		argc,	char **,	argv){    int  i;		/* indexing variable */    int status = 0;	/* exit status */    char *temp = NULL;    char *cp;    FILE *fp;    char filename[LY_MAXPATH];    BOOL LYGetStdinArgs = FALSE;#ifndef DISABLE_FTP    /* malloc a sizeof(char) so 1st strcmp() won't dump in HTLoadFile() */    ftp_lasthost = (char *)malloc(sizeof(char));    *ftp_lasthost = NULL;#endif /* DISABLE_FTP */#ifdef    NOT_ASCII    FixCharacters();#endif /* NOT_ASCII */#ifdef _WINDOWS    WSADATA WSAData;    {	int err;	WORD wVerReq;	wVerReq = MAKEWORD(1,1);	err = WSAStartup(wVerReq, &WSAData);	if (err != 0)	{	    printf(gettext("No Winsock found, sorry."));	    sleep(5);	    return;	}    }#endif /* _WINDOWS */#ifdef __DJGPP__    if (LY_get_ctrl_break() == 0) {	LY_set_ctrl_break(TRUE);	init_ctrl_break[0] = 0;    } else {	init_ctrl_break[0] = 1;    }    atexit(reset_break);    dbug_init();    sock_init();#endif    /*     * To prevent corrupting binary data on DOS, MS-WINDOWS or OS/2     * we open files and stdout in BINARY mode by default.     * Where necessary we should open and (close!) TEXT mode.     * (use LYNewTxtFile/LYAppendToTxtFile to open text files for writing)     */    SetDefaultMode(O_BINARY);    SetOutputMode(O_BINARY);#ifdef DOSPATH    if (getenv("TERM")==NULL) putenv("TERM=vt100");#endif    LYShowColor = (SHOW_COLOR ? SHOW_COLOR_ON : SHOW_COLOR_OFF);    /*     *	Set up the argument list.     */    pgm = argv[0];    if ((cp = strrchr(pgm, '/')) != NULL) {	pgm = cp + 1;    }    /*     *	Act on -help NOW, so we only output the help and exit. - FM     */    for (i = 1; i < argc; i++) {	if (argncmp(argv[i], "-help") == 0) {	    parse_arg(&argv[i], &i);	}    }#ifdef LY_FIND_LEAKS    /*     *	Register the final function to be executed when being exited.     *	Will display memory leaks if LY_FIND_LEAKS is defined.     */    atexit(LYLeaks);    /*     *	Register the function which will free our allocated globals.     */    atexit(free_lynx_globals);#endif /* LY_FIND_LEAKS */#ifdef LOCALE    /*     *	LOCALE support for international characters.     */    setlocale(LC_ALL, "");#endif /* LOCALE */    /* Set the text message domain.  */#ifdef HAVE_LIBINTL_H#ifndef __DJGPP__    bindtextdomain ("lynx", LOCALEDIR);#endif /* !__DJGPP__ */    textdomain ("lynx");#endif /* HAVE_LIBINTL_H */    /*     *	Initialize our startup and global variables.     */#ifdef ULTRIX    /*     *	Need this for Ultrix.     */    terminal = getenv("TERM");    if ((terminal == NULL) || !strncasecomp(terminal, "xterm", 5))	terminal = "vt100";#endif /* ULTRIX */    /*     *	Zero the links and history struct arrays.     */    memset((void *)links, 0, sizeof(linkstruct)*MAXLINKS);    memset((void *)history, 0, sizeof(histstruct)*MAXHIST);    /*     *	Zero the MultiBookmark arrays.     */    memset((void *)MBM_A_subbookmark, 0, sizeof(char)*(MBM_V_MAXFILES+1));    memset((void *)MBM_A_subdescript, 0, sizeof(char)*(MBM_V_MAXFILES+1));#ifndef VMS#ifdef SYSLOG_REQUESTED_URLS    openlog("lynx", LOG_PID, LOG_LOCAL5);#endif /* SYSLOG_REQUESTED_URLS */    StrAllocCopy(list_format, LIST_FORMAT);#endif /* !VMS */    InfoSecs	= (int)INFOSECS;    MessageSecs = (int)MESSAGESECS;    AlertSecs	= (int)ALERTSECS;    StrAllocCopy(helpfile, HELPFILE);    StrAllocCopy(startfile, STARTFILE);    LYEscapeStartfile(&startfile);     StrAllocCopy(indexfile, DEFAULT_INDEX_FILE);    StrAllocCopy(global_type_map, GLOBAL_MAILCAP);    StrAllocCopy(personal_type_map, PERSONAL_MAILCAP);    StrAllocCopy(global_extension_map, GLOBAL_EXTENSION_MAP);    StrAllocCopy(personal_extension_map, PERSONAL_EXTENSION_MAP);    StrAllocCopy(language, PREFERRED_LANGUAGE);    StrAllocCopy(pref_charset, PREFERRED_CHARSET);    StrAllocCopy(system_mail, SYSTEM_MAIL);    StrAllocCopy(system_mail_flags, SYSTEM_MAIL_FLAGS);    StrAllocCopy(LYUserAgent, LYNX_NAME);    StrAllocCat(LYUserAgent, "/");    StrAllocCat(LYUserAgent, LYNX_VERSION);    if (HTLibraryVersion) {	StrAllocCat(LYUserAgent, " libwww-FM/");	StrAllocCat(LYUserAgent, HTLibraryVersion);    }    StrAllocCopy(LYUserAgentDefault, LYUserAgent);#ifdef VMS    Define_VMSLogical("LYNX_VERSION", LYNX_VERSION);#else    StrAllocCopy(lynx_version_putenv_command, "LYNX_VERSION=");    StrAllocCat(lynx_version_putenv_command, LYNX_VERSION);    (void) putenv(lynx_version_putenv_command);    /* Note: you must not free the data passed to 'putenv()' until you give it     * a new value for that variable.     */#endif /* VMS */    if ((cp = getenv("LYNX_TEMP_SPACE")) != NULL)	StrAllocCopy(lynx_temp_space, cp);#if defined (UNIX)    else if ((cp = getenv("TMPDIR")) != NULL)	StrAllocCopy(lynx_temp_space, cp);#endif#if defined (DOSPATH) || defined (__EMX__)    else if ((cp = getenv("TEMP")) != NULL)	StrAllocCopy(lynx_temp_space, HTDOS_name(cp));    else if ((cp = getenv("TMP")) != NULL)	StrAllocCopy(lynx_temp_space, HTDOS_name(cp));#endif    else#ifdef TEMP_SPACE	StrAllocCopy(lynx_temp_space, TEMP_SPACE);#else    {	printf(gettext("You MUST define a valid TMP or TEMP area!\n"));	exit(-1);    }#endif    if ((cp = strchr(lynx_temp_space, '~'))) {	*(cp++) = '\0';	StrAllocCopy(temp, lynx_temp_space);	LYTrimPathSep(temp);	StrAllocCat(temp, wwwName(Home_Dir()));	StrAllocCat(temp, cp);	StrAllocCopy(lynx_temp_space, temp);	FREE(temp);    }    if ((cp = strstr(lynx_temp_space, "$USER")) != NULL) {	char *cp1;	if ((cp1 = (char *)getenv("USER")) != NULL) {	    *cp = '\0';	    StrAllocCopy(temp, lynx_temp_space);	    *cp = '$';	    StrAllocCat(temp, cp1);	    cp += 5;	    StrAllocCat(temp, cp);	    StrAllocCopy(lynx_temp_space, temp);	    FREE(temp);	}    }    StrAllocCat(lynx_temp_space, "/lynx-XXXXXX");    lynx_temp_space = mkdtemp(lynx_temp_space);#ifdef VMS    LYLowerCase(lynx_temp_space);    if (strchr(lynx_temp_space, '/') != NULL) {	if (strlen(lynx_temp_space) == 1) {	    StrAllocCopy(lynx_temp_space, "sys$scratch:");	} else {	    LYAddPathSep(&lynx_temp_space);	    StrAllocCopy(temp, HTVMS_name("", lynx_temp_space));	    StrAllocCopy(lynx_temp_space, temp);	    FREE(temp);	}    }    if (strchr(lynx_temp_space, ':') == NULL &&	strchr(lynx_temp_space, ']') == NULL) {	StrAllocCat(lynx_temp_space, ":");    }#else    LYAddPathSep(&lynx_temp_space);#endif /* VMS */#ifdef VMS    StrAllocCopy(mail_adrs, MAIL_ADRS);#ifdef CSWING_PATH    StrAllocCopy(LYCSwingPath, CSWING_PATH);#endif /* CSWING_PATH */#endif /* VMS */#ifdef LYNX_HOST_NAME    StrAllocCopy(LYHostName, LYNX_HOST_NAME);#else    StrAllocCopy(LYHostName, HTHostName());#endif /* LYNX_HOST_NAME */    StrAllocCopy(LYLocalDomain, LOCAL_DOMAIN);    StrAllocCopy(URLDomainPrefixes, URL_DOMAIN_PREFIXES);    StrAllocCopy(URLDomainSuffixes, URL_DOMAIN_SUFFIXES);    StrAllocCopy(XLoadImageCommand, XLOADIMAGE_COMMAND);    /*     *	Disable news posting if the compilation-based     *	LYNewsPosting value is FALSE.  This may be changed     *	further down via lynx.cfg or the -restriction     *	command line switch. - FM     */#ifndef DISABLE_NEWS    no_newspost = (LYNewsPosting == FALSE);#endif    /*     *	Set up trace, the anonymous account defaults,     *	validate restrictions, and/or the nosocks flag,     *	if requested, and an alternate configuration     *	file, if specified, NOW.  Also, if we only want     *	the help menu, output that and exit. - FM     */    for (i = 1; i < argc; i++) {	if (argncmp(argv[i], "-trace") == 0) {	    WWW_TraceFlag = TRUE;	} else if (argncmp(argv[i], "-tlog") == 0) {	    if (LYUseTraceLog) {		LYUseTraceLog = FALSE;	    } else {		LYUseTraceLog = TRUE;	    }	} else if (argncmp(argv[i], "-anonymous") == 0) {	    if (!LYValidate)		parse_restrictions("default");	    LYRestricted = TRUE;	} else if (argcmp(argv[i], "-validate") == 0) {	    /*	     *	Follow only http URLs.	     */	    LYValidate = TRUE;#ifdef SOCKS	} else if (argncmp(argv[i], "-nosocks") == 0) {	    socks_flag = FALSE;#endif /* SOCKS */	} else if (argncmp(argv[i], "-cfg") == 0) {	    if ((cp=strchr(argv[i],'=')) != NULL)		StrAllocCopy(lynx_cfg_file, cp+1);	    else {		StrAllocCopy(lynx_cfg_file, argv[i+1]);		i++;	    }#if defined(USE_HASH)	} else if (argncmp(argv[i], "-lss") == 0) {	    if ((cp=strchr(argv[i],'=')) != NULL)		StrAllocCopy(lynx_lss_file, cp+1);	    else {		StrAllocCopy(lynx_lss_file, argv[i+1]);		i++;	    }	    CTRACE(tfp, "LYMain found -lss flag, lss file is %s\n",		    lynx_lss_file ? lynx_lss_file : "<NONE>");#endif	}    }    /*     *	If we have a lone "-" switch for getting arguments from stdin,     *	get them NOW, and act on the relevant ones, saving the others     *	into an HTList for handling after the other initializations.     *	The primary purpose of this feature is to allow for the     *	potentially very long command line that can be associated with     *	post or get data.  The original implementation required that     *	the lone "-" be the only command line argument, but that     *	precluded its use when the lynx command is aliased with other     *	arguments.  When interactive, the stdin input is terminated by     *	by Control-D on Unix or Control-Z on VMS, and each argument     *	is terminated by a RETURN.  When the argument is -get_data or     *	-post_data, the data are terminate by a "___" string, alone     *	on the line (also terminated by RETURN). - FM     */    for (i = 1; i < argc; i++) {	if (strcmp(argv[i], "-") == 0) {	    LYGetStdinArgs = TRUE;	}    }    if (LYGetStdinArgs == TRUE) {	char *buf = NULL;	while (LYSafeGets(&buf, stdin) != 0) {	    int j;	    for (j = strlen(buf) - 1; j > 0 &&		(buf[j] == CR || buf[j] == LF); j--) {		buf[j] = '\0';	    }	    if (argncmp(buf, "-trace") == 0) {		WWW_TraceFlag = TRUE;	    } else if (argncmp(buf, "-tlog") == 0) {		if (LYUseTraceLog) {		    LYUseTraceLog = FALSE;		} else {		    LYUseTraceLog = TRUE;		}	    } else if (argncmp(buf, "-anonymous") == 0) {		if (!LYValidate && !LYRestricted)		    parse_restrictions("default");		LYRestricted = TRUE;	    } else if (argcmp(buf, "-validate") == 0) {		/*		 *  Follow only http URLs.		 */		LYValidate = TRUE;#ifdef SOCKS	    } else if (argncmp(buf, "-nosocks") == 0) {		socks_flag = FALSE;#endif /* SOCKS */	    } else if (argncmp(buf, "-cfg") == 0) {		if ((cp = strchr(buf,'=')) != NULL) {		    StrAllocCopy(lynx_cfg_file, cp+1);		} else {		    cp = LYSkipNonBlanks(buf);		    cp = LYSkipBlanks(cp);		    if (*cp)			StrAllocCopy(lynx_cfg_file, cp);		}#if defined(USE_HASH)	    } else if (argncmp(buf, "-lss") == 0) {		if ((cp = strchr(buf,'=')) != NULL) {		    StrAllocCopy(lynx_lss_file, cp+1);		} else {		    cp = LYSkipNonBlanks(buf);		    cp = LYSkipBlanks(cp);		    if (*cp)			StrAllocCopy(lynx_lss_file, cp);		}		CTRACE(tfp, "LYMain found -lss flag, lss file is %s\n",			lynx_lss_file ? lynx_lss_file : "<NONE>");#endif	    } else if (argcmp(buf, "-get_data") == 0) {		/*		 *  User data for GET form.		 */		char **get_data;		/*		 *  On Unix, conflicts with curses when interactive		 *  so let's force a dump.  - CL		 *		 *  On VMS, mods have been made in LYCurses.c to deal		 *  with potential conflicts, so don't force the dump		 *  here. - FM		 */#ifndef VMS		dump_output_immediately = TRUE;		LYcols = 80;#endif /* VMS */		StrAllocCopy(form_get_data, "?");   /* Prime the pump */		get_data = &form_get_data;		/*		 *  Build GET data for later.  Stop reading when we see		 *  a line with "---" as its first three characters.		 */		while (LYSafeGets(&buf, stdin) != 0 &&		       strncmp(buf, "---", 3) != 0) {		    int j2;		    /*		     *	Strip line terminators.		     */		    for (j2 = strlen(buf) - 1; j2 >= 0 &&			 (buf[j2] == CR || buf[j2] == LF); j2--) {			buf[j2] = '\0';		    }		    StrAllocCat(*get_data, buf);		}	    } else if (argcmp(buf, "-post_data") == 0) {		/*		 *  User data for POST form.		 */		char **post_data;		/*		 *  On Unix, conflicts with curses when interactive		 *  so let's force a dump.  - CL		 *		 *  On VMS, mods have been made in LYCurses.c to deal		 *  with potential conflicts, so don't force a dump		 *  here. - FM		 */#ifndef VMS		dump_output_immediately = TRUE;		LYcols = 80;#endif /* VMS */		post_data = &form_post_data;		/*		 *  Build post data for later.	Stop reading when we see		 *  a line with "---" as its first three characters.		 */		while (LYSafeGets(&buf, stdin) != 0 &&		       strncmp(buf, "---", 3) != 0) {		    int j2;		     /*		      *  Strip line terminators.		      */		    for (j2 = strlen(buf) - 1; j2 >= 0 &&			 (buf[j2] == CR || buf[j2] == LF); j2--) {			buf[j2] = '\0';		    }		    StrAllocCat(*post_data, buf);		}	    } else if (buf[0] != '\0') {		char *argument = NULL;		if (LYStdinArgs == NULL) {		    LYStdinArgs = HTList_new();#ifdef LY_FIND_LEAKS		    atexit(LYStdinArgs_free);#endif		}		StrAllocCopy(argument, buf);		HTList_appendObject(LYStdinArgs, argument);	    }	}	FREE(buf);    }#ifdef SOCKS    if (socks_flag)	SOCKSinit(argv[0]);#endif /* SOCKS */    /*     *	If we had -validate set all of the restrictions     *	and disallow a TRACE log NOW. - FM     */    if (LYValidate == TRUE) {	parse_restrictions("all");	LYUseTraceLog = FALSE;    }    /*     *	If we didn't get and act on a -validate or -anonymous     *	switch, but can verify that this is the anonymous account,     *	set the default restrictions for that account and disallow     *	a TRACE log NOW. - FM     */    if (!LYValidate && !LYRestricted &&	strlen((char *)ANONYMOUS_USER) > 0 &&#if defined (VMS) || defined (NOUSERS)	!strcasecomp(((char *)getenv("USER")==NULL ? " " : getenv("USER")),		     ANONYMOUS_USER))#else#if HAVE_CUSERID	STREQ((char *)cuserid((char *) NULL), ANONYMOUS_USER))#else	STREQ(((char *)getlogin()==NULL ? " " : getlogin()), ANONYMOUS_USER))#endif /* HAVE_CUSERID */#endif /* VMS */    {	parse_restrictions("default");	LYRestricted = TRUE;	LYUseTraceLog = FALSE;    }    /*     *	Set up the TRACE log path, and logging if appropriate. - FM     */    LYAddPathToHome(LYTraceLogPath = malloc(LY_MAXPATH), LY_MAXPATH, "Lynx.trace");    LYOpenTraceLog();    /*     *	Set up the default jump file stuff. - FM     */    StrAllocCopy(jumpprompt, JUMP_PROMPT);#ifdef JUMPFILE    StrAllocCopy(jumpfile, JUMPFILE);    {	temp = (char *)malloc(strlen(jumpfile) + 10);	if (!temp) {	    outofmem(__FILE__, "main");	} else {	    sprintf(temp, "JUMPFILE:%s", jumpfile);	    if (!LYJumpInit(temp)) {		CTRACE(tfp, "Failed to register %s\n", temp);	    }	    FREE(temp);	}    }#endif /* JUMPFILE */    /*     *	If no alternate configuration file was specified on     *	the command line, see if it's in the environment.     */    if (!lynx_cfg_file) {	if (((cp=getenv("LYNX_CFG")) != NULL) ||	    (cp=getenv("lynx_cfg")) != NULL)	    StrAllocCopy(lynx_cfg_file, cp);    }    /*     *	If we still don't have a configuration file,     *	use the userdefs.h definition.     */    if (!lynx_cfg_file)	StrAllocCopy(lynx_cfg_file, LYNX_CFG_FILE);    /*     *	Convert a '~' in the configuration file path to $HOME.     */#ifndef _WINDOWS /* avoid the whole ~ thing for now */   /* I think this should only be performed if lynx_cfg_file starts with ~/ */   if ((lynx_cfg_file[0] == '~') && LYIsPathSep(lynx_cfg_file[1]))     {#ifdef VMS	StrAllocCopy(temp, HTVMS_wwwName((char *)Home_Dir()));#else	StrAllocCopy(temp, Home_Dir());#endif /* VMS */	StrAllocCat(temp, lynx_cfg_file + 1);	StrAllocCopy(lynx_cfg_file, temp);	FREE(temp);     }#endif    /*     *	If the configuration file is not available,     *	inform the user and exit.     */    if ((fp = fopen(lynx_cfg_file, "r")) == NULL) {	fprintf(stderr, gettext("\nConfiguration file %s is not available.\n\n"),			lynx_cfg_file);	exit(-1);    }    fclose(fp);#if defined(USE_KEYMAPS) && defined(USE_SLANG)    if (-1 == lynx_initialize_keymaps ())	exit (-1);#endif    /*     * Make sure we have the character sets declared.     *	This will initialize the CHARTRANS handling. - KW     */    if (!LYCharSetsDeclared()) {	fprintf(stderr, gettext("\nLynx character sets not declared.\n\n"));	exit(-1);    }    /*     *  (**) in Lynx, UCLYhndl_HTFile_for_unspec and UCLYhndl_for_unrec may be     *  valid or not, but current_char_set and UCLYhndl_for_unspec SHOULD     *  ALWAYS be a valid charset.  Initialized here and may be changed later     *  from lynx.cfg/command_line/options_menu. - LP  (**)     */    /*     *	Set up the compilation default character set. - FM     */    current_char_set = safeUCGetLYhndl_byMIME(CHARACTER_SET);    /*     *	Set up HTTP default for unlabeled charset (iso-8859-1).     */    UCLYhndl_for_unspec = LATIN1;    StrAllocCopy(UCAssume_MIMEcharset,			LYCharSet_UC[UCLYhndl_for_unspec].MIMEname);    /*     *	Make sure we have the edit map declared. - FM     */    if (!LYEditmapDeclared()) {	fprintf(stderr, gettext("\nLynx edit map not declared.\n\n"));	exit(-1);    }#if defined(USE_HASH)    /*     *	If no alternate lynx-style file was specified on     *	the command line, see if it's in the environment.     */    if (!lynx_lss_file) {	if (((cp=getenv("LYNX_LSS")) != NULL) ||	    (cp=getenv("lynx_lss")) != NULL)	    StrAllocCopy(lynx_lss_file, cp);    }    /*     *	If we still don't have a lynx-style file,     *	use the userdefs.h definition.     */    if (!lynx_lss_file)	StrAllocCopy(lynx_lss_file, LYNX_LSS_FILE);    /*     *	Convert a '~' in the lynx-style file path to $HOME.     */    if ((cp = strchr(lynx_lss_file, '~'))) {	*(cp++) = '\0';	StrAllocCopy(temp, lynx_lss_file);	LYTrimPathSep(temp);#ifdef VMS	StrAllocCat(temp, HTVMS_wwwName((char *)Home_Dir()));#else	StrAllocCat(temp, Home_Dir());#endif /* VMS */	StrAllocCat(temp, cp);	StrAllocCopy(lynx_lss_file, temp);	FREE(temp);    }    /*     *	If the lynx-style file is not available,     *	inform the user and exit.     */    if ((fp = fopen(lynx_lss_file, "r")) == NULL) {	fprintf(stderr, gettext("\nLynx file %s is not available.\n\n"),			lynx_lss_file);    }    else    {	fclose(fp);	style_readFromFile(lynx_lss_file);    }#endif /* USE_HASH */#if USE_COLOR_TABLE    /*     *	Set up default foreground and background colors.     */    lynx_setup_colors();#endif /* USE_COLOR_TABLE */    /*     *  Set the original directory, used for default download     */    if (!strcmp(Current_Dir(filename), ".")) {	if ((cp = getenv("PWD")) != 0)	    StrAllocCopy(original_dir, cp);    } else {	StrAllocCopy(original_dir, filename);    }    /*     *	Set the compilation default signature file. - FM     */    strcpy(filename, LYNX_SIG_FILE);    if (LYPathOffHomeOK(filename, sizeof(filename))) {	StrAllocCopy(LynxSigFile, filename);	LYAddPathToHome(filename, sizeof(filename), LynxSigFile);	StrAllocCopy(LynxSigFile, filename);	CTRACE(tfp, "LYNX_SIG_FILE set to '%s'\n", LynxSigFile);    } else {	CTRACE(tfp, "LYNX_SIG_FILE '%s' is bad. Ignoring.\n", LYNX_SIG_FILE);    }#ifdef USE_PSRC    /*this is required for checking the tagspecs when parsing cfg file by       LYReadCFG.c:parse_html_src_spec -HV */    HTSwitchDTD(TRUE);#endif    /*     *	Process the configuration file.     */    read_cfg(lynx_cfg_file, "main program", 1, (FILE *)0);    /*     *	Process the RC file.     */    read_rc();    /*     * Get WWW_HOME environment variable if it exists.     */    if ((cp = getenv("WWW_HOME")) != NULL) {	StrAllocCopy(startfile, cp);	LYEscapeStartfile(&startfile);    }    /*     * Set the LynxHome URL.  If it's a file URL and the     * host is defaulted, force in "//localhost", and if     * it's not an absolute URL, make it one. - FM     */    StrAllocCopy(LynxHome, startfile);    LYFillLocalFileURL((char **)&LynxHome, "file://localhost");    LYEnsureAbsoluteURL((char **)&LynxHome, "LynxHome", FALSE);    /*     *  Process any command line arguments not already handled. - FM     */    for (i = 1; i < argc; i++) {	parse_arg(&argv[i], &i);    }    /*     *  Process any stdin-derived arguments for a lone "-"  which we've     *  loaded into LYStdinArgs. - FM     */    if (LYStdinArgs != NULL) {	char *my_args[2];	HTList *cur = LYStdinArgs;	my_args[1] = NULL;	while (NULL != (my_args[0] = (char *)HTList_nextObject(cur))) {	     parse_arg(my_args, (int *)0);	}	LYStdinArgs_free();    }    /*     *  Initialize other things based on the configuration read.     */#ifdef USE_PSRC    if ( (!Old_DTD) != TRUE ) /* skip if they are already initialized -HV */#endif    HTSwitchDTD(!Old_DTD);    /*     * Set up the proper character set with the desired     * startup raw 8-bit or CJK mode handling.  - FM     */    HTMLUseCharacterSet(current_char_set);#ifdef EXP_PERSISTENT_COOKIES    /*     * Sod it, this looks like a reasonable place to load the     * cookies file, probably.  - RP     */    if (persistent_cookies) {	if(LYCookieFile == NULL) {	   LYAddPathToHome(LYCookieFile = malloc(LY_MAXPATH), LY_MAXPATH, COOKIE_FILE);	} else {	    if ((cp = strchr(LYCookieFile, '~'))) {		temp = NULL;		*(cp++) = '\0';		StrAllocCopy(temp, cp);		LYTrimPathSep(temp);		StrAllocCopy(LYCookieFile, wwwName(Home_Dir()));		StrAllocCat(LYCookieFile, temp);		FREE(temp);	    }	}	LYLoadCookies(LYCookieFile);    }#endif    /*     * Set up our help and about file base paths. - FM     */    StrAllocCopy(helpfilepath, helpfile);    if ((cp = LYPathLeaf(helpfilepath)) != helpfilepath)	*cp = '\0';    LYAddHtmlSep(&helpfilepath);    /*     *	Check for a save space path in the environment.     *	If one was set in the configuration file, that     *	one will be overridden. - FM     */    if ((cp=getenv("LYNX_SAVE_SPACE")) != NULL)	StrAllocCopy(lynx_save_space, cp);    /*     *	We have a save space path, make sure it's valid. - FM     */    if (lynx_save_space && *lynx_save_space == '\0') {	FREE(lynx_save_space);    }    if (lynx_save_space) {	if ((cp = strchr(lynx_save_space, '~')) != NULL) {	    *(cp++) = '\0';	    StrAllocCopy(temp, lynx_save_space);	    LYTrimPathSep(temp);	    StrAllocCat(temp, wwwName(Home_Dir()));	    StrAllocCat(temp, cp);	    StrAllocCopy(lynx_save_space, temp);	    FREE(temp);	}#ifdef VMS	LYLowerCase(lynx_save_space);	if (strchr(lynx_save_space, '/') != NULL) {	    if (strlen(lynx_save_space) == 1) {		StrAllocCopy(lynx_save_space, "sys$login:");	    } else {		LYAddPathSep(&lynx_save_space);		StrAllocCopy(temp, HTVMS_name("", lynx_save_space));		StrAllocCopy(lynx_save_space, temp);		FREE(temp);	    }	}	if (strchr(lynx_save_space, ':') == NULL &&	    strchr(lynx_save_space, ']') == NULL) {	    StrAllocCat(lynx_save_space, ":");	}#else	LYAddPathSep(&lynx_save_space);#endif /* VMS */    }    /*     *	Set up the file extension and mime type maps from     *	src/HTInit.c and the global and personal mime.types     *	and mailcap files.  These will override any SUFFIX     *	or VIEWER maps in userdefs.h or the configuration     *	file, if they overlap.     */    HTFormatInit();    HTFileInit();#ifndef VMS#ifdef SYSLOG_REQUESTED_URLS    if (syslog_txt) {	syslog(LOG_INFO, "Session start:%s", syslog_txt);    } else {	syslog(LOG_INFO, "Session start");    }#endif /* SYSLOG_REQUESTED_URLS */#endif /* !VMS */#ifdef USE_SLANG    if (LYShowColor >= SHOW_COLOR_ON &&	!(Lynx_Color_Flags & SL_LYNX_USE_COLOR)) {	Lynx_Color_Flags |= SL_LYNX_USE_COLOR;    } else if ((Lynx_Color_Flags & SL_LYNX_USE_COLOR) ||	       getenv("COLORTERM") != NULL) {	if (LYShowColor != SHOW_COLOR_NEVER &&	    LYShowColor != SHOW_COLOR_ALWAYS) {	    LYShowColor = SHOW_COLOR_ON;	}    }#endif /* USE_SLANG */    if (LYPreparsedSource) {	HTPreparsedFormatInit();    }#if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)#ifdef NEVER_ALLOW_REMOTE_EXEC    if (local_exec) {	local_exec = FALSE;	local_exec_on_local_files = TRUE;    }#endif /* NEVER_ALLOW_REMOTE_EXEC */#endif /* EXEC_LINKS || EXEC_SCRIPTS */    if (emacs_keys)	set_emacs_keys();    if (vi_keys)	set_vi_keys();    if (number_links && keypad_mode == NUMBERS_AS_ARROWS)	keypad_mode = LINKS_ARE_NUMBERED;    if (keypad_mode == NUMBERS_AS_ARROWS)	set_numbers_as_arrows();    /*     *	Check the -popup command line toggle. - FM     */    if (LYUseDefSelPop == FALSE) {	if (LYSelectPopups == TRUE)	    LYSelectPopups = FALSE;	else	    LYSelectPopups = TRUE;    }    /*     *	Check the -show_cursor command line toggle. - FM     */    if (LYUseDefShoCur == FALSE) {	if (LYShowCursor == TRUE)	    LYShowCursor = FALSE;	else	    LYShowCursor = TRUE;    }    /*     *	Check the -base command line switch with -source. - FM     */    if (LYPrependBase && HTOutputFormat == HTAtom_for("www/download")) {	LYPrependBaseToSource = TRUE;    }    /*     *	Disable multiple bookmark support if not interactive,     *	so it doesn't crash on curses functions, or if the     *	support was blocked via userdefs.h and/or lynx.cfg,     *	or via command line restrictions. - FM     */    if (no_multibook)	LYMBMBlocked = TRUE;    if (dump_output_immediately || LYMBMBlocked || no_multibook) {	LYMultiBookmarks = FALSE;	LYMBMBlocked = TRUE;	no_multibook = TRUE;    }#ifdef SOURCE_CACHE    /*     * Disable source caching if not interactive.     */    if (dump_output_immediately)	LYCacheSource = SOURCE_CACHE_NONE;#endif#ifdef DISP_PARTIAL    /*     * Disable partial mode if not interactive.     */    if (dump_output_immediately)	display_partial_flag = FALSE;#endif#ifdef VMS    set_vms_keys();#endif /* VMS */    /* trap interrupts */    if (!dump_output_immediately)#ifndef NOSIGHUP	(void) signal(SIGHUP, cleanup_sig);#endif /* NOSIGHUP */    (void) signal(SIGTERM, cleanup_sig);#ifdef SIGWINCH    (void) signal(SIGWINCH, size_change);#endif /* SIGWINCH */#ifndef VMS    if (!TRACE && !dump_output_immediately && !stack_dump) {	(void) signal(SIGINT, cleanup_sig);#ifndef __linux__#ifndef DOSPATH	(void) signal(SIGBUS, FatalProblem);#endif /* DOSPATH */#endif /* !__linux__ */	(void) signal(SIGSEGV, FatalProblem);	(void) signal(SIGILL, FatalProblem);	/*	 *  Since we're doing lots of TCP, just ignore SIGPIPE altogether.	 *	 *  HTTCP.c should deal with a broken pipe for servers.	 *  Rick Mallet's check after c = GetChar() in LYStrings.c should	 *   deal with a disconnected terminal.	 *  So the runaway CPU time problem on Unix should not occur any	 *   more.	 */#ifndef DOSPATH	(void) signal(SIGPIPE, SIG_IGN);#endif /* DOSPATH */    }#endif /* !VMS */#ifdef SIGTSTP    /*     *	Block Control-Z suspending if requested. - FM     */    if (no_suspend)	(void) signal(SIGTSTP,SIG_IGN);#endif /* SIGTSTP */    /*     *	Check for a valid HEAD request. - FM     */    if (HEAD_request && LYCanDoHEAD(startfile) != TRUE) {	fprintf(stderr, "The '-head' switch is for http HEAD requests and cannot be used for\n'%s'.\n",		startfile);	exit_immediately(-1);    }    /*     *	Check for a valid MIME headers request. - FM     */    if (keep_mime_headers && LYCanDoHEAD(startfile) != TRUE) {	fprintf(stderr, "The '-mime_header' switch is for http URLs and cannot be used for\n'%s'.\n",		startfile);	exit_immediately(-1);    }    /*     *	Check for a valid traversal request. - FM     */    if (traversal && strncmp(startfile, "http", 4)) {	fprintf(stderr, "The '-traversal' switch is for http URLs and cannot be used for\n'%s'.\n",		startfile);	exit_immediately(-1);    }    /*     *  Finish setting up for an INTERACTIVE session.     *  Done here so that URL guessing in LYEnsureAbsoluteURL() can be     *  interruptible (terminal is in raw mode, select() works).  -BL     */#ifdef USE_PSRC    if (!dump_output_immediately)	HTMLSRC_init_caches(); /* do it before terminal is initialized*/#endif    if (!dump_output_immediately) {	setup(terminal);    }    /*     *	If startfile is a file URL and the host is defaulted,     *	force in "//localhost", and if it's not an absolute URL,     *	make it one. - FM     */    LYFillLocalFileURL((char **)&startfile, "file://localhost");    LYEnsureAbsoluteURL((char **)&startfile, "STARTFILE", FALSE);    /*     *	If homepage was specified and is a file URL with the     *	host defaulted, force in "//localhost", and if it's     *	not an absolute URL, make it one. - FM     */    if (homepage) {	LYFillLocalFileURL((char **)&homepage, "file://localhost");	LYEnsureAbsoluteURL((char **)&homepage, "HOMEPAGE", FALSE);    }    /*     *	If we don't have a homepage specified,     *	set it to startfile.  Otherwise, reset     *	LynxHome. - FM     */    if (!(homepage && *homepage)) {	StrAllocCopy(homepage, startfile);    } else {	StrAllocCopy(LynxHome, homepage);    }    /*     *	Set up the inside/outside domain restriction flags. - FM     */    if (inlocaldomain()) {#if !defined(HAVE_UTMP) || defined(VMS) /* not selective */	telnet_ok = !no_inside_telnet && !no_outside_telnet && telnet_ok;#ifndef DISABLE_NEWS	news_ok = !no_inside_news && !no_outside_news && news_ok;#endif	ftp_ok = !no_inside_ftp && !no_outside_ftp && ftp_ok;	rlogin_ok = !no_inside_rlogin && !no_outside_rlogin && rlogin_ok;#else	CTRACE(tfp,"LYMain.c: User in Local domain\n");	telnet_ok = !no_inside_telnet && telnet_ok;#ifndef DISABLE_NEWS	news_ok = !no_inside_news && news_ok;#endif	ftp_ok = !no_inside_ftp && ftp_ok;	rlogin_ok = !no_inside_rlogin && rlogin_ok;#endif /* !HAVE_UTMP || VMS */    } else {	CTRACE(tfp,"LYMain.c: User in REMOTE domain\n");	telnet_ok = !no_outside_telnet && telnet_ok;#ifndef DISABLE_NEWS	news_ok = !no_outside_news && news_ok;#endif	ftp_ok = !no_outside_ftp && ftp_ok;	rlogin_ok = !no_outside_rlogin && rlogin_ok;    }    /*     *	Make sure our bookmark default strings     *	are all allocated and synchronized. - FM     */    if (!bookmark_page || *bookmark_page == '\0') {	StrAllocCopy(bookmark_page, "lynx_bookmarks");	StrAllocCat(bookmark_page, HTML_SUFFIX);	StrAllocCopy(BookmarkPage, bookmark_page);	StrAllocCopy(MBM_A_subbookmark[0], bookmark_page);	StrAllocCopy(MBM_A_subdescript[0], "Default");    }    if (!BookmarkPage || *BookmarkPage == '\0') {	StrAllocCopy(BookmarkPage, bookmark_page);	StrAllocCopy(MBM_A_subbookmark[0], bookmark_page);	StrAllocCopy(MBM_A_subdescript[0], MULTIBOOKMARKS_DEFAULT);    }    /*     *	Here's where we do all the work.     */    if (dump_output_immediately) {	/*	 *  Finish setting up and start a	 *  NON-INTERACTIVE session. - FM	 */	if (crawl && !number_links) {	    keypad_mode = NUMBERS_AS_ARROWS;	} else if (!nolist) {	    if (keypad_mode == NUMBERS_AS_ARROWS) {		keypad_mode = LINKS_ARE_NUMBERED;	    }	}	if (x_display != NULL && *x_display != '\0') {	    LYisConfiguredForX = TRUE;	}	if (dump_output_width > 0) {	    LYcols = dump_output_width;	}	status = mainloop();	if (!nolist &&	    (keypad_mode == LINKS_ARE_NUMBERED ||	     keypad_mode == LINKS_AND_FORM_FIELDS_ARE_NUMBERED))	    printlist(stdout,FALSE);#ifdef EXP_PERSISTENT_COOKIES	/*	 *  We want to save cookies picked up when in immediate dump	 *  mode.  Instead of calling cleanup() here, let's only call	 *  this one. - BJP	 */	if (persistent_cookies)	    LYStoreCookies(LYCookieFile);#endif /* EXP_PERSISTENT_COOKIES */	cleanup_files();	exit_immediately(status);    } else {	/*	 *  Start an INTERACTIVE session. - FM	 */	if (x_display != NULL && *x_display != '\0') {	    LYisConfiguredForX = TRUE;	}#ifdef USE_COLOR_STYLE	cache_tag_styles();#endif	ena_csi((LYlowest_eightbit[current_char_set] > 155));	LYOpenCloset();	status = mainloop();	LYCloseCloset();	cleanup();	exit(status);    }    return(status);	/* though redundant, for compiler-warnings */}