summaryrefslogtreecommitdiff
path: root/src/c/urweb.c
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2010-12-23 17:46:40 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2010-12-23 17:46:40 -0500
commit38d3bc508b3b882e81599bdb0e1d4a2572c23dd0 (patch)
tree31bbf2f979aa12d31eb3977bb6c0cdfe2c57bae9 /src/c/urweb.c
parent867a11af44827af8974250e6dbb5e96b6268b44f (diff)
[De]serialization of times in JavaScript; proper integer division in JavaScript; Basis.crypt; Top.mkRead'; more aggressive Mono-level inlining, for values of function-y types
Diffstat (limited to 'src/c/urweb.c')
-rw-r--r--src/c/urweb.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c
index a09978cd..efe50591 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -13,6 +13,7 @@
#include <stdint.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <crypt.h>
#include <pthread.h>
@@ -2006,6 +2007,27 @@ uw_unit uw_Basis_htmlifyFloat_w(uw_context ctx, uw_Basis_float n) {
return uw_unit_v;
}
+char *uw_Basis_jsifyTime(uw_context ctx, uw_Basis_time n) {
+ int len;
+ char *r;
+
+ uw_check_heap(ctx, INTS_MAX);
+ r = ctx->heap.front;
+ sprintf(r, "%lld%n", (uw_Basis_int)n, &len);
+ ctx->heap.front += len+1;
+ return r;
+}
+
+uw_unit uw_Basis_jsifyInt_w(uw_context ctx, uw_Basis_time n) {
+ int len;
+
+ uw_check(ctx, INTS_MAX);
+ sprintf(ctx->page.front, "%lld%n", (uw_Basis_int)n, &len);
+ ctx->page.front += len;
+
+ return uw_unit_v;
+}
+
char *uw_Basis_htmlifyString(uw_context ctx, uw_Basis_string s) {
char *r, *s2;
@@ -3568,3 +3590,15 @@ failure_kind uw_runCallback(uw_context ctx, void (*callback)(uw_context)) {
return r;
}
+
+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));
+}