lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev [patch] 2.8.3dev.16 - cookie_save_file


From: brian j pardy
Subject: lynx-dev [patch] 2.8.3dev.16 - cookie_save_file
Date: Sun, 12 Dec 1999 21:53:26 -0500

On Sun, Dec 12, 1999, brian j pardy wrote:
> I'll be making it a lynx.cfg and .lynxrc option as well.  Any
> objections?  I can see a few from it being "only" useful in batch
> mode, but I like the ideas about implementing a read-only cookie file
> for multiple users.

Actually, not in .lynxrc -- it would store the setting based on the
current mode, and throw it off for future modes.  If someone can come
up with a way around this, feel free.

I also put a wrapper around the bits of reload_read_cfg() that were
giving LP problems -- can you test this?  I can't duplicate it so I
don't know if this worked, but I'm guessing it should.

I rearranged lynx.cfg to put PERSISTENT_COOKIES above the
COOKIE_FILE and COOKIE_SAVE_FILE settings, where I feel it belongs.
If someone can come up with better comments for COOKIE_SAVE_FILE,
please do.  Same for volunteering to write it up in the user's guide.
I'll do it sooner or later if nobody volunteers, but...

* Add cookie_save_file lynx.cfg and commandline option

diff -ru 2.8.3dev.16/lynx.cfg 2.8.3dev.16.bri/lynx.cfg
--- 2.8.3dev.16/lynx.cfg        Tue Nov 30 22:33:02 1999
+++ 2.8.3dev.16.bri/lynx.cfg    Sun Dec 12 21:37:39 1999
@@ -999,14 +999,6 @@
 #COOKIE_STRICT_INVALID_DOMAINS:
 #COOKIE_QUERY_INVALID_DOMAINS:
 
-# COOKIE_FILE is the default file from which persistent cookies are read
-# at startup (if the file exists), and into which persistent cookies are
-# stored before exiting, if Lynx was compiled with EXP_PERSISTENT_COOKIES
-# and the PERSISTENT_COOKIES option is enabled.
-# The cookie file can also be specified in .lynxrc or on the command line.
-#
-#COOKIE_FILE:~/.lynx_cookies
-
 # PERSISTENT_COOKIES indicates that cookies should be read at startup from
 # the COOKIE_FILE, and saved at exit for storage between Lynx sessions.
 # It is not used if Lynx was compiled without EXP_PERSISTENT_COOKIES.
@@ -1014,6 +1006,24 @@
 # explicitly if you want it.
 #
 #PERSISTENT_COOKIES:FALSE
+
+# COOKIE_FILE is the default file from which persistent cookies are read
+# at startup (if the file exists), if Lynx was compiled with
+# EXP_PERSISTENT_COOKIES and the PERSISTENT_COOKIES option is enabled.
+# The cookie file can also be specified in .lynxrc or on the command line.
+#
+#COOKIE_FILE:~/.lynx_cookies
+
+# COOKIE_SAVE_FILE is the default file in which persistent cookies are
+# stored at exit, if Lynx was compiled with EXP_PERSISTENT_COOKIES and the
+# PERSISTENT_COOKIES option is enabled.  The cookie save file can also be
+# specified on the command line.
+#
+# With an interactive Lynx session, COOKIE_SAVE_FILE will default to
+# COOKIE_FILE if it is not set.  With a non-interactive Lynx session (e.g.,
+# -dump), cookies will only be saved to file if COOKIE_SAVE_FILE is set.
+#
+#COOKIE_SAVE_FILE:~/.lynx_cookies
 
 # VMS:
 #=====
diff -ru 2.8.3dev.16/src/LYClean.c 2.8.3dev.16.bri/src/LYClean.c
--- 2.8.3dev.16/src/LYClean.c   Fri Apr 23 10:56:35 1999
+++ 2.8.3dev.16.bri/src/LYClean.c       Sun Dec 12 20:07:21 1999
@@ -189,7 +189,7 @@
      * out as well.
      */
     if (persistent_cookies)
-       LYStoreCookies (LYCookieFile);
+       LYStoreCookies (LYCookieSaveFile);
 #endif
 
     cleanup_files();
diff -ru 2.8.3dev.16/src/LYCookie.c 2.8.3dev.16.bri/src/LYCookie.c
--- 2.8.3dev.16/src/LYCookie.c  Tue Nov 30 22:33:02 1999
+++ 2.8.3dev.16.bri/src/LYCookie.c      Sun Dec 12 20:32:22 1999
@@ -2186,6 +2186,11 @@
     FILE *cookie_handle;
     time_t now = time(NULL); /* system specific? - RP */
 
