From 0392773d57e3fca5efade2298d641c22202d624a Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Thu, 29 Jan 2009 22:18:47 +0100 Subject: pingu: make it work --- xlib.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'xlib.c') diff --git a/xlib.c b/xlib.c index d8392c1..e48ec39 100644 --- a/xlib.c +++ b/xlib.c @@ -1,4 +1,9 @@ +#include +#include +#include + +#include #include #include #include @@ -29,3 +34,17 @@ char *xstrdup(const char *str) return s; } +int init_sockaddr(struct sockaddr_in *addr, const char *host) +{ + memset((char *) addr, 0, sizeof(struct sockaddr_in)); + addr->sin_family = AF_INET; + if (inet_aton(host, &addr->sin_addr) == 0) { + struct hostent *hp; + hp = gethostbyname(host); + if (!hp) + return -1; + memcpy(&addr->sin_addr, hp->h_addr, 4); + } + return 0; +} + -- cgit v1.2.3