comparison 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
comparison
equal deleted inserted replaced
1396:115d217bbfbc 1397:a5bfed32d4f7
11 #include <ctype.h> 11 #include <ctype.h>
12 #include <limits.h> 12 #include <limits.h>
13 #include <stdint.h> 13 #include <stdint.h>
14 #include <sys/types.h> 14 #include <sys/types.h>
15 #include <sys/socket.h> 15 #include <sys/socket.h>
16 #include <crypt.h> 16 #include <openssl/des.h>
17 #include <time.h> 17 #include <time.h>
18 18
19 #include <pthread.h> 19 #include <pthread.h>
20 20
21 #include "types.h" 21 #include "types.h"
3695 3695
3696 return r; 3696 return r;
3697 } 3697 }
3698 3698
3699 uw_Basis_string uw_Basis_crypt(uw_context ctx, uw_Basis_string key, uw_Basis_string salt) { 3699 uw_Basis_string uw_Basis_crypt(uw_context ctx, uw_Basis_string key, uw_Basis_string salt) {
3700 struct crypt_data *data; 3700 char buf[14];
3701 3701 return uw_strdup(ctx, DES_fcrypt(key, salt, buf));
3702 if ((data = uw_get_global(ctx, "crypt")) == NULL) {
3703 data = malloc(sizeof(struct crypt_data));
3704 data->initialized = 0;
3705 uw_set_global(ctx, "crypt", data, free);
3706 }
3707
3708 return uw_strdup(ctx, crypt_r(key, salt, data));
3709 } 3702 }
3710 3703
3711 uw_Basis_bool uw_Basis_eq_time(uw_context ctx, uw_Basis_time t1, uw_Basis_time t2) { 3704 uw_Basis_bool uw_Basis_eq_time(uw_context ctx, uw_Basis_time t1, uw_Basis_time t2) {
3712 return !!(t1.seconds == t2.seconds && t1.microseconds == t2.microseconds); 3705 return !!(t1.seconds == t2.seconds && t1.microseconds == t2.microseconds);
3713 } 3706 }