[FFmpeg-devel] [PATCH] Move resolve_host() to ffserver.c
Mans Rullgard
mans
Mon Mar 8 17:55:55 CET 2010
This deprecated function is only used by ffserver, yet does not have
a prototype visible there.
In the long term, ffserver should be made IPv6-aware. In the meantime,
this change removes cruft from lavf and fixes some warnings in ffserver.
---
ffserver.c | 36 ++++++++++++++++++++++++++++++++++++
libavformat/avformat.h | 4 ----
libavformat/os_support.c | 35 -----------------------------------
3 files changed, 36 insertions(+), 39 deletions(-)
diff --git a/ffserver.c b/ffserver.c
index 1ab4bdd..bebb87c 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -312,6 +312,42 @@ static AVLFG random_state;
static FILE *logfile = NULL;
+/* FIXME: make ffserver work with IPv6 */
+/* resolve host with also IP address parsing */
+static int resolve_host(struct in_addr *sin_addr, const char *hostname)
+{
+
+ if (!ff_inet_aton(hostname, sin_addr)) {
+#if HAVE_GETADDRINFO
+ struct addrinfo *ai, *cur;
+ struct addrinfo hints;
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET;
+ if (getaddrinfo(hostname, NULL, &hints, &ai))
+ return -1;
+ /* getaddrinfo returns a linked list of addrinfo structs.
+ * Even if we set ai_family = AF_INET above, make sure
+ * that the returned one actually is of the correct type. */
+ for (cur = ai; cur; cur = cur->ai_next) {
+ if (cur->ai_family == AF_INET) {
+ *sin_addr = ((struct sockaddr_in *)cur->ai_addr)->sin_addr;
+ freeaddrinfo(ai);
+ return 0;
+ }
+ }
+ freeaddrinfo(ai);
+ return -1;
+#else
+ struct hostent *hp;
+ hp = gethostbyname(hostname);
+ if (!hp)
+ return -1;
+ memcpy(sin_addr, hp->h_addr_list[0], sizeof(struct in_addr));
+#endif
+ }
+ return 0;
+}
+
static char *ctime1(char *buf2)
{
time_t ti;
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 309d28a..eda556e 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1339,10 +1339,6 @@ struct tm *brktimegm(time_t secs, struct tm *tm);
const char *small_strptime(const char *p, const char *fmt,
struct tm *dt);
-struct in_addr;
-/* Deprecated, use getaddrinfo instead. */
-attribute_deprecated int resolve_host(struct in_addr *sin_addr, const char *hostname);
-
/**
* Splits a URL string into components. To reassemble components back into
* a URL, use ff_url_join instead of using snprintf directly.
diff --git a/libavformat/os_support.c b/libavformat/os_support.c
index 4b8e16d..2786303 100644
--- a/libavformat/os_support.c
+++ b/libavformat/os_support.c
@@ -223,41 +223,6 @@ const char *ff_gai_strerror(int ecode)
}
#endif
-/* resolve host with also IP address parsing */
-int resolve_host(struct in_addr *sin_addr, const char *hostname)
-{
-
- if (!ff_inet_aton(hostname, sin_addr)) {
-#if HAVE_GETADDRINFO
- struct addrinfo *ai, *cur;
- struct addrinfo hints;
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_INET;
- if (getaddrinfo(hostname, NULL, &hints, &ai))
- return -1;
- /* getaddrinfo returns a linked list of addrinfo structs.
- * Even if we set ai_family = AF_INET above, make sure
- * that the returned one actually is of the correct type. */
- for (cur = ai; cur; cur = cur->ai_next) {
- if (cur->ai_family == AF_INET) {
- *sin_addr = ((struct sockaddr_in *)cur->ai_addr)->sin_addr;
- freeaddrinfo(ai);
- return 0;
- }
- }
- freeaddrinfo(ai);
- return -1;
-#else
- struct hostent *hp;
- hp = gethostbyname(hostname);
- if (!hp)
- return -1;
- memcpy(sin_addr, hp->h_addr_list[0], sizeof(struct in_addr));
-#endif
- }
- return 0;
-}
-
int ff_socket_nonblock(int socket, int enable)
{
#if HAVE_WINSOCK2_H
--
1.7.0.2
More information about the ffmpeg-devel
mailing list