Use random functions source files on Windows.
Use srand/rand instead of srandom/random (from MichaĆ Janiszewski)
Closes #156.
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index d5bf580..83fd054 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -169,9 +169,13 @@
zip_source_win32w.c
)
IF(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore)
+ SET(LIBZIP_OPSYS_FILES "${LIBZIP_OPSYS_FILES}"
+ zip_random_uwp.c
+ )
ELSE()
SET(LIBZIP_OPSYS_FILES "${LIBZIP_OPSYS_FILES}"
zip_source_win32a.c
+ zip_random_win32.c
)
ENDIF()
ELSE(WIN32)
diff --git a/lib/zip_random_uwp.c b/lib/zip_random_uwp.c
index ce7d6b8..cec7ec6 100644
--- a/lib/zip_random_uwp.c
+++ b/lib/zip_random_uwp.c
@@ -68,17 +68,17 @@
zip_uint32_t
zip_random_uint32(void) {
static bool seeded = false;
-
+
zip_uint32_t value;
-
+
if (zip_secure_random((zip_uint8_t *)&value, sizeof(value))) {
return value;
}
-
+
if (!seeded) {
- srandom((unsigned int)time(NULL));
+ srand((unsigned int)time(NULL));
}
-
- return (zip_uint32_t)random();
+
+ return (zip_uint32_t)rand();
}
#endif
diff --git a/lib/zip_random_win32.c b/lib/zip_random_win32.c
index 16d0f64..052bd4f 100644
--- a/lib/zip_random_win32.c
+++ b/lib/zip_random_win32.c
@@ -64,17 +64,17 @@
zip_uint32_t
zip_random_uint32(void) {
static bool seeded = false;
-
+
zip_uint32_t value;
-
+
if (zip_secure_random((zip_uint8_t *)&value, sizeof(value))) {
return value;
}
-
+
if (!seeded) {
- srandom((unsigned int)time(NULL));
+ srand((unsigned int)time(NULL));
}
-
- return (zip_uint32_t)random();
+
+ return (zip_uint32_t)rand();
}
#endif