From 383eda234879aad7e90fe73c52574ef7e735f85c Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 26 Apr 2007 18:04:42 +0000 Subject: [PATCH] move resolve_host from tcp.c to os_support.c as it is used widely Originally committed as revision 8834 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavformat/os_support.c | 23 ++++++++++++++++++++--- libavformat/tcp.c | 14 -------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/libavformat/os_support.c b/libavformat/os_support.c index 5bd9e58b68..9dddab2f15 100644 --- a/libavformat/os_support.c +++ b/libavformat/os_support.c @@ -71,10 +71,12 @@ struct tm *localtime_r(const time_t *t, struct tm *tp) } #endif /* !defined(HAVE_LOCALTIME_R) */ -#if !defined(HAVE_INET_ATON) && defined(CONFIG_NETWORK) +#ifdef CONFIG_NETWORK +#include "network.h" + +#if !defined(HAVE_INET_ATON) #include #include -#include "network.h" int inet_aton (const char * str, struct in_addr * add) { @@ -97,7 +99,22 @@ done: return 1; } -#endif /* !defined(HAVE_INET_ATON) && defined(CONFIG_NETWORK) */ +#endif /* !defined(HAVE_INET_ATON) */ + +/* resolve host with also IP address parsing */ +int resolve_host(struct in_addr *sin_addr, const char *hostname) +{ + struct hostent *hp; + + if (!inet_aton(hostname, sin_addr)) { + hp = gethostbyname(hostname); + if (!hp) + return -1; + memcpy(sin_addr, hp->h_addr, sizeof(struct in_addr)); + } + return 0; +} +#endif /* CONFIG_NETWORK */ #ifdef CONFIG_FFSERVER #ifndef HAVE_SYS_POLL_H diff --git a/libavformat/tcp.c b/libavformat/tcp.c index 3f46b791a5..40aba66a2d 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -28,20 +28,6 @@ typedef struct TCPContext { int fd; } TCPContext; -/* resolve host with also IP address parsing */ -int resolve_host(struct in_addr *sin_addr, const char *hostname) -{ - struct hostent *hp; - - if (!inet_aton(hostname, sin_addr)) { - hp = gethostbyname(hostname); - if (!hp) - return -1; - memcpy(sin_addr, hp->h_addr, sizeof(struct in_addr)); - } - return 0; -} - /* return non zero if error */ static int tcp_open(URLContext *h, const char *uri, int flags) { -- GitLab