3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2004 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
27 # if defined(HAVE_STRINGS_H) && (!defined(HAVE_STRING_H) || defined(BOTH_STRINGS_H))
39 # define strrchr rindex
44 # define memcpy(d, s, n) ((void) bcopy ((s), (d), (n)))
46 # define memmove(d, s, n) ((void) bcopy ((s), (d), (n)))
50 /* use ldap_pvt_strtok instead of strtok or strtok_r! */
51 LDAP_F(char *) ldap_pvt_strtok LDAP_P(( char *str,
52 const char *delim, char **pos ));
55 /* strdup() is missing, declare our own version */
57 # define strdup(s) ber_strdup(s)
58 #elif !defined(_WIN32)
59 /* some systems fail to declare strdup */
60 /* Windows does not require this declaration */
61 LDAP_LIBC_F(char *) (strdup)();
65 * some systems fail to declare strcasecmp() and strncasecmp()
66 * we need them declared so we can obtain pointers to them
69 /* we don't want these declared for Windows or Mingw */
76 # if defined( HAVE_MEMMOVE )
77 # define SAFEMEMCPY( d, s, n ) memmove((d), (s), (n))
78 # elif defined( HAVE_BCOPY )
79 # define SAFEMEMCPY( d, s, n ) bcopy((s), (d), (n))
81 /* nothing left but memcpy() */
82 # define SAFEMEMCPY( d, s, n ) memcpy((d), (s), (n))
86 #define AC_MEMCPY( d, s, n ) (SAFEMEMCPY((d),(s),(n)))
87 #define AC_FMEMCPY( d, s, n ) do { \
88 if((n) == 1) *((char*)(d)) = *((char*)(s)); \
89 else AC_MEMCPY( (d), (s), (n) ); \
92 #define STRLENOF(s) (sizeof(s)-1)
94 #if defined( HAVE_NONPOSIX_STRERROR_R )
95 # define AC_STRERROR_R(e,b,l) (strerror_r((e), (b), (l)))
96 #elif defined( HAVE_STRERROR_R )
97 # define AC_STRERROR_R(e,b,l) (strerror_r((e), (b), (l)) ? (b) : NULL)
98 #elif defined( HAVE_SYS_ERRLIST )
99 # define AC_STRERROR_R(e,b,l) ((e) > -1 && (e) < sys_nerr \
100 ? sys_errlist[(e)] : NULL )
101 #elif defined( HAVE_STRERROR )
102 # define AC_STRERROR_R(e,b,l) (strerror(e))
104 # define AC_STRERROR_R(e,b,l) (NULL)
107 #endif /* _AC_STRING_H */