simplify some logic in scanf and remove redundant invalid-format check
[musl] / include / netdb.h
index 6e181b6..3cda711 100644 (file)
@@ -5,7 +5,9 @@
 extern "C" {
 #endif
 
-#ifdef _GNU_SOURCE
+#include <features.h>
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
 #define __NEED_size_t
 #endif
 
@@ -44,9 +46,6 @@ struct addrinfo
 #define NI_DGRAM        0x10
 /*#define NI_NUMERICSCOPE */
 
-#define NI_MAXHOST 255
-#define NI_MAXSERV 32
-
 #define EAI_BADFLAGS   -1
 #define EAI_NONAME     -2
 #define EAI_AGAIN      -3
@@ -58,9 +57,9 @@ 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);
 
 
@@ -99,18 +98,9 @@ struct protoent
        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 +120,23 @@ 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
+#endif
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
 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 *);
@@ -146,6 +152,8 @@ int getservbyname_r(const char *, const char *, struct servent *, char *, size_t
 #define EAI_ALLDONE    -103
 #define EAI_INTR       -104
 #define EAI_IDN_ENCODE -105
+#define NI_MAXHOST 255
+#define NI_MAXSERV 32
 #endif