Browse Source

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
svn/tags/lighttpd-1.4.36
Stefan Bühler 7 years ago
parent
commit
91a9a6b391
  1. 4
      src/buffer.c
  2. 2
      src/buffer.h
  3. 22
      src/http_chunk.c
  4. 4
      src/log.c

4
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) */

2
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);

22
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);
}

4
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 ')':

Loading…
Cancel
Save