lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lynx-dev (patch) activate lynx.cfg changes for current lynx session


From: Leonid Pauzner
Subject: lynx-dev (patch) activate lynx.cfg changes for current lynx session
Date: Tue, 6 Apr 1999 01:48:31 +0400 (MSD)

* lynx.cfg and farther included cfg files can be edited from LYNXCFG:/ page
  with the default editor and changes can be activated for the same
  lynx session.  NOT allowed for restricted users (LYRestricted) and
  occasionally for user mode other than ADVANCED.  This is an *experimental*
  code (reload_read_cfg() in LYMain.c - more work required): currently
  command-line switches may be lost when overriden by lynx.cfg changes,
  file paths like lynx_temp_space and LYCookieFile should not be changed
  (unwanted results). - LP


This is a rather long patch over my previous patches
but really independent since changes affects other parts of the code.

Comments:
1) lynx_cfg_infopage() and lynx_compile_opts() both absorb some code
   from LYGetFile.c - this may be not nice but add more flexibility.
   lynx_cfg_infopage() now gains a lot from postoptions() code.
2) lynx_compile_opts() moved from LYShowInfo.c to LYReadCFG.c
3) other minore changes for lynx_cfg_infopage() HTML layout made.
4) two pages excluded from Visited Links page.
5) contributions for reload_read_cfg() always welcome.




diff -u old/lygetfil.c ./lygetfil.c
--- old/lygetfil.c      Wed Mar 31 15:48:14 1999
+++ ./lygetfil.c        Mon Apr  5 23:36:24 1999
@@ -250,33 +250,13 @@
 #endif

                } else if (url_type == LYNXCFG_URL_TYPE) {
-                   /* show lynx.cfg settings */
-                   StrAllocCopy(doc->address, lynx_cfg_infopage());
-                   WWWDoc.address = doc->address;
-                   WWWDoc.post_data = doc->post_data;
-                   WWWDoc.post_content_type = doc->post_content_type;
-                   WWWDoc.bookmark = doc->bookmark;
-                   WWWDoc.isHEAD = doc->isHEAD;
-                   WWWDoc.safe = doc->safe;
+                   /* show/change/reload lynx.cfg settings */
+                   return(lynx_cfg_infopage(doc));

-                   if (!HTLoadAbsolute(&WWWDoc))
-                        return(NOT_FOUND);
-                   return(NORMAL);
-
-#ifdef HAVE_CFG_DEFS_H
+#if defined(HAVE_CONFIG_H) && !defined(NO_CONFIG_INFO)
                } else if (url_type == LYNXCOMPILE_OPTS_URL_TYPE) {
                    /* show compile-time settings */
-                   StrAllocCopy(doc->address, (char *)lynx_compile_opts());
-                   WWWDoc.address = doc->address;
-                   WWWDoc.post_data = doc->post_data;
-                   WWWDoc.post_content_type = doc->post_content_type;
-                   WWWDoc.bookmark = doc->bookmark;
-                   WWWDoc.isHEAD = doc->isHEAD;
-                   WWWDoc.safe = doc->safe;
-
-                   if (!HTLoadAbsolute(&WWWDoc))
-                        return(NOT_FOUND);
-                   return(NORMAL);
+                   return(lynx_compile_opts(doc));
 #endif

 #ifndef DISABLE_NEWS
diff -u old/lyhistor.c ./lyhistor.c
--- old/lyhistor.c      Wed Mar 31 00:43:06 1999
+++ ./lyhistor.c        Mon Apr  5 23:36:02 1999
@@ -67,6 +67,7 @@
      * or list files. - FM
      */
     if (doc->post_data || doc->isHEAD || doc->bookmark ||
+       (!strncmp(doc->address, "file://localhost/", 17) && (
        !strcmp((doc->title ? doc->title : ""), HISTORY_PAGE_TITLE) ||
        !strcmp((doc->title ? doc->title : ""), PRINT_OPTIONS_TITLE) ||
        !strcmp((doc->title ? doc->title : ""), DOWNLOAD_OPTIONS_TITLE) ||
@@ -82,9 +83,11 @@
        !strcmp((doc->title ? doc->title : ""), ADDRLIST_PAGE_TITLE) ||
 #endif
        !strcmp((doc->title ? doc->title : ""), SHOWINFO_TITLE) ||
+       !strcmp((doc->title ? doc->title : ""), CONFIG_DEF_TITLE) ||
+       !strcmp((doc->title ? doc->title : ""), LYNXCFG_TITLE) ||
        !strcmp((doc->title ? doc->title : ""), COOKIE_JAR_TITLE) ||
        !strcmp((doc->title ? doc->title : ""), VISITED_LINKS_TITLE) ||
-       !strcmp((doc->title ? doc->title : ""), LYNX_TRACELOG_TITLE)) {
+       !strcmp((doc->title ? doc->title : ""), LYNX_TRACELOG_TITLE)))) {
        return;
     }

diff -u old/lymain.c ./lymain.c
--- old/lymain.c        Sun Apr  4 15:37:18 1999
+++ ./lymain.c  Mon Apr  5 23:55:22 1999
@@ -1362,15 +1362,15 @@
     LYEnsureAbsoluteURL((char **)&LynxHome, "LynxHome");

     /*
-     * Process any command line arguments not already handled. - FM
+     *  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
+     *  Process any stdin-derived arguments for a lone "-"  which we've
+     *  loaded into LYStdinArgs. - FM
      */
     if (LYStdinArgs != NULL) {
        char *my_args[2];
@@ -1384,7 +1384,7 @@
     }

     /*
-     * Set the rest of variables when the configuration have read.
+     *  Initialize other things based on the configuration read.
      */

     HTSwitchDTD(!Old_DTD);
@@ -1421,6 +1421,14 @@
 #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
@@ -1709,14 +1717,6 @@
     }

     /*
-     * Set up our help and about file base paths. - FM
-     */
-    StrAllocCopy(helpfilepath, helpfile);
-    if ((cp = LYPathLeaf(helpfilepath)) != helpfilepath)
-       *cp = '\0';
-    LYAddHtmlSep(&helpfilepath);
-
-    /*
      * Make sure our bookmark default strings
      * are all allocated and synchronized. - FM
      */
