diff options
author | Stefan Bühler <stbuehler@web.de> | 2015-02-08 19:10:44 +0000 |
---|---|---|
committer | Stefan Bühler <stbuehler@web.de> | 2015-02-08 19:10:44 +0000 |
commit | ad3e93ea96d1cbaab00d07245dbd02f790060f85 (patch) | |
tree | ff1dab6ccb2f2cd95c2c668b290ed3b1ffc6022b /src/mod_staticfile.c | |
parent | adfa06de996944b495b878540464dd6e74563052 (diff) | |
download | lighttpd-git-ad3e93ea96d1cbaab00d07245dbd02f790060f85.tar.gz |
Use buffer API to read and modify "used" member
- a lot of code tried to handle manually adding terminating zeroes and
keeping track of the correct "used" count.
Replaced all "external" usages with simple wrapper functions:
* buffer_string_is_empty (used <= 1), buffer_is_empty (used == 0);
prefer buffer_string_is_empty
* buffer_string_set_length
* buffer_string_length
* CONST_BUF_LEN() macro
- removed "static" buffer hacks (buffers pointing to constant/stack
memory instead of malloc()ed data)
- buffer_append_strftime(): refactor buffer+strftime uses
- li_tohex(): no need for a buffer for binary-to-hex conversion:
the output data length is easy to predict
- remove "-Winline" from extra warnings: the "inline" keyword just
supresses the warning about unused but defined (static) functions;
don't care whether it actually gets inlined or not.
From: Stefan Bühler <stbuehler@web.de>
git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2979 152afb58-edef-0310-8abb-c4023f1b3aa9
Diffstat (limited to 'src/mod_staticfile.c')
-rw-r--r-- | src/mod_staticfile.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/mod_staticfile.c b/src/mod_staticfile.c index e36c6973..d40aa31b 100644 --- a/src/mod_staticfile.c +++ b/src/mod_staticfile.c @@ -304,7 +304,7 @@ static int http_response_parse_range(server *srv, connection *con, plugin_data * /* write END-OF-HEADER */ buffer_append_string_len(b, CONST_STR_LEN("\r\n\r\n")); - con->response.content_length += b->used - 1; + con->response.content_length += buffer_string_length(b); chunkqueue_append_buffer(con->write_queue, b); buffer_free(b); } @@ -325,7 +325,7 @@ static int http_response_parse_range(server *srv, connection *con, plugin_data * buffer_append_string(b, boundary); buffer_append_string_len(b, "--\r\n", 4); - con->response.content_length += b->used - 1; + con->response.content_length += buffer_string_length(b); chunkqueue_append_buffer(con->write_queue, b); buffer_free(b); @@ -363,8 +363,8 @@ URIHANDLER_FUNC(mod_staticfile_subrequest) { /* someone else has done a decision for us */ if (con->http_status != 0) return HANDLER_GO_ON; - if (con->uri.path->used == 0) return HANDLER_GO_ON; - if (con->physical.path->used == 0) return HANDLER_GO_ON; + if (buffer_is_empty(con->uri.path)) return HANDLER_GO_ON; + if (buffer_is_empty(con->physical.path)) return HANDLER_GO_ON; /* someone else has handled this request */ if (con->mode != DIRECT) return HANDLER_GO_ON; @@ -381,7 +381,7 @@ URIHANDLER_FUNC(mod_staticfile_subrequest) { mod_staticfile_patch_connection(srv, con, p); - if (p->conf.disable_pathinfo && 0 != con->request.pathinfo->used) { + if (p->conf.disable_pathinfo && !buffer_string_is_empty(con->request.pathinfo)) { if (con->conf.log_request_handling) { log_error_write(srv, __FILE__, __LINE__, "s", "-- NOT handling file as static file, pathinfo forbidden"); } @@ -392,9 +392,9 @@ URIHANDLER_FUNC(mod_staticfile_subrequest) { for (k = 0; k < p->conf.exclude_ext->used; k++) { ds = (data_string *)p->conf.exclude_ext->data[k]; - if (ds->value->used == 0) continue; + if (buffer_is_empty(ds->value)) continue; - if (buffer_is_equal_right_len(con->physical.path, ds->value, ds->value->used - 1)) { + if (buffer_is_equal_right_len(con->physical.path, ds->value, buffer_string_length(ds->value))) { if (con->conf.log_request_handling) { log_error_write(srv, __FILE__, __LINE__, "s", "-- NOT handling file as static file, extension forbidden"); } |