Mercurial > urweb
comparison src/c/urweb.c @ 1360:02fc16faecf3
[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
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Thu, 23 Dec 2010 17:46:40 -0500 |
parents | e525ad571e15 |
children | 7dd8a6704265 |
comparison
equal
deleted
inserted
replaced
1359:e525ad571e15 | 1360:02fc16faecf3 |
---|---|
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 | 17 |
17 #include <pthread.h> | 18 #include <pthread.h> |
18 | 19 |
19 #include "types.h" | 20 #include "types.h" |
20 | 21 |
2004 ctx->page.front += len; | 2005 ctx->page.front += len; |
2005 | 2006 |
2006 return uw_unit_v; | 2007 return uw_unit_v; |
2007 } | 2008 } |
2008 | 2009 |
2010 char *uw_Basis_jsifyTime(uw_context ctx, uw_Basis_time n) { | |
2011 int len; | |
2012 char *r; | |
2013 | |
2014 uw_check_heap(ctx, INTS_MAX); | |
2015 r = ctx->heap.front; | |
2016 sprintf(r, "%lld%n", (uw_Basis_int)n, &len); | |
2017 ctx->heap.front += len+1; | |
2018 return r; | |
2019 } | |
2020 | |
2021 uw_unit uw_Basis_jsifyInt_w(uw_context ctx, uw_Basis_time n) { | |
2022 int len; | |
2023 | |
2024 uw_check(ctx, INTS_MAX); | |
2025 sprintf(ctx->page.front, "%lld%n", (uw_Basis_int)n, &len); | |
2026 ctx->page.front += len; | |
2027 | |
2028 return uw_unit_v; | |
2029 } | |
2030 | |
2009 char *uw_Basis_htmlifyString(uw_context ctx, uw_Basis_string s) { | 2031 char *uw_Basis_htmlifyString(uw_context ctx, uw_Basis_string s) { |
2010 char *r, *s2; | 2032 char *r, *s2; |
2011 | 2033 |
2012 uw_check_heap(ctx, strlen(s) * 5 + 1); | 2034 uw_check_heap(ctx, strlen(s) * 5 + 1); |
2013 | 2035 |
3566 else | 3588 else |
3567 uw_rollback(ctx, 0); | 3589 uw_rollback(ctx, 0); |
3568 | 3590 |
3569 return r; | 3591 return r; |
3570 } | 3592 } |
3593 | |
3594 uw_Basis_string uw_Basis_crypt(uw_context ctx, uw_Basis_string key, uw_Basis_string salt) { | |
3595 struct crypt_data *data; | |
3596 | |
3597 if ((data = uw_get_global(ctx, "crypt")) == NULL) { | |
3598 data = malloc(sizeof(struct crypt_data)); | |
3599 data->initialized = 0; | |
3600 uw_set_global(ctx, "crypt", data, free); | |
3601 } | |
3602 | |
3603 return uw_strdup(ctx, crypt_r(key, salt, data)); | |
3604 } |