lynx-dev
[Top][All Lists]
Advanced

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

Re: LYNX-DEV Using $HOME/.lynx to store lynx config files


From: Andrew Kuchling
Subject: Re: LYNX-DEV Using $HOME/.lynx to store lynx config files
Date: Sat, 14 Jun 1997 13:23:25 -0400 (EDT)

        Here's a first cut at a patch; changes may still be made based
on feedback from lynx-dev.  This patch adds a Lynx_Dir() function to
LYUtils.c that returns a directory to use; currently this directory is
equal to Home_Dir()+'/.lynx'.  (What should it be for DOS?  VMS?
Mac?)
        
        The .lynx directory is created if it doesn't exist; the user
is *not* prompted about it.  If Home_Dir()==/tmp, /tmp/.lynx will be
created.  If the .lynx directory can't be created, Home_Dir() will be
used.

        The patch also changes LYrcFile to look for .lynxrx in the
directory provided by Lynx_Dir().  Is there anything else existing
that should go in the private directory?


        Andrew Kuchling
        address@hidden
        http://people.magnet.com/%7Eamk/


--- LYUtils.c   1997/06/13 19:06:27     1.1
+++ LYUtils.c   1997/06/13 20:15:33
@@ -3138,9 +3138,40 @@
 }
 #endif /* VMS */
 
+/* Lynx_Dir() is where Lynx can keep its own private files: cookies,
+   certificates, .lynxrc, or whatever */
+
+PUBLIC CONST char * Lynx_Dir NOARGS
+{
+    static CONST char *lynxdir=NULL;
+
+    if (!lynxdir) {
+      StrAllocCopy(lynxdir, Home_Dir() );
+      StrAllocCat(lynxdir, "/.lynx");
+      /* Check if the Lynx-private directory exists */
+      {
+       struct stat st;
+       
+       if (stat(lynxdir, &st)<0)
+         {
+           /* Attempt to create the directory */
+           if (mkdir(lynxdir, 0700)<0)
+             {
+               /* XXX couldn't create .lynx directory; how to handle? */
+               /* For the moment, just drop the .lynx and use homedir */
+               free(lynxdir); lynxdir=Home_Dir();
+             }
+         }
+      }
+    }
+    return lynxdir;
+}
+
+
+
 PUBLIC CONST char * Home_Dir NOARGS
 {
-    static CONST char *homedir;
+    static CONST char *homedir=NULL;
 
     if (!homedir) {
        if ((homedir = getenv("HOME")) == NULL) {
--- LYUtils.h   1997/06/13 19:52:05     1.1
+++ LYUtils.h   1997/06/13 19:52:38
@@ -49,6 +49,7 @@
        char *LogicalName, char *LogicalValue));
 #endif /* VMS */
 extern CONST char *Home_Dir NOPARAMS;
+extern CONST char *Lynx_Dir NOPARAMS;
 extern BOOLEAN LYPathOffHomeOK PARAMS((char *fbuffer, int fbuffer_size));
 extern void LYAddPathToHome PARAMS((
        char *fbuffer, int fbuffer_size, char *fname));
--- LYrcFile.c  1997/06/13 19:52:05     1.1
+++ LYrcFile.c  1997/06/13 20:07:44
@@ -26,12 +26,12 @@
      *  Make an RC file name.
      */
 #ifdef DJGPP
-        sprintf(rcfile, "%s/lynx.rc", Home_Dir());
+        sprintf(rcfile, "%s/lynx.rc", Lynx_Dir());
 #else
 #ifdef VMS
     sprintf(rcfile, "sys$login:.lynxrc");
 #else
-    sprintf(rcfile, "%s/.lynxrc", Home_Dir());
+    sprintf(rcfile, "%s/.lynxrc", Lynx_Dir());
 #endif /* VMS */
 #endif /* DJGPP */
 
@@ -476,12 +476,12 @@
      *  Make a name.
      */
 #ifdef DJGPP
-        sprintf(rcfile, "%s/lynx.rc", Home_Dir());
+        sprintf(rcfile, "%s/lynx.rc", Lynx_Dir());
 #else
 #ifdef VMS
     sprintf(rcfile, "sys$login:.lynxrc");
 #else
-    sprintf(rcfile, "%s/.lynxrc", Home_Dir());
+    sprintf(rcfile, "%s/.lynxrc", Lynx_Dir());
 #endif /* VMS */
 #endif /* DJGPP */
;
; To UNSUBSCRIBE:  Send a mail message to address@hidden
;                  with "unsubscribe lynx-dev" (without the
;                  quotation marks) on a line by itself.
;

reply via email to

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