PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/include/netdb.lua

http://github.com/chatid/fend
Lua | 228 lines | 222 code | 6 blank | 0 comment | 0 complexity | 7d0161f8130e96c8c56ecaa0f51debed MD5 | raw file
  1. include "netinet/in"
  2. ffi.cdef [[
  3. extern int *__h_errno_location (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
  4. extern void herror (__const char *__str) __attribute__ ((__nothrow__ , __leaf__));
  5. extern __const char *hstrerror (int __err_num) __attribute__ ((__nothrow__ , __leaf__));
  6. struct hostent
  7. {
  8. char *h_name;
  9. char **h_aliases;
  10. int h_addrtype;
  11. int h_length;
  12. char **h_addr_list;
  13. };
  14. extern void sethostent (int __stay_open);
  15. extern void endhostent (void);
  16. extern struct hostent *gethostent (void);
  17. extern struct hostent *gethostbyaddr (__const void *__addr, __socklen_t __len,
  18. int __type);
  19. extern struct hostent *gethostbyname (__const char *__name);
  20. extern struct hostent *gethostbyname2 (__const char *__name, int __af);
  21. extern int gethostent_r (struct hostent *__restrict __result_buf,
  22. char *__restrict __buf, size_t __buflen,
  23. struct hostent **__restrict __result,
  24. int *__restrict __h_errnop);
  25. extern int gethostbyaddr_r (__const void *__restrict __addr, __socklen_t __len,
  26. int __type,
  27. struct hostent *__restrict __result_buf,
  28. char *__restrict __buf, size_t __buflen,
  29. struct hostent **__restrict __result,
  30. int *__restrict __h_errnop);
  31. extern int gethostbyname_r (__const char *__restrict __name,
  32. struct hostent *__restrict __result_buf,
  33. char *__restrict __buf, size_t __buflen,
  34. struct hostent **__restrict __result,
  35. int *__restrict __h_errnop);
  36. extern int gethostbyname2_r (__const char *__restrict __name, int __af,
  37. struct hostent *__restrict __result_buf,
  38. char *__restrict __buf, size_t __buflen,
  39. struct hostent **__restrict __result,
  40. int *__restrict __h_errnop);
  41. extern void setnetent (int __stay_open);
  42. extern void endnetent (void);
  43. extern struct netent *getnetent (void);
  44. extern struct netent *getnetbyaddr (uint32_t __net, int __type);
  45. extern struct netent *getnetbyname (__const char *__name);
  46. extern int getnetent_r (struct netent *__restrict __result_buf,
  47. char *__restrict __buf, size_t __buflen,
  48. struct netent **__restrict __result,
  49. int *__restrict __h_errnop);
  50. extern int getnetbyaddr_r (uint32_t __net, int __type,
  51. struct netent *__restrict __result_buf,
  52. char *__restrict __buf, size_t __buflen,
  53. struct netent **__restrict __result,
  54. int *__restrict __h_errnop);
  55. extern int getnetbyname_r (__const char *__restrict __name,
  56. struct netent *__restrict __result_buf,
  57. char *__restrict __buf, size_t __buflen,
  58. struct netent **__restrict __result,
  59. int *__restrict __h_errnop);
  60. struct servent
  61. {
  62. char *s_name;
  63. char **s_aliases;
  64. int s_port;
  65. char *s_proto;
  66. };
  67. extern void setservent (int __stay_open);
  68. extern void endservent (void);
  69. extern struct servent *getservent (void);
  70. extern struct servent *getservbyname (__const char *__name,
  71. __const char *__proto);
  72. extern struct servent *getservbyport (int __port, __const char *__proto);
  73. extern int getservent_r (struct servent *__restrict __result_buf,
  74. char *__restrict __buf, size_t __buflen,
  75. struct servent **__restrict __result);
  76. extern int getservbyname_r (__const char *__restrict __name,
  77. __const char *__restrict __proto,
  78. struct servent *__restrict __result_buf,
  79. char *__restrict __buf, size_t __buflen,
  80. struct servent **__restrict __result);
  81. extern int getservbyport_r (int __port, __const char *__restrict __proto,
  82. struct servent *__restrict __result_buf,
  83. char *__restrict __buf, size_t __buflen,
  84. struct servent **__restrict __result);
  85. struct protoent
  86. {
  87. char *p_name;
  88. char **p_aliases;
  89. int p_proto;
  90. };
  91. extern void setprotoent (int __stay_open);
  92. extern void endprotoent (void);
  93. extern struct protoent *getprotoent (void);
  94. extern struct protoent *getprotobyname (__const char *__name);
  95. extern struct protoent *getprotobynumber (int __proto);
  96. extern int getprotoent_r (struct protoent *__restrict __result_buf,
  97. char *__restrict __buf, size_t __buflen,
  98. struct protoent **__restrict __result);
  99. extern int getprotobyname_r (__const char *__restrict __name,
  100. struct protoent *__restrict __result_buf,
  101. char *__restrict __buf, size_t __buflen,
  102. struct protoent **__restrict __result);
  103. extern int getprotobynumber_r (int __proto,
  104. struct protoent *__restrict __result_buf,
  105. char *__restrict __buf, size_t __buflen,
  106. struct protoent **__restrict __result);
  107. extern int setnetgrent (__const char *__netgroup);
  108. extern void endnetgrent (void);
  109. extern int getnetgrent (char **__restrict __hostp,
  110. char **__restrict __userp,
  111. char **__restrict __domainp);
  112. extern int innetgr (__const char *__netgroup, __const char *__host,
  113. __const char *__user, __const char *__domain);
  114. extern int getnetgrent_r (char **__restrict __hostp,
  115. char **__restrict __userp,
  116. char **__restrict __domainp,
  117. char *__restrict __buffer, size_t __buflen);
  118. extern int rcmd (char **__restrict __ahost, unsigned short int __rport,
  119. __const char *__restrict __locuser,
  120. __const char *__restrict __remuser,
  121. __const char *__restrict __cmd, int *__restrict __fd2p);
  122. extern int rcmd_af (char **__restrict __ahost, unsigned short int __rport,
  123. __const char *__restrict __locuser,
  124. __const char *__restrict __remuser,
  125. __const char *__restrict __cmd, int *__restrict __fd2p,
  126. sa_family_t __af);
  127. extern int rexec (char **__restrict __ahost, int __rport,
  128. __const char *__restrict __name,
  129. __const char *__restrict __pass,
  130. __const char *__restrict __cmd, int *__restrict __fd2p);
  131. extern int rexec_af (char **__restrict __ahost, int __rport,
  132. __const char *__restrict __name,
  133. __const char *__restrict __pass,
  134. __const char *__restrict __cmd, int *__restrict __fd2p,
  135. sa_family_t __af);
  136. extern int ruserok (__const char *__rhost, int __suser,
  137. __const char *__remuser, __const char *__locuser);
  138. extern int ruserok_af (__const char *__rhost, int __suser,
  139. __const char *__remuser, __const char *__locuser,
  140. sa_family_t __af);
  141. extern int iruserok (uint32_t __raddr, int __suser,
  142. __const char *__remuser, __const char *__locuser);
  143. extern int iruserok_af (__const void *__raddr, int __suser,
  144. __const char *__remuser, __const char *__locuser,
  145. sa_family_t __af);
  146. extern int rresvport (int *__alport);
  147. extern int rresvport_af (int *__alport, sa_family_t __af);
  148. struct addrinfo
  149. {
  150. int ai_flags;
  151. int ai_family;
  152. int ai_socktype;
  153. int ai_protocol;
  154. socklen_t ai_addrlen;
  155. struct sockaddr *ai_addr;
  156. char *ai_canonname;
  157. struct addrinfo *ai_next;
  158. };
  159. struct gaicb
  160. {
  161. const char *ar_name;
  162. const char *ar_service;
  163. const struct addrinfo *ar_request;
  164. struct addrinfo *ar_result;
  165. int __return;
  166. int __unused[5];
  167. };
  168. extern int getaddrinfo (__const char *__restrict __name,
  169. __const char *__restrict __service,
  170. __const struct addrinfo *__restrict __req,
  171. struct addrinfo **__restrict __pai);
  172. extern void freeaddrinfo (struct addrinfo *__ai) __attribute__ ((__nothrow__ , __leaf__));
  173. extern __const char *gai_strerror (int __ecode) __attribute__ ((__nothrow__ , __leaf__));
  174. extern int getnameinfo (__const struct sockaddr *__restrict __sa,
  175. socklen_t __salen, char *__restrict __host,
  176. socklen_t __hostlen, char *__restrict __serv,
  177. socklen_t __servlen, int __flags);
  178. extern int getaddrinfo_a (int __mode, struct gaicb *__list[__restrict],
  179. int __ent, struct sigevent *__restrict __sig);
  180. extern int gai_suspend (__const struct gaicb *__const __list[], int __ent,
  181. __const struct timespec *__timeout);
  182. extern int gai_error (struct gaicb *__req) __attribute__ ((__nothrow__ , __leaf__));
  183. extern int gai_cancel (struct gaicb *__gaicbp) __attribute__ ((__nothrow__ , __leaf__));
  184. ]]
  185. GAI_WAIT = 0
  186. GAI_NOWAIT = 1
  187. AI_PASSIVE = 0x0001 -- Socket address is intended for `bind'.
  188. AI_CANONNAME = 0x0002 -- Request for canonical name.
  189. AI_NUMERICHOST = 0x0004 -- Don't use name resolution.
  190. AI_V4MAPPED = 0x0008 -- IPv4 mapped addresses are acceptable.
  191. AI_ALL = 0x0010 -- Return IPv4 mapped and IPv6 addresses.
  192. AI_ADDRCONFIG = 0x0020 -- Use configuration of this host to choose returned address type..
  193. AI_IDN = 0x0040 -- IDN encode input (assuming it is encoded in the current locale's character set) before looking it up.
  194. AI_CANONIDN = 0x0080 -- Translate canonical name from IDN format.
  195. AI_IDN_ALLOW_UNASSIGNED = 0x0100 -- Don't reject unassigned Unicode code points.
  196. AI_IDN_USE_STD3_ASCII_RULES = 0x0200 -- Validate strings according to STD3 rules.
  197. AI_NUMERICSERV = 0x0400 -- Don't use name resolution.
  198. EAI_BADFLAGS = -1 -- Invalid value for `ai_flags' field.
  199. EAI_NONAME = -2 -- NAME or SERVICE is unknown.
  200. EAI_AGAIN = -3 -- Temporary failure in name resolution.
  201. EAI_FAIL = -4 -- Non-recoverable failure in name res.
  202. EAI_FAMILY = -6 -- `ai_family' not supported.
  203. EAI_SOCKTYPE = -7 -- `ai_socktype' not supported.
  204. EAI_SERVICE = -8 -- SERVICE not supported for `ai_socktype'.
  205. EAI_MEMORY = -10 -- Memory allocation failure.
  206. EAI_SYSTEM = -11 -- System error returned in `errno'.
  207. EAI_OVERFLOW = -12 -- Argument buffer overflow.
  208. EAI_NODATA = -5 -- No address associated with NAME.
  209. EAI_ADDRFAMILY = -9 -- Address family for NAME not supported.
  210. EAI_INPROGRESS = -100 -- Processing request in progress.
  211. EAI_CANCELED = -101 -- Request canceled.
  212. EAI_NOTCANCELED = -102 -- Request not canceled.
  213. EAI_ALLDONE = -103 -- All requests done.
  214. EAI_INTR = -104 -- Interrupted by a signal.
  215. EAI_IDN_ENCODE = -105 -- IDN encoding failed.
  216. NI_MAXSERV = 32
  217. NI_MAXHOST = 1025
  218. NI_NUMERICHOST = 1
  219. NI_NUMERICSERV = 2
  220. NI_NOFQDN = 4
  221. NI_NAMEREQD = 8
  222. NI_DGRAM = 16