+    if (!strcmp(cookie_file, "/dev/null")) {
+       /* We give /dev/null the Unix meaning, regardless of OS */
+       return;
+    }
+
     /*
      * Check whether we have something to do. - FM
      */
diff -ru 2.8.3dev.16/src/LYGlobalDefs.h 2.8.3dev.16.bri/src/LYGlobalDefs.h
--- 2.8.3dev.16/src/LYGlobalDefs.h      Tue Nov 30 22:33:02 1999
+++ 2.8.3dev.16.bri/src/LYGlobalDefs.h  Sun Dec 12 20:06:13 1999
@@ -358,7 +358,8 @@
 extern char *LYCookieSQueryCheckDomains;/* domains to check w/a query    */
 #ifdef EXP_PERSISTENT_COOKIES
 extern BOOLEAN persistent_cookies;
-extern char *LYCookieFile;              /* file to store cookies in      */
+extern char *LYCookieFile;              /* cookie read file              */
+extern char *LYCookieSaveFile;          /* cookie save file              */
 #endif /* EXP_PERSISTENT_COOKIES */
 extern char *XLoadImageCommand;                /* Default image viewer for X   
 */
 #ifdef USE_EXTERNALS
diff -ru 2.8.3dev.16/src/LYMain.c 2.8.3dev.16.bri/src/LYMain.c
--- 2.8.3dev.16/src/LYMain.c    Tue Nov 30 22:33:02 1999
+++ 2.8.3dev.16.bri/src/LYMain.c        Sun Dec 12 21:30:29 1999
@@ -411,7 +411,8 @@
 PUBLIC char *LYCookieSQueryCheckDomains = NULL;  /* check w/a query */
 #ifdef EXP_PERSISTENT_COOKIES
 BOOLEAN persistent_cookies = FALSE;    /* disabled by default! */
-PUBLIC char *LYCookieFile = NULL;         /* default cookie file */
+PUBLIC char *LYCookieFile = NULL;         /* cookie read file */
+PUBLIC char *LYCookieSaveFile = NULL;     /* cookie save file */
 #endif /* EXP_PERSISTENT_COOKIES */
 PUBLIC char *XLoadImageCommand = NULL; /* Default image viewer for X */
 PUBLIC BOOLEAN LYNoISMAPifUSEMAP = FALSE; /* Omit ISMAP link if MAP present? */
@@ -601,6 +602,7 @@
     FREE(system_mail_flags);
 #ifdef EXP_PERSISTENT_COOKIES
     FREE(LYCookieFile);
+    FREE(LYCookieSaveFile);
 #endif
     FREE(LYCookieAcceptDomains);
     FREE(LYCookieRejectDomains);
@@ -1588,6 +1590,8 @@
     /*
      * Sod it, this looks like a reasonable place to load the
      * cookies file, probably.  - RP
+     *
+     * And to set LYCookieSaveFile. - BJP
      */
     if (persistent_cookies) {
        if(LYCookieFile == NULL) {
@@ -1605,6 +1609,31 @@
        }
        LYLoadCookies(LYCookieFile);
     }
+
+    /* 
+     * In dump_output_immediately mode, LYCookieSaveFile defaults to
+     * /dev/null, otherwise it defaults to LYCookieFile.  
+     */
+
+    if (dump_output_immediately) {
+       if (LYCookieSaveFile != NULL) {
+           if (LYCookieSaveFile[0] == '~' && LYCookieSaveFile[1] == '/' &&
+               LYCookieSaveFile[2] != '\0') {
+               temp = NULL;
+               StrAllocCopy(temp, LYCookieSaveFile + 2);
+               StrAllocCopy(LYCookieSaveFile, wwwName(Home_Dir()));
+               LYAddPathSep(&LYCookieSaveFile);
+               StrAllocCat(LYCookieSaveFile, temp);
+               FREE(temp);
+           }
+       } else {
+           StrAllocCopy(LYCookieSaveFile, "/dev/null");
+       }
+    } else {
+       if (LYCookieSaveFile == NULL) {
+           StrAllocCopy(LYCookieSaveFile, LYCookieFile);
+       }
+    }
 #endif
 
     /*
@@ -2015,7 +2044,7 @@
         *  this one. - BJP
         */
        if (persistent_cookies)
-           LYStoreCookies(LYCookieFile);
+           LYStoreCookies(LYCookieSaveFile);
 #endif /* EXP_PERSISTENT_COOKIES */
        cleanup_files();        /* if someone starts with LYNXfoo: page */
        exit_immediately(status);
@@ -2151,7 +2180,11 @@
 #ifdef EXP_PERSISTENT_COOKIES
        BOOLEAN persistent_cookies_flag = persistent_cookies;
        char * LYCookieFile_flag = NULL;
