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