about summary refs log tree commit diff stats
path: root/src/LYrcFile.c
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>1999-12-01 03:38:43 -0500
committerThomas E. Dickey <dickey@invisible-island.net>1999-12-01 03:38:43 -0500
commit4525eb4b32fdf2124e246285af59a1e14ecbf551 (patch)
treeb4fa005bd9b3ff3f0973cb1ea9e5ac4243ec2a39 /src/LYrcFile.c
parent45f1aadc261561566cd074da1d9b0fb21a6ad78c (diff)
downloadlynx-snapshots-4525eb4b32fdf2124e246285af59a1e14ecbf551.tar.gz
snapshot of project "lynx", label v2-8-3dev_16
Diffstat (limited to 'src/LYrcFile.c')
-rw-r--r--src/LYrcFile.c66
1 files changed, 41 insertions, 25 deletions
diff --git a/src/LYrcFile.c b/src/LYrcFile.c
index adcc312f..a2e65c26 100644
--- a/src/LYrcFile.c
+++ b/src/LYrcFile.c
@@ -29,11 +29,15 @@ PRIVATE char *SkipEquals ARGS1(char *, src)
     return LYSkipBlanks(src);
 }
 
-PUBLIC void read_rc NOPARAMS
+/*  Read and process user options.
+ *  If the passed-in fp is NULL, open the regular user defaults file
+ *  for reading, otherwise use fp which has to be a file open for
+ *  reading. - kw
+ */
+PUBLIC void read_rc ARGS1(FILE *, fp)
 {
     char *line_buffer = NULL;
     char rcfile[LY_MAXPATH];
-    FILE *fp;
     char *cp;
     int number_sign;
     char MBM_line[256];
@@ -41,16 +45,18 @@ PUBLIC void read_rc NOPARAMS
     char *MBM_cp2, *MBM_cp1;
     int  MBM_i2;
 
-    /*
-     *  Make an RC file name.
-     */
-    LYAddPathToHome(rcfile, sizeof(rcfile), FNAME_LYNXRC);
+    if (!fp) {
+	/*
+	 *  Make an RC file name.
+	 */
+	LYAddPathToHome(rcfile, sizeof(rcfile), FNAME_LYNXRC);
 
-    /*
-     *  Open the RC file for reading.
-     */
-    if ((fp = fopen(rcfile, TXT_R)) == NULL) {
-	return;
+	/*
+	 *  Open the RC file for reading.
+	 */
+	if ((fp = fopen(rcfile, TXT_R)) == NULL) {
+	    return;
+	}
     }
 
     /*
@@ -540,23 +546,30 @@ PRIVATE void write_list ARGS2(
     }
 }
 
-PUBLIC int save_rc NOPARAMS
+/*  Save user options.
+ *  If the passed-in fp is NULL, open the regular user defaults file
+ *  for writing, otherwise use fp which has to be a temp file open for
+ *  writing. - kw
+ */
+PUBLIC int save_rc ARGS1(FILE *, fp)
 {
     char rcfile[LY_MAXPATH];
-    FILE *fp;
+    BOOLEAN is_tempfile = (fp != NULL);
     int i;
     int MBM_c;
 
-    /*
-     *  Make a name.
-     */
-    LYAddPathToHome(rcfile, sizeof(rcfile), FNAME_LYNXRC);
+    if (!fp) {
+	/*
+	 *  Make a name.
+	 */
+	LYAddPathToHome(rcfile, sizeof(rcfile), FNAME_LYNXRC);
 
-    /*
-     *  Open the file for write.
-     */
-    if ((fp = LYNewTxtFile(rcfile)) == NULL) {
-	return FALSE;
+	/*
+	 *  Open the file for write.
+	 */
+	if ((fp = LYNewTxtFile(rcfile)) == NULL) {
+	    return FALSE;
+	}
     }
 
     /*
@@ -1044,9 +1057,12 @@ See also VERBOSE_IMAGES in lynx.cfg\n\
     /*
      *  Close the RC file.
      */
-    fclose(fp);
-
-    HTSYS_purge(rcfile);
+    if (is_tempfile) {
+	LYCloseTempFP(fp);
+    } else {
+	fclose(fp);
+	HTSYS_purge(rcfile);
+    }
 
     return TRUE;
 }