summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Bühler <stbuehler@web.de>2015-02-08 19:10:46 +0000
committerStefan Bühler <stbuehler@web.de>2015-02-08 19:10:46 +0000
commit91a9a6b3910df8be3936ed0a70b0ac6cbdc10079 (patch)
tree4b5aecbe0e29aed0c8a1178215c11f73fb069a6c
parentad3e93ea96d1cbaab00d07245dbd02f790060f85 (diff)
downloadlighttpd-git-91a9a6b3910df8be3936ed0a70b0ac6cbdc10079.tar.gz
rename buffer_append_long_hex to buffer_append_uint_hex
* takes uintmax_t now * use in http_chunk_append_len From: Stefan Bühler <stbuehler@web.de> git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2980 152afb58-edef-0310-8abb-c4023f1b3aa9
-rw-r--r--src/buffer.c4
-rw-r--r--src/buffer.h2
-rw-r--r--src/http_chunk.c22
-rw-r--r--src/log.c4
4 files changed, 8 insertions, 24 deletions
diff --git a/src/buffer.c b/src/buffer.c
index d3437319..425d700e 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -234,12 +234,12 @@ void buffer_append_string_buffer(buffer *b, const buffer *src) {
}
}
-void buffer_append_long_hex(buffer *b, unsigned long value) {
+void buffer_append_uint_hex(buffer *b, uintmax_t value) {
char *buf;
int shift = 0;
{
- unsigned long copy = value;
+ uintmax_t copy = value;
do {
copy >>= 8;
shift += 2; /* counting nibbles (4 bits) */
diff --git a/src/buffer.h b/src/buffer.h
index e2ac778e..f5d02243 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -89,7 +89,7 @@ void buffer_append_string(buffer *b, const char *s);
void buffer_append_string_len(buffer *b, const char *s, size_t s_len);
void buffer_append_string_buffer(buffer *b, const buffer *src);
-void buffer_append_long_hex(buffer *b, unsigned long len);
+void buffer_append_uint_hex(buffer *b, uintmax_t len);
void buffer_append_int(buffer *b, intmax_t val);
void buffer_copy_int(buffer *b, intmax_t val);
diff --git a/src/http_chunk.c b/src/http_chunk.c
index 79e4586a..45db56c4 100644
--- a/src/http_chunk.c
+++ b/src/http_chunk.c
@@ -21,31 +21,15 @@
#include <string.h>
static void http_chunk_append_len(server *srv, connection *con, size_t len) {
- size_t i, olen = len, j;
buffer *b;
force_assert(NULL != srv);
b = srv->tmp_chunk_len;
- if (len == 0) {
- buffer_copy_string_len(b, CONST_STR_LEN("0\r\n"));
- } else {
- for (i = 0; i < 8 && len; i++) {
- len >>= 4;
- }
-
- /* i is the number of hex digits we have, + \r\n */
- buffer_string_prepare_copy(b, i + 2);
-
- for (j = i-1, len = olen; j+1 > 0; j--) {
- b->ptr[j] = (len & 0xf) + (((len & 0xf) <= 9) ? '0' : 'a' - 10);
- len >>= 4;
- }
- buffer_commit(b, i);
-
- buffer_append_string_len(b, CONST_STR_LEN("\r\n"));
- }
+ buffer_string_set_length(b, 0);
+ buffer_append_uint_hex(b, len);
+ buffer_append_string_len(b, CONST_STR_LEN("\r\n"));
chunkqueue_append_buffer(con->write_queue, b);
}
diff --git a/src/log.c b/src/log.c
index 6c9c38db..9322d2cb 100644
--- a/src/log.c
+++ b/src/log.c
@@ -288,7 +288,7 @@ static void log_buffer_append_printf(buffer *out, const char *fmt, va_list ap) {
case 'x': /* int (hex) */
d = va_arg(ap, int);
buffer_append_string_len(out, CONST_STR_LEN("0x"));
- buffer_append_long_hex(out, d);
+ buffer_append_uint_hex(out, d);
buffer_append_string_len(out, CONST_STR_LEN(" "));
break;
case 'S': /* string */
@@ -310,7 +310,7 @@ static void log_buffer_append_printf(buffer *out, const char *fmt, va_list ap) {
case 'X': /* int (hex) */
d = va_arg(ap, int);
buffer_append_string_len(out, CONST_STR_LEN("0x"));
- buffer_append_long_hex(out, d);
+ buffer_append_uint_hex(out, d);
break;
case '(':
case ')':