PS2SDK
PS2 Homebrew Libraries
netdb.c
1 /*
2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # Copyright ps2dev - http://www.ps2dev.org
7 # Licenced under Academic Free License version 2.0
8 # Review ps2sdk README & LICENSE files for further details.
9 */
10 
11 #define LIBCGLUE_SYS_SOCKET_NO_ALIASES
12 #define LIBCGLUE_ARPA_INET_NO_ALIASES
13 #include <ps2sdkapi.h>
14 #include <netdb.h>
15 
16 #include "ps2sdkapi.h"
17 
18 #ifdef F_gethostbyaddr
19 struct hostent *gethostbyaddr(const void *addr, int len, int type)
20 {
21  if (_libcglue_fdman_socket_ops == NULL || _libcglue_fdman_socket_ops->gethostbyaddr == NULL)
22  {
23  return NULL;
24  }
25 
26  return _libcglue_fdman_socket_ops->gethostbyaddr(addr, len, type);
27 }
28 #endif
29 
30 #ifdef F_gethostbyname
31 struct hostent *gethostbyname(const char *name)
32 {
33  if (_libcglue_fdman_socket_ops == NULL || _libcglue_fdman_socket_ops->gethostbyname == NULL)
34  {
35  return NULL;
36  }
37 
38  return _libcglue_fdman_socket_ops->gethostbyname(name);
39 }
40 #endif
41 
42 #ifdef F_gethostbyname_r
43 int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop)
44 {
45  if (_libcglue_fdman_socket_ops == NULL || _libcglue_fdman_socket_ops->gethostbyname_r == NULL)
46  {
47  if (h_errnop != NULL)
48  {
49  *h_errnop = NO_RECOVERY;
50  }
51  return -1;
52  }
53 
54  return _libcglue_fdman_socket_ops->gethostbyname_r(name, ret, buf, buflen, result, h_errnop);
55 }
56 #endif
57 
58 #ifdef F_freeaddrinfo
59 void freeaddrinfo(struct addrinfo *ai)
60 {
61  if (_libcglue_fdman_socket_ops == NULL || _libcglue_fdman_socket_ops->freeaddrinfo == NULL)
62  {
63  return;
64  }
65 
66  return _libcglue_fdman_socket_ops->freeaddrinfo(ai);
67 }
68 #endif
69 
70 #ifdef F_getaddrinfo
71 int getaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
72 {
73  if (_libcglue_fdman_socket_ops == NULL || _libcglue_fdman_socket_ops->getaddrinfo == NULL)
74  {
75  return EAI_FAIL;
76  }
77 
78  return _libcglue_fdman_socket_ops->getaddrinfo(nodename, servname, hints, res);
79 }
80 #endif
addrinfo
Definition: tcpip.h:1952
hostent
Definition: tcpip.h:1940