Commit 02e52db7 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

libs: Import code from upstream openldap 2.5.13.

Minimal set of files to compile libldap and liblber client libraries.
parent 0b09db59
......@@ -1558,6 +1558,7 @@ enable_gsm
enable_jpeg
enable_jxr
enable_lcms2
enable_ldap
enable_mfuuid
enable_mpg123
enable_png
......@@ -22160,6 +22161,7 @@ wine_fn_config_makefile libs/gsm enable_gsm
wine_fn_config_makefile libs/jpeg enable_jpeg
wine_fn_config_makefile libs/jxr enable_jxr
wine_fn_config_makefile libs/lcms2 enable_lcms2
wine_fn_config_makefile libs/ldap enable_ldap
wine_fn_config_makefile libs/mfuuid enable_mfuuid
wine_fn_config_makefile libs/mpg123 enable_mpg123
wine_fn_config_makefile libs/png enable_png
......
......@@ -3327,6 +3327,7 @@ WINE_CONFIG_MAKEFILE(libs/gsm)
WINE_CONFIG_MAKEFILE(libs/jpeg)
WINE_CONFIG_MAKEFILE(libs/jxr)
WINE_CONFIG_MAKEFILE(libs/lcms2)
WINE_CONFIG_MAKEFILE(libs/ldap)
WINE_CONFIG_MAKEFILE(libs/mfuuid)
WINE_CONFIG_MAKEFILE(libs/mpg123)
WINE_CONFIG_MAKEFILE(libs/png)
......
Copyright 1998-2022 The OpenLDAP Foundation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted only as authorized by the OpenLDAP
Public License.
A copy of this license is available in the file LICENSE in the
top-level directory of the distribution or, alternatively, at
<http://www.OpenLDAP.org/license.html>.
OpenLDAP is a registered trademark of the OpenLDAP Foundation.
Individual files and/or contributed packages may be copyright by
other parties and/or subject to additional restrictions.
This work is derived from the University of Michigan LDAP v3.3
distribution. Information concerning this software is available
at <http://www.umich.edu/~dirsvcs/ldap/ldap.html>.
This work also contains materials derived from public sources.
Additional information about OpenLDAP can be obtained at
<http://www.openldap.org/>.
---
Portions Copyright 1998-2013 Kurt D. Zeilenga.
Portions Copyright 1998-2006 Net Boolean Incorporated.
Portions Copyright 2001-2006 IBM Corporation.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted only as authorized by the OpenLDAP
Public License.
---
Portions Copyright 1999-2008 Howard Y.H. Chu.
Portions Copyright 1999-2008 Symas Corporation.
Portions Copyright 1998-2003 Hallvard B. Furuseth.
Portions Copyright 2007-2011 Gavin Henry.
Portions Copyright 2007-2011 Suretec Systems Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that this notice is preserved.
The names of the copyright holders may not be used to endorse or
promote products derived from this software without their specific
prior written permission. This software is provided ``as is''
without express or implied warranty.
---
Portions Copyright (c) 1992-1996 Regents of the University of Michigan.
All rights reserved.
Redistribution and use in source and binary forms are permitted
provided that this notice is preserved and that due credit is given
to the University of Michigan at Ann Arbor. The name of the
University may not be used to endorse or promote products derived
from this software without specific prior written permission. This
software is provided ``as is'' without express or implied warranty.
The OpenLDAP Public License
Version 2.8, 17 August 2003
Redistribution and use of this software and associated documentation
("Software"), with or without modification, are permitted provided
that the following conditions are met:
1. Redistributions in source form must retain copyright statements
and notices,
2. Redistributions in binary form must reproduce applicable copyright
statements and notices, this list of conditions, and the following
disclaimer in the documentation and/or other materials provided
with the distribution, and
3. Redistributions must contain a verbatim copy of this document.
The OpenLDAP Foundation may revise this license from time to time.
Each revision is distinguished by a version number. You may use
this Software under terms of this license revision or under the
terms of any subsequent revision of the license.
THIS SOFTWARE IS PROVIDED BY THE OPENLDAP FOUNDATION AND ITS
CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE OPENLDAP FOUNDATION, ITS CONTRIBUTORS, OR THE AUTHOR(S)
OR OWNER(S) OF THE SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
The names of the authors and copyright holders must not be used in
advertising or otherwise to promote the sale, use or other dealing
in this Software without specific, written prior permission. Title
to copyright in this Software shall at all times remain with copyright
holders.
OpenLDAP is a registered trademark of the OpenLDAP Foundation.
Copyright 1999-2003 The OpenLDAP Foundation, Redwood City,
California, USA. All Rights Reserved. Permission to copy and
distribute verbatim copies of this document is granted.
EXTLIB = libldap.a
EXTRAINCL = -I$(srcdir)/include
EXTRADEFS = -D_TIMEVAL_DEFINED
C_SRCS = \
liblber/bprint.c \
liblber/decode.c \
liblber/encode.c \
liblber/io.c \
liblber/memory.c \
liblber/nt_err.c \
liblber/options.c \
liblber/sockbuf.c \
libldap/abandon.c \
libldap/add.c \
libldap/avl.c \
libldap/bind.c \
libldap/charray.c \
libldap/compare.c \
libldap/controls.c \
libldap/cyrus.c \
libldap/delete.c \
libldap/error.c \
libldap/extended.c \
libldap/fetch.c \
libldap/filter.c \
libldap/free.c \
libldap/getattr.c \
libldap/getdn.c \
libldap/getentry.c \
libldap/getvalues.c \
libldap/init.c \
libldap/lbase64.c \
libldap/ldif.c \
libldap/modify.c \
libldap/modrdn.c \
libldap/open.c \
libldap/options.c \
libldap/os-ip.c \
libldap/pagectrl.c \
libldap/print.c \
libldap/references.c \
libldap/request.c \
libldap/result.c \
libldap/sasl.c \
libldap/sasl_w.c \
libldap/schema.c \
libldap/search.c \
libldap/sortctrl.c \
libldap/string.c \
libldap/tavl.c \
libldap/thr_nt.c \
libldap/tls2.c \
libldap/tls_w.c \
libldap/unbind.c \
libldap/url.c \
libldap/utf-8.c \
libldap/util-int.c \
libldap/vlvctrl.c
/* Generic assert.h */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
#ifndef _AC_ASSERT_H
#define _AC_ASSERT_H
#undef assert
#ifdef LDAP_DEBUG
#if defined( HAVE_ASSERT_H ) || defined( STDC_HEADERS )
#undef NDEBUG
#include <assert.h>
#else /* !(HAVE_ASSERT_H || STDC_HEADERS) */
#define LDAP_NEED_ASSERT 1
/*
* no assert()... must be a very old compiler.
* create a replacement and hope it works
*/
LBER_F (void) ber_pvt_assert LDAP_P(( const char *file, int line,
const char *test ));
/* Can't use LDAP_STRING(test), that'd expand to "test" */
#if defined(__STDC__) || defined(__cplusplus)
#define assert(test) \
((test) ? (void)0 : ber_pvt_assert( __FILE__, __LINE__, #test ) )
#else
#define assert(test) \
((test) ? (void)0 : ber_pvt_assert( __FILE__, __LINE__, "test" ) )
#endif
#endif /* (HAVE_ASSERT_H || STDC_HEADERS) */
#else /* !LDAP_DEBUG */
/* no asserts */
#define assert(test) ((void)0)
#endif /* LDAP_DEBUG */
#endif /* _AC_ASSERT_H */
/* Generic bytes.h */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
#ifndef _AC_BYTES_H
#define _AC_BYTES_H
/* cross compilers should define both AC_INT{2,4}_TYPE in CPPFLAGS */
#if !defined( AC_INT4_TYPE )
/* use autoconf defines to provide sized typedefs */
# if SIZEOF_LONG == 4
# define AC_INT4_TYPE long
# elif SIZEOF_INT == 4
# define AC_INT4_TYPE int
# elif SIZEOF_SHORT == 4
# define AC_INT4_TYPE short
# else
# error "AC_INT4_TYPE?"
# endif
#endif
typedef AC_INT4_TYPE ac_int4;
typedef signed AC_INT4_TYPE ac_sint4;
typedef unsigned AC_INT4_TYPE ac_uint4;
#if !defined( AC_INT2_TYPE )
# if SIZEOF_SHORT == 2
# define AC_INT2_TYPE short
# elif SIZEOF_INT == 2
# define AC_INT2_TYPE int
# elif SIZEOF_LONG == 2
# define AC_INT2_TYPE long
# else
# error "AC_INT2_TYPE?"
# endif
#endif
#if defined( AC_INT2_TYPE )
typedef AC_INT2_TYPE ac_int2;
typedef signed AC_INT2_TYPE ac_sint2;
typedef unsigned AC_INT2_TYPE ac_uint2;
#endif
#ifndef BYTE_ORDER
/* cross compilers should define BYTE_ORDER in CPPFLAGS */
/*
* Definitions for byte order, according to byte significance from low
* address to high.
*/
#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
/* assume autoconf's AC_C_BIGENDIAN has been ran */
/* if it hasn't, we assume (maybe falsely) the order is LITTLE ENDIAN */
# ifdef WORDS_BIGENDIAN
# define BYTE_ORDER BIG_ENDIAN
# else
# define BYTE_ORDER LITTLE_ENDIAN
# endif
#endif /* BYTE_ORDER */
#endif /* _AC_BYTES_H */
/* Generic ctype.h */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
#ifndef _AC_CTYPE_H
#define _AC_CTYPE_H
#include <ctype.h>
#undef TOUPPER
#undef TOLOWER
#ifdef C_UPPER_LOWER
# define TOUPPER(c) (islower(c) ? toupper(c) : (c))
# define TOLOWER(c) (isupper(c) ? tolower(c) : (c))
#else
# define TOUPPER(c) toupper(c)
# define TOLOWER(c) tolower(c)
#endif
#endif /* _AC_CTYPE_H */
/* Generic dirent.h */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
#ifndef _AC_DIRENT_H
#define _AC_DIRENT_H
#ifdef HAVE_DIRENT_H
# include <dirent.h>
# define NAMLEN(dirent) strlen((dirent)->d_name)
#elif defined(_MSC_VER)
#include <windows.h>
#ifndef MAX_PATH
#define MAX_PATH 260
#endif
struct dirent {
char *d_name;
};
typedef struct DIR {
HANDLE dir;
struct dirent data;
int first;
char buf[MAX_PATH+1];
} DIR;
DIR *opendir(const char *name);
struct dirent *readdir(DIR *dir);
int closedir(DIR *dir);
#else
# define dirent direct
# define NAMLEN(dirent) (dirent)->d_namlen
# ifdef HAVE_SYS_NDIR_H
# include <sys/ndir.h>
# endif
# ifdef HAVE_SYS_DIR_H
# include <sys/dir.h>
# endif
# ifdef HAVE_NDIR_H
# include <ndir.h>
# endif
#endif
#endif /* _AC_DIRENT_H */
/* Generic errno.h */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
#ifndef _AC_ERRNO_H
#define _AC_ERRNO_H
#if defined( HAVE_ERRNO_H )
# include <errno.h>
#elif defined( HAVE_SYS_ERRNO_H )
# include <sys/errno.h>
#endif
#if defined( HAVE_SYS_ERRLIST ) && defined( DECL_SYS_ERRLIST )
/* have sys_errlist but need declaration */
LDAP_LIBC_V(int) sys_nerr;
LDAP_LIBC_V(char) *sys_errlist[];
#endif
#endif /* _AC_ERRNO_H */
/* redefine FD_SET */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
/*
* This header is to be included by portable.h to ensure
* tweaking of FD_SETSIZE is done early enough to be effective.
*/
#ifndef _AC_FDSET_H
#define _AC_FDSET_H
#if !defined( OPENLDAP_FD_SETSIZE ) && !defined( FD_SETSIZE )
# define OPENLDAP_FD_SETSIZE 4096
#endif
#ifdef OPENLDAP_FD_SETSIZE
/* assume installer desires to enlarge fd_set */
# ifdef HAVE_BITS_TYPES_H
# include <bits/types.h>
# endif
# ifdef __FD_SETSIZE
# undef __FD_SETSIZE
# define __FD_SETSIZE OPENLDAP_FD_SETSIZE
# else
# define FD_SETSIZE OPENLDAP_FD_SETSIZE
# endif
#endif
#endif /* _AC_FDSET_H */
/* localize.h (i18n/l10n) */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
#ifndef _AC_LOCALIZE_H
#define _AC_LOCALIZE_H
#ifdef LDAP_LOCALIZE
# include <locale.h>
# include <libintl.h>
/* enable i18n/l10n */
# define gettext_noop(s) s
# define _(s) gettext(s)
# define N_(s) gettext_noop(s)
# define ldap_pvt_setlocale(c,l) ((void) setlocale(c, l))
# define ldap_pvt_textdomain(d) ((void) textdomain(d))
# define ldap_pvt_bindtextdomain(p,d) ((void) bindtextdomain(p, d))
#else
/* disable i18n/l10n */
# define _(s) s
# define N_(s) s
# define ldap_pvt_setlocale(c,l) ((void) 0)
# define ldap_pvt_textdomain(d) ((void) 0)
# define ldap_pvt_bindtextdomain(p,d) ((void) 0)
#endif
#endif /* _AC_LOCALIZE_H */
/* Generic param.h */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
#ifndef _AC_PARAM_H
#define _AC_PARAM_H
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
/* MAXPATHLEN should come from <unistd.h> */
#include <ac/unistd.h>
#ifndef MAXPATHLEN
# if defined(PATH_MAX)
# define MAXPATHLEN PATH_MAX
# elif defined(_MAX_PATH)
# define MAXPATHLEN _MAX_PATH
# else
# define MAXPATHLEN 4096
# endif
#endif
#endif /* _AC_PARAM_H */
/* Generic signal.h */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
#ifndef _AC_SIGNAL_H
#define _AC_SIGNAL_H
#include <signal.h>
#undef SIGNAL
#if defined( HAVE_SIGACTION )
#define SIGNAL lutil_sigaction
typedef void (*lutil_sig_t)(int);
LDAP_LUTIL_F(lutil_sig_t) lutil_sigaction( int sig, lutil_sig_t func );
#define SIGNAL_REINSTALL(sig,act) (void)0
#elif defined( HAVE_SIGSET )
#define SIGNAL sigset
#define SIGNAL_REINSTALL sigset
#else
#define SIGNAL signal
#define SIGNAL_REINSTALL signal
#endif
#if !defined( LDAP_SIGUSR1 ) || !defined( LDAP_SIGUSR2 )
#undef LDAP_SIGUSR1
#undef LDAP_SIGUSR2
# if defined(WINNT) || defined(_WINNT) || defined(_WIN32)
# define LDAP_SIGUSR1 SIGILL
# define LDAP_SIGUSR2 SIGTERM
# elif !defined(HAVE_LINUX_THREADS)
# define LDAP_SIGUSR1 SIGUSR1
# define LDAP_SIGUSR2 SIGUSR2
# else
/*
* Some versions of LinuxThreads unfortunately uses the only
* two signals reserved for user applications. This forces
* OpenLDAP to use other signals reserved for other uses.
*/
# if defined( SIGSTKFLT )
# define LDAP_SIGUSR1 SIGSTKFLT
# elif defined ( SIGSYS )
# define LDAP_SIGUSR1 SIGSYS
# endif
# if defined( SIGUNUSED )
# define LDAP_SIGUSR2 SIGUNUSED
# elif defined ( SIGINFO )
# define LDAP_SIGUSR2 SIGINFO
# elif defined ( SIGEMT )
# define LDAP_SIGUSR2 SIGEMT
# endif
# endif
#endif
#ifndef LDAP_SIGCHLD
#ifdef SIGCHLD
#define LDAP_SIGCHLD SIGCHLD
#elif SIGCLD
#define LDAP_SIGCHLD SIGCLD
#endif
#endif
#endif /* _AC_SIGNAL_H */
/* Generic socket.h */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
#ifndef _AC_SOCKET_H_
#define _AC_SOCKET_H_
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_POLL_H
#include <poll.h>
#elif defined(HAVE_SYS_POLL_H)
#include <sys/poll.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#include <netinet/in.h>
#ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
#include <arpa/nameser.h>
#endif
#include <netdb.h>
#ifdef HAVE_RESOLV_H
#include <resolv.h>
#endif
#endif /* HAVE_SYS_SOCKET_H */
#ifdef HAVE_WINSOCK2
#include <winsock2.h>
#include <ws2tcpip.h>
#elif HAVE_WINSOCK
#include <winsock.h>
#endif
#ifdef HAVE_PCNFS
#include <tklib.h>
#endif /* HAVE_PCNFS */
#ifndef INADDR_LOOPBACK
#define INADDR_LOOPBACK (0x7f000001UL)
#endif
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 64
#endif
#undef sock_errno
#undef sock_errstr
#define sock_errno() errno
#define sock_errstr(e, b, l) AC_STRERROR_R(e, b, l)
#define sock_errset(e) ((void) (errno = (e)))
#ifdef HAVE_WINSOCK
# define tcp_read( s, buf, len ) recv( s, buf, len, 0 )
# define tcp_write( s, buf, len ) send( s, buf, len, 0 )
# define ioctl( s, c, a ) ioctlsocket( (s), (c), (a) )
# define ioctl_t u_long
# define AC_SOCKET_INVALID ((unsigned int) -1)
# ifdef SD_BOTH
# define tcp_close( s ) (shutdown( s, SD_BOTH ), closesocket( s ))
# else
# define tcp_close( s ) closesocket( s )
# endif
#undef EWOULDBLOCK
#undef EINPROGRESS
#undef ETIMEDOUT
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EINPROGRESS WSAEINPROGRESS
#define ETIMEDOUT WSAETIMEDOUT
#undef sock_errno
#undef sock_errstr
#undef sock_errset
#define sock_errno() WSAGetLastError()
#define sock_errstr(e, b, l) ber_pvt_wsa_err2string(e)
#define sock_errset(e) WSASetLastError(e)
LBER_F( char * ) ber_pvt_wsa_err2string LDAP_P((int));
#elif MACOS
# define tcp_close( s ) tcpclose( s )
# define tcp_read( s, buf, len ) tcpread( s, buf, len )
# define tcp_write( s, buf, len ) tcpwrite( s, buf, len )
#elif DOS
# ifdef PCNFS
# define tcp_close( s ) close( s )
# define tcp_read( s, buf, len ) recv( s, buf, len, 0 )
# define tcp_write( s, buf, len ) send( s, buf, len, 0 )
# endif /* PCNFS */
# ifdef NCSA
# define tcp_close( s ) do { netclose( s ); netshut() } while(0)
# define tcp_read( s, buf, len ) nread( s, buf, len )
# define tcp_write( s, buf, len ) netwrite( s, buf, len )
# endif /* NCSA */
#elif defined(HAVE_CLOSESOCKET)
# define tcp_close( s ) closesocket( s )
# ifdef __BEOS__
# define tcp_read( s, buf, len ) recv( s, buf, len, 0 )
# define tcp_write( s, buf, len ) send( s, buf, len, 0 )
# endif
#else
# define tcp_read( s, buf, len) read( s, buf, len )
# define tcp_write( s, buf, len) write( s, buf, len )
# ifdef SHUT_RDWR
# define tcp_close( s ) (shutdown( s, SHUT_RDWR ), close( s ))
# else
# define tcp_close( s ) close( s )
# endif
#ifdef HAVE_PIPE
/*
* Only use pipe() on systems where file and socket descriptors
* are interchangeable
*/
# define USE_PIPE HAVE_PIPE
#endif
#endif /* MACOS */
#ifndef ioctl_t
# define ioctl_t int
#endif
#ifndef AC_SOCKET_INVALID
# define AC_SOCKET_INVALID (-1)
#endif
#ifndef AC_SOCKET_ERROR
# define AC_SOCKET_ERROR (-1)
#endif
#if !defined( HAVE_INET_ATON ) && !defined( inet_aton )
# define inet_aton ldap_pvt_inet_aton
struct in_addr;
LDAP_F (int) ldap_pvt_inet_aton LDAP_P(( const char *, struct in_addr * ));
#endif
#if defined(__WIN32) && defined(_ALPHA)
/* NT on Alpha is hosed. */
# define AC_HTONL( l ) \
((((l)&0xffU)<<24) + (((l)&0xff00U)<<8) + \
(((l)&0xff0000U)>>8) + (((l)&0xff000000U)>>24))
# define AC_NTOHL(l) AC_HTONL(l)
#else
# define AC_HTONL( l ) htonl( l )
# define AC_NTOHL( l ) ntohl( l )
#endif
/* htons()/ntohs() may be broken much like htonl()/ntohl() */
#define AC_HTONS( s ) htons( s )
#define AC_NTOHS( s ) ntohs( s )
#ifdef LDAP_PF_LOCAL
# if !defined( AF_LOCAL ) && defined( AF_UNIX )
# define AF_LOCAL AF_UNIX
# endif
# if !defined( PF_LOCAL ) && defined( PF_UNIX )
# define PF_LOCAL PF_UNIX
# endif
#endif
#ifndef INET_ADDRSTRLEN
# define INET_ADDRSTRLEN 16
#endif
#ifndef INET6_ADDRSTRLEN
# define INET6_ADDRSTRLEN 46
#endif
#if defined( HAVE_GETADDRINFO ) || defined( HAVE_GETNAMEINFO )
# ifdef HAVE_GAI_STRERROR
# define AC_GAI_STRERROR(x) (gai_strerror((x)))
# else
# define AC_GAI_STRERROR(x) (ldap_pvt_gai_strerror((x)))
LDAP_F (char *) ldap_pvt_gai_strerror( int );
# endif
#endif
#if defined(LDAP_PF_LOCAL) && \
!defined(HAVE_GETPEEREID) && \
!defined(HAVE_GETPEERUCRED) && \
!defined(SO_PEERCRED) && !defined(LOCAL_PEERCRED) && \
defined(HAVE_SENDMSG) && (defined(HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTSLEN) || \
defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL))
# define LDAP_PF_LOCAL_SENDMSG 1
#endif
#ifdef HAVE_GETPEEREID
#define LUTIL_GETPEEREID( s, uid, gid, bv ) getpeereid( s, uid, gid )
#elif defined(LDAP_PF_LOCAL_SENDMSG)
struct berval;
LDAP_LUTIL_F( int ) lutil_getpeereid( int s, uid_t *, gid_t *, struct berval *bv );
#define LUTIL_GETPEEREID( s, uid, gid, bv ) lutil_getpeereid( s, uid, gid, bv )
#else
LDAP_LUTIL_F( int ) lutil_getpeereid( int s, uid_t *, gid_t * );
#define LUTIL_GETPEEREID( s, uid, gid, bv ) lutil_getpeereid( s, uid, gid )
#endif
typedef union Sockaddr {
struct sockaddr sa_addr;
struct sockaddr_in sa_in_addr;
#ifdef LDAP_PF_INET6
struct sockaddr_storage sa_storage;
struct sockaddr_in6 sa_in6_addr;
#endif
#ifdef LDAP_PF_LOCAL
struct sockaddr_un sa_un_addr;
#endif
} Sockaddr;
/* DNS RFC defines max host name as 255. New systems seem to use 1024 */
#ifndef NI_MAXHOST
#define NI_MAXHOST 256
#endif
#ifdef HAVE_POLL
# ifndef INFTIM
# define INFTIM (-1)
# endif
#undef POLL_OTHER
#define POLL_OTHER (POLLERR|POLLHUP)
#undef POLL_READ
#define POLL_READ (POLLIN|POLLPRI|POLL_OTHER)
#undef POLL_WRITE
#define POLL_WRITE (POLLOUT|POLL_OTHER)
#endif
#endif /* _AC_SOCKET_H_ */
/* Generic stdarg.h */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
#ifndef _AC_STDARG_H
#define _AC_STDARG_H 1
/* require STDC variable argument support */
#include <stdarg.h>
#ifndef HAVE_STDARG
# define HAVE_STDARG 1
#endif
#endif /* _AC_STDARG_H */
/* Generic stdlib.h */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
#ifndef _AC_STDLIB_H
#define _AC_STDLIB_H
#if defined( HAVE_CSRIMALLOC )
#include <stdio.h>
#define MALLOC_TRACE
#include <libmalloc.h>
#endif
#include <stdlib.h>
/* Ignore malloc.h if we have STDC_HEADERS */
#if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
# include <malloc.h>
#endif
#ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# define EXIT_FAILURE 1
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#if defined(LINE_MAX)
# define AC_LINE_MAX LINE_MAX
#else
# define AC_LINE_MAX 2048 /* POSIX MIN */
#endif
#endif /* _AC_STDLIB_H */
/* Generic string.h */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
#ifndef _AC_STRING_H
#define _AC_STRING_H
#ifdef STDC_HEADERS
# include <string.h>
#else
# ifdef HAVE_STRING_H
# include <string.h>
# endif
# if defined(HAVE_STRINGS_H) && (!defined(HAVE_STRING_H) || defined(BOTH_STRINGS_H))
# include <strings.h>
# endif
# ifdef HAVE_MEMORY_H
# include <memory.h>
# endif
# ifndef HAVE_STRRCHR
# undef strchr
# define strchr index
# undef strrchr
# define strrchr rindex
# endif
# ifndef HAVE_MEMCPY
# undef memcpy
# define memcpy(d, s, n) ((void) bcopy ((s), (d), (n)))
# undef memmove
# define memmove(d, s, n) ((void) bcopy ((s), (d), (n)))
# endif
#endif
/* use ldap_pvt_strtok instead of strtok or strtok_r! */
LDAP_F(char *) ldap_pvt_strtok LDAP_P(( char *str,
const char *delim, char **pos ));
#ifndef HAVE_STRDUP
/* strdup() is missing, declare our own version */
# undef strdup
# define strdup(s) ber_strdup(s)
#elif !defined(_WIN32)
/* some systems fail to declare strdup */
/* Windows does not require this declaration */
LDAP_LIBC_F(char *) (strdup)();
#endif
/*
* some systems fail to declare strcasecmp() and strncasecmp()
* we need them declared so we can obtain pointers to them
*/
/* we don't want these declared for Windows or Mingw */
#ifndef _WIN32
int (strcasecmp)();
int (strncasecmp)();
#endif
#ifndef SAFEMEMCPY
# if defined( HAVE_MEMMOVE )
# define SAFEMEMCPY( d, s, n ) memmove((d), (s), (n))
# elif defined( HAVE_BCOPY )
# define SAFEMEMCPY( d, s, n ) bcopy((s), (d), (n))
# else
/* nothing left but memcpy() */
# define SAFEMEMCPY( d, s, n ) memcpy((d), (s), (n))
# endif
#endif
#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)
#ifdef NEED_MEMCMP_REPLACEMENT
int (lutil_memcmp)(const void *b1, const void *b2, size_t len);
#define memcmp lutil_memcmp
#endif
void *(lutil_memrchr)(const void *b, int c, size_t n);
/* GNU extension (glibc >= 2.1.91), only declared when defined(_GNU_SOURCE) */
#if defined(HAVE_MEMRCHR) && defined(_GNU_SOURCE)
#define lutil_memrchr(b, c, n) memrchr(b, c, n)
#endif /* ! HAVE_MEMRCHR */
#define STRLENOF(s) (sizeof(s)-1)
#if defined( HAVE_NONPOSIX_STRERROR_R )
# define AC_STRERROR_R(e,b,l) (strerror_r((e), (b), (l)))
#elif defined( HAVE_STRERROR_R )
# define AC_STRERROR_R(e,b,l) (strerror_r((e), (b), (l)) == 0 ? (b) : "Unknown error")
#elif defined( HAVE_SYS_ERRLIST )
# define AC_STRERROR_R(e,b,l) ((e) > -1 && (e) < sys_nerr \
? sys_errlist[(e)] : "Unknown error" )
#elif defined( HAVE_STRERROR )
# define AC_STRERROR_R(e,b,l) (strerror(e)) /* NOTE: may be NULL */
#else
# define AC_STRERROR_R(e,b,l) ("Unknown error")
#endif
#endif /* _AC_STRING_H */
/* Generic time.h */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
#ifndef _AC_TIME_H
#define _AC_TIME_H
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#elif defined(HAVE_SYS_TIME_H)
# include <sys/time.h>
# ifdef HAVE_SYS_TIMEB_H
# include <sys/timeb.h>
# endif
#else
# include <time.h>
#endif
#if defined(_WIN32) && !defined(HAVE_CLOCK_GETTIME)
struct timespec {
time_t tv_sec;
int tv_nsec;
};
#endif
#endif /* _AC_TIME_H */
/* Generic unistd.h */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
#ifndef _AC_UNISTD_H
#define _AC_UNISTD_H
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_PROCESS_H
# include <process.h>
#endif
/* note: callers of crypt(3) should include <ac/crypt.h> */
#if defined(HAVE_GETPASSPHRASE)
LDAP_LIBC_F(char*)(getpassphrase)();
#else
#define getpassphrase(p) lutil_getpass(p)
LDAP_LUTIL_F(char*)(lutil_getpass) LDAP_P((const char *getpass));
#endif
/* getopt() defines may be in separate include file */
#ifdef HAVE_GETOPT_H
# include <getopt.h>
#elif !defined(HAVE_GETOPT)
/* no getopt, assume we need getopt-compat.h */
# include <getopt-compat.h>
#else
/* assume we need to declare these externs */
LDAP_LIBC_V (char *) optarg;
LDAP_LIBC_V (int) optind, opterr, optopt;
#endif
/* use lutil file locking */
#define ldap_lockf(x) lutil_lockf(x)
#define ldap_unlockf(x) lutil_unlockf(x)
#include <lutil_lockf.h>
/*
* Windows: although sleep() will be resolved by both MSVC and Mingw GCC
* linkers, the function is not declared in header files. This is
* because Windows' version of the function is called _sleep(), and it
* is declared in stdlib.h
*/
#ifdef _WIN32
#define sleep _sleep
#endif
#endif /* _AC_UNISTD_H */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
/*
* lber_pvt.h - Header for ber_pvt_ functions.
* These are meant to be internal to OpenLDAP Software.
*/
#ifndef _LBER_PVT_H
#define _LBER_PVT_H 1
#include <lber.h>
LDAP_BEGIN_DECL
/* for allocating aligned buffers (on the stack) */
#define LBER_ALIGNED_BUFFER(uname,size) \
union uname { \
char buffer[size]; \
/* force alignment */ \
int ialign; \
long lalign; \
float falign; \
double dalign; \
char* palign; \
}
#define LBER_ELEMENT_SIZEOF (256) /* must be >= sizeof(BerElement) */
typedef LBER_ALIGNED_BUFFER(lber_berelement_u,LBER_ELEMENT_SIZEOF)
BerElementBuffer;
typedef struct sockbuf_buf {
ber_len_t buf_size;
ber_len_t buf_ptr;
ber_len_t buf_end;
char *buf_base;
} Sockbuf_Buf;
/*
* bprint.c
*/
LBER_V( BER_LOG_PRINT_FN ) ber_pvt_log_print;
LBER_F( int )
ber_pvt_log_printf LDAP_P((
int errlvl,
int loglvl,
const char *fmt,
... )) LDAP_GCCATTR((format(printf, 3, 4)));
/*
* sockbuf.c
*/
LBER_F( ber_slen_t )
ber_pvt_sb_do_write LDAP_P(( Sockbuf_IO_Desc *sbiod, Sockbuf_Buf *buf_out ));
LBER_F( void )
ber_pvt_sb_buf_init LDAP_P(( Sockbuf_Buf *buf ));
LBER_F( void )
ber_pvt_sb_buf_destroy LDAP_P(( Sockbuf_Buf *buf ));
LBER_F( int )
ber_pvt_sb_grow_buffer LDAP_P(( Sockbuf_Buf *buf, ber_len_t minsize ));
LBER_F( ber_len_t )
ber_pvt_sb_copy_out LDAP_P(( Sockbuf_Buf *sbb, char *buf, ber_len_t len ));
LBER_F( int )
ber_pvt_socket_set_nonblock LDAP_P(( ber_socket_t sd, int nb ));
/*
* memory.c
*/
LBER_F( void * )
ber_memalloc_x LDAP_P((
ber_len_t s, void *ctx));
LBER_F( void * )
ber_memrealloc_x LDAP_P((
void* p,
ber_len_t s, void *ctx ));
LBER_F( void * )
ber_memcalloc_x LDAP_P((
ber_len_t n,
ber_len_t s, void *ctx ));
LBER_F( void )
ber_memfree_x LDAP_P((
void* p, void *ctx ));
LBER_F( void )
ber_memvfree_x LDAP_P((
void** vector, void *ctx ));
LBER_F( void )
ber_bvfree_x LDAP_P((
struct berval *bv, void *ctx ));
LBER_F( void )
ber_bvecfree_x LDAP_P((
struct berval **bv, void *ctx ));
LBER_F( int )
ber_bvecadd_x LDAP_P((
struct berval ***bvec,
struct berval *bv, void *ctx ));
LBER_F( struct berval * )
ber_dupbv_x LDAP_P((
struct berval *dst, struct berval *src, void *ctx ));
LBER_F( struct berval * )
ber_str2bv_x LDAP_P((
LDAP_CONST char *, ber_len_t len, int dup, struct berval *bv, void *ctx));
LBER_F( struct berval * )
ber_mem2bv_x LDAP_P((
LDAP_CONST char *, ber_len_t len, int dup, struct berval *bv, void *ctx));
LBER_F( char * )
ber_strdup_x LDAP_P((
LDAP_CONST char *, void *ctx ));
LBER_F( struct berval * )
ber_bvreplace_x LDAP_P((
struct berval *dst, LDAP_CONST struct berval *src, void *ctx ));
LBER_F( void )
ber_bvarray_free_x LDAP_P(( BerVarray p, void *ctx ));
LBER_F( int )
ber_bvarray_add_x LDAP_P(( BerVarray *p, BerValue *bv, void *ctx ));
LBER_F( int )
ber_bvarray_dup_x LDAP_P(( BerVarray *dst, BerVarray src, void *ctx ));
#if 0
#define ber_bvstrcmp(v1,v2) \
((v1)->bv_len < (v2)->bv_len \
? -1 : ((v1)->bv_len > (v2)->bv_len \
? 1 : strncmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) ))
#else
/* avoid strncmp() */
#define ber_bvstrcmp(v1,v2) ber_bvcmp((v1),(v2))
#endif
#define ber_bvstrcasecmp(v1,v2) \
((v1)->bv_len < (v2)->bv_len \
? -1 : ((v1)->bv_len > (v2)->bv_len \
? 1 : strncasecmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) ))
#define ber_bvccmp(v1,c) \
( (v1)->bv_len == 1 && (v1)->bv_val[0] == (c) )
#define ber_strccmp(s,c) \
( (s)[0] == (c) && (s)[1] == '\0' )
#define ber_bvchr(bv,c) \
((char *) memchr( (bv)->bv_val, (c), (bv)->bv_len ))
#define ber_bvrchr(bv,c) \
((char *) lutil_memrchr( (bv)->bv_val, (c), (bv)->bv_len ))
#define ber_bvchr_post(dst,bv,c) \
do { \
(dst)->bv_val = memchr( (bv)->bv_val, (c), (bv)->bv_len ); \
(dst)->bv_len = (dst)->bv_val ? (bv)->bv_len - ((dst)->bv_val - (bv)->bv_val) : 0; \
} while (0)
#define ber_bvchr_pre(dst,bv,c) \
do { \
(dst)->bv_val = memchr( (bv)->bv_val, (c), (bv)->bv_len ); \
(dst)->bv_len = (dst)->bv_val ? ((dst)->bv_val - (bv)->bv_val) : (bv)->bv_len; \
(dst)->bv_val = (bv)->bv_val; \
} while (0)
#define ber_bvrchr_post(dst,bv,c) \
do { \
(dst)->bv_val = lutil_memrchr( (bv)->bv_val, (c), (bv)->bv_len ); \
(dst)->bv_len = (dst)->bv_val ? (bv)->bv_len - ((dst)->bv_val - (bv)->bv_val) : 0; \
} while (0)
#define ber_bvrchr_pre(dst,bv,c) \
do { \
(dst)->bv_val = lutil_memrchr( (bv)->bv_val, (c), (bv)->bv_len ); \
(dst)->bv_len = (dst)->bv_val ? ((dst)->bv_val - (bv)->bv_val) : (bv)->bv_len; \
(dst)->bv_val = (bv)->bv_val; \
} while (0)
#define BER_STRLENOF(s) (sizeof(s)-1)
#define BER_BVC(s) { BER_STRLENOF(s), (char *)(s) }
#define BER_BVNULL { 0L, NULL }
#define BER_BVZERO(bv) \
do { \
(bv)->bv_len = 0; \
(bv)->bv_val = NULL; \
} while (0)
#define BER_BVSTR(bv,s) \
do { \
(bv)->bv_len = BER_STRLENOF(s); \
(bv)->bv_val = (s); \
} while (0)
#define BER_BVISNULL(bv) ((bv)->bv_val == NULL)
#define BER_BVISEMPTY(bv) ((bv)->bv_len == 0)
LDAP_END_DECL
#endif
/* include/lber_types.h. Generated from lber_types.hin by configure. */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
/*
* LBER types
*/
#ifndef _LBER_TYPES_H
#define _LBER_TYPES_H
#include <ldap_cdefs.h>
LDAP_BEGIN_DECL
/* LBER boolean, enum, integers (32 bits or larger) */
#define LBER_INT_T int
/* LBER tags (32 bits or larger) */
#define LBER_TAG_T long
/* LBER socket descriptor */
#define LBER_SOCKET_T int
/* LBER lengths (32 bits or larger) */
#define LBER_LEN_T long
/* ------------------------------------------------------------ */
/* booleans, enumerations, and integers */
typedef LBER_INT_T ber_int_t;
/* signed and unsigned versions */
typedef signed LBER_INT_T ber_sint_t;
typedef unsigned LBER_INT_T ber_uint_t;
/* tags */
typedef unsigned LBER_TAG_T ber_tag_t;
/* "socket" descriptors */
typedef LBER_SOCKET_T ber_socket_t;
/* lengths */
typedef unsigned LBER_LEN_T ber_len_t;
/* signed lengths */
typedef signed LBER_LEN_T ber_slen_t;
LDAP_END_DECL
#endif /* _LBER_TYPES_H */
/* ldap_avl.h - avl tree definitions */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
/* Portions Copyright (c) 1993 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*/
#ifndef _AVL
#define _AVL
#include <ldap_cdefs.h>
/*
* this structure represents a generic avl tree node.
*/
LDAP_BEGIN_DECL
typedef struct avlnode Avlnode;
struct avlnode {
void* avl_data;
struct avlnode *avl_link[2];
char avl_bits[2];
signed char avl_bf;
};
#define avl_left avl_link[0]
#define avl_right avl_link[1]
#define avl_lbit avl_bits[0]
#define avl_rbit avl_bits[1]
typedef struct tavlnode TAvlnode;
struct tavlnode {
void* avl_data;
struct tavlnode *avl_link[2];
char avl_bits[2];
signed char avl_bf;
};
#ifdef AVL_INTERNAL
/* balance factor values */
#define LH (-1)
#define EH 0
#define RH 1
#define avl_bf2str(bf) ((bf) == -1 ? "LH" : (bf) == 0 ? "EH" : (bf) == 1 ? "RH" : "(unknown)" )
/* thread bits */
#define AVL_CHILD 0
#define AVL_THREAD 1
/* avl routines */
#define ldap_avl_getone(x) ((x) == 0 ? 0 : (x)->avl_data)
#define ldap_avl_onenode(x) ((x) == 0 || ((x)->avl_left == 0 && (x)->avl_right == 0))
#endif /* AVL_INTERNALS */
#define ldap_avl_child(x,dir) ((x)->avl_bits[dir]) == AVL_CHILD ? \
(x)->avl_link[dir] : NULL
#define ldap_avl_lchild(x) ldap_avl_child(x,0)
#define ldap_avl_rchild(x) ldap_avl_child(x,1)
typedef int (*AVL_APPLY) LDAP_P((void *, void*));
typedef int (*AVL_CMP) LDAP_P((const void*, const void*));
typedef int (*AVL_DUP) LDAP_P((void*, void*));
typedef void (*AVL_FREE) LDAP_P((void*));
LDAP_AVL_F( int )
ldap_avl_free LDAP_P(( Avlnode *root, AVL_FREE dfree ));
LDAP_AVL_F( int )
ldap_avl_insert LDAP_P((Avlnode **, void*, AVL_CMP, AVL_DUP));
LDAP_AVL_F( void* )
ldap_avl_delete LDAP_P((Avlnode **, void*, AVL_CMP));
LDAP_AVL_F( void* )
ldap_avl_find LDAP_P((Avlnode *, const void*, AVL_CMP));
LDAP_AVL_F( Avlnode* )
ldap_avl_find2 LDAP_P((Avlnode *, const void*, AVL_CMP));
LDAP_AVL_F( void* )
ldap_avl_find_lin LDAP_P((Avlnode *, const void*, AVL_CMP));
#ifdef AVL_NONREENTRANT
LDAP_AVL_F( void* )
ldap_avl_getfirst LDAP_P((Avlnode *));
LDAP_AVL_F( void* )
ldap_avl_getnext LDAP_P((void));
#endif
LDAP_AVL_F( int )
ldap_avl_dup_error LDAP_P((void*, void*));
LDAP_AVL_F( int )
ldap_avl_dup_ok LDAP_P((void*, void*));
LDAP_AVL_F( int )
ldap_avl_apply LDAP_P((Avlnode *, AVL_APPLY, void*, int, int));
LDAP_AVL_F( int )
ldap_avl_prefixapply LDAP_P((Avlnode *, void*, AVL_CMP, void*, AVL_CMP, void*, int));
LDAP_AVL_F( int )
ldap_tavl_free LDAP_P(( TAvlnode *root, AVL_FREE dfree ));
LDAP_AVL_F( int )
ldap_tavl_insert LDAP_P((TAvlnode **, void*, AVL_CMP, AVL_DUP));
LDAP_AVL_F( void* )
ldap_tavl_delete LDAP_P((TAvlnode **, void*, AVL_CMP));
LDAP_AVL_F( void* )
ldap_tavl_find LDAP_P((TAvlnode *, const void*, AVL_CMP));
LDAP_AVL_F( TAvlnode* )
ldap_tavl_find2 LDAP_P((TAvlnode *, const void*, AVL_CMP));
LDAP_AVL_F( TAvlnode* )
ldap_tavl_find3 LDAP_P((TAvlnode *, const void*, AVL_CMP, int *ret));
#define TAVL_DIR_LEFT 0
#define TAVL_DIR_RIGHT 1
LDAP_AVL_F( TAvlnode* )
ldap_tavl_end LDAP_P((TAvlnode *, int direction));
LDAP_AVL_F( TAvlnode* )
ldap_tavl_next LDAP_P((TAvlnode *, int direction));
/* apply traversal types */
#define AVL_PREORDER 1
#define AVL_INORDER 2
#define AVL_POSTORDER 3
/* what apply returns if it ran out of nodes */
#define AVL_NOMORE (-6)
LDAP_END_DECL
#endif /* _AVL */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
/* LDAP C Defines */
#ifndef _LDAP_CDEFS_H
#define _LDAP_CDEFS_H
#if defined(__cplusplus) || defined(c_plusplus)
# define LDAP_BEGIN_DECL extern "C" {
# define LDAP_END_DECL }
#else
# define LDAP_BEGIN_DECL /* begin declarations */
# define LDAP_END_DECL /* end declarations */
#endif
#if !defined(LDAP_NO_PROTOTYPES) && ( defined(LDAP_NEEDS_PROTOTYPES) || \
defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) )
/* ANSI C or C++ */
# define LDAP_P(protos) protos
# define LDAP_CONCAT1(x,y) x ## y
# define LDAP_CONCAT(x,y) LDAP_CONCAT1(x,y)
# define LDAP_STRING(x) #x /* stringify without expanding x */
# define LDAP_XSTRING(x) LDAP_STRING(x) /* expand x, then stringify */
#ifndef LDAP_CONST
# define LDAP_CONST const
#endif
#else /* no prototypes */
/* traditional C */
# define LDAP_P(protos) ()
# define LDAP_CONCAT(x,y) x/**/y
# define LDAP_STRING(x) "x"
#ifndef LDAP_CONST
# define LDAP_CONST /* no const */
#endif
#endif /* no prototypes */
#if (__GNUC__) * 1000 + (__GNUC_MINOR__) >= 2006
# define LDAP_GCCATTR(attrs) __attribute__(attrs)
#else
# define LDAP_GCCATTR(attrs)
#endif
/*
* Support for Windows DLLs.
*
* When external source code includes header files for dynamic libraries,
* the external source code is "importing" DLL symbols into its resulting
* object code. On Windows, symbols imported from DLLs must be explicitly
* indicated in header files with the __declspec(dllimport) directive.
* This is not totally necessary for functions because the compiler
* (gcc or MSVC) will generate stubs when this directive is absent.
* However, this is required for imported variables.
*
* The LDAP libraries, i.e. liblber and libldap, can be built as
* static or shared, based on configuration. Just about all other source
* code in OpenLDAP use these libraries. If the LDAP libraries
* are configured as shared, 'configure' defines the LDAP_LIBS_DYNAMIC
* macro. When other source files include LDAP library headers, the
* LDAP library symbols will automatically be marked as imported. When
* the actual LDAP libraries are being built, the symbols will not
* be marked as imported because the LBER_LIBRARY or LDAP_LIBRARY macros
* will be respectively defined.
*
* Any project outside of OpenLDAP with source code wanting to use
* LDAP dynamic libraries should explicitly define LDAP_LIBS_DYNAMIC.
* This will ensure that external source code appropriately marks symbols
* that will be imported.
*
* The slapd executable, itself, can be used as a dynamic library.
* For example, if a backend module is compiled as shared, it will
* import symbols from slapd. When this happens, the slapd symbols
* must be marked as imported in header files that the backend module
* includes. Remember that slapd links with various static libraries.
* If the LDAP libraries were configured as static, their object
* code is also part of the monolithic slapd executable. Thus, when
* a backend module imports symbols from slapd, it imports symbols from
* all of the static libraries in slapd as well. Thus, the SLAP_IMPORT
* macro, when defined, will appropriately mark symbols as imported.
* This macro should be used by shared backend modules as well as any
* other external source code that imports symbols from the slapd
* executable as if it were a DLL.
*
* Note that we don't actually have to worry about using the
* __declspec(dllexport) directive anywhere. This is because both
* MSVC and Mingw provide alternate (more effective) methods for exporting
* symbols out of binaries, i.e. the use of a DEF file.
*
* NOTE ABOUT BACKENDS: Backends can be configured as static or dynamic.
* When a backend is configured as dynamic, slapd will load the backend
* explicitly and populate function pointer structures by calling
* the backend's well-known initialization function. Because of this
* procedure, slapd never implicitly imports symbols from dynamic backends.
* This makes it unnecessary to tag various backend functions with the
* __declspec(dllimport) directive. This is because neither slapd nor
* any other external binary should ever be implicitly loading a backend
* dynamic module.
*
* Backends are supposed to be self-contained. However, it appears that
* back-meta DOES implicitly import symbols from back-ldap. This means
* that the __declspec(dllimport) directive should be marked on back-ldap
* functions (in its header files) if and only if we're compiling for
* windows AND back-ldap has been configured as dynamic AND back-meta
* is the client of back-ldap. When client is slapd, there is no effect
* since slapd does not implicitly import symbols.
*
* TODO(?): Currently, back-meta nor back-ldap is supported for Mingw32.
* Thus, there's no need to worry about this right now. This is something that
* may or may not have to be addressed in the future.
*/
/* LBER library */
#if defined(_WIN32) && \
((defined(LDAP_LIBS_DYNAMIC) && !defined(LBER_LIBRARY)) || \
(!defined(LDAP_LIBS_DYNAMIC) && defined(SLAPD_IMPORT)))
# define LBER_F(type) extern __declspec(dllimport) type
# define LBER_V(type) extern __declspec(dllimport) type
#else
# define LBER_F(type) extern type
# define LBER_V(type) extern type
#endif
/* LDAP library */
#if defined(_WIN32) && \
((defined(LDAP_LIBS_DYNAMIC) && !defined(LDAP_LIBRARY)) || \
(!defined(LDAP_LIBS_DYNAMIC) && defined(SLAPD_IMPORT)))
# define LDAP_F(type) extern __declspec(dllimport) type
# define LDAP_V(type) extern __declspec(dllimport) type
#else
# define LDAP_F(type) extern type
# define LDAP_V(type) extern type
#endif
/* AVL library */
#if defined(_WIN32) && defined(SLAPD_IMPORT)
# define LDAP_AVL_F(type) extern __declspec(dllimport) type
# define LDAP_AVL_V(type) extern __declspec(dllimport) type
#else
# define LDAP_AVL_F(type) extern type
# define LDAP_AVL_V(type) extern type
#endif
/* LDIF library */
#if defined(_WIN32) && defined(SLAPD_IMPORT)
# define LDAP_LDIF_F(type) extern __declspec(dllimport) type
# define LDAP_LDIF_V(type) extern __declspec(dllimport) type
#else
# define LDAP_LDIF_F(type) extern type
# define LDAP_LDIF_V(type) extern type
#endif
/* LUNICODE library */
#if defined(_WIN32) && defined(SLAPD_IMPORT)
# define LDAP_LUNICODE_F(type) extern __declspec(dllimport) type
# define LDAP_LUNICODE_V(type) extern __declspec(dllimport) type
#else
# define LDAP_LUNICODE_F(type) extern type
# define LDAP_LUNICODE_V(type) extern type
#endif
/* LUTIL library */
#if defined(_WIN32) && defined(SLAPD_IMPORT)
# define LDAP_LUTIL_F(type) extern __declspec(dllimport) type
# define LDAP_LUTIL_V(type) extern __declspec(dllimport) type
#else
# define LDAP_LUTIL_F(type) extern type
# define LDAP_LUTIL_V(type) extern type
#endif
/* REWRITE library */
#if defined(_WIN32) && defined(SLAPD_IMPORT)
# define LDAP_REWRITE_F(type) extern __declspec(dllimport) type
# define LDAP_REWRITE_V(type) extern __declspec(dllimport) type
#else
# define LDAP_REWRITE_F(type) extern type
# define LDAP_REWRITE_V(type) extern type
#endif
/* SLAPD (as a dynamic library exporting symbols) */
#if defined(_WIN32) && defined(SLAPD_IMPORT)
# define LDAP_SLAPD_F(type) extern __declspec(dllimport) type
# define LDAP_SLAPD_V(type) extern __declspec(dllimport) type
#else
# define LDAP_SLAPD_F(type) extern type
# define LDAP_SLAPD_V(type) extern type
#endif
/* SLAPD (as a dynamic library exporting symbols) */
#if defined(_WIN32) && defined(SLAPD_IMPORT)
# define LDAP_SLAPI_F(type) extern __declspec(dllimport) type
# define LDAP_SLAPI_V(type) extern __declspec(dllimport) type
#else
# define LDAP_SLAPI_F(type) extern type
# define LDAP_SLAPI_V(type) extern type
#endif
/* SLAPD (as a dynamic library exporting symbols) */
#if defined(_WIN32) && defined(SLAPD_IMPORT)
# define SLAPI_F(type) extern __declspec(dllimport) type
# define SLAPI_V(type) extern __declspec(dllimport) type
#else
# define SLAPI_F(type) extern type
# define SLAPI_V(type) extern type
#endif
/*
* C library. Mingw32 links with the dynamic C run-time library by default,
* so the explicit definition of CSTATIC will keep dllimport from
* being defined, if desired.
*
* MSVC defines the _DLL macro when the compiler is invoked with /MD or /MDd,
* which means the resulting object code will be linked with the dynamic
* C run-time library.
*
* Technically, it shouldn't be necessary to redefine any functions that
* the headers for the C library should already contain. Nevertheless, this
* is here as a safe-guard.
*
* TODO: Determine if these macros ever get expanded for Windows. If not,
* the declspec expansion can probably be removed.
*/
#if (defined(__MINGW32__) && !defined(CSTATIC)) || \
(defined(_MSC_VER) && defined(_DLL))
# define LDAP_LIBC_F(type) extern __declspec(dllimport) type
# define LDAP_LIBC_V(type) extern __declspec(dllimport) type
#else
# define LDAP_LIBC_F(type) extern type
# define LDAP_LIBC_V(type) extern type
#endif
#endif /* _LDAP_CDEFS_H */
/* Generated from ./ldap_config.hin on Wed 22 Dec 2021 05:22:52 PM CET */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
/*
* This file works in conjunction with OpenLDAP configure system.
* If you do no like the values below, adjust your configure options.
*/
#ifndef _LDAP_CONFIG_H
#define _LDAP_CONFIG_H
/* directory separator */
#ifndef LDAP_DIRSEP
#ifndef _WIN32
#define LDAP_DIRSEP "/"
#else
#define LDAP_DIRSEP "\\"
#endif
#endif
/* directory for temporary files */
#if defined(_WIN32)
# define LDAP_TMPDIR "C:\\." /* we don't have much of a choice */
#elif defined( _P_tmpdir )
# define LDAP_TMPDIR _P_tmpdir
#elif defined( P_tmpdir )
# define LDAP_TMPDIR P_tmpdir
#elif defined( _PATH_TMPDIR )
# define LDAP_TMPDIR _PATH_TMPDIR
#else
# define LDAP_TMPDIR LDAP_DIRSEP "tmp"
#endif
/* directories */
#ifndef LDAP_BINDIR
#define LDAP_BINDIR ""
#endif
#ifndef LDAP_SBINDIR
#define LDAP_SBINDIR ""
#endif
#ifndef LDAP_DATADIR
#define LDAP_DATADIR ""
#endif
#ifndef LDAP_SYSCONFDIR
#define LDAP_SYSCONFDIR ""
#endif
#ifndef LDAP_LIBEXECDIR
#define LDAP_LIBEXECDIR ""
#endif
#ifndef LDAP_MODULEDIR
#define LDAP_MODULEDIR ""
#endif
#ifndef LDAP_RUNDIR
#define LDAP_RUNDIR ""
#endif
#ifndef LDAP_LOCALEDIR
#define LDAP_LOCALEDIR ""
#endif
#endif /* _LDAP_CONFIG_H */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
/* Portions Copyright (c) 1994 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*/
/*
* This file controls defaults for OpenLDAP package.
* You probably do not need to edit the defaults provided by this file.
*/
#ifndef _LDAP_DEFAULTS_H
#define _LDAP_DEFAULTS_H
#include <ldap_config.h>
#define LDAP_CONF_FILE LDAP_SYSCONFDIR LDAP_DIRSEP "ldap.conf"
#define LDAP_USERRC_FILE "ldaprc"
#define LDAP_ENV_PREFIX "LDAP"
/* default ldapi:// socket */
#define LDAPI_SOCK LDAP_RUNDIR LDAP_DIRSEP "run" LDAP_DIRSEP "ldapi"
/*
* SLAPD DEFINITIONS
*/
/* location of the default slapd config file */
#define SLAPD_DEFAULT_CONFIGFILE LDAP_SYSCONFDIR LDAP_DIRSEP "slapd.conf"
#define SLAPD_DEFAULT_CONFIGDIR LDAP_SYSCONFDIR LDAP_DIRSEP "slapd.d"
#define SLAPD_DEFAULT_DB_DIR LDAP_RUNDIR LDAP_DIRSEP "openldap-data"
#define SLAPD_DEFAULT_DB_MODE 0600
#define SLAPD_DEFAULT_UCDATA LDAP_DATADIR LDAP_DIRSEP "ucdata"
/* default max deref depth for aliases */
#define SLAPD_DEFAULT_MAXDEREFDEPTH 15
/* default sizelimit on number of entries from a search */
#define SLAPD_DEFAULT_SIZELIMIT 500
/* default timelimit to spend on a search */
#define SLAPD_DEFAULT_TIMELIMIT 3600
/* the following DNs must be normalized! */
/* dn of the default subschema subentry */
#define SLAPD_SCHEMA_DN "cn=Subschema"
/* dn of the default "monitor" subentry */
#define SLAPD_MONITOR_DN "cn=Monitor"
/*
* LLOADD DEFINITIONS
*/
#define LLOADD_DEFAULT_CONFIGFILE LDAP_SYSCONFDIR LDAP_DIRSEP "lloadd.conf"
#endif /* _LDAP_CONFIG_H */
/* include/ldap_features.h. Generated from ldap_features.hin by configure. */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
/*
* LDAP Features
*/
#ifndef _LDAP_FEATURES_H
#define _LDAP_FEATURES_H 1
/* OpenLDAP API version macros */
#define LDAP_VENDOR_VERSION 000000
#define LDAP_VENDOR_VERSION_MAJOR 2
#define LDAP_VENDOR_VERSION_MINOR X
#define LDAP_VENDOR_VERSION_PATCH X
/*
** WORK IN PROGRESS!
**
** OpenLDAP reentrancy/thread-safeness should be dynamically
** checked using ldap_get_option().
**
** If built with thread support, the -lldap implementation is:
** LDAP_API_FEATURE_THREAD_SAFE (basic thread safety)
** LDAP_API_FEATURE_SESSION_THREAD_SAFE
** LDAP_API_FEATURE_OPERATION_THREAD_SAFE
**
** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
** can be used to determine if -lldap is thread safe at compile
** time.
**
*/
/* is -lldap reentrant or not */
#define LDAP_API_FEATURE_X_OPENLDAP_REENTRANT 1
/* is -lldap thread safe or not */
#define LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE 1
/* LDAP v2 Referrals */
/* #undef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
#endif /* LDAP_FEATURES */
/* ldap_int_thread.h - ldap internal thread wrappers header file */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
LDAP_BEGIN_DECL
/* Can be done twice. See libldap/ldap_thr_debug.h. */
LDAP_F(int) ldap_int_thread_initialize LDAP_P(( void ));
LDAP_F(int) ldap_int_thread_destroy LDAP_P(( void ));
LDAP_END_DECL
#ifndef _LDAP_INT_THREAD_H
#define _LDAP_INT_THREAD_H
#if defined( HAVE_PTHREADS )
/**********************************
* *
* definitions for POSIX Threads *
* *
**********************************/
#include <pthread.h>
#ifdef HAVE_SCHED_H
#include <sched.h>
#endif
LDAP_BEGIN_DECL
typedef pthread_t ldap_int_thread_t;
typedef pthread_mutex_t ldap_int_thread_mutex_t;
typedef pthread_cond_t ldap_int_thread_cond_t;
typedef pthread_key_t ldap_int_thread_key_t;
#define ldap_int_thread_equal(a, b) pthread_equal((a), (b))
#if defined( _POSIX_REENTRANT_FUNCTIONS ) || \
defined( _POSIX_THREAD_SAFE_FUNCTIONS ) || \
defined( _POSIX_THREADSAFE_FUNCTIONS )
#define HAVE_REENTRANT_FUNCTIONS 1
#endif
#if defined( HAVE_PTHREAD_GETCONCURRENCY ) || \
defined( HAVE_THR_GETCONCURRENCY )
#define LDAP_THREAD_HAVE_GETCONCURRENCY 1
#endif
#if defined( HAVE_PTHREAD_SETCONCURRENCY ) || \
defined( HAVE_THR_SETCONCURRENCY )
#define LDAP_THREAD_HAVE_SETCONCURRENCY 1
#endif
#if defined( HAVE_PTHREAD_RWLOCK_DESTROY )
#define LDAP_THREAD_HAVE_RDWR 1
typedef pthread_rwlock_t ldap_int_thread_rdwr_t;
#endif
#ifndef LDAP_INT_MUTEX_NULL
#define LDAP_INT_MUTEX_NULL PTHREAD_MUTEX_INITIALIZER
#define LDAP_INT_MUTEX_FIRSTCREATE(m) ((void) 0)
#endif
LDAP_END_DECL
#elif defined( HAVE_GNU_PTH )
/***********************************
* *
* thread definitions for GNU Pth *
* *
***********************************/
#define PTH_SYSCALL_SOFT 1
#include <pth.h>
LDAP_BEGIN_DECL
typedef pth_t ldap_int_thread_t;
typedef pth_mutex_t ldap_int_thread_mutex_t;
typedef pth_cond_t ldap_int_thread_cond_t;
typedef pth_key_t ldap_int_thread_key_t;
#if 0
#define LDAP_THREAD_HAVE_RDWR 1
typedef pth_rwlock_t ldap_int_thread_rdwr_t;
#endif
#ifndef LDAP_INT_MUTEX_NULL
#define LDAP_INT_MUTEX_NULL PTH_MUTEX_INIT
#define LDAP_INT_MUTEX_FIRSTCREATE(m) ((void) 0)
#endif
LDAP_END_DECL
#elif defined( HAVE_THR )
/********************************************
* *
* thread definitions for Solaris LWP (THR) *
* *
********************************************/
#include <thread.h>
#include <synch.h>
LDAP_BEGIN_DECL
typedef thread_t ldap_int_thread_t;
typedef mutex_t ldap_int_thread_mutex_t;
typedef cond_t ldap_int_thread_cond_t;
typedef thread_key_t ldap_int_thread_key_t;
#define HAVE_REENTRANT_FUNCTIONS 1
#ifdef HAVE_THR_GETCONCURRENCY
#define LDAP_THREAD_HAVE_GETCONCURRENCY 1
#endif
#ifdef HAVE_THR_SETCONCURRENCY
#define LDAP_THREAD_HAVE_SETCONCURRENCY 1
#endif
#ifndef LDAP_INT_MUTEX_NULL
#define LDAP_INT_MUTEX_NULL DEFAULTMUTEX
#define LDAP_INT_MUTEX_FIRSTCREATE(m) ((void) 0)
#endif
#elif defined(HAVE_NT_THREADS)
/*************************************
* *
* thread definitions for NT threads *
* *
*************************************/
#include <process.h>
#include <windows.h>
LDAP_BEGIN_DECL
typedef unsigned long ldap_int_thread_t;
typedef HANDLE ldap_int_thread_mutex_t;
typedef HANDLE ldap_int_thread_cond_t;
typedef DWORD ldap_int_thread_key_t;
LDAP_F( int )
ldap_int_mutex_firstcreate LDAP_P(( ldap_int_thread_mutex_t *mutex ));
#ifndef LDAP_INT_MUTEX_NULL
#define LDAP_INT_MUTEX_NULL ((HANDLE)0)
#define LDAP_INT_MUTEX_FIRSTCREATE(m) \
ldap_int_mutex_firstcreate(&(m))
#endif
LDAP_END_DECL
#else
/***********************************
* *
* thread definitions for no *
* underlying library support *
* *
***********************************/
#ifndef NO_THREADS
#define NO_THREADS 1
#endif
LDAP_BEGIN_DECL
typedef int ldap_int_thread_t;
typedef int ldap_int_thread_mutex_t;
typedef int ldap_int_thread_cond_t;
typedef int ldap_int_thread_key_t;
#define LDAP_THREAD_HAVE_TPOOL 1
typedef int ldap_int_thread_pool_t;
#ifndef LDAP_INT_MUTEX_NULL
#define LDAP_INT_MUTEX_NULL 0
#define LDAP_INT_MUTEX_FIRSTCREATE(m) ((void) 0)
#endif
LDAP_END_DECL
#endif /* no threads support */
LDAP_BEGIN_DECL
#ifndef ldap_int_thread_equal
#define ldap_int_thread_equal(a, b) ((a) == (b))
#endif
#ifndef LDAP_THREAD_HAVE_RDWR
typedef struct ldap_int_thread_rdwr_s * ldap_int_thread_rdwr_t;
#endif
LDAP_F(int) ldap_int_thread_pool_startup ( void );
LDAP_F(int) ldap_int_thread_pool_shutdown ( void );
#ifndef LDAP_THREAD_HAVE_TPOOL
typedef struct ldap_int_thread_pool_s * ldap_int_thread_pool_t;
#endif
LDAP_END_DECL
#if defined(LDAP_THREAD_DEBUG) && !((LDAP_THREAD_DEBUG +0) & 2U)
#define LDAP_THREAD_DEBUG_WRAP 1
#endif
#ifdef LDAP_THREAD_DEBUG_WRAP
/**************************************
* *
* definitions for type-wrapped debug *
* *
**************************************/
LDAP_BEGIN_DECL
#ifndef LDAP_UINTPTR_T /* May be configured in CPPFLAGS */
#define LDAP_UINTPTR_T unsigned long
#endif
typedef enum {
ldap_debug_magic = -(int) (((unsigned)-1)/19)
} ldap_debug_magic_t;
typedef enum {
/* Could fill in "locked" etc here later */
ldap_debug_state_inited = (int) (((unsigned)-1)/11),
ldap_debug_state_destroyed
} ldap_debug_state_t;
typedef struct {
/* Enclosed in magic numbers in the hope of catching overwrites */
ldap_debug_magic_t magic; /* bit pattern to recognize usages */
LDAP_UINTPTR_T self; /* ~(LDAP_UINTPTR_T)&(this struct) */
union ldap_debug_mem_u { /* Dummy memory reference */
unsigned char *ptr;
LDAP_UINTPTR_T num;
} mem;
ldap_debug_state_t state; /* doubles as another magic number */
} ldap_debug_usage_info_t;
typedef struct {
ldap_int_thread_mutex_t wrapped;
ldap_debug_usage_info_t usage;
ldap_int_thread_t owner;
} ldap_debug_thread_mutex_t;
#define LDAP_DEBUG_MUTEX_NULL {LDAP_INT_MUTEX_NULL, {0,0,{0},0} /*,owner*/}
#define LDAP_DEBUG_MUTEX_FIRSTCREATE(m) \
((void) ((m).usage.state || ldap_pvt_thread_mutex_init(&(m))))
typedef struct {
ldap_int_thread_cond_t wrapped;
ldap_debug_usage_info_t usage;
} ldap_debug_thread_cond_t;
typedef struct {
ldap_int_thread_rdwr_t wrapped;
ldap_debug_usage_info_t usage;
} ldap_debug_thread_rdwr_t;
#ifndef NDEBUG
#define LDAP_INT_THREAD_ASSERT_MUTEX_OWNER(mutex) \
ldap_debug_thread_assert_mutex_owner( \
__FILE__, __LINE__, "owns(" #mutex ")", mutex )
LDAP_F(void) ldap_debug_thread_assert_mutex_owner LDAP_P((
LDAP_CONST char *file,
int line,
LDAP_CONST char *msg,
ldap_debug_thread_mutex_t *mutex ));
#endif /* NDEBUG */
LDAP_END_DECL
#endif /* LDAP_THREAD_DEBUG_WRAP */
#endif /* _LDAP_INT_THREAD_H */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
/* Portions Copyright (c) 1990 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*/
#ifndef LDAP_LOG_H
#define LDAP_LOG_H
#include <stdio.h>
#include <ldap_cdefs.h>
LDAP_BEGIN_DECL
/*
* debug reporting levels.
*
* They start with the syslog levels, and
* go down in importance. The normal
* debugging levels begin with LDAP_LEVEL_ENTRY
*
*/
/*
* The "OLD_DEBUG" means that all logging occurs at LOG_DEBUG
*/
#ifdef OLD_DEBUG
/* original behavior: all logging occurs at the same severity level */
#if defined(LDAP_DEBUG) && defined(LDAP_SYSLOG)
#define LDAP_LEVEL_EMERG ldap_syslog_level
#define LDAP_LEVEL_ALERT ldap_syslog_level
#define LDAP_LEVEL_CRIT ldap_syslog_level
#define LDAP_LEVEL_ERR ldap_syslog_level
#define LDAP_LEVEL_WARNING ldap_syslog_level
#define LDAP_LEVEL_NOTICE ldap_syslog_level
#define LDAP_LEVEL_INFO ldap_syslog_level
#define LDAP_LEVEL_DEBUG ldap_syslog_level
#else /* !LDAP_DEBUG || !LDAP_SYSLOG */
#define LDAP_LEVEL_EMERG (7)
#define LDAP_LEVEL_ALERT (7)
#define LDAP_LEVEL_CRIT (7)
#define LDAP_LEVEL_ERR (7)
#define LDAP_LEVEL_WARNING (7)
#define LDAP_LEVEL_NOTICE (7)
#define LDAP_LEVEL_INFO (7)
#define LDAP_LEVEL_DEBUG (7)
#endif /* !LDAP_DEBUG || !LDAP_SYSLOG */
#else /* ! OLD_DEBUG */
/* map syslog onto LDAP severity levels */
#ifdef LOG_DEBUG
#define LDAP_LEVEL_EMERG LOG_EMERG
#define LDAP_LEVEL_ALERT LOG_ALERT
#define LDAP_LEVEL_CRIT LOG_CRIT
#define LDAP_LEVEL_ERR LOG_ERR
#define LDAP_LEVEL_WARNING LOG_WARNING
#define LDAP_LEVEL_NOTICE LOG_NOTICE
#define LDAP_LEVEL_INFO LOG_INFO
#define LDAP_LEVEL_DEBUG LOG_DEBUG
#else /* ! LOG_DEBUG */
#define LDAP_LEVEL_EMERG (0)
#define LDAP_LEVEL_ALERT (1)
#define LDAP_LEVEL_CRIT (2)
#define LDAP_LEVEL_ERR (3)
#define LDAP_LEVEL_WARNING (4)
#define LDAP_LEVEL_NOTICE (5)
#define LDAP_LEVEL_INFO (6)
#define LDAP_LEVEL_DEBUG (7)
#endif /* ! LOG_DEBUG */
#endif /* ! OLD_DEBUG */
#if 0
/* in case we need to reuse the unused bits of severity */
#define LDAP_LEVEL_MASK(s) ((s) & 0x7)
#else
#define LDAP_LEVEL_MASK(s) (s)
#endif
/* (yet) unused */
#define LDAP_LEVEL_ENTRY (0x08) /* log function entry points */
#define LDAP_LEVEL_ARGS (0x10) /* log function call parameters */
#define LDAP_LEVEL_RESULTS (0x20) /* Log function results */
#define LDAP_LEVEL_DETAIL1 (0x40) /* log level 1 function operational details */
#define LDAP_LEVEL_DETAIL2 (0x80) /* Log level 2 function operational details */
/* end of (yet) unused */
/* original subsystem selection mechanism */
#define LDAP_DEBUG_TRACE 0x0001
#define LDAP_DEBUG_PACKETS 0x0002
#define LDAP_DEBUG_ARGS 0x0004
#define LDAP_DEBUG_CONNS 0x0008
#define LDAP_DEBUG_BER 0x0010
#define LDAP_DEBUG_FILTER 0x0020
#define LDAP_DEBUG_CONFIG 0x0040
#define LDAP_DEBUG_ACL 0x0080
#define LDAP_DEBUG_STATS 0x0100
#define LDAP_DEBUG_STATS2 0x0200
#define LDAP_DEBUG_SHELL 0x0400
#define LDAP_DEBUG_PARSE 0x0800
#if 0 /* no longer used (nor supported) */
#define LDAP_DEBUG_CACHE 0x1000
#define LDAP_DEBUG_INDEX 0x2000
#endif
#define LDAP_DEBUG_SYNC 0x4000
#define LDAP_DEBUG_NONE 0x8000
#define LDAP_DEBUG_ANY (-1)
/* debugging stuff */
#ifdef LDAP_DEBUG
/*
* This is a bogus extern declaration for the compiler. No need to ensure
* a 'proper' dllimport.
*/
#ifndef ldap_debug
extern int ldap_debug;
#endif /* !ldap_debug */
#ifdef LDAP_SYSLOG
extern int ldap_syslog;
extern int ldap_syslog_level;
#ifdef HAVE_EBCDIC
#define syslog eb_syslog
extern void eb_syslog(int pri, const char *fmt, ...);
#endif /* HAVE_EBCDIC */
#endif /* LDAP_SYSLOG */
#endif /* LDAP_DEBUG */
/* we keep libldap working with preprocessors that can't do variadic macros */
#ifndef LDAP_INT_DEBUG
/* this doesn't below as part of ldap.h */
#ifdef LDAP_DEBUG
#ifdef LDAP_SYSLOG
#define LogTest(level) ( ( ldap_debug | ldap_syslog ) & (level) )
#define Log(level, severity, ...) \
do { \
if ( ldap_debug & (level) ) \
lutil_debug( ldap_debug, (level), __VA_ARGS__ ); \
if ( ldap_syslog & (level) ) \
syslog( LDAP_LEVEL_MASK((severity)), __VA_ARGS__ ); \
} while ( 0 )
#else /* ! LDAP_SYSLOG */
#define LogTest(level) ( ldap_debug & (level) )
#define Log(level, severity, ...) \
do { \
if ( ldap_debug & (level) ) \
lutil_debug( ldap_debug, (level), __VA_ARGS__ ); \
} while ( 0 )
#endif /* ! LDAP_SYSLOG */
#else /* ! LDAP_DEBUG */
/* TODO: in case LDAP_DEBUG is undefined, make sure logs with appropriate
* severity gets thru anyway */
#define LogTest(level) ( 0 )
#define Log(level, severity, ...) ((void) 0)
#endif /* ! LDAP_DEBUG */
#define Debug(level, ...) \
Log((level), ldap_syslog_level, __VA_ARGS__ )
#endif /* ! LDAP_INT_DEBUG */
/* Actually now in liblber/debug.c */
LDAP_LUTIL_F(int) lutil_debug_file LDAP_P(( FILE *file ));
LDAP_LUTIL_F(void) lutil_debug LDAP_P((
int debug, int level,
const char* fmt, ... )) LDAP_GCCATTR((format(printf, 3, 4)));
#ifdef LDAP_DEFINE_LDAP_DEBUG
/* This struct matches the head of ldapoptions in <ldap-int.h> */
struct ldapoptions_prefix {
short ldo_valid;
int ldo_debug;
};
#define ldap_debug \
(*(int *) ((char *)&ldap_int_global_options \
+ offsetof(struct ldapoptions_prefix, ldo_debug)))
struct ldapoptions;
LDAP_V ( struct ldapoptions ) ldap_int_global_options;
#endif /* LDAP_DEFINE_LDAP_DEBUG */
LDAP_END_DECL
#endif /* LDAP_LOG_H */
/* ldap_pvt_thread.h - ldap threads header file */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
#ifndef _LDAP_PVT_THREAD_H
#define _LDAP_PVT_THREAD_H /* libldap/ldap_thr_debug.h #undefines this */
#include "ldap_cdefs.h"
#include "ldap_int_thread.h"
LDAP_BEGIN_DECL
#ifndef LDAP_PVT_THREAD_H_DONE
typedef ldap_int_thread_t ldap_pvt_thread_t;
#ifdef LDAP_THREAD_DEBUG_WRAP
typedef ldap_debug_thread_mutex_t ldap_pvt_thread_mutex_t;
typedef ldap_debug_thread_cond_t ldap_pvt_thread_cond_t;
typedef ldap_debug_thread_rdwr_t ldap_pvt_thread_rdwr_t;
#define LDAP_PVT_MUTEX_FIRSTCREATE LDAP_DEBUG_MUTEX_FIRSTCREATE
#define LDAP_PVT_MUTEX_NULL LDAP_DEBUG_MUTEX_NULL
#else
typedef ldap_int_thread_mutex_t ldap_pvt_thread_mutex_t;
typedef ldap_int_thread_cond_t ldap_pvt_thread_cond_t;
typedef ldap_int_thread_rdwr_t ldap_pvt_thread_rdwr_t;
#define LDAP_PVT_MUTEX_FIRSTCREATE LDAP_INT_MUTEX_FIRSTCREATE
#define LDAP_PVT_MUTEX_NULL LDAP_INT_MUTEX_NULL
#endif
typedef ldap_int_thread_key_t ldap_pvt_thread_key_t;
#endif /* !LDAP_PVT_THREAD_H_DONE */
#define ldap_pvt_thread_equal ldap_int_thread_equal
LDAP_F( int )
ldap_pvt_thread_initialize LDAP_P(( void ));
LDAP_F( int )
ldap_pvt_thread_destroy LDAP_P(( void ));
LDAP_F( unsigned int )
ldap_pvt_thread_sleep LDAP_P(( unsigned int s ));
LDAP_F( int )
ldap_pvt_thread_get_concurrency LDAP_P(( void ));
LDAP_F( int )
ldap_pvt_thread_set_concurrency LDAP_P(( int ));
#define LDAP_PVT_THREAD_CREATE_JOINABLE 0
#define LDAP_PVT_THREAD_CREATE_DETACHED 1
#ifndef LDAP_PVT_THREAD_H_DONE
#define LDAP_PVT_THREAD_SET_STACK_SIZE
/* The size may be explicitly #defined to zero to disable it. */
#if defined( LDAP_PVT_THREAD_STACK_SIZE ) && LDAP_PVT_THREAD_STACK_SIZE == 0
# undef LDAP_PVT_THREAD_SET_STACK_SIZE
#elif !defined( LDAP_PVT_THREAD_STACK_SIZE )
/* LARGE stack. Will be twice as large on 64 bit machine. */
# define LDAP_PVT_THREAD_STACK_SIZE ( 1 * 1024 * 1024 * sizeof(void *) )
#endif
#endif /* !LDAP_PVT_THREAD_H_DONE */
LDAP_F( int )
ldap_pvt_thread_create LDAP_P((
ldap_pvt_thread_t * thread,
int detach,
void *(*start_routine)( void * ),
void *arg));
LDAP_F( void )
ldap_pvt_thread_exit LDAP_P(( void *retval ));
LDAP_F( int )
ldap_pvt_thread_join LDAP_P(( ldap_pvt_thread_t thread, void **status ));
LDAP_F( int )
ldap_pvt_thread_kill LDAP_P(( ldap_pvt_thread_t thread, int signo ));
LDAP_F( int )
ldap_pvt_thread_yield LDAP_P(( void ));
LDAP_F( int )
ldap_pvt_thread_cond_init LDAP_P(( ldap_pvt_thread_cond_t *cond ));
LDAP_F( int )
ldap_pvt_thread_cond_destroy LDAP_P(( ldap_pvt_thread_cond_t *cond ));
LDAP_F( int )
ldap_pvt_thread_cond_signal LDAP_P(( ldap_pvt_thread_cond_t *cond ));
LDAP_F( int )
ldap_pvt_thread_cond_broadcast LDAP_P(( ldap_pvt_thread_cond_t *cond ));
LDAP_F( int )
ldap_pvt_thread_cond_wait LDAP_P((
ldap_pvt_thread_cond_t *cond,
ldap_pvt_thread_mutex_t *mutex ));
LDAP_F( int )
ldap_pvt_thread_mutex_init LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
LDAP_F( int )
ldap_pvt_thread_mutex_recursive_init LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
LDAP_F( int )
ldap_pvt_thread_mutex_destroy LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
LDAP_F( int )
ldap_pvt_thread_mutex_lock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
LDAP_F( int )
ldap_pvt_thread_mutex_trylock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
LDAP_F( int )
ldap_pvt_thread_mutex_unlock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
LDAP_F( ldap_pvt_thread_t )
ldap_pvt_thread_self LDAP_P(( void ));
#ifdef LDAP_INT_THREAD_ASSERT_MUTEX_OWNER
#define LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER LDAP_INT_THREAD_ASSERT_MUTEX_OWNER
#else
#define LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER(mutex) ((void) 0)
#endif
LDAP_F( int )
ldap_pvt_thread_rdwr_init LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
LDAP_F( int )
ldap_pvt_thread_rdwr_destroy LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
LDAP_F( int )
ldap_pvt_thread_rdwr_rlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
LDAP_F( int )
ldap_pvt_thread_rdwr_rtrylock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
LDAP_F( int )
ldap_pvt_thread_rdwr_runlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
LDAP_F( int )
ldap_pvt_thread_rdwr_wlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
LDAP_F( int )
ldap_pvt_thread_rdwr_wtrylock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
LDAP_F( int )
ldap_pvt_thread_rdwr_wunlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
LDAP_F( int )
ldap_pvt_thread_key_create LDAP_P((ldap_pvt_thread_key_t *keyp));
LDAP_F( int )
ldap_pvt_thread_key_destroy LDAP_P((ldap_pvt_thread_key_t key));
LDAP_F( int )
ldap_pvt_thread_key_setdata LDAP_P((ldap_pvt_thread_key_t key, void *data));
LDAP_F( int )
ldap_pvt_thread_key_getdata LDAP_P((ldap_pvt_thread_key_t key, void **data));
#ifdef LDAP_DEBUG
LDAP_F( int )
ldap_pvt_thread_rdwr_readers LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
LDAP_F( int )
ldap_pvt_thread_rdwr_writers LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
LDAP_F( int )
ldap_pvt_thread_rdwr_active LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
#endif /* LDAP_DEBUG */
#define LDAP_PVT_THREAD_EINVAL EINVAL
#define LDAP_PVT_THREAD_EBUSY EINVAL
#ifndef LDAP_PVT_THREAD_H_DONE
typedef ldap_int_thread_pool_t ldap_pvt_thread_pool_t;
typedef void * (ldap_pvt_thread_start_t) LDAP_P((void *ctx, void *arg));
typedef int (ldap_pvt_thread_walk_t) LDAP_P((ldap_pvt_thread_start_t *start, void *start_arg, void *arg));
typedef void (ldap_pvt_thread_pool_keyfree_t) LDAP_P((void *key, void *data));
#endif /* !LDAP_PVT_THREAD_H_DONE */
LDAP_F( int )
ldap_pvt_thread_pool_init LDAP_P((
ldap_pvt_thread_pool_t *pool_out,
int max_threads,
int max_pending ));
LDAP_F( int )
ldap_pvt_thread_pool_init_q LDAP_P((
ldap_pvt_thread_pool_t *pool_out,
int max_threads,
int max_pending,
int num_qs ));
LDAP_F( int )
ldap_pvt_thread_pool_submit LDAP_P((
ldap_pvt_thread_pool_t *pool,
ldap_pvt_thread_start_t *start,
void *arg ));
LDAP_F( int )
ldap_pvt_thread_pool_submit2 LDAP_P((
ldap_pvt_thread_pool_t *pool,
ldap_pvt_thread_start_t *start,
void *arg,
void **cookie ));
LDAP_F( int )
ldap_pvt_thread_pool_retract LDAP_P((
void *cookie ));
LDAP_F( int )
ldap_pvt_thread_pool_walk LDAP_P((
ldap_pvt_thread_pool_t *pool,
ldap_pvt_thread_start_t *start,
ldap_pvt_thread_walk_t *cb,
void *arg ));
LDAP_F( int )
ldap_pvt_thread_pool_maxthreads LDAP_P((
ldap_pvt_thread_pool_t *pool,
int max_threads ));
LDAP_F( int )
ldap_pvt_thread_pool_queues LDAP_P((
ldap_pvt_thread_pool_t *pool,
int numqs ));
#ifndef LDAP_PVT_THREAD_H_DONE
typedef enum {
LDAP_PVT_THREAD_POOL_PARAM_UNKNOWN = -1,
LDAP_PVT_THREAD_POOL_PARAM_MAX,
LDAP_PVT_THREAD_POOL_PARAM_MAX_PENDING,
LDAP_PVT_THREAD_POOL_PARAM_OPEN,
LDAP_PVT_THREAD_POOL_PARAM_STARTING,
LDAP_PVT_THREAD_POOL_PARAM_ACTIVE,
LDAP_PVT_THREAD_POOL_PARAM_PAUSING,
LDAP_PVT_THREAD_POOL_PARAM_PENDING,
LDAP_PVT_THREAD_POOL_PARAM_BACKLOAD,
LDAP_PVT_THREAD_POOL_PARAM_ACTIVE_MAX,
LDAP_PVT_THREAD_POOL_PARAM_PENDING_MAX,
LDAP_PVT_THREAD_POOL_PARAM_BACKLOAD_MAX,
LDAP_PVT_THREAD_POOL_PARAM_STATE
} ldap_pvt_thread_pool_param_t;
#endif /* !LDAP_PVT_THREAD_H_DONE */
LDAP_F( int )
ldap_pvt_thread_pool_query LDAP_P((
ldap_pvt_thread_pool_t *pool,
ldap_pvt_thread_pool_param_t param, void *value ));
LDAP_F( int )
ldap_pvt_thread_pool_pausing LDAP_P((
ldap_pvt_thread_pool_t *pool ));
LDAP_F( int )
ldap_pvt_thread_pool_backload LDAP_P((
ldap_pvt_thread_pool_t *pool ));
LDAP_F( void )
ldap_pvt_thread_pool_idle LDAP_P((
ldap_pvt_thread_pool_t *pool ));
LDAP_F( void )
ldap_pvt_thread_pool_unidle LDAP_P((
ldap_pvt_thread_pool_t *pool ));
LDAP_F( int )
ldap_pvt_thread_pool_pausecheck LDAP_P((
ldap_pvt_thread_pool_t *pool ));
LDAP_F( int )
ldap_pvt_thread_pool_pausecheck_native LDAP_P((
ldap_pvt_thread_pool_t *pool ));
LDAP_F( int )
ldap_pvt_thread_pool_pause LDAP_P((
ldap_pvt_thread_pool_t *pool ));
LDAP_F( int )
ldap_pvt_thread_pool_resume LDAP_P((
ldap_pvt_thread_pool_t *pool ));
LDAP_F( int )
ldap_pvt_thread_pool_destroy LDAP_P((
ldap_pvt_thread_pool_t *pool,
int run_pending ));
LDAP_F( int )
ldap_pvt_thread_pool_close LDAP_P((
ldap_pvt_thread_pool_t *pool,
int run_pending ));
LDAP_F( int )
ldap_pvt_thread_pool_free LDAP_P((
ldap_pvt_thread_pool_t *pool ));
LDAP_F( int )
ldap_pvt_thread_pool_getkey LDAP_P((
void *ctx,
void *key,
void **data,
ldap_pvt_thread_pool_keyfree_t **kfree ));
LDAP_F( int )
ldap_pvt_thread_pool_setkey LDAP_P((
void *ctx,
void *key,
void *data,
ldap_pvt_thread_pool_keyfree_t *kfree,
void **olddatap,
ldap_pvt_thread_pool_keyfree_t **oldkfreep ));
LDAP_F( void )
ldap_pvt_thread_pool_purgekey LDAP_P(( void *key ));
LDAP_F( void *)
ldap_pvt_thread_pool_context LDAP_P(( void ));
LDAP_F( void )
ldap_pvt_thread_pool_context_reset LDAP_P(( void *key ));
LDAP_F( ldap_pvt_thread_t )
ldap_pvt_thread_pool_tid LDAP_P(( void *ctx ));
LDAP_END_DECL
#define LDAP_PVT_THREAD_H_DONE
#endif /* _LDAP_PVT_THREAD_H */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
/*
* ldap_pvt_uc.h - Header for Unicode functions.
* These are meant to be used by the OpenLDAP distribution only.
* These should be named ldap_pvt_....()
*/
#ifndef _LDAP_PVT_UC_H
#define _LDAP_PVT_UC_H 1
#include <lber.h> /* get ber_slen_t */
#include <ac/bytes.h>
LDAP_BEGIN_DECL
/*
* UTF-8 (in utf-8.c)
*/
/* UCDATA uses UCS-2 passed in a 4 byte unsigned int */
typedef ac_uint4 ldap_unicode_t;
/* Convert a string with csize octets per character to UTF-8 */
LDAP_F( int ) ldap_ucs_to_utf8s LDAP_P((
struct berval *ucs, int csize, struct berval *utf8s ));
/* returns the number of bytes in the UTF-8 string */
LDAP_F (ber_len_t) ldap_utf8_bytes( const char * );
/* returns the number of UTF-8 characters in the string */
LDAP_F (ber_len_t) ldap_utf8_chars( const char * );
/* returns the length (in bytes) of the UTF-8 character */
LDAP_F (int) ldap_utf8_offset( const char * );
/* returns the length (in bytes) indicated by the UTF-8 character */
LDAP_F (int) ldap_utf8_charlen( const char * );
/* returns the length (in bytes) indicated by the UTF-8 character
* also checks that shortest possible encoding was used
*/
LDAP_F (int) ldap_utf8_charlen2( const char * );
/* copies a UTF-8 character and returning number of bytes copied */
LDAP_F (int) ldap_utf8_copy( char *, const char *);
/* returns pointer of next UTF-8 character in string */
LDAP_F (char*) ldap_utf8_next( const char * );
/* returns pointer of previous UTF-8 character in string */
LDAP_F (char*) ldap_utf8_prev( const char * );
/* primitive ctype routines -- not aware of non-ascii characters */
LDAP_F (int) ldap_utf8_isascii( const char * );
LDAP_F (int) ldap_utf8_isalpha( const char * );
LDAP_F (int) ldap_utf8_isalnum( const char * );
LDAP_F (int) ldap_utf8_isdigit( const char * );
LDAP_F (int) ldap_utf8_isxdigit( const char * );
LDAP_F (int) ldap_utf8_isspace( const char * );
/* span characters not in set, return bytes spanned */
LDAP_F (ber_len_t) ldap_utf8_strcspn( const char* str, const char *set);
/* span characters in set, return bytes spanned */
LDAP_F (ber_len_t) ldap_utf8_strspn( const char* str, const char *set);
/* return first occurrence of character in string */
LDAP_F (char *) ldap_utf8_strchr( const char* str, const char *chr);
/* return first character of set in string */
LDAP_F (char *) ldap_utf8_strpbrk( const char* str, const char *set);
/* reentrant tokenizer */
LDAP_F (char*) ldap_utf8_strtok( char* sp, const char* sep, char **last);
/* Optimizations */
LDAP_V (const char) ldap_utf8_lentab[128];
LDAP_V (const char) ldap_utf8_mintab[32];
#define LDAP_UTF8_ISASCII(p) ( !(*(const unsigned char *)(p) & 0x80 ) )
#define LDAP_UTF8_CHARLEN(p) ( LDAP_UTF8_ISASCII(p) \
? 1 : ldap_utf8_lentab[*(const unsigned char *)(p) ^ 0x80] )
/* This is like CHARLEN but additionally validates to make sure
* the char used the shortest possible encoding.
* 'l' is used to temporarily hold the result of CHARLEN.
*/
#define LDAP_UTF8_CHARLEN2(p, l) ( ( ( l = LDAP_UTF8_CHARLEN( p )) < 3 || \
( ldap_utf8_mintab[*(const unsigned char *)(p) & 0x1f] & (p)[1] ) ) ? \
l : 0 )
#define LDAP_UTF8_OFFSET(p) ( LDAP_UTF8_ISASCII(p) \
? 1 : ldap_utf8_offset((p)) )
#define LDAP_UTF8_COPY(d,s) ( LDAP_UTF8_ISASCII(s) \
? (*(d) = *(s), 1) : ldap_utf8_copy((d),(s)) )
#define LDAP_UTF8_NEXT(p) ( LDAP_UTF8_ISASCII(p) \
? (char *)(p)+1 : ldap_utf8_next((p)) )
#define LDAP_UTF8_INCR(p) ((p) = LDAP_UTF8_NEXT(p))
/* For symmetry */
#define LDAP_UTF8_PREV(p) (ldap_utf8_prev((p)))
#define LDAP_UTF8_DECR(p) ((p)=LDAP_UTF8_PREV((p)))
/* these probably should be renamed */
LDAP_LUNICODE_F(int) ucstrncmp(
const ldap_unicode_t *,
const ldap_unicode_t *,
ber_len_t );
LDAP_LUNICODE_F(int) ucstrncasecmp(
const ldap_unicode_t *,
const ldap_unicode_t *,
ber_len_t );
LDAP_LUNICODE_F(ldap_unicode_t *) ucstrnchr(
const ldap_unicode_t *,
ber_len_t,
ldap_unicode_t );
LDAP_LUNICODE_F(ldap_unicode_t *) ucstrncasechr(
const ldap_unicode_t *,
ber_len_t,
ldap_unicode_t );
LDAP_LUNICODE_F(void) ucstr2upper(
ldap_unicode_t *,
ber_len_t );
#define LDAP_UTF8_NOCASEFOLD 0x0U
#define LDAP_UTF8_CASEFOLD 0x1U
#define LDAP_UTF8_ARG1NFC 0x2U
#define LDAP_UTF8_ARG2NFC 0x4U
#define LDAP_UTF8_APPROX 0x8U
LDAP_LUNICODE_F(struct berval *) UTF8bvnormalize(
struct berval *,
struct berval *,
unsigned,
void *memctx );
LDAP_LUNICODE_F(int) UTF8bvnormcmp(
struct berval *,
struct berval *,
unsigned,
void *memctx );
LDAP_END_DECL
#endif
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
/* ldap-schema.h - Header for basic schema handling functions that can be
* used by both clients and servers.
* these routines should be renamed ldap_x_...
*/
#ifndef _LDAP_SCHEMA_H
#define _LDAP_SCHEMA_H 1
#include <ldap_cdefs.h>
LDAP_BEGIN_DECL
/* Codes for parsing errors */
#define LDAP_SCHERR_OUTOFMEM 1
#define LDAP_SCHERR_UNEXPTOKEN 2
#define LDAP_SCHERR_NOLEFTPAREN 3
#define LDAP_SCHERR_NORIGHTPAREN 4
#define LDAP_SCHERR_NODIGIT 5
#define LDAP_SCHERR_BADNAME 6
#define LDAP_SCHERR_BADDESC 7
#define LDAP_SCHERR_BADSUP 8
#define LDAP_SCHERR_DUPOPT 9
#define LDAP_SCHERR_EMPTY 10
#define LDAP_SCHERR_MISSING 11
#define LDAP_SCHERR_OUT_OF_ORDER 12
typedef struct ldap_schema_extension_item {
char *lsei_name;
char **lsei_values;
} LDAPSchemaExtensionItem;
typedef struct ldap_syntax {
char *syn_oid; /* REQUIRED */
char **syn_names; /* OPTIONAL */
char *syn_desc; /* OPTIONAL */
LDAPSchemaExtensionItem **syn_extensions; /* OPTIONAL */
} LDAPSyntax;
typedef struct ldap_matchingrule {
char *mr_oid; /* REQUIRED */
char **mr_names; /* OPTIONAL */
char *mr_desc; /* OPTIONAL */
int mr_obsolete; /* OPTIONAL */
char *mr_syntax_oid; /* REQUIRED */
LDAPSchemaExtensionItem **mr_extensions; /* OPTIONAL */
} LDAPMatchingRule;
typedef struct ldap_matchingruleuse {
char *mru_oid; /* REQUIRED */
char **mru_names; /* OPTIONAL */
char *mru_desc; /* OPTIONAL */
int mru_obsolete; /* OPTIONAL */
char **mru_applies_oids; /* REQUIRED */
LDAPSchemaExtensionItem **mru_extensions; /* OPTIONAL */
} LDAPMatchingRuleUse;
typedef struct ldap_attributetype {
char *at_oid; /* REQUIRED */
char **at_names; /* OPTIONAL */
char *at_desc; /* OPTIONAL */
int at_obsolete; /* 0=no, 1=yes */
char *at_sup_oid; /* OPTIONAL */
char *at_equality_oid; /* OPTIONAL */
char *at_ordering_oid; /* OPTIONAL */
char *at_substr_oid; /* OPTIONAL */
char *at_syntax_oid; /* OPTIONAL */
int at_syntax_len; /* OPTIONAL */
int at_single_value; /* 0=no, 1=yes */
int at_collective; /* 0=no, 1=yes */
int at_no_user_mod; /* 0=no, 1=yes */
int at_usage; /* 0=userApplications, 1=directoryOperation,
2=distributedOperation, 3=dSAOperation */
LDAPSchemaExtensionItem **at_extensions; /* OPTIONAL */
} LDAPAttributeType;
typedef struct ldap_objectclass {
char *oc_oid; /* REQUIRED */
char **oc_names; /* OPTIONAL */
char *oc_desc; /* OPTIONAL */
int oc_obsolete; /* 0=no, 1=yes */
char **oc_sup_oids; /* OPTIONAL */
int oc_kind; /* 0=ABSTRACT, 1=STRUCTURAL, 2=AUXILIARY */
char **oc_at_oids_must; /* OPTIONAL */
char **oc_at_oids_may; /* OPTIONAL */
LDAPSchemaExtensionItem **oc_extensions; /* OPTIONAL */
} LDAPObjectClass;
typedef struct ldap_contentrule {
char *cr_oid; /* REQUIRED */
char **cr_names; /* OPTIONAL */
char *cr_desc; /* OPTIONAL */
char **cr_sup_oids; /* OPTIONAL */
int cr_obsolete; /* 0=no, 1=yes */
char **cr_oc_oids_aux; /* OPTIONAL */
char **cr_at_oids_must; /* OPTIONAL */
char **cr_at_oids_may; /* OPTIONAL */
char **cr_at_oids_not; /* OPTIONAL */
LDAPSchemaExtensionItem **cr_extensions; /* OPTIONAL */
} LDAPContentRule;
typedef struct ldap_nameform {
char *nf_oid; /* REQUIRED */
char **nf_names; /* OPTIONAL */
char *nf_desc; /* OPTIONAL */
int nf_obsolete; /* 0=no, 1=yes */
char *nf_objectclass; /* REQUIRED */
char **nf_at_oids_must; /* REQUIRED */
char **nf_at_oids_may; /* OPTIONAL */
LDAPSchemaExtensionItem **nf_extensions; /* OPTIONAL */
} LDAPNameForm;
typedef struct ldap_structurerule {
int sr_ruleid; /* REQUIRED */
char **sr_names; /* OPTIONAL */
char *sr_desc; /* OPTIONAL */
int sr_obsolete; /* 0=no, 1=yes */
char *sr_nameform; /* REQUIRED */
int sr_nsup_ruleids;/* number of sr_sup_ruleids */
int *sr_sup_ruleids;/* OPTIONAL */
LDAPSchemaExtensionItem **sr_extensions; /* OPTIONAL */
} LDAPStructureRule;
/*
* Misc macros
*/
#define LDAP_SCHEMA_NO 0
#define LDAP_SCHEMA_YES 1
#define LDAP_SCHEMA_USER_APPLICATIONS 0
#define LDAP_SCHEMA_DIRECTORY_OPERATION 1
#define LDAP_SCHEMA_DISTRIBUTED_OPERATION 2
#define LDAP_SCHEMA_DSA_OPERATION 3
#define LDAP_SCHEMA_ABSTRACT 0
#define LDAP_SCHEMA_STRUCTURAL 1
#define LDAP_SCHEMA_AUXILIARY 2
/*
* Flags that control how liberal the parsing routines are.
*/
#define LDAP_SCHEMA_ALLOW_NONE 0x00U /* Strict parsing */
#define LDAP_SCHEMA_ALLOW_NO_OID 0x01U /* Allow missing oid */
#define LDAP_SCHEMA_ALLOW_QUOTED 0x02U /* Allow bogus extra quotes */
#define LDAP_SCHEMA_ALLOW_DESCR 0x04U /* Allow descr instead of OID */
#define LDAP_SCHEMA_ALLOW_DESCR_PREFIX 0x08U /* Allow descr as OID prefix */
#define LDAP_SCHEMA_ALLOW_OID_MACRO 0x10U /* Allow OID macros in slapd */
#define LDAP_SCHEMA_ALLOW_OUT_OF_ORDER_FIELDS 0x20U /* Allow fields in most any order */
#define LDAP_SCHEMA_ALLOW_ALL 0x3fU /* Be very liberal in parsing */
#define LDAP_SCHEMA_SKIP 0x80U /* Don't malloc any result */
LDAP_F( LDAP_CONST char * )
ldap_syntax2name LDAP_P((
LDAPSyntax * syn ));
LDAP_F( LDAP_CONST char * )
ldap_matchingrule2name LDAP_P((
LDAPMatchingRule * mr ));
LDAP_F( LDAP_CONST char * )
ldap_matchingruleuse2name LDAP_P((
LDAPMatchingRuleUse * mru ));
LDAP_F( LDAP_CONST char * )
ldap_attributetype2name LDAP_P((
LDAPAttributeType * at ));
LDAP_F( LDAP_CONST char * )
ldap_objectclass2name LDAP_P((
LDAPObjectClass * oc ));
LDAP_F( LDAP_CONST char * )
ldap_contentrule2name LDAP_P((
LDAPContentRule * cr ));
LDAP_F( LDAP_CONST char * )
ldap_nameform2name LDAP_P((
LDAPNameForm * nf ));
LDAP_F( LDAP_CONST char * )
ldap_structurerule2name LDAP_P((
LDAPStructureRule * sr ));
LDAP_F( void )
ldap_syntax_free LDAP_P((
LDAPSyntax * syn ));
LDAP_F( void )
ldap_matchingrule_free LDAP_P((
LDAPMatchingRule * mr ));
LDAP_F( void )
ldap_matchingruleuse_free LDAP_P((
LDAPMatchingRuleUse * mr ));
LDAP_F( void )
ldap_attributetype_free LDAP_P((
LDAPAttributeType * at ));
LDAP_F( void )
ldap_objectclass_free LDAP_P((
LDAPObjectClass * oc ));
LDAP_F( void )
ldap_contentrule_free LDAP_P((
LDAPContentRule * cr ));
LDAP_F( void )
ldap_nameform_free LDAP_P((
LDAPNameForm * nf ));
LDAP_F( void )
ldap_structurerule_free LDAP_P((
LDAPStructureRule * sr ));
LDAP_F( LDAPStructureRule * )
ldap_str2structurerule LDAP_P((
LDAP_CONST char * s,
int * code,
LDAP_CONST char ** errp,
LDAP_CONST unsigned flags ));
LDAP_F( LDAPNameForm * )
ldap_str2nameform LDAP_P((
LDAP_CONST char * s,
int * code,
LDAP_CONST char ** errp,
LDAP_CONST unsigned flags ));
LDAP_F( LDAPContentRule * )
ldap_str2contentrule LDAP_P((
LDAP_CONST char * s,
int * code,
LDAP_CONST char ** errp,
LDAP_CONST unsigned flags ));
LDAP_F( LDAPObjectClass * )
ldap_str2objectclass LDAP_P((
LDAP_CONST char * s,
int * code,
LDAP_CONST char ** errp,
LDAP_CONST unsigned flags ));
LDAP_F( LDAPAttributeType * )
ldap_str2attributetype LDAP_P((
LDAP_CONST char * s,
int * code,
LDAP_CONST char ** errp,
LDAP_CONST unsigned flags ));
LDAP_F( LDAPSyntax * )
ldap_str2syntax LDAP_P((
LDAP_CONST char * s,
int * code,
LDAP_CONST char ** errp,
LDAP_CONST unsigned flags ));
LDAP_F( LDAPMatchingRule * )
ldap_str2matchingrule LDAP_P((
LDAP_CONST char * s,
int * code,
LDAP_CONST char ** errp,
LDAP_CONST unsigned flags ));
LDAP_F( LDAPMatchingRuleUse * )
ldap_str2matchingruleuse LDAP_P((
LDAP_CONST char * s,
int * code,
LDAP_CONST char ** errp,
LDAP_CONST unsigned flags ));
LDAP_F( char * )
ldap_structurerule2str LDAP_P((
LDAPStructureRule * sr ));
LDAP_F( struct berval * )
ldap_structurerule2bv LDAP_P((
LDAPStructureRule * sr, struct berval *bv ));
LDAP_F( char * )
ldap_nameform2str LDAP_P((
LDAPNameForm * nf ));
LDAP_F( struct berval * )
ldap_nameform2bv LDAP_P((
LDAPNameForm * nf, struct berval *bv ));
LDAP_F( char * )
ldap_contentrule2str LDAP_P((
LDAPContentRule * cr ));
LDAP_F( struct berval * )
ldap_contentrule2bv LDAP_P((
LDAPContentRule * cr, struct berval *bv ));
LDAP_F( char * )
ldap_objectclass2str LDAP_P((
LDAPObjectClass * oc ));
LDAP_F( struct berval * )
ldap_objectclass2bv LDAP_P((
LDAPObjectClass * oc, struct berval *bv ));
LDAP_F( char * )
ldap_attributetype2str LDAP_P((
LDAPAttributeType * at ));
LDAP_F( struct berval * )
ldap_attributetype2bv LDAP_P((
LDAPAttributeType * at, struct berval *bv ));
LDAP_F( char * )
ldap_syntax2str LDAP_P((
LDAPSyntax * syn ));
LDAP_F( struct berval * )
ldap_syntax2bv LDAP_P((
LDAPSyntax * syn, struct berval *bv ));
LDAP_F( char * )
ldap_matchingrule2str LDAP_P((
LDAPMatchingRule * mr ));
LDAP_F( struct berval * )
ldap_matchingrule2bv LDAP_P((
LDAPMatchingRule * mr, struct berval *bv ));
LDAP_F( char * )
ldap_matchingruleuse2str LDAP_P((
LDAPMatchingRuleUse * mru ));
LDAP_F( struct berval * )
ldap_matchingruleuse2bv LDAP_P((
LDAPMatchingRuleUse * mru, struct berval *bv ));
LDAP_F( char * )
ldap_scherr2str LDAP_P((
int code )) LDAP_GCCATTR((const));
LDAP_END_DECL
#endif
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
/* This notice applies to changes, created by or for Novell, Inc.,
* to preexisting works for which notices appear elsewhere in this file.
*
* Copyright (C) 2000 Novell, Inc. All Rights Reserved.
*
* THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND TREATIES.
* USE, MODIFICATION, AND REDISTRIBUTION OF THIS WORK IS SUBJECT TO VERSION
* 2.0.1 OF THE OPENLDAP PUBLIC LICENSE, A COPY OF WHICH IS AVAILABLE AT
* HTTP://WWW.OPENLDAP.ORG/LICENSE.HTML OR IN THE FILE "LICENSE" IN THE
* TOP-LEVEL DIRECTORY OF THE DISTRIBUTION. ANY USE OR EXPLOITATION OF THIS
* WORK OTHER THAN AS AUTHORIZED IN VERSION 2.0.1 OF THE OPENLDAP PUBLIC
* LICENSE, OR OTHER PRIOR WRITTEN CONSENT FROM NOVELL, COULD SUBJECT THE
* PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
*/
/* Note: A verbatim copy of version 2.0.1 of the OpenLDAP Public License
* can be found in the file "build/LICENSE-2.0.1" in this distribution
* of OpenLDAP Software.
*/
#ifndef _LDAP_UTF8_H
#define _LDAP_UTF8_H
#include <lber_types.h> /* get ber_*_t */
/*
* UTF-8 Utility Routines
*/
LDAP_BEGIN_DECL
#define LDAP_UCS4_INVALID (0x80000000U)
typedef ber_int_t ldap_ucs4_t;
/* LDAP_MAX_UTF8_LEN is 3 or 6 depending on size of wchar_t */
#define LDAP_MAX_UTF8_LEN ( sizeof(wchar_t) * 3/2 )
/* Unicode conversion routines */
LDAP_F( ldap_ucs4_t ) ldap_x_utf8_to_ucs4( LDAP_CONST char * p );
LDAP_F( int ) ldap_x_ucs4_to_utf8( ldap_ucs4_t c, char *buf );
/*
* Wide Char / UTF-8 Conversion Routines
*/
/* UTF-8 character to Wide Char */
LDAP_F(int) ldap_x_utf8_to_wc LDAP_P((
wchar_t *wchar, LDAP_CONST char *utf8char ));
/* UTF-8 string to Wide Char string */
LDAP_F(int) ldap_x_utf8s_to_wcs LDAP_P((
wchar_t *wcstr, LDAP_CONST char *utf8str, size_t count ));
/* Wide Char to UTF-8 character */
LDAP_F(int) ldap_x_wc_to_utf8 LDAP_P((
char *utf8char, wchar_t wchar, size_t count ));
/* Wide Char string to UTF-8 string */
LDAP_F(int) ldap_x_wcs_to_utf8s LDAP_P((
char *utf8str, LDAP_CONST wchar_t *wcstr, size_t count ));
/*
* MultiByte Char / UTF-8 Conversion Routines
*/
/* UTF-8 character to MultiByte character */
LDAP_F(int) ldap_x_utf8_to_mb LDAP_P((
char *mbchar, LDAP_CONST char *utf8char,
int (*ldap_f_wctomb)( char *mbchar, wchar_t wchar )));
/* UTF-8 string to MultiByte string */
LDAP_F(int) ldap_x_utf8s_to_mbs LDAP_P((
char *mbstr, LDAP_CONST char *utf8str, size_t count,
size_t (*ldap_f_wcstombs)( char *mbstr,
LDAP_CONST wchar_t *wcstr, size_t count) ));
/* MultiByte character to UTF-8 character */
LDAP_F(int) ldap_x_mb_to_utf8 LDAP_P((
char *utf8char, LDAP_CONST char *mbchar, size_t mbsize,
int (*ldap_f_mbtowc)( wchar_t *wchar,
LDAP_CONST char *mbchar, size_t count) ));
/* MultiByte string to UTF-8 string */
LDAP_F(int) ldap_x_mbs_to_utf8s LDAP_P((
char *utf8str, LDAP_CONST char *mbstr, size_t count,
size_t (*ldap_f_mbstowcs)( wchar_t *wcstr,
LDAP_CONST char *mbstr, size_t count) ));
LDAP_END_DECL
#endif /* _LDAP_UTF8_H */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
/* Portions Copyright (c) 1996 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*/
#ifndef _LDIF_H
#define _LDIF_H
#include <ldap_cdefs.h>
LDAP_BEGIN_DECL
/* This is NOT a bogus extern declaration (unlike ldap_debug) */
LDAP_LDIF_V (int) ldif_debug;
#define LDIF_LINE_WIDTH 78 /* default maximum length of LDIF lines */
#define LDIF_LINE_WIDTH_MAX ((ber_len_t)-1) /* maximum length of LDIF lines */
#define LDIF_LINE_WIDTH_WRAP(wrap) ((wrap) == 0 ? LDIF_LINE_WIDTH : (wrap))
/*
* Macro to calculate maximum number of bytes that the base64 equivalent
* of an item that is "len" bytes long will take up. Base64 encoding
* uses one byte for every six bits in the value plus up to two pad bytes.
*/
#define LDIF_BASE64_LEN(len) (((len) * 4 / 3 ) + 3)
/*
* Macro to calculate maximum size that an LDIF-encoded type (length
* tlen) and value (length vlen) will take up: room for type + ":: " +
* first newline + base64 value + continued lines. Each continued line
* needs room for a newline and a leading space character.
*/
#define LDIF_SIZE_NEEDED(nlen,vlen) LDIF_SIZE_NEEDED_WRAP(nlen, vlen, 0)
#define LDIF_SIZE_NEEDED_WRAP(nlen,vlen,wrap) \
((nlen) + 4 + LDIF_BASE64_LEN(vlen) \
+ ((wrap) == 0 ? ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / ( LDIF_LINE_WIDTH-1 ) * 2 ) : \
((wrap) == LDIF_LINE_WIDTH_MAX ? 0 : ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / (wrap-1) * 2 ))))
LDAP_LDIF_F( int )
ldif_parse_line LDAP_P((
LDAP_CONST char *line,
char **name,
char **value,
ber_len_t *vlen ));
LDAP_LDIF_F( int )
ldif_parse_line2 LDAP_P((
char *line,
struct berval *type,
struct berval *value,
int *freeval ));
LDAP_LDIF_F( FILE * )
ldif_open_url LDAP_P(( LDAP_CONST char *urlstr ));
LDAP_LDIF_F( int )
ldif_fetch_url LDAP_P((
LDAP_CONST char *line,
char **value,
ber_len_t *vlen ));
LDAP_LDIF_F( char * )
ldif_getline LDAP_P(( char **next ));
LDAP_LDIF_F( int )
ldif_countlines LDAP_P(( LDAP_CONST char *line ));
/* ldif_ropen, rclose, read_record - just for reading LDIF files,
* no special open/close needed to write LDIF files.
*/
typedef struct LDIFFP {
FILE *fp;
struct LDIFFP *prev;
} LDIFFP;
LDAP_LDIF_F( LDIFFP * )
ldif_open LDAP_P(( LDAP_CONST char *file, LDAP_CONST char *mode ));
/* ldif_open equivalent that opens ldif stream in memory rather than from file */
LDAP_LDIF_F( LDIFFP * )
ldif_open_mem LDAP_P(( char *ldif, size_t size, LDAP_CONST char *mode ));
LDAP_LDIF_F( void )
ldif_close LDAP_P(( LDIFFP * ));
LDAP_LDIF_F( int )
ldif_read_record LDAP_P((
LDIFFP *fp,
unsigned long *lineno,
char **bufp,
int *buflen ));
LDAP_LDIF_F( int )
ldif_must_b64_encode_register LDAP_P((
LDAP_CONST char *name,
LDAP_CONST char *oid ));
LDAP_LDIF_F( void )
ldif_must_b64_encode_release LDAP_P(( void ));
#define LDIF_PUT_NOVALUE 0x0000 /* no value */
#define LDIF_PUT_VALUE 0x0001 /* value w/ auto detection */
#define LDIF_PUT_TEXT 0x0002 /* assume text */
#define LDIF_PUT_BINARY 0x0004 /* assume binary (convert to base64) */
#define LDIF_PUT_B64 0x0008 /* pre-converted base64 value */
#define LDIF_PUT_COMMENT 0x0010 /* comment */
#define LDIF_PUT_URL 0x0020 /* url */
#define LDIF_PUT_SEP 0x0040 /* separator */
LDAP_LDIF_F( void )
ldif_sput LDAP_P((
char **out,
int type,
LDAP_CONST char *name,
LDAP_CONST char *val,
ber_len_t vlen ));
LDAP_LDIF_F( void )
ldif_sput_wrap LDAP_P((
char **out,
int type,
LDAP_CONST char *name,
LDAP_CONST char *val,
ber_len_t vlen,
ber_len_t wrap ));
LDAP_LDIF_F( char * )
ldif_put LDAP_P((
int type,
LDAP_CONST char *name,
LDAP_CONST char *val,
ber_len_t vlen ));
LDAP_LDIF_F( char * )
ldif_put_wrap LDAP_P((
int type,
LDAP_CONST char *name,
LDAP_CONST char *val,
ber_len_t vlen,
ber_len_t wrap ));
LDAP_LDIF_F( int )
ldif_is_not_printable LDAP_P((
LDAP_CONST char *val,
ber_len_t vlen ));
LDAP_END_DECL
#endif /* _LDIF_H */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
#ifndef _LUTIL_H
#define _LUTIL_H 1
#include <ldap_cdefs.h>
#include <lber_types.h>
#include <ac/socket.h>
#ifdef HAVE_TCPD
# include <tcpd.h>
# define LUTIL_STRING_UNKNOWN STRING_UNKNOWN
#else /* ! TCP Wrappers */
# define LUTIL_STRING_UNKNOWN "unknown"
#endif /* ! TCP Wrappers */
/*
* Include file for LDAP utility routine
*/
LDAP_BEGIN_DECL
/* n octets encode into ceiling(n/3) * 4 bytes */
/* Avoid floating point math through extra padding */
#define LUTIL_BASE64_ENCODE_LEN(n) (((n)+2)/3 * 4)
#define LUTIL_BASE64_DECODE_LEN(n) ((n)/4*3)
/* ISC Base64 Routines */
/* base64.c */
LDAP_LUTIL_F( int )
lutil_b64_ntop LDAP_P((
unsigned char const *,
size_t,
char *,
size_t));
LDAP_LUTIL_F( int )
lutil_b64_pton LDAP_P((
char const *,
unsigned char *,
size_t));
/* detach.c */
LDAP_LUTIL_F( int )
lutil_detach LDAP_P((
int debug,
int do_close));
/* entropy.c */
LDAP_LUTIL_F( int )
lutil_entropy LDAP_P((
unsigned char *buf,
ber_len_t nbytes ));
/* passfile.c */
struct berval; /* avoid pulling in lber.h */
LDAP_LUTIL_F( int )
lutil_get_filed_password LDAP_P((
const char *filename,
struct berval * ));
/* passwd.c */
struct lutil_pw_scheme;
#define LUTIL_PASSWD_OK (0)
#define LUTIL_PASSWD_ERR (-1)
typedef int (LUTIL_PASSWD_CHK_FUNC)(
const struct berval *scheme,
const struct berval *passwd,
const struct berval *cred,
const char **text );
typedef int (LUTIL_PASSWD_HASH_FUNC) (
const struct berval *scheme,
const struct berval *passwd,
struct berval *hash,
const char **text );
LDAP_LUTIL_F( int )
lutil_passwd_add LDAP_P((
struct berval *scheme,
LUTIL_PASSWD_CHK_FUNC *chk_fn,
LUTIL_PASSWD_HASH_FUNC *hash_fn ));
LDAP_LUTIL_F( void )
lutil_passwd_init LDAP_P(( void ));
LDAP_LUTIL_F( void )
lutil_passwd_destroy LDAP_P(( void ));
LDAP_LUTIL_F( int )
lutil_authpasswd LDAP_P((
const struct berval *passwd, /* stored password */
const struct berval *cred, /* user supplied value */
const char **methods ));
LDAP_LUTIL_F( int )
lutil_authpasswd_hash LDAP_P((
const struct berval *cred,
struct berval **passwd, /* password to store */
struct berval **salt, /* salt to store */
const char *method ));
#ifdef SLAPD_CRYPT
typedef int (lutil_cryptfunc) LDAP_P((
const char *key,
const char *salt,
char **hash ));
LDAP_LUTIL_V (lutil_cryptfunc *) lutil_cryptptr;
#endif
LDAP_LUTIL_F( int )
lutil_passwd LDAP_P((
const struct berval *passwd, /* stored password */
const struct berval *cred, /* user supplied value */
const char **methods,
const char **text )); /* error message */
LDAP_LUTIL_F( int )
lutil_passwd_generate LDAP_P(( struct berval *pw, ber_len_t ));
LDAP_LUTIL_F( int )
lutil_passwd_hash LDAP_P((
const struct berval *passwd,
const char *method,
struct berval *hash,
const char **text ));
LDAP_LUTIL_F( int )
lutil_passwd_scheme LDAP_P((
const char *scheme ));
LDAP_LUTIL_F( int )
lutil_salt_format LDAP_P((
const char *format ));
LDAP_LUTIL_F( int )
lutil_passwd_string64 LDAP_P((
const struct berval *sc,
const struct berval *hash,
struct berval *b64,
const struct berval *salt ));
/* utils.c */
LDAP_LUTIL_F( char* )
lutil_progname LDAP_P((
const char* name,
int argc,
char *argv[] ));
typedef struct lutil_tm {
int tm_sec; /* seconds 0-60 (1 leap second) */
int tm_min; /* minutes 0-59 */
int tm_hour; /* hours 0-23 */
int tm_mday; /* day 1-31 */
int tm_mon; /* month 0-11 */
int tm_year; /* year - 1900 */
int tm_nsec; /* nanoseconds */
int tm_usub; /* submicro */
} lutil_tm;
typedef struct lutil_timet {
unsigned int tt_sec; /* seconds since epoch, 0000 or 1970 */
int tt_gsec; /* seconds since epoch, high 7 bits, maybe sign-flipped */
/* sign flipped to sort properly as unsigned ints */
unsigned int tt_nsec; /* nanoseconds */
} lutil_timet;
/* Parse a timestamp string into a structure */
LDAP_LUTIL_F( int )
lutil_parsetime LDAP_P((
char *atm, struct lutil_tm * ));
/* Convert structured time to time in seconds since 1970 (Unix epoch) */
LDAP_LUTIL_F( int )
lutil_tm2time LDAP_P((
struct lutil_tm *, struct lutil_timet * ));
/* Convert structured time to time in seconds since 0000 (Proleptic Gregorian) */
LDAP_LUTIL_F( int )
lutil_tm2gtime LDAP_P((
struct lutil_tm *, struct lutil_timet * ));
#ifdef _WIN32
LDAP_LUTIL_F( void )
lutil_slashpath LDAP_P(( char* path ));
#define LUTIL_SLASHPATH(p) lutil_slashpath(p)
#else
#define LUTIL_SLASHPATH(p)
#endif
LDAP_LUTIL_F( char* )
lutil_strcopy LDAP_P(( char *dst, const char *src ));
LDAP_LUTIL_F( char* )
lutil_strncopy LDAP_P(( char *dst, const char *src, size_t n ));
LDAP_LUTIL_F( char* )
lutil_memcopy LDAP_P(( char *dst, const char *src, size_t n ));
#define lutil_strbvcopy(a, bv) lutil_memcopy((a),(bv)->bv_val,(bv)->bv_len)
struct tm;
/* use this macro to statically allocate buffer for lutil_gentime */
#define LDAP_LUTIL_GENTIME_BUFSIZE 22
#define lutil_gentime(s,m,t) lutil_localtime((s),(m),(t),0)
LDAP_LUTIL_F( size_t )
lutil_localtime LDAP_P(( char *s, size_t smax, const struct tm *tm,
long delta ));
#ifndef HAVE_MKSTEMP
LDAP_LUTIL_F( int )
mkstemp LDAP_P (( char * template ));
#endif
/* sockpair.c */
LDAP_LUTIL_F( int )
lutil_pair( ber_socket_t sd[2] );
/* uuid.c */
/* use this macro to allocate buffer for lutil_uuidstr */
#define LDAP_LUTIL_UUIDSTR_BUFSIZE 40
LDAP_LUTIL_F( size_t )
lutil_uuidstr( char *buf, size_t len );
LDAP_LUTIL_F( int )
lutil_uuidstr_from_normalized(
char *uuid,
size_t uuidlen,
char *buf,
size_t buflen );
/*
* Sometimes not all declarations in a header file are needed.
* An indicator to this is whether or not the symbol's type has
* been defined. Thus, we don't need to include a symbol if
* its type has not been defined through another header file.
*/
#ifdef HAVE_NT_SERVICE_MANAGER
LDAP_LUTIL_V (int) is_NT_Service;
#ifdef _LDAP_PVT_THREAD_H
LDAP_LUTIL_V (ldap_pvt_thread_cond_t) started_event;
#endif /* _LDAP_PVT_THREAD_H */
/* macros are different between Windows and Mingw */
#if defined(_WINSVC_H) || defined(_WINSVC_)
LDAP_LUTIL_V (SERVICE_STATUS) lutil_ServiceStatus;
LDAP_LUTIL_V (SERVICE_STATUS_HANDLE) hlutil_ServiceStatus;
#endif /* _WINSVC_H */
LDAP_LUTIL_F (void)
lutil_CommenceStartupProcessing( char *serverName, void (*stopper)(int)) ;
LDAP_LUTIL_F (void)
lutil_ReportShutdownComplete( void );
LDAP_LUTIL_F (void *)
lutil_getRegParam( char *svc, char *value );
LDAP_LUTIL_F (int)
lutil_srv_install( char* service, char * displayName, char* filename,
int auto_start );
LDAP_LUTIL_F (int)
lutil_srv_remove ( char* service, char* filename );
#endif /* HAVE_NT_SERVICE_MANAGER */
#ifdef HAVE_NT_EVENT_LOG
LDAP_LUTIL_F (void)
lutil_LogStartedEvent( char *svc, int slap_debug, char *configfile, char *urls );
LDAP_LUTIL_F (void)
lutil_LogStoppedEvent( char *svc );
#endif
#ifdef HAVE_EBCDIC
/* Generally this has only been used to put '\n' to stdout. We need to
* make sure it is output in EBCDIC.
*/
#undef putchar
#undef putc
#define putchar(c) putc((c), stdout)
#define putc(c,fp) do { char x=(c); __atoe_l(&x,1); putc(x,fp); } while(0)
#endif
LDAP_LUTIL_F (int)
lutil_atoix( int *v, const char *s, int x );
LDAP_LUTIL_F (int)
lutil_atoux( unsigned *v, const char *s, int x );
LDAP_LUTIL_F (int)
lutil_atolx( long *v, const char *s, int x );
LDAP_LUTIL_F (int)
lutil_atoulx( unsigned long *v, const char *s, int x );
#define lutil_atoi(v, s) lutil_atoix((v), (s), 10)
#define lutil_atou(v, s) lutil_atoux((v), (s), 10)
#define lutil_atol(v, s) lutil_atolx((v), (s), 10)
#define lutil_atoul(v, s) lutil_atoulx((v), (s), 10)
#ifdef HAVE_LONG_LONG
#if defined(HAVE_STRTOLL) || defined(HAVE_STRTOQ)
LDAP_LUTIL_F (int)
lutil_atollx( long long *v, const char *s, int x );
#define lutil_atoll(v, s) lutil_atollx((v), (s), 10)
#endif /* HAVE_STRTOLL || HAVE_STRTOQ */
#if defined(HAVE_STRTOULL) || defined(HAVE_STRTOUQ)
LDAP_LUTIL_F (int)
lutil_atoullx( unsigned long long *v, const char *s, int x );
#define lutil_atoull(v, s) lutil_atoullx((v), (s), 10)
#endif /* HAVE_STRTOULL || HAVE_STRTOUQ */
#endif /* HAVE_LONG_LONG */
LDAP_LUTIL_F (int)
lutil_str2bin( struct berval *in, struct berval *out, void *ctx );
/* Parse and unparse time intervals */
LDAP_LUTIL_F (int)
lutil_parse_time( const char *in, unsigned long *tp );
LDAP_LUTIL_F (int)
lutil_unparse_time( char *buf, size_t buflen, unsigned long t );
#ifdef timerdiv
#define lutil_timerdiv timerdiv
#else /* ! timerdiv */
/* works inplace (x == t) */
#define lutil_timerdiv(t,d,x) \
do { \
time_t s = (t)->tv_sec; \
assert( d > 0 ); \
(x)->tv_sec = s / d; \
(x)->tv_usec = ( (t)->tv_usec + 1000000 * ( s % d ) ) / d; \
} while ( 0 )
#endif /* ! timerdiv */
#ifdef timermul
#define lutil_timermul timermul
#else /* ! timermul */
/* works inplace (x == t) */
#define lutil_timermul(t,m,x) \
do { \
time_t u = (t)->tv_usec * m; \
assert( m > 0 ); \
(x)->tv_sec = (t)->tv_sec * m + u / 1000000; \
(x)->tv_usec = u % 1000000; \
} while ( 0 );
#endif /* ! timermul */
LDAP_END_DECL
#endif /* _LUTIL_H */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
/* File locking methods
*
* lutil_lockf() will block until an exclusive lock is acquired.
*/
#ifndef _LUTIL_LOCKF_H_
#define _LUTIL_LOCKF_H_
LDAP_BEGIN_DECL
LDAP_LUTIL_F( int )
lutil_lockf LDAP_P(( int fd ));
LDAP_LUTIL_F( int )
lutil_unlockf LDAP_P(( int fd ));
LDAP_END_DECL
#endif /* _LUTIL_LOCKF_H_ */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 2019-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* 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>.
*/
/* openldap.h - Header for openldap specific interfaces. */
#ifndef _OPENLDAP_H
#define _OPENLDAP_H 1
#include <ldap.h>
LDAP_BEGIN_DECL
#define LDAP_PROTO_TCP 1 /* ldap:// */
#define LDAP_PROTO_UDP 2 /* reserved */
#define LDAP_PROTO_IPC 3 /* ldapi:// */
#define LDAP_PROTO_EXT 4 /* user-defined socket/sockbuf */
LDAP_F( int )
ldap_init_fd LDAP_P((
ber_socket_t fd,
int proto,
LDAP_CONST char *url,
LDAP **ldp ));
LDAP_END_DECL
#endif /* _OPENLDAP_H */
/*
* Copyright 2022 Hans Leidekker for CodeWeavers
*
* Minimal compatible sasl.h header
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef SASL_H
#define SASL_H 1
#define SASL_VERSION_MAJOR 2
#define SASL_VERSION_MINOR 1
#define SASL_CONTINUE 1
#define SASL_INTERACT 2
#define SASL_OK 0
#define SASL_FAIL -1
#define SASL_NOMEM -2
#define SASL_BUFOVER -3
#define SASL_NOMECH -4
#define SASL_BADPROT -5
#define SASL_NOTDONE -6
#define SASL_BADPARAM -7
#define SASL_TRYAGAIN -8
#define SASL_BADMAC -9
#define SASL_BADSERV -10
#define SASL_WRONGMECH -11
#define SASL_NOTINIT -12
#define SASL_BADAUTH -13
#define SASL_NOAUTHZ -14
#define SASL_TOOWEAK -15
#define SASL_ENCRYPT -16
typedef unsigned int sasl_ssf_t;
#define SASL_SEC_NOPLAINTEXT 0x0001
#define SASL_SEC_NOACTIVE 0x0002
#define SASL_SEC_NODICTIONARY 0x0004
#define SASL_SEC_FORWARD_SECRECY 0x0008
#define SASL_SEC_NOANONYMOUS 0x0010
#define SASL_SEC_PASS_CREDENTIALS 0x0020
#define SASL_SEC_MUTUAL_AUTH 0x0040
#define SASL_SEC_MAXIMUM 0x00FF
typedef struct sasl_security_properties
{
sasl_ssf_t min_ssf;
sasl_ssf_t max_ssf;
unsigned int maxbufsize;
unsigned int security_flags;
const char **property_names;
const char **property_values;
} sasl_security_properties_t;
#define SASL_CB_LIST_END 0
#define SASL_CB_USER 0x4001
#define SASL_CB_AUTHNAME 0x4002
#define SASL_CB_PASS 0x4004
#define SASL_CB_ECHOPROMPT 0x4005
#define SASL_CB_NOECHOPROMPT 0x4006
#define SASL_CB_GETREALM 0x4008
typedef struct sasl_callback
{
unsigned long id;
int (*proc)(void);
void *context;
} sasl_callback_t;
typedef struct sasl_interact
{
unsigned long id;
const char *challenge;
const char *prompt;
const char *defresult;
const void *result;
unsigned len;
} sasl_interact_t;
#define SASL_USERNAME 0
#define SASL_SSF 1
#define SASL_MAXOUTBUF 2
typedef struct sasl_conn sasl_conn_t;
#define SASL_SSF_EXTERNAL 100
#define SASL_SEC_PROPS 101
#define SASL_AUTH_EXTERNAL 102
int sasl_client_init(const sasl_callback_t *);
int sasl_client_new(const char *, const char *, const char *, const char *, const sasl_callback_t *,
unsigned int, sasl_conn_t **);
int sasl_client_start(sasl_conn_t *conn, const char *, sasl_interact_t **, const char **, unsigned int *,
const char **);
int sasl_client_step(sasl_conn_t *conn, const char *, unsigned int, sasl_interact_t **, const char **,
unsigned int *);
int sasl_decode(sasl_conn_t *, const char *, unsigned int, const char **, unsigned int *);
void sasl_dispose(sasl_conn_t **);
int sasl_encode(sasl_conn_t *, const char *, unsigned int, const char **, unsigned int *);
const char *sasl_errdetail(sasl_conn_t *);
const char *sasl_errstring(int, const char *, const char **);
int sasl_getprop(sasl_conn_t *, int, const void **);
const char **sasl_global_listmech(void);
void sasl_set_mutex(void *, void *, void *, void *);
int sasl_setprop(sasl_conn_t *, int, const void *);
#endif /* SASL_H */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
/*
* Copyright (c) 1991 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*/
/* ACKNOWLEDGEMENTS:
* This work was originally developed by the University of Michigan
* (as part of U-MICH LDAP).
*/
#include "portable.h"
#include <stdio.h>
#include <ac/ctype.h>
#include <ac/stdarg.h>
#include <ac/string.h>
#include "lber-int.h"
#define ber_log_check(errlvl, loglvl) ((errlvl) & (loglvl))
BER_LOG_FN ber_int_log_proc = NULL;
/*
* We don't just set ber_pvt_err_file to stderr here, because in NT,
* stderr is a symbol imported from a DLL. As such, the compiler
* doesn't recognize the symbol as having a constant address. Thus
* we set ber_pvt_err_file to stderr later, when it first gets
* referenced.
*/
FILE *ber_pvt_err_file = NULL;
/*
* ber errno
*/
BER_ERRNO_FN ber_int_errno_fn = NULL;
int * ber_errno_addr(void)
{
static int ber_int_errno = LBER_ERROR_NONE;
if( ber_int_errno_fn ) {
return (*ber_int_errno_fn)();
}
return &ber_int_errno;
}
/*
* Print stuff
*/
void ber_error_print( LDAP_CONST char *data )
{
assert( data != NULL );
if (!ber_pvt_err_file) ber_pvt_err_file = stderr;
fputs( data, ber_pvt_err_file );
/* Print to both streams */
if (ber_pvt_err_file != stderr) {
fputs( data, stderr );
fflush( stderr );
}
fflush( ber_pvt_err_file );
}
BER_LOG_PRINT_FN ber_pvt_log_print = ber_error_print;
/*
* lber log
*/
int ber_pvt_log_output(
const char *subsystem,
int level,
const char *fmt,
... )
{
char buf[1024];
va_list vl;
va_start( vl, fmt );
if ( ber_int_log_proc != NULL ) {
ber_int_log_proc( ber_pvt_err_file, subsystem, level, fmt, vl );
} else {
int level;
ber_get_option( NULL, LBER_OPT_BER_DEBUG, &level );
buf[sizeof(buf) - 1] = '\0';
vsnprintf( buf, sizeof(buf)-1, fmt, vl );
if ( ber_log_check( LDAP_DEBUG_BER, level ) ) {
(*ber_pvt_log_print)( buf );
}
}
va_end(vl);
return 1;
}
int ber_pvt_log_printf( int errlvl, int loglvl, const char *fmt, ... )
{
char buf[1024];
va_list ap;
assert( fmt != NULL );
if ( !ber_log_check( errlvl, loglvl )) {
return 0;
}
va_start( ap, fmt );
buf[sizeof(buf) - 1] = '\0';
vsnprintf( buf, sizeof(buf)-1, fmt, ap );
va_end(ap);
(*ber_pvt_log_print)( buf );
return 1;
}
#if 0
static int ber_log_puts(int errlvl, int loglvl, char *buf)
{
assert( buf != NULL );
if ( !ber_log_check( errlvl, loglvl )) {
return 0;
}
(*ber_pvt_log_print)( buf );
return 1;
}
#endif
/*
* Print arbitrary stuff, for debugging.
*/
int
ber_log_bprint(int errlvl,
int loglvl,
const char *data,
ber_len_t len )
{
assert( data != NULL );
if ( !ber_log_check( errlvl, loglvl )) {
return 0;
}
ber_bprint(data, len);
return 1;
}
void
ber_bprint(
LDAP_CONST char *data,
ber_len_t len )
{
static const char hexdig[] = "0123456789abcdef";
#define BP_OFFSET 9
#define BP_GRAPH 60
#define BP_LEN 80
char line[BP_LEN];
ber_len_t i;
assert( data != NULL );
/* in case len is zero */
line[0] = '\n';
line[1] = '\0';
for ( i = 0 ; i < len ; i++ ) {
int n = i % 16;
unsigned off;
if( !n ) {
if( i ) (*ber_pvt_log_print)( line );
memset( line, ' ', sizeof(line)-2 );
line[sizeof(line)-2] = '\n';
line[sizeof(line)-1] = '\0';
off = i % 0x0ffffU;
line[2] = hexdig[0x0f & (off >> 12)];
line[3] = hexdig[0x0f & (off >> 8)];
line[4] = hexdig[0x0f & (off >> 4)];
line[5] = hexdig[0x0f & off];
line[6] = ':';
}
off = BP_OFFSET + n*3 + ((n >= 8)?1:0);
line[off] = hexdig[0x0f & ( data[i] >> 4 )];
line[off+1] = hexdig[0x0f & data[i]];
off = BP_GRAPH + n + ((n >= 8)?1:0);
if ( isprint( (unsigned char) data[i] )) {
line[BP_GRAPH + n] = data[i];
} else {
line[BP_GRAPH + n] = '.';
}
}
(*ber_pvt_log_print)( line );
}
int
ber_log_dump(
int errlvl,
int loglvl,
BerElement *ber,
int inout )
{
assert( ber != NULL );
assert( LBER_VALID( ber ) );
if ( !ber_log_check( errlvl, loglvl )) {
return 0;
}
ber_dump(ber, inout);
return 1;
}
void
ber_dump(
BerElement *ber,
int inout )
{
char buf[132];
ber_len_t len;
assert( ber != NULL );
assert( LBER_VALID( ber ) );
if ( inout == 1 ) {
len = ber_pvt_ber_remaining(ber);
} else {
len = ber_pvt_ber_write(ber);
}
sprintf( buf, "ber_dump: buf=%p ptr=%p end=%p len=%ld\n",
ber->ber_buf,
ber->ber_ptr,
ber->ber_end,
(long) len );
(void) (*ber_pvt_log_print)( buf );
ber_bprint( ber->ber_ptr, len );
}
typedef struct seqorset Seqorset;
/* Exists for binary compatibility with OpenLDAP 2.4.17-- */
int
ber_log_sos_dump(
int errlvl,
int loglvl,
Seqorset *sos )
{
return 0;
}
/* Exists for binary compatibility with OpenLDAP 2.4.17-- */
void
ber_sos_dump(
Seqorset *sos )
{
}
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
/* Portions Copyright (c) 1990 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*/
#ifndef _LBER_INT_H
#define _LBER_INT_H
#include "lber.h"
#define LDAP_INT_DEBUG
#include "ldap_log.h"
#include "lber_pvt.h"
#include "ldap_queue.h"
LDAP_BEGIN_DECL
typedef void (*BER_LOG_FN)(FILE *file,
const char *subsys, int level, const char *fmt, ... );
LBER_V (BER_ERRNO_FN) ber_int_errno_fn;
#ifdef LDAP_MEMORY_TRACE
# ifndef LDAP_MEMORY_DEBUG
# define LDAP_MEMORY_DEBUG 1
# endif
#endif
#ifdef LDAP_MEMORY_DEBUG
LBER_V (long) ber_int_meminuse;
#endif
#if defined(LDAP_MEMORY_DEBUG) && ((LDAP_MEMORY_DEBUG +0) & 2)
# define LDAP_MEMORY_DEBUG_ASSERT assert
#else
# define LDAP_MEMORY_DEBUG_ASSERT(expr) ((void) 0)
#endif
struct lber_options {
short lbo_valid;
unsigned short lbo_options;
int lbo_debug;
};
LBER_F( int ) ber_pvt_log_output(
const char *subsystem,
int level,
const char *fmt, ... );
#define LBER_UNINITIALIZED 0x0
#define LBER_INITIALIZED 0x1
#define LBER_VALID_BERELEMENT 0x2
#define LBER_VALID_SOCKBUF 0x3
LBER_V (struct lber_options) ber_int_options;
#define ber_int_debug ber_int_options.lbo_debug
/* Data encoded in ASN.1 BER format */
struct berelement {
struct lber_options ber_opts;
#define ber_valid ber_opts.lbo_valid
#define ber_options ber_opts.lbo_options
#define ber_debug ber_opts.lbo_debug
/*
* The members below, when not NULL/LBER_DEFAULT/etc, are:
* ber_buf Data buffer. Other pointers normally point into it.
* ber_rwptr Read/write cursor for Sockbuf I/O.
* ber_memctx Context passed to ber_memalloc() & co.
* When decoding data (reading it from the BerElement):
* ber_end End of BER data.
* ber_ptr Read cursor, except for 1st octet of tags.
* ber_tag 1st octet of next tag, saved from *ber_ptr when
* ber_ptr may be pointing at a tag and is >ber_buf.
* The octet *ber_ptr itself may get overwritten with
* a \0, to terminate the preceding element.
* When encoding data (writing it to the BerElement):
* ber_end End of allocated buffer - 1 (allowing a final \0).
* ber_ptr Last complete BER element (normally write cursor).
* ber_sos_ptr NULL or write cursor for incomplete sequence or set.
* ber_sos_inner offset(seq/set length octets) if ber_sos_ptr!=NULL.
* ber_tag Default tag for next ber_printf() element.
* ber_usertag Boolean set by ber_printf "!" if it sets ber_tag.
* ber_len Reused for ber_sos_inner.
* When output to a Sockbuf:
* ber_ptr End of encoded data to write.
* When input from a Sockbuf:
* See ber_get_next().
*/
/* Do not change the order of these 3 fields! see ber_get_next */
ber_tag_t ber_tag;
ber_len_t ber_len;
ber_tag_t ber_usertag;
char *ber_buf;
char *ber_ptr;
char *ber_end;
char *ber_sos_ptr;
# define ber_sos_inner ber_len /* reused for binary compat */
char *ber_rwptr;
void *ber_memctx;
};
#define LBER_VALID(ber) ((ber)->ber_valid==LBER_VALID_BERELEMENT)
#define ber_pvt_ber_remaining(ber) ((ber)->ber_end - (ber)->ber_ptr)
#define ber_pvt_ber_total(ber) ((ber)->ber_end - (ber)->ber_buf)
#define ber_pvt_ber_write(ber) ((ber)->ber_ptr - (ber)->ber_buf)
struct sockbuf {
struct lber_options sb_opts;
Sockbuf_IO_Desc *sb_iod; /* I/O functions */
#define sb_valid sb_opts.lbo_valid
#define sb_options sb_opts.lbo_options
#define sb_debug sb_opts.lbo_debug
ber_socket_t sb_fd;
ber_len_t sb_max_incoming;
unsigned int sb_trans_needs_read:1;
unsigned int sb_trans_needs_write:1;
#ifdef LDAP_PF_LOCAL_SENDMSG
char sb_ungetlen;
char sb_ungetbuf[8];
#endif
};
#define SOCKBUF_VALID( sb ) ( (sb)->sb_valid == LBER_VALID_SOCKBUF )
/*
* decode.c, encode.c
*/
/* Simplest OID max-DER-component to implement in both decode and encode */
#define LBER_OID_COMPONENT_MAX ((unsigned long)-1 - 128)
/*
* io.c
*/
LBER_F( int )
ber_realloc LDAP_P((
BerElement *ber,
ber_len_t len ));
LBER_F (char *) ber_start LDAP_P(( BerElement * ));
LBER_F (int) ber_len LDAP_P(( BerElement * ));
LBER_F (int) ber_ptrlen LDAP_P(( BerElement * ));
LBER_F (void) ber_rewind LDAP_P(( BerElement * ));
/*
* bprint.c
*/
#define ber_log_printf ber_pvt_log_printf
LBER_F( int )
ber_log_bprint LDAP_P((
int errlvl,
int loglvl,
const char *data,
ber_len_t len ));
LBER_F( int )
ber_log_dump LDAP_P((
int errlvl,
int loglvl,
BerElement *ber,
int inout ));
LBER_V (BER_LOG_FN) ber_int_log_proc;
LBER_V (FILE *) ber_pvt_err_file;
/* memory.c */
/* simple macros to realloc for now */
LBER_V (BerMemoryFunctions *) ber_int_memory_fns;
LBER_F (char *) ber_strndup( LDAP_CONST char *, ber_len_t );
LBER_F (char *) ber_strndup_x( LDAP_CONST char *, ber_len_t, void *ctx );
#define LBER_MALLOC(s) ber_memalloc((s))
#define LBER_CALLOC(n,s) ber_memcalloc((n),(s))
#define LBER_REALLOC(p,s) ber_memrealloc((p),(s))
#define LBER_FREE(p) ber_memfree((p))
#define LBER_VFREE(v) ber_memvfree((void**)(v))
#define LBER_STRDUP(s) ber_strdup((s))
#define LBER_STRNDUP(s,l) ber_strndup((s),(l))
/* sockbuf.c */
LBER_F( int )
ber_int_sb_init LDAP_P(( Sockbuf *sb ));
LBER_F( int )
ber_int_sb_close LDAP_P(( Sockbuf *sb ));
LBER_F( int )
ber_int_sb_destroy LDAP_P(( Sockbuf *sb ));
LBER_F( ber_slen_t )
ber_int_sb_read LDAP_P(( Sockbuf *sb, void *buf, ber_len_t len ));
LBER_F( ber_slen_t )
ber_int_sb_write LDAP_P(( Sockbuf *sb, void *buf, ber_len_t len ));
LDAP_END_DECL
#endif /* _LBER_INT_H */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2022 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
#include "portable.h"
#ifdef HAVE_WINSOCK2
#include <winsock2.h>
#elif defined(HAVE_WINSOCK)
#include <winsock.h>
#endif /* HAVE_WINSOCK(2) */
#define LBER_RETSTR( x ) case x: return #x;
char *ber_pvt_wsa_err2string( int err )
{
switch( err ) {
LBER_RETSTR( WSAEINTR )
LBER_RETSTR( WSAEBADF )
LBER_RETSTR( WSAEACCES )
LBER_RETSTR( WSAEFAULT )
LBER_RETSTR( WSAEINVAL )
LBER_RETSTR( WSAEMFILE )
LBER_RETSTR( WSAEWOULDBLOCK )
LBER_RETSTR( WSAEINPROGRESS )
LBER_RETSTR( WSAEALREADY )
LBER_RETSTR( WSAENOTSOCK )
LBER_RETSTR( WSAEDESTADDRREQ )
LBER_RETSTR( WSAEMSGSIZE )
LBER_RETSTR( WSAEPROTOTYPE )
LBER_RETSTR( WSAENOPROTOOPT )
LBER_RETSTR( WSAEPROTONOSUPPORT )
LBER_RETSTR( WSAESOCKTNOSUPPORT )
LBER_RETSTR( WSAEOPNOTSUPP )
LBER_RETSTR( WSAEPFNOSUPPORT )
LBER_RETSTR( WSAEAFNOSUPPORT )
LBER_RETSTR( WSAEADDRINUSE )
LBER_RETSTR( WSAEADDRNOTAVAIL )
LBER_RETSTR( WSAENETDOWN )
LBER_RETSTR( WSAENETUNREACH )
LBER_RETSTR( WSAENETRESET )
LBER_RETSTR( WSAECONNABORTED )
LBER_RETSTR( WSAECONNRESET )
LBER_RETSTR( WSAENOBUFS )
LBER_RETSTR( WSAEISCONN )
LBER_RETSTR( WSAENOTCONN )
LBER_RETSTR( WSAESHUTDOWN )
LBER_RETSTR( WSAETOOMANYREFS )
LBER_RETSTR( WSAETIMEDOUT )
LBER_RETSTR( WSAECONNREFUSED )
LBER_RETSTR( WSAELOOP )
LBER_RETSTR( WSAENAMETOOLONG )
LBER_RETSTR( WSAEHOSTDOWN )
LBER_RETSTR( WSAEHOSTUNREACH )
LBER_RETSTR( WSAENOTEMPTY )
LBER_RETSTR( WSAEPROCLIM )
LBER_RETSTR( WSAEUSERS )
LBER_RETSTR( WSAEDQUOT )
LBER_RETSTR( WSAESTALE )
LBER_RETSTR( WSAEREMOTE )
LBER_RETSTR( WSASYSNOTREADY )
LBER_RETSTR( WSAVERNOTSUPPORTED )
LBER_RETSTR( WSANOTINITIALISED )
LBER_RETSTR( WSAEDISCON )
#ifdef HAVE_WINSOCK2
LBER_RETSTR( WSAENOMORE )
LBER_RETSTR( WSAECANCELLED )
LBER_RETSTR( WSAEINVALIDPROCTABLE )
LBER_RETSTR( WSAEINVALIDPROVIDER )
LBER_RETSTR( WSASYSCALLFAILURE )
LBER_RETSTR( WSASERVICE_NOT_FOUND )
LBER_RETSTR( WSATYPE_NOT_FOUND )
LBER_RETSTR( WSA_E_NO_MORE )
LBER_RETSTR( WSA_E_CANCELLED )
LBER_RETSTR( WSAEREFUSED )
#endif /* HAVE_WINSOCK2 */
LBER_RETSTR( WSAHOST_NOT_FOUND )
LBER_RETSTR( WSATRY_AGAIN )
LBER_RETSTR( WSANO_RECOVERY )
LBER_RETSTR( WSANO_DATA )
}
return "unknown WSA error";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment