📄 lymain.c
字号:
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");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -