diff options
Diffstat (limited to 'src/time.c')
-rw-r--r-- | src/time.c | 23 |
1 files changed, 9 insertions, 14 deletions
@@ -14,36 +14,31 @@ | |||
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License |
15 | along with vmod-tbf. If not, see <http://www.gnu.org/licenses/>. | 15 | along with vmod-tbf. If not, see <http://www.gnu.org/licenses/>. |
16 | */ | 16 | */ |
17 | #include <config.h> | 17 | #include "tbf.h" |
18 | #include <stdlib.h> | ||
19 | #include <stdio.h> | ||
20 | #include <time.h> | 18 | #include <time.h> |
21 | #include "vrt.h" | ||
22 | #include "vcc_if.h" | ||
23 | #include "bin/varnishd/cache.h" | ||
24 | 19 | ||
25 | int | 20 | VCL_INT |
26 | vmod_systime(struct sess *sp) | 21 | vmod_systime(MOD_CTX ctx) |
27 | { | 22 | { |
28 | return time(NULL); | 23 | return time(NULL); |
29 | } | 24 | } |
30 | 25 | ||
31 | const char * | 26 | VCL_STRING |
32 | vmod_strftime(struct sess *sp, const char *format, int timestamp) | 27 | vmod_strftime(MOD_CTX ctx, VCL_STRING format, VCL_INT timestamp) |
33 | { | 28 | { |
34 | time_t ts = (time_t) timestamp; | 29 | time_t ts = (time_t) timestamp; |
35 | size_t u, n; | 30 | size_t u, n; |
36 | char *p; | 31 | char *p; |
37 | 32 | ||
38 | u = WS_Reserve(sp->wrk->ws, 0); | 33 | u = WS_Reserve(WSPTR(ctx), 0); |
39 | p = sp->wrk->ws->f; | 34 | p = WSPTR(ctx)->f; |
40 | n = strftime(p, u, format, gmtime(&ts)); | 35 | n = strftime(p, u, format, gmtime(&ts)); |
41 | if (n == 0) { | 36 | if (n == 0) { |
42 | WS_Release(sp->wrk->ws, 0); | 37 | WS_Release(WSPTR(ctx), 0); |
43 | return NULL; | 38 | return NULL; |
44 | } | 39 | } |
45 | 40 | ||
46 | WS_Release(sp->wrk->ws, n + 1); | 41 | WS_Release(WSPTR(ctx), n + 1); |
47 | 42 | ||
48 | return p; | 43 | return p; |
49 | } | 44 | } |