From 6bf1ca780c5f60618e59e02b61eae4bfee199f46 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 12 May 2008 00:40:04 +0000 Subject: [PATCH] r19675@catbus: nickm | 2008-05-11 20:39:39 -0400 Stop pretending that u_char and u_short are standard types that win32 is dumb not to have. In fact, u_char can really just be spelled out, and u_short was usually just a bad way of saying ev_uint16_t. svn:r808 --- buffer.c | 20 ++++++++++---------- evdns.c | 1 - http.c | 16 ++++++++-------- include/event2/buffer.h | 6 +++--- include/event2/bufferevent.h | 2 -- include/event2/bufferevent_struct.h | 2 -- include/event2/event.h | 2 -- include/event2/event_compat.h | 2 -- include/event2/event_struct.h | 2 -- include/event2/http.h | 4 ++-- include/event2/http_compat.h | 4 +--- include/event2/http_struct.h | 2 +- include/event2/tag.h | 2 -- 13 files changed, 25 insertions(+), 40 deletions(-) diff --git a/buffer.c b/buffer.c index 58869140..90117ae0 100644 --- a/buffer.c +++ b/buffer.c @@ -131,7 +131,7 @@ evbuffer_get_contiguous_space(struct evbuffer *buf) return (chain != NULL ? chain->off : 0); } -u_char * +unsigned char * evbuffer_reserve_space(struct evbuffer *buf, size_t size) { struct evbuffer_chain *chain; @@ -395,11 +395,11 @@ evbuffer_remove_buffer(struct evbuffer *src, struct evbuffer *dst, } /* XXX shouldn't the second arg be ssize_t? */ -u_char * +unsigned char * evbuffer_pullup(struct evbuffer *buf, int size) { struct evbuffer_chain *chain = buf->first, *next, *tmp; - u_char *buffer; + unsigned char *buffer; if (size == -1) size = buf->total_len; @@ -643,7 +643,7 @@ int evbuffer_add(struct evbuffer *buf, const void *data_in, size_t datlen) { struct evbuffer_chain *chain = buf->last; - const u_char *data = data_in; + const unsigned char *data = data_in; size_t old_len = buf->total_len, remain, to_alloc; /* If there are no chains allocated for this buffer, allocate one @@ -813,7 +813,7 @@ int evbuffer_read(struct evbuffer *buf, evutil_socket_t fd, int howmuch) { struct evbuffer_chain *chain = buf->last; - u_char *p; + unsigned char *p; size_t old_len = buf->total_len; int n = EVBUFFER_MAX_READ; @@ -910,12 +910,12 @@ evbuffer_write(struct evbuffer *buffer, evutil_socket_t fd) return (n); } -u_char * -evbuffer_find(struct evbuffer *buffer, const u_char *what, size_t len) +unsigned char * +evbuffer_find(struct evbuffer *buffer, const unsigned char *what, size_t len) { - u_char *search = evbuffer_pullup(buffer, -1); - u_char *end = search + buffer->total_len; - u_char *p; + unsigned char *search = evbuffer_pullup(buffer, -1); + unsigned char *end = search + buffer->total_len; + unsigned char *p; while (search < end && (p = memchr(search, *what, end - search)) != NULL) { diff --git a/evdns.c b/evdns.c index efbc2595..19657657 100644 --- a/evdns.c +++ b/evdns.c @@ -132,7 +132,6 @@ #ifdef __USE_ISOC99B /* libevent doesn't work without this */ -typedef ev_uint8_t u_char; typedef unsigned int uint; #endif #include "event2/event.h" diff --git a/http.c b/http.c index 3ae82b85..6e196749 100644 --- a/http.c +++ b/http.c @@ -153,7 +153,7 @@ extern int debug; static int socket_connect(evutil_socket_t kefd, const char *address, unsigned short port); static evutil_socket_t bind_socket_ai(struct addrinfo *); -static evutil_socket_t bind_socket(const char *, u_short); +static evutil_socket_t bind_socket(const char *, ev_uint16_t); static void name_from_addr(struct sockaddr *, socklen_t, char **, char **); static int evhttp_associate_new_request_with_connection( struct evhttp_connection *evcon); @@ -1483,7 +1483,7 @@ evhttp_connection_set_closecb(struct evhttp_connection *evcon, void evhttp_connection_get_peer(struct evhttp_connection *evcon, - char **address, u_short *port) + char **address, ev_uint16_t *port) { *address = evcon->address; *port = evcon->port; @@ -1788,10 +1788,10 @@ evhttp_encode_uri(const char *uri) char *p; for (p = (char *)uri; *p != '\0'; p++) { - if (uri_chars[(u_char)(*p)]) { + if (uri_chars[(unsigned char)(*p)]) { evbuffer_add(buf, p, 1); } else { - evbuffer_add_printf(buf, "%%%02X", (u_char)(*p)); + evbuffer_add_printf(buf, "%%%02X", (unsigned char)(*p)); } } evbuffer_add(buf, "", 1); @@ -2027,7 +2027,7 @@ accept_socket(evutil_socket_t fd, short what, void *arg) } int -evhttp_bind_socket(struct evhttp *http, const char *address, u_short port) +evhttp_bind_socket(struct evhttp *http, const char *address, ev_uint16_t port) { evutil_socket_t fd; int res; @@ -2114,7 +2114,7 @@ evhttp_new(struct event_base *base) */ struct evhttp * -evhttp_start(const char *address, u_short port) +evhttp_start(const char *address, unsigned short port) { struct evhttp *http = evhttp_new_object(); @@ -2576,7 +2576,7 @@ bind_socket_ai(struct addrinfo *ai) } static struct addrinfo * -make_addrinfo(const char *address, u_short port) +make_addrinfo(const char *address, ev_uint16_t port) { struct addrinfo *aitop = NULL; @@ -2614,7 +2614,7 @@ make_addrinfo(const char *address, u_short port) } static evutil_socket_t -bind_socket(const char *address, u_short port) +bind_socket(const char *address, ev_uint16_t port) { evutil_socket_t fd; struct addrinfo *aitop = make_addrinfo(address, port); diff --git a/include/event2/buffer.h b/include/event2/buffer.h index 7d7e1b53..d02feb71 100644 --- a/include/event2/buffer.h +++ b/include/event2/buffer.h @@ -134,7 +134,7 @@ int evbuffer_expand(struct evbuffer *buf, size_t datlen); @see evbuffer_commit_space */ -u_char *evbuffer_reserve_space(struct evbuffer *buf, size_t size); +unsigned char *evbuffer_reserve_space(struct evbuffer *buf, size_t size); /** Commits previously reserved space. @@ -306,7 +306,7 @@ int evbuffer_read(struct evbuffer *buffer, evutil_socket_t fd, int howmuch); @param len the length of the search string @return a pointer to the beginning of the search string, or NULL if the search failed. */ -u_char *evbuffer_find(struct evbuffer *buffer, const u_char *what, size_t len); +unsigned char *evbuffer_find(struct evbuffer *buffer, const unsigned char *what, size_t len); /** Set a callback to invoke when the evbuffer is modified. @@ -327,7 +327,7 @@ void evbuffer_setcb(struct evbuffer *buffer, @return a pointer to the contigous memory areay */ -u_char *evbuffer_pullup(struct evbuffer *buf, int size); +unsigned char *evbuffer_pullup(struct evbuffer *buf, int size); /** Prepends data to the beginning of the evbuffer diff --git a/include/event2/bufferevent.h b/include/event2/bufferevent.h index f0c9f672..0067f248 100644 --- a/include/event2/bufferevent.h +++ b/include/event2/bufferevent.h @@ -55,8 +55,6 @@ extern "C" { #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN -typedef unsigned char u_char; -typedef unsigned short u_short; #endif diff --git a/include/event2/bufferevent_struct.h b/include/event2/bufferevent_struct.h index 8616a9a6..c41d7f3f 100644 --- a/include/event2/bufferevent_struct.h +++ b/include/event2/bufferevent_struct.h @@ -55,8 +55,6 @@ extern "C" { #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN -typedef unsigned char u_char; -typedef unsigned short u_short; #endif struct event_watermark { diff --git a/include/event2/event.h b/include/event2/event.h index 1827fc67..563b2d1b 100644 --- a/include/event2/event.h +++ b/include/event2/event.h @@ -52,8 +52,6 @@ extern "C" { #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN -typedef unsigned char u_char; -typedef unsigned short u_short; #endif struct event_base; diff --git a/include/event2/event_compat.h b/include/event2/event_compat.h index 3d8050f6..ee789e35 100644 --- a/include/event2/event_compat.h +++ b/include/event2/event_compat.h @@ -53,8 +53,6 @@ extern "C" { #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN -typedef unsigned char u_char; -typedef unsigned short u_short; #endif /** diff --git a/include/event2/event_struct.h b/include/event2/event_struct.h index 17a89a85..1b3fa7c3 100644 --- a/include/event2/event_struct.h +++ b/include/event2/event_struct.h @@ -53,8 +53,6 @@ extern "C" { #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN -typedef unsigned char u_char; -typedef unsigned short u_short; #endif #define EVLIST_TIMEOUT 0x01 diff --git a/include/event2/http.h b/include/event2/http.h index 5b58e223..9d0c1d3d 100644 --- a/include/event2/http.h +++ b/include/event2/http.h @@ -89,7 +89,7 @@ struct evhttp *evhttp_new(struct event_base *base); * @return 0 on success, -1 on failure. * @see evhttp_free(), evhttp_accept_socket() */ -int evhttp_bind_socket(struct evhttp *http, const char *address, u_short port); +int evhttp_bind_socket(struct evhttp *http, const char *address, ev_uint16_t port); /** * Makes an HTTP server accept connections on the specified socket @@ -272,7 +272,7 @@ void evhttp_connection_set_closecb(struct evhttp_connection *evcon, /** Get the remote address and port associated with this connection. */ void evhttp_connection_get_peer(struct evhttp_connection *evcon, - char **address, u_short *port); + char **address, ev_uint16_t *port); /** The connection gets ownership of the request */ int evhttp_make_request(struct evhttp_connection *evcon, diff --git a/include/event2/http_compat.h b/include/event2/http_compat.h index 266e3839..93135e60 100644 --- a/include/event2/http_compat.h +++ b/include/event2/http_compat.h @@ -53,8 +53,6 @@ extern "C" { #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN -typedef unsigned char u_char; -typedef unsigned short u_short; #endif /** @@ -66,7 +64,7 @@ typedef unsigned short u_short; * @param port the port number on which the HTTP server should listen * @return an struct evhttp object */ -struct evhttp *evhttp_start(const char *address, u_short port); +struct evhttp *evhttp_start(const char *address, unsigned short port); /** * A connection object that can be used to for making HTTP requests. The diff --git a/include/event2/http_struct.h b/include/event2/http_struct.h index a6320aa2..1983fe4d 100644 --- a/include/event2/http_struct.h +++ b/include/event2/http_struct.h @@ -79,7 +79,7 @@ struct { /* address of the remote host and the port connection came from */ char *remote_host; - u_short remote_port; + ev_uint16_t remote_port; enum evhttp_request_kind kind; enum evhttp_cmd_type type; diff --git a/include/event2/tag.h b/include/event2/tag.h index 6f408fd1..0d0d8ca1 100644 --- a/include/event2/tag.h +++ b/include/event2/tag.h @@ -52,8 +52,6 @@ extern "C" { #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN -typedef unsigned char u_char; -typedef unsigned short u_short; #endif struct evbuffer; -- 2.50.1