/include/netdb.lua
http://github.com/chatid/fend · Lua · 228 lines · 227 code · 1 blank · 0 comment · 0 complexity · 7d0161f8130e96c8c56ecaa0f51debed MD5 · raw file
- include "netinet/in"
- ffi.cdef [[
- extern int *__h_errno_location (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
- extern void herror (__const char *__str) __attribute__ ((__nothrow__ , __leaf__));
- extern __const char *hstrerror (int __err_num) __attribute__ ((__nothrow__ , __leaf__));
- struct hostent
- {
- char *h_name;
- char **h_aliases;
- int h_addrtype;
- int h_length;
- char **h_addr_list;
- };
- extern void sethostent (int __stay_open);
- extern void endhostent (void);
- extern struct hostent *gethostent (void);
- extern struct hostent *gethostbyaddr (__const void *__addr, __socklen_t __len,
- int __type);
- extern struct hostent *gethostbyname (__const char *__name);
- extern struct hostent *gethostbyname2 (__const char *__name, int __af);
- extern int gethostent_r (struct hostent *__restrict __result_buf,
- char *__restrict __buf, size_t __buflen,
- struct hostent **__restrict __result,
- int *__restrict __h_errnop);
- extern int gethostbyaddr_r (__const void *__restrict __addr, __socklen_t __len,
- int __type,
- struct hostent *__restrict __result_buf,
- char *__restrict __buf, size_t __buflen,
- struct hostent **__restrict __result,
- int *__restrict __h_errnop);
- extern int gethostbyname_r (__const char *__restrict __name,
- struct hostent *__restrict __result_buf,
- char *__restrict __buf, size_t __buflen,
- struct hostent **__restrict __result,
- int *__restrict __h_errnop);
- extern int gethostbyname2_r (__const char *__restrict __name, int __af,
- struct hostent *__restrict __result_buf,
- char *__restrict __buf, size_t __buflen,
- struct hostent **__restrict __result,
- int *__restrict __h_errnop);
- extern void setnetent (int __stay_open);
- extern void endnetent (void);
- extern struct netent *getnetent (void);
- extern struct netent *getnetbyaddr (uint32_t __net, int __type);
- extern struct netent *getnetbyname (__const char *__name);
- extern int getnetent_r (struct netent *__restrict __result_buf,
- char *__restrict __buf, size_t __buflen,
- struct netent **__restrict __result,
- int *__restrict __h_errnop);
- extern int getnetbyaddr_r (uint32_t __net, int __type,
- struct netent *__restrict __result_buf,
- char *__restrict __buf, size_t __buflen,
- struct netent **__restrict __result,
- int *__restrict __h_errnop);
- extern int getnetbyname_r (__const char *__restrict __name,
- struct netent *__restrict __result_buf,
- char *__restrict __buf, size_t __buflen,
- struct netent **__restrict __result,
- int *__restrict __h_errnop);
- struct servent
- {
- char *s_name;
- char **s_aliases;
- int s_port;
- char *s_proto;
- };
- extern void setservent (int __stay_open);
- extern void endservent (void);
- extern struct servent *getservent (void);
- extern struct servent *getservbyname (__const char *__name,
- __const char *__proto);
- extern struct servent *getservbyport (int __port, __const char *__proto);
- extern int getservent_r (struct servent *__restrict __result_buf,
- char *__restrict __buf, size_t __buflen,
- struct servent **__restrict __result);
- extern int getservbyname_r (__const char *__restrict __name,
- __const char *__restrict __proto,
- struct servent *__restrict __result_buf,
- char *__restrict __buf, size_t __buflen,
- struct servent **__restrict __result);
- extern int getservbyport_r (int __port, __const char *__restrict __proto,
- struct servent *__restrict __result_buf,
- char *__restrict __buf, size_t __buflen,
- struct servent **__restrict __result);
- struct protoent
- {
- char *p_name;
- char **p_aliases;
- int p_proto;
- };
- extern void setprotoent (int __stay_open);
- extern void endprotoent (void);
- extern struct protoent *getprotoent (void);
- extern struct protoent *getprotobyname (__const char *__name);
- extern struct protoent *getprotobynumber (int __proto);
- extern int getprotoent_r (struct protoent *__restrict __result_buf,
- char *__restrict __buf, size_t __buflen,
- struct protoent **__restrict __result);
- extern int getprotobyname_r (__const char *__restrict __name,
- struct protoent *__restrict __result_buf,
- char *__restrict __buf, size_t __buflen,
- struct protoent **__restrict __result);
- extern int getprotobynumber_r (int __proto,
- struct protoent *__restrict __result_buf,
- char *__restrict __buf, size_t __buflen,
- struct protoent **__restrict __result);
- extern int setnetgrent (__const char *__netgroup);
- extern void endnetgrent (void);
- extern int getnetgrent (char **__restrict __hostp,
- char **__restrict __userp,
- char **__restrict __domainp);
- extern int innetgr (__const char *__netgroup, __const char *__host,
- __const char *__user, __const char *__domain);
- extern int getnetgrent_r (char **__restrict __hostp,
- char **__restrict __userp,
- char **__restrict __domainp,
- char *__restrict __buffer, size_t __buflen);
- extern int rcmd (char **__restrict __ahost, unsigned short int __rport,
- __const char *__restrict __locuser,
- __const char *__restrict __remuser,
- __const char *__restrict __cmd, int *__restrict __fd2p);
- extern int rcmd_af (char **__restrict __ahost, unsigned short int __rport,
- __const char *__restrict __locuser,
- __const char *__restrict __remuser,
- __const char *__restrict __cmd, int *__restrict __fd2p,
- sa_family_t __af);
- extern int rexec (char **__restrict __ahost, int __rport,
- __const char *__restrict __name,
- __const char *__restrict __pass,
- __const char *__restrict __cmd, int *__restrict __fd2p);
- extern int rexec_af (char **__restrict __ahost, int __rport,
- __const char *__restrict __name,
- __const char *__restrict __pass,
- __const char *__restrict __cmd, int *__restrict __fd2p,
- sa_family_t __af);
- extern int ruserok (__const char *__rhost, int __suser,
- __const char *__remuser, __const char *__locuser);
- extern int ruserok_af (__const char *__rhost, int __suser,
- __const char *__remuser, __const char *__locuser,
- sa_family_t __af);
- extern int iruserok (uint32_t __raddr, int __suser,
- __const char *__remuser, __const char *__locuser);
- extern int iruserok_af (__const void *__raddr, int __suser,
- __const char *__remuser, __const char *__locuser,
- sa_family_t __af);
- extern int rresvport (int *__alport);
- extern int rresvport_af (int *__alport, sa_family_t __af);
- struct addrinfo
- {
- int ai_flags;
- int ai_family;
- int ai_socktype;
- int ai_protocol;
- socklen_t ai_addrlen;
- struct sockaddr *ai_addr;
- char *ai_canonname;
- struct addrinfo *ai_next;
- };
- struct gaicb
- {
- const char *ar_name;
- const char *ar_service;
- const struct addrinfo *ar_request;
- struct addrinfo *ar_result;
- int __return;
- int __unused[5];
- };
- extern int getaddrinfo (__const char *__restrict __name,
- __const char *__restrict __service,
- __const struct addrinfo *__restrict __req,
- struct addrinfo **__restrict __pai);
- extern void freeaddrinfo (struct addrinfo *__ai) __attribute__ ((__nothrow__ , __leaf__));
- extern __const char *gai_strerror (int __ecode) __attribute__ ((__nothrow__ , __leaf__));
- extern int getnameinfo (__const struct sockaddr *__restrict __sa,
- socklen_t __salen, char *__restrict __host,
- socklen_t __hostlen, char *__restrict __serv,
- socklen_t __servlen, int __flags);
- extern int getaddrinfo_a (int __mode, struct gaicb *__list[__restrict],
- int __ent, struct sigevent *__restrict __sig);
- extern int gai_suspend (__const struct gaicb *__const __list[], int __ent,
- __const struct timespec *__timeout);
- extern int gai_error (struct gaicb *__req) __attribute__ ((__nothrow__ , __leaf__));
- extern int gai_cancel (struct gaicb *__gaicbp) __attribute__ ((__nothrow__ , __leaf__));
- ]]
- GAI_WAIT = 0
- GAI_NOWAIT = 1
- AI_PASSIVE = 0x0001 -- Socket address is intended for `bind'.
- AI_CANONNAME = 0x0002 -- Request for canonical name.
- AI_NUMERICHOST = 0x0004 -- Don't use name resolution.
- AI_V4MAPPED = 0x0008 -- IPv4 mapped addresses are acceptable.
- AI_ALL = 0x0010 -- Return IPv4 mapped and IPv6 addresses.
- AI_ADDRCONFIG = 0x0020 -- Use configuration of this host to choose returned address type..
- AI_IDN = 0x0040 -- IDN encode input (assuming it is encoded in the current locale's character set) before looking it up.
- AI_CANONIDN = 0x0080 -- Translate canonical name from IDN format.
- AI_IDN_ALLOW_UNASSIGNED = 0x0100 -- Don't reject unassigned Unicode code points.
- AI_IDN_USE_STD3_ASCII_RULES = 0x0200 -- Validate strings according to STD3 rules.
- AI_NUMERICSERV = 0x0400 -- Don't use name resolution.
- EAI_BADFLAGS = -1 -- Invalid value for `ai_flags' field.
- EAI_NONAME = -2 -- NAME or SERVICE is unknown.
- EAI_AGAIN = -3 -- Temporary failure in name resolution.
- EAI_FAIL = -4 -- Non-recoverable failure in name res.
- EAI_FAMILY = -6 -- `ai_family' not supported.
- EAI_SOCKTYPE = -7 -- `ai_socktype' not supported.
- EAI_SERVICE = -8 -- SERVICE not supported for `ai_socktype'.
- EAI_MEMORY = -10 -- Memory allocation failure.
- EAI_SYSTEM = -11 -- System error returned in `errno'.
- EAI_OVERFLOW = -12 -- Argument buffer overflow.
- EAI_NODATA = -5 -- No address associated with NAME.
- EAI_ADDRFAMILY = -9 -- Address family for NAME not supported.
- EAI_INPROGRESS = -100 -- Processing request in progress.
- EAI_CANCELED = -101 -- Request canceled.
- EAI_NOTCANCELED = -102 -- Request not canceled.
- EAI_ALLDONE = -103 -- All requests done.
- EAI_INTR = -104 -- Interrupted by a signal.
- EAI_IDN_ENCODE = -105 -- IDN encoding failed.
- NI_MAXSERV = 32
- NI_MAXHOST = 1025
- NI_NUMERICHOST = 1
- NI_NUMERICSERV = 2
- NI_NOFQDN = 4
- NI_NAMEREQD = 8
- NI_DGRAM = 16