summaryrefslogtreecommitdiffstats
path: root/sysif.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-01-13 06:57:04 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-01-13 06:57:04 -0800
commitd1d529634ca0efabd8def4d1e4d103facb9f9380 (patch)
treeb78b2ac15b30f1b62b9de6303c5eff2a74a64dab /sysif.c
parentdbc666fb0822e3bc0fd97d90e068f104ea4f5781 (diff)
downloadtxr-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.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sysif.c b/sysif.c
index 1f7eb085..cd59cc64 100644
--- a/sysif.c
+++ b/sysif.c
@@ -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