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
This commit is contained in:
Nick Mathewson 2008-05-12 00:40:04 +00:00
parent a57767faf8
commit 6bf1ca780c
13 changed files with 25 additions and 40 deletions

View File

@ -131,7 +131,7 @@ evbuffer_get_contiguous_space(struct evbuffer *buf)
return (chain != NULL ? chain->off : 0); return (chain != NULL ? chain->off : 0);
} }
u_char * unsigned char *
evbuffer_reserve_space(struct evbuffer *buf, size_t size) evbuffer_reserve_space(struct evbuffer *buf, size_t size)
{ {
struct evbuffer_chain *chain; 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? */ /* XXX shouldn't the second arg be ssize_t? */
u_char * unsigned char *
evbuffer_pullup(struct evbuffer *buf, int size) evbuffer_pullup(struct evbuffer *buf, int size)
{ {
struct evbuffer_chain *chain = buf->first, *next, *tmp; struct evbuffer_chain *chain = buf->first, *next, *tmp;
u_char *buffer; unsigned char *buffer;
if (size == -1) if (size == -1)
size = buf->total_len; size = buf->total_len;
@ -643,7 +643,7 @@ int
evbuffer_add(struct evbuffer *buf, const void *data_in, size_t datlen) evbuffer_add(struct evbuffer *buf, const void *data_in, size_t datlen)
{ {
struct evbuffer_chain *chain = buf->last; 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; size_t old_len = buf->total_len, remain, to_alloc;
/* If there are no chains allocated for this buffer, allocate one /* 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) evbuffer_read(struct evbuffer *buf, evutil_socket_t fd, int howmuch)
{ {
struct evbuffer_chain *chain = buf->last; struct evbuffer_chain *chain = buf->last;
u_char *p; unsigned char *p;
size_t old_len = buf->total_len; size_t old_len = buf->total_len;
int n = EVBUFFER_MAX_READ; int n = EVBUFFER_MAX_READ;
@ -910,12 +910,12 @@ evbuffer_write(struct evbuffer *buffer, evutil_socket_t fd)
return (n); return (n);
} }
u_char * unsigned char *
evbuffer_find(struct evbuffer *buffer, const u_char *what, size_t len) evbuffer_find(struct evbuffer *buffer, const unsigned char *what, size_t len)
{ {
u_char *search = evbuffer_pullup(buffer, -1); unsigned char *search = evbuffer_pullup(buffer, -1);
u_char *end = search + buffer->total_len; unsigned char *end = search + buffer->total_len;
u_char *p; unsigned char *p;
while (search < end && while (search < end &&
(p = memchr(search, *what, end - search)) != NULL) { (p = memchr(search, *what, end - search)) != NULL) {

View File

@ -132,7 +132,6 @@
#ifdef __USE_ISOC99B #ifdef __USE_ISOC99B
/* libevent doesn't work without this */ /* libevent doesn't work without this */
typedef ev_uint8_t u_char;
typedef unsigned int uint; typedef unsigned int uint;
#endif #endif
#include "event2/event.h" #include "event2/event.h"

16
http.c
View File

@ -153,7 +153,7 @@ extern int debug;
static int socket_connect(evutil_socket_t kefd, const char *address, unsigned short port); 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_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 void name_from_addr(struct sockaddr *, socklen_t, char **, char **);
static int evhttp_associate_new_request_with_connection( static int evhttp_associate_new_request_with_connection(
struct evhttp_connection *evcon); struct evhttp_connection *evcon);
@ -1483,7 +1483,7 @@ evhttp_connection_set_closecb(struct evhttp_connection *evcon,
void void
evhttp_connection_get_peer(struct evhttp_connection *evcon, evhttp_connection_get_peer(struct evhttp_connection *evcon,
char **address, u_short *port) char **address, ev_uint16_t *port)
{ {
*address = evcon->address; *address = evcon->address;
*port = evcon->port; *port = evcon->port;
@ -1788,10 +1788,10 @@ evhttp_encode_uri(const char *uri)
char *p; char *p;
for (p = (char *)uri; *p != '\0'; 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); evbuffer_add(buf, p, 1);
} else { } else {
evbuffer_add_printf(buf, "%%%02X", (u_char)(*p)); evbuffer_add_printf(buf, "%%%02X", (unsigned char)(*p));
} }
} }
evbuffer_add(buf, "", 1); evbuffer_add(buf, "", 1);
@ -2027,7 +2027,7 @@ accept_socket(evutil_socket_t fd, short what, void *arg)
} }
int 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; evutil_socket_t fd;
int res; int res;
@ -2114,7 +2114,7 @@ evhttp_new(struct event_base *base)
*/ */
struct evhttp * struct evhttp *
evhttp_start(const char *address, u_short port) evhttp_start(const char *address, unsigned short port)
{ {
struct evhttp *http = evhttp_new_object(); struct evhttp *http = evhttp_new_object();
@ -2576,7 +2576,7 @@ bind_socket_ai(struct addrinfo *ai)
} }
static struct addrinfo * static struct addrinfo *
make_addrinfo(const char *address, u_short port) make_addrinfo(const char *address, ev_uint16_t port)
{ {
struct addrinfo *aitop = NULL; struct addrinfo *aitop = NULL;
@ -2614,7 +2614,7 @@ make_addrinfo(const char *address, u_short port)
} }
static evutil_socket_t 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; evutil_socket_t fd;
struct addrinfo *aitop = make_addrinfo(address, port); struct addrinfo *aitop = make_addrinfo(address, port);

View File

@ -134,7 +134,7 @@ int evbuffer_expand(struct evbuffer *buf, size_t datlen);
@see evbuffer_commit_space @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. 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 @param len the length of the search string
@return a pointer to the beginning of the search string, or NULL if the search failed. @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. 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 @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 Prepends data to the beginning of the evbuffer

View File

@ -55,8 +55,6 @@ extern "C" {
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
typedef unsigned char u_char;
typedef unsigned short u_short;
#endif #endif

View File

@ -55,8 +55,6 @@ extern "C" {
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
typedef unsigned char u_char;
typedef unsigned short u_short;
#endif #endif
struct event_watermark { struct event_watermark {

View File

@ -52,8 +52,6 @@ extern "C" {
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
typedef unsigned char u_char;
typedef unsigned short u_short;
#endif #endif
struct event_base; struct event_base;

View File

@ -53,8 +53,6 @@ extern "C" {
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
typedef unsigned char u_char;
typedef unsigned short u_short;
#endif #endif
/** /**

View File

@ -53,8 +53,6 @@ extern "C" {
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
typedef unsigned char u_char;
typedef unsigned short u_short;
#endif #endif
#define EVLIST_TIMEOUT 0x01 #define EVLIST_TIMEOUT 0x01

View File

@ -89,7 +89,7 @@ struct evhttp *evhttp_new(struct event_base *base);
* @return 0 on success, -1 on failure. * @return 0 on success, -1 on failure.
* @see evhttp_free(), evhttp_accept_socket() * @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 * 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. */ /** Get the remote address and port associated with this connection. */
void evhttp_connection_get_peer(struct evhttp_connection *evcon, 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 */ /** The connection gets ownership of the request */
int evhttp_make_request(struct evhttp_connection *evcon, int evhttp_make_request(struct evhttp_connection *evcon,

View File

@ -53,8 +53,6 @@ extern "C" {
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
typedef unsigned char u_char;
typedef unsigned short u_short;
#endif #endif
/** /**
@ -66,7 +64,7 @@ typedef unsigned short u_short;
* @param port the port number on which the HTTP server should listen * @param port the port number on which the HTTP server should listen
* @return an struct evhttp object * @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 * A connection object that can be used to for making HTTP requests. The

View File

@ -79,7 +79,7 @@ struct {
/* address of the remote host and the port connection came from */ /* address of the remote host and the port connection came from */
char *remote_host; char *remote_host;
u_short remote_port; ev_uint16_t remote_port;
enum evhttp_request_kind kind; enum evhttp_request_kind kind;
enum evhttp_cmd_type type; enum evhttp_cmd_type type;

View File

@ -52,8 +52,6 @@ extern "C" {
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
typedef unsigned char u_char;
typedef unsigned short u_short;
#endif #endif
struct evbuffer; struct evbuffer;