-       StrAllocCopy(LYCookieFile_flag, LYCookieFile);
+       char * LYCookieSaveFile_flag = NULL;
+       if (persistent_cookies) {
+           StrAllocCopy(LYCookieFile_flag, LYCookieFile);
+           StrAllocCopy(LYCookieSaveFile_flag, LYCookieSaveFile);
+       }
 #endif
 
 #ifdef EXP_CHARSET_CHOICE
@@ -2213,11 +2246,18 @@
            persistent_cookies = persistent_cookies_flag;
            HTAlert(gettext("persistent cookies state will be changed in next 
session only."));
        }
-       if (strcmp(LYCookieFile, LYCookieFile_flag)) {
-           StrAllocCopy(LYCookieFile, LYCookieFile_flag);
-           CTRACE((tfp, "cookies file can be changed in next session only, 
restored.\n"));
+       if (persistent_cookies) {
+           if (strcmp(LYCookieFile, LYCookieFile_flag)) {
+               StrAllocCopy(LYCookieFile, LYCookieFile_flag);
+               CTRACE((tfp, "cookie file can be changed in next session only, 
restored.\n"));
+           }
+           if (strcmp(LYCookieSaveFile, LYCookieSaveFile_flag)) {
+               StrAllocCopy(LYCookieSaveFile, LYCookieSaveFile_flag);
+               CTRACE((tfp, "cookie save file can be changed in next session 
only, restored.\n"));
+           }
+           FREE(LYCookieFile_flag);
+           FREE(LYCookieSaveFile_flag);
        }
-       FREE(LYCookieFile_flag);
 #endif
 
     }
@@ -3114,6 +3154,10 @@
 #ifdef EXP_PERSISTENT_COOKIES
    PARSE_STR(
       "cookie_file",   LYSTRING_ARG,           &LYCookieFile,
+      "=FILENAME\nspecifies a file to use to read cookies"
+   ),
+   PARSE_STR(
+      "cookie_save_file",      LYSTRING_ARG,   &LYCookieSaveFile,
       "=FILENAME\nspecifies a file to use to store cookies"
    ),
 #endif /* EXP_PERSISTENT_COOKIES */
diff -ru 2.8.3dev.16/src/LYReadCFG.c 2.8.3dev.16.bri/src/LYReadCFG.c
--- 2.8.3dev.16/src/LYReadCFG.c Tue Nov 30 22:33:02 1999
+++ 2.8.3dev.16.bri/src/LYReadCFG.c     Sun Dec 12 20:18:26 1999
@@ -1269,6 +1269,7 @@
      PARSE_STR("cookie_accept_domains", CONF_STR, &LYCookieSAcceptDomains),
 #ifdef EXP_PERSISTENT_COOKIES
      PARSE_STR("cookie_file", CONF_STR, &LYCookieFile),
+     PARSE_STR("cookie_save_file", CONF_STR, &LYCookieSaveFile),
 #endif /* EXP_PERSISTENT_COOKIES */
      PARSE_STR("cookie_loose_invalid_domains", CONF_STR, 
&LYCookieSLooseCheckDomains),
      PARSE_STR("cookie_query_invalid_domains", CONF_STR, 
&LYCookieSQueryCheckDomains),
diff -ru 2.8.3dev.16/src/LYrcFile.c 2.8.3dev.16.bri/src/LYrcFile.c
--- 2.8.3dev.16/src/LYrcFile.c  Tue Nov 30 22:33:02 1999
+++ 2.8.3dev.16.bri/src/LYrcFile.c      Sun Dec 12 21:48:50 1999
@@ -452,7 +452,7 @@
 
 #ifdef EXP_PERSISTENT_COOKIES
        /*
-        *  File in which to store persistent cookies.
+        *  File from which to read persistent cookies.
         */
        } else if (FIND_KEYWORD(cp, "cookie_file")) {
            cp = SkipEquals(cp);
@@ -995,10 +995,10 @@
 
 #ifdef EXP_PERSISTENT_COOKIES
     /*
-     *  Cookie file.
+     *  Cookie read file.
      */
     write_list(fp, gettext("\
-cookie_file specifies the file in which to store persistent cookies.\n\
+cookie_file specifies the file from which to read persistent cookies.\n\
 The default is ~/.lynx_cookies.\n\
 "));
     fprintf(fp, "cookie_file=%s\n\n",

-- 
Another war ... must it always be so?  How many comrades have we lost
in this way? ...  Obedience.  Duty.  Death, and more death ...
                -- Romulan Commander, "Balance of Terror", stardate 1709.2

reply via email to

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