mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-09 04:19:10 -04:00
Export evutil_str[n]casecmp as evutil_ascii_str[n]casecmp.
svn:r1387
This commit is contained in:
parent
a826a75800
commit
72ea534f8e
@ -2,6 +2,7 @@ Changes in 2.0.3-alpha:
|
|||||||
o Add a new code to support SSL/TLS on bufferevents, using the OpenSSL library (where available).
|
o Add a new code to support SSL/TLS on bufferevents, using the OpenSSL library (where available).
|
||||||
o Fix a bug where we didn't allocate enough memory in event_get_supported_methods().
|
o Fix a bug where we didn't allocate enough memory in event_get_supported_methods().
|
||||||
o Avoid segfault during failed allocation of locked evdns_base. (Found by Rocco Carbone.)
|
o Avoid segfault during failed allocation of locked evdns_base. (Found by Rocco Carbone.)
|
||||||
|
o Export new evutil_ascii_* functions to perform locale-independent character type operations.
|
||||||
|
|
||||||
Changes in 2.0.2-alpha:
|
Changes in 2.0.2-alpha:
|
||||||
o Add a new flag to bufferevents to make all callbacks automatically deferred.
|
o Add a new flag to bufferevents to make all callbacks automatically deferred.
|
||||||
|
2
evdns.c
2
evdns.c
@ -1005,7 +1005,7 @@ reply_parse(struct evdns_base *base, u8 *packet, int length) {
|
|||||||
if (strcmp(tmp_name, cmp_name) == 0) \
|
if (strcmp(tmp_name, cmp_name) == 0) \
|
||||||
name_matches = 1; \
|
name_matches = 1; \
|
||||||
} else { \
|
} else { \
|
||||||
if (evutil_strcasecmp(tmp_name, cmp_name) == 0) \
|
if (evutil_ascii_strcasecmp(tmp_name, cmp_name) == 0) \
|
||||||
name_matches = 1; \
|
name_matches = 1; \
|
||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
4
evutil.c
4
evutil.c
@ -773,7 +773,7 @@ const char EVUTIL_TOLOWER_TABLE[256] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
evutil_strcasecmp(const char *s1, const char *s2)
|
evutil_ascii_strcasecmp(const char *s1, const char *s2)
|
||||||
{
|
{
|
||||||
char c1, c2;
|
char c1, c2;
|
||||||
while (1) {
|
while (1) {
|
||||||
@ -787,7 +787,7 @@ evutil_strcasecmp(const char *s1, const char *s2)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int evutil_strncasecmp(const char *s1, const char *s2, size_t n)
|
int evutil_ascii_strncasecmp(const char *s1, const char *s2, size_t n)
|
||||||
{
|
{
|
||||||
char c1, c2;
|
char c1, c2;
|
||||||
while (n--) {
|
while (n--) {
|
||||||
|
14
http.c
14
http.c
@ -418,10 +418,10 @@ evhttp_is_connection_close(int flags, struct evkeyvalq* headers)
|
|||||||
if (flags & EVHTTP_PROXY_REQUEST) {
|
if (flags & EVHTTP_PROXY_REQUEST) {
|
||||||
/* proxy connection */
|
/* proxy connection */
|
||||||
const char *connection = evhttp_find_header(headers, "Proxy-Connection");
|
const char *connection = evhttp_find_header(headers, "Proxy-Connection");
|
||||||
return (connection == NULL || evutil_strcasecmp(connection, "keep-alive") != 0);
|
return (connection == NULL || evutil_ascii_strcasecmp(connection, "keep-alive") != 0);
|
||||||
} else {
|
} else {
|
||||||
const char *connection = evhttp_find_header(headers, "Connection");
|
const char *connection = evhttp_find_header(headers, "Connection");
|
||||||
return (connection != NULL && evutil_strcasecmp(connection, "close") == 0);
|
return (connection != NULL && evutil_ascii_strcasecmp(connection, "close") == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,7 +430,7 @@ evhttp_is_connection_keepalive(struct evkeyvalq* headers)
|
|||||||
{
|
{
|
||||||
const char *connection = evhttp_find_header(headers, "Connection");
|
const char *connection = evhttp_find_header(headers, "Connection");
|
||||||
return (connection != NULL
|
return (connection != NULL
|
||||||
&& evutil_strncasecmp(connection, "keep-alive", 10) == 0);
|
&& evutil_ascii_strncasecmp(connection, "keep-alive", 10) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1325,7 +1325,7 @@ evhttp_find_header(const struct evkeyvalq *headers, const char *key)
|
|||||||
struct evkeyval *header;
|
struct evkeyval *header;
|
||||||
|
|
||||||
TAILQ_FOREACH(header, headers, next) {
|
TAILQ_FOREACH(header, headers, next) {
|
||||||
if (evutil_strcasecmp(header->key, key) == 0)
|
if (evutil_ascii_strcasecmp(header->key, key) == 0)
|
||||||
return (header->value);
|
return (header->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1358,7 +1358,7 @@ evhttp_remove_header(struct evkeyvalq *headers, const char *key)
|
|||||||
struct evkeyval *header;
|
struct evkeyval *header;
|
||||||
|
|
||||||
TAILQ_FOREACH(header, headers, next) {
|
TAILQ_FOREACH(header, headers, next) {
|
||||||
if (evutil_strcasecmp(header->key, key) == 0)
|
if (evutil_ascii_strcasecmp(header->key, key) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1554,7 +1554,7 @@ evhttp_get_body_length(struct evhttp_request *req)
|
|||||||
if (content_length == NULL && connection == NULL)
|
if (content_length == NULL && connection == NULL)
|
||||||
req->ntoread = -1;
|
req->ntoread = -1;
|
||||||
else if (content_length == NULL &&
|
else if (content_length == NULL &&
|
||||||
evutil_strcasecmp(connection, "Close") != 0) {
|
evutil_ascii_strcasecmp(connection, "Close") != 0) {
|
||||||
/* Bad combination, we don't know when it will end */
|
/* Bad combination, we don't know when it will end */
|
||||||
event_warnx("%s: we got no content length, but the "
|
event_warnx("%s: we got no content length, but the "
|
||||||
"server wants to keep the connection open: %s.",
|
"server wants to keep the connection open: %s.",
|
||||||
@ -1593,7 +1593,7 @@ evhttp_get_body(struct evhttp_connection *evcon, struct evhttp_request *req)
|
|||||||
}
|
}
|
||||||
evcon->state = EVCON_READING_BODY;
|
evcon->state = EVCON_READING_BODY;
|
||||||
xfer_enc = evhttp_find_header(req->input_headers, "Transfer-Encoding");
|
xfer_enc = evhttp_find_header(req->input_headers, "Transfer-Encoding");
|
||||||
if (xfer_enc != NULL && evutil_strcasecmp(xfer_enc, "chunked") == 0) {
|
if (xfer_enc != NULL && evutil_ascii_strcasecmp(xfer_enc, "chunked") == 0) {
|
||||||
req->chunked = 1;
|
req->chunked = 1;
|
||||||
req->ntoread = -1;
|
req->ntoread = -1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -295,6 +295,14 @@ struct sockaddr;
|
|||||||
*/
|
*/
|
||||||
int evutil_parse_sockaddr_port(const char *str, struct sockaddr *out, int *outlen);
|
int evutil_parse_sockaddr_port(const char *str, struct sockaddr *out, int *outlen);
|
||||||
|
|
||||||
|
/** As strcasecmp, but always compares the characters in locale-independent
|
||||||
|
ASCII. That's useful if you're handling data in ASCII-based protocols.
|
||||||
|
*/
|
||||||
|
int evutil_ascii_strcasecmp(const char *str1, const char *str2);
|
||||||
|
/** As strncasecmp, but always compares the characters in locale-independent
|
||||||
|
ASCII. That's useful if you're handling data in ASCII-based protocols.
|
||||||
|
*/
|
||||||
|
int evutil_ascii_strncasecmp(const char *str1, const char *str2, size_t n);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -70,9 +70,6 @@ static int dns_ok = 0;
|
|||||||
static int dns_got_cancel = 0;
|
static int dns_got_cancel = 0;
|
||||||
static int dns_err = 0;
|
static int dns_err = 0;
|
||||||
|
|
||||||
/* XXXXX have evutil export this. */
|
|
||||||
int evutil_strcasecmp(const char *, const char *);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dns_gethostbyname_cb(int result, char type, int count, int ttl,
|
dns_gethostbyname_cb(int result, char type, int count, int ttl,
|
||||||
void *addresses, void *arg)
|
void *addresses, void *arg)
|
||||||
@ -226,7 +223,7 @@ dns_server_request_cb(struct evdns_server_request *req, void *data)
|
|||||||
ans.s_addr = htonl(0xc0a80b0bUL); /* 192.168.11.11 */
|
ans.s_addr = htonl(0xc0a80b0bUL); /* 192.168.11.11 */
|
||||||
if (req->questions[i]->type == EVDNS_TYPE_A &&
|
if (req->questions[i]->type == EVDNS_TYPE_A &&
|
||||||
req->questions[i]->dns_question_class == EVDNS_CLASS_INET &&
|
req->questions[i]->dns_question_class == EVDNS_CLASS_INET &&
|
||||||
!evutil_strcasecmp(req->questions[i]->name, "zz.example.com")) {
|
!evutil_ascii_strcasecmp(req->questions[i]->name, "zz.example.com")) {
|
||||||
r = evdns_server_request_add_a_reply(req,
|
r = evdns_server_request_add_a_reply(req,
|
||||||
req->questions[i]->name,
|
req->questions[i]->name,
|
||||||
1, &ans.s_addr, 12345);
|
1, &ans.s_addr, 12345);
|
||||||
@ -234,7 +231,7 @@ dns_server_request_cb(struct evdns_server_request *req, void *data)
|
|||||||
dns_ok = 0;
|
dns_ok = 0;
|
||||||
} else if (req->questions[i]->type == EVDNS_TYPE_AAAA &&
|
} else if (req->questions[i]->type == EVDNS_TYPE_AAAA &&
|
||||||
req->questions[i]->dns_question_class == EVDNS_CLASS_INET &&
|
req->questions[i]->dns_question_class == EVDNS_CLASS_INET &&
|
||||||
!evutil_strcasecmp(req->questions[i]->name, "zz.example.com")) {
|
!evutil_ascii_strcasecmp(req->questions[i]->name, "zz.example.com")) {
|
||||||
char addr6[17] = "abcdefghijklmnop";
|
char addr6[17] = "abcdefghijklmnop";
|
||||||
r = evdns_server_request_add_aaaa_reply(req,
|
r = evdns_server_request_add_aaaa_reply(req,
|
||||||
req->questions[i]->name,
|
req->questions[i]->name,
|
||||||
@ -243,7 +240,7 @@ dns_server_request_cb(struct evdns_server_request *req, void *data)
|
|||||||
dns_ok = 0;
|
dns_ok = 0;
|
||||||
} else if (req->questions[i]->type == EVDNS_TYPE_PTR &&
|
} else if (req->questions[i]->type == EVDNS_TYPE_PTR &&
|
||||||
req->questions[i]->dns_question_class == EVDNS_CLASS_INET &&
|
req->questions[i]->dns_question_class == EVDNS_CLASS_INET &&
|
||||||
!evutil_strcasecmp(req->questions[i]->name, TEST_ARPA)) {
|
!evutil_ascii_strcasecmp(req->questions[i]->name, TEST_ARPA)) {
|
||||||
r = evdns_server_request_add_ptr_reply(req, NULL,
|
r = evdns_server_request_add_ptr_reply(req, NULL,
|
||||||
req->questions[i]->name,
|
req->questions[i]->name,
|
||||||
"ZZ.EXAMPLE.COM", 54321);
|
"ZZ.EXAMPLE.COM", 54321);
|
||||||
@ -251,7 +248,7 @@ dns_server_request_cb(struct evdns_server_request *req, void *data)
|
|||||||
dns_ok = 0;
|
dns_ok = 0;
|
||||||
} else if (req->questions[i]->type == EVDNS_TYPE_A &&
|
} else if (req->questions[i]->type == EVDNS_TYPE_A &&
|
||||||
req->questions[i]->dns_question_class == EVDNS_CLASS_INET &&
|
req->questions[i]->dns_question_class == EVDNS_CLASS_INET &&
|
||||||
!evutil_strcasecmp(req->questions[i]->name, "drop.example.com")) {
|
!evutil_ascii_strcasecmp(req->questions[i]->name, "drop.example.com")) {
|
||||||
if (evdns_server_request_drop(req)<0)
|
if (evdns_server_request_drop(req)<0)
|
||||||
dns_ok = 0;
|
dns_ok = 0;
|
||||||
return;
|
return;
|
||||||
|
@ -304,20 +304,20 @@ test_evutil_snprintf(void *ptr)
|
|||||||
static void
|
static void
|
||||||
test_evutil_casecmp(void *ptr)
|
test_evutil_casecmp(void *ptr)
|
||||||
{
|
{
|
||||||
tt_int_op(evutil_strcasecmp("ABC", "ABC"), ==, 0);
|
tt_int_op(evutil_ascii_strcasecmp("ABC", "ABC"), ==, 0);
|
||||||
tt_int_op(evutil_strcasecmp("ABC", "abc"), ==, 0);
|
tt_int_op(evutil_ascii_strcasecmp("ABC", "abc"), ==, 0);
|
||||||
tt_int_op(evutil_strcasecmp("ABC", "abcd"), <, 0);
|
tt_int_op(evutil_ascii_strcasecmp("ABC", "abcd"), <, 0);
|
||||||
tt_int_op(evutil_strcasecmp("ABC", "abb"), >, 0);
|
tt_int_op(evutil_ascii_strcasecmp("ABC", "abb"), >, 0);
|
||||||
tt_int_op(evutil_strcasecmp("ABCd", "abc"), >, 0);
|
tt_int_op(evutil_ascii_strcasecmp("ABCd", "abc"), >, 0);
|
||||||
|
|
||||||
tt_int_op(evutil_strncasecmp("Libevent", "LibEvEnT", 100), ==, 0);
|
tt_int_op(evutil_ascii_strncasecmp("Libevent", "LibEvEnT", 100), ==, 0);
|
||||||
tt_int_op(evutil_strncasecmp("Libevent", "LibEvEnT", 4), ==, 0);
|
tt_int_op(evutil_ascii_strncasecmp("Libevent", "LibEvEnT", 4), ==, 0);
|
||||||
tt_int_op(evutil_strncasecmp("Libevent", "LibEXXXX", 4), ==, 0);
|
tt_int_op(evutil_ascii_strncasecmp("Libevent", "LibEXXXX", 4), ==, 0);
|
||||||
tt_int_op(evutil_strncasecmp("Libevent", "LibE", 4), ==, 0);
|
tt_int_op(evutil_ascii_strncasecmp("Libevent", "LibE", 4), ==, 0);
|
||||||
tt_int_op(evutil_strncasecmp("Libe", "LibEvEnT", 4), ==, 0);
|
tt_int_op(evutil_ascii_strncasecmp("Libe", "LibEvEnT", 4), ==, 0);
|
||||||
tt_int_op(evutil_strncasecmp("Lib", "LibEvEnT", 4), <, 0);
|
tt_int_op(evutil_ascii_strncasecmp("Lib", "LibEvEnT", 4), <, 0);
|
||||||
tt_int_op(evutil_strncasecmp("abc", "def", 99), <, 0);
|
tt_int_op(evutil_ascii_strncasecmp("abc", "def", 99), <, 0);
|
||||||
tt_int_op(evutil_strncasecmp("Z", "qrst", 1), >, 0);
|
tt_int_op(evutil_ascii_strncasecmp("Z", "qrst", 1), >, 0);
|
||||||
end:
|
end:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -108,8 +108,6 @@ extern const char EVUTIL_TOUPPER_TABLE[];
|
|||||||
extern const char EVUTIL_TOLOWER_TABLE[];
|
extern const char EVUTIL_TOLOWER_TABLE[];
|
||||||
#define EVUTIL_TOLOWER(c) (EVUTIL_TOLOWER_TABLE[(ev_uint8_t)c])
|
#define EVUTIL_TOLOWER(c) (EVUTIL_TOLOWER_TABLE[(ev_uint8_t)c])
|
||||||
#define EVUTIL_TOUPPER(c) (EVUTIL_TOUPPER_TABLE[(ev_uint8_t)c])
|
#define EVUTIL_TOUPPER(c) (EVUTIL_TOUPPER_TABLE[(ev_uint8_t)c])
|
||||||
int evutil_strcasecmp(const char *, const char *);
|
|
||||||
int evutil_strncasecmp(const char *, const char *, size_t);
|
|
||||||
|
|
||||||
/** Helper macro. If we know that a given pointer points to a field in a
|
/** Helper macro. If we know that a given pointer points to a field in a
|
||||||
structure, return a pointer to the structure itself. Used to implement
|
structure, return a pointer to the structure itself. Used to implement
|
||||||
|
Loading…
x
Reference in New Issue
Block a user