@@ -1810,6 +1810,59 @@
     HTRegisterProtocol(&LYLynxIMGmap);
     HTRegisterProtocol(&LYLynxCookies);
 }
+
+
+/*
+ *  Some staff to reload lynx.cfg without restarting new lynx session,
+ *  also load options menu items and command-line options
+ *  to made things consistent.  Not implemented yet.
+ *  Warning: experimental, more main() reorganization required.
+ *
+ *  Called by user of interactive session by LYNXCFG://reload/ link.
+ */
+PUBLIC void reload_read_cfg NOARGS
+{
+    if (!LYRestricted) {
+
+       /* save .lynxrc file in case we change something from Options Menu */
+       if (!save_rc()) return;
+
+       /*
+        *  Process the configuration file.
+        */
+       read_cfg(lynx_cfg_file, "main program", 1, (FILE *)0);
+
+       /*
+        *  Process the RC file.
+        */
+       read_rc();
+
+
+               /* We are not interested in startfile here */
+               /* but other things may be lost: */
+
+       /*
+        *  Process any command line arguments not already handled. - FM
+        */
+               /* Not implemented yet here */
+
+       /*
+        *  Process any stdin-derived arguments for a lone "-"  which we've
+        *  loaded into LYStdinArgs. - FM
+        */
+               /* Not implemented yet here */
+
+       /*
+        *  Initialize other things based on the configuration read.
+        */
+               /* Not implemented yet here,
+                * a major problem: file paths
+                * like lynx_temp_space, LYCookieFile etc.
+                */
+
+    }
+}
+

 /* There are different ways of setting arguments on the command line, and
  * there are different types of arguments.  These include:
diff -u old/lyreadcf.c ./lyreadcf.c
--- old/lyreadcf.c      Mon Apr  5 17:52:24 1999
+++ ./lyreadcf.c        Mon Apr  5 23:36:06 1999
@@ -1034,8 +1034,6 @@
      {0}
 };

-PRIVATE char *local_url = NULL;
-
 /*
  * Free memory allocated in 'read_cfg()'
  */
@@ -1060,7 +1058,6 @@
            break;
        }
     }
