diff options
Diffstat (limited to 'functions13.h')
-rw-r--r-- | functions13.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/functions13.h b/functions13.h new file mode 100644 index 0000000..bff37f2 --- /dev/null +++ b/functions13.h | |||
@@ -0,0 +1,38 @@ | |||
1 | static const char *extract_request_time(request_rec *r, char *a) | ||
2 | { | ||
3 | int timz; | ||
4 | struct tm *t; | ||
5 | char tstr[MAX_STRING_LEN]; | ||
6 | |||
7 | t = ap_get_gmtoff(&timz); | ||
8 | |||
9 | if (a && *a) { /* Custom format */ | ||
10 | strftime(tstr, MAX_STRING_LEN, a, t); | ||
11 | } else { /* CLF format */ | ||
12 | char sign = (timz < 0 ? '-' : '+'); | ||
13 | |||
14 | if (timz < 0) { | ||
15 | timz = -timz; | ||
16 | } | ||
17 | strftime(tstr, MAX_STRING_LEN, "[%d/%b/%Y:%H:%M:%S ", t); | ||
18 | ap_snprintf(tstr + strlen(tstr), sizeof(tstr) - strlen(tstr), "%c%.2d%.2d]", sign, timz / 60, timz % 60); | ||
19 | } | ||
20 | |||
21 | return ap_pstrdup(r->pool, tstr); | ||
22 | } | ||
23 | |||
24 | static const char *extract_request_duration(request_rec *r, char *a) | ||
25 | { | ||
26 | char duration[22]; /* Long enough for 2^64 */ | ||
27 | |||
28 | ap_snprintf(duration, sizeof(duration), "%ld", (long) time(NULL) - r->request_time); | ||
29 | return ap_pstrdup(r->pool, duration); | ||
30 | } | ||
31 | |||
32 | static const char *extract_request_timestamp(request_rec *r, char *a) | ||
33 | { | ||
34 | char tstr[32]; | ||
35 | |||
36 | ap_snprintf(tstr, 32, "%ld", (long) time(NULL)); | ||
37 | return ap_pstrdup(r->pool, tstr); | ||
38 | } | ||