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 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:
o Add a new flag to bufferevents to make all callbacks automatically deferred.
if (strcmp(tmp_name, cmp_name) == 0) \
name_matches = 1; \
} else { \
- if (evutil_strcasecmp(tmp_name, cmp_name) == 0) \
+ if (evutil_ascii_strcasecmp(tmp_name, cmp_name) == 0) \
name_matches = 1; \
} \
} while(0)
};
int
-evutil_strcasecmp(const char *s1, const char *s2)
+evutil_ascii_strcasecmp(const char *s1, const char *s2)
{
char c1, c2;
while (1) {
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;
while (n--) {
if (flags & EVHTTP_PROXY_REQUEST) {
/* 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 {
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);
}
}
{
const char *connection = evhttp_find_header(headers, "Connection");
return (connection != NULL
- && evutil_strncasecmp(connection, "keep-alive", 10) == 0);
+ && evutil_ascii_strncasecmp(connection, "keep-alive", 10) == 0);
}
static void
struct evkeyval *header;
TAILQ_FOREACH(header, headers, next) {
- if (evutil_strcasecmp(header->key, key) == 0)
+ if (evutil_ascii_strcasecmp(header->key, key) == 0)
return (header->value);
}
struct evkeyval *header;
TAILQ_FOREACH(header, headers, next) {
- if (evutil_strcasecmp(header->key, key) == 0)
+ if (evutil_ascii_strcasecmp(header->key, key) == 0)
break;
}
if (content_length == NULL && connection == NULL)
req->ntoread = -1;
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 */
event_warnx("%s: we got no content length, but the "
"server wants to keep the connection open: %s.",
}
evcon->state = EVCON_READING_BODY;
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->ntoread = -1;
} else {
*/
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
}
static int dns_got_cancel = 0;
static int dns_err = 0;
-/* XXXXX have evutil export this. */
-int evutil_strcasecmp(const char *, const char *);
-
static void
dns_gethostbyname_cb(int result, char type, int count, int ttl,
void *addresses, void *arg)
ans.s_addr = htonl(0xc0a80b0bUL); /* 192.168.11.11 */
if (req->questions[i]->type == EVDNS_TYPE_A &&
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,
req->questions[i]->name,
1, &ans.s_addr, 12345);
dns_ok = 0;
} else if (req->questions[i]->type == EVDNS_TYPE_AAAA &&
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";
r = evdns_server_request_add_aaaa_reply(req,
req->questions[i]->name,
dns_ok = 0;
} else if (req->questions[i]->type == EVDNS_TYPE_PTR &&
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,
req->questions[i]->name,
"ZZ.EXAMPLE.COM", 54321);
dns_ok = 0;
} else if (req->questions[i]->type == EVDNS_TYPE_A &&
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)
dns_ok = 0;
return;
static void
test_evutil_casecmp(void *ptr)
{
- tt_int_op(evutil_strcasecmp("ABC", "ABC"), ==, 0);
- tt_int_op(evutil_strcasecmp("ABC", "abc"), ==, 0);
- tt_int_op(evutil_strcasecmp("ABC", "abcd"), <, 0);
- tt_int_op(evutil_strcasecmp("ABC", "abb"), >, 0);
- tt_int_op(evutil_strcasecmp("ABCd", "abc"), >, 0);
+ tt_int_op(evutil_ascii_strcasecmp("ABC", "ABC"), ==, 0);
+ tt_int_op(evutil_ascii_strcasecmp("ABC", "abc"), ==, 0);
+ tt_int_op(evutil_ascii_strcasecmp("ABC", "abcd"), <, 0);
+ tt_int_op(evutil_ascii_strcasecmp("ABC", "abb"), >, 0);
+ tt_int_op(evutil_ascii_strcasecmp("ABCd", "abc"), >, 0);
- tt_int_op(evutil_strncasecmp("Libevent", "LibEvEnT", 100), ==, 0);
- tt_int_op(evutil_strncasecmp("Libevent", "LibEvEnT", 4), ==, 0);
- tt_int_op(evutil_strncasecmp("Libevent", "LibEXXXX", 4), ==, 0);
- tt_int_op(evutil_strncasecmp("Libevent", "LibE", 4), ==, 0);
- tt_int_op(evutil_strncasecmp("Libe", "LibEvEnT", 4), ==, 0);
- tt_int_op(evutil_strncasecmp("Lib", "LibEvEnT", 4), <, 0);
- tt_int_op(evutil_strncasecmp("abc", "def", 99), <, 0);
- tt_int_op(evutil_strncasecmp("Z", "qrst", 1), >, 0);
+ tt_int_op(evutil_ascii_strncasecmp("Libevent", "LibEvEnT", 100), ==, 0);
+ tt_int_op(evutil_ascii_strncasecmp("Libevent", "LibEvEnT", 4), ==, 0);
+ tt_int_op(evutil_ascii_strncasecmp("Libevent", "LibEXXXX", 4), ==, 0);
+ tt_int_op(evutil_ascii_strncasecmp("Libevent", "LibE", 4), ==, 0);
+ tt_int_op(evutil_ascii_strncasecmp("Libe", "LibEvEnT", 4), ==, 0);
+ tt_int_op(evutil_ascii_strncasecmp("Lib", "LibEvEnT", 4), <, 0);
+ tt_int_op(evutil_ascii_strncasecmp("abc", "def", 99), <, 0);
+ tt_int_op(evutil_ascii_strncasecmp("Z", "qrst", 1), >, 0);
end:
;
}
extern const char EVUTIL_TOLOWER_TABLE[];
#define EVUTIL_TOLOWER(c) (EVUTIL_TOLOWER_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
structure, return a pointer to the structure itself. Used to implement