-    FREE(local_url);
 }

 /*
@@ -1238,19 +1235,28 @@
        case CONF_INCLUDE:
            /* include another file */
 #ifndef NO_CONFIG_INFO
-           if (fp0 != 0) {
+           if (fp0 != 0  &&  !LYRestricted) {
                char *url = 0;
+               char *cp1 = NULL;
                LYLocalFileToURL(&url, value);
-               fprintf(fp0, "%s:<a href=\"%s\">%s</a>\n\n", name, url, value);
-               fprintf(fp0, "    #&lt;begin  %s&gt;\n", value);
+               StrAllocCopy(cp1, value);
+               if (strchr(value, '&') || strchr(value, '<')) {
+                   LYEntify(&cp1, TRUE);
+               }
+
+               fprintf(fp0, "%s:<a href=\"%s\">%s</a>\n\n", name, url, cp1);
+               fprintf(fp0, "    #&lt;begin  %s&gt;\n", cp1);
+
+           read_cfg (value, cfg_filename, nesting_level + 1, fp0);
+
+               fprintf(fp0, "    #&lt;end of %s&gt;\n\n", cp1);
                FREE(url);
-           }
-#endif
+               FREE(cp1);
+           } else
+#endif /* !NO_CONFIG_INFO */
+
            read_cfg (value, cfg_filename, nesting_level + 1, fp0);
-#ifndef NO_CONFIG_INFO
-           if (fp0 != 0)
-               fprintf(fp0, "    #&lt;end of %s&gt;\n\n", value);
-#endif
+
            break;

        case CONF_ADD_ITEM:
@@ -1355,19 +1361,78 @@

 }

+
+extern void reload_read_cfg NOPARAMS; /* not implemented yet, in LYMain.c */
+
 /*
- * lynx.cfg infopage, returns local url.
+ *  Show rendered lynx.cfg data without comments, LYNXCFG:/ internal page.
+ *  Called from getfile() cyrcle:
+ *  we create and load the page just in place and return to mainloop().
  */
