diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-01-13 06:57:04 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-01-13 06:57:04 -0800 |
commit | d1d529634ca0efabd8def4d1e4d103facb9f9380 (patch) | |
tree | b78b2ac15b30f1b62b9de6303c5eff2a74a64dab /sysif.c | |
parent | dbc666fb0822e3bc0fd97d90e068f104ea4f5781 (diff) | |
download | txr-d1d529634ca0efabd8def4d1e4d103facb9f9380.tar.gz txr-d1d529634ca0efabd8def4d1e4d103facb9f9380.tar.bz2 txr-d1d529634ca0efabd8def4d1e4d103facb9f9380.zip |
Support crypt function.
* configure: Check for availability of crypt,
and what library must be used.
* sysif.c (crypt_wrap): New static function.
(sysif_init): Register crypt intrinsic.
* txr.1: Documented crypt.
Diffstat (limited to 'sysif.c')
-rw-r--r-- | sysif.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -1037,6 +1037,21 @@ static val getgrnam_wrap(val wname) #endif +#if HAVE_CRYPT + +static val crypt_wrap(val wkey, val wsalt) +{ + char *key = utf8_dup_to(c_str(wkey)); + char *salt = utf8_dup_to(c_str(wsalt)); + char *hash = crypt(key, salt); + val whash = string_utf8(hash); + free(key); + free(salt); + return whash; +} + +#endif + off_t off_t_num(val num) { switch (type(num)) { @@ -1397,6 +1412,10 @@ void sysif_init(void) reg_fun(intern(lit("getgrnam"), user_package), func_n1(getgrnam_wrap)); #endif +#if HAVE_CRYPT + reg_fun(intern(lit("crypt"), user_package), func_n2(crypt_wrap)); +#endif + #if HAVE_POLL reg_fun(intern(lit("poll"), user_package), func_n2o(poll_wrap, 1)); #endif |