Revision 6023d84a libavformat/os_support.c

View differences:

libavformat/os_support.c
68 68
    struct addrinfo *ai;
69 69
    struct sockaddr_in *sin;
70 70

  
71
#if HAVE_WINSOCK2_H
72
    int (WSAAPI *win_getaddrinfo)(const char *node, const char *service,
73
                                  const struct addrinfo *hints,
74
                                  struct addrinfo **res);
75
    HMODULE ws2mod = GetModuleHandle("ws2_32.dll");
76
    win_getaddrinfo = GetProcAddress(ws2mod, "getaddrinfo");
77
    if (win_getaddrinfo)
78
        return win_getaddrinfo(node, service, hints, res);
79
#endif
80

  
71 81
    sin = av_mallocz(sizeof(struct sockaddr_in));
72 82
    if (!sin)
73 83
        return EAI_FAIL;
......
124 134

  
125 135
void ff_freeaddrinfo(struct addrinfo *res)
126 136
{
137
#if HAVE_WINSOCK2_H
138
    void (WSAAPI *win_freeaddrinfo)(struct addrinfo *res);
139
    HMODULE ws2mod = GetModuleHandle("ws2_32.dll");
140
    win_freeaddrinfo = (void (WSAAPI *)(struct addrinfo *res))
141
                       GetProcAddress(ws2mod, "freeaddrinfo");
142
    if (win_freeaddrinfo) {
143
        win_freeaddrinfo(res);
144
        return;
145
    }
146
#endif
147

  
127 148
    av_free(res->ai_canonname);
128 149
    av_free(res->ai_addr);
129 150
    av_free(res);
......
135 156
{
136 157
    const struct sockaddr_in *sin = (const struct sockaddr_in *)sa;
137 158

  
159
#if HAVE_WINSOCK2_H
160
    int (WSAAPI *win_getnameinfo)(const struct sockaddr *sa, socklen_t salen,
161
                                  char *host, DWORD hostlen,
162
                                  char *serv, DWORD servlen, int flags);
163
    HMODULE ws2mod = GetModuleHandle("ws2_32.dll");
164
    win_getnameinfo = GetProcAddress(ws2mod, "getnameinfo");
165
    if (win_getnameinfo)
166
        return win_getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
167
#endif
168

  
138 169
    if (sa->sa_family != AF_INET)
139 170
        return EAI_FAMILY;
140 171
    if (!host && !serv)

Also available in: Unified diff