Browse code

Move resolve_host() to ffserver.c

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.

Originally committed as revision 22329 to svn://svn.ffmpeg.org/ffmpeg/trunk

Måns Rullgård authored on 2010/03/09 03:43:27
Showing 3 changed files
... ...
@@ -312,6 +312,42 @@ static AVLFG random_state;
312 312
 
313 313
 static FILE *logfile = NULL;
314 314
 
315
+/* FIXME: make ffserver work with IPv6 */
316
+/* resolve host with also IP address parsing */
317
+static int resolve_host(struct in_addr *sin_addr, const char *hostname)
318
+{
319
+
320
+    if (!ff_inet_aton(hostname, sin_addr)) {
321
+#if HAVE_GETADDRINFO
322
+        struct addrinfo *ai, *cur;
323
+        struct addrinfo hints;
324
+        memset(&hints, 0, sizeof(hints));
325
+        hints.ai_family = AF_INET;
326
+        if (getaddrinfo(hostname, NULL, &hints, &ai))
327
+            return -1;
328
+        /* getaddrinfo returns a linked list of addrinfo structs.
329
+         * Even if we set ai_family = AF_INET above, make sure
330
+         * that the returned one actually is of the correct type. */
331
+        for (cur = ai; cur; cur = cur->ai_next) {
332
+            if (cur->ai_family == AF_INET) {
333
+                *sin_addr = ((struct sockaddr_in *)cur->ai_addr)->sin_addr;
334
+                freeaddrinfo(ai);
335
+                return 0;
336
+            }
337
+        }
338
+        freeaddrinfo(ai);
339
+        return -1;
340
+#else
341
+        struct hostent *hp;
342
+        hp = gethostbyname(hostname);
343
+        if (!hp)
344
+            return -1;
345
+        memcpy(sin_addr, hp->h_addr_list[0], sizeof(struct in_addr));
346
+#endif
347
+    }
348
+    return 0;
349
+}
350
+
315 351
 static char *ctime1(char *buf2)
316 352
 {
317 353
     time_t ti;
... ...
@@ -1339,10 +1339,6 @@ struct tm *brktimegm(time_t secs, struct tm *tm);
1339 1339
 const char *small_strptime(const char *p, const char *fmt,
1340 1340
                            struct tm *dt);
1341 1341
 
1342
-struct in_addr;
1343
-/* Deprecated, use getaddrinfo instead. */
1344
-attribute_deprecated int resolve_host(struct in_addr *sin_addr, const char *hostname);
1345
-
1346 1342
 /**
1347 1343
  * Splits a URL string into components. To reassemble components back into
1348 1344
  * a URL, use ff_url_join instead of using snprintf directly.
... ...
@@ -223,41 +223,6 @@ const char *ff_gai_strerror(int ecode)
223 223
 }
224 224
 #endif
225 225
 
226
-/* resolve host with also IP address parsing */
227
-int resolve_host(struct in_addr *sin_addr, const char *hostname)
228
-{
229
-
230
-    if (!ff_inet_aton(hostname, sin_addr)) {
231
-#if HAVE_GETADDRINFO
232
-        struct addrinfo *ai, *cur;
233
-        struct addrinfo hints;
234
-        memset(&hints, 0, sizeof(hints));
235
-        hints.ai_family = AF_INET;
236
-        if (getaddrinfo(hostname, NULL, &hints, &ai))
237
-            return -1;
238
-        /* getaddrinfo returns a linked list of addrinfo structs.
239
-         * Even if we set ai_family = AF_INET above, make sure
240
-         * that the returned one actually is of the correct type. */
241
-        for (cur = ai; cur; cur = cur->ai_next) {
242
-            if (cur->ai_family == AF_INET) {
243
-                *sin_addr = ((struct sockaddr_in *)cur->ai_addr)->sin_addr;
244
-                freeaddrinfo(ai);
245
-                return 0;
246
-            }
247
-        }
248
-        freeaddrinfo(ai);
249
-        return -1;
250
-#else
251
-        struct hostent *hp;
252
-        hp = gethostbyname(hostname);
253
-        if (!hp)
254
-            return -1;
255
-        memcpy(sin_addr, hp->h_addr_list[0], sizeof(struct in_addr));
256
-#endif
257
-    }
258
-    return 0;
259
-}
260
-
261 226
 int ff_socket_nonblock(int socket, int enable)
262 227
 {
263 228
 #if HAVE_WINSOCK2_H