5 * missing.h Replacements for functions that are or can be
6 * missing on some platforms.
16 #ifdef HAVE_SYS_TYPES_H
17 #include <sys/types.h>
21 * Functions from missing.c
24 #ifndef HAVE_STRNCASECMP
25 extern int strncasecmp(char *s1, char *s2, int n);
28 #ifndef HAVE_STRCASECMP
29 extern int strcasecmp(char *s1, char *s2);
33 extern char *strsep(char **stringp, const char *delim);
36 #ifndef HAVE_LOCALTIME_R
38 struct tm *localtime_r(const time_t *l_clock, struct tm *result);
42 char *ctime_r(const time_t *l_clock, char *l_buf);
45 #ifdef NEED_DECLARATION_CRYPT
46 char *crypt(char *key, char *salt);
49 #ifdef NEED_DECLARATION_STRNCASECMP
50 int strncasecmp(char *s1, char *s2, int n);
53 #ifdef NEED_DECLARATION_STRCASECMP
54 int strcasecmp(char *s1, char *s2);
57 #ifdef NEED_DECLARATION_INET_ATON
59 int inet_aton(char *cp, struct in_addr *inp);
62 #ifdef NEED_DECLARATION_GETHOSTNAME
63 int gethostname(char *name, int len);
66 #ifndef HAVE_SETLINEBUF
68 #define setlinebuf(x) setvbuf(x, NULL, _IOLBF, 0)
70 #define setlinebuf(x) 0
74 #ifdef NEED_DECLARATION_SETLINEBUF
75 #define setlinebuf(x) 0
78 #ifdef NEED_DECLARATION_GETUSERSHELL
79 char *getusershell(void);
82 #ifdef NEED_DECLARATION_ENDUSERSHELL
83 void endusershell(void);
87 #define INADDR_ANY ((uint32_t) 0x00000000)
90 #ifndef INADDR_LOOPBACK
91 #define INADDR_LOOPBACK ((uint32_t) 0x7f000001) /* Inet 127.0.0.1 */
95 #define INADDR_NONE ((uint32_t) 0xffffffff)
102 #ifndef INET_ADDRSTRLEN
103 #define INET_ADDRSTRLEN 16
113 #ifndef HAVE_STRUCT_IN6_ADDR
117 uint8_t u6_addr8[16];
118 uint16_t u6_addr16[8];
119 uint32_t u6_addr32[4];
121 #define s6_addr in6_u.u6_addr8
122 #define s6_addr16 in6_u.u6_addr16
123 #define s6_addr32 in6_u.u6_addr32
130 #ifndef INET6_ADDRSTRLEN
131 #define INET6_ADDRSTRLEN 46
134 #ifndef IN6ADDR_ANY_INIT
135 #define IN6ADDR_ANY_INIT {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }}}
138 #ifndef IN6ADDR_LOOPBACK_INIT
139 #define IN6ADDR_LOOPBACK_INIT {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }}}
142 #ifndef IN6_IS_ADDR_UNSPECIFIED
143 #define IN6_IS_ADDR_UNSPECIFIED(a) \
144 (((__const uint32_t *) (a))[0] == 0 \
145 && ((__const uint32_t *) (a))[1] == 0 \
146 && ((__const uint32_t *) (a))[2] == 0 \
147 && ((__const uint32_t *) (a))[3] == 0)
150 #ifndef IN6_IS_ADDR_LOOPBACK
151 #define IN6_IS_ADDR_LOOPBACK(a) \
152 (((__const uint32_t *) (a))[0] == 0 \
153 && ((__const uint32_t *) (a))[1] == 0 \
154 && ((__const uint32_t *) (a))[2] == 0 \
155 && ((__const uint32_t *) (a))[3] == htonl (1))
158 #ifndef IN6_IS_ADDR_MULTICAST
159 #define IN6_IS_ADDR_MULTICAST(a) (((__const uint8_t *) (a))[0] == 0xff)
162 #ifndef IN6_IS_ADDR_LINKLOCAL
163 #define IN6_IS_ADDR_LINKLOCAL(a) \
164 ((((__const uint32_t *) (a))[0] & htonl (0xffc00000)) \
165 == htonl (0xfe800000))
168 #ifndef IN6_IS_ADDR_SITELOCAL
169 #define IN6_IS_ADDR_SITELOCAL(a) \
170 ((((__const uint32_t *) (a))[0] & htonl (0xffc00000)) \
171 == htonl (0xfec00000))
174 #ifndef IN6_IS_ADDR_V4MAPPED
175 #define IN6_IS_ADDR_V4MAPPED(a) \
176 ((((__const uint32_t *) (a))[0] == 0) \
177 && (((__const uint32_t *) (a))[1] == 0) \
178 && (((__const uint32_t *) (a))[2] == htonl (0xffff)))
181 #ifndef IN6_IS_ADDR_V4COMPAT
182 #define IN6_IS_ADDR_V4COMPAT(a) \
183 ((((__const uint32_t *) (a))[0] == 0) \
184 && (((__const uint32_t *) (a))[1] == 0) \
185 && (((__const uint32_t *) (a))[2] == 0) \
186 && (ntohl (((__const uint32_t *) (a))[3]) > 1))
189 #ifndef IN6_ARE_ADDR_EQUAL
190 #define IN6_ARE_ADDR_EQUAL(a,b) \
191 ((((__const uint32_t *) (a))[0] == ((__const uint32_t *) (b))[0]) \
192 && (((__const uint32_t *) (a))[1] == ((__const uint32_t *) (b))[1]) \
193 && (((__const uint32_t *) (a))[2] == ((__const uint32_t *) (b))[2]) \
194 && (((__const uint32_t *) (a))[3] == ((__const uint32_t *) (b))[3]))
197 #endif /* HAVE_STRUCT_IN6_ADDR */
201 * Functions from getaddrinfo.c
204 #ifndef HAVE_STRUCT_SOCKADDR_STORAGE
205 struct sockaddr_storage
207 uint16_t ss_family; /* Address family, etc. */
208 char ss_padding[128 - (sizeof(uint16_t))];
210 #endif /* HAVE_STRUCT_SOCKADDR_STORAGE */
212 #ifndef HAVE_STRUCT_ADDRINFO
214 /* for old netdb.h */
217 #define EAI_FAMILY 5 /* ai_family not supported */
218 #define EAI_NONAME 8 /* hostname nor servname provided, or not known */
219 #define EAI_SERVICE 9 /* servname not supported for ai_socktype */
222 /* dummy value for old netdb.h */
225 #define AI_CANONNAME 2
226 #define AI_NUMERICHOST 4
227 #define NI_NUMERICHOST 2
228 #define NI_NAMEREQD 4
229 #define NI_NUMERICSERV 8
233 int ai_flags; /* Input flags. */
234 int ai_family; /* Protocol family for socket. */
235 int ai_socktype; /* Socket type. */
236 int ai_protocol; /* Protocol for socket. */
237 socklen_t ai_addrlen; /* Length of socket address. */
238 struct sockaddr *ai_addr; /* Socket address for socket. */
239 char *ai_canonname; /* Canonical name for service location. */
240 struct addrinfo *ai_next; /* Pointer to next in list. */
243 #endif /* AI_PASSIVE */
245 #endif /* HAVE_STRUCT_ADDRINFO */
247 /* Translate name of a service location and/or a service name to set of
249 #ifndef HAVE_GETADDRINFO
250 extern int getaddrinfo (const char *__name,
251 const char *__service,
252 const struct addrinfo *__req,
253 struct addrinfo **__pai);
255 /* Free `addrinfo' structure AI including associated storage. */
256 extern void freeaddrinfo (struct addrinfo *__ai);
258 /* Convert error return from getaddrinfo() to a string. */
259 extern char *gai_strerror (int __ecode);
262 /* Translate a socket address to a location and service name. */
263 #ifndef HAVE_GETNAMEINFO
264 extern int getnameinfo (const struct sockaddr *__sa,
265 socklen_t __salen, char *__host,
266 socklen_t __hostlen, char *__serv,
267 socklen_t __servlen, unsigned int __flags);
271 * Functions from snprintf.c
274 #ifndef HAVE_VSNPRINTF
276 extern int vsnprintf(char *str, size_t count, const char *fmt, va_list arg);
279 #ifndef HAVE_SNPRINTF
280 extern int snprintf(char *str, size_t count, const char *fmt, ...);
284 * Functions from strl{cat,cpy}.c
288 extern size_t strlcpy(char *dst, const char *src, size_t siz);
292 extern size_t strlcat(char *dst, const char *src, size_t siz);
295 #endif /* _FR_MISSING_H */