X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=include%2Fnetdb.h;h=d096c78183b5609c4e5932adbd8d6ed8e75f168e;hb=751bee0ee727e8d8b003c87cff77ac76f1dbecd6;hp=5f1dd3f179e36200bea483678da35d69c0bafcc2;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/include/netdb.h b/include/netdb.h index 5f1dd3f1..d096c781 100644 --- a/include/netdb.h +++ b/include/netdb.h @@ -5,17 +5,15 @@ extern "C" { #endif -#ifdef _GNU_SOURCE -#define __NEED_size_t -#endif - -#define __NEED_socklen_t -#define __NEED_uint32_t +#include +#include +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define __NEED_size_t #include +#endif -struct addrinfo -{ +struct addrinfo { int ai_flags; int ai_family; int ai_socktype; @@ -26,8 +24,6 @@ struct addrinfo struct addrinfo *ai_next; }; -#define IPPORT_RESERVED 1024 - #define AI_PASSIVE 0x01 #define AI_CANONNAME 0x02 #define AI_NUMERICHOST 0x04 @@ -42,10 +38,7 @@ struct addrinfo #define NI_NOFQDN 0x04 #define NI_NAMEREQD 0x08 #define NI_DGRAM 0x10 -/*#define NI_NUMERICSCOPE */ - -#define NI_MAXHOST 255 -#define NI_MAXSERV 32 +#define NI_NUMERICSCOPE 0x100 #define EAI_BADFLAGS -1 #define EAI_NONAME -2 @@ -58,24 +51,22 @@ struct addrinfo #define EAI_SYSTEM -11 #define EAI_OVERFLOW -12 -int getaddrinfo (const char *, const char *, const struct addrinfo *, struct addrinfo **); +int getaddrinfo (const char *__restrict, const char *__restrict, const struct addrinfo *__restrict, struct addrinfo **__restrict); void freeaddrinfo (struct addrinfo *); -int getnameinfo (const struct sockaddr *, socklen_t, char *, socklen_t, char *, socklen_t, int); +int getnameinfo (const struct sockaddr *__restrict, socklen_t, char *__restrict, socklen_t, char *__restrict, socklen_t, int); const char *gai_strerror(int); /* Legacy functions follow (marked OBsolete in SUS) */ -struct netent -{ +struct netent { char *n_name; char **n_aliases; int n_addrtype; uint32_t n_net; }; -struct hostent -{ +struct hostent { char *h_name; char **h_aliases; int h_addrtype; @@ -84,33 +75,22 @@ struct hostent }; #define h_addr h_addr_list[0] -struct servent -{ +struct servent { char *s_name; char **s_aliases; int s_port; char *s_proto; }; -struct protoent -{ +struct protoent { char *p_name; char **p_aliases; int p_proto; }; -extern int h_errno; - -#define HOST_NOT_FOUND 1 -#define TRY_AGAIN 2 -#define NO_RECOVERY 3 -#define NO_DATA 4 - void sethostent (int); void endhostent (void); struct hostent *gethostent (void); -struct hostent *gethostbyaddr (const void *, socklen_t, int); -struct hostent *gethostbyname (const char *); void setnetent (int); void endnetent (void); @@ -130,7 +110,25 @@ struct protoent *getprotoent (void); struct protoent *getprotobyname (const char *); struct protoent *getprotobynumber (int); -#ifdef _GNU_SOURCE +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \ + || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \ + || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700) +struct hostent *gethostbyname (const char *); +struct hostent *gethostbyaddr (const void *, socklen_t, int); +#ifdef __GNUC__ +__attribute__((const)) +#endif +int *__h_errno_location(void); +#define h_errno (*__h_errno_location()) +#define HOST_NOT_FOUND 1 +#define TRY_AGAIN 2 +#define NO_RECOVERY 3 +#define NO_DATA 4 +#define NO_ADDRESS NO_DATA +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +void herror(const char *); const char *hstrerror(int); int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *); int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *); @@ -138,6 +136,16 @@ struct hostent *gethostbyname2(const char *, int); int gethostbyaddr_r(const void *, socklen_t, int, struct hostent *, char *, size_t, struct hostent **, int *); int getservbyport_r(int, const char *, struct servent *, char *, size_t, struct servent **); int getservbyname_r(const char *, const char *, struct servent *, char *, size_t, struct servent **); +#define EAI_NODATA -5 +#define EAI_ADDRFAMILY -9 +#define EAI_INPROGRESS -100 +#define EAI_CANCELED -101 +#define EAI_NOTCANCELED -102 +#define EAI_ALLDONE -103 +#define EAI_INTR -104 +#define EAI_IDN_ENCODE -105 +#define NI_MAXHOST 255 +#define NI_MAXSERV 32 #endif