aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/rand/randfile.c
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>1999-09-11 17:54:18 +0000
committerAndy Polyakov <appro@openssl.org>1999-09-11 17:54:18 +0000
commit17f389bbbfccf057a8bc04084ed068c4b368e751 (patch)
tree7daa85ce7f0f44aff61853dc10c5915d465ba43c /crypto/rand/randfile.c
parent5bdae1675c8b450bed091b9605ae9d10d61adfc7 (diff)
downloadopenssl-17f389bbbfccf057a8bc04084ed068c4b368e751.tar.gz
Initial support for MacOS.
This will soon be complemented with MacOS specific source code files and INSTALL.MacOS. I (Andy) have decided to get rid of a number of #include <sys/types.h>. I've verified it's ok (both by examining /usr/include/*.h and compiling) on a number of Unix platforms. Unfortunately I don't have Windows box to verify this on. I really appreciate if somebody could try to compile it and contact me a.s.a.p. in case a problem occurs. Submitted by: Roy Wood <roy@centricsystems.ca> Reviewed by: Andy Polyakov <appro@fy.chalmers.se>
Diffstat (limited to 'crypto/rand/randfile.c')
-rw-r--r--crypto/rand/randfile.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c
index 6829d4ec37..e1ed4e3a98 100644
--- a/crypto/rand/randfile.c
+++ b/crypto/rand/randfile.c
@@ -60,12 +60,18 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/types.h>
#include "openssl/e_os.h"
+#ifndef NO_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef MAC_OS_pre_X
+# include <stat.h>
+#else
+# include <sys/stat.h>
+#endif
+
#include <openssl/rand.h>
#undef BUFSIZE
@@ -116,19 +122,25 @@ int RAND_write_file(const char *file)
FILE *out;
int n;
- /* Under VMS, fopen(file, "wb") will craete a new version of the
+ /* Under VMS, fopen(file, "wb") will create a new version of the
same file. This is not good, so let's try updating an existing
one, and create file only if it doesn't already exist. This
should be completely harmless on system that have no file
versions. -- Richard Levitte */
out=fopen(file,"rb+");
- if (out == NULL && errno == ENOENT)
+ if (out == NULL
+#ifdef ENOENT
+ && errno == ENOENT
+#endif
+ )
{
errno = 0;
out=fopen(file,"wb");
}
if (out == NULL) goto err;
+#ifndef NO_CHMOD
chmod(file,0600);
+#endif
n=RAND_DATA;
for (;;)
{