|
|
|
@ -660,7 +660,7 @@ int buffer_append_string_hex(buffer *b, const char *in, size_t in_len) {
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int buffer_append_string_url_encoded(buffer *b, const char *s) { |
|
|
|
|
int buffer_append_string_url_encoded(buffer *b, const char *s, size_t s_len) { |
|
|
|
|
unsigned char *ds, *d; |
|
|
|
|
size_t d_len; |
|
|
|
|
|
|
|
|
@ -670,6 +670,7 @@ int buffer_append_string_url_encoded(buffer *b, const char *s) {
|
|
|
|
|
SEGFAULT(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (s_len == 0) return 0; |
|
|
|
|
|
|
|
|
|
/* count to-be-encoded-characters */ |
|
|
|
|
for (ds = (unsigned char *)s, d_len = 0; *ds; ds++) { |
|
|
|
@ -747,7 +748,7 @@ int buffer_append_string_url_encoded(buffer *b, const char *s) {
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int buffer_append_string_html_encoded(buffer *b, const char *s) { |
|
|
|
|
int buffer_append_string_html_encoded(buffer *b, const char *s, size_t s_len) { |
|
|
|
|
unsigned char *ds, *d; |
|
|
|
|
size_t d_len; |
|
|
|
|
|
|
|
|
@ -757,6 +758,8 @@ int buffer_append_string_html_encoded(buffer *b, const char *s) {
|
|
|
|
|
SEGFAULT(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* nothing to append */ |
|
|
|
|
if (s_len == 0) return 0; |
|
|
|
|
|
|
|
|
|
/* count to-be-encoded-characters */ |
|
|
|
|
for (ds = (unsigned char *)s, d_len = 0; *ds; ds++) { |
|
|
|
@ -964,3 +967,32 @@ int light_isalpha(int c) {
|
|
|
|
|
int light_isalnum(int c) { |
|
|
|
|
return light_isdigit(c) || light_isalpha(c); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int buffer_to_lower(buffer *b) { |
|
|
|
|
char *c; |
|
|
|
|
|
|
|
|
|
if (b->used == 0) return 0; |
|
|
|
|
|
|
|
|
|
for (c = b->ptr; *c; c++) { |
|
|
|
|
if (*c >= 'A' && *c <= 'Z') { |
|
|
|
|
*c |= 32; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int buffer_to_upper(buffer *b) { |
|
|
|
|
char *c; |
|
|
|
|
|
|
|
|
|
if (b->used == 0) return 0; |
|
|
|
|
|
|
|
|
|
for (c = b->ptr; *c; c++) { |
|
|
|
|
if (*c >= 'a' && *c <= 'z') { |
|
|
|
|
*c &= ~32; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|