Skip to content

Commit

Permalink
Move uv_ip4_addr to uv-common.c
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jun 17, 2011
1 parent 8218146 commit b7b7df0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
14 changes: 14 additions & 0 deletions uv-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <assert.h>
#include <stddef.h> /* NULL */
#include <string.h> /* memset */


static uv_counters_t counters;
Expand Down Expand Up @@ -75,3 +76,16 @@ const char* uv_err_name(uv_err_t err) {
return NULL;
}
}


struct sockaddr_in uv_ip4_addr(const char* ip, int port) {
struct sockaddr_in addr;

memset(&addr, 0, sizeof(struct sockaddr_in));

addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = inet_addr(ip);

return addr;
}
13 changes: 0 additions & 13 deletions uv-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,6 @@ static uv_err_t uv_err_new(uv_handle_t* handle, int sys_error) {
}


struct sockaddr_in uv_ip4_addr(const char* ip, int port) {
struct sockaddr_in addr;

memset(&addr, 0, sizeof(struct sockaddr_in));

addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = inet_addr(ip);

return addr;
}


int uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
uv_tcp_t* tcp;
uv_async_t* async;
Expand Down
11 changes: 0 additions & 11 deletions uv-win.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,17 +705,6 @@ int uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
}


struct sockaddr_in uv_ip4_addr(const char* ip, int port) {
struct sockaddr_in addr;

addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = inet_addr(ip);

return addr;
}


int uv_bind(uv_tcp_t* handle, struct sockaddr_in addr) {
DWORD err;
int r;
Expand Down

0 comments on commit b7b7df0

Please sign in to comment.