]> git.sesse.net Git - ffmpeg/commitdiff
network: use getservbyport() only if available
authorMans Rullgard <mans@mansr.com>
Sun, 14 Oct 2012 19:24:51 +0000 (20:24 +0100)
committerMans Rullgard <mans@mansr.com>
Tue, 23 Oct 2012 11:00:21 +0000 (12:00 +0100)
The absence of this function will only give a less informative
string back from our fallback implementation of getnameinfo().

Signed-off-by: Mans Rullgard <mans@mansr.com>
configure
libavformat/os_support.c

index 996c7169e4eb27cb1d85c15e1b9cc95a3dbedb31..e1524fbf21253f5be8cba52924cb848d00faa9fb 100755 (executable)
--- a/configure
+++ b/configure
@@ -1190,6 +1190,7 @@ HAVE_LIST="
     GetProcessTimes
     GetSystemTimeAsFileTime
     getrusage
+    getservbyport
     gettimeofday
     gnu_as
     ibm_asm
@@ -3158,6 +3159,7 @@ if enabled network; then
     check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
     check_type netinet/sctp.h "struct sctp_event_subscribe"
     check_func getaddrinfo $network_extralibs
+    check_func getservbyport $network_extralibs
     # Prefer arpa/inet.h over winsock2
     if check_header arpa/inet.h ; then
         check_func closesocket
index 76187082836a5abb0d07b11efbcd98aa00a7d7f7..451801ff706200be4143a6af37b04045cd8c6adf 100644 (file)
@@ -235,8 +235,10 @@ int ff_getnameinfo(const struct sockaddr *sa, int salen,
 
     if (serv && servlen > 0) {
         struct servent *ent = NULL;
+#if HAVE_GETSERVBYPORT
         if (!(flags & NI_NUMERICSERV))
             ent = getservbyport(sin->sin_port, flags & NI_DGRAM ? "udp" : "tcp");
+#endif
 
         if (ent)
             snprintf(serv, servlen, "%s", ent->s_name);