Change functions to ANSI C.
[openssl.git] / crypto / rand / randfile.c
index f2b37463630d6d544512b2e088977b67051f2114..1cea7696f963e31f9dd6a3e9ab0b896bc433c9eb 100644 (file)
  */
 
 #include <stdio.h>
-#include "cryptlib.h"
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include "e_os.h"
 #include "rand.h"
 
 #undef BUFSIZE
@@ -68,9 +71,7 @@
 
 /* #define RFILE ".rand" - defined in ../../e_os.h */
 
-int RAND_load_file(file,bytes)
-char *file;
-long bytes;
+int RAND_load_file(const char *file, long bytes)
        {
        MS_STATIC unsigned char buf[BUFSIZE];
        struct stat sb;
@@ -81,12 +82,12 @@ long bytes;
 
        i=stat(file,&sb);
        /* If the state fails, put some crap in anyway */
-       RAND_seed((unsigned char *)&sb,sizeof(sb));
+       RAND_seed(&sb,sizeof(sb));
        ret+=sizeof(sb);
        if (i < 0) return(0);
        if (bytes <= 0) return(ret);
 
-       in=fopen(file,"r");
+       in=fopen(file,"rb");
        if (in == NULL) goto err;
        for (;;)
                {
@@ -105,15 +106,14 @@ err:
        return(ret);
        }
 
-int RAND_write_file(file)
-char *file;
+int RAND_write_file(const char *file)
        {
        unsigned char buf[BUFSIZE];
        int i,ret=0;
        FILE *out;
        int n;
 
-       out=fopen(file,"w");
+       out=fopen(file,"wb");
        if (out == NULL) goto err;
        chmod(file,0600);
        n=RAND_DATA;
@@ -137,9 +137,7 @@ err:
        return(ret);
        }
 
-char *RAND_file_name(buf,size)
-char *buf;
-int size;
+char *RAND_file_name(char *buf, int size)
        {
        char *s;
        char *ret=NULL;