summaryrefslogtreecommitdiffstats
path: root/sysif.c
diff options
context:
space:
mode:
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