1998-10-24 21:41:42 -04:00
|
|
|
/* Generic string.h */
|
1999-08-30 04:08:00 -04:00
|
|
|
/* $OpenLDAP$ */
|
2003-11-25 23:16:36 -05:00
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
|
*
|
2015-02-11 16:36:57 -05:00
|
|
|
* Copyright 1998-2015 The OpenLDAP Foundation.
|
1998-12-28 14:51:35 -05:00
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
2001-05-28 23:35:56 -04:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
2003-11-25 18:17:08 -05:00
|
|
|
* Public License.
|
|
|
|
|
*
|
|
|
|
|
* A copy of this license is available in file LICENSE in the
|
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
1998-12-28 14:51:35 -05:00
|
|
|
*/
|
1998-10-24 21:41:42 -04:00
|
|
|
|
|
|
|
|
#ifndef _AC_STRING_H
|
|
|
|
|
#define _AC_STRING_H
|
|
|
|
|
|
|
|
|
|
#ifdef STDC_HEADERS
|
|
|
|
|
# include <string.h>
|
1998-11-17 14:05:48 -05:00
|
|
|
|
1998-10-24 21:41:42 -04:00
|
|
|
#else
|
1998-11-15 21:02:45 -05:00
|
|
|
# ifdef HAVE_STRING_H
|
|
|
|
|
# include <string.h>
|
2002-07-26 07:31:29 -04:00
|
|
|
# endif
|
2002-07-26 09:46:09 -04:00
|
|
|
# if defined(HAVE_STRINGS_H) && (!defined(HAVE_STRING_H) || defined(BOTH_STRINGS_H))
|
1998-11-15 21:02:45 -05:00
|
|
|
# include <strings.h>
|
|
|
|
|
# endif
|
|
|
|
|
|
1998-11-17 14:05:48 -05:00
|
|
|
# ifdef HAVE_MEMORY_H
|
|
|
|
|
# include <memory.h>
|
|
|
|
|
# endif
|
|
|
|
|
|
1998-11-20 02:04:20 -05:00
|
|
|
# ifndef HAVE_STRRCHR
|
1999-02-20 13:31:56 -05:00
|
|
|
# undef strchr
|
1998-10-24 21:41:42 -04:00
|
|
|
# define strchr index
|
1999-02-20 13:31:56 -05:00
|
|
|
# undef strrchr
|
1998-10-24 21:41:42 -04:00
|
|
|
# define strrchr rindex
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
# ifndef HAVE_MEMCPY
|
1999-02-20 13:31:56 -05:00
|
|
|
# undef memcpy
|
1998-11-22 23:29:01 -05:00
|
|
|
# define memcpy(d, s, n) ((void) bcopy ((s), (d), (n)))
|
1999-02-20 13:31:56 -05:00
|
|
|
# undef memmove
|
1998-11-22 23:29:01 -05:00
|
|
|
# define memmove(d, s, n) ((void) bcopy ((s), (d), (n)))
|
1998-10-24 21:41:42 -04:00
|
|
|
# endif
|
1998-11-17 14:05:48 -05:00
|
|
|
#endif
|
1998-11-15 21:02:45 -05:00
|
|
|
|
1999-02-20 15:12:03 -05:00
|
|
|
/* use ldap_pvt_strtok instead of strtok or strtok_r! */
|
2001-07-21 19:13:04 -04:00
|
|
|
LDAP_F(char *) ldap_pvt_strtok LDAP_P(( char *str,
|
|
|
|
|
const char *delim, char **pos ));
|
1999-06-07 14:35:30 -04:00
|
|
|
|
1998-11-17 14:05:48 -05:00
|
|
|
#ifndef HAVE_STRDUP
|
1998-11-20 02:04:20 -05:00
|
|
|
/* strdup() is missing, declare our own version */
|
1999-02-20 13:31:56 -05:00
|
|
|
# undef strdup
|
2000-06-07 01:17:29 -04:00
|
|
|
# define strdup(s) ber_strdup(s)
|
2001-12-06 23:03:25 -05:00
|
|
|
#elif !defined(_WIN32)
|
1999-05-24 19:01:57 -04:00
|
|
|
/* some systems fail to declare strdup */
|
2001-12-06 23:03:25 -05:00
|
|
|
/* Windows does not require this declaration */
|
2000-06-18 15:48:07 -04:00
|
|
|
LDAP_LIBC_F(char *) (strdup)();
|
1998-10-24 21:41:42 -04:00
|
|
|
#endif
|
|
|
|
|
|
1998-11-20 02:04:20 -05:00
|
|
|
/*
|
|
|
|
|
* some systems fail to declare strcasecmp() and strncasecmp()
|
1998-11-22 23:29:01 -05:00
|
|
|
* we need them declared so we can obtain pointers to them
|
1998-11-20 02:04:20 -05:00
|
|
|
*/
|
1999-11-27 18:40:08 -05:00
|
|
|
|
2001-12-17 17:40:10 -05:00
|
|
|
/* we don't want these declared for Windows or Mingw */
|
|
|
|
|
#ifndef _WIN32
|
1999-11-27 18:40:08 -05:00
|
|
|
int (strcasecmp)();
|
|
|
|
|
int (strncasecmp)();
|
2001-12-17 17:40:10 -05:00
|
|
|
#endif
|
1998-11-20 02:04:20 -05:00
|
|
|
|
1998-10-24 21:41:42 -04:00
|
|
|
#ifndef SAFEMEMCPY
|
|
|
|
|
# if defined( HAVE_MEMMOVE )
|
|
|
|
|
# define SAFEMEMCPY( d, s, n ) memmove((d), (s), (n))
|
1998-11-16 23:07:31 -05:00
|
|
|
# elif defined( HAVE_BCOPY )
|
1998-10-24 21:41:42 -04:00
|
|
|
# define SAFEMEMCPY( d, s, n ) bcopy((s), (d), (n))
|
1998-11-16 23:07:31 -05:00
|
|
|
# else
|
1998-10-24 21:41:42 -04:00
|
|
|
/* nothing left but memcpy() */
|
|
|
|
|
# define SAFEMEMCPY( d, s, n ) memcpy((d), (s), (n))
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2000-07-27 16:10:44 -04:00
|
|
|
#define AC_MEMCPY( d, s, n ) (SAFEMEMCPY((d),(s),(n)))
|
|
|
|
|
#define AC_FMEMCPY( d, s, n ) do { \
|
|
|
|
|
if((n) == 1) *((char*)(d)) = *((char*)(s)); \
|
|
|
|
|
else AC_MEMCPY( (d), (s), (n) ); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
2005-03-04 20:23:29 -05:00
|
|
|
#ifdef NEED_MEMCMP_REPLACEMENT
|
|
|
|
|
int (lutil_memcmp)(const void *b1, const void *b2, size_t len);
|
|
|
|
|
#define memcmp lutil_memcmp
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-11-20 15:43:50 -05:00
|
|
|
void *(lutil_memrchr)(const void *b, int c, size_t n);
|
2005-11-14 11:02:04 -05:00
|
|
|
/* GNU extension (glibc >= 2.1.91), only declared when defined(_GNU_SOURCE) */
|
2009-11-20 15:43:50 -05:00
|
|
|
#if defined(HAVE_MEMRCHR) && defined(_GNU_SOURCE)
|
|
|
|
|
#define lutil_memrchr(b, c, n) memrchr(b, c, n)
|
2009-11-15 16:41:41 -05:00
|
|
|
#endif /* ! HAVE_MEMRCHR */
|
2005-11-13 17:26:53 -05:00
|
|
|
|
2004-04-06 20:41:57 -04:00
|
|
|
#define STRLENOF(s) (sizeof(s)-1)
|
|
|
|
|
|
2004-04-24 20:19:06 -04:00
|
|
|
#if defined( HAVE_NONPOSIX_STRERROR_R )
|
|
|
|
|
# define AC_STRERROR_R(e,b,l) (strerror_r((e), (b), (l)))
|
|
|
|
|
#elif defined( HAVE_STRERROR_R )
|
2006-01-02 04:46:49 -05:00
|
|
|
# define AC_STRERROR_R(e,b,l) (strerror_r((e), (b), (l)) == 0 ? (b) : "Unknown error")
|
2004-04-24 20:19:06 -04:00
|
|
|
#elif defined( HAVE_SYS_ERRLIST )
|
|
|
|
|
# define AC_STRERROR_R(e,b,l) ((e) > -1 && (e) < sys_nerr \
|
2006-01-02 04:46:49 -05:00
|
|
|
? sys_errlist[(e)] : "Unknown error" )
|
2004-04-24 20:19:06 -04:00
|
|
|
#elif defined( HAVE_STRERROR )
|
2006-01-02 04:46:49 -05:00
|
|
|
# define AC_STRERROR_R(e,b,l) (strerror(e)) /* NOTE: may be NULL */
|
2004-04-24 20:19:06 -04:00
|
|
|
#else
|
2006-01-02 04:46:49 -05:00
|
|
|
# define AC_STRERROR_R(e,b,l) ("Unknown error")
|
2004-04-24 20:19:06 -04:00
|
|
|
#endif
|
|
|
|
|
|
1998-10-24 21:41:42 -04:00
|
|
|
#endif /* _AC_STRING_H */
|