StrAllocCat(lynx_temp_space, "/lynx-XXXXXX"); lynx_temp_space = mkdtemp(lynx_temp_space);
PUBLIC int main ARGS2(	int,		argc,	char **,	argv){    int  i;		/* indexing variable */    int status = 0;	/* exit status */    int len;    char *lynx_cfg_file = NULL;    char *temp = NULL;    char *cp;    FILE *fp;    char filename[256];    BOOL LYGetStdinArgs = FALSE;#ifdef _WINDOWS    WSADATA WSAData;    {	int err;	WORD wVerReq;	wVerReq = MAKEWORD(1,1);	err = WSAStartup(wVerReq, &WSAData);	if (err != 0)	{	    printf("No Winsock found, sorry.");	    sleep(5);	    return;	}    }#endif /* _WINDOWS */#ifdef __DJGPP__if (PDC_get_ctrl_break() == 0) {    PDC_set_ctrl_break(TRUE);    init_ctrl_break[0] = 0;}else {init_ctrl_break[0] = 1;}    atexit(reset_break);    sock_init();#endif#if defined(_WINDOWS) || defined(DJGPP)	/*	 * To prevent corrupting binary data with _WINDOWS and DJGPP	 * we open files and stdout in BINARY mode by default.	 * Where necessary we should open and (close!) TEXT mode.	 */	_fmode = O_BINARY;	setmode( fileno( stdout ), O_BINARY );#endif#ifdef DOSPATH    terminal = "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 (strncmp(argv[i], "-help", 5) == 0) {	    parse_arg(&argv[i], &i, argc);	}    }#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);#endif /* LY_FIND_LEAKS */    /*     *	Register the function which will free our allocated globals.     */    atexit(free_lynx_globals);#ifdef LOCALE    /*     *	LOCALE support for international characters.     */    setlocale(LC_ALL, "");#endif /* LOCALE */    /*     *	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);    LYTrimHead(startfile);    if (!strncasecomp(startfile, "lynxexec:", 9) ||	!strncasecomp(startfile, "lynxprog:", 9)) {	/*	 *  The original implementations of these schemes expected	 *  white space without hex escaping, and did not check	 *  for hex escaping, so we'll continue to support that,	 *  until that code is redone in conformance with SGML	 *  principles.  - FM	 */	HTUnEscapeSome(startfile, " \r\n\t");	convert_to_spaces(startfile, TRUE);    }    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);    putenv(lynx_version_putenv_command);#endif /* VMS */    if ((cp = getenv("LYNX_TEMP_SPACE")) != NULL)	StrAllocCopy(lynx_temp_space, cp);    else#ifdef DOSPATH    if ((cp = getenv("TEMP")) != NULL)	StrAllocCopy(lynx_temp_space, cp);    else if ((cp = getenv("TMP")) != NULL)	StrAllocCopy(lynx_temp_space, cp);    else#endif	StrAllocCopy(lynx_temp_space, TEMP_SPACE);    if ((cp = strchr(lynx_temp_space, '~'))) {	*(cp++) = '\0';	StrAllocCopy(temp, lynx_temp_space);	if (((len = strlen(temp)) > 0) && temp[len-1] == '/')	    temp[len-1] = '\0';#ifdef DOSPATH	StrAllocCat(temp, HTDOS_wwwName((char *)Home_Dir()));#else#ifdef VMS	StrAllocCat(temp, HTVMS_wwwName((char *)Home_Dir()));#else	StrAllocCat(temp, Home_Dir());#endif /* VMS */#endif /* DOSPATH */	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);	}    }#ifdef VMS    for (i = 0; lynx_temp_space[i]; i++)	lynx_temp_space[i] = TOLOWER(lynx_temp_space[i]);    if (strchr(lynx_temp_space, '/') != NULL) {	if ((len = strlen(lynx_temp_space)) == 1) {	    StrAllocCopy(lynx_temp_space, "sys$scratch:");	} else {	    if (lynx_temp_space[len-1] != '/')		StrAllocCat(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#ifndef __DJGPP__    if (((len = strlen(lynx_temp_space)) > 1) &&	lynx_temp_space[len-1] != '/') {	StrAllocCat(lynx_temp_space, "/");    }#else    if (((len = strlen(lynx_temp_space)) > 1) &&	lynx_temp_space[len-1] != '\\') {	StrAllocCat(lynx_temp_space, "\\");    }#endif /* __DJGPP__ */#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);    /*     *	Set up the compilation default character set. - FM     */    for (i = 0; LYchar_set_names[i]; i++) {	if (!strncmp(CHARACTER_SET, LYchar_set_names[i],		     strlen(CHARACTER_SET))) {	    current_char_set=i;	    break;	}    }    if (!LYchar_set_names[i])	current_char_set = i = 0;    HTMLSetRawModeDefault(i);    /*     *	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     */    no_newspost = (LYNewsPosting == FALSE);    /*     *	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 (strncmp(argv[i], "-trace", 6) == 0) {	    WWW_TraceFlag = TRUE;	} else if (strncmp(argv[i], "-tlog", 5) == 0) {	    if (LYUseTraceLog) {		LYUseTraceLog = FALSE;	    } else {		LYUseTraceLog = TRUE;	    }	} else if (strncmp(argv[i], "-anonymous", 10) == 0) {	    if (!LYValidate)		parse_restrictions("default");	    anon_restrictions_set = TRUE;	} else if (strcmp(argv[i], "-validate") == 0) {	    /*	     *	Follow only http URLs.	     */	    LYValidate = TRUE;#ifdef SOCKS	} else if (strncmp(argv[i], "-nosocks", 8) == 0) {	    socks_flag = FALSE;#endif /* SOCKS */	} else if (strncmp(argv[i], "-cfg", 4) == 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 (strncmp(argv[i], "-lss", 4) == 0) {	    if ((cp=strchr(argv[i],'=')) != NULL)		StrAllocCopy(lynx_lss_file, cp+1);	    else {		StrAllocCopy(lynx_lss_file, argv[i+1]);		i++;	    }	    if (TRACE)		fprintf(stderr, "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[1025];	while (fgets(buf, sizeof(buf) - 1, stdin)) {	    int j;	    for (j = strlen(buf) - 1; j > 0 &&		(buf[j] == CR || buf[j] == LF); j--) {		buf[j] = '\0';	    }	    if (strncmp(buf, "-trace", 6) == 0) {		WWW_TraceFlag = TRUE;	    } else if (strncmp(buf, "-tlog", 5) == 0) {		if (LYUseTraceLog) {		    LYUseTraceLog = FALSE;		} else {		    LYUseTraceLog = TRUE;		}	    } else if (strncmp(buf, "-anonymous", 10) == 0) {		if (!LYValidate && !anon_restrictions_set)		    parse_restrictions("default");		anon_restrictions_set = TRUE;	    } else if (strcmp(buf, "-validate") == 0) {		/*		 *  Follow only http URLs.		 */		LYValidate = TRUE;#ifdef SOCKS	    } else if (strncmp(buf, "-nosocks", 8) == 0) {		socks_flag = FALSE;#endif /* SOCKS */	    } else if (strncmp(buf, "-cfg", 4) == 0) {		if ((cp = strchr(buf,'=')) != NULL) {		    StrAllocCopy(lynx_cfg_file, cp+1);		} else {		    cp = buf;		    while (*cp && !isspace((unsigned char)*cp))			cp++;		    while (*cp && isspace((unsigned char)*cp))			cp++;		    if (*cp)			StrAllocCopy(lynx_cfg_file, cp);		}#if defined(USE_HASH)	    } else if (strncmp(buf, "-lss", 4) == 0) {		if ((cp = strchr(buf,'=')) != NULL) {		    StrAllocCopy(lynx_lss_file, cp+1);		} else {		    cp = buf;		    while (*cp && !isspace((unsigned char)*cp))			cp++;		    while (*cp && isspace((unsigned char)*cp))			cp++;		    if (*cp)			StrAllocCopy(lynx_cfg_file, cp);		}		if (TRACE)		    fprintf(stderr, "LYMain found -lss flag, lss file is %s\n",			lynx_lss_file ? lynx_lss_file : "<NONE>");#endif	    } else if (strcmp(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 (fgets(buf, sizeof(buf), stdin) &&		       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 (strcmp(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 (fgets(buf, sizeof(buf), stdin) &&		       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();		    atexit(LYStdinArgs_free);		}		StrAllocCopy(argument, buf);		HTList_appendObject(LYStdinArgs, argument);	    }	}    }#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 && !anon_restrictions_set &&	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");	anon_restrictions_set = TRUE;	LYUseTraceLog = FALSE;    }    /*     *	Set up the TRACE log path, and logging if appropriate. - FM     */#ifdef VMS    StrAllocCopy(LYTraceLogPath, "sys$login:Lynx.trace");#else    StrAllocCopy(LYTraceLogPath, (Home_Dir() ? Home_Dir() : ""));    StrAllocCat(LYTraceLogPath, "/Lynx.trace");#endif /* VMS */    LYOrigStderr = *stderr;    if (TRACE && LYUseTraceLog) {	/*	 *  If we can't open it for writing, give up.	 *  Otherwise, on VMS close it, delete it and any	 *  versions from previous sessions so they don't	 *  accumulate, and open it again. - FM	 */	if ((LYTraceLogFP = LYNewTxtFile(LYTraceLogPath)) == NULL) {	    WWW_TraceFlag = FALSE;	    fprintf(stderr, "%s\n", TRACELOG_OPEN_FAILED);	    exit(-1);	}#ifdef VMS	fclose(LYTraceLogFP);	while (remove(LYTraceLogPath) == 0)	    ;	if ((LYTraceLogFP = LYNewTxtFile(LYTraceLogPath)) == NULL) {	    WWW_TraceFlag = FALSE;	    printf("%s\n", TRACELOG_OPEN_FAILED);	    exit(-1);	}#endif /* VMS */	fflush(stdout);	fflush(stderr);	*stderr = *LYTraceLogFP;	fprintf(stderr, "\t\t%s\n\n", LYNX_TRACELOG_TITLE);    }    /*     *	If TRACE is on, indicate whether the     *	anonymous restrictions are set. - FM     */    if (TRACE && anon_restrictions_set) {	fprintf(stderr, "LYMain: Anonymous restrictions set.\n");    }    /*     *	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)) {		if (TRACE)		    fprintf(stderr, "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] == '~') && (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, "\nConfiguration file %s is not available.\n\n",			lynx_cfg_file);	exit(-1);    }    fclose(fp);    /*     * Make sure we have the character sets declared.     *	This will initialize the CHARTRANS handling. - KW     */    if (!LYCharSetsDeclared()) {	fprintf(stderr, "\nLynx character sets 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);	if ((len=strlen(temp)) > 0 && temp[len-1] == '/')	    temp[len-1] = '\0';#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, "\nLynxile file %s is not available.\n\n",			lynx_lss_file);    }    else    {	fclose(fp);	style_readFromFile(lynx_lss_file);    }#endif    /*     *	Make sure we have the edit map declared. - FM     */    if (!LYEditmapDeclared()) {	fprintf(stderr, "\nLynx edit map not declared.\n\n");	exit(-1);    }#if USE_COLOR_TABLE    /*     *	Set up default foreground and background colors.     */    lynx_setup_colors();#endif /* USE_SLANG */    /*     *	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);	if (TRACE)	    fprintf(stderr, "LYNX_SIG_FILE set to '%s'\n", LynxSigFile);    } else {	if (TRACE)	    fprintf(stderr, "LYNX_SIG_FILE '%s' is bad. Ignoring.\n",			    LYNX_SIG_FILE);    }    /*     *	Process the configuration file.     */    if (TRACE) {	fprintf(stderr,		"Loading cfg file '%s'.\n", lynx_cfg_file);    }    read_cfg(lynx_cfg_file);    FREE(lynx_cfg_file);    HTSwitchDTD(New_DTD);    /*     *	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);	    if (((len = strlen(temp)) > 0) && temp[len-1] == '/')		temp[len-1] = '\0';#ifdef DOSPATH	    StrAllocCat(temp, HTDOS_wwwName((char *)Home_Dir()));#else#ifdef VMS	    StrAllocCat(temp, HTVMS_wwwName((char *)Home_Dir()));#else	    StrAllocCat(temp, Home_Dir());#endif /* VMS */#endif /* DOSPATH */	    StrAllocCat(temp, cp);	    StrAllocCopy(lynx_save_space, temp);	    FREE(temp);	}#ifdef VMS	for (i = 0; lynx_save_space[i]; i++)	    lynx_save_space[i] = TOLOWER(lynx_save_space[i]);	if (strchr(lynx_save_space, '/') != NULL) {	    if ((len = strlen(lynx_save_space)) == 1) {		StrAllocCopy(lynx_save_space, "sys$login:");	    } else {		if (lynx_save_space[len-1] != '/')		    StrAllocCat(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    {	if (((len = strlen(lynx_save_space)) > 1) &&	    lynx_save_space[len-1] != '/') {	    StrAllocCat(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();    /*     *	Get WWW_HOME environment variable if it exists.     */    if ((cp = getenv("WWW_HOME")) != NULL) {	StrAllocCopy(startfile, cp);	LYTrimHead(startfile);	if (!strncasecomp(startfile, "lynxexec:", 9) ||	    !strncasecomp(startfile, "lynxprog:", 9)) {	    /*	     *	The original implementations of these schemes expected	     *	white space without hex escaping, and did not check	     *	for hex escaping, so we'll continue to support that,	     *	until that code is redone in conformance with SGML	     *	principles.  - FM	     */	    HTUnEscapeSome(startfile, " \r\n\t");	    convert_to_spaces(startfile, TRUE);	}    }    /*     *	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");    /*     *	Process any command line arguments not already handled. - FM     */    for (i = 1; i < argc; i++) {	parse_arg(&argv[i], &i, argc);    }    /*     *	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, NULL, -1);	}	LYStdinArgs_free();    }#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 */    /*     *	Process the RC file.     */    read_rc();#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 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 */    /*     *	Set up the proper character set with the desired     *	startup raw 8-bit or CJK mode handling.  - FM     */    HTMLUseCharacterSet(current_char_set);    /*     *	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");    /*     *	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");    }    /*     *	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;	news_ok = !no_inside_news && !no_outside_news && news_ok;	ftp_ok = !no_inside_ftp && !no_outside_ftp && ftp_ok;	rlogin_ok = !no_inside_rlogin && !no_outside_rlogin && rlogin_ok;#else	if (TRACE)	   fprintf(stderr,"LYMain.c: User in Local domain\n");	telnet_ok = !no_inside_telnet && telnet_ok;	news_ok = !no_inside_news && news_ok;	ftp_ok = !no_inside_ftp && ftp_ok;	rlogin_ok = !no_inside_rlogin && rlogin_ok;#endif /* !HAVE_UTMP || VMS */    } else {	if (TRACE)	   fprintf(stderr,"LYMain.c: User in REMOTE domain\n");	telnet_ok = !no_outside_telnet && telnet_ok;	news_ok = !no_outside_news && news_ok;	ftp_ok = !no_outside_ftp && ftp_ok;	rlogin_ok = !no_outside_rlogin && rlogin_ok;    }#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);#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);    }    /*     *	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);#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);    }    /*     *	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);#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);    }    /*     *	Set up our help and about file base paths. - FM     */    StrAllocCopy(helpfilepath, helpfile);    if ((cp=strrchr(helpfilepath, '/')) != NULL)	*cp = '\0';    /*     *	Remove code to merge the historical about_lynx     *	directory into lynx_help. - HN     */    StrAllocCat(helpfilepath, "/");    /*     *	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 (display != NULL && *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);#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 */    } else {	/*	 *  Finish setting up and start an	 *  INTERACTIVE session. - FM	 */	if (setup(terminal)) {	    if (display != NULL && *display != '\0') {		LYisConfiguredForX = TRUE;	    }	    ena_csi((LYlowest_eightbit[current_char_set] > 155));	    status = mainloop();	    cleanup();	}    }    exit(status);}