lua-bcrypt

Secure password hashing for Lua
Log | Files | Refs

string.h (1440B)


      1 /*
      2  * Public domain
      3  * string.h compatibility shim
      4  */
      5 
      6 #include_next <string.h>
      7 
      8 #ifndef LIBCRYPTOCOMPAT_STRING_H
      9 #define LIBCRYPTOCOMPAT_STRING_H
     10 
     11 #include <sys/types.h>
     12 
     13 #if defined(__sun) || defined(__hpux)
     14 /* Some functions historically defined in string.h were placed in strings.h by
     15  * SUS. Use the same hack as OS X and FreeBSD use to work around on Solaris and HPUX.
     16  */
     17 #include <strings.h>
     18 #endif
     19 
     20 #ifndef HAVE_STRLCPY
     21 size_t strlcpy(char *dst, const char *src, size_t siz);
     22 #endif
     23 
     24 #ifndef HAVE_STRLCAT
     25 size_t strlcat(char *dst, const char *src, size_t siz);
     26 #endif
     27 
     28 #ifndef HAVE_STRNDUP
     29 char * strndup(const char *str, size_t maxlen);
     30 /* the only user of strnlen is strndup, so only build it if needed */
     31 #ifndef HAVE_STRNLEN
     32 size_t strnlen(const char *str, size_t maxlen);
     33 #endif
     34 #endif
     35 
     36 #ifndef HAVE_EXPLICIT_BZERO
     37 void explicit_bzero(void *, size_t);
     38 #endif
     39 
     40 #ifndef HAVE_TIMINGSAFE_BCMP
     41 int timingsafe_bcmp(const void *b1, const void *b2, size_t n);
     42 #endif
     43 
     44 #ifndef HAVE_TIMINGSAFE_MEMCMP
     45 int timingsafe_memcmp(const void *b1, const void *b2, size_t len);
     46 #endif
     47 
     48 #ifndef HAVE_MEMMEM
     49 void * memmem(const void *big, size_t big_len, const void *little,
     50 	size_t little_len);
     51 #endif
     52 
     53 #ifdef _WIN32
     54 #include <errno.h>
     55 
     56 static inline char  *
     57 posix_strerror(int errnum)
     58 {
     59 	if (errnum == ECONNREFUSED) {
     60 		return "Connection refused";
     61 	}
     62 	return strerror(errnum);
     63 }
     64 
     65 #define strerror(errnum) posix_strerror(errnum)
     66 
     67 #endif
     68 
     69 #endif