aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/mingw/libsrc/wspiapi/WspiapiClone.c
blob: a29335e9f95bbf228dc7b3a8e8d337ef26ef5f1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#undef  __CRT__NO_INLINE
#define __CRT__NO_INLINE
#include <winsock2.h>
#include <wspiapi.h>

int WINAPI
WspiapiClone (WORD wPort, struct addrinfo *ptResult)
{
  struct addrinfo *p = NULL;
  struct addrinfo *n = NULL;

  for (p = ptResult; p != NULL;)
    {
	n = WspiapiNewAddrInfo (SOCK_DGRAM, p->ai_protocol, wPort,
				((struct sockaddr_in *) p->ai_addr)->sin_addr.s_addr);
	if (!n)
	  break;
	n->ai_next = p->ai_next;
	p->ai_next = n;
	p = n->ai_next;
    }
  if (p != NULL)
    return EAI_MEMORY;
  return 0;
}