]> granicus.if.org Git - libevent/commitdiff
use ev_uint16_t instead of unsigned short for port
authorThomas Bernard <miniupnp@free.fr>
Sat, 13 Dec 2014 18:42:42 +0000 (19:42 +0100)
committerAzat Khuzhin <a3at.mail@gmail.com>
Tue, 25 Oct 2016 22:41:13 +0000 (01:41 +0300)
Like in `sockaddr_in` structure in /usr/include/netinet/in.h

@azat: convert all other users (bench, compat, ..) and tweak message
Fixes: #178
Fixes: #196
Refs: 6bf1ca78
Link: https://codereview.appspot.com/156040043/#msg4
http-internal.h
http.c
include/event2/http.h
include/event2/http_compat.h
sample/http-server.c
test/bench_http.c
test/regress_http.c

index ae01f386aed96773b5d89edeb1d2172cc6ffbe13..45555171c2cfd79e15531504ff909c17b075bed3 100644 (file)
@@ -62,10 +62,10 @@ struct evhttp_connection {
        struct event retry_ev;          /* for retrying connects */
 
        char *bind_address;             /* address to use for binding the src */
-       unsigned short bind_port;       /* local port for binding the src */
+       ev_uint16_t bind_port;          /* local port for binding the src */
 
        char *address;                  /* address to connect to */
-       unsigned short port;
+       ev_uint16_t port;
 
        size_t max_headers_size;
        ev_uint64_t max_body_size;
diff --git a/http.c b/http.c
index b9f909e4ac6dd9d62a4b3033f29beae9f1e7b410..8429240075f713d3fc9150c81045c2b49b232545 100644 (file)
--- a/http.c
+++ b/http.c
@@ -2342,14 +2342,14 @@ evhttp_read_header(struct evhttp_connection *evcon,
  */
 
 struct evhttp_connection *
-evhttp_connection_new(const char *address, unsigned short port)
+evhttp_connection_new(const char *address, ev_uint16_t port)
 {
        return (evhttp_connection_base_new(NULL, NULL, address, port));
 }
 
 struct evhttp_connection *
 evhttp_connection_base_bufferevent_new(struct event_base *base, struct evdns_base *dnsbase, struct bufferevent* bev,
-    const char *address, unsigned short port)
+    const char *address, ev_uint16_t port)
 {
        struct evhttp_connection *evcon = NULL;
 
@@ -2425,7 +2425,7 @@ evhttp_connection_get_server(struct evhttp_connection *evcon)
 
 struct evhttp_connection *
 evhttp_connection_base_new(struct event_base *base, struct evdns_base *dnsbase,
-    const char *address, unsigned short port)
+    const char *address, ev_uint16_t port)
 {
        return evhttp_connection_base_bufferevent_new(base, dnsbase, NULL, address, port);
 }
@@ -3665,7 +3665,7 @@ evhttp_new(struct event_base *base)
  */
 
 struct evhttp *
-evhttp_start(const char *address, unsigned short port)
+evhttp_start(const char *address, ev_uint16_t port)
 {
        struct evhttp *http = NULL;
 
index 10a7e975f2238df6daa6412307963651900e6f9e..8fb5642f7f483d63421e1048c52b785f8ead6c84 100644 (file)
@@ -520,7 +520,7 @@ enum evhttp_request_kind { EVHTTP_REQUEST, EVHTTP_RESPONSE };
  */
 EVENT2_EXPORT_SYMBOL
 struct evhttp_connection *evhttp_connection_base_bufferevent_new(
-       struct event_base *base, struct evdns_base *dnsbase, struct bufferevent* bev, const char *address, unsigned short port);
+       struct event_base *base, struct evdns_base *dnsbase, struct bufferevent* bev, const char *address, ev_uint16_t port);
 
 /**
  * Return the bufferevent that an evhttp_connection is using.
@@ -641,7 +641,7 @@ void evhttp_request_free(struct evhttp_request *req);
 EVENT2_EXPORT_SYMBOL
 struct evhttp_connection *evhttp_connection_base_new(
        struct event_base *base, struct evdns_base *dnsbase,
-       const char *address, unsigned short port);
+       const char *address, ev_uint16_t port);
 
 /**
  * Set family hint for DNS requests.
index 0d9af17f3feda103a0b9957a55589057e61b611a..43c2c43e46b5ef4a8547824738da48a0cbd8536c 100644 (file)
@@ -58,7 +58,7 @@ extern "C" {
  * @param port the port number on which the HTTP server should listen
  * @return an struct evhttp object
  */
-struct evhttp *evhttp_start(const char *address, unsigned short port);
+struct evhttp *evhttp_start(const char *address, ev_uint16_t port);
 
 /**
  * A connection object that can be used to for making HTTP requests.  The
@@ -68,7 +68,7 @@ struct evhttp *evhttp_start(const char *address, unsigned short port);
  * @deprecated It does not allow an event base to be specified
  */
 struct evhttp_connection *evhttp_connection_new(
-       const char *address, unsigned short port);
+       const char *address, ev_uint16_t port);
 
 /**
  * Associates an event base with the connection - can only be called
index cbb9c914dd8fd9e758419d6a5a43c5674cfe640e..99c249a24b7a1a4c69ae60e090eedcadec504e3e 100644 (file)
@@ -333,7 +333,7 @@ main(int argc, char **argv)
        struct evhttp *http;
        struct evhttp_bound_socket *handle;
 
-       unsigned short port = 0;
+       ev_uint16_t port = 0;
 #ifdef _WIN32
        WSADATA WSAData;
        WSAStartup(0x101, &WSAData);
index 0c46855f4f9497e654b690adccd303c5ad3dff8e..d20d3bc790108871d8970a0512c03287710ba180 100644 (file)
@@ -90,7 +90,7 @@ main(int argc, char **argv)
        int i;
        int c;
        int use_iocp = 0;
-       unsigned short port = 8080;
+       ev_uint16_t port = 8080;
        char *endptr = NULL;
 
 #ifdef _WIN32
index 6d6abe29d3c3bbd31e60b21dbadbe0e31e95ccb4..cfe85387a2cf2ee81197c9ab6cd44406cf92eb43 100644 (file)
@@ -164,7 +164,7 @@ http_setup(ev_uint16_t *pport, struct event_base *base, int mask)
 #endif
 
 static evutil_socket_t
-http_connect(const char *address, unsigned short port)
+http_connect(const char *address, ev_uint16_t port)
 {
        /* Stupid code for connecting */
        struct evutil_addrinfo ai, *aitop;