[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lynx-dev show lynx.cfg from options/info page
From: |
Leonid Pauzner |
Subject: |
lynx-dev show lynx.cfg from options/info page |
Date: |
Fri, 18 Sep 1998 14:28:55 +0400 (MSD) |
Patch against dev28:
* Create "lynx.cfg Information" page, comments skipped, "include" OK.
The link available from '='InfoPage and 'O'ptions menu. It is assumed
that distribution's "lynx.cfg" now in lynx_help/ as most advanced docs. - LP
diff -u old/lyglobal.h ./lyglobal.h
--- old/lyglobal.h Thu Sep 17 22:52:42 1998
+++ ./lyglobal.h Thu Sep 17 14:35:24 1998
@@ -23,6 +23,7 @@
#define DIRED_MENU_HELP "keystrokes/dired_help.html"
#define DOWNLOAD_OPTIONS_HELP "Lynx_users_guide.html#RemoteSource"
#define HISTORY_PAGE_HELP "keystrokes/history_help.html"
+#define LYNXCFG_HELP "lynx.cfg"
#define LIST_PAGE_HELP "keystrokes/follow_help.html"
#define OPTIONS_HELP "keystrokes/option_help.html"
#define PRINT_OPTIONS_HELP "keystrokes/print_help.html"
diff -u old/lymessag.h ./lymessag.h
--- old/lymessag.h Thu Sep 17 22:54:06 1998
+++ ./lymessag.h Fri Sep 18 11:59:42 1998
@@ -662,6 +662,7 @@
#define DOWNLOAD_OPTIONS_TITLE "Download Options"
#define HISTORY_PAGE_TITLE "History Page"
#define LIST_PAGE_TITLE "List Page"
+#define LYNXCFG_TITLE "Lynx.cfg Information"
#define OPTIONS_TITLE "Options Menu"
#define PERMIT_OPTIONS_TITLE "File Permission Options"
#define PRINT_OPTIONS_TITLE "Printing Options"
diff -u old/lyoption.c ./lyoption.c
--- old/lyoption.c Thu Sep 17 22:52:46 1998
+++ ./lyoption.c Fri Sep 18 12:02:52 1998
@@ -19,6 +19,7 @@
#include <LYBookmark.h>
#include <GridText.h>
#include <LYGetFile.h>
+#include <LYReadCFG.h>
#include <LYLeaks.h>
@@ -3362,19 +3363,17 @@
BOOLEAN raw_mode_changed = FALSE;
BOOLEAN assume_char_set_changed = FALSE;
BOOLEAN need_reload = FALSE;
- char *link_info = NULL;
int CurrentShowColor = LYShowColor;
/*-------------------------------------------------
* kludge a link from mbm_menu, the URL was:
- * fprintf(fp0,"<a href=\"LYNXOPTIONS://MBM_MENU\">go mbm menu</a>\n");
+ * "<a href=\"LYNXOPTIONS://MBM_MENU\">Goto multi-bookmark menu</a>\n"
*--------------------------------------------------*/
- StrAllocCopy(link_info, newdoc->address);
- if (strstr(link_info, "LYNXOPTIONS://MBM_MENU")) {
- edit_bookmarks();
+ if (strstr(newdoc->address, "LYNXOPTIONS://MBM_MENU")) {
FREE(newdoc->post_data);
FREE(data);
+ edit_bookmarks();
return(NULLFILE);
}
@@ -4017,6 +4016,10 @@
PutTextInput(fp0, user_agent_string,
NOTEMPTY(LYUserAgent), text_len, "");
}
+
+ fprintf(fp0,
+ "<a href=\"%s\">lynx.cfg information (read-only)</a>\n",
+ lynx_cfg_infopage());
fprintf(fp0,"\n</pre>\n");
diff -u old/lyreadcf.c ./lyreadcf.c
--- old/lyreadcf.c Mon Sep 14 01:29:40 1998
+++ ./lyreadcf.c Fri Sep 18 13:44:16 1998
@@ -973,6 +973,8 @@
/*
* Process the configuration file (lynx.cfg).
+ *
+ * (please synchronize info_read_cfg() below if you change something here).
*/
PUBLIC void read_cfg ARGS3(
char *, cfg_filename,
@@ -1176,4 +1178,192 @@
if (LYCookieRejectDomains != NULL) {
cookie_add_rejectlist(LYCookieRejectDomains);
}
+}
+
+
+/*
+ * Read the configuration file (lynx.cfg),
+ * write the bare info for lynx_cfg_infopage() into a file.
+ *
+ * (plain stolen from read_cfg() above, please synchronize with read_cfg()
+ * if you change something here).
+ */
+PRIVATE void info_read_cfg ARGS4(
+ char *, cfg_filename,
+ char *, parent_filename,
+ int, nesting_level,
+ FILE *, fp0)
+{
+ FILE *fp;
+ char buffer[MAX_LINE_BUFFER_LEN];
+
+ CTRACE(tfp, "Loading cfg file '%s'.\n", cfg_filename);
+
+ /*
+ * Don't get hung up by an include file loop. Arbitrary max depth
+ * of 10. - BL
+ */
+ if (nesting_level > 10) {
+ fprintf(stderr,
+ "More than %d nested lynx.cfg includes -- perhaps there is a
loop?!?\n",
+ nesting_level - 1);
+ fprintf(stderr,"Last attempted include was '%s',\n", cfg_filename);
+ fprintf(stderr,"included from '%s'.\n", parent_filename);
+ exit(-1);
+ }
+ /*
+ * Locate and open the file.
+ */
+ if (!cfg_filename || strlen(cfg_filename) == 0) {
+ CTRACE(tfp,"No filename following -cfg switch!\n");
+ return;
+ }
+ if ((fp = fopen(cfg_filename,"r")) == 0) {
+ CTRACE(tfp,"lynx.cfg file not found as %s\n",cfg_filename);
+ return;
+ }
+ have_read_cfg = TRUE;
+
+ /*
+ * Process each line in the file.
+ */
+ while (fgets(buffer, sizeof(buffer), fp) != 0) {
+ char *name, *value;
+ char *cp;
+ Config_Type *tbl;
+ char ch;
+#ifdef PARSE_DEBUG
+ Config_Type *q;
+#else
+ ConfigUnion *q;
+#endif
+
+ /* Most lines in the config file are comment lines. Weed them out
+ * now. Also, leading whitespace is ok, so trim it.
+ */
+ name = LYSkipBlanks(buffer);
+
+ if (*name == '#')
+ continue;
+
+ LYTrimTrailing(name);
+
+ if (*name == 0) continue;
+
+ /* Significant lines are of the form KEYWORD:WHATEVER */
+ if ((value = strchr (name, ':')) == 0) {
+ /* fprintf (stderr, "Bad line-- no :\n"); */
+ continue;
+ }
+
+ /* skip past colon, but replace ':' with 0 to make name meaningful */
+ *value++ = 0;
+
+ /*
+ * Trim off any trailing comments.
+ *
+ * (Apparently, the original code considers a trailing comment
+ * valid only if preceded by a space character but is not followed
+ * by a colon. -- JED)
+ */
+ if ((cp = strrchr (value, ':')) == 0)
+ cp = value;
+ if ((cp = strchr (cp, '#')) != 0) {
+ cp--;
+ if (isspace ((unsigned char) *cp))
+ *cp = 0;
+ }
+
+ tbl = Config_Table;
+ ch = TOUPPER(*name);
+ while (tbl->name != 0) {
+ char ch1 = tbl->name[0];
+
+ if ((ch == TOUPPER(ch1))
+ && (0 == strcasecomp (name, tbl->name)))
+ break;
+
+ tbl++;
+ }
+
+ if (tbl->name == 0) {
+ /* Apparently, lynx ignores unknown keywords */
+ /* fprintf (stderr, "%s not found in config file */
+ continue;
+ }
+
+#ifdef PARSE_DEBUG
+ q = tbl;
+#else
+ q = (ConfigUnion *)(&(tbl->value));
+#endif
+/****** info_read_cfg() special: ******************/
+
+ switch (tbl->type) {
+
+ case CONF_INCLUDE:
+ /* include another file */
+ fprintf(fp0, "%s:%s\n\n", name, value);
+ fprintf(fp0, " #<begin %s>\n", value);
+ info_read_cfg (value, cfg_filename, nesting_level + 1, fp0);
+ fprintf(fp0, " #<end of %s>\n\n", value);
+ break;
+
+ default:
+ fprintf(fp0, "%s:%s\n", name, value);
+ break;
+ }
+ }
+
+ fclose (fp);
+}
+
+
+/*
+ * lynx.cfg infopage, returns local url.
+ */
+PUBLIC char *lynx_cfg_infopage NOARGS
+{
+ static char tempfile[LY_MAXPATH];
+ static char *local_url;
+ char *temp;
+ FILE *fp0;
+
+ LYRemoveTemp(tempfile);
+ if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) {
+ HTAlert(CANNOT_OPEN_TEMP);
+ return(0);
+ }
+ LYLocalFileToURL(&local_url, tempfile);
+
+ LYforce_no_cache = TRUE; /* don't cache this doc */
+
+
+#ifdef HAVE_CONFIG_H
+ StrAllocCopy(temp, LYNX_CFG_FILE);
+#else
+ StrAllocCopy(temp, helpfilepath);
+ StrAllocCat(temp, LYNXCFG_HELP); /* DJGPP/Win32/VMS should care of */
+#endif /* HAVE_CONFIG_H */
+
+ BeginInternalPage (fp0, LYNXCFG_TITLE, NULL);
+ fprintf(fp0, "<pre>\n");
+ fprintf(fp0, "<em>This is a bare information from your lynx.cfg
file,\n");
+
+ fprintf(fp0, "please \"read\" distribution's <a href=\"%s\">lynx.cfg",
+ temp);
+ fprintf(fp0, "</a> for more comments.</em>\n\n");
+
+ fprintf(fp0, " #<em>Your primary configuration %s</em>\n",
+ lynx_cfg_file);
+ /*
+ * Process the configuration file.
+ */
+ info_read_cfg(lynx_cfg_file, "main program", 1, fp0);
+
+ fprintf(fp0, "</pre>\n");
+ EndInternalPage(fp0);
+ LYCloseTempFP(fp0);
+
+ return(local_url);
}
diff -u old/lyreadcf.h ./lyreadcf.h
--- old/lyreadcf.h Fri Jul 24 20:01:04 1998
+++ ./lyreadcf.h Thu Sep 17 14:18:36 1998
@@ -43,8 +43,11 @@
extern int check_color PARAMS((char * color, int the_default));
#endif
+
extern void read_cfg PARAMS((char *cfg_filename, char *parent_filename, int
nesting_level));
extern void free_lynx_cfg NOPARAMS;
extern BOOLEAN have_read_cfg;
+
+extern char *lynx_cfg_infopage NOPARAMS;
#endif /* LYREADCFG_H */
diff -u old/lyshowin.c ./lyshowin.c
--- old/lyshowin.c Thu Sep 17 23:25:34 1998
+++ ./lyshowin.c Fri Sep 18 13:44:48 1998
@@ -28,11 +28,15 @@
#define PutDefs(table, n) fprintf(fp0, "%-35s %s\n", table[n].name,
table[n].value)
+/*
+ * Compile-time definitions info, returns local url
+ */
PRIVATE char *lynx_compile_opts NOARGS
{
- static char tempfile[256];
+ static char tempfile[LY_MAXPATH];
#include <cfg_defs.h>
unsigned n;
+ static char *info_url;
FILE *fp0;
if (strlen(tempfile) == 0) {
@@ -41,8 +45,14 @@
tempfile[0] = '\0';
return(0);
}
+ LYLocalFileToURL(&info_url, lynx_compile_opts());
+
BeginInternalPage (fp0, CONFIG_DEF_TITLE, NULL);
fprintf(fp0, "<pre>\n");
+
+ fprintf(fp0, "See also <a href=\"%s\">lynx.cfg</a> for run-time
options\n\n",
+ lynx_cfg_infopage());
+
fprintf(fp0, "\n<em>config.cache</em>\n");
for (n = 0; n < TABLESIZE(config_cache); n++) {
PutDefs(config_cache, n);
@@ -55,7 +65,7 @@
EndInternalPage(fp0);
LYCloseTempFP(fp0);
}
- return tempfile;
+ return info_url;
}
#else
#undef HAVE_CFG_DEFS_H
@@ -72,7 +82,7 @@
document *, newdoc,
char *, owner_address)
{
- static char tempfile[256];
+ static char tempfile[LY_MAXPATH];
static char *info_url;
int url_type;
FILE *fp0;
@@ -123,12 +133,11 @@
(LYNX_RELEASE ? LYNX_WWW_HOME : LYNX_WWW_DIST),
(LYNX_RELEASE ? "latest release" : "development version") );
#ifdef HAVE_CFG_DEFS_H
- LYLocalFileToURL(&info_url, lynx_compile_opts());
fprintf(fp0, " - <a href=\"%s\">compile time settings</a></h1>\n",
- info_url);
+ lynx_compile_opts());
#else
- fprintf(fp0, "</h1>\n"
- ); /* do not forget to close </h1> */
+ fprintf(fp0, " - <a href=\"%s\">lynx.cfg</a></h1>\n",
+ lynx_cfg_infopage());
#endif
#ifdef DIRED_SUPPORT
Only in .: old
- lynx-dev show lynx.cfg from options/info page,
Leonid Pauzner <=