Mercurial > libavformat.hg
comparison tcp.c @ 2050:612d19cb9550 libavformat
move resolve_host from tcp.c to os_support.c as it is used widely
author | alex |
---|---|
date | Thu, 26 Apr 2007 18:04:42 +0000 |
parents | b6b8a9836cf9 |
children | eeea52739ff3 |
comparison
equal
deleted
inserted
replaced
2049:b6b8a9836cf9 | 2050:612d19cb9550 |
---|---|
25 #include <fcntl.h> | 25 #include <fcntl.h> |
26 | 26 |
27 typedef struct TCPContext { | 27 typedef struct TCPContext { |
28 int fd; | 28 int fd; |
29 } TCPContext; | 29 } TCPContext; |
30 | |
31 /* resolve host with also IP address parsing */ | |
32 int resolve_host(struct in_addr *sin_addr, const char *hostname) | |
33 { | |
34 struct hostent *hp; | |
35 | |
36 if (!inet_aton(hostname, sin_addr)) { | |
37 hp = gethostbyname(hostname); | |
38 if (!hp) | |
39 return -1; | |
40 memcpy(sin_addr, hp->h_addr, sizeof(struct in_addr)); | |
41 } | |
42 return 0; | |
43 } | |
44 | 30 |
45 /* return non zero if error */ | 31 /* return non zero if error */ |
46 static int tcp_open(URLContext *h, const char *uri, int flags) | 32 static int tcp_open(URLContext *h, const char *uri, int flags) |
47 { | 33 { |
48 struct sockaddr_in dest_addr; | 34 struct sockaddr_in dest_addr; |