diff src/c/urweb.c @ 1397:a5bfed32d4f7

Patch from Vladimir Shabanov to support crypt under OS X
author Adam Chlipala <adam@chlipala.net>
date Sun, 16 Jan 2011 10:38:03 -0500
parents e305ffee2b5b
children d6ea63612909
line wrap: on
line diff
--- a/src/c/urweb.c	Sat Jan 15 20:06:00 2011 -0500
+++ b/src/c/urweb.c	Sun Jan 16 10:38:03 2011 -0500
@@ -13,7 +13,7 @@
 #include <stdint.h>
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <crypt.h>
+#include <openssl/des.h>
 #include <time.h>
 
 #include <pthread.h>
@@ -3697,15 +3697,8 @@
 }
 
 uw_Basis_string uw_Basis_crypt(uw_context ctx, uw_Basis_string key, uw_Basis_string salt) {
-  struct crypt_data *data;
-
-  if ((data = uw_get_global(ctx, "crypt")) == NULL) {
-    data = malloc(sizeof(struct crypt_data));
-    data->initialized = 0;
-    uw_set_global(ctx, "crypt", data, free);
-  }
-
-  return uw_strdup(ctx, crypt_r(key, salt, data));
+  char buf[14];
+  return uw_strdup(ctx, DES_fcrypt(key, salt, buf));
 }
 
 uw_Basis_bool uw_Basis_eq_time(uw_context ctx, uw_Basis_time t1, uw_Basis_time t2) {