summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortechnion <technion@lolware.net>2014-08-29 12:02:19 +1000
committertechnion <technion@lolware.net>2014-08-29 12:02:19 +1000
commitc75e52cc1219ff79947078772fc5c0543cbeee8b (patch)
treeefe5d0d680d1a0c4fb14623b2194d526a7a3bd1a
parent0f3098e0c82c5faf10236c8b0cfff48ba5c07bff (diff)
parentc88ddb27de082085a2d72e5b2eefc3e5d1557294 (diff)
Merge pull request #27 from nmathewson/mingw-port
Compile correctly under mingw32, mingw64
-rw-r--r--b64.c10
-rw-r--r--crypto_scrypt-check.c8
-rw-r--r--crypto_scrypt-nosse.c3
3 files changed, 15 insertions, 6 deletions
diff --git a/b64.c b/b64.c
index edce1b8..0e8c221 100644
--- a/b64.c
+++ b/b64.c
@@ -121,14 +121,14 @@ static const char Pad64 = '=';
int
libscrypt_b64_encode(src, srclength, target, targsize)
- u_char const *src;
+ unsigned char const *src;
size_t srclength;
char *target;
size_t targsize;
{
size_t datalength = 0;
- u_char input[3];
- u_char output[4];
+ unsigned char input[3];
+ unsigned char output[4];
unsigned int i;
while (2 < srclength) {
@@ -186,12 +186,12 @@ libscrypt_b64_encode(src, srclength, target, targsize)
int
libscrypt_b64_decode(src, target, targsize)
char const *src;
- u_char *target;
+ unsigned char *target;
size_t targsize;
{
int state, ch;
unsigned int tarindex;
- u_char nextbyte;
+ unsigned char nextbyte;
char *pos;
state = 0;
diff --git a/crypto_scrypt-check.c b/crypto_scrypt-check.c
index c889a7c..5ed7ab0 100644
--- a/crypto_scrypt-check.c
+++ b/crypto_scrypt-check.c
@@ -7,6 +7,12 @@
#include "slowequals.h"
#include "libscrypt.h"
+#ifdef _WIN32
+/* On windows, strtok uses a thread-local static variable in strtok to
+ * make strtok thread-safe. It also neglects to provide a strtok_r. */
+#define strtok_r(str, val, saveptr) strtok((str), (val))
+#endif
+
/* pow() works with doubles. Sounds like it should cast to int correctly,
* but doesn't always. This is faster anyway
*/
@@ -32,7 +38,9 @@ int libscrypt_check(char *mcf, const char *password)
* >0 correct password
*/
+#ifndef _WIN32
char *saveptr = NULL;
+#endif
uint32_t params;
uint64_t N;
uint8_t r, p;
diff --git a/crypto_scrypt-nosse.c b/crypto_scrypt-nosse.c
index f54e42e..311e84a 100644
--- a/crypto_scrypt-nosse.c
+++ b/crypto_scrypt-nosse.c
@@ -28,8 +28,9 @@
*/
#include <sys/types.h>
+#ifndef _WIN32
#include <sys/mman.h>
-
+#endif
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>