changeset 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 115d217bbfbc
children fe470db7feea
files src/c/urweb.c src/compiler.sml tests/crypt.ur tests/crypt.urs
diffstat 4 files changed, 12 insertions(+), 11 deletions(-) [+]
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) {
--- a/src/compiler.sml	Sat Jan 15 20:06:00 2011 -0500
+++ b/src/compiler.sml	Sun Jan 16 10:38:03 2011 -0500
@@ -1295,7 +1295,7 @@
                       ^ " " ^ #compile proto
                       ^ " -c " ^ cname ^ " -o " ^ oname
 
-        val link = "gcc -Werror -O3 -lm -lcrypt -pthread " ^ Config.gccArgs ^ " " ^ libs ^ " " ^ lib ^ " " ^ Config.openssl ^ " " ^ oname
+        val link = "gcc -Werror -O3 -lm -pthread " ^ Config.gccArgs ^ " " ^ libs ^ " " ^ lib ^ " " ^ Config.openssl ^ " " ^ oname
                    ^ " -o " ^ ename
 
         val (compile, link) =
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/crypt.ur	Sun Jan 16 10:38:03 2011 -0500
@@ -0,0 +1,7 @@
+fun cryptIt r = return <xml><body>
+  {[crypt r.Pass "AB"]}
+</body></xml>
+
+fun main () = return <xml><body>
+  <form><textbox{#Pass}/> <submit action={cryptIt}/></form>
+</body></xml>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/crypt.urs	Sun Jan 16 10:38:03 2011 -0500
@@ -0,0 +1,1 @@
+val main : unit -> transaction page