-PUBLIC char *lynx_cfg_infopage NOARGS
+PUBLIC int lynx_cfg_infopage ARGS1(
+    document *,                newdoc)
 {
     char tempfile[LY_MAXPATH];
+    static char *local_url;  /* static! */
+    DocAddress WWWDoc;  /* need on exit */
     char *temp = 0;
+    char *cp1 = NULL;
     FILE *fp0;

+
+#ifndef NO_CONFIG_INFO
+    /*-------------------------------------------------
+     * kludge a link from LYNXCFG:/, the URL was:
+     * "  <a href=\"LYNXCFG://reload\">RELOAD THE CHANGES</a>\n"
+     *--------------------------------------------------*/
+
+    if ((strstr(newdoc->address, "LYNXCFG://reload")) && !LYRestricted) {
+       /*
+        *  Some staff to reload read_cfg(),
+        *  but also load options menu items and command-line options
+        *  to made things consistent.  Not implemented yet. Dummy.
+        */
+       reload_read_cfg();
+
+       /*
+        *  now pop-up and return to updated LYNXCFG:/ page,
+        *  remind postoptions() but much simpler:
+        */
+
+           /*  the page was pushed, 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 obsolete file again without this (overhead).
+            *
+            * Probably *no_cache was set in a wrong position because of
+            * the internal page...
+            */
+           if (!HTLoadAbsolute(&WWWDoc))
+               return(NOT_FOUND);
+
+
+       /* FIXME: probably remove obsolete temp file just now (before exit)? */
+
+       /* now set up the flag and fall down to create a new LYNXCFG:/ page */
+        local_url = 0;  /* see below */
+    }
+#endif /* !NO_CONFIG_INFO */
+
+
     if (local_url == 0) {
        if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) {
            HTAlert(CANNOT_OPEN_TEMP);
-           return(0);
+           return(NOT_FOUND);
        }
        LYLocalFileToURL(&local_url, tempfile);

@@ -1376,13 +1441,15 @@
        BeginInternalPage (fp0, LYNXCFG_TITLE, NULL);
        fprintf(fp0, "<pre>\n");

+
 #ifndef NO_CONFIG_INFO
+       if (!LYRestricted) {
 #if defined(HAVE_CONFIG_H) || defined(VMS)
        if (strcmp(lynx_cfg_file, LYNX_CFG_FILE)) {
-           StrAllocCopy(temp, LYNX_CFG_FILE);
            fprintf(fp0, "<em>%s\n%s",
                         gettext("This is read from your lynx.cfg file,"),
                         gettext("please \"read\" distribution's"));
+           LYLocalFileToURL(&temp, LYNX_CFG_FILE);
            fprintf(fp0, " <a href=\"%s\">lynx.cfg</a> ",
                         temp);
            FREE(temp);
@@ -1396,20 +1463,32 @@
                         gettext("This is read from your lynx.cfg file,"),
                         gettext("please \"read\" distribution's"));
            fprintf(fp0, " </em>lynx.cfg<em> ");
-           fprintf(fp0, "%s</em>\n\n",
+           fprintf(fp0, "%s</em>\n",
                         gettext("for more comments."));
        }

+/** a new experimental link ... **/
+       if (user_mode == ADVANCED_MODE)
+           fprintf(fp0, "  <a href=\"LYNXCFG://reload\">%s</a>\n",
+                       gettext("RELOAD THE CHANGES"));
+
+
        LYLocalFileToURL(&temp, lynx_cfg_file);
-       fprintf(fp0, "    #<em>%s <a href=\"%s\">%s</a></em>\n",
+       StrAllocCopy(cp1, lynx_cfg_file);
+       if (strchr(lynx_cfg_file, '&') || strchr(lynx_cfg_file, '<')) {
+           LYEntify(&cp1, TRUE);
+       }
+       fprintf(fp0, "\n    #<em>%s <a href=\"%s\">%s</a></em>\n",
                    gettext("Your primary configuration"),
                    temp,
-                   lynx_cfg_file);
+                   cp1);
        FREE(temp);
+       FREE(cp1);
+
+       } else
+#endif /* !NO_CONFIG_INFO */

-#else
        fprintf(fp0, "<em>%s</em>\n\n", gettext("This is read from your 
lynx.cfg file:"));
-#endif /* NO_CONFIG_INFO */

        /*
         *  Process the configuration file.
@@ -1421,5 +1500,78 @@
        LYCloseTempFP(fp0);
     }

-    return(local_url);
+                   /* return to getfile() cyrcle */
+                   StrAllocCopy(newdoc->address, local_url);
+                   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);
+}
+
+
+#if defined(HAVE_CONFIG_H) && !defined(NO_CONFIG_INFO)
+/*
+ *  Compile-time definitions info, LYNXCOMPILEOPTS:/ internal page,
+ *  from getfile() cyrcle.
+ */
+PUBLIC int lynx_compile_opts ARGS1(
+    document *,                newdoc)
+{
+    char tempfile[LY_MAXPATH];
+#define PutDefs(table, N) fprintf(fp0, "%-35s %s\n", table[N].name, 
table[N].value)
+#include <cfg_defs.h>
+    unsigned n;
+    static char *info_url;  /* static! */
+    DocAddress WWWDoc;  /* need on exit */
+    FILE *fp0;
+
+    /* create the page only once - compile-time data will not change... */
+
+    if (info_url == 0) {
+       if ((fp0 = LYOpenTemp (tempfile, HTML_SUFFIX, "w")) == 0) {
+           HTAlert(CANNOT_OPEN_TEMP);
+           return(NOT_FOUND);
+       }
+       LYLocalFileToURL(&info_url, tempfile);
+
+       BeginInternalPage (fp0, CONFIG_DEF_TITLE, NULL);
+       fprintf(fp0, "<pre>\n");
+
+       fprintf(fp0, "%s %s<a href=\"LYNXCFG:\"> lynx.cfg</a> %s\n\n",
+           SEE_ALSO,
+           YOUR_SEGMENT,
+           RUNTIME_OPT_SEGMENT);
+
+       fprintf(fp0, "\n%s<br>\n<em>config.cache</em>\n", 
AUTOCONF_CONFIG_CACHE);
+       for (n = 0; n < TABLESIZE(config_cache); n++) {
+           PutDefs(config_cache, n);
+       }
+       fprintf(fp0, "\n%s<br>\n<em>lynx_cfg.h</em>\n", AUTOCONF_LYNXCFG_H);
+       for (n = 0; n < TABLESIZE(config_defines); n++) {
+           PutDefs(config_defines, n);
+       }
+       fprintf(fp0, "</pre>\n");
+       EndInternalPage(fp0);
+       LYCloseTempFP(fp0);
+    }
+
+                   /* exit to getfile() cyrcle */
+                   StrAllocCopy(newdoc->address, info_url);
+                   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);
 }
