Replace buffer_{append,copy}_string with the _len variant where possible (#1732, thx crypt)
Replace BUFFER_{APPEND,COPY}_STRING_CONST with _len(b, CONST_STRL_LEN(x)) git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2250 152afb58-edef-0310-8abb-c4023f1b3aa9
This commit is contained in:
parent
0c8ebbeb60
commit
52861d77df
1
NEWS
1
NEWS
|
@ -35,6 +35,7 @@ NEWS
|
|||
* [tests] removed pidfile from test system
|
||||
* [tests] fixed tests needing php running (if not running on port 1026, search php in env[PHP] or /usr/bin/php-cgi)
|
||||
* fixed typo in mod_accesslog (#1699)
|
||||
* replaced buffer_{append,copy}_string with the _len variant where possible (#1732) (thx crypt)
|
||||
|
||||
- 1.4.19 - 2008-03-10
|
||||
|
||||
|
|
16
src/array.c
16
src/array.c
|
@ -330,30 +330,30 @@ int main (int argc, char **argv) {
|
|||
a = array_init();
|
||||
|
||||
ds = data_string_init();
|
||||
buffer_copy_string(ds->key, "abc");
|
||||
buffer_copy_string(ds->value, "alfrag");
|
||||
buffer_copy_string_len(ds->key, CONST_STR_LEN("abc"));
|
||||
buffer_copy_string_len(ds->value, CONST_STR_LEN("alfrag"));
|
||||
|
||||
array_insert_unique(a, (data_unset *)ds);
|
||||
|
||||
ds = data_string_init();
|
||||
buffer_copy_string(ds->key, "abc");
|
||||
buffer_copy_string(ds->value, "hameplman");
|
||||
buffer_copy_string_len(ds->key, CONST_STR_LEN("abc"));
|
||||
buffer_copy_string_len(ds->value, CONST_STR_LEN("hameplman"));
|
||||
|
||||
array_insert_unique(a, (data_unset *)ds);
|
||||
|
||||
ds = data_string_init();
|
||||
buffer_copy_string(ds->key, "123");
|
||||
buffer_copy_string(ds->value, "alfrag");
|
||||
buffer_copy_string_len(ds->key, CONST_STR_LEN("123"));
|
||||
buffer_copy_string_len(ds->value, CONST_STR_LEN("alfrag"));
|
||||
|
||||
array_insert_unique(a, (data_unset *)ds);
|
||||
|
||||
dc = data_count_init();
|
||||
buffer_copy_string(dc->key, "def");
|
||||
buffer_copy_string_len(dc->key, CONST_STR_LEN("def"));
|
||||
|
||||
array_insert_unique(a, (data_unset *)dc);
|
||||
|
||||
dc = data_count_init();
|
||||
buffer_copy_string(dc->key, "def");
|
||||
buffer_copy_string_len(dc->key, CONST_STR_LEN("def"));
|
||||
|
||||
array_insert_unique(a, (data_unset *)dc);
|
||||
|
||||
|
|
|
@ -296,7 +296,7 @@ chunk *chunkqueue_get_append_tempfile(chunkqueue *cq) {
|
|||
|
||||
buffer_copy_string_buffer(template, ds->value);
|
||||
BUFFER_APPEND_SLASH(template);
|
||||
BUFFER_APPEND_STRING_CONST(template, "lighttpd-upload-XXXXXX");
|
||||
buffer_append_string_len(template, CONST_STR_LEN("lighttpd-upload-XXXXXX"));
|
||||
|
||||
if (-1 != (c->file.fd = mkstemp(template->ptr))) {
|
||||
/* only trigger the unlink if we created the temp-file successfully */
|
||||
|
|
|
@ -155,7 +155,7 @@ int config_insert_values_global(server *srv, array *ca, const config_values_t cv
|
|||
/* touched */
|
||||
touched = data_string_init();
|
||||
|
||||
buffer_copy_string(touched->value, "");
|
||||
buffer_copy_string_len(touched->value, CONST_STR_LEN(""));
|
||||
buffer_copy_string_buffer(touched->key, du->key);
|
||||
|
||||
array_insert_unique(srv->config_touched, (data_unset *)touched);
|
||||
|
@ -260,7 +260,7 @@ static cond_result_t config_check_cond_nocache(server *srv, connection *con, dat
|
|||
if (ck_colon) {
|
||||
/* condition "host:port" but client send "host" */
|
||||
buffer_copy_string_buffer(srv->cond_check_buf, l);
|
||||
BUFFER_APPEND_STRING_CONST(srv->cond_check_buf, ":");
|
||||
buffer_append_string_len(srv->cond_check_buf, CONST_STR_LEN(":"));
|
||||
buffer_append_long(srv->cond_check_buf, sock_addr_get_port(&(srv_sock->addr)));
|
||||
l = srv->cond_check_buf;
|
||||
} else if (!ck_colon) {
|
||||
|
|
|
@ -478,7 +478,7 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
|
|||
if (t->input[t->offset + 1] == '>') {
|
||||
t->offset += 2;
|
||||
|
||||
buffer_copy_string(token, "=>");
|
||||
buffer_copy_string_len(token, CONST_STR_LEN("=>"));
|
||||
|
||||
tid = TK_ARRAY_ASSIGN;
|
||||
} else {
|
||||
|
@ -492,13 +492,13 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
|
|||
if (t->input[t->offset + 1] == '=') {
|
||||
t->offset += 2;
|
||||
|
||||
buffer_copy_string(token, "==");
|
||||
buffer_copy_string_len(token, CONST_STR_LEN("=="));
|
||||
|
||||
tid = TK_EQ;
|
||||
} else if (t->input[t->offset + 1] == '~') {
|
||||
t->offset += 2;
|
||||
|
||||
buffer_copy_string(token, "=~");
|
||||
buffer_copy_string_len(token, CONST_STR_LEN("=~"));
|
||||
|
||||
tid = TK_MATCH;
|
||||
} else {
|
||||
|
@ -531,13 +531,13 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
|
|||
if (t->input[t->offset + 1] == '=') {
|
||||
t->offset += 2;
|
||||
|
||||
buffer_copy_string(token, "!=");
|
||||
buffer_copy_string_len(token, CONST_STR_LEN("!="));
|
||||
|
||||
tid = TK_NE;
|
||||
} else if (t->input[t->offset + 1] == '~') {
|
||||
t->offset += 2;
|
||||
|
||||
buffer_copy_string(token, "!~");
|
||||
buffer_copy_string_len(token, CONST_STR_LEN("!~"));
|
||||
|
||||
tid = TK_NOMATCH;
|
||||
} else {
|
||||
|
@ -592,7 +592,7 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
|
|||
}
|
||||
t->in_key = 1;
|
||||
tid = TK_EOL;
|
||||
buffer_copy_string(token, "(EOL)");
|
||||
buffer_copy_string_len(token, CONST_STR_LEN("(EOL)"));
|
||||
} else {
|
||||
config_skip_newline(t);
|
||||
t->line_pos = 1;
|
||||
|
@ -603,7 +603,7 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
|
|||
if (t->in_brace > 0) {
|
||||
tid = TK_COMMA;
|
||||
|
||||
buffer_copy_string(token, "(COMMA)");
|
||||
buffer_copy_string_len(token, CONST_STR_LEN("(COMMA)"));
|
||||
}
|
||||
|
||||
t->offset++;
|
||||
|
@ -612,7 +612,7 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
|
|||
case '"':
|
||||
/* search for the terminating " */
|
||||
start = t->input + t->offset + 1;
|
||||
buffer_copy_string(token, "");
|
||||
buffer_copy_string_len(token, CONST_STR_LEN(""));
|
||||
|
||||
for (i = 1; t->input[t->offset + i]; i++) {
|
||||
if (t->input[t->offset + i] == '\\' &&
|
||||
|
@ -658,7 +658,7 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
|
|||
|
||||
tid = TK_LPARAN;
|
||||
|
||||
buffer_copy_string(token, "(");
|
||||
buffer_copy_string_len(token, CONST_STR_LEN("("));
|
||||
break;
|
||||
case ')':
|
||||
t->offset++;
|
||||
|
@ -666,7 +666,7 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
|
|||
|
||||
tid = TK_RPARAN;
|
||||
|
||||
buffer_copy_string(token, ")");
|
||||
buffer_copy_string_len(token, CONST_STR_LEN(")"));
|
||||
break;
|
||||
case '$':
|
||||
t->offset++;
|
||||
|
@ -675,19 +675,19 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
|
|||
t->in_cond = 1;
|
||||
t->in_key = 0;
|
||||
|
||||
buffer_copy_string(token, "$");
|
||||
buffer_copy_string_len(token, CONST_STR_LEN("$"));
|
||||
|
||||
break;
|
||||
|
||||
case '+':
|
||||
if (t->input[t->offset + 1] == '=') {
|
||||
t->offset += 2;
|
||||
buffer_copy_string(token, "+=");
|
||||
buffer_copy_string_len(token, CONST_STR_LEN("+="));
|
||||
tid = TK_APPEND;
|
||||
} else {
|
||||
t->offset++;
|
||||
tid = TK_PLUS;
|
||||
buffer_copy_string(token, "+");
|
||||
buffer_copy_string_len(token, CONST_STR_LEN("+"));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -696,7 +696,7 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
|
|||
|
||||
tid = TK_LCURLY;
|
||||
|
||||
buffer_copy_string(token, "{");
|
||||
buffer_copy_string_len(token, CONST_STR_LEN("{"));
|
||||
|
||||
break;
|
||||
|
||||
|
@ -705,7 +705,7 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
|
|||
|
||||
tid = TK_RCURLY;
|
||||
|
||||
buffer_copy_string(token, "}");
|
||||
buffer_copy_string_len(token, CONST_STR_LEN("}"));
|
||||
|
||||
break;
|
||||
|
||||
|
@ -714,7 +714,7 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
|
|||
|
||||
tid = TK_LBRACKET;
|
||||
|
||||
buffer_copy_string(token, "[");
|
||||
buffer_copy_string_len(token, CONST_STR_LEN("["));
|
||||
|
||||
break;
|
||||
|
||||
|
@ -723,7 +723,7 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
|
|||
|
||||
tid = TK_RBRACKET;
|
||||
|
||||
buffer_copy_string(token, "]");
|
||||
buffer_copy_string_len(token, CONST_STR_LEN("]"));
|
||||
|
||||
break;
|
||||
case '#':
|
||||
|
@ -1009,7 +1009,7 @@ int config_read(server *srv, const char *fn) {
|
|||
}
|
||||
|
||||
dc = data_config_init();
|
||||
buffer_copy_string(dc->key, "global");
|
||||
buffer_copy_string_len(dc->key, CONST_STR_LEN("global"));
|
||||
|
||||
assert(context.all_configs->used == 0);
|
||||
dc->context_ndx = context.all_configs->used;
|
||||
|
@ -1020,14 +1020,14 @@ int config_read(server *srv, const char *fn) {
|
|||
srv->config = dc->value;
|
||||
dpid = data_integer_init();
|
||||
dpid->value = getpid();
|
||||
buffer_copy_string(dpid->key, "var.PID");
|
||||
buffer_copy_string_len(dpid->key, CONST_STR_LEN("var.PID"));
|
||||
array_insert_unique(srv->config, (data_unset *)dpid);
|
||||
|
||||
dcwd = data_string_init();
|
||||
buffer_prepare_copy(dcwd->value, 1024);
|
||||
if (NULL != getcwd(dcwd->value->ptr, dcwd->value->size - 1)) {
|
||||
dcwd->value->used = strlen(dcwd->value->ptr) + 1;
|
||||
buffer_copy_string(dcwd->key, "var.CWD");
|
||||
buffer_copy_string_len(dcwd->key, CONST_STR_LEN("var.CWD"));
|
||||
array_insert_unique(srv->config, (data_unset *)dcwd);
|
||||
}
|
||||
|
||||
|
@ -1061,7 +1061,7 @@ int config_read(server *srv, const char *fn) {
|
|||
/* prepend default modules */
|
||||
if (NULL == array_get_element(modules->value, "mod_indexfile")) {
|
||||
ds = data_string_init();
|
||||
buffer_copy_string(ds->value, "mod_indexfile");
|
||||
buffer_copy_string_len(ds->value, CONST_STR_LEN("mod_indexfile"));
|
||||
array_insert_unique(prepends->value, (data_unset *)ds);
|
||||
}
|
||||
|
||||
|
@ -1074,13 +1074,13 @@ int config_read(server *srv, const char *fn) {
|
|||
/* append default modules */
|
||||
if (NULL == array_get_element(modules->value, "mod_dirlisting")) {
|
||||
ds = data_string_init();
|
||||
buffer_copy_string(ds->value, "mod_dirlisting");
|
||||
buffer_copy_string_len(ds->value, CONST_STR_LEN("mod_dirlisting"));
|
||||
array_insert_unique(modules->value, (data_unset *)ds);
|
||||
}
|
||||
|
||||
if (NULL == array_get_element(modules->value, "mod_staticfile")) {
|
||||
ds = data_string_init();
|
||||
buffer_copy_string(ds->value, "mod_staticfile");
|
||||
buffer_copy_string_len(ds->value, CONST_STR_LEN("mod_staticfile"));
|
||||
array_insert_unique(modules->value, (data_unset *)ds);
|
||||
}
|
||||
} else {
|
||||
|
@ -1090,18 +1090,18 @@ int config_read(server *srv, const char *fn) {
|
|||
|
||||
/* server.modules is not set */
|
||||
ds = data_string_init();
|
||||
buffer_copy_string(ds->value, "mod_indexfile");
|
||||
buffer_copy_string_len(ds->value, CONST_STR_LEN("mod_indexfile"));
|
||||
array_insert_unique(modules->value, (data_unset *)ds);
|
||||
|
||||
ds = data_string_init();
|
||||
buffer_copy_string(ds->value, "mod_dirlisting");
|
||||
buffer_copy_string_len(ds->value, CONST_STR_LEN("mod_dirlisting"));
|
||||
array_insert_unique(modules->value, (data_unset *)ds);
|
||||
|
||||
ds = data_string_init();
|
||||
buffer_copy_string(ds->value, "mod_staticfile");
|
||||
buffer_copy_string_len(ds->value, CONST_STR_LEN("mod_staticfile"));
|
||||
array_insert_unique(modules->value, (data_unset *)ds);
|
||||
|
||||
buffer_copy_string(modules->key, "server.modules");
|
||||
buffer_copy_string_len(modules->key, CONST_STR_LEN("server.modules"));
|
||||
array_insert_unique(srv->config, (data_unset *)modules);
|
||||
}
|
||||
|
||||
|
|
|
@ -475,30 +475,30 @@ static int connection_handle_write_prepare(server *srv, connection *con) {
|
|||
b = chunkqueue_get_append_buffer(con->write_queue);
|
||||
|
||||
/* build default error-page */
|
||||
buffer_copy_string(b,
|
||||
buffer_copy_string_len(b, CONST_STR_LEN(
|
||||
"<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
|
||||
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n"
|
||||
" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
|
||||
"<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n"
|
||||
" <head>\n"
|
||||
" <title>");
|
||||
" <title>"));
|
||||
buffer_append_long(b, con->http_status);
|
||||
buffer_append_string(b, " - ");
|
||||
buffer_append_string_len(b, CONST_STR_LEN(" - "));
|
||||
buffer_append_string(b, get_http_status_name(con->http_status));
|
||||
|
||||
buffer_append_string(b,
|
||||
buffer_append_string_len(b, CONST_STR_LEN(
|
||||
"</title>\n"
|
||||
" </head>\n"
|
||||
" <body>\n"
|
||||
" <h1>");
|
||||
" <h1>"));
|
||||
buffer_append_long(b, con->http_status);
|
||||
buffer_append_string(b, " - ");
|
||||
buffer_append_string_len(b, CONST_STR_LEN(" - "));
|
||||
buffer_append_string(b, get_http_status_name(con->http_status));
|
||||
|
||||
buffer_append_string(b,"</h1>\n"
|
||||
buffer_append_string_len(b, CONST_STR_LEN("</h1>\n"
|
||||
" </body>\n"
|
||||
"</html>\n"
|
||||
);
|
||||
));
|
||||
|
||||
response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html"));
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ static int data_string_insert_dup(data_unset *dst, data_unset *src) {
|
|||
data_string *ds_src = (data_string *)src;
|
||||
|
||||
if (ds_dst->value->used) {
|
||||
buffer_append_string(ds_dst->value, ", ");
|
||||
buffer_append_string_len(ds_dst->value, CONST_STR_LEN(", "));
|
||||
buffer_append_string_buffer(ds_dst->value, ds_src->value);
|
||||
} else {
|
||||
buffer_copy_string_buffer(ds_dst->value, ds_src->value);
|
||||
|
@ -53,9 +53,9 @@ static int data_response_insert_dup(data_unset *dst, data_unset *src) {
|
|||
data_string *ds_src = (data_string *)src;
|
||||
|
||||
if (ds_dst->value->used) {
|
||||
buffer_append_string(ds_dst->value, "\r\n");
|
||||
buffer_append_string_len(ds_dst->value, CONST_STR_LEN("\r\n"));
|
||||
buffer_append_string_buffer(ds_dst->value, ds_dst->key);
|
||||
buffer_append_string(ds_dst->value, ": ");
|
||||
buffer_append_string_len(ds_dst->value, CONST_STR_LEN(": "));
|
||||
buffer_append_string_buffer(ds_dst->value, ds_src->value);
|
||||
} else {
|
||||
buffer_copy_string_buffer(ds_dst->value, ds_src->value);
|
||||
|
|
|
@ -109,9 +109,9 @@ int http_response_redirect_to_directory(server *srv, connection *con) {
|
|||
o = buffer_init();
|
||||
|
||||
if (con->conf.is_ssl) {
|
||||
buffer_copy_string(o, "https://");
|
||||
buffer_copy_string_len(o, CONST_STR_LEN("https://"));
|
||||
} else {
|
||||
buffer_copy_string(o, "http://");
|
||||
buffer_copy_string_len(o, CONST_STR_LEN("http://"));
|
||||
}
|
||||
if (con->uri.authority->used) {
|
||||
buffer_append_string_buffer(o, con->uri.authority);
|
||||
|
@ -180,14 +180,14 @@ int http_response_redirect_to_directory(server *srv, connection *con) {
|
|||
|
||||
if (!((con->conf.is_ssl == 0 && srv->srvconf.port == 80) ||
|
||||
(con->conf.is_ssl == 1 && srv->srvconf.port == 443))) {
|
||||
buffer_append_string(o, ":");
|
||||
buffer_append_string_len(o, CONST_STR_LEN(":"));
|
||||
buffer_append_long(o, srv->srvconf.port);
|
||||
}
|
||||
}
|
||||
buffer_append_string_buffer(o, con->uri.path);
|
||||
buffer_append_string(o, "/");
|
||||
buffer_append_string_len(o, CONST_STR_LEN("/"));
|
||||
if (!buffer_is_empty(con->uri.query)) {
|
||||
buffer_append_string(o, "?");
|
||||
buffer_append_string_len(o, CONST_STR_LEN("?"));
|
||||
buffer_append_string_buffer(o, con->uri.query);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ static int http_chunk_append_len(server *srv, connection *con, size_t len) {
|
|||
b = srv->tmp_chunk_len;
|
||||
|
||||
if (len == 0) {
|
||||
buffer_copy_string(b, "0");
|
||||
buffer_copy_string_len(b, CONST_STR_LEN("0"));
|
||||
} else {
|
||||
for (i = 0; i < 8 && len; i++) {
|
||||
len >>= 4;
|
||||
|
@ -44,7 +44,7 @@ static int http_chunk_append_len(server *srv, connection *con, size_t len) {
|
|||
b->ptr[b->used++] = '\0';
|
||||
}
|
||||
|
||||
buffer_append_string(b, "\r\n");
|
||||
buffer_append_string_len(b, CONST_STR_LEN("\r\n"));
|
||||
chunkqueue_append_buffer(con->write_queue, b);
|
||||
|
||||
return 0;
|
||||
|
|
24
src/log.c
24
src/log.c
|
@ -185,18 +185,18 @@ int log_error_write(server *srv, const char *filename, unsigned int line, const
|
|||
}
|
||||
|
||||
buffer_copy_string_buffer(srv->errorlog_buf, srv->ts_debug_str);
|
||||
BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, ": (");
|
||||
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(": ("));
|
||||
break;
|
||||
case ERRORLOG_SYSLOG:
|
||||
/* syslog is generating its own timestamps */
|
||||
BUFFER_COPY_STRING_CONST(srv->errorlog_buf, "(");
|
||||
buffer_copy_string_len(srv->errorlog_buf, CONST_STR_LEN("("));
|
||||
break;
|
||||
}
|
||||
|
||||
buffer_append_string(srv->errorlog_buf, filename);
|
||||
BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, ".");
|
||||
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN("."));
|
||||
buffer_append_long(srv->errorlog_buf, line);
|
||||
BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, ") ");
|
||||
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(") "));
|
||||
|
||||
|
||||
for(va_start(ap, fmt); *fmt; fmt++) {
|
||||
|
@ -209,28 +209,28 @@ int log_error_write(server *srv, const char *filename, unsigned int line, const
|
|||
case 's': /* string */
|
||||
s = va_arg(ap, char *);
|
||||
buffer_append_string(srv->errorlog_buf, s);
|
||||
BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, " ");
|
||||
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(" "));
|
||||
break;
|
||||
case 'b': /* buffer */
|
||||
b = va_arg(ap, buffer *);
|
||||
buffer_append_string_buffer(srv->errorlog_buf, b);
|
||||
BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, " ");
|
||||
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(" "));
|
||||
break;
|
||||
case 'd': /* int */
|
||||
d = va_arg(ap, int);
|
||||
buffer_append_long(srv->errorlog_buf, d);
|
||||
BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, " ");
|
||||
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(" "));
|
||||
break;
|
||||
case 'o': /* off_t */
|
||||
o = va_arg(ap, off_t);
|
||||
buffer_append_off_t(srv->errorlog_buf, o);
|
||||
BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, " ");
|
||||
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(" "));
|
||||
break;
|
||||
case 'x': /* int (hex) */
|
||||
d = va_arg(ap, int);
|
||||
BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, "0x");
|
||||
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN("0x"));
|
||||
buffer_append_long_hex(srv->errorlog_buf, d);
|
||||
BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, " ");
|
||||
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(" "));
|
||||
break;
|
||||
case 'S': /* string */
|
||||
s = va_arg(ap, char *);
|
||||
|
@ -258,11 +258,11 @@ int log_error_write(server *srv, const char *filename, unsigned int line, const
|
|||
|
||||
switch(srv->errorlog_mode) {
|
||||
case ERRORLOG_FILE:
|
||||
BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, "\n");
|
||||
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN("\n"));
|
||||
write(srv->errorlog_fd, srv->errorlog_buf->ptr, srv->errorlog_buf->used - 1);
|
||||
break;
|
||||
case ERRORLOG_STDERR:
|
||||
BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, "\n");
|
||||
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN("\n"));
|
||||
write(STDERR_FILENO, srv->errorlog_buf->ptr, srv->errorlog_buf->used - 1);
|
||||
break;
|
||||
case ERRORLOG_SYSLOG:
|
||||
|
|
|
@ -433,7 +433,7 @@ SETDEFAULTS_FUNC(log_access_open) {
|
|||
if (i == 0 && buffer_is_empty(s->format)) {
|
||||
/* set a default logfile string */
|
||||
|
||||
buffer_copy_string(s->format, "%h %V %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"");
|
||||
buffer_copy_string_len(s->format, CONST_STR_LEN("%h %V %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""));
|
||||
}
|
||||
|
||||
/* parse */
|
||||
|
@ -654,7 +654,7 @@ REQUESTDONE_FUNC(log_access_write) {
|
|||
|
||||
b = p->conf.access_logbuffer;
|
||||
if (b->used == 0) {
|
||||
buffer_copy_string(b, "");
|
||||
buffer_copy_string_len(b, CONST_STR_LEN(""));
|
||||
}
|
||||
|
||||
for (j = 0; j < p->conf.parsed_format->used; j++) {
|
||||
|
@ -683,19 +683,19 @@ REQUESTDONE_FUNC(log_access_write) {
|
|||
# endif
|
||||
p->conf.ts_accesslog_str->used = strlen(p->conf.ts_accesslog_str->ptr) + 1;
|
||||
|
||||
buffer_append_string(p->conf.ts_accesslog_str, tm.tm_gmtoff >= 0 ? "+" : "-");
|
||||
buffer_append_string_len(p->conf.ts_accesslog_str, tm.tm_gmtoff >= 0 ? "+" : "-", 1);
|
||||
|
||||
scd = abs(tm.tm_gmtoff);
|
||||
hrs = scd / 3600;
|
||||
min = (scd % 3600) / 60;
|
||||
|
||||
/* hours */
|
||||
if (hrs < 10) buffer_append_string(p->conf.ts_accesslog_str, "0");
|
||||
if (hrs < 10) buffer_append_string_len(p->conf.ts_accesslog_str, CONST_STR_LEN("0"));
|
||||
buffer_append_long(p->conf.ts_accesslog_str, hrs);
|
||||
|
||||
if (min < 10) buffer_append_string(p->conf.ts_accesslog_str, "0");
|
||||
if (min < 10) buffer_append_string_len(p->conf.ts_accesslog_str, CONST_STR_LEN("0"));
|
||||
buffer_append_long(p->conf.ts_accesslog_str, min);
|
||||
BUFFER_APPEND_STRING_CONST(p->conf.ts_accesslog_str, "]");
|
||||
buffer_append_string_len(p->conf.ts_accesslog_str, CONST_STR_LEN("]"));
|
||||
#else
|
||||
#ifdef HAVE_GMTIME_R
|
||||
gmtime_r(&(srv->cur_ts), &tm);
|
||||
|
@ -722,13 +722,13 @@ REQUESTDONE_FUNC(log_access_write) {
|
|||
break;
|
||||
case FORMAT_REMOTE_IDENT:
|
||||
/* ident */
|
||||
BUFFER_APPEND_STRING_CONST(b, "-");
|
||||
buffer_append_string_len(b, CONST_STR_LEN("-"));
|
||||
break;
|
||||
case FORMAT_REMOTE_USER:
|
||||
if (con->authed_user->used > 1) {
|
||||
buffer_append_string_buffer(b, con->authed_user);
|
||||
} else {
|
||||
BUFFER_APPEND_STRING_CONST(b, "-");
|
||||
buffer_append_string_len(b, CONST_STR_LEN("-"));
|
||||
}
|
||||
break;
|
||||
case FORMAT_REQUEST_LINE:
|
||||
|
@ -745,42 +745,42 @@ REQUESTDONE_FUNC(log_access_write) {
|
|||
buffer_append_off_t(b,
|
||||
con->bytes_written - con->bytes_header <= 0 ? 0 : con->bytes_written - con->bytes_header);
|
||||
} else {
|
||||
BUFFER_APPEND_STRING_CONST(b, "-");
|
||||
buffer_append_string_len(b, CONST_STR_LEN("-"));
|
||||
}
|
||||
break;
|
||||
case FORMAT_HEADER:
|
||||
if (NULL != (ds = (data_string *)array_get_element(con->request.headers, p->conf.parsed_format->ptr[j]->string->ptr))) {
|
||||
buffer_append_string_buffer(b, ds->value);
|
||||
} else {
|
||||
BUFFER_APPEND_STRING_CONST(b, "-");
|
||||
buffer_append_string_len(b, CONST_STR_LEN("-"));
|
||||
}
|
||||
break;
|
||||
case FORMAT_RESPONSE_HEADER:
|
||||
if (NULL != (ds = (data_string *)array_get_element(con->response.headers, p->conf.parsed_format->ptr[j]->string->ptr))) {
|
||||
buffer_append_string_buffer(b, ds->value);
|
||||
} else {
|
||||
BUFFER_APPEND_STRING_CONST(b, "-");
|
||||
buffer_append_string_len(b, CONST_STR_LEN("-"));
|
||||
}
|
||||
break;
|
||||
case FORMAT_FILENAME:
|
||||
if (con->physical.path->used > 1) {
|
||||
buffer_append_string_buffer(b, con->physical.path);
|
||||
} else {
|
||||
BUFFER_APPEND_STRING_CONST(b, "-");
|
||||
buffer_append_string_len(b, CONST_STR_LEN("-"));
|
||||
}
|
||||
break;
|
||||
case FORMAT_BYTES_OUT:
|
||||
if (con->bytes_written > 0) {
|
||||
buffer_append_off_t(b, con->bytes_written);
|
||||
} else {
|
||||
BUFFER_APPEND_STRING_CONST(b, "-");
|
||||
buffer_append_string_len(b, CONST_STR_LEN("-"));
|
||||
}
|
||||
break;
|
||||
case FORMAT_BYTES_IN:
|
||||
if (con->bytes_read > 0) {
|
||||
buffer_append_off_t(b, con->bytes_read);
|
||||
} else {
|
||||
BUFFER_APPEND_STRING_CONST(b, "-");
|
||||
buffer_append_string_len(b, CONST_STR_LEN("-"));
|
||||
}
|
||||
break;
|
||||
case FORMAT_TIME_USED:
|
||||
|
@ -790,25 +790,25 @@ REQUESTDONE_FUNC(log_access_write) {
|
|||
if (con->server_name->used > 1) {
|
||||
buffer_append_string_buffer(b, con->server_name);
|
||||
} else {
|
||||
BUFFER_APPEND_STRING_CONST(b, "-");
|
||||
buffer_append_string_len(b, CONST_STR_LEN("-"));
|
||||
}
|
||||
break;
|
||||
case FORMAT_HTTP_HOST:
|
||||
if (con->uri.authority->used > 1) {
|
||||
buffer_append_string_buffer(b, con->uri.authority);
|
||||
} else {
|
||||
BUFFER_APPEND_STRING_CONST(b, "-");
|
||||
buffer_append_string_len(b, CONST_STR_LEN("-"));
|
||||
}
|
||||
break;
|
||||
case FORMAT_REQUEST_PROTOCOL:
|
||||
buffer_append_string(b,
|
||||
con->request.http_version == HTTP_VERSION_1_1 ? "HTTP/1.1" : "HTTP/1.0");
|
||||
buffer_append_string_len(b,
|
||||
con->request.http_version == HTTP_VERSION_1_1 ? "HTTP/1.1" : "HTTP/1.0", 8);
|
||||
break;
|
||||
case FORMAT_REQUEST_METHOD:
|
||||
buffer_append_string(b, get_http_method_name(con->request.http_method));
|
||||
break;
|
||||
case FORMAT_PERCENT:
|
||||
buffer_append_string(b, "%");
|
||||
buffer_append_string_len(b, CONST_STR_LEN("%"));
|
||||
break;
|
||||
case FORMAT_SERVER_PORT:
|
||||
{
|
||||
|
@ -828,8 +828,8 @@ REQUESTDONE_FUNC(log_access_write) {
|
|||
break;
|
||||
case FORMAT_CONNECTION_STATUS:
|
||||
switch(con->keep_alive) {
|
||||
case 0: buffer_append_string(b, "-"); break;
|
||||
default: buffer_append_string(b, "+"); break;
|
||||
case 0: buffer_append_string_len(b, CONST_STR_LEN("-")); break;
|
||||
default: buffer_append_string_len(b, CONST_STR_LEN("+")); break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -849,7 +849,7 @@ REQUESTDONE_FUNC(log_access_write) {
|
|||
}
|
||||
}
|
||||
|
||||
BUFFER_APPEND_STRING_CONST(b, "\n");
|
||||
buffer_append_string_len(b, CONST_STR_LEN("\n"));
|
||||
|
||||
if (p->conf.use_syslog || /* syslog doesn't cache */
|
||||
(p->conf.access_logfile->used && p->conf.access_logfile->ptr[0] == '|') || /* pipes don't cache */
|
||||
|
|
|
@ -270,20 +270,20 @@ static handler_t mod_auth_uri_handler(server *srv, connection *con, void *p_d) {
|
|||
con->http_status = 401;
|
||||
|
||||
if (0 == strcmp(method->value->ptr, "basic")) {
|
||||
buffer_copy_string(p->tmp_buf, "Basic realm=\"");
|
||||
buffer_copy_string_len(p->tmp_buf, CONST_STR_LEN("Basic realm=\""));
|
||||
buffer_append_string_buffer(p->tmp_buf, realm->value);
|
||||
buffer_append_string(p->tmp_buf, "\"");
|
||||
buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("\""));
|
||||
|
||||
response_header_insert(srv, con, CONST_STR_LEN("WWW-Authenticate"), CONST_BUF_LEN(p->tmp_buf));
|
||||
} else if (0 == strcmp(method->value->ptr, "digest")) {
|
||||
char hh[33];
|
||||
http_auth_digest_generate_nonce(srv, p, srv->tmp_buf, hh);
|
||||
|
||||
buffer_copy_string(p->tmp_buf, "Digest realm=\"");
|
||||
buffer_copy_string_len(p->tmp_buf, CONST_STR_LEN("Digest realm=\""));
|
||||
buffer_append_string_buffer(p->tmp_buf, realm->value);
|
||||
buffer_append_string(p->tmp_buf, "\", nonce=\"");
|
||||
buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("\", nonce=\""));
|
||||
buffer_append_string(p->tmp_buf, hh);
|
||||
buffer_append_string(p->tmp_buf, "\", qop=\"auth\"");
|
||||
buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("\", qop=\"auth\""));
|
||||
|
||||
response_header_insert(srv, con, CONST_STR_LEN("WWW-Authenticate"), CONST_BUF_LEN(p->tmp_buf));
|
||||
} else {
|
||||
|
@ -479,21 +479,21 @@ SETDEFAULTS_FUNC(mod_auth_set_defaults) {
|
|||
|
||||
ds = data_string_init();
|
||||
|
||||
buffer_copy_string(ds->key, "method");
|
||||
buffer_copy_string_len(ds->key, CONST_STR_LEN("method"));
|
||||
buffer_copy_string(ds->value, method);
|
||||
|
||||
array_insert_unique(a->value, (data_unset *)ds);
|
||||
|
||||
ds = data_string_init();
|
||||
|
||||
buffer_copy_string(ds->key, "realm");
|
||||
buffer_copy_string_len(ds->key, CONST_STR_LEN("realm"));
|
||||
buffer_copy_string(ds->value, realm);
|
||||
|
||||
array_insert_unique(a->value, (data_unset *)ds);
|
||||
|
||||
ds = data_string_init();
|
||||
|
||||
buffer_copy_string(ds->key, "require");
|
||||
buffer_copy_string_len(ds->key, CONST_STR_LEN("require"));
|
||||
buffer_copy_string(ds->value, require);
|
||||
|
||||
array_insert_unique(a->value, (data_unset *)ds);
|
||||
|
|
|
@ -912,7 +912,7 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer *
|
|||
buffer_reset(p->tmp_buf);
|
||||
|
||||
if (0 != strcasecmp(ds->key->ptr, "CONTENT-TYPE")) {
|
||||
buffer_copy_string(p->tmp_buf, "HTTP_");
|
||||
buffer_copy_string_len(p->tmp_buf, CONST_STR_LEN("HTTP_"));
|
||||
p->tmp_buf->used--; /* strip \0 after HTTP_ */
|
||||
}
|
||||
|
||||
|
|
|
@ -396,13 +396,13 @@ static int deflate_file_to_file(server *srv, connection *con, plugin_data *p, bu
|
|||
|
||||
switch(type) {
|
||||
case HTTP_ACCEPT_ENCODING_GZIP:
|
||||
buffer_append_string(p->ofn, "-gzip-");
|
||||
buffer_append_string_len(p->ofn, CONST_STR_LEN("-gzip-"));
|
||||
break;
|
||||
case HTTP_ACCEPT_ENCODING_DEFLATE:
|
||||
buffer_append_string(p->ofn, "-deflate-");
|
||||
buffer_append_string_len(p->ofn, CONST_STR_LEN("-deflate-"));
|
||||
break;
|
||||
case HTTP_ACCEPT_ENCODING_BZIP2:
|
||||
buffer_append_string(p->ofn, "-bzip2-");
|
||||
buffer_append_string_len(p->ofn, CONST_STR_LEN("-bzip2-"));
|
||||
break;
|
||||
default:
|
||||
log_error_write(srv, __FILE__, __LINE__, "sd", "unknown compression type", type);
|
||||
|
|
|
@ -454,21 +454,21 @@ static int http_list_directory_sizefmt(char *buf, off_t size) {
|
|||
static void http_list_directory_header(server *srv, connection *con, plugin_data *p, buffer *out) {
|
||||
UNUSED(srv);
|
||||
|
||||
BUFFER_APPEND_STRING_CONST(out,
|
||||
buffer_append_string_len(out, CONST_STR_LEN(
|
||||
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"
|
||||
"<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n"
|
||||
"<head>\n"
|
||||
"<title>Index of "
|
||||
);
|
||||
));
|
||||
buffer_append_string_encoded(out, CONST_BUF_LEN(con->uri.path), ENCODING_MINIMAL_XML);
|
||||
BUFFER_APPEND_STRING_CONST(out, "</title>\n");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("</title>\n"));
|
||||
|
||||
if (p->conf.external_css->used > 1) {
|
||||
BUFFER_APPEND_STRING_CONST(out, "<link rel=\"stylesheet\" type=\"text/css\" href=\"");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("<link rel=\"stylesheet\" type=\"text/css\" href=\""));
|
||||
buffer_append_string_buffer(out, p->conf.external_css);
|
||||
BUFFER_APPEND_STRING_CONST(out, "\" />\n");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("\" />\n"));
|
||||
} else {
|
||||
BUFFER_APPEND_STRING_CONST(out,
|
||||
buffer_append_string_len(out, CONST_STR_LEN(
|
||||
"<style type=\"text/css\">\n"
|
||||
"a, a:active {text-decoration: none; color: blue;}\n"
|
||||
"a:visited {color: #48468F;}\n"
|
||||
|
@ -485,8 +485,6 @@ static void http_list_directory_header(server *srv, connection *con, plugin_data
|
|||
" padding-right: 14px;"
|
||||
" padding-bottom: 3px;"
|
||||
"}\n"
|
||||
);
|
||||
BUFFER_APPEND_STRING_CONST(out,
|
||||
"td {padding-right: 14px;}\n"
|
||||
"td.s, th.s {text-align: right;}\n"
|
||||
"div.list {"
|
||||
|
@ -502,10 +500,10 @@ static void http_list_directory_header(server *srv, connection *con, plugin_data
|
|||
" padding-top: 4px;"
|
||||
"}\n"
|
||||
"</style>\n"
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
BUFFER_APPEND_STRING_CONST(out, "</head>\n<body>\n");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("</head>\n<body>\n"));
|
||||
|
||||
/* HEADER.txt */
|
||||
if (p->conf.show_header) {
|
||||
|
@ -514,19 +512,19 @@ static void http_list_directory_header(server *srv, connection *con, plugin_data
|
|||
|
||||
buffer_copy_string_buffer(p->tmp_buf, con->physical.path);
|
||||
BUFFER_APPEND_SLASH(p->tmp_buf);
|
||||
BUFFER_APPEND_STRING_CONST(p->tmp_buf, "HEADER.txt");
|
||||
buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("HEADER.txt"));
|
||||
|
||||
if (-1 != stream_open(&s, p->tmp_buf)) {
|
||||
BUFFER_APPEND_STRING_CONST(out, "<pre class=\"header\">");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("<pre class=\"header\">"));
|
||||
buffer_append_string_encoded(out, s.start, s.size, ENCODING_MINIMAL_XML);
|
||||
BUFFER_APPEND_STRING_CONST(out, "</pre>");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("</pre>"));
|
||||
}
|
||||
stream_close(&s);
|
||||
}
|
||||
|
||||
BUFFER_APPEND_STRING_CONST(out, "<h2>Index of ");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("<h2>Index of "));
|
||||
buffer_append_string_encoded(out, CONST_BUF_LEN(con->uri.path), ENCODING_MINIMAL_XML);
|
||||
BUFFER_APPEND_STRING_CONST(out,
|
||||
buffer_append_string_len(out, CONST_STR_LEN(
|
||||
"</h2>\n"
|
||||
"<div class=\"list\">\n"
|
||||
"<table summary=\"Directory Listing\" cellpadding=\"0\" cellspacing=\"0\">\n"
|
||||
|
@ -545,17 +543,17 @@ static void http_list_directory_header(server *srv, connection *con, plugin_data
|
|||
"<td class=\"s\">- </td>"
|
||||
"<td class=\"t\">Directory</td>"
|
||||
"</tr>\n"
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
static void http_list_directory_footer(server *srv, connection *con, plugin_data *p, buffer *out) {
|
||||
UNUSED(srv);
|
||||
|
||||
BUFFER_APPEND_STRING_CONST(out,
|
||||
buffer_append_string_len(out, CONST_STR_LEN(
|
||||
"</tbody>\n"
|
||||
"</table>\n"
|
||||
"</div>\n"
|
||||
);
|
||||
));
|
||||
|
||||
if (p->conf.show_readme) {
|
||||
stream s;
|
||||
|
@ -563,33 +561,33 @@ static void http_list_directory_footer(server *srv, connection *con, plugin_data
|
|||
|
||||
buffer_copy_string_buffer(p->tmp_buf, con->physical.path);
|
||||
BUFFER_APPEND_SLASH(p->tmp_buf);
|
||||
BUFFER_APPEND_STRING_CONST(p->tmp_buf, "README.txt");
|
||||
buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("README.txt"));
|
||||
|
||||
if (-1 != stream_open(&s, p->tmp_buf)) {
|
||||
BUFFER_APPEND_STRING_CONST(out, "<pre class=\"readme\">");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("<pre class=\"readme\">"));
|
||||
buffer_append_string_encoded(out, s.start, s.size, ENCODING_MINIMAL_XML);
|
||||
BUFFER_APPEND_STRING_CONST(out, "</pre>");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("</pre>"));
|
||||
}
|
||||
stream_close(&s);
|
||||
}
|
||||
|
||||
BUFFER_APPEND_STRING_CONST(out,
|
||||
buffer_append_string_len(out, CONST_STR_LEN(
|
||||
"<div class=\"foot\">"
|
||||
);
|
||||
));
|
||||
|
||||
if (p->conf.set_footer->used > 1) {
|
||||
buffer_append_string_buffer(out, p->conf.set_footer);
|
||||
} else if (buffer_is_empty(con->conf.server_tag)) {
|
||||
BUFFER_APPEND_STRING_CONST(out, PACKAGE_NAME "/" PACKAGE_VERSION);
|
||||
buffer_append_string_len(out, CONST_STR_LEN(PACKAGE_NAME "/" PACKAGE_VERSION));
|
||||
} else {
|
||||
buffer_append_string_buffer(out, con->conf.server_tag);
|
||||
}
|
||||
|
||||
BUFFER_APPEND_STRING_CONST(out,
|
||||
buffer_append_string_len(out, CONST_STR_LEN(
|
||||
"</div>\n"
|
||||
"</body>\n"
|
||||
"</html>\n"
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
static int http_list_directory(server *srv, connection *con, plugin_data *p, buffer *dir) {
|
||||
|
@ -742,13 +740,13 @@ static int http_list_directory(server *srv, connection *con, plugin_data *p, buf
|
|||
if (files.used) http_dirls_sort(files.ent, files.used);
|
||||
|
||||
out = chunkqueue_get_append_buffer(con->write_queue);
|
||||
BUFFER_COPY_STRING_CONST(out, "<?xml version=\"1.0\" encoding=\"");
|
||||
buffer_copy_string_len(out, CONST_STR_LEN("<?xml version=\"1.0\" encoding=\""));
|
||||
if (buffer_is_empty(p->conf.encoding)) {
|
||||
BUFFER_APPEND_STRING_CONST(out, "iso-8859-1");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("iso-8859-1"));
|
||||
} else {
|
||||
buffer_append_string_buffer(out, p->conf.encoding);
|
||||
}
|
||||
BUFFER_APPEND_STRING_CONST(out, "\"?>\n");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("\"?>\n"));
|
||||
http_list_directory_header(srv, con, p, out);
|
||||
|
||||
/* directories */
|
||||
|
@ -762,13 +760,13 @@ static int http_list_directory(server *srv, connection *con, plugin_data *p, buf
|
|||
strftime(datebuf, sizeof(datebuf), "%Y-%b-%d %H:%M:%S", localtime(&(tmp->mtime)));
|
||||
#endif
|
||||
|
||||
BUFFER_APPEND_STRING_CONST(out, "<tr><td class=\"n\"><a href=\"");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("<tr><td class=\"n\"><a href=\""));
|
||||
buffer_append_string_encoded(out, DIRLIST_ENT_NAME(tmp), tmp->namelen, ENCODING_REL_URI_PART);
|
||||
BUFFER_APPEND_STRING_CONST(out, "/\">");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("/\">"));
|
||||
buffer_append_string_encoded(out, DIRLIST_ENT_NAME(tmp), tmp->namelen, ENCODING_MINIMAL_XML);
|
||||
BUFFER_APPEND_STRING_CONST(out, "</a>/</td><td class=\"m\">");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("</a>/</td><td class=\"m\">"));
|
||||
buffer_append_string_len(out, datebuf, sizeof(datebuf) - 1);
|
||||
BUFFER_APPEND_STRING_CONST(out, "</td><td class=\"s\">- </td><td class=\"t\">Directory</td></tr>\n");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("</td><td class=\"s\">- </td><td class=\"t\">Directory</td></tr>\n"));
|
||||
|
||||
free(tmp);
|
||||
}
|
||||
|
@ -818,17 +816,17 @@ static int http_list_directory(server *srv, connection *con, plugin_data *p, buf
|
|||
#endif
|
||||
http_list_directory_sizefmt(sizebuf, tmp->size);
|
||||
|
||||
BUFFER_APPEND_STRING_CONST(out, "<tr><td class=\"n\"><a href=\"");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("<tr><td class=\"n\"><a href=\""));
|
||||
buffer_append_string_encoded(out, DIRLIST_ENT_NAME(tmp), tmp->namelen, ENCODING_REL_URI_PART);
|
||||
BUFFER_APPEND_STRING_CONST(out, "\">");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("\">"));
|
||||
buffer_append_string_encoded(out, DIRLIST_ENT_NAME(tmp), tmp->namelen, ENCODING_MINIMAL_XML);
|
||||
BUFFER_APPEND_STRING_CONST(out, "</a></td><td class=\"m\">");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("</a></td><td class=\"m\">"));
|
||||
buffer_append_string_len(out, datebuf, sizeof(datebuf) - 1);
|
||||
BUFFER_APPEND_STRING_CONST(out, "</td><td class=\"s\">");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("</td><td class=\"s\">"));
|
||||
buffer_append_string(out, sizebuf);
|
||||
BUFFER_APPEND_STRING_CONST(out, "</td><td class=\"t\">");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("</td><td class=\"t\">"));
|
||||
buffer_append_string(out, content_type);
|
||||
BUFFER_APPEND_STRING_CONST(out, "</td></tr>\n");
|
||||
buffer_append_string_len(out, CONST_STR_LEN("</td></tr>\n"));
|
||||
|
||||
free(tmp);
|
||||
}
|
||||
|
@ -843,7 +841,7 @@ static int http_list_directory(server *srv, connection *con, plugin_data *p, buf
|
|||
if (buffer_is_empty(p->conf.encoding)) {
|
||||
response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html"));
|
||||
} else {
|
||||
buffer_copy_string(p->content_charset, "text/html; charset=");
|
||||
buffer_copy_string_len(p->content_charset, CONST_STR_LEN("text/html; charset="));
|
||||
buffer_append_string_buffer(p->content_charset, p->conf.encoding);
|
||||
response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_BUF_LEN(p->content_charset));
|
||||
}
|
||||
|
|
|
@ -181,7 +181,7 @@ static int mod_evhost_parse_host(connection *con,array *host) {
|
|||
}
|
||||
|
||||
ds = data_string_init();
|
||||
buffer_copy_string(ds->key,"%0");
|
||||
buffer_copy_string_len(ds->key,CONST_STR_LEN("%0"));
|
||||
|
||||
/* if we stopped at a dot, skip the dot */
|
||||
if (*ptr == '.') ptr++;
|
||||
|
@ -197,7 +197,7 @@ static int mod_evhost_parse_host(connection *con,array *host) {
|
|||
if (ptr != colon - 1) {
|
||||
/* is something between the dots */
|
||||
ds = data_string_init();
|
||||
buffer_copy_string(ds->key,"%");
|
||||
buffer_copy_string_len(ds->key,CONST_STR_LEN("%"));
|
||||
buffer_append_long(ds->key, i++);
|
||||
buffer_copy_string_len(ds->value,ptr+1,colon-ptr-1);
|
||||
|
||||
|
@ -210,7 +210,7 @@ static int mod_evhost_parse_host(connection *con,array *host) {
|
|||
/* if the . is not the first charactor of the hostname */
|
||||
if (colon != ptr) {
|
||||
ds = data_string_init();
|
||||
buffer_copy_string(ds->key,"%");
|
||||
buffer_copy_string_len(ds->key,CONST_STR_LEN("%"));
|
||||
buffer_append_long(ds->key, i++);
|
||||
buffer_copy_string_len(ds->value,ptr,colon-ptr);
|
||||
|
||||
|
@ -286,7 +286,7 @@ static handler_t mod_evhost_uri_handler(server *srv, connection *con, void *p_d)
|
|||
|
||||
if (*(ptr+1) == '%') {
|
||||
/* %% */
|
||||
BUFFER_APPEND_STRING_CONST(p->tmp_buf,"%");
|
||||
buffer_append_string_len(p->tmp_buf,CONST_STR_LEN("%"));
|
||||
} else if (NULL != (ds = (data_string *)array_get_element(parsed_host,p->conf.path_pieces[i]->ptr))) {
|
||||
if (ds->value->used) {
|
||||
buffer_append_string_buffer(p->tmp_buf,ds->value);
|
||||
|
|
|
@ -339,7 +339,7 @@ URIHANDLER_FUNC(mod_expire_path_handler) {
|
|||
response_header_overwrite(srv, con, CONST_STR_LEN("Expires"), CONST_BUF_LEN(p->expire_tstmp));
|
||||
|
||||
/* HTTP/1.1 */
|
||||
buffer_copy_string(p->expire_tstmp, "max-age=");
|
||||
buffer_copy_string_len(p->expire_tstmp, CONST_STR_LEN("max-age="));
|
||||
buffer_append_long(p->expire_tstmp, ts);
|
||||
|
||||
response_header_overwrite(srv, con, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(p->expire_tstmp));
|
||||
|
|
|
@ -390,10 +390,10 @@ typedef struct {
|
|||
static handler_t fcgi_handle_fdevent(void *s, void *ctx, int revents);
|
||||
|
||||
int fastcgi_status_copy_procname(buffer *b, fcgi_extension_host *host, fcgi_proc *proc) {
|
||||
buffer_copy_string(b, "fastcgi.backend.");
|
||||
buffer_copy_string_len(b, CONST_STR_LEN("fastcgi.backend."));
|
||||
buffer_append_string_buffer(b, host->id);
|
||||
if (proc) {
|
||||
buffer_append_string(b, ".");
|
||||
buffer_append_string_len(b, CONST_STR_LEN("."));
|
||||
buffer_append_long(b, proc->id);
|
||||
}
|
||||
|
||||
|
@ -403,7 +403,7 @@ int fastcgi_status_copy_procname(buffer *b, fcgi_extension_host *host, fcgi_proc
|
|||
int fastcgi_status_init(server *srv, buffer *b, fcgi_extension_host *host, fcgi_proc *proc) {
|
||||
#define CLEAN(x) \
|
||||
fastcgi_status_copy_procname(b, host, proc); \
|
||||
buffer_append_string(b, x); \
|
||||
buffer_append_string_len(b, CONST_STR_LEN(x)); \
|
||||
status_counter_set(srv, CONST_BUF_LEN(b), 0);
|
||||
|
||||
CLEAN(".disabled");
|
||||
|
@ -416,7 +416,7 @@ int fastcgi_status_init(server *srv, buffer *b, fcgi_extension_host *host, fcgi_
|
|||
|
||||
#define CLEAN(x) \
|
||||
fastcgi_status_copy_procname(b, host, NULL); \
|
||||
buffer_append_string(b, x); \
|
||||
buffer_append_string_len(b, CONST_STR_LEN(x)); \
|
||||
status_counter_set(srv, CONST_BUF_LEN(b), 0);
|
||||
|
||||
CLEAN(".load");
|
||||
|
@ -821,7 +821,7 @@ static int fcgi_spawn_connection(server *srv,
|
|||
socket_type = AF_UNIX;
|
||||
fcgi_addr = (struct sockaddr *) &fcgi_addr_un;
|
||||
|
||||
buffer_copy_string(proc->connection_name, "unix:");
|
||||
buffer_copy_string_len(proc->connection_name, CONST_STR_LEN("unix:"));
|
||||
buffer_append_string_buffer(proc->connection_name, proc->unixsocket);
|
||||
|
||||
#else
|
||||
|
@ -867,13 +867,13 @@ static int fcgi_spawn_connection(server *srv,
|
|||
socket_type = AF_INET;
|
||||
fcgi_addr = (struct sockaddr *) &fcgi_addr_in;
|
||||
|
||||
buffer_copy_string(proc->connection_name, "tcp:");
|
||||
buffer_copy_string_len(proc->connection_name, CONST_STR_LEN("tcp:"));
|
||||
if (!buffer_is_empty(host->host)) {
|
||||
buffer_append_string_buffer(proc->connection_name, host->host);
|
||||
} else {
|
||||
buffer_append_string(proc->connection_name, "localhost");
|
||||
buffer_append_string_len(proc->connection_name, CONST_STR_LEN("localhost"));
|
||||
}
|
||||
buffer_append_string(proc->connection_name, ":");
|
||||
buffer_append_string_len(proc->connection_name, CONST_STR_LEN(":"));
|
||||
buffer_append_long(proc->connection_name, proc->port);
|
||||
}
|
||||
|
||||
|
@ -1339,7 +1339,7 @@ SETDEFAULTS_FUNC(mod_fastcgi_set_defaults) {
|
|||
proc->port = host->port + pno;
|
||||
} else {
|
||||
buffer_copy_string_buffer(proc->unixsocket, host->unixsocket);
|
||||
buffer_append_string(proc->unixsocket, "-");
|
||||
buffer_append_string_len(proc->unixsocket, CONST_STR_LEN("-"));
|
||||
buffer_append_long(proc->unixsocket, pno);
|
||||
}
|
||||
|
||||
|
@ -1497,7 +1497,7 @@ void fcgi_connection_close(server *srv, handler_ctx *hctx) {
|
|||
status_counter_dec(srv, CONST_STR_LEN("fastcgi.active-requests"));
|
||||
|
||||
fastcgi_status_copy_procname(p->statuskey, hctx->host, hctx->proc);
|
||||
buffer_append_string(p->statuskey, ".load");
|
||||
buffer_append_string_len(p->statuskey, CONST_STR_LEN(".load"));
|
||||
|
||||
status_counter_set(srv, CONST_BUF_LEN(p->statuskey), hctx->proc->load);
|
||||
|
||||
|
@ -1698,7 +1698,7 @@ static connection_result_t fcgi_establish_connection(server *srv, handler_ctx *h
|
|||
|
||||
if (buffer_is_empty(proc->connection_name)) {
|
||||
/* on remote spawing we have to set the connection-name now */
|
||||
buffer_copy_string(proc->connection_name, "unix:");
|
||||
buffer_copy_string_len(proc->connection_name, CONST_STR_LEN("unix:"));
|
||||
buffer_append_string_buffer(proc->connection_name, proc->unixsocket);
|
||||
}
|
||||
#else
|
||||
|
@ -1724,13 +1724,13 @@ static connection_result_t fcgi_establish_connection(server *srv, handler_ctx *h
|
|||
|
||||
if (buffer_is_empty(proc->connection_name)) {
|
||||
/* on remote spawing we have to set the connection-name now */
|
||||
buffer_copy_string(proc->connection_name, "tcp:");
|
||||
buffer_copy_string_len(proc->connection_name, CONST_STR_LEN("tcp:"));
|
||||
if (!buffer_is_empty(host->host)) {
|
||||
buffer_append_string_buffer(proc->connection_name, host->host);
|
||||
} else {
|
||||
buffer_append_string(proc->connection_name, "localhost");
|
||||
buffer_append_string_len(proc->connection_name, CONST_STR_LEN("localhost"));
|
||||
}
|
||||
buffer_append_string(proc->connection_name, ":");
|
||||
buffer_append_string_len(proc->connection_name, CONST_STR_LEN(":"));
|
||||
buffer_append_long(proc->connection_name, proc->port);
|
||||
}
|
||||
}
|
||||
|
@ -1786,7 +1786,7 @@ static int fcgi_env_add_request_headers(server *srv, connection *con, plugin_dat
|
|||
buffer_reset(srv->tmp_buf);
|
||||
|
||||
if (0 != strcasecmp(ds->key->ptr, "CONTENT-TYPE")) {
|
||||
BUFFER_COPY_STRING_CONST(srv->tmp_buf, "HTTP_");
|
||||
buffer_copy_string_len(srv->tmp_buf, CONST_STR_LEN("HTTP_"));
|
||||
srv->tmp_buf->used--;
|
||||
}
|
||||
|
||||
|
@ -2041,7 +2041,7 @@ static int fcgi_create_env(server *srv, handler_ctx *hctx, size_t request_id) {
|
|||
*/
|
||||
if ('/' != host->strip_request_uri->ptr[host->strip_request_uri->used - 2]) {
|
||||
/* fix the user-input to have / as last char */
|
||||
buffer_append_string(host->strip_request_uri, "/");
|
||||
buffer_append_string_len(host->strip_request_uri, CONST_STR_LEN("/"));
|
||||
}
|
||||
|
||||
if (con->request.orig_uri->used >= host->strip_request_uri->used &&
|
||||
|
@ -2383,7 +2383,7 @@ static int fastcgi_get_packet(server *srv, handler_ctx *hctx, fastcgi_response_p
|
|||
offset = sizeof(*header);
|
||||
|
||||
/* ->b should only be the content */
|
||||
buffer_copy_string(packet->b, ""); /* used == 1 */
|
||||
buffer_copy_string_len(packet->b, CONST_STR_LEN("")); /* used == 1 */
|
||||
|
||||
if (packet->len) {
|
||||
/* copy the content */
|
||||
|
@ -2815,7 +2815,7 @@ static handler_t fcgi_write_request(server *srv, handler_ctx *hctx) {
|
|||
hctx->proc->state = PROC_STATE_DIED;
|
||||
|
||||
fastcgi_status_copy_procname(p->statuskey, hctx->host, hctx->proc);
|
||||
buffer_append_string(p->statuskey, ".died");
|
||||
buffer_append_string_len(p->statuskey, CONST_STR_LEN(".died"));
|
||||
|
||||
status_counter_inc(srv, CONST_BUF_LEN(p->statuskey));
|
||||
|