diff options
author | Adam Chlipala <adam@chlipala.net> | 2011-01-16 10:38:03 -0500 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2011-01-16 10:38:03 -0500 |
commit | fbc17fa1d962150062aa0b4839d75a27605b965e (patch) | |
tree | fe0b592698e1c2198b6af517782f7c8608065759 | |
parent | 3af8bcda28c4c831cf420ebba926dd9ac1f44d71 (diff) |
Patch from Vladimir Shabanov to support crypt under OS X
-rw-r--r-- | src/c/urweb.c | 13 | ||||
-rw-r--r-- | src/compiler.sml | 2 | ||||
-rw-r--r-- | tests/crypt.ur | 7 | ||||
-rw-r--r-- | tests/crypt.urs | 1 |
4 files changed, 12 insertions, 11 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c index 38733cc4..9f5c009a 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -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 @@ failure_kind uw_runCallback(uw_context ctx, void (*callback)(uw_context)) { } 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) { diff --git a/src/compiler.sml b/src/compiler.sml index db500b6b..e13042af 100644 --- a/src/compiler.sml +++ b/src/compiler.sml @@ -1295,7 +1295,7 @@ fun compileC {cname, oname, ename, libs, profile, debug, link = link'} = ^ " " ^ #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) = diff --git a/tests/crypt.ur b/tests/crypt.ur new file mode 100644 index 00000000..e1f48c65 --- /dev/null +++ b/tests/crypt.ur @@ -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> diff --git a/tests/crypt.urs b/tests/crypt.urs new file mode 100644 index 00000000..6ac44e0b --- /dev/null +++ b/tests/crypt.urs @@ -0,0 +1 @@ +val main : unit -> transaction page |