Browse Source

added now and weeks support to mod_expire. close #943

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@1478 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.14
Elan Ruusamäe 16 years ago
parent
commit
36544e2186
  1. 12
      src/mod_expire.c

12
src/mod_expire.c

@ -85,7 +85,7 @@ static int mod_expire_get_offset(server *srv, plugin_data *p, buffer *expire, in
/*
* parse
*
* '(access|modification) [plus] {<num> <type>}*'
* '(access|now|modification) [plus] {<num> <type>}*'
*
* e.g. 'access 1 years'
*/
@ -101,6 +101,9 @@ static int mod_expire_get_offset(server *srv, plugin_data *p, buffer *expire, in
if (0 == strncmp(ts, "access ", 7)) {
type = 0;
ts += 7;
} else if (0 == strncmp(ts, "now ", 4)) {
type = 0;
ts += 4;
} else if (0 == strncmp(ts, "modification ", 13)) {
type = 1;
ts += 13;
@ -116,7 +119,7 @@ static int mod_expire_get_offset(server *srv, plugin_data *p, buffer *expire, in
ts += 5;
}
/* the rest is just <number> (years|months|days|hours|minutes|seconds) */
/* the rest is just <number> (years|months|weeks|days|hours|minutes|seconds) */
while (1) {
char *space, *err;
int num;
@ -148,6 +151,9 @@ static int mod_expire_get_offset(server *srv, plugin_data *p, buffer *expire, in
} else if (slen == 6 &&
0 == strncmp(ts, "months", slen)) {
num *= 60 * 60 * 24 * 30;
} else if (slen == 5 &&
0 == strncmp(ts, "weeks", slen)) {
num *= 60 * 60 * 24 * 7;
} else if (slen == 4 &&
0 == strncmp(ts, "days", slen)) {
num *= 60 * 60 * 24;
@ -174,6 +180,8 @@ static int mod_expire_get_offset(server *srv, plugin_data *p, buffer *expire, in
num *= 60 * 60 * 24 * 30 * 12;
} else if (0 == strcmp(ts, "months")) {
num *= 60 * 60 * 24 * 30;
} else if (0 == strcmp(ts, "weeks")) {
num *= 60 * 60 * 24 * 7;
} else if (0 == strcmp(ts, "days")) {
num *= 60 * 60 * 24;
} else if (0 == strcmp(ts, "hours")) {

Loading…
Cancel
Save