1 --- libevent-1.4.2-rc/evbuffer.c 2007-11-18 07:08:36.000000000 +0000
2 +++ libevent-1.4.2-rc.new/evbuffer.c 2008-04-05 20:13:51.000000000 +0000
7 +#include <sys/socket.h>
9 +#include <netinet/in.h>
24 void bufferevent_setwatermark(struct bufferevent *, short, size_t, size_t);
25 void bufferevent_read_pressure_cb(struct evbuffer *, size_t, size_t, void *);
28 +int bufev_socket_new(void) {
29 + return socket(AF_INET, SOCK_STREAM, 0);
32 +int bufev_socket_connect(int sock, struct sockaddr_in *addr) {
33 + return connect(sock, (struct sockaddr*)addr, sizeof(struct sockaddr_in));
36 +struct bufferevent *bufev_socket_accept(int listen_sock, evbuffercb readcb, evbuffercb writecb, everrorcb errorcb, void *cbarg) {
38 + returned = accept(listen_sock, NULL, NULL);
41 + perror("Accept failed : ");
45 + return bufferevent_new(returned, readcb, writecb, errorcb, cbarg);
48 +int bufev_socket_listen(int sock, int backlog) {
49 + return listen(sock, backlog);
52 +int bufev_socket_bind(int sock, struct sockaddr_in *bind_to) {
53 + return bind(sock, (struct sockaddr*) bind_to, sizeof(struct sockaddr_in));
56 +int bufev_socket_close(int sock) {
61 bufferevent_add(struct event *ev, int timeout)
68 +//void bufferevent_close_and_free(struct bufferevent *bufev) {
69 +// bufev_socket_close(bufev->fd);
70 +// bufferevent_free(bufev);
74 * Returns 0 on success;
76 --- libevent-1.4.2-rc/event.h 2008-02-23 01:36:12.000000000 +0000
77 +++ libevent-1.4.2-rc.new/event.h 2008-04-05 20:13:18.000000000 +0000
79 #ifdef _EVENT_HAVE_SYS_TYPES_H
80 #include <sys/types.h>
82 +#ifdef _EVENT_HAVE_SYS_SOCKET_H
83 +#include <sys/socket.h>
85 #ifdef _EVENT_HAVE_SYS_TIME_H
95 #define WIN32_LEAN_AND_MEAN
102 + * From: https://tor-svn.freehaven.net/svn/libevent-urz
104 + * Documentation for the below is rough, but should be complete
106 + * int bufev_socket_new(void);
107 + * Creates a new socket which is compatible with the local implementation
108 + * of bufferevents. The return value is only required to fit in the same
109 + * space as an int, it is not required to actually *be* an int.
110 + * Regardless the true return type, (int) -1 is a reserved value which
111 + * means creating a new socket failed.
113 + * int bufev_socket_connect(int sock, struct sockaddr_in *addr);
114 + * Connects a socket to an internet address. Returns -1 on failure,
117 + * struct bufferevent *bufev_socket_accept(int listen_sock, evbuffercb readcb, evbuffercb writecb, everrorcb errorcb, void *cbarg);
118 + * listen_sock is a listening socket (see bufev_socket_listen).
119 + * all other arguments are as bufferevent_new().
120 + * Takes one connection off the pending connection queue for a listening socket and
121 + * creates a new bufferevent based on the connection.
123 + * int bufev_socket_listen(int sock, int backlog);
124 + * Sets a socket (created with bufev_socket_new()) to listen. The socket must first be bound
125 + * (with bufev_socket_bind()). Returns 0 on success, -1 on failure.
127 + * int bufev_socket_bind(int sock, struct sockaddr_in *bind_to);
128 + * Binds a socket (created with bufev_socket_new()) to a particular internet address.
129 + * returns 0 on success, -1 on failure.
131 + * int bufev_socket_close(int sock);
132 + * Closes a socket (created with bufev_socket_new()). Returns 0 on success, -1 on error.
136 +int bufev_socket_new(void);
138 +int bufev_socket_connect(int sock, struct sockaddr_in *addr);
140 +struct bufferevent *bufev_socket_accept(int listen_sock, evbuffercb readcb, evbuffercb writecb, everrorcb errorcb, void *cbarg);
142 +int bufev_socket_listen(int sock, int backlog);
144 +int bufev_socket_bind(int sock, struct sockaddr_in *bind_to);
146 +int bufev_socket_close(int sock);
150 Create a new bufferevent.
152 --- libevent-1.4.2-rc/evhttp.h 2008-02-17 01:16:12.000000000 +0000
153 +++ libevent-1.4.2-rc.new/evhttp.h 2008-04-05 20:13:34.000000000 +0000
156 char *evhttp_htmlescape(const char *html);
158 +int socket_connect(int fd, const char *address, unsigned short port);
159 +int bind_socket_ai(struct addrinfo *);
160 +int bind_socket(const char *, u_short);
165 --- libevent-1.4.2-rc/http.c 2008-02-17 01:16:12.000000000 +0000
166 +++ libevent-1.4.2-rc.new/http.c 2008-04-05 20:13:51.000000000 +0000
171 -static int socket_connect(int fd, const char *address, unsigned short port);
172 -static int bind_socket_ai(struct addrinfo *);
173 -static int bind_socket(const char *, u_short);
174 static void name_from_addr(struct sockaddr *, socklen_t, char **, char **);
175 static int evhttp_associate_new_request_with_connection(
176 struct evhttp_connection *evcon);
177 @@ -2371,7 +2368,7 @@
179 /* Either connect or bind */
183 bind_socket_ai(struct addrinfo *ai)
186 @@ -2448,7 +2445,7 @@
192 bind_socket(const char *address, u_short port)
195 @@ -2468,7 +2465,7 @@
201 socket_connect(int fd, const char *address, unsigned short port)
203 struct addrinfo *ai = make_addrinfo(address, port);