Advertisement
Guest User

Untitled

a guest
Aug 28th, 2014
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.32 KB | None | 0 0
  1. /*
  2.  * (C) 2001-2012 Marmalade. All Rights Reserved.
  3.  *
  4.  * This document is protected by copyright, and contains information
  5.  * proprietary to Marmalade.
  6.  *
  7.  * This file consists of source code released by Marmalade under
  8.  * the terms of the accompanying End User License Agreement (EULA).
  9.  * Please do not use this program/source code before you have read the
  10.  * EULA and have agreed to be bound by its terms.
  11.  */
  12.  
  13. #ifndef IW_NETDB_H
  14. #define IW_NETDB_H
  15.  
  16. #include <sys/types.h>
  17. #include <sys/socket.h>
  18.  
  19. #define NETDB_INTERNAL   -1 /* see errno */
  20. #define NETDB_SUCCESS    0  /* no problem */
  21. #define HOST_NOT_FOUND   1  /* Authoritative Answer Host not found */
  22. #define TRY_AGAIN        2  /* Non-Authoritative Host not found, or SERVERFAIL */
  23. #define NO_RECOVERY      3  /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
  24. #define NO_DATA          4  /* Valid name, no data record of requested type */
  25. #define NO_ADDRESS       NO_DATA /* no address, look for MX record */
  26.  
  27. #define AI_PASSIVE      0x0001  /* Socket address is intended for `bind'.  */
  28. #define AI_CANONNAME    0x0002  /* Request for canonical name.  */
  29. #define AI_NUMERICHOST  0x0004  /* Don't use name resolution.  */
  30.  
  31. #define NI_NUMERICHOST  1   /* Don't try to look up hostname.  */
  32. #define NI_NUMERICSERV  2   /* Don't convert port number to name.  */
  33. #define NI_NOFQDN       4   /* Only return nodename portion.  */
  34. #define NI_NAMEREQD     8   /* Don't return numeric addresses.  */
  35. #define NI_DGRAM        16  /* Look up UDP service rather than TCP.  */
  36.  
  37. #define NI_MAXHOST      1025
  38. #define NI_MAXSERV      32
  39.  
  40. #define EAI_BADFLAGS   -1  /* Invalid value for `ai_flags' field.  */
  41. #define EAI_NONAME     -2  /* NAME or SERVICE is unknown.  */
  42. #define EAI_AGAIN      -3  /* Temporary failure in name resolution.  */
  43. #define EAI_FAIL       -4  /* Non-recoverable failure in name res.  */
  44. #define EAI_FAMILY     -6  /* `ai_family' not supported.  */
  45. #define EAI_SOCKTYPE   -7  /* `ai_socktype' not supported.  */
  46. #define EAI_SERVICE    -8  /* SERVICE not supported for `ai_socktype'.  */
  47. #define EAI_MEMORY     -10 /* Memory allocation failure.  */
  48. #define EAI_SYSTEM     -11 /* System error returned in `errno'.  */
  49. #define EAI_OVERFLOW   -12 /* Argument buffer overflow.  */
  50.  
  51. struct hostent
  52. {
  53.     char  *h_name;       /* official name of host */
  54.     char **h_aliases;    /* alias list */
  55.     int    h_addrtype;   /* host address type */
  56.     int    h_length;     /* length of address */
  57.     char **h_addr_list;  /* list of addresses */
  58. };
  59. #define h_addr  h_addr_list[0]
  60.  
  61. struct servent
  62. {
  63.     char  *s_name;    /* official service name */
  64.     char **s_aliases; /* alias list */
  65.     int    s_port;    /* port number */
  66.     char  *s_proto;   /* protocol to use */
  67. };
  68.  
  69. struct protoent
  70. {
  71.     char *p_name;     /* Official protocol name.  */
  72.     char **p_aliases; /* Alias list.  */
  73.     int p_proto;      /* Protocol number.  */
  74. };
  75.  
  76. struct addrinfo
  77. {
  78.     int              ai_flags;
  79.     int              ai_family;
  80.     int              ai_socktype;
  81.     int              ai_protocol;
  82.     size_t           ai_addrlen;
  83.     struct sockaddr *ai_addr;
  84.     char            *ai_canonname;
  85.     struct addrinfo *ai_next;
  86. };
  87.  
  88.  
  89. S3E_BEGIN_C_DECL
  90.  
  91. struct hostent *gethostbyname(const char *name);
  92. struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type);
  93. int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop);
  94.  
  95. struct protoent *getprotoent(void);
  96. struct protoent *getprotobyname(const char *name);
  97. struct protoent *getprotobynumber(int proto);
  98. void setprotoent(int stayopen);
  99. void endprotoent(void);
  100.  
  101. struct servent *getservent(void);
  102. struct servent *getservbyname(const char *name, const char *proto);
  103. struct servent *getservbyport(int port, const char *proto);
  104. void setservent(int stayopen);
  105. void endservent(void);
  106.  
  107. int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res);
  108. void freeaddrinfo(struct addrinfo *res);
  109. const char *gai_strerror(int errcode);
  110.  
  111. int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags);
  112.  
  113. #define H_ERRNO_NAME iw_h_errno
  114. extern int H_ERRNO_NAME;
  115. #define h_errno H_ERRNO_NAME
  116.  
  117. S3E_END_C_DECL
  118.  
  119. #endif /* !IW_NETDB_H */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement