remove arch/$(ARCH)/src from the build system
[musl.git] / include / netdb.h
blob47940684e6db1d8419fdd538a6b3bbdb71c28888
1 #ifndef _NETDB_H
2 #define _NETDB_H
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
8 #include <features.h>
9 #include <netinet/in.h>
11 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
12 #define __NEED_size_t
13 #include <bits/alltypes.h>
14 #endif
16 struct addrinfo
18 int ai_flags;
19 int ai_family;
20 int ai_socktype;
21 int ai_protocol;
22 socklen_t ai_addrlen;
23 struct sockaddr *ai_addr;
24 char *ai_canonname;
25 struct addrinfo *ai_next;
28 #define IPPORT_RESERVED 1024
30 #define AI_PASSIVE 0x01
31 #define AI_CANONNAME 0x02
32 #define AI_NUMERICHOST 0x04
33 #define AI_V4MAPPED 0x08
34 #define AI_ALL 0x10
35 #define AI_ADDRCONFIG 0x20
36 #define AI_NUMERICSERV 0x400
39 #define NI_NUMERICHOST 0x01
40 #define NI_NUMERICSERV 0x02
41 #define NI_NOFQDN 0x04
42 #define NI_NAMEREQD 0x08
43 #define NI_DGRAM 0x10
44 #define NI_NUMERICSCOPE 0x100
46 #define EAI_BADFLAGS -1
47 #define EAI_NONAME -2
48 #define EAI_AGAIN -3
49 #define EAI_FAIL -4
50 #define EAI_FAMILY -6
51 #define EAI_SOCKTYPE -7
52 #define EAI_SERVICE -8
53 #define EAI_MEMORY -10
54 #define EAI_SYSTEM -11
55 #define EAI_OVERFLOW -12
57 int getaddrinfo (const char *__restrict, const char *__restrict, const struct addrinfo *__restrict, struct addrinfo **__restrict);
58 void freeaddrinfo (struct addrinfo *);
59 int getnameinfo (const struct sockaddr *__restrict, socklen_t, char *__restrict, socklen_t, char *__restrict, socklen_t, int);
60 const char *gai_strerror(int);
63 /* Legacy functions follow (marked OBsolete in SUS) */
65 struct netent
67 char *n_name;
68 char **n_aliases;
69 int n_addrtype;
70 uint32_t n_net;
73 struct hostent
75 char *h_name;
76 char **h_aliases;
77 int h_addrtype;
78 int h_length;
79 char **h_addr_list;
81 #define h_addr h_addr_list[0]
83 struct servent
85 char *s_name;
86 char **s_aliases;
87 int s_port;
88 char *s_proto;
91 struct protoent
93 char *p_name;
94 char **p_aliases;
95 int p_proto;
98 void sethostent (int);
99 void endhostent (void);
100 struct hostent *gethostent (void);
102 void setnetent (int);
103 void endnetent (void);
104 struct netent *getnetent (void);
105 struct netent *getnetbyaddr (uint32_t, int);
106 struct netent *getnetbyname (const char *);
108 void setservent (int);
109 void endservent (void);
110 struct servent *getservent (void);
111 struct servent *getservbyname (const char *, const char *);
112 struct servent *getservbyport (int, const char *);
114 void setprotoent (int);
115 void endprotoent (void);
116 struct protoent *getprotoent (void);
117 struct protoent *getprotobyname (const char *);
118 struct protoent *getprotobynumber (int);
120 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \
121 || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
122 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
123 struct hostent *gethostbyname (const char *);
124 struct hostent *gethostbyaddr (const void *, socklen_t, int);
125 int *__h_errno_location(void);
126 #define h_errno (*__h_errno_location())
127 #define HOST_NOT_FOUND 1
128 #define TRY_AGAIN 2
129 #define NO_RECOVERY 3
130 #define NO_DATA 4
131 #define NO_ADDRESS NO_DATA
132 #endif
134 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
135 void herror(const char *);
136 const char *hstrerror(int);
137 int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *);
138 int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *);
139 struct hostent *gethostbyname2(const char *, int);
140 int gethostbyaddr_r(const void *, socklen_t, int, struct hostent *, char *, size_t, struct hostent **, int *);
141 int getservbyport_r(int, const char *, struct servent *, char *, size_t, struct servent **);
142 int getservbyname_r(const char *, const char *, struct servent *, char *, size_t, struct servent **);
143 #define EAI_NODATA -5
144 #define EAI_ADDRFAMILY -9
145 #define EAI_INPROGRESS -100
146 #define EAI_CANCELED -101
147 #define EAI_NOTCANCELED -102
148 #define EAI_ALLDONE -103
149 #define EAI_INTR -104
150 #define EAI_IDN_ENCODE -105
151 #define NI_MAXHOST 255
152 #define NI_MAXSERV 32
153 #endif
156 #ifdef __cplusplus
158 #endif
160 #endif