diff options
author | Martin Storsjö <martin@martin.st> | 2010-01-25 01:28:01 +0000 |
---|---|---|
committer | Ramiro Polla <ramiro.polla@gmail.com> | 2010-01-25 01:28:01 +0000 |
commit | 6023d84a2b7aa6d5f02de91541c514c36e553de0 (patch) | |
tree | 5a4eba5b73ac660754fbc5ab9c0f8044d3fedb98 /libavformat | |
parent | 3debf366c865e4e0a7b5809c343bcb07ce3e8104 (diff) | |
download | ffmpeg-6023d84a2b7aa6d5f02de91541c514c36e553de0.tar.gz |
Load the proper getaddrinfo functions from ws2_32.dll, if they're present.
Patch by Martin Storsjö <martin at martin dot st>.
Originally committed as revision 21443 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/os_support.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/libavformat/os_support.c b/libavformat/os_support.c index 120f23469f..58215ec198 100644 --- a/libavformat/os_support.c +++ b/libavformat/os_support.c @@ -68,6 +68,16 @@ int ff_getaddrinfo(const char *node, const char *service, struct addrinfo *ai; struct sockaddr_in *sin; +#if HAVE_WINSOCK2_H + int (WSAAPI *win_getaddrinfo)(const char *node, const char *service, + const struct addrinfo *hints, + struct addrinfo **res); + HMODULE ws2mod = GetModuleHandle("ws2_32.dll"); + win_getaddrinfo = GetProcAddress(ws2mod, "getaddrinfo"); + if (win_getaddrinfo) + return win_getaddrinfo(node, service, hints, res); +#endif + sin = av_mallocz(sizeof(struct sockaddr_in)); if (!sin) return EAI_FAIL; @@ -124,6 +134,17 @@ int ff_getaddrinfo(const char *node, const char *service, void ff_freeaddrinfo(struct addrinfo *res) { +#if HAVE_WINSOCK2_H + void (WSAAPI *win_freeaddrinfo)(struct addrinfo *res); + HMODULE ws2mod = GetModuleHandle("ws2_32.dll"); + win_freeaddrinfo = (void (WSAAPI *)(struct addrinfo *res)) + GetProcAddress(ws2mod, "freeaddrinfo"); + if (win_freeaddrinfo) { + win_freeaddrinfo(res); + return; + } +#endif + av_free(res->ai_canonname); av_free(res->ai_addr); av_free(res); @@ -135,6 +156,16 @@ int ff_getnameinfo(const struct sockaddr *sa, int salen, { const struct sockaddr_in *sin = (const struct sockaddr_in *)sa; +#if HAVE_WINSOCK2_H + int (WSAAPI *win_getnameinfo)(const struct sockaddr *sa, socklen_t salen, + char *host, DWORD hostlen, + char *serv, DWORD servlen, int flags); + HMODULE ws2mod = GetModuleHandle("ws2_32.dll"); + win_getnameinfo = GetProcAddress(ws2mod, "getnameinfo"); + if (win_getnameinfo) + return win_getnameinfo(sa, salen, host, hostlen, serv, servlen, flags); +#endif + if (sa->sa_family != AF_INET) return EAI_FAMILY; if (!host && !serv) |