+#endif /* !NO_CONFIG_INFO */
diff -u old/lyreadcf.h ./lyreadcf.h
--- old/lyreadcf.h      Wed Mar 31 00:43:12 1999
+++ ./lyreadcf.h        Mon Apr  5 23:36:20 1999
@@ -47,7 +47,7 @@
 extern void free_lynx_cfg NOPARAMS;
 extern BOOLEAN have_read_cfg;

-extern char *lynx_cfg_infopage NOPARAMS;
-extern char *lynx_compile_opts NOPARAMS;
+extern int lynx_cfg_infopage PARAMS((document *newdoc));
+extern int lynx_compile_opts PARAMS((document *newdoc));

 #endif /* LYREADCFG_H */
diff -u old/lyshowin.c ./lyshowin.c
--- old/lyshowin.c      Wed Mar 31 00:43:12 1999
+++ ./lyshowin.c        Mon Apr  5 23:36:28 1999
@@ -24,55 +24,6 @@

 #define ADVANCED_INFO 1                /* to get more info in advanced mode */

-#if defined(HAVE_CONFIG_H) && !defined(NO_CONFIG_INFO)
-#define HAVE_CFG_DEFS_H
-
-#define PutDefs(table, N) fprintf(fp0, "%-35s %s\n", table[N].name, 
table[N].value)
-
-/*
- *  Compile-time definitions info, returns local url
- */
-PUBLIC char *lynx_compile_opts NOARGS
-{
-    char tempfile[LY_MAXPATH];
-#include <cfg_defs.h>
-    unsigned n;
-    static char *info_url;
-    FILE *fp0;
-
-    if (info_url == 0) {
-       if ((fp0 = LYOpenTemp (tempfile, HTML_SUFFIX, "w")) == 0) {
-           HTAlert(CANNOT_OPEN_TEMP);
-           return(0);
-       }
-       LYLocalFileToURL(&info_url, tempfile);
-
-       BeginInternalPage (fp0, CONFIG_DEF_TITLE, NULL);
-       fprintf(fp0, "<pre>\n");
-
-       fprintf(fp0, "%s %s<a href=\"LYNXCFG:\"> lynx.cfg</a> %s\n\n",
-           SEE_ALSO,
-           YOUR_SEGMENT,
-           RUNTIME_OPT_SEGMENT);
-
-       fprintf(fp0, "\n%s<br>\n<em>config.cache</em>\n", 
AUTOCONF_CONFIG_CACHE);
-       for (n = 0; n < TABLESIZE(config_cache); n++) {
-           PutDefs(config_cache, n);
-       }
-       fprintf(fp0, "\n%s<br>\n<em>lynx_cfg.h</em>\n", AUTOCONF_LYNXCFG_H);
-       for (n = 0; n < TABLESIZE(config_defines); n++) {
-           PutDefs(config_defines, n);
-       }
-       fprintf(fp0, "</pre>\n");
-       EndInternalPage(fp0);
-       LYCloseTempFP(fp0);
-    }
-    return info_url;
-}
-#else
-#undef HAVE_CFG_DEFS_H
-#endif /* !NO_CONFIG_INFO */
-
 /*
  *  Showinfo prints a page of info about the current file and the link
  *  that the cursor is on.
@@ -135,7 +86,7 @@
                 (LYNX_RELEASE ? REL_VERSION       : DEV_VERSION) );

     if (!LYRestricted) {
-#ifdef HAVE_CFG_DEFS_H
+#if defined(HAVE_CONFIG_H) && !defined(NO_CONFIG_INFO)
        fprintf(fp0, " - <a href=\"LYNXCOMPILEOPTS:\">%s</a>\n",
                COMPILE_OPT_SEGMENT);
 #else




reply via email to

[Prev in Thread] Current Thread [Next in Thread]