about summary refs log tree commit diff stats
path: root/src/LYUtils.c
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>1997-09-06 22:48:00 -0400
committerThomas E. Dickey <dickey@invisible-island.net>1997-09-06 22:48:00 -0400
commit549ec595d1da7693d5f7730e63f539cc8452307f (patch)
tree0ab3576fd5bbbcf610cc58e24f1762d4da3ac7f7 /src/LYUtils.c
parent73d5512d62200a263f3084bd869366326e445cf4 (diff)
downloadlynx-snapshots-549ec595d1da7693d5f7730e63f539cc8452307f.tar.gz
snapshot of project "lynx", label v2-7-1ac_0-60
Diffstat (limited to 'src/LYUtils.c')
-rw-r--r--src/LYUtils.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 26015709..27898c31 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -5312,6 +5312,61 @@ PUBLIC int putenv ARGS1(
 #ifdef NEED_REMOVE
 int remove ARGS1(char *, name)
 {
-	return unlink(name);
+    return unlink(name);
 }
 #endif
+
+#ifdef UNIX
+/*
+ * Open a file that we don't want other users to see.  For new files, the umask
+ * will suffice; however if the file already exists we'll change permissions
+ * first, before opening it.  If the chmod fails because of some reason other
+ * than a non-existent file, there's no point in trying to open it.
+ */
+static FILE *OpenHiddenFile ARGS2(char *, name, char *, mode)
+{
+    int save = umask(HIDE_UMASK);
+    FILE *fp = 0;
+    if (chmod(name, HIDE_CHMOD) == 0 || errno == ENOENT)
+    	fp = fopen(name, mode);
+    umask(save);
+    return fp;
+}
+#else
+# ifndef VMS
+#  define OpenHiddenFile(name, mode) fopen(name, mode)
+# endif
+#endif
+
+FILE *LYNewBinFile ARGS1(char *, name)
+{
+#ifdef VMS
+    FILE *fp = fopen (name, "wb", "mbc=32");
+    chmod(name, HIDE_CHMOD);
+#else
+    FILE *fp = OpenHiddenFile(name, "wb");
+#endif
+    return fp;
+}
+
+FILE *LYNewTxtFile ARGS1(char *, name)
+{
+#ifdef VMS
+    FILE *fp = fopen (name, "w", "shr=get");
+    chmod(name, HIDE_CHMOD);
+#else
+    FILE *fp = OpenHiddenFile(name, "w");
+#endif
+    return fp;
+}
+
+FILE *LYAppendToTxtFile ARGS1(char *, name)
+{
+#ifdef VMS
+    FILE *fp = fopen (name, "a+", "shr=get");
+    chmod(name, HIDE_CHMOD);
+#else
+    FILE *fp = OpenHiddenFile(name, "a+");
+#endif
+    return fp;
+}