| CODENOTIFIER | HelpYou are not signed inSign in |
Project: lighttpd
Revision: 2263
Author: stbuehler
Date: 31 Jul 2008 12:45:21
Changes: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))
| ... | ...@@ -111,11 +111,11 @@ | |
| 111 | 111 | "GE"); |
| 112 | 112 | |
| 113 | 113 | b = chunkqueue_get_append_buffer(cq); |
| 114 | buffer_copy_string(b, "T "); | |
| 114 | buffer_copy_string_len(b, CONST_STR_LEN("T ")); | |
| 115 | 115 | b = chunkqueue_get_append_buffer(cq); |
| 116 | buffer_copy_string(b, "/foo"); | |
| 116 | buffer_copy_string_len(b, CONST_STR_LEN("/foo")); | |
| 117 | 117 | b = chunkqueue_get_append_buffer(cq); |
| 118 | buffer_copy_string(b, "bar HTTP/1.0\r"); | |
| 118 | buffer_copy_string_len(b, CONST_STR_LEN("bar HTTP/1.0\r")); | |
| 119 | 119 | |
| 120 | 120 | b = chunkqueue_get_append_buffer(cq); |
| 121 | 121 | buffer_copy_string(b, "\n" |
| ... | ...@@ -162,33 +162,33 @@ | |
| 162 | 162 | * */ |
| 163 | 163 | |
| 164 | 164 | if (!buffer_is_empty(s->core->hostname)) { |
| 165 | BUFFER_APPEND_STRING_CONST(s->conninfo, "host="); | |
| 165 | buffer_append_string_len(s->conninfo, CONST_STR_LEN("host=")); | |
| 166 | 166 | buffer_append_string_buffer(s->conninfo, s->core->hostname); |
| 167 | 167 | if (s->core->port) { |
| 168 | BUFFER_APPEND_STRING_CONST(s->conninfo, " "); | |
| 169 | BUFFER_APPEND_STRING_CONST(s->conninfo, "port="); | |
| 168 | buffer_append_string_len(s->conninfo, CONST_STR_LEN(" ")); | |
| 169 | buffer_append_string_len(s->conninfo, CONST_STR_LEN("port=")); | |
| 170 | 170 | buffer_append_long(s->conninfo, s->core->port); |
| 171 | 171 | } |
| 172 | 172 | } else if (!buffer_is_empty(s->core->sock)) { |
| 173 | BUFFER_APPEND_STRING_CONST(s->conninfo, "host="); | |
| 173 | buffer_append_string_len(s->conninfo, CONST_STR_LEN("host=")); | |
| 174 | 174 | buffer_append_string_buffer(s->conninfo, s->core->sock); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | if (!buffer_is_empty(s->core->db)) { |
| 178 | if (!buffer_is_empty(s->conninfo)) BUFFER_APPEND_STRING_CONST(s->conninfo, " "); | |
| 179 | BUFFER_APPEND_STRING_CONST(s->conninfo, "dbname="); | |
| 178 | if (!buffer_is_empty(s->conninfo)) buffer_append_string_len(s->conninfo, CONST_STR_LEN(" ")); | |
| 179 | buffer_append_string_len(s->conninfo, CONST_STR_LEN("dbname=")); | |
| 180 | 180 | buffer_append_string_buffer(s->conninfo, s->core->db); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | if (!buffer_is_empty(s->core->user)) { |
| 184 | if (!buffer_is_empty(s->conninfo)) BUFFER_APPEND_STRING_CONST(s->conninfo, " "); | |
| 185 | BUFFER_APPEND_STRING_CONST(s->conninfo, "user="); | |
| 184 | if (!buffer_is_empty(s->conninfo)) buffer_append_string_len(s->conninfo, CONST_STR_LEN(" ")); | |
| 185 | buffer_append_string_len(s->conninfo, CONST_STR_LEN("user=")); | |
| 186 | 186 | buffer_append_string_buffer(s->conninfo, s->core->user); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | if (!buffer_is_empty(s->core->pass)) { |
| 190 | if (!buffer_is_empty(s->conninfo)) BUFFER_APPEND_STRING_CONST(s->conninfo, " "); | |
| 191 | BUFFER_APPEND_STRING_CONST(s->conninfo, "password="); | |
| 190 | if (!buffer_is_empty(s->conninfo)) buffer_append_string_len(s->conninfo, CONST_STR_LEN(" ")); | |
| 191 | buffer_append_string_len(s->conninfo, CONST_STR_LEN("password=")); | |
| 192 | 192 | buffer_append_string_buffer(s->conninfo, s->core->pass); |
| 193 | 193 | } |
| 194 | 194 | |
| ... | ...@@ -353,7 +353,7 @@ | |
| 353 | 353 | |
| 354 | 354 | ds = data_string_init(); |
| 355 | 355 | |
| 356 | buffer_copy_string(ds->value, CORE_PLUGIN); | |
| 356 | buffer_copy_string_len(ds->value, CONST_STR_LEN(CORE_PLUGIN)); | |
| 357 | 357 | array_insert_unique(p->required_plugins, (data_unset *)ds); |
| 358 | 358 | |
| 359 | 359 | return 0; |
| ... | ...@@ -250,7 +250,7 @@ | |
| 250 | 250 | buffer_reset(p->tmp_buf); |
| 251 | 251 | |
| 252 | 252 | if (0 != strcasecmp(ds->key->ptr, "CONTENT-TYPE")) { |
| 253 | BUFFER_COPY_STRING_CONST(p->tmp_buf, "HTTP_"); | |
| 253 | buffer_copy_string_len(p->tmp_buf, CONST_STR_LEN("HTTP_")); | |
| 254 | 254 | p->tmp_buf->used--; |
| 255 | 255 | } |
| 256 | 256 | |
| ... | ...@@ -805,7 +805,7 @@ | |
| 805 | 805 | p->data = NULL; |
| 806 | 806 | |
| 807 | 807 | ds = data_string_init(); |
| 808 | buffer_copy_string(ds->value, CORE_PLUGIN); | |
| 808 | buffer_copy_string_len(ds->value, CONST_STR_LEN(CORE_PLUGIN)); | |
| 809 | 809 | array_insert_unique(p->required_plugins, (data_unset *)ds); |
| 810 | 810 | |
| 811 | 811 | return 0; |
| ... | ...@@ -722,7 +722,7 @@ | |
| 722 | 722 | if (NULL == (ds = (data_string *)array_get_unused_element(con->request.headers, TYPE_STRING))) { |
| 723 | 723 | ds = data_response_init(); |
| 724 | 724 | } |
| 725 | buffer_copy_string(ds->key, "Host"); | |
| 725 | buffer_copy_string_len(ds->key, CONST_STR_LEN("Host")); | |
| 726 | 726 | buffer_copy_string_buffer(ds->value, header->value); |
| 727 | 727 | array_insert_unique(con->request.headers, (data_unset *)ds); |
| 728 | 728 | } |
| ... | ...@@ -623,7 +623,7 @@ | |
| 623 | 623 | b = buffer_init(); |
| 624 | 624 | |
| 625 | 625 | buffer_copy_string_buffer(b, srv->srvconf.bindhost); |
| 626 | buffer_append_string(b, ":"); | |
| 626 | buffer_append_string_len(b, CONST_STR_LEN(":")); | |
| 627 | 627 | buffer_append_long(b, srv->srvconf.port); |
| 628 | 628 | |
| 629 | 629 | if (0 != network_server_init(srv, b, srv->config_storage[0])) { |
| ... | ...@@ -343,7 +343,7 @@ | |
| 343 | 343 | response_header_overwrite(srv, con, CONST_STR_LEN("Expires"), CONST_BUF_LEN(p->expire_tstmp)); |
| 344 | 344 | |
| 345 | 345 | /* HTTP/1.1 */ |
| 346 | buffer_copy_string(p->expire_tstmp, "max-age="); | |
| 346 | buffer_copy_string_len(p->expire_tstmp, CONST_STR_LEN("max-age=")); | |
| 347 | 347 | buffer_append_long(p->expire_tstmp, ts); |
| 348 | 348 | |
| 349 | 349 | response_header_overwrite(srv, con, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(p->expire_tstmp)); |
| ... | ...@@ -218,7 +218,7 @@ | |
| 218 | 218 | buffer_reset(p->tmp_buf); |
| 219 | 219 | |
| 220 | 220 | if (0 != strcasecmp(ds->key->ptr, "CONTENT-TYPE")) { |
| 221 | BUFFER_COPY_STRING_CONST(p->tmp_buf, "HTTP_"); | |
| 221 | buffer_copy_string_len(p->tmp_buf, CONST_STR_LEN("HTTP_")); | |
| 222 | 222 | p->tmp_buf->used--; |
| 223 | 223 | } |
| 224 | 224 | |
| ... | ...@@ -460,7 +460,7 @@ | |
| 460 | 460 | p->data = NULL; |
| 461 | 461 | |
| 462 | 462 | ds = data_string_init(); |
| 463 | buffer_copy_string(ds->value, CORE_PLUGIN); | |
| 463 | buffer_copy_string_len(ds->value, CONST_STR_LEN(CORE_PLUGIN)); | |
| 464 | 464 | array_insert_unique(p->required_plugins, (data_unset *)ds); |
| 465 | 465 | |
| 466 | 466 | return 0; |
| ... | ...@@ -182,7 +182,7 @@ | |
| 182 | 182 | a->name->ptr[0] = '['; |
| 183 | 183 | inet_ntop(cur->ai_family, &(a->addr.ipv6.sin6_addr), a->name->ptr + 1, a->name->size - 2); |
| 184 | 184 | a->name->used = strlen(a->name->ptr) + 1; |
| 185 | buffer_append_string(a->name, "]:"); | |
| 185 | buffer_append_string_len(a->name, CONST_STR_LEN("]:")); | |
| 186 | 186 | buffer_append_long(a->name, ntohs(a->addr.ipv6.sin6_port)); |
| 187 | 187 | break; |
| 188 | 188 | #endif |
| ... | ...@@ -190,7 +190,7 @@ | |
| 190 | 190 | inet_ntop(cur->ai_family, &(a->addr.ipv4.sin_addr), a->name->ptr, a->name->size - 1); |
| 191 | 191 | a->name->used = strlen(a->name->ptr) + 1; |
| 192 | 192 | |
| 193 | buffer_append_string(a->name, ":"); | |
| 193 | buffer_append_string_len(a->name, CONST_STR_LEN(":")); | |
| 194 | 194 | buffer_append_long(a->name, ntohs(a->addr.ipv4.sin_port)); |
| 195 | 195 | break; |
| 196 | 196 | default: |
| ... | ...@@ -175,7 +175,7 @@ | |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | if (0 != strcasecmp(ds->key->ptr, "CONTENT-TYPE")) { |
| 178 | buffer_copy_string(srv->tmp_buf, "HTTP_"); | |
| 178 | buffer_copy_string_len(srv->tmp_buf, CONST_STR_LEN("HTTP_")); | |
| 179 | 179 | srv->tmp_buf->used--; |
| 180 | 180 | } |
| 181 | 181 | |
| ... | ...@@ -417,7 +417,7 @@ | |
| 417 | 417 | |
| 418 | 418 | b = chunkqueue_get_append_buffer(con->send); |
| 419 | 419 | if (0 == strftime(buf, sizeof(buf), p->timefmt->ptr, localtime(&t))) { |
| 420 | buffer_copy_string(b, "(none)"); | |
| 420 | buffer_copy_string_len(b, CONST_STR_LEN("(none)")); | |
| 421 | 421 | } else { |
| 422 | 422 | buffer_copy_string(b, buf); |
| 423 | 423 | } |
| ... | ...@@ -428,7 +428,7 @@ | |
| 428 | 428 | |
| 429 | 429 | b = chunkqueue_get_append_buffer(con->send); |
| 430 | 430 | if (0 == strftime(buf, sizeof(buf), p->timefmt->ptr, localtime(&t))) { |
| 431 | buffer_copy_string(b, "(none)"); | |
| 431 | buffer_copy_string_len(b, CONST_STR_LEN("(none)")); | |
| 432 | 432 | } else { |
| 433 | 433 | buffer_copy_string(b, buf); |
| 434 | 434 | } |
| ... | ...@@ -439,7 +439,7 @@ | |
| 439 | 439 | |
| 440 | 440 | b = chunkqueue_get_append_buffer(con->send); |
| 441 | 441 | if (0 == strftime(buf, sizeof(buf), p->timefmt->ptr, gmtime(&t))) { |
| 442 | buffer_copy_string(b, "(none)"); | |
| 442 | buffer_copy_string_len(b, CONST_STR_LEN("(none)")); | |
| 443 | 443 | } else { |
| 444 | 444 | buffer_copy_string(b, buf); |
| 445 | 445 | } |
| ... | ...@@ -470,7 +470,7 @@ | |
| 470 | 470 | if (NULL != (ds = (data_string *)array_get_element(p->ssi_cgi_env, var_val, strlen(var_val)))) { |
| 471 | 471 | buffer_copy_string_buffer(b, ds->value); |
| 472 | 472 | } else { |
| 473 | buffer_copy_string(b, "(none)"); | |
| 473 | buffer_copy_string_len(b, CONST_STR_LEN("(none)")); | |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | break; |
| ... | ...@@ -517,7 +517,7 @@ | |
| 517 | 517 | if (file_path) { |
| 518 | 518 | /* current doc-root */ |
| 519 | 519 | if (NULL == (sl = strrchr(con->physical.path->ptr, '/'))) { |
| 520 | buffer_copy_string(p->stat_fn, "/"); | |
| 520 | buffer_copy_string_len(p->stat_fn, CONST_STR_LEN("/")); | |
| 521 | 521 | } else { |
| 522 | 522 | buffer_copy_string_len(p->stat_fn, con->physical.path->ptr, sl - con->physical.path->ptr + 1); |
| 523 | 523 | } |
| ... | ...@@ -571,7 +571,7 @@ | |
| 571 | 571 | case SSI_FLASTMOD: |
| 572 | 572 | b = chunkqueue_get_append_buffer(con->send); |
| 573 | 573 | if (0 == strftime(buf, sizeof(buf), p->timefmt->ptr, localtime(&t))) { |
| 574 | buffer_copy_string(b, "(none)"); | |
| 574 | buffer_copy_string_len(b, CONST_STR_LEN("(none)")); | |
| 575 | 575 | } else { |
| 576 | 576 | buffer_copy_string(b, buf); |
| 577 | 577 | } |
| ... | ...@@ -649,17 +649,17 @@ | |
| 649 | 649 | if (p->if_is_false) break; |
| 650 | 650 | |
| 651 | 651 | b = chunkqueue_get_append_buffer(con->send); |
| 652 | buffer_copy_string(b, "<pre>"); | |
| 652 | buffer_copy_string_len(b, CONST_STR_LEN("<pre>")); | |
| 653 | 653 | for (i = 0; i < p->ssi_vars->used; i++) { |
| 654 | 654 | data_string *ds = (data_string *)p->ssi_vars->data[p->ssi_vars->sorted[i]]; |
| 655 | 655 | |
| 656 | 656 | buffer_append_string_buffer(b, ds->key); |
| 657 | buffer_append_string(b, ": "); | |
| 657 | buffer_append_string_len(b, CONST_STR_LEN(": ")); | |
| 658 | 658 | buffer_append_string_buffer(b, ds->value); |
| 659 | buffer_append_string(b, "<br />"); | |
| 659 | buffer_append_string_len(b, CONST_STR_LEN("<br />")); | |
| 660 | 660 | |
| 661 | 661 | } |
| 662 | buffer_append_string(b, "</pre>"); | |
| 662 | buffer_append_string_len(b, CONST_STR_LEN("</pre>")); | |
| 663 | 663 | |
| 664 | 664 | break; |
| 665 | 665 | case SSI_EXEC: { |
| ... | ...@@ -901,7 +901,7 @@ | |
| 901 | 901 | |
| 902 | 902 | array_reset(p->ssi_vars); |
| 903 | 903 | array_reset(p->ssi_cgi_env); |
| 904 | buffer_copy_string(p->timefmt, "%a, %d %b %Y %H:%M:%S %Z"); | |
| 904 | buffer_copy_string_len(p->timefmt, CONST_STR_LEN("%a, %d %b %Y %H:%M:%S %Z")); | |
| 905 | 905 | p->sizefmt = 0; |
| 906 | 906 | build_ssi_cgi_vars(srv, con, p); |
| 907 | 907 | p->if_is_false = 0; |
| ... | ...@@ -115,9 +115,9 @@ | |
| 115 | 115 | o = buffer_init(); |
| 116 | 116 | |
| 117 | 117 | if (con->conf.is_ssl) { |
| 118 | buffer_copy_string(o, "https://"); | |
| 118 | buffer_copy_string_len(o, CONST_STR_LEN("https://")); | |
| 119 | 119 | } else { |
| 120 | buffer_copy_string(o, "http://"); | |
| 120 | buffer_copy_string_len(o, CONST_STR_LEN("http://")); | |
| 121 | 121 | } |
| 122 | 122 | if (con->uri.authority->used) { |
| 123 | 123 | buffer_append_string_buffer(o, con->uri.authority); |
| ... | ...@@ -183,14 +183,14 @@ | |
| 183 | 183 | |
| 184 | 184 | if (!((con->conf.is_ssl == 0 && srv->srvconf.port == 80) || |
| 185 | 185 | (con->conf.is_ssl == 1 && srv->srvconf.port == 443))) { |
| 186 | buffer_append_string(o, ":"); | |
| 186 | buffer_append_string_len(o, CONST_STR_LEN(":")); | |
| 187 | 187 | buffer_append_long(o, srv->srvconf.port); |
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | 190 | buffer_append_string_buffer(o, con->uri.path); |
| 191 | buffer_append_string(o, "/"); | |
| 191 | buffer_append_string_len(o, CONST_STR_LEN("/")); | |
| 192 | 192 | if (!buffer_is_empty(con->uri.query)) { |
| 193 | buffer_append_string(o, "?"); | |
| 193 | buffer_append_string_len(o, CONST_STR_LEN("?")); | |
| 194 | 194 | buffer_append_string_buffer(o, con->uri.query); |
| 195 | 195 | } |
| 196 | 196 |
| ... | ...@@ -15,49 +15,49 @@ | |
| 15 | 15 | log_init(); |
| 16 | 16 | plan_tests(7); |
| 17 | 17 | |
| 18 | buffer_copy_string(b, "bytes=0-0"); | |
| 18 | buffer_copy_string_len(b, CONST_STR_LEN("bytes=0-0")); | |
| 19 | 19 | ok(PARSE_SUCCESS == http_request_range_parse(b, ranges), "0-0"); |
| 20 | 20 | for (r = ranges; r; r = r->next) { |
| 21 | 21 | diag(".. %jd - %jd", (intmax_t) r->start, (intmax_t) r->end); |
| 22 | 22 | } |
| 23 | 23 | http_request_range_reset(ranges); |
| 24 | 24 | |
| 25 | buffer_copy_string(b, "bytes=1-2,3-4"); | |
| 25 | buffer_copy_string_len(b, CONST_STR_LEN("bytes=1-2,3-4")); | |
| 26 | 26 | ok(PARSE_SUCCESS == http_request_range_parse(b, ranges), "1-2,3-4"); |
| 27 | 27 | for (r = ranges; r; r = r->next) { |
| 28 | 28 | diag(".. %jd - %jd", (intmax_t) r->start, (intmax_t) r->end); |
| 29 | 29 | } |
| 30 | 30 | http_request_range_reset(ranges); |
| 31 | 31 | |
| 32 | buffer_copy_string(b, "bytes=-0"); | |
| 32 | buffer_copy_string_len(b, CONST_STR_LEN("bytes=-0")); | |
| 33 | 33 | ok(PARSE_SUCCESS == http_request_range_parse(b, ranges), "-0"); |
| 34 | 34 | for (r = ranges; r; r = r->next) { |
| 35 | 35 | diag(".. %jd - %jd", (intmax_t) r->start, (intmax_t) r->end); |
| 36 | 36 | } |
| 37 | 37 | http_request_range_reset(ranges); |
| 38 | 38 | |
| 39 | buffer_copy_string(b, "bytes=0-"); | |
| 39 | buffer_copy_string_len(b, CONST_STR_LEN("bytes=0-")); | |
| 40 | 40 | ok(PARSE_SUCCESS == http_request_range_parse(b, ranges), "0-"); |
| 41 | 41 | for (r = ranges; r; r = r->next) { |
| 42 | 42 | diag(".. %jd - %jd", (intmax_t) r->start, (intmax_t) r->end); |
| 43 | 43 | } |
| 44 | 44 | http_request_range_reset(ranges); |
| 45 | 45 | |
| 46 | buffer_copy_string(b, "bytes=0-0,0-"); | |
| 46 | buffer_copy_string_len(b, CONST_STR_LEN("bytes=0-0,0-")); | |
| 47 | 47 | ok(PARSE_SUCCESS == http_request_range_parse(b, ranges), "0-0,0-"); |
| 48 | 48 | for (r = ranges; r; r = r->next) { |
| 49 | 49 | diag(".. %jd - %jd", (intmax_t) r->start, (intmax_t) r->end); |
| 50 | 50 | } |
| 51 | 51 | http_request_range_reset(ranges); |
| 52 | 52 | |
| 53 | buffer_copy_string(b, "bytes=0-0,-0"); | |
| 53 | buffer_copy_string_len(b, CONST_STR_LEN("bytes=0-0,-0")); | |
| 54 | 54 | ok(PARSE_SUCCESS == http_request_range_parse(b, ranges), "0-0,-0"); |
| 55 | 55 | for (r = ranges; r; r = r->next) { |
| 56 | 56 | diag(".. %jd - %jd", (intmax_t) r->start, (intmax_t) r->end); |
| 57 | 57 | } |
| 58 | 58 | http_request_range_reset(ranges); |
| 59 | 59 | |
| 60 | buffer_copy_string(b, "bytes=1-2,3-4,5-"); | |
| 60 | buffer_copy_string_len(b, CONST_STR_LEN("bytes=1-2,3-4,5-")); | |
| 61 | 61 | ok(PARSE_SUCCESS == http_request_range_parse(b, ranges), "1-2,3-4,5-"); |
| 62 | 62 | for (r = ranges; r; r = r->next) { |
| 63 | 63 | diag(".. %jd - %jd", (intmax_t) r->start, (intmax_t) r->end); |
| ... | ...@@ -419,7 +419,7 @@ | |
| 419 | 419 | if (i == 0 && buffer_is_empty(s->format)) { |
| 420 | 420 | /* set a default logfile string */ |
| 421 | 421 | |
| 422 | buffer_copy_string(s->format, "%h %V %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""); | |
| 422 | buffer_copy_string_len(s->format, CONST_STR_LEN("%h %V %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"")); | |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | /* parse */ |
| ... | ...@@ -630,7 +630,7 @@ | |
| 630 | 630 | |
| 631 | 631 | b = p->conf.access_logbuffer; |
| 632 | 632 | if (b->used == 0) { |
| 633 | buffer_copy_string(b, ""); | |
| 633 | buffer_copy_string_len(b, CONST_STR_LEN("")); | |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | for (j = 0; j < p->conf.parsed_format->used; j++) { |
| ... | ...@@ -666,12 +666,12 @@ | |
| 666 | 666 | min = (scd % 3600) / 60; |
| 667 | 667 | |
| 668 | 668 | /* hours */ |
| 669 | if (hrs < 10) buffer_append_string(p->conf.ts_accesslog_str, "0"); | |
| 669 | if (hrs < 10) buffer_append_string_len(p->conf.ts_accesslog_str, CONST_STR_LEN("0")); | |
| 670 | 670 | buffer_append_long(p->conf.ts_accesslog_str, hrs); |
| 671 | 671 | |
| 672 | if (min < 10) buffer_append_string(p->conf.ts_accesslog_str, "0"); | |
| 672 | if (min < 10) buffer_append_string_len(p->conf.ts_accesslog_str, CONST_STR_LEN("0")); | |
| 673 | 673 | buffer_append_long(p->conf.ts_accesslog_str, min); |
| 674 | BUFFER_APPEND_STRING_CONST(p->conf.ts_accesslog_str, "]"); | |
| 674 | buffer_append_string_len(p->conf.ts_accesslog_str, CONST_STR_LEN("]")); | |
| 675 | 675 | #else |
| 676 | 676 | #ifdef HAVE_GMTIME_R |
| 677 | 677 | gmtime_r(&(srv->cur_ts), &tm); |
| ... | ...@@ -698,20 +698,20 @@ | |
| 698 | 698 | break; |
| 699 | 699 | case FORMAT_REMOTE_IDENT: |
| 700 | 700 | /* ident */ |
| 701 | BUFFER_APPEND_STRING_CONST(b, "-"); | |
| 701 | buffer_append_string_len(b, CONST_STR_LEN("-")); | |
| 702 | 702 | break; |
| 703 | 703 | case FORMAT_REMOTE_USER: |
| 704 | 704 | if (con->authed_user->used > 1) { |
| 705 | 705 | buffer_append_string_buffer(b, con->authed_user); |
| 706 | 706 | } else { |
| 707 | BUFFER_APPEND_STRING_CONST(b, "-"); | |
| 707 | buffer_append_string_len(b, CONST_STR_LEN("-")); | |
| 708 | 708 | } |
| 709 | 709 | break; |
| 710 | 710 | case FORMAT_REQUEST_LINE: |
| 711 | 711 | buffer_append_string(b, get_http_method_name(con->request.http_method)); |
| 712 | buffer_append_string(b, " "); | |
| 712 | buffer_append_string_len(b, CONST_STR_LEN(" ")); | |
| 713 | 713 | buffer_append_string_buffer(b, con->request.orig_uri); |
| 714 | buffer_append_string(b, " "); | |
| 714 | buffer_append_string_len(b, CONST_STR_LEN(" ")); | |
| 715 | 715 | buffer_append_string(b, get_http_version_name(con->request.http_version)); |
| 716 | 716 | |
| 717 | 717 | break; |
| ... | ...@@ -724,42 +724,42 @@ | |
| 724 | 724 | buffer_append_off_t(b, |
| 725 | 725 | con->bytes_written - con->bytes_header <= 0 ? 0 : con->bytes_written - con->bytes_header); |
| 726 | 726 | } else { |
| 727 | BUFFER_APPEND_STRING_CONST(b, "-"); | |
| 727 | buffer_append_string_len(b, CONST_STR_LEN("-")); | |
| 728 | 728 | } |
| 729 | 729 | break; |
| 730 | 730 | case FORMAT_HEADER: |
| 731 | 731 | if (NULL != (ds = (data_string *)array_get_element(con->request.headers, CONST_BUF_LEN(p->conf.parsed_format->ptr[j]->string)))) { |
| 732 | 732 | buffer_append_string_buffer(b, ds->value); |
| 733 | 733 | } else { |
| 734 | BUFFER_APPEND_STRING_CONST(b, "-"); | |
| 734 | buffer_append_string_len(b, CONST_STR_LEN("-")); | |
| 735 | 735 | } |
| 736 | 736 | break; |
| 737 | 737 | case FORMAT_RESPONSE_HEADER: |
| 738 | 738 | if (NULL != (ds = (data_string *)array_get_element(con->response.headers, CONST_BUF_LEN(p->conf.parsed_format->ptr[j]->string)))) { |
| 739 | 739 | buffer_append_string_buffer(b, ds->value); |
| 740 | 740 | } else { |
| 741 | BUFFER_APPEND_STRING_CONST(b, "-"); | |
| 741 | buffer_append_string_len(b, CONST_STR_LEN("-")); | |
| 742 | 742 | } |
| 743 | 743 | break; |
| 744 | 744 | case FORMAT_FILENAME: |
| 745 | 745 | if (con->physical.path->used > 1) { |
| 746 | 746 | buffer_append_string_buffer(b, con->physical.path); |
| 747 | 747 | } else { |
| 748 | BUFFER_APPEND_STRING_CONST(b, "-"); | |
| 748 | buffer_append_string_len(b, CONST_STR_LEN("-")); | |
| 749 | 749 | } |
| 750 | 750 | break; |
| 751 | 751 | case FORMAT_BYTES_OUT: |
| 752 | 752 | if (con->bytes_written > 0) { |
| 753 | 753 | buffer_append_off_t(b, con->bytes_written); |
| 754 | 754 | } else { |
| 755 | BUFFER_APPEND_STRING_CONST(b, "-"); | |
| 755 | buffer_append_string_len(b, CONST_STR_LEN("-")); | |
| 756 | 756 | } |
| 757 | 757 | break; |
| 758 | 758 | case FORMAT_BYTES_IN: |
| 759 | 759 | if (con->bytes_read > 0) { |
| 760 | 760 | buffer_append_off_t(b, con->bytes_read); |
| 761 | 761 | } else { |
| 762 | BUFFER_APPEND_STRING_CONST(b, "-"); | |
| 762 | buffer_append_string_len(b, CONST_STR_LEN("-")); | |
| 763 | 763 | } |
| 764 | 764 | break; |
| 765 | 765 | case FORMAT_TIME_USED: |
| ... | ...@@ -769,14 +769,14 @@ | |
| 769 | 769 | if (con->server_name->used > 1) { |
| 770 | 770 | buffer_append_string_buffer(b, con->server_name); |
| 771 | 771 | } else { |
| 772 | BUFFER_APPEND_STRING_CONST(b, "-"); | |
| 772 | buffer_append_string_len(b, CONST_STR_LEN("-")); | |
| 773 | 773 | } |
| 774 | 774 | break; |
| 775 | 775 | case FORMAT_HTTP_HOST: |
| 776 | 776 | if (con->uri.authority->used > 1) { |
| 777 | 777 | buffer_append_string_buffer(b, con->uri.authority); |
| 778 | 778 | } else { |
| 779 | BUFFER_APPEND_STRING_CONST(b, "-"); | |
| 779 | buffer_append_string_len(b, CONST_STR_LEN("-")); | |
| 780 | 780 | } |
| 781 | 781 | break; |
| 782 | 782 | case FORMAT_REQUEST_PROTOCOL: |
| ... | ...@@ -797,8 +797,8 @@ | |
| 797 | 797 | break; |
| 798 | 798 | case FORMAT_CONNECTION_STATUS: |
| 799 | 799 | switch(con->keep_alive) { |
| 800 | case 0: buffer_append_string(b, "-"); break; | |
| 801 | default: buffer_append_string(b, "+"); break; | |
| 800 | case 0: buffer_append_string_len(b, CONST_STR_LEN("-")); break; | |
| 801 | default: buffer_append_string_len(b, CONST_STR_LEN("+")); break; | |
| 802 | 802 | } |
| 803 | 803 | break; |
| 804 | 804 | default: |
| ... | ...@@ -818,7 +818,7 @@ | |
| 818 | 818 | } |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | BUFFER_APPEND_STRING_CONST(b, "\n"); | |
| 821 | buffer_append_string_len(b, CONST_STR_LEN("\n")); | |
| 822 | 822 | |
| 823 | 823 | if (p->conf.use_syslog || /* syslog doesn't cache */ |
| 824 | 824 | (p->conf.access_logfile->used && p->conf.access_logfile->ptr[0] != '|') || /* pipes don't cache */ |
| ... | ...@@ -1241,7 +1241,7 @@ | |
| 1241 | 1241 | if (NULL != (ds = (data_string *)array_get_element(con->response.headers, CONST_STR_LEN("Vary")))) { |
| 1242 | 1242 | /* append Accept-Encoding to Vary header */ |
| 1243 | 1243 | if (NULL == strstr(ds->value->ptr, "Accept-Encoding")) { |
| 1244 | buffer_append_string(ds->value, ",Accept-Encoding"); | |
| 1244 | buffer_append_string_len(ds->value, CONST_STR_LEN(",Accept-Encoding")); | |
| 1245 | 1245 | if (p->conf.debug) { |
| 1246 | 1246 | TRACE("appending ,Accept-Encoding for '%s'", SAFE_BUF_STR(con->uri.path)); |
| 1247 | 1247 | } |
| ... | ...@@ -503,23 +503,23 @@ | |
| 503 | 503 | UNUSED(con); |
| 504 | 504 | |
| 505 | 505 | if (value) { |
| 506 | buffer_append_string(b,"<"); | |
| 506 | buffer_append_string_len(b,CONST_STR_LEN("<")); | |
| 507 | 507 | buffer_append_string(b, prop_name); |
| 508 | buffer_append_string(b, " xmlns=\""); | |
| 508 | buffer_append_string_len(b, CONST_STR_LEN(" xmlns=\"")); | |
| 509 | 509 | buffer_append_string(b, prop_ns); |
| 510 | buffer_append_string(b, "\">"); | |
| 510 | buffer_append_string_len(b, CONST_STR_LEN("\">")); | |
| 511 | 511 | |
| 512 | 512 | buffer_append_string(b, value); |
| 513 | 513 | |
| 514 | buffer_append_string(b,"</"); | |
| 514 | buffer_append_string_len(b,CONST_STR_LEN("</")); | |
| 515 | 515 | buffer_append_string(b, prop_name); |
| 516 | buffer_append_string(b, ">"); | |
| 516 | buffer_append_string_len(b, CONST_STR_LEN(">")); | |
| 517 | 517 | } else { |
| 518 | buffer_append_string(b,"<"); | |
| 518 | buffer_append_string_len(b,CONST_STR_LEN("<")); | |
| 519 | 519 | buffer_append_string(b, prop_name); |
| 520 | buffer_append_string(b, " xmlns=\""); | |
| 520 | buffer_append_string_len(b, CONST_STR_LEN(" xmlns=\"")); | |
| 521 | 521 | buffer_append_string(b, prop_ns); |
| 522 | buffer_append_string(b, "\"/>"); | |
| 522 | buffer_append_string_len(b, CONST_STR_LEN("\"/>")); | |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | return 0; |
| ... | ...@@ -529,24 +529,24 @@ | |
| 529 | 529 | static int webdav_gen_response_status_tag(server *srv, connection *con, physical *dst, int status, buffer *b) { |
| 530 | 530 | UNUSED(srv); |
| 531 | 531 | |
| 532 | buffer_append_string(b,"<D:response xmlns:ns0=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\">\n"); | |
| 532 | buffer_append_string_len(b,CONST_STR_LEN("<D:response xmlns:ns0=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\">\n")); | |
| 533 | 533 | |
| 534 | buffer_append_string(b,"<D:href>\n"); | |
| 534 | buffer_append_string_len(b,CONST_STR_LEN("<D:href>\n")); | |
| 535 | 535 | buffer_append_string_buffer(b, dst->rel_path); |
| 536 | buffer_append_string(b,"</D:href>\n"); | |
| 537 | buffer_append_string(b,"<D:status>\n"); | |
| 536 | buffer_append_string_len(b,CONST_STR_LEN("</D:href>\n")); | |
| 537 | buffer_append_string_len(b,CONST_STR_LEN("<D:status>\n")); | |
| 538 | 538 | |
| 539 | 539 | if (con->request.http_version == HTTP_VERSION_1_1) { |
| 540 | BUFFER_COPY_STRING_CONST(b, "HTTP/1.1 "); | |
| 540 | buffer_copy_string_len(b, CONST_STR_LEN("HTTP/1.1 ")); | |
| 541 | 541 | } else { |
| 542 | BUFFER_COPY_STRING_CONST(b, "HTTP/1.0 "); | |
| 542 | buffer_copy_string_len(b, CONST_STR_LEN("HTTP/1.0 ")); | |
| 543 | 543 | } |
| 544 | 544 | buffer_append_long(b, status); |
| 545 | BUFFER_APPEND_STRING_CONST(b, " "); | |
| 545 | buffer_append_string_len(b, CONST_STR_LEN(" ")); | |
| 546 | 546 | buffer_append_string(b, get_http_status_name(status)); |
| 547 | 547 | |
| 548 | buffer_append_string(b,"</D:status>\n"); | |
| 549 | buffer_append_string(b,"</D:response>\n"); | |
| 548 | buffer_append_string_len(b,CONST_STR_LEN("</D:status>\n")); | |
| 549 | buffer_append_string_len(b,CONST_STR_LEN("</D:response>\n")); | |
| 550 | 550 | |
| 551 | 551 | return 0; |
| 552 | 552 | } |
| ... | ...@@ -862,12 +862,12 @@ | |
| 862 | 862 | |
| 863 | 863 | if (0 == strcmp(prop_name, "resourcetype")) { |
| 864 | 864 | if (S_ISDIR(sce->st.st_mode)) { |
| 865 | buffer_append_string(b, "<D:resourcetype><D:collection/></D:resourcetype>"); | |
| 865 | buffer_append_string_len(b, CONST_STR_LEN("<D:resourcetype><D:collection/></D:resourcetype>")); | |
| 866 | 866 | found = 1; |
| 867 | 867 | } |
| 868 | 868 | } else if (0 == strcmp(prop_name, "getcontenttype")) { |
| 869 | 869 | if (S_ISDIR(sce->st.st_mode)) { |
| 870 | buffer_append_string(b, "<D:getcontenttype>httpd/unix-directory</D:getcontenttype>"); | |
| 870 | buffer_append_string_len(b, CONST_STR_LEN("<D:getcontenttype>httpd/unix-directory</D:getcontenttype>")); | |
| 871 | 871 | found = 1; |
| 872 | 872 | } else if(S_ISREG(sce->st.st_mode)) { |
| 873 | 873 | for (k = 0; k < con->conf.mimetypes->used; k++) { |
| ... | ...@@ -876,9 +876,9 @@ | |
| 876 | 876 | if (ds->key->used == 0) continue; |
| 877 | 877 | |
| 878 | 878 | if (buffer_is_equal_right_len(dst->path, ds->key, ds->key->used - 1)) { |
| 879 | buffer_append_string(b,"<D:getcontenttype>"); | |
| 879 | buffer_append_string_len(b,CONST_STR_LEN("<D:getcontenttype>")); | |
| 880 | 880 | buffer_append_string_buffer(b, ds->value); |
| 881 | buffer_append_string(b, "</D:getcontenttype>"); | |
| 881 | buffer_append_string_len(b, CONST_STR_LEN("</D:getcontenttype>")); | |
| 882 | 882 | found = 1; |
| 883 | 883 | |
| 884 | 884 | break; |
| ... | ...@@ -886,26 +886,26 @@ | |
| 886 | 886 | } |
| 887 | 887 | } |
| 888 | 888 | } else if (0 == strcmp(prop_name, "creationdate")) { |
| 889 | buffer_append_string(b, "<D:creationdate ns0:dt=\"dateTime.tz\">"); | |
| 889 | buffer_append_string_len(b, CONST_STR_LEN("<D:creationdate ns0:dt=\"dateTime.tz\">")); | |
| 890 | 890 | strftime(ctime_buf, sizeof(ctime_buf), "%Y-%m-%dT%H:%M:%SZ", gmtime(&(sce->st.st_ctime))); |
| 891 | 891 | buffer_append_string(b, ctime_buf); |
| 892 | buffer_append_string(b, "</D:creationdate>"); | |
| 892 | buffer_append_string_len(b, CONST_STR_LEN("</D:creationdate>")); | |
| 893 | 893 | found = 1; |
| 894 | 894 | } else if (0 == strcmp(prop_name, "getlastmodified")) { |
| 895 | buffer_append_string(b,"<D:getlastmodified ns0:dt=\"dateTime.rfc1123\">"); | |
| 895 | buffer_append_string_len(b,CONST_STR_LEN("<D:getlastmodified ns0:dt=\"dateTime.rfc1123\">")); | |
| 896 | 896 | strftime(mtime_buf, sizeof(mtime_buf), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&(sce->st.st_mtime))); |
| 897 | 897 | buffer_append_string(b, mtime_buf); |
| 898 | buffer_append_string(b, "</D:getlastmodified>"); | |
| 898 | buffer_append_string_len(b, CONST_STR_LEN("</D:getlastmodified>")); | |
| 899 | 899 | found = 1; |
| 900 | 900 | } else if (0 == strcmp(prop_name, "getcontentlength")) { |
| 901 | buffer_append_string(b,"<D:getcontentlength>"); | |
| 901 | buffer_append_string_len(b,CONST_STR_LEN("<D:getcontentlength>")); | |
| 902 | 902 | buffer_append_off_t(b, sce->st.st_size); |
| 903 | buffer_append_string(b, "</D:getcontentlength>"); | |
| 903 | buffer_append_string_len(b, CONST_STR_LEN("</D:getcontentlength>")); | |
| 904 | 904 | found = 1; |
| 905 | 905 | } else if (0 == strcmp(prop_name, "getcontentlanguage")) { |
| 906 | buffer_append_string(b,"<D:getcontentlanguage>"); | |
| 907 | buffer_append_string(b, "en"); | |
| 908 | buffer_append_string(b, "</D:getcontentlanguage>"); | |
| 906 | buffer_append_string_len(b,CONST_STR_LEN("<D:getcontentlanguage>")); | |
| 907 | buffer_append_string_len(b, CONST_STR_LEN("en")); | |
| 908 | buffer_append_string_len(b, CONST_STR_LEN("</D:getcontentlanguage>")); | |
| 909 | 909 | found = 1; |
| 910 | 910 | } |
| 911 | 911 | } |
| ... | ...@@ -1124,44 +1124,44 @@ | |
| 1124 | 1124 | |
| 1125 | 1125 | b = chunkqueue_get_append_buffer(con->send); |
| 1126 | 1126 | |
| 1127 | buffer_copy_string(b, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); | |
| 1127 | buffer_copy_string_len(b, CONST_STR_LEN("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")); | |
| 1128 | 1128 | |
| 1129 | buffer_append_string(b,"<D:prop xmlns:D=\"DAV:\" xmlns:ns0=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\">\n"); | |
| 1130 | buffer_append_string(b,"<D:lockdiscovery>\n"); | |
| 1131 | buffer_append_string(b,"<D:activelock>\n"); | |
| 1129 | buffer_append_string_len(b,CONST_STR_LEN("<D:prop xmlns:D=\"DAV:\" xmlns:ns0=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\">\n")); | |
| 1130 | buffer_append_string_len(b,CONST_STR_LEN("<D:lockdiscovery>\n")); | |
| 1131 | buffer_append_string_len(b,CONST_STR_LEN("<D:activelock>\n")); | |
| 1132 | 1132 | |
| 1133 | buffer_append_string(b,"<D:lockscope>"); | |
| 1134 | buffer_append_string(b,"<D:"); | |
| 1133 | buffer_append_string_len(b,CONST_STR_LEN("<D:lockscope>")); | |
| 1134 | buffer_append_string_len(b,CONST_STR_LEN("<D:")); | |
| 1135 | 1135 | buffer_append_string(b, lockscope); |
| 1136 | buffer_append_string(b, "/>"); | |
| 1137 | buffer_append_string(b,"</D:lockscope>\n"); | |
| 1136 | buffer_append_string_len(b, CONST_STR_LEN("/>")); | |
| 1137 | buffer_append_string_len(b,CONST_STR_LEN("</D:lockscope>\n")); | |
| 1138 | 1138 | |
| 1139 | buffer_append_string(b,"<D:locktype>"); | |
| 1140 | buffer_append_string(b,"<D:"); | |
| 1139 | buffer_append_string_len(b,CONST_STR_LEN("<D:locktype>")); | |
| 1140 | buffer_append_string_len(b,CONST_STR_LEN("<D:")); | |
| 1141 | 1141 | buffer_append_string(b, locktype); |
| 1142 | buffer_append_string(b, "/>"); | |
| 1143 | buffer_append_string(b,"</D:locktype>\n"); | |
| 1142 | buffer_append_string_len(b, CONST_STR_LEN("/>")); | |
| 1143 | buffer_append_string_len(b,CONST_STR_LEN("</D:locktype>\n")); | |
| 1144 | 1144 | |
| 1145 | buffer_append_string(b,"<D:depth>"); | |
| 1145 | buffer_append_string_len(b,CONST_STR_LEN("<D:depth>")); | |
| 1146 | 1146 | buffer_append_string(b, depth == 0 ? "0" : "infinity"); |
| 1147 | buffer_append_string(b,"</D:depth>\n"); | |
| 1147 | buffer_append_string_len(b,CONST_STR_LEN("</D:depth>\n")); | |
| 1148 | 1148 | |
| 1149 | buffer_append_string(b,"<D:timeout>"); | |
| 1150 | buffer_append_string(b, "Second-600"); | |
| 1151 | buffer_append_string(b,"</D:timeout>\n"); | |
| 1149 | buffer_append_string_len(b,CONST_STR_LEN("<D:timeout>")); | |
| 1150 | buffer_append_string_len(b, CONST_STR_LEN("Second-600")); | |
| 1151 | buffer_append_string_len(b,CONST_STR_LEN("</D:timeout>\n")); | |
| 1152 | 1152 | |
| 1153 | buffer_append_string(b,"<D:owner>"); | |
| 1154 | buffer_append_string(b,"</D:owner>\n"); | |
| 1153 | buffer_append_string_len(b,CONST_STR_LEN("<D:owner>")); | |
| 1154 | buffer_append_string_len(b,CONST_STR_LEN("</D:owner>\n")); | |
| 1155 | 1155 | |
| 1156 | buffer_append_string(b,"<D:locktoken>"); | |
| 1157 | buffer_append_string(b, "<D:href>"); | |
| 1156 | buffer_append_string_len(b,CONST_STR_LEN("<D:locktoken>")); | |
| 1157 | buffer_append_string_len(b, CONST_STR_LEN("<D:href>")); | |
| 1158 | 1158 | buffer_append_string_buffer(b, locktoken); |
| 1159 | buffer_append_string(b, "</D:href>"); | |
| 1160 | buffer_append_string(b,"</D:locktoken>\n"); | |
| 1159 | buffer_append_string_len(b, CONST_STR_LEN("</D:href>")); | |
| 1160 | buffer_append_string_len(b,CONST_STR_LEN("</D:locktoken>\n")); | |
| 1161 | 1161 | |
| 1162 | buffer_append_string(b,"</D:activelock>\n"); | |
| 1163 | buffer_append_string(b,"</D:lockdiscovery>\n"); | |
| 1164 | buffer_append_string(b,"</D:prop>\n"); | |
| 1162 | buffer_append_string_len(b,CONST_STR_LEN("</D:activelock>\n")); | |
| 1163 | buffer_append_string_len(b,CONST_STR_LEN("</D:lockdiscovery>\n")); | |
| 1164 | buffer_append_string_len(b,CONST_STR_LEN("</D:prop>\n")); | |
| 1165 | 1165 | |
| 1166 | 1166 | return 0; |
| 1167 | 1167 | } |
| ... | ...@@ -1385,9 +1385,9 @@ | |
| 1385 | 1385 | |
| 1386 | 1386 | b = chunkqueue_get_append_buffer(con->send); |
| 1387 | 1387 | |
| 1388 | buffer_copy_string(b, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); | |
| 1388 | buffer_copy_string_len(b, CONST_STR_LEN("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")); | |
| 1389 | 1389 | |