2014-11-19 14:43:07 +01:00
|
|
|
/*
|
|
|
|
* Public domain
|
|
|
|
* string.h compatibility shim
|
|
|
|
*/
|
|
|
|
|
2014-07-10 13:21:51 +02:00
|
|
|
#include_next <string.h>
|
|
|
|
|
|
|
|
#ifndef LIBCRYPTOCOMPAT_STRING_H
|
|
|
|
#define LIBCRYPTOCOMPAT_STRING_H
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2014-10-22 08:47:31 +02:00
|
|
|
#if defined(__sun) || defined(__hpux)
|
2014-07-10 13:21:51 +02:00
|
|
|
/* Some functions historically defined in string.h were placed in strings.h by
|
2014-10-22 08:47:31 +02:00
|
|
|
* SUS. Use the same hack as OS X and FreeBSD use to work around on Solaris and HPUX.
|
2014-07-10 13:21:51 +02:00
|
|
|
*/
|
|
|
|
#include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
2014-10-29 21:44:36 +01:00
|
|
|
#ifndef HAVE_STRLCPY
|
2014-07-10 13:21:51 +02:00
|
|
|
size_t strlcpy(char *dst, const char *src, size_t siz);
|
2014-07-28 19:09:38 +02:00
|
|
|
#endif
|
2014-07-10 13:21:51 +02:00
|
|
|
|
2014-10-29 21:44:36 +01:00
|
|
|
#ifndef HAVE_STRLCAT
|
2014-07-10 13:21:51 +02:00
|
|
|
size_t strlcat(char *dst, const char *src, size_t siz);
|
2014-07-28 19:09:38 +02:00
|
|
|
#endif
|
2014-07-10 13:21:51 +02:00
|
|
|
|
2014-10-29 21:44:36 +01:00
|
|
|
#ifndef HAVE_STRNDUP
|
2014-07-27 13:11:56 +02:00
|
|
|
char * strndup(const char *str, size_t maxlen);
|
2014-10-29 21:44:36 +01:00
|
|
|
/* the only user of strnlen is strndup, so only build it if needed */
|
|
|
|
#ifndef HAVE_STRNLEN
|
2014-07-27 13:11:56 +02:00
|
|
|
size_t strnlen(const char *str, size_t maxlen);
|
2014-07-28 19:09:38 +02:00
|
|
|
#endif
|
2014-08-03 04:43:56 +02:00
|
|
|
#endif
|
2014-07-27 13:11:56 +02:00
|
|
|
|
2014-10-29 21:44:36 +01:00
|
|
|
#ifndef HAVE_EXPLICIT_BZERO
|
2014-07-10 13:21:51 +02:00
|
|
|
void explicit_bzero(void *, size_t);
|
2014-07-28 19:09:38 +02:00
|
|
|
#endif
|
2014-07-10 13:21:51 +02:00
|
|
|
|
2014-10-29 21:44:36 +01:00
|
|
|
#ifndef HAVE_TIMINGSAFE_BCMP
|
2014-07-10 13:21:51 +02:00
|
|
|
int timingsafe_bcmp(const void *b1, const void *b2, size_t n);
|
2014-07-28 19:09:38 +02:00
|
|
|
#endif
|
2014-07-10 13:21:51 +02:00
|
|
|
|
2014-10-29 21:44:36 +01:00
|
|
|
#ifndef HAVE_TIMINGSAFE_MEMCMP
|
2014-07-10 13:21:51 +02:00
|
|
|
int timingsafe_memcmp(const void *b1, const void *b2, size_t len);
|
2014-07-28 19:09:38 +02:00
|
|
|
#endif
|
2014-07-10 13:21:51 +02:00
|
|
|
|
2014-10-29 21:44:36 +01:00
|
|
|
#ifndef HAVE_MEMMEM
|
2014-07-22 01:57:06 +02:00
|
|
|
void * memmem(const void *big, size_t big_len, const void *little,
|
|
|
|
size_t little_len);
|
2014-07-28 19:09:38 +02:00
|
|
|
#endif
|
2014-07-22 01:57:06 +02:00
|
|
|
|
2014-11-20 14:32:15 +01:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
static inline char *
|
|
|
|
posix_strerror(int errnum)
|
|
|
|
{
|
|
|
|
if (errnum == ECONNREFUSED) {
|
|
|
|
return "Connection refused";
|
|
|
|
}
|
|
|
|
return strerror(errnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define strerror(errnum) posix_strerror(errnum)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2014-07-10 13:21:51 +02:00
|
|
|
#endif
|