LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
*/
+/* These are defined in lber_types.h */
+/*
+ LBER_INT_T
+ LBER_LEN_T
+ LBER_SOCKET_T
+ LBER_TAG_T
+*/
\f
/* Leave that blank line there!! Autoheader needs it. */
static int
-entry2textwrite( void *fp, char *buf, int len )
+entry2textwrite( void *fp, char *buf, ber_len_t len )
{
return( fwrite( buf, len, 1, (FILE *)fp ) == 0 ? -1 : len );
}
}
static int
-entry2textwrite( void *fp, char *buf, int len )
+entry2textwrite( void *fp, char *buf, ber_len_t len )
{
return( fwrite( buf, len, 1, (FILE *)fp ) == 0 ? -1 : len );
}
static int isoc ( char **ocl, char *oc );
static int make_scope ( LDAP *ld, char *dn );
static void do_search (LDAP *ld, FILE *fp, char *query);
-static int entry2textwrite( void *fp, char *buf, int len );
+static int entry2textwrite( void *fp, char *buf, ber_len_t len );
static void do_read (LDAP *ld, FILE *fp, char *dn);
static void do_help (FILE *op);
static void do_sizelimit(FILE *fp, char type);
static int
-entry2textwrite( void *fp, char *buf, int len )
+entry2textwrite( void *fp, char *buf, ber_len_t len )
{
return( fwrite( buf, len, 1, (FILE *)fp ) == 0 ? -1 : len );
}
static void close_ldap(LDAP *ld);
static void append_entry_list(char *rep, char *qu, LDAP *ld, LDAPMessage *msg);
-static int append_text(void *reply, char *text, int len);
+static int append_text(void *reply, char *text, ber_len_t len);
static int do_read (LDAP *ld, char *dn, char *rep, struct ldap_disptmpl *tmp);
static void report_ldap_err (LDAP *ldp, char *reply);
static void remove_trailing_space (char *s);
static int
-append_text( void *reply, char *text, int len )
+append_text( void *reply, char *text, ber_len_t len )
{
strcat( (char *) reply, text );
return( len );
#define CROSS_COMPILING 1
EOF
+
+ cat >> confdefs.h <<\EOF
+#define LBER_INT_T long
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define LBER_TAG_T long
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define LBER_SOCKET_T int
+EOF
+
+
else
echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:10865: checking whether byte ordering is bigendian" >&5
+echo "configure:10879: checking whether byte ordering is bigendian" >&5
if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_c_bigendian=unknown
# See if sys/param.h defines the BYTE_ORDER macro.
cat > conftest.$ac_ext <<EOF
-#line 10872 "configure"
+#line 10886 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
#endif
; return 0; }
EOF
-if { (eval echo configure:10883: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:10897: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
# It does; now see whether it defined to BIG_ENDIAN or not.
cat > conftest.$ac_ext <<EOF
-#line 10887 "configure"
+#line 10901 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
#endif
; return 0; }
EOF
-if { (eval echo configure:10898: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:10912: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_bigendian=yes
else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 10918 "configure"
+#line 10932 "configure"
#include "confdefs.h"
main () {
/* Are we little or big endian? From Harbison&Steele. */
exit (u.c[sizeof (long) - 1] == 1);
}
EOF
-if { (eval echo configure:10931: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:10945: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_bigendian=no
else
fi
echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:10955: checking size of short" >&5
+echo "configure:10969: checking size of short" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 10963 "configure"
+#line 10977 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
exit(0);
}
EOF
-if { (eval echo configure:10974: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:10988: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_short=`cat conftestval`
else
echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:10994: checking size of int" >&5
+echo "configure:11008: checking size of int" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 11002 "configure"
+#line 11016 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
exit(0);
}
EOF
-if { (eval echo configure:11013: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:11027: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_int=`cat conftestval`
else
echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:11033: checking size of long" >&5
+echo "configure:11047: checking size of long" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 11041 "configure"
+#line 11055 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
exit(0);
}
EOF
-if { (eval echo configure:11052: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:11066: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_long=`cat conftestval`
else
if test "$ac_cv_sizeof_int" -lt 4 ; then
echo "configure: warning: OpenLDAP requires 'int' to be 32 bits or greater." 1>&2
+
+ cat >> confdefs.h <<\EOF
+#define LBER_INT_T long
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define LBER_TAG_T long
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define LBER_SOCKET_T int
+EOF
+
+ else
+ cat >> confdefs.h <<\EOF
+#define LBER_INT_T int
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define LBER_TAG_T long
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define LBER_SOCKET_T int
+EOF
+
fi
fi
+cat >> confdefs.h <<\EOF
+#define LBER_LEN_T long
+EOF
+
+
echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6
-echo "configure:11078: checking for 8-bit clean memcmp" >&5
+echo "configure:11123: checking for 8-bit clean memcmp" >&5
if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_func_memcmp_clean=no
else
cat > conftest.$ac_ext <<EOF
-#line 11086 "configure"
+#line 11131 "configure"
#include "confdefs.h"
main()
}
EOF
-if { (eval echo configure:11096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:11141: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_memcmp_clean=yes
else
test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}"
echo $ac_n "checking for strftime""... $ac_c" 1>&6
-echo "configure:11114: checking for strftime" >&5
+echo "configure:11159: checking for strftime" >&5
if eval "test \"`echo '$''{'ac_cv_func_strftime'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 11119 "configure"
+#line 11164 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char strftime(); below. */
; return 0; }
EOF
-if { (eval echo configure:11142: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11187: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_strftime=yes"
else
echo "$ac_t""no" 1>&6
# strftime is in -lintl on SCO UNIX.
echo $ac_n "checking for strftime in -lintl""... $ac_c" 1>&6
-echo "configure:11164: checking for strftime in -lintl" >&5
+echo "configure:11209: checking for strftime in -lintl" >&5
ac_lib_var=`echo intl'_'strftime | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lintl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 11172 "configure"
+#line 11217 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
strftime()
; return 0; }
EOF
-if { (eval echo configure:11183: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11228: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
echo $ac_n "checking for vprintf""... $ac_c" 1>&6
-echo "configure:11211: checking for vprintf" >&5
+echo "configure:11256: checking for vprintf" >&5
if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 11216 "configure"
+#line 11261 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vprintf(); below. */
; return 0; }
EOF
-if { (eval echo configure:11239: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11284: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_vprintf=yes"
else
if test "$ac_cv_func_vprintf" != yes; then
echo $ac_n "checking for _doprnt""... $ac_c" 1>&6
-echo "configure:11263: checking for _doprnt" >&5
+echo "configure:11308: checking for _doprnt" >&5
if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 11268 "configure"
+#line 11313 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char _doprnt(); below. */
; return 0; }
EOF
-if { (eval echo configure:11291: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11336: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func__doprnt=yes"
else
for ac_func in vsnprintf vsprintf
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:11320: checking for $ac_func" >&5
+echo "configure:11365: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 11325 "configure"
+#line 11370 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:11348: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11393: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:11417: checking for $ac_func" >&5
+echo "configure:11462: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 11422 "configure"
+#line 11467 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:11445: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11490: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
for ac_func in getopt tempnam
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:11473: checking for $ac_func" >&5
+echo "configure:11518: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 11478 "configure"
+#line 11523 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:11501: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11546: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
# Check Configuration
echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6
-echo "configure:11531: checking declaration of sys_errlist" >&5
+echo "configure:11576: checking declaration of sys_errlist" >&5
if eval "test \"`echo '$''{'ol_cv_dcl_sys_errlist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 11537 "configure"
+#line 11582 "configure"
#include "confdefs.h"
#include <stdio.h>
char *c = (char *) *sys_errlist
; return 0; }
EOF
-if { (eval echo configure:11547: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:11592: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ol_cv_dcl_sys_errlist=yes
else
EOF
echo $ac_n "checking existence of sys_errlist""... $ac_c" 1>&6
-echo "configure:11567: checking existence of sys_errlist" >&5
+echo "configure:11612: checking existence of sys_errlist" >&5
if eval "test \"`echo '$''{'ol_cv_have_sys_errlist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 11573 "configure"
+#line 11618 "configure"
#include "confdefs.h"
#include <errno.h>
int main() {
char *c = (char *) *sys_errlist
; return 0; }
EOF
-if { (eval echo configure:11580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11625: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ol_cv_have_sys_errlist=yes
else
contrib/Makefile:build/top.mk:contrib/Makefile.in:build/dir.mk \
contrib/saucer/Makefile:build/top.mk:contrib/saucer/Makefile.in:build/rules.mk \
contrib/web_ldap/Makefile:build/top.mk:contrib/web_ldap/Makefile.in:build/rules.mk \
- include/portable.h include/ldap_features.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+ include/portable.h include/ldap_features.h include/lber_types.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
EOF
cat >> $CONFIG_STATUS <<EOF
if test "${CONFIG_HEADERS+set}" != set; then
EOF
cat >> $CONFIG_STATUS <<EOF
- CONFIG_HEADERS="include/portable.h include/ldap_features.h"
+ CONFIG_HEADERS="include/portable.h include/ldap_features.h include/lber_types.h"
EOF
cat >> $CONFIG_STATUS <<\EOF
fi
dnl aclocal.m4 should be built using aclocal from automake 1.4
AC_PREREQ(2.13)dnl Required Autoconf version
-AC_CONFIG_HEADER(include/portable.h include/ldap_features.h)dnl
+AC_CONFIG_HEADER(include/portable.h include/ldap_features.h include/lber_types.h)dnl
dnl
dnl Start Args
if test $cross_compiling = yes ; then
AC_DEFINE(CROSS_COMPILING, 1, [define if cross compiling])
+
+ AC_DEFINE(LBER_INT_T,long)
+ AC_DEFINE(LBER_TAG_T,long)
+ AC_DEFINE(LBER_SOCKET_T,int)
+
else
AC_C_BIGENDIAN
AC_CHECK_SIZEOF(short)
if test "$ac_cv_sizeof_int" -lt 4 ; then
AC_MSG_WARN([OpenLDAP requires 'int' to be 32 bits or greater.])
+
+ AC_DEFINE(LBER_INT_T,long)
+ AC_DEFINE(LBER_TAG_T,long)
+ AC_DEFINE(LBER_SOCKET_T,int)
+ else
+ AC_DEFINE(LBER_INT_T,int)
+ AC_DEFINE(LBER_TAG_T,long)
+ AC_DEFINE(LBER_SOCKET_T,int)
fi
fi
+AC_DEFINE(LBER_LEN_T,long)
+
dnl ----------------------------------------------------------------
dnl Checks for library functions.
AC_FUNC_MEMCMP
# define tcp_close( s ) closesocket( s );
# define ioctl( s, c, a ) ioctlsocket( (s), (c), (a) )
# define ioctl_t u_long
+# define AC_SOCKET_INVALID ((unsigned int) ~0)
#define EWOULDBLOCK WSAEWOULDBLOCK
# define ioctl_t int
#endif
+#ifndef AC_SOCKET_INVALID
+# define AC_SOCKET_INVALID (-1)
+#endif
+
#if defined(__WIN32) && defined(_ALPHA)
/* NT on Alpha is hosed. */
#define AC_HTONL( l ) \
((((l)&0xff)<<24) + (((l)&0xff00)<<8) + \
(((l)&0xff0000)>>8) + (((l)&0xff000000)>>24))
-#define AC_NTOHL(l) LBER_HTONL(l)
+#define AC_NTOHL(l) AC_HTONL(l)
#elif defined(__alpha) && !defined(VMS)
/*
#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 )
+
#endif /* _AC_SOCKET_H_ */
#endif /* AVL_INTERNALS */
typedef int (*AVL_APPLY) LDAP_P((void *, void*));
-typedef int (*AVL_CMP) 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*));
avl_delete LDAP_P((Avlnode **, void*, AVL_CMP));
LDAP_F( void* )
-avl_find LDAP_P((Avlnode *, void*, AVL_CMP));
+avl_find LDAP_P((Avlnode *, const void*, AVL_CMP));
LDAP_F( void* )
-avl_find_lin LDAP_P((Avlnode *, void*, AVL_CMP));
+avl_find_lin LDAP_P((Avlnode *, const void*, AVL_CMP));
#ifdef AVL_NONREENTRANT
LDAP_F( void* )
#define LDAP_DTMPL_BUFSIZ 8192
-typedef int (*ldap_writeptype) LDAP_P(( void *writeparm, char *p, int len ));
+typedef int (*ldap_writeptype) LDAP_P((
+ void *writeparm, char *p, ber_len_t len ));
LDAP_F( int )
ldap_init_templates LDAP_P(( char *file, struct ldap_disptmpl **tmpllistp ));
LDAP_F( int )
ldap_init_templates_buf LDAP_P(( char *buf,
- long buflen,
+ ber_len_t buflen,
struct ldap_disptmpl **tmpllistp ));
LDAP_F( void )
#define _LBER_H
#include <ldap_cdefs.h>
-
-#ifndef LBER_SIZE_T_DEFINED
-#include <stddef.h>
-#endif
+#include <lber_types.h>
LDAP_BEGIN_DECL
+/* boolean, 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 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 LBER_LEN_T ber_slen_t;
+
+
/* Overview of LBER tag construction
*
* Bits
*/
/* BER classes and mask */
-#define LBER_CLASS_UNIVERSAL 0x00UL
-#define LBER_CLASS_APPLICATION 0x40UL
-#define LBER_CLASS_CONTEXT 0x80UL
-#define LBER_CLASS_PRIVATE 0xc0UL
-#define LBER_CLASS_MASK 0xc0UL
+#define LBER_CLASS_UNIVERSAL (ber_tag_t) 0x00U
+#define LBER_CLASS_APPLICATION (ber_tag_t) 0x40U
+#define LBER_CLASS_CONTEXT (ber_tag_t) 0x80U
+#define LBER_CLASS_PRIVATE (ber_tag_t) 0xc0U
+#define LBER_CLASS_MASK (ber_tag_t) 0xc0U
/* BER encoding type and mask */
-#define LBER_PRIMITIVE 0x00UL
-#define LBER_CONSTRUCTED 0x20UL
-#define LBER_ENCODING_MASK 0x20UL
+#define LBER_PRIMITIVE (ber_tag_t) 0x00U
+#define LBER_CONSTRUCTED (ber_tag_t) 0x20U
+#define LBER_ENCODING_MASK (ber_tag_t) 0x20U
-#define LBER_BIG_TAG_MASK 0x1fUL
-#define LBER_MORE_TAG_MASK 0x80UL
+#define LBER_BIG_TAG_MASK (ber_tag_t) 0x1fU
+#define LBER_MORE_TAG_MASK (ber_tag_t) 0x80U
/*
* Note that LBER_ERROR and LBER_DEFAULT are values that can never appear
* as valid BER tags, and so it is safe to use them to report errors. In
* fact, any tag for which the following is true is invalid:
*/
-#define LBER_INVALID(tag) (((tag) & 0x00000080) && (((tag) & 0xFFFFFF00))
-#define LBER_ERROR 0xffffffffUL
-#define LBER_DEFAULT 0xffffffffUL
+#define LBER_INVALID(t) (((t) & 0x080) && (((t) & (ber_tag_t) ~ 0x0FF))
+#define LBER_ERROR ((ber_tag_t) ~ 0x0)
+#define LBER_DEFAULT ((ber_tag_t) ~ 0x0)
/* general BER types we know about */
-#define LBER_BOOLEAN 0x01UL
-#define LBER_INTEGER 0x02UL
-#define LBER_BITSTRING 0x03UL
-#define LBER_OCTETSTRING 0x04UL
-#define LBER_NULL 0x05UL
-#define LBER_ENUMERATED 0x0aUL
-#define LBER_SEQUENCE 0x30UL /* constructed */
-#define LBER_SET 0x31UL /* constructed */
-
-#define OLD_LBER_SEQUENCE 0x10UL /* w/o constructed bit - broken */
-#define OLD_LBER_SET 0x11UL /* w/o constructed bit - broken */
+#define LBER_BOOLEAN (ber_tag_t) 0x01UL
+#define LBER_INTEGER (ber_tag_t) 0x02UL
+#define LBER_BITSTRING (ber_tag_t) 0x03UL
+#define LBER_OCTETSTRING (ber_tag_t) 0x04UL
+#define LBER_NULL (ber_tag_t) 0x05UL
+#define LBER_ENUMERATED (ber_tag_t) 0x0aUL
+#define LBER_SEQUENCE (ber_tag_t) 0x30UL /* constructed */
+#define LBER_SET (ber_tag_t) 0x31UL /* constructed */
+
+#define OLD_LBER_SEQUENCE (ber_tag_t) 0x10UL /* w/o constructed bit - broken */
+#define OLD_LBER_SET (ber_tag_t) 0x11UL /* w/o constructed bit - broken */
typedef int (*BERTranslateProc) LDAP_P((
char **bufp,
typedef void (*BER_LOG_PRINT_FN) LDAP_P(( char *buf ));
-typedef void* (*BER_MEMALLOC_FN) LDAP_P(( size_t size ));
-typedef void* (*BER_MEMCALLOC_FN) LDAP_P(( size_t n, size_t size ));
-typedef void* (*BER_MEMREALLOC_FN) LDAP_P(( void *p, size_t size ));
+typedef void* (*BER_MEMALLOC_FN) LDAP_P(( ber_len_t size ));
+typedef void* (*BER_MEMCALLOC_FN) LDAP_P(( ber_len_t n, ber_len_t size ));
+typedef void* (*BER_MEMREALLOC_FN) LDAP_P(( void *p, ber_len_t size ));
typedef void (*BER_MEMFREE_FN) LDAP_P(( void *p ));
typedef struct lber_memory_fns {
/* structure for returning a sequence of octet strings + length */
typedef struct berval {
- unsigned long bv_len;
+ ber_len_t bv_len;
char *bv_val;
} BerValue;
LDAP_F( void )
ber_bprint LDAP_P((
- LDAP_CONST char *data, int len ));
+ LDAP_CONST char *data, ber_len_t len ));
LDAP_F( void )
ber_dump LDAP_P((
void *data,
int mode ));
-LDAP_F( unsigned long )
+LDAP_F( ber_tag_t )
ber_get_tag LDAP_P((
BerElement *ber ));
-LDAP_F( unsigned long )
+LDAP_F( ber_tag_t )
ber_skip_tag LDAP_P((
BerElement *ber,
- unsigned long *len ));
+ ber_len_t *len ));
-LDAP_F( unsigned long )
+LDAP_F( ber_tag_t )
ber_peek_tag LDAP_P((
LDAP_CONST BerElement *ber,
- unsigned long *len ));
+ ber_len_t *len ));
-LDAP_F( unsigned long )
+LDAP_F( ber_tag_t )
ber_get_int LDAP_P((
BerElement *ber,
- long *num ));
+ ber_int_t *num ));
-LDAP_F( unsigned long )
+LDAP_F( ber_tag_t )
ber_get_stringb LDAP_P((
BerElement *ber,
char *buf,
- unsigned long *len ));
+ ber_len_t *len ));
-LDAP_F( unsigned long )
+LDAP_F( ber_tag_t )
ber_get_stringa LDAP_P((
- BerElement *ber, char **buf ));
+ BerElement *ber,
+ char **buf ));
-LDAP_F( unsigned long )
+LDAP_F( ber_tag_t )
ber_get_stringal LDAP_P((
BerElement *ber,
struct berval **bv ));
-LDAP_F( unsigned long )
+LDAP_F( ber_tag_t )
ber_get_bitstringa LDAP_P((
BerElement *ber,
char **buf,
- unsigned long *len ));
+ ber_len_t *len ));
-LDAP_F( unsigned long )
+LDAP_F( ber_tag_t )
ber_get_null LDAP_P((
BerElement *ber ));
-LDAP_F( unsigned long )
+LDAP_F( ber_tag_t )
ber_get_boolean LDAP_P((
BerElement *ber,
- int *boolval ));
+ ber_int_t *boolval ));
-LDAP_F( unsigned long )
+LDAP_F( ber_tag_t )
ber_first_element LDAP_P((
BerElement *ber,
- unsigned long *len,
+ ber_len_t *len,
char **last ));
-LDAP_F( unsigned long )
+LDAP_F( ber_tag_t )
ber_next_element LDAP_P((
BerElement *ber,
- unsigned long *len,
+ ber_len_t *len,
char *last ));
-LDAP_F( unsigned long )
+LDAP_F( ber_tag_t )
ber_scanf LDAP_P((
BerElement *ber,
LDAP_CONST char *fmt,
LDAP_F( int )
ber_put_enum LDAP_P((
BerElement *ber,
- long num,
- unsigned long tag ));
+ ber_int_t num,
+ ber_tag_t tag ));
LDAP_F( int )
ber_put_int LDAP_P((
BerElement *ber,
- long num,
- unsigned long tag ));
+ ber_int_t num,
+ ber_tag_t tag ));
LDAP_F( int )
ber_put_ostring LDAP_P((
BerElement *ber,
LDAP_CONST char *str,
- unsigned long len,
- unsigned long tag ));
+ ber_len_t len,
+ ber_tag_t tag ));
LDAP_F( int )
ber_put_berval LDAP_P((
BerElement *ber,
LDAP_CONST struct berval *bv,
- unsigned long tag ));
+ ber_tag_t tag ));
LDAP_F( int )
ber_put_string LDAP_P((
BerElement *ber,
LDAP_CONST char *str,
- unsigned long tag ));
+ ber_tag_t tag ));
LDAP_F( int )
ber_put_bitstring LDAP_P((
BerElement *ber,
LDAP_CONST char *str,
- unsigned long bitlen,
- unsigned long tag ));
+ ber_len_t bitlen,
+ ber_tag_t tag ));
LDAP_F( int )
ber_put_null LDAP_P((
BerElement *ber,
- unsigned long tag ));
+ ber_tag_t tag ));
LDAP_F( int )
ber_put_boolean LDAP_P((
BerElement *ber,
- int boolval,
- unsigned long tag ));
+ ber_int_t boolval,
+ ber_tag_t tag ));
LDAP_F( int )
ber_start_seq LDAP_P((
BerElement *ber,
- unsigned long tag ));
+ ber_tag_t tag ));
LDAP_F( int )
ber_start_set LDAP_P((
BerElement *ber,
- unsigned long tag ));
+ ber_tag_t tag ));
LDAP_F( int )
ber_put_seq LDAP_P((
* in io.c:
*/
-LDAP_F( long )
+LDAP_F( ber_slen_t )
ber_read LDAP_P((
BerElement *ber,
char *buf,
- unsigned long len ));
+ ber_len_t len ));
-LDAP_F( long )
+LDAP_F( ber_slen_t )
ber_write LDAP_P((
BerElement *ber,
LDAP_CONST char *buf,
- unsigned long len,
+ ber_len_t len,
int nosos ));
LDAP_F( void )
LDAP_F( int )
ber_flush LDAP_P((
- Sockbuf *sb, BerElement *ber, int freeit ));
+ Sockbuf *sb,
+ BerElement *ber,
+ int freeit ));
LDAP_F( BerElement * )
ber_alloc LDAP_P(( void )); /* DEPRECATED */
ber_dup LDAP_P((
LDAP_CONST BerElement *ber ));
-LDAP_F( unsigned long )
+LDAP_F( ber_tag_t )
ber_get_next LDAP_P((
Sockbuf *sb,
- unsigned long *len,
+ ber_len_t *len,
BerElement *ber ));
LDAP_F( void )
LDAP_F( Sockbuf * )
ber_sockbuf_alloc_fd(
- int fd );
+ ber_socket_t fd );
LDAP_F( void )
ber_sockbuf_free(
*/
LDAP_F( void * )
ber_memalloc LDAP_P((
- size_t s ));
+ ber_len_t s ));
LDAP_F( void * )
ber_memrealloc LDAP_P((
void* p,
- size_t s ));
+ ber_len_t s ));
LDAP_F( void * )
ber_memcalloc LDAP_P((
- size_t n,
- size_t s ));
+ ber_len_t n,
+ ber_len_t s ));
LDAP_F( void )
ber_memfree LDAP_P((
--- /dev/null
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License. A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+/*
+ * LBER types
+ */
+
+#ifndef _LBER_TYPES_H
+#define _LBER_TYPES_H
+
+/* LBER boolean, enum, integers - 32 bits or larger*/
+#undef LBER_INT_T
+
+/* LBER tags - 32 bits or larger */
+#undef LBER_TAG_T
+
+/* LBER socket descriptor */
+#undef LBER_SOCKET_T
+
+/* LBER lengths - 32 bits or larger*/
+#undef LBER_LEN_T
+
+#endif /* _LBER_TYPES_H */
--- /dev/null
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License. A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+/*
+ * LBER types for Windows NT
+ */
+
+#ifndef _LBER_TYPES_H_NT
+#define _LBER_TYPES_H_NT
+
+/*
+ * NT types:
+ *
+ * bitsof(short) == 2
+ * bitsof(int) == 4
+ * bitsof(long) == 4
+ *
+ * typedef unsigned int size_t;
+ * typedef unsigned int SOCKET;
+ *
+ * we use native C types to avoid sucking in system headers
+ */
+
+/* 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 unsigned int
+
+/* LBER lengths - 32 bits or larger*/
+#define LBER_LEN_T int
+
+#endif /* _LBER_TYPES_H_NT */
* As such, the number will be above the old RFC but below
* whatever number does finally get assigned
*/
-#define LDAP_API_VERSION 2002
+#define LDAP_API_VERSION 2003
#define LDAP_VENDOR_NAME "OpenLDAP"
/* We'll eventually release as 200 */
#define LDAP_VENDOR_VERSION 192
*/
/* general stuff */
-#define LDAP_TAG_MESSAGE 0x30UL /* constructed + 16 */
-#define OLD_LDAP_TAG_MESSAGE 0x10UL /* forgot the constructed bit */
-#define LDAP_TAG_MSGID 0x02UL /* integer */
-#define LDAP_TAG_LDAPDN 0x04UL /* octect string */
-#define LDAP_TAG_CONTROLS 0xa0UL /* context specific + constructed + 0 */
-#define LDAP_TAG_REFERRAL 0xa3UL /* context specific + constructed + 3 */
+#define LDAP_TAG_MESSAGE (ber_tag_t) 0x30U /* constructed + 16 */
+#define OLD_LDAP_TAG_MESSAGE (ber_tag_t) 0x10U /* forgot the constructed bit */
+#define LDAP_TAG_MSGID (ber_tag_t) 0x02U /* integer */
+#define LDAP_TAG_LDAPDN (ber_tag_t) 0x04U /* octect string */
+#define LDAP_TAG_CONTROLS (ber_tag_t) 0xa0U /* context specific + constructed + 0 */
+#define LDAP_TAG_REFERRAL (ber_tag_t) 0xa3U /* context specific + constructed + 3 */
-#define LDAP_TAG_NEWSUPERIOR 0x80UL /* context-specific + primitive + 0 */
+#define LDAP_TAG_NEWSUPERIOR (ber_tag_t) 0x80U /* context-specific + primitive + 0 */
-#define LDAP_TAG_EXOP_REQ_OID 0x80UL /* context specific + primitive */
-#define LDAP_TAG_EXOP_REQ_VALUE 0x81UL /* context specific + primitive */
-#define LDAP_TAG_EXOP_RES_OID 0x8aUL /* context specific + primitive */
-#define LDAP_TAG_EXOP_RES_VALUE 0x8bUL /* context specific + primitive */
+#define LDAP_TAG_EXOP_REQ_OID (ber_tag_t) 0x80U /* context specific + primitive */
+#define LDAP_TAG_EXOP_REQ_VALUE (ber_tag_t) 0x81U /* context specific + primitive */
+#define LDAP_TAG_EXOP_RES_OID (ber_tag_t) 0x8aU /* context specific + primitive */
+#define LDAP_TAG_EXOP_RES_VALUE (ber_tag_t) 0x8bU /* context specific + primitive */
-#define LDAP_TAG_SASL_RES_CREDS 0x87UL /* context specific + primitive */
+#define LDAP_TAG_SASL_RES_CREDS (ber_tag_t) 0x87U /* context specific + primitive */
/* possible operations a client can invoke */
-#define LDAP_REQ_BIND 0x60UL /* application + constructed */
-#define LDAP_REQ_UNBIND 0x42UL /* application + primitive */
-#define LDAP_REQ_SEARCH 0x63UL /* application + constructed */
-#define LDAP_REQ_MODIFY 0x66UL /* application + constructed */
-#define LDAP_REQ_ADD 0x68UL /* application + constructed */
-#define LDAP_REQ_DELETE 0x4aUL /* application + primitive */
-#define LDAP_REQ_MODRDN 0x6cUL /* application + constructed */
+#define LDAP_REQ_BIND (ber_tag_t) 0x60U /* application + constructed */
+#define LDAP_REQ_UNBIND (ber_tag_t) 0x42U /* application + primitive */
+#define LDAP_REQ_SEARCH (ber_tag_t) 0x63U /* application + constructed */
+#define LDAP_REQ_MODIFY (ber_tag_t) 0x66U /* application + constructed */
+#define LDAP_REQ_ADD (ber_tag_t) 0x68U /* application + constructed */
+#define LDAP_REQ_DELETE (ber_tag_t) 0x4aU /* application + primitive */
+#define LDAP_REQ_MODRDN (ber_tag_t) 0x6cU /* application + constructed */
#define LDAP_REQ_MODDN LDAP_REQ_MODRDN
#define LDAP_REQ_RENAME LDAP_REQ_MODRDN
-#define LDAP_REQ_COMPARE 0x6eUL /* application + constructed */
-#define LDAP_REQ_ABANDON 0x50UL /* application + primitive */
-#define LDAP_REQ_EXTENDED 0x77UL /* application + constructed */
+#define LDAP_REQ_COMPARE (ber_tag_t) 0x6eU /* application + constructed */
+#define LDAP_REQ_ABANDON (ber_tag_t) 0x50U /* application + primitive */
+#define LDAP_REQ_EXTENDED (ber_tag_t) 0x77U /* application + constructed */
/* U-Mich version 3.0 compatibility stuff */
-#define LDAP_REQ_UNBIND_30 0x62UL
-#define LDAP_REQ_DELETE_30 0x6aUL
-#define LDAP_REQ_ABANDON_30 0x70UL
+#define LDAP_REQ_UNBIND_30 (ber_tag_t) 0x62U
+#define LDAP_REQ_DELETE_30 (ber_tag_t) 0x6aU
+#define LDAP_REQ_ABANDON_30 (ber_tag_t) 0x70U
/*
* old broken stuff for backwards compatibility - forgot application tag
* and constructed/primitive bit
*/
-#define OLD_LDAP_REQ_BIND 0x00UL
-#define OLD_LDAP_REQ_UNBIND 0x02UL
-#define OLD_LDAP_REQ_SEARCH 0x03UL
-#define OLD_LDAP_REQ_MODIFY 0x06UL
-#define OLD_LDAP_REQ_ADD 0x08UL
-#define OLD_LDAP_REQ_DELETE 0x0aUL
-#define OLD_LDAP_REQ_MODRDN 0x0cUL
-#define OLD_LDAP_REQ_COMPARE 0x0eUL
-#define OLD_LDAP_REQ_ABANDON 0x10UL
+#define OLD_LDAP_REQ_BIND (ber_tag_t) 0x00U
+#define OLD_LDAP_REQ_UNBIND (ber_tag_t) 0x02U
+#define OLD_LDAP_REQ_SEARCH (ber_tag_t) 0x03U
+#define OLD_LDAP_REQ_MODIFY (ber_tag_t) 0x06U
+#define OLD_LDAP_REQ_ADD (ber_tag_t) 0x08U
+#define OLD_LDAP_REQ_DELETE (ber_tag_t) 0x0aU
+#define OLD_LDAP_REQ_MODRDN (ber_tag_t) 0x0cU
+#define OLD_LDAP_REQ_COMPARE (ber_tag_t) 0x0eU
+#define OLD_LDAP_REQ_ABANDON (ber_tag_t) 0x10U
/* possible result types a server can return */
-#define LDAP_RES_BIND 0x61UL /* application + constructed */
-#define LDAP_RES_SEARCH_ENTRY 0x64UL /* application + constructed */
-#define LDAP_RES_SEARCH_REFERENCE 0x73UL /* V3: application + constructed */
-#define LDAP_RES_SEARCH_RESULT 0x65UL /* application + constructed */
-#define LDAP_RES_MODIFY 0x67UL /* application + constructed */
-#define LDAP_RES_ADD 0x69UL /* application + constructed */
-#define LDAP_RES_DELETE 0x6bUL /* application + constructed */
-#define LDAP_RES_MODRDN 0x6dUL /* application + constructed */
+#define LDAP_RES_BIND (ber_tag_t) 0x61U /* application + constructed */
+#define LDAP_RES_SEARCH_ENTRY (ber_tag_t) 0x64U /* application + constructed */
+#define LDAP_RES_SEARCH_REFERENCE (ber_tag_t) 0x73U /* V3: application + constructed */
+#define LDAP_RES_SEARCH_RESULT (ber_tag_t) 0x65U /* application + constructed */
+#define LDAP_RES_MODIFY (ber_tag_t) 0x67U /* application + constructed */
+#define LDAP_RES_ADD (ber_tag_t) 0x69U /* application + constructed */
+#define LDAP_RES_DELETE (ber_tag_t) 0x6bU /* application + constructed */
+#define LDAP_RES_MODRDN (ber_tag_t) 0x6dU /* application + constructed */
#define LDAP_RES_MODDN LDAP_RES_MODRDN /* application + constructed */
#define LDAP_RES_RENAME LDAP_RES_MODRDN /* application + constructed */
-#define LDAP_RES_COMPARE 0x6fUL /* application + constructed */
-#define LDAP_RES_EXTENDED 0x78UL /* V3: application + constructed */
-#define LDAP_RES_ANY ((unsigned long)(-1))
+#define LDAP_RES_COMPARE (ber_tag_t) 0x6fU /* application + constructed */
+#define LDAP_RES_EXTENDED (ber_tag_t) 0x78U /* V3: application + constructed */
+#define LDAP_RES_ANY ((ber_tag_t)(~0))
/* old broken stuff for backwards compatibility */
-#define OLD_LDAP_RES_BIND 0x01UL
-#define OLD_LDAP_RES_SEARCH_ENTRY 0x04UL
-#define OLD_LDAP_RES_SEARCH_RESULT 0x05UL
-#define OLD_LDAP_RES_MODIFY 0x07UL
-#define OLD_LDAP_RES_ADD 0x09UL
-#define OLD_LDAP_RES_DELETE 0x0bUL
-#define OLD_LDAP_RES_MODRDN 0x0dUL
+#define OLD_LDAP_RES_BIND (ber_tag_t) 0x01UL
+#define OLD_LDAP_RES_SEARCH_ENTRY (ber_tag_t) 0x04UL
+#define OLD_LDAP_RES_SEARCH_RESULT (ber_tag_t) 0x05U
+#define OLD_LDAP_RES_MODIFY (ber_tag_t) 0x07U
+#define OLD_LDAP_RES_ADD (ber_tag_t) 0x09U
+#define OLD_LDAP_RES_DELETE (ber_tag_t) 0x0bU
+#define OLD_LDAP_RES_MODRDN (ber_tag_t) 0x0dU
#define OLD_LDAP_RES_MODDN OLD_LDAP_RES_MODRDN
-#define OLD_LDAP_RES_COMPARE 0x0fUL
+#define OLD_LDAP_RES_COMPARE (ber_tag_t) 0x0fU
/* sasl methods */
#define LDAP_SASL_SIMPLE NULL
/* authentication methods available */
-#define LDAP_AUTH_NONE 0x00UL /* no authentication */
-#define LDAP_AUTH_SIMPLE 0x80UL /* context specific + primitive */
-#define LDAP_AUTH_SASL 0xa3UL /* context specific + primitive */
-#define LDAP_AUTH_KRBV4 0xffUL /* means do both of the following */
-#define LDAP_AUTH_KRBV41 0x81UL /* context specific + primitive */
-#define LDAP_AUTH_KRBV42 0x82UL /* context specific + primitive */
+#define LDAP_AUTH_NONE (ber_tag_t) 0x00U /* no authentication */
+#define LDAP_AUTH_SIMPLE (ber_tag_t) 0x80U /* context specific + primitive */
+#define LDAP_AUTH_SASL (ber_tag_t) 0xa3U /* context specific + primitive */
+#define LDAP_AUTH_KRBV4 (ber_tag_t) 0xffU /* means do both of the following */
+#define LDAP_AUTH_KRBV41 (ber_tag_t) 0x81U /* context specific + primitive */
+#define LDAP_AUTH_KRBV42 (ber_tag_t) 0x82U /* context specific + primitive */
/* U-Mich version 3.0 compatibility auth methods */
-#define LDAP_AUTH_SIMPLE_30 0xa0UL /* context specific + constructed */
-#define LDAP_AUTH_KRBV41_30 0xa1UL /* context specific + constructed */
-#define LDAP_AUTH_KRBV42_30 0xa2UL /* context specific + constructed */
+#define LDAP_AUTH_SIMPLE_30 (ber_tag_t) 0xa0U /* context specific + constructed */
+#define LDAP_AUTH_KRBV41_30 (ber_tag_t) 0xa1U /* context specific + constructed */
+#define LDAP_AUTH_KRBV42_30 (ber_tag_t) 0xa2U /* context specific + constructed */
/* old broken stuff */
-#define OLD_LDAP_AUTH_SIMPLE 0x00UL
-#define OLD_LDAP_AUTH_KRBV4 0x01UL
-#define OLD_LDAP_AUTH_KRBV42 0x02UL
+#define OLD_LDAP_AUTH_SIMPLE (ber_tag_t) 0x00U
+#define OLD_LDAP_AUTH_KRBV4 (ber_tag_t) 0x01U
+#define OLD_LDAP_AUTH_KRBV42 (ber_tag_t) 0x02U
/* filter types */
-#define LDAP_FILTER_AND 0xa0UL /* context specific + constructed */
-#define LDAP_FILTER_OR 0xa1UL /* context specific + constructed */
-#define LDAP_FILTER_NOT 0xa2UL /* context specific + constructed */
-#define LDAP_FILTER_EQUALITY 0xa3UL /* context specific + constructed */
-#define LDAP_FILTER_SUBSTRINGS 0xa4UL /* context specific + constructed */
-#define LDAP_FILTER_GE 0xa5UL /* context specific + constructed */
-#define LDAP_FILTER_LE 0xa6UL /* context specific + constructed */
-#define LDAP_FILTER_PRESENT 0x87UL /* context specific + primitive */
-#define LDAP_FILTER_APPROX 0xa8UL /* context specific + constructed */
-#define LDAP_FILTER_EXTENDED 0xa9UL /* context specific + constructed */
+#define LDAP_FILTER_AND (ber_tag_t) 0xa0U /* context specific + constructed */
+#define LDAP_FILTER_OR (ber_tag_t) 0xa1U /* context specific + constructed */
+#define LDAP_FILTER_NOT (ber_tag_t) 0xa2U /* context specific + constructed */
+#define LDAP_FILTER_EQUALITY (ber_tag_t) 0xa3U /* context specific + constructed */
+#define LDAP_FILTER_SUBSTRINGS (ber_tag_t) 0xa4U /* context specific + constructed */
+#define LDAP_FILTER_GE (ber_tag_t) 0xa5U /* context specific + constructed */
+#define LDAP_FILTER_LE (ber_tag_t) 0xa6U /* context specific + constructed */
+#define LDAP_FILTER_PRESENT (ber_tag_t) 0x87U /* context specific + primitive */
+#define LDAP_FILTER_APPROX (ber_tag_t) 0xa8U /* context specific + constructed */
+#define LDAP_FILTER_EXTENDED (ber_tag_t) 0xa9U /* context specific + constructed */
/* U-Mich version 3.0 compatibility filter types */
-#define LDAP_FILTER_PRESENT_30 0xa7UL /* context specific + constructed */
+#define LDAP_FILTER_PRESENT_30 (ber_tag_t) 0xa7U /* context specific + constructed */
/* old broken stuff */
-#define OLD_LDAP_FILTER_AND 0x00UL
-#define OLD_LDAP_FILTER_OR 0x01UL
-#define OLD_LDAP_FILTER_NOT 0x02UL
-#define OLD_LDAP_FILTER_EQUALITY 0x03UL
-#define OLD_LDAP_FILTER_SUBSTRINGS 0x04UL
-#define OLD_LDAP_FILTER_GE 0x05UL
-#define OLD_LDAP_FILTER_LE 0x06UL
-#define OLD_LDAP_FILTER_PRESENT 0x07UL
-#define OLD_LDAP_FILTER_APPROX 0x08UL
+#define OLD_LDAP_FILTER_AND (ber_tag_t) 0x00U
+#define OLD_LDAP_FILTER_OR (ber_tag_t) 0x01U
+#define OLD_LDAP_FILTER_NOT (ber_tag_t) 0x02U
+#define OLD_LDAP_FILTER_EQUALITY (ber_tag_t) 0x03U
+#define OLD_LDAP_FILTER_SUBSTRINGS (ber_tag_t) 0x04U
+#define OLD_LDAP_FILTER_GE (ber_tag_t) 0x05U
+#define OLD_LDAP_FILTER_LE (ber_tag_t) 0x06U
+#define OLD_LDAP_FILTER_PRESENT (ber_tag_t) 0x07U
+#define OLD_LDAP_FILTER_APPROX (ber_tag_t) 0x08U
/* extended filter component types */
-#define LDAP_FILTER_EXTENDED_OID 0x81UL /* context specific */
-#define LDAP_FILTER_EXTENDED_TYPE 0x82UL /* context specific */
-#define LDAP_FILTER_EXTENDED_VALUE 0x83UL /* context specific */
-#define LDAP_FILTER_EXTENDED_DNATTRS 0x84UL /* context specific */
+#define LDAP_FILTER_EXTENDED_OID (ber_tag_t) 0x81U /* context specific */
+#define LDAP_FILTER_EXTENDED_TYPE (ber_tag_t) 0x82U /* context specific */
+#define LDAP_FILTER_EXTENDED_VALUE (ber_tag_t) 0x83U /* context specific */
+#define LDAP_FILTER_EXTENDED_DNATTRS (ber_tag_t) 0x84U /* context specific */
/* substring filter component types */
-#define LDAP_SUBSTRING_INITIAL 0x80UL /* context specific */
-#define LDAP_SUBSTRING_ANY 0x81UL /* context specific */
-#define LDAP_SUBSTRING_FINAL 0x82UL /* context specific */
+#define LDAP_SUBSTRING_INITIAL (ber_tag_t) 0x80U /* context specific */
+#define LDAP_SUBSTRING_ANY (ber_tag_t) 0x81U /* context specific */
+#define LDAP_SUBSTRING_FINAL (ber_tag_t) 0x82U /* context specific */
/* U-Mich version 3.0 compatibility substring filter component types */
-#define LDAP_SUBSTRING_INITIAL_30 0xa0UL /* context specific */
-#define LDAP_SUBSTRING_ANY_30 0xa1UL /* context specific */
-#define LDAP_SUBSTRING_FINAL_30 0xa2UL /* context specific */
+#define LDAP_SUBSTRING_INITIAL_30 (ber_tag_t) 0xa0U /* context specific */
+#define LDAP_SUBSTRING_ANY_30 (ber_tag_t) 0xa1U /* context specific */
+#define LDAP_SUBSTRING_FINAL_30 (ber_tag_t) 0xa2U /* context specific */
/* old broken stuff */
-#define OLD_LDAP_SUBSTRING_INITIAL 0x00UL
-#define OLD_LDAP_SUBSTRING_ANY 0x01UL
-#define OLD_LDAP_SUBSTRING_FINAL 0x02UL
+#define OLD_LDAP_SUBSTRING_INITIAL (ber_tag_t) 0x00U
+#define OLD_LDAP_SUBSTRING_ANY (ber_tag_t) 0x01U
+#define OLD_LDAP_SUBSTRING_FINAL (ber_tag_t) 0x02U
/* search scopes */
-#define LDAP_SCOPE_BASE 0x0000
-#define LDAP_SCOPE_ONELEVEL 0x0001
-#define LDAP_SCOPE_SUBTREE 0x0002
+#define LDAP_SCOPE_BASE (ber_int_t) 0x0000
+#define LDAP_SCOPE_ONELEVEL (ber_int_t) 0x0001
+#define LDAP_SCOPE_SUBTREE (ber_int_t) 0x0002
/* for modifications */
typedef struct ldapmod {
int mod_op;
-#define LDAP_MOD_ADD 0x0000
-#define LDAP_MOD_DELETE 0x0001
-#define LDAP_MOD_REPLACE 0x0002
-#define LDAP_MOD_BVALUES 0x0080
+#define LDAP_MOD_ADD (ber_int_t) 0x0000
+#define LDAP_MOD_DELETE (ber_int_t) 0x0001
+#define LDAP_MOD_REPLACE (ber_int_t) 0x0002
+#define LDAP_MOD_BVALUES (ber_int_t) 0x0080
/* IMPORTANT: do not use code 0x1000 (or above),
* it is used internally by the backends!
* (see ldap/servers/slapd/slap.h)
* (deprecated)
*/
LDAP_F( int )
-ldap_enable_cache LDAP_P(( LDAP *ld, long timeout, long maxmem ));
+ldap_enable_cache LDAP_P(( LDAP *ld, long timeout, ber_len_t maxmem ));
LDAP_F( void )
ldap_disable_cache LDAP_P(( LDAP *ld ));
LDAP_F( LDAPFiltDesc *)
ldap_init_getfilter_buf LDAP_P((
/* LDAP_CONST */ char *buf,
- long buflen ));
+ ber_len_t buflen ));
LDAP_F( LDAPFiltInfo *)
ldap_getfirstfilter LDAP_P((
LDAP_F( void )
ldap_build_filter LDAP_P((
char *buf,
- unsigned long buflen,
+ ber_len_t buflen,
LDAP_CONST char *pattern,
LDAP_CONST char *prefix,
LDAP_CONST char *suffix,
LDAP_F( void * )
ldap_memalloc LDAP_P((
- size_t s ));
+ ber_len_t s ));
LDAP_F( void * )
ldap_memrealloc LDAP_P((
void* p,
- size_t s ));
+ ber_len_t s ));
LDAP_F( void * )
ldap_memcalloc LDAP_P((
- size_t n,
- size_t s ));
+ ber_len_t n,
+ ber_len_t s ));
LDAP_F( void )
ldap_memfree LDAP_P((
ldap_translate_from_t61 LDAP_P((
LDAP *ld,
char **bufp,
- unsigned long *lenp,
+ ber_len_t *lenp,
int free_input ));
LDAP_F( int )
ldap_translate_to_t61 LDAP_P((
LDAP *ld,
char **bufp,
- unsigned long *lenp, int free_input ));
+ ber_len_t *lenp,
+ int free_input ));
LDAP_F( void )
ldap_enable_translation LDAP_P((
LDAP_F( int )
ldap_t61_to_8859 LDAP_P((
char **bufp,
- unsigned long *buflenp,
+ ber_len_t *buflenp,
int free_input ));
LDAP_F( int )
ldap_8859_to_t61 LDAP_P((
char **bufp,
- unsigned long *buflenp,
+ ber_len_t *buflenp,
int free_input ));
LDAP_END_DECL
LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
*/
+/* These are defined in lber_types.h */
+/*
+ LBER_INT_T
+ LBER_LEN_T
+ LBER_SOCKET_T
+ LBER_TAG_T
+*/
/* The number of bytes in a int. */
#undef SIZEOF_INT
#define OPENLDAP_PACKAGE "OpenLDAP"
#define OPENLDAP_VERSION "-devel"
#define EXEEXT ".exe"
+#define LDAP_DIRSEP "\\"
#if defined( _DEBUG ) && !defined( LDAP_DEBUG )
/* #define LDAP_MEMORY_DEBUG 1 */
/* define type for caddr_t */
typedef char * caddr_t;
+#define ssize_t signed int
+
#define LOG_DEBUG 0
#define openlog( a, b )
#define closelog()
LDAP_F( int )
ldap_init_searchprefs_buf LDAP_P(( char *buf,
- long buflen,
+ ber_len_t buflen,
struct ldap_searchobj **solistp ));
LDAP_F( void )
*/
void*
-avl_find( Avlnode *root, void* data, AVL_CMP fcmp )
+avl_find( Avlnode *root, const void* data, AVL_CMP fcmp )
{
int cmp;
*/
void*
-avl_find_lin( Avlnode *root, void* data, AVL_CMP fcmp )
+avl_find_lin( Avlnode *root, const void* data, AVL_CMP fcmp )
{
void* res;
ber_log_bprint(int errlvl,
int loglvl,
const char *data,
- int len )
+ ber_len_t len )
{
assert( data != NULL );
void
ber_bprint(
LDAP_CONST char *data,
- int len )
+ ber_len_t len )
{
static const char hexdig[] = "0123456789abcdef";
#define BPLEN 48
(*ber_pvt_log_print)( "*** sos dump ***\n" );
- while ( sos != NULLSEQORSET ) {
+ while ( sos != NULL ) {
sprintf( buf, "ber_sos_dump: clen %ld first 0x%lx ptr 0x%lx\n",
- (long) sos->sos_clen, (long) sos->sos_first, (long) sos->sos_ptr );
+ (long) sos->sos_clen,
+ (long) sos->sos_first,
+ (long) sos->sos_ptr );
(*ber_pvt_log_print)( buf );
sprintf( buf, " current len %ld contents:\n",
#include "lber-int.h"
-static int ber_getnint LDAP_P(( BerElement *ber, long *num, int len ));
+static ber_tag_t ber_getnint LDAP_P((
+ BerElement *ber,
+ ber_int_t *num,
+ ber_len_t len ));
/* return the tag - LBER_DEFAULT returned means trouble */
-unsigned long
+ber_tag_t
ber_get_tag( BerElement *ber )
{
unsigned char xbyte;
- unsigned long tag;
+ ber_tag_t tag;
char *tagp;
unsigned int i;
return( LBER_DEFAULT );
if ( (xbyte & LBER_BIG_TAG_MASK) != LBER_BIG_TAG_MASK )
- return( (unsigned long) xbyte );
+ return( (ber_tag_t) xbyte );
tagp = (char *) &tag;
tagp[0] = xbyte;
- for ( i = 1; i < sizeof(long); i++ ) {
+ for ( i = 1; i < sizeof(ber_tag_t); i++ ) {
if ( ber_read( ber, (char *) &xbyte, 1 ) != 1 )
return( LBER_DEFAULT );
}
/* tag too big! */
- if ( i == sizeof(long) )
+ if ( i == sizeof(ber_tag_t) )
return( LBER_DEFAULT );
/* want leading, not trailing 0's */
- return( tag >> (sizeof(long) - i - 1) );
+ return( tag >> (sizeof(ber_tag_t) - i - 1) );
}
-unsigned long
-ber_skip_tag( BerElement *ber, unsigned long *len )
+ber_tag_t
+ber_skip_tag( BerElement *ber, ber_len_t *len )
{
- unsigned long tag;
+ ber_tag_t tag;
unsigned char lc;
- unsigned int noctets;
+ ber_len_t noctets;
int diff;
- unsigned long netlen;
+ ber_len_t netlen;
assert( ber != NULL );
assert( len != NULL );
return( LBER_DEFAULT );
if ( lc & 0x80U ) {
noctets = (lc & 0x7fU);
- if ( (unsigned) noctets > sizeof(unsigned long) )
+ if ( noctets > sizeof(ber_len_t) )
return( LBER_DEFAULT );
- diff = sizeof(unsigned long) - noctets;
+ diff = sizeof(ber_len_t) - noctets;
if ( (unsigned) ber_read( ber, (char *) &netlen + diff, noctets )
!= noctets )
return( LBER_DEFAULT );
- *len = AC_NTOHL( netlen );
+ *len = LBER_LEN_NTOH( netlen );
} else {
*len = lc;
}
return( tag );
}
-unsigned long
+ber_tag_t
ber_peek_tag(
- LDAP_CONST BerElement *ber_in, /* not const per c-api-02 */
- unsigned long *len )
+ LDAP_CONST BerElement *ber_in,
+ ber_len_t *len )
{
- unsigned long tag;
+ ber_tag_t tag;
BerElement *ber;
assert( ber_in != NULL );
return( tag );
}
-static int
-ber_getnint( BerElement *ber, long *num, int len )
+static ber_tag_t
+ber_getnint(
+ BerElement *ber,
+ ber_int_t *num,
+ ber_len_t len )
{
- int diff, sign, i;
- long netnum;
- char *p;
+ unsigned char buf[sizeof(ber_int_t)];
assert( ber != NULL );
assert( num != NULL );
* extend after we read it in.
*/
- if ( (unsigned) len > sizeof(long) )
+ if ( len > sizeof(ber_int_t) )
return( -1 );
- netnum = 0;
- diff = sizeof(long) - len;
- /* read into the low-order bytes of netnum */
- if ( ber_read( ber, ((char *) &netnum) + diff, len ) != len )
+ /* read into the low-order bytes of our buffer */
+ if ( (ber_len_t) ber_read( ber, buf, len ) != len ) {
return( -1 );
+ }
+
+ if( len ) {
+ /* sign extend if necessary */
+ ber_len_t i;
+ ber_int_t netnum = 0x80 & buf[0] ? -1 : 0;
- /* sign extend if necessary */
- p = (char *) &netnum;
- sign = (0x80 & *(p+diff) );
- if ( sign && ((unsigned) len < sizeof(long)) ) {
- for ( i = 0; i < diff; i++ ) {
- *(p+i) = (unsigned char) 0xff;
+ /* shift in the bytes */
+ for( i=0 ; i<len; i++ ) {
+ netnum = (netnum << 8 ) | buf[i];
}
+
+ *num = netnum;
+
+ } else {
+ *num = 0;
}
- *num = AC_NTOHL( netnum );
return( len );
}
-unsigned long
-ber_get_int( BerElement *ber, long *num )
+ber_tag_t
+ber_get_int(
+ BerElement *ber,
+ ber_int_t *num )
{
- unsigned long tag, len;
+ ber_tag_t tag;
+ ber_len_t len;
assert( ber != NULL );
assert( BER_VALID( ber ) );
if ( (tag = ber_skip_tag( ber, &len )) == LBER_DEFAULT )
return( LBER_DEFAULT );
- if ( (unsigned long) ber_getnint( ber, num, (int)len ) != len )
+ if ( (unsigned long) ber_getnint( ber, num, len ) != len )
return( LBER_DEFAULT );
else
return( tag );
}
-unsigned long
-ber_get_stringb( BerElement *ber, char *buf, unsigned long *len )
+ber_tag_t
+ber_get_stringb(
+ BerElement *ber,
+ char *buf,
+ ber_len_t *len )
{
- unsigned long datalen, tag;
+ ber_len_t datalen;
+ ber_tag_t tag;
+
#ifdef STR_TRANSLATION
char *transbuf;
#endif /* STR_TRANSLATION */
return( tag );
}
-unsigned long
+ber_tag_t
ber_get_stringa( BerElement *ber, char **buf )
{
- unsigned long datalen, tag;
+ ber_len_t datalen;
+ ber_tag_t tag;
assert( ber != NULL );
assert( buf != NULL );
return( LBER_DEFAULT );
}
- if ( (*buf = (char *) LBER_MALLOC( (size_t)datalen + 1 )) == NULL )
+ if ( (*buf = (char *) LBER_MALLOC( datalen + 1 )) == NULL )
return( LBER_DEFAULT );
if ( (unsigned long) ber_read( ber, *buf, datalen ) != datalen ) {
return( tag );
}
-unsigned long
+ber_tag_t
ber_get_stringal( BerElement *ber, struct berval **bv )
{
- unsigned long len, tag;
+ ber_len_t len;
+ ber_tag_t tag;
assert( ber != NULL );
assert( bv != NULL );
if ( (*bv = (struct berval *) LBER_MALLOC( sizeof(struct berval) )) == NULL )
return( LBER_DEFAULT );
- if ( ((*bv)->bv_val = (char *) LBER_MALLOC( (size_t)len + 1 )) == NULL ) {
+ if ( ((*bv)->bv_val = (char *) LBER_MALLOC( len + 1 )) == NULL ) {
LBER_FREE( *bv );
*bv = NULL;
return( LBER_DEFAULT );
}
- if ( (unsigned long) ber_read( ber, (*bv)->bv_val, len ) != len ) {
+ if ( (ber_len_t) ber_read( ber, (*bv)->bv_val, len ) != len ) {
ber_bvfree( *bv );
*bv = NULL;
return( LBER_DEFAULT );
return( tag );
}
-unsigned long
-ber_get_bitstringa( BerElement *ber, char **buf, unsigned long *blen )
+ber_tag_t
+ber_get_bitstringa(
+ BerElement *ber,
+ char **buf,
+ ber_len_t *blen )
{
- unsigned long datalen, tag;
+ ber_len_t datalen;
+ ber_tag_t tag;
unsigned char unusedbits;
assert( ber != NULL );
}
--datalen;
- if ( (*buf = (char *) LBER_MALLOC( (size_t)datalen )) == NULL )
+ if ( (*buf = (char *) LBER_MALLOC( datalen )) == NULL )
return( LBER_DEFAULT );
if ( ber_read( ber, (char *)&unusedbits, 1 ) != 1 ) {
return( tag );
}
-unsigned long
+ber_tag_t
ber_get_null( BerElement *ber )
{
- unsigned long len, tag;
+ ber_len_t len;
+ ber_tag_t tag;
assert( ber != NULL );
assert( BER_VALID( ber ) );
return( tag );
}
-unsigned long
-ber_get_boolean( BerElement *ber, int *boolval )
+ber_tag_t
+ber_get_boolean(
+ BerElement *ber,
+ ber_int_t *boolval )
{
- long longbool;
- int rc;
+ ber_int_t longbool;
+ ber_tag_t rc;
assert( ber != NULL );
assert( boolval != NULL );
return( rc );
}
-unsigned long
-ber_first_element( BerElement *ber, unsigned long *len, char **last )
+ber_tag_t
+ber_first_element(
+ BerElement *ber,
+ ber_len_t *len,
+ char **last )
{
assert( ber != NULL );
assert( len != NULL );
return( ber_peek_tag( ber, len ) );
}
-unsigned long
-ber_next_element( BerElement *ber, unsigned long *len, char *last )
+ber_tag_t
+ber_next_element(
+ BerElement *ber,
+ ber_len_t *len,
+ char *last )
{
assert( ber != NULL );
assert( len != NULL );
}
/* VARARGS */
-unsigned long
+ber_tag_t
ber_scanf
#if HAVE_STDARG
( BerElement *ber,
char *last;
char *s, **ss, ***sss;
struct berval ***bv, **bvp, *bval;
- int *i, j;
- long *l;
- unsigned long rc, tag, len;
+ ber_int_t *i;
+ int j;
+ ber_len_t *l;
+ ber_tag_t *t;
+ ber_tag_t rc, tag;
+ ber_len_t len;
#ifdef HAVE_STDARG
va_start( ap, fmt );
break;
case 'b': /* boolean */
- i = va_arg( ap, int * );
+ i = va_arg( ap, ber_int_t * );
rc = ber_get_boolean( ber, i );
break;
case 'e': /* enumerated */
case 'i': /* int */
- l = va_arg( ap, long * );
- rc = ber_get_int( ber, l );
+ i = va_arg( ap, ber_int_t * );
+ rc = ber_get_int( ber, i );
break;
case 'l': /* length of next item */
- l = va_arg( ap, long * );
+ l = va_arg( ap, ber_len_t * );
rc = ber_peek_tag( ber, l );
break;
case 's': /* octet string - in a buffer */
s = va_arg( ap, char * );
- l = va_arg( ap, long * );
+ l = va_arg( ap, ber_len_t * );
rc = ber_get_stringb( ber, s, l );
break;
case 'B': /* bit string - allocate storage as needed */
ss = va_arg( ap, char ** );
- l = va_arg( ap, long * ); /* for length, in bits */
+ l = va_arg( ap, ber_len_t * ); /* for length, in bits */
rc = ber_get_bitstringa( ber, ss, l );
break;
case 't': /* tag of next item */
- l = va_arg( ap, long * );
- *l = rc = ber_peek_tag( ber, &len );
+ t = va_arg( ap, ber_tag_t * );
+ *t = rc = ber_peek_tag( ber, &len );
break;
case 'T': /* skip tag of next item */
- l = va_arg( ap, long * );
- *l = rc = ber_skip_tag( ber, &len );
+ t = va_arg( ap, ber_tag_t * );
+ *t = rc = ber_skip_tag( ber, &len );
break;
case 'v': /* sequence of strings */
break;
case 'b': /* boolean */
+ case 'e': /* enumerated */
+ case 'i': /* int */
(void) va_arg( ap, int * );
break;
case 's': /* octet string - in a buffer */
(void) va_arg( ap, char * );
- (void) va_arg( ap, long * );
+ (void) va_arg( ap, ber_len_t * );
break;
- case 'e': /* enumerated */
- case 'i': /* int */
case 'l': /* length of next item */
+ (void) va_arg( ap, ber_len_t * );
+ break;
+
case 't': /* tag of next item */
case 'T': /* skip tag of next item */
- (void) va_arg( ap, long * );
+ (void) va_arg( ap, ber_tag_t * );
break;
case 'o': /* octet string in a supplied berval */
LBER_FREE( *ss );
*ss = NULL;
}
- *(va_arg( ap, long * )) = 0; /* for length, in bits */
+ *(va_arg( ap, ber_len_t * )) = 0; /* for length, in bits */
break;
case 'v': /* sequence of strings */
#include "lber-int.h"
-static int ber_put_len LDAP_P(( BerElement *ber,
- unsigned long len, int nosos ));
+static int ber_put_len LDAP_P((
+ BerElement *ber,
+ ber_len_t len,
+ int nosos ));
-static int ber_start_seqorset LDAP_P(( BerElement *ber,
- unsigned long tag ));
+static int ber_start_seqorset LDAP_P((
+ BerElement *ber,
+ ber_tag_t tag ));
static int ber_put_seqorset LDAP_P(( BerElement *ber ));
-static int ber_put_int_or_enum LDAP_P(( BerElement *ber,
- long num, unsigned long tag ));
+static int ber_put_int_or_enum LDAP_P((
+ BerElement *ber,
+ ber_int_t num,
+ ber_tag_t tag ));
-static int
-ber_calc_taglen( unsigned long tag )
+static ber_len_t
+ber_calc_taglen( ber_tag_t tag )
{
int i;
- unsigned long mask;
+ ber_tag_t mask;
/* find the first non-all-zero byte in the tag */
- for ( i = sizeof(long) - 1; i > 0; i-- ) {
- mask = (0xffUL << (i * 8));
+ for ( i = sizeof(ber_tag_t) - 1; i > 0; i-- ) {
+ mask = ((ber_tag_t)0xffU << (i * 8));
/* not all zero */
if ( tag & mask )
break;
}
static int
-ber_put_tag( BerElement *ber, unsigned long tag, int nosos )
+ber_put_tag(
+ BerElement *ber,
+ ber_tag_t tag,
+ int nosos )
{
- int taglen;
- unsigned long ntag;
+ int rc;
+ ber_len_t taglen;
+ ber_tag_t ntag;
assert( ber != NULL );
assert( BER_VALID( ber ) );
taglen = ber_calc_taglen( tag );
- ntag = AC_HTONL( tag );
+ ntag = LBER_TAG_HTON( tag );
+
+ rc = ber_write( ber,
+ ((char *) &ntag) + sizeof(ber_tag_t) - taglen,
+ taglen, nosos );
- return( ber_write( ber, ((char *) &ntag) + sizeof(long) - taglen,
- taglen, nosos ) );
+ return rc;
}
-static int
-ber_calc_lenlen( unsigned long len )
+static ber_len_t
+ber_calc_lenlen( ber_len_t len )
{
/*
* short len if it's less than 128 - one byte giving the len,
* with bit 8 0.
*/
- if ( len <= 0x7FUL )
+ if ( len <= (ber_len_t) 0x7FU )
return( 1 );
/*
* length of the length, followed by the length itself.
*/
- if ( len <= 0xffUL )
+ if ( len <= (ber_len_t) 0xffU )
return( 2 );
- if ( len <= 0xffffUL )
+ if ( len <= (ber_len_t) 0xffffU )
return( 3 );
- if ( len <= 0xffffffUL )
+ if ( len <= (ber_len_t) 0xffffffU )
return( 4 );
return( 5 );
}
static int
-ber_put_len( BerElement *ber, unsigned long len, int nosos )
+ber_put_len( BerElement *ber, ber_len_t len, int nosos )
{
int i;
char lenlen;
- unsigned long mask;
- unsigned long netlen;
+ ber_len_t mask;
+ ber_len_t netlen;
assert( ber != NULL );
assert( BER_VALID( ber ) );
*/
if ( len <= 127 ) {
- netlen = AC_HTONL( len );
+ netlen = LBER_LEN_HTON( len );
return( ber_write( ber, (char *) &netlen + sizeof(long) - 1,
1, nosos ) );
}
*/
/* find the first non-all-zero byte */
- for ( i = sizeof(long) - 1; i > 0; i-- ) {
- mask = (0xffUL << (i * 8));
+ for ( i = sizeof(ber_len_t) - 1; i > 0; i-- ) {
+ mask = (0xffU << (i * 8));
/* not all zero */
if ( len & mask )
break;
return( -1 );
/* write the length itself */
- netlen = AC_HTONL( len );
- if ( ber_write( ber, (char *) &netlen + (sizeof(long) - i), i, nosos )
+ netlen = LBER_LEN_HTON( len );
+ if ( ber_write( ber, (char *) &netlen + (sizeof(ber_len_t) - i), i, nosos )
!= i )
return( -1 );
}
static int
-ber_put_int_or_enum( BerElement *ber, long num, unsigned long tag )
+ber_put_int_or_enum(
+ BerElement *ber,
+ ber_int_t num,
+ ber_tag_t tag )
{
- int i, sign, taglen;
- int len, lenlen;
- long netnum, mask;
+ int i, sign;
+ ber_len_t len, lenlen, taglen;
+ ber_int_t netnum, mask;
assert( ber != NULL );
assert( BER_VALID( ber ) );
* high bit is set - look for first non-all-one byte
* high bit is clear - look for first non-all-zero byte
*/
- for ( i = sizeof(long) - 1; i > 0; i-- ) {
- mask = (0xffUL << (i * 8));
+ for ( i = sizeof(ber_int_t) - 1; i > 0; i-- ) {
+ mask = (0xffU << (i * 8));
if ( sign ) {
/* not all ones */
* we now have the "leading byte". if the high bit on this
* byte matches the sign bit, we need to "back up" a byte.
*/
- mask = (num & (0x80UL << (i * 8)));
+ mask = (num & (0x80U << (i * 8)));
if ( (mask && !sign) || (sign && !mask) )
i++;
if ( (lenlen = ber_put_len( ber, len, 0 )) == -1 )
return( -1 );
i++;
- netnum = AC_HTONL( num );
- if ( ber_write( ber, (char *) &netnum + (sizeof(long) - i), i, 0 )
+ netnum = LBER_INT_HTON( num );
+ if ( ber_write( ber, (char *) &netnum + (sizeof(ber_int_t) - i), i, 0 )
!= i )
return( -1 );
}
int
-ber_put_enum( BerElement *ber, long num, unsigned long tag )
+ber_put_enum(
+ BerElement *ber,
+ ber_int_t num,
+ ber_tag_t tag )
{
assert( ber != NULL );
assert( BER_VALID( ber ) );
}
int
-ber_put_int( BerElement *ber, long num, unsigned long tag )
+ber_put_int(
+ BerElement *ber,
+ ber_int_t num,
+ ber_tag_t tag )
{
assert( ber != NULL );
assert( BER_VALID( ber ) );
ber_put_ostring(
BerElement *ber,
LDAP_CONST char *str,
- unsigned long len,
- unsigned long tag )
+ ber_len_t len,
+ ber_tag_t tag )
{
- int taglen, lenlen, rc;
+ ber_len_t taglen, lenlen;
+ int rc;
#ifdef STR_TRANSLATION
int free_str;
#endif /* STR_TRANSLATION */
return( rc );
}
+
int
ber_put_berval(
BerElement *ber,
LDAP_CONST struct berval *bv,
- unsigned long tag )
+ ber_tag_t tag )
{
assert( ber != NULL );
assert( bv != NULL );
ber_put_string(
BerElement *ber,
LDAP_CONST char *str,
- unsigned long tag )
+ ber_tag_t tag )
{
assert( ber != NULL );
assert( str != NULL );
ber_put_bitstring(
BerElement *ber,
LDAP_CONST char *str,
- unsigned long blen /* in bits */,
- unsigned long tag )
+ ber_len_t blen /* in bits */,
+ ber_tag_t tag )
{
- int taglen, lenlen, len;
+ ber_len_t taglen, lenlen, len;
unsigned char unusedbits;
assert( ber != NULL );
if ( ber_write( ber, (char *)&unusedbits, 1, 0 ) != 1 )
return( -1 );
- if ( ber_write( ber, str, len, 0 ) != len )
+ if ( (ber_len_t) ber_write( ber, str, len, 0 ) != len )
return( -1 );
/* return length of tag + length + unused bit count + contents */
}
int
-ber_put_null( BerElement *ber, unsigned long tag )
+ber_put_null( BerElement *ber, ber_tag_t tag )
{
- int taglen;
+ ber_len_t taglen;
assert( ber != NULL );
assert( BER_VALID( ber ) );
}
int
-ber_put_boolean( BerElement *ber, int boolval, unsigned long tag )
+ber_put_boolean(
+ BerElement *ber,
+ ber_int_t boolval,
+ ber_tag_t tag )
{
- int taglen;
- unsigned char trueval = 0xffU;
+ ber_len_t taglen;
+ unsigned char trueval = 0xFFU;
unsigned char falseval = 0x00U;
assert( ber != NULL );
#define FOUR_BYTE_LEN 5
static int
-ber_start_seqorset( BerElement *ber, unsigned long tag )
+ber_start_seqorset(
+ BerElement *ber,
+ ber_tag_t tag )
{
Seqorset *new;
new = (Seqorset *) LBER_CALLOC( 1, sizeof(Seqorset) );
- if ( new == NULLSEQORSET )
+ if ( new == NULL )
return( -1 );
new->sos_ber = ber;
- if ( ber->ber_sos == NULLSEQORSET )
+ if ( ber->ber_sos == NULL )
new->sos_first = ber->ber_ptr;
else
new->sos_first = ber->ber_sos->sos_ptr;
}
int
-ber_start_seq( BerElement *ber, unsigned long tag )
+ber_start_seq( BerElement *ber, ber_tag_t tag )
{
assert( ber != NULL );
assert( BER_VALID( ber ) );
}
int
-ber_start_set( BerElement *ber, unsigned long tag )
+ber_start_set( BerElement *ber, ber_tag_t tag )
{
assert( ber != NULL );
assert( BER_VALID( ber ) );
static int
ber_put_seqorset( BerElement *ber )
{
- unsigned long len, netlen;
- int taglen, lenlen;
+ ber_len_t len, netlen;
+ ber_len_t taglen, lenlen;
unsigned char ltag = 0x80U + FOUR_BYTE_LEN - 1;
Seqorset *next;
Seqorset **sos = &ber->ber_sos;
*/
len = (*sos)->sos_clen;
- netlen = AC_HTONL( len );
- if ( sizeof(long) > 4 && len > 0xffffffffUL )
+ netlen = LBER_LEN_HTON( len );
+ if ( sizeof(ber_len_t) > 4 && len > 0xffffffffUL )
return( -1 );
if ( ber->ber_options & LBER_USE_DER ) {
lenlen = FOUR_BYTE_LEN;
}
- if ( (next = (*sos)->sos_next) == NULLSEQORSET ) {
+ if ( (next = (*sos)->sos_next) == NULL ) {
/* write the tag */
if ( (taglen = ber_put_tag( ber, (*sos)->sos_tag, 1 )) == -1 )
return( -1 );
/* The ber_ptr is at the set/seq start - move it to the end */
(*sos)->sos_ber->ber_ptr += len;
} else {
- unsigned long ntag;
+ ber_tag_t ntag;
/* the tag */
taglen = ber_calc_taglen( (*sos)->sos_tag );
- ntag = AC_HTONL( (*sos)->sos_tag );
+ ntag = LBER_TAG_HTON( (*sos)->sos_tag );
SAFEMEMCPY( (*sos)->sos_first, (char *) &ntag +
- sizeof(long) - taglen, taglen );
+ sizeof(ber_tag_t) - taglen, taglen );
if ( ber->ber_options & LBER_USE_DER ) {
ltag = (lenlen == 1)
? (unsigned char) len
- : (unsigned char) (0x80UL + (lenlen - 1));
+ : (unsigned char) (0x80U + (lenlen - 1));
}
/* one byte of length length */
if (lenlen > 1) {
/* Write the length itself */
SAFEMEMCPY( (*sos)->sos_first + 2,
- (char *)&netlen + sizeof(unsigned long) -
+ (char *)&netlen + sizeof(ber_len_t) -
(lenlen - 1),
lenlen - 1 );
}
} else {
/* the length itself */
SAFEMEMCPY( (*sos)->sos_first + taglen + 1,
- (char *) &netlen + sizeof(long) -
+ (char *) &netlen + sizeof(ber_len_t) -
(FOUR_BYTE_LEN - 1), FOUR_BYTE_LEN - 1 );
}
#endif
char *s, **ss;
struct berval *bv, **bvp;
- int rc, i;
- unsigned long len;
+ int rc;
+ ber_int_t i;
+ ber_len_t len;
#ifdef HAVE_STDARG
va_start( ap, fmt );
} break;
case 'b': /* boolean */
- i = va_arg( ap, int );
+ i = va_arg( ap, ber_int_t );
rc = ber_put_boolean( ber, i, ber->ber_tag );
break;
case 'i': /* int */
- i = va_arg( ap, int );
+ i = va_arg( ap, ber_int_t );
rc = ber_put_int( ber, i, ber->ber_tag );
break;
case 'e': /* enumeration */
- i = va_arg( ap, int );
+ i = va_arg( ap, ber_int_t );
rc = ber_put_enum( ber, i, ber->ber_tag );
break;
case 'o': /* octet string (non-null terminated) */
s = va_arg( ap, char * );
- len = va_arg( ap, int );
+ len = va_arg( ap, ber_len_t );
rc = ber_put_ostring( ber, s, len, ber->ber_tag );
break;
break;
case 't': /* tag for the next element */
- ber->ber_tag = va_arg( ap, unsigned long );
+ ber->ber_tag = va_arg( ap, ber_tag_t );
ber->ber_usertag = 1;
break;
#include "lber-int.h"
-static long BerRead LDAP_P(( Sockbuf *sb, char *buf, long len ));
-static int ber_realloc LDAP_P(( BerElement *ber, unsigned long len ));
+static ber_slen_t BerRead LDAP_P((
+ Sockbuf *sb,
+ char *buf,
+ ber_len_t len ));
+
+static int ber_realloc LDAP_P((
+ BerElement *ber,
+ ber_len_t len ));
#define EXBUFSIZ 1024
# define MAX_BERBUFSIZE 65535
#endif
-static long
-BerRead( Sockbuf *sb, char *buf, long len )
+static ber_slen_t
+BerRead(
+ Sockbuf *sb,
+ char *buf,
+ ber_len_t len )
{
- int c;
- long nread = 0;
+ ber_slen_t c;
+ ber_slen_t nread = 0;
assert( sb != NULL );
assert( buf != NULL );
return( nread );
}
-long
-ber_read( BerElement *ber, char *buf, unsigned long len )
+ber_slen_t
+ber_read(
+ BerElement *ber,
+ char *buf,
+ ber_len_t len )
{
- unsigned long actuallen, nleft;
+ ber_len_t actuallen, nleft;
assert( ber != NULL );
assert( buf != NULL );
nleft = ber->ber_end - ber->ber_ptr;
actuallen = nleft < len ? nleft : len;
- SAFEMEMCPY( buf, ber->ber_ptr, (size_t)actuallen );
+ SAFEMEMCPY( buf, ber->ber_ptr, actuallen );
ber->ber_ptr += actuallen;
- return( (long)actuallen );
+ return( (ber_slen_t) actuallen );
}
-long
+ber_slen_t
ber_write(
BerElement *ber,
LDAP_CONST char *buf,
- unsigned long len,
+ ber_len_t len,
int nosos )
{
assert( ber != NULL );
}
SAFEMEMCPY( ber->ber_ptr, buf, (size_t)len );
ber->ber_ptr += len;
- return( len );
+ return( (ber_slen_t) len );
+
} else {
if ( ber->ber_sos->sos_ptr + len > ber->ber_end ) {
if ( ber_realloc( ber, len ) != 0 )
SAFEMEMCPY( ber->ber_sos->sos_ptr, buf, (size_t)len );
ber->ber_sos->sos_ptr += len;
ber->ber_sos->sos_clen += len;
- return( len );
+ return( (ber_slen_t) len );
}
}
static int
-ber_realloc( BerElement *ber, unsigned long len )
+ber_realloc( BerElement *ber, ber_len_t len )
{
- unsigned long need, have, total;
+ ber_len_t need, have, total;
Seqorset *s;
long off;
char *oldbuf;
if ( ber->ber_buf != oldbuf ) {
ber->ber_ptr = ber->ber_buf + (ber->ber_ptr - oldbuf);
- for ( s = ber->ber_sos; s != NULLSEQORSET; s = s->sos_next ) {
+ for ( s = ber->ber_sos; s != NULL; s = s->sos_next ) {
off = s->sos_first - oldbuf;
s->sos_first = ber->ber_buf + off;
int
ber_flush( Sockbuf *sb, BerElement *ber, int freeit )
{
- long nwritten, towrite, rc;
+ ber_len_t nwritten, towrite;
+ ber_slen_t rc;
assert( sb != NULL );
assert( ber != NULL );
ber = (BerElement *) LBER_CALLOC( 1, sizeof(BerElement) );
- if ( ber == NULLBER )
- return( NULLBER );
+ if ( ber == NULL )
+ return( NULL );
ber->ber_valid = LBER_VALID_BERELEMENT;
ber->ber_tag = LBER_DEFAULT;
ber = ber_alloc_t( 0 );
- if( ber == NULLBER ) {
+ if( ber == NULL ) {
/* allocation failed */
return ( NULL );
}
/* copy the data */
- if ( ( (unsigned int) ber_write ( ber, bv->bv_val, bv->bv_len, 0 )) != bv->bv_len ) {
+ if ( ( (ber_len_t) ber_write ( ber, bv->bv_val, bv->bv_len, 0 )) != bv->bv_len ) {
/* write failed, so free and return NULL */
ber_free( ber, 1 );
return( NULL );
} else {
/* copy the berval */
- ptrdiff_t len = ber->ber_ptr - ber->ber_buf;
+ ber_len_t len = ber->ber_ptr - ber->ber_buf;
if ( (bv->bv_val = (char *) LBER_MALLOC( len + 1 )) == NULL ) {
ber_bvfree( bv );
return( -1 );
}
- SAFEMEMCPY( bv->bv_val, ber->ber_buf, (size_t)len );
+ SAFEMEMCPY( bv->bv_val, ber->ber_buf, len );
bv->bv_val[len] = '\0';
bv->bv_len = len;
}
#if 0
/* return the tag - LBER_DEFAULT returned means trouble */
-static unsigned long
+static ber_tag_t
get_tag( Sockbuf *sb )
{
unsigned char xbyte;
- unsigned long tag;
+ ber_tag_t tag;
char *tagp;
unsigned int i;
return( LBER_DEFAULT );
if ( (xbyte & LBER_BIG_TAG_MASK) != LBER_BIG_TAG_MASK )
- return( (unsigned long) xbyte );
+ return( (ber_tag_t) xbyte );
tagp = (char *) &tag;
tagp[0] = xbyte;
- for ( i = 1; i < sizeof(long); i++ ) {
+ for ( i = 1; i < sizeof(ber_tag_t); i++ ) {
if ( ber_pvt_sb_read( sb, (char *) &xbyte, 1 ) != 1 )
return( LBER_DEFAULT );
}
/* tag too big! */
- if ( i == sizeof(long) )
+ if ( i == sizeof(ber_tag_t) )
return( LBER_DEFAULT );
/* want leading, not trailing 0's */
- return( tag >> (sizeof(long) - i - 1) );
+ return( tag >> (sizeof(ber_tag_t) - i - 1) );
}
#endif
* a full packet is read.
*/
-unsigned long
-ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber )
+ber_tag_t
+ber_get_next(
+ Sockbuf *sb,
+ ber_len_t *len,
+ BerElement *ber )
{
assert( sb != NULL );
assert( len != NULL );
return LBER_DEFAULT;
if (c & 0x80U) {
int len = c & 0x7fU;
- if ( (len==0) || ((unsigned) len>sizeof( ber->ber_len ) ) ) {
+ if ( (len==0) || ( len>sizeof( ber->ber_len ) ) ) {
errno = ERANGE;
return LBER_DEFAULT;
}
}
}
if (PTR_IN_VAR(ber->ber_rwptr, ber->ber_len)) {
- int res;
- int to_go;
+ ber_slen_t res;
+ ber_slen_t to_go;
to_go = (char *) &ber->ber_len + sizeof( ber->ber_len ) -
ber->ber_rwptr;
assert( to_go > 0 );
ber->ber_rwptr += res;
if (res==to_go) {
/* convert length. */
- ber->ber_len = AC_NTOHL( ber->ber_len );
+ ber->ber_len = LBER_LEN_NTOH( ber->ber_len );
goto fill_buffer;
} else {
#if defined( EWOULDBLOCK )
ber->ber_end = ber->ber_buf + ber->ber_len;
}
if ((ber->ber_rwptr>=ber->ber_buf) && (ber->ber_rwptr<ber->ber_end)) {
- int res;
- int to_go;
+ ber_slen_t res;
+ ber_slen_t to_go;
to_go = ber->ber_end - ber->ber_rwptr;
assert( to_go > 0 );
LDAP_BEGIN_DECL
+/* these have to match lber types settings */
+#define LBER_INT_HTON(i) AC_HTONL(i)
+#define LBER_INT_NTOH(i) AC_NTOHL(i)
+#define LBER_LEN_HTON(l) AC_HTONL(l)
+#define LBER_LEN_NTOH(l) AC_NTOHL(l)
+#define LBER_TAG_HTON(t) AC_HTONL(t)
+#define LBER_TAG_NTOH(t) AC_NTOHL(t)
+
+
struct lber_options {
short lbo_valid;
#define LBER_UNINITIALIZED 0x0
#define ber_options ber_opts.lbo_options
#define ber_debug ber_opts.lbo_debug
- int ber_usertag;
+ ber_tag_t ber_usertag;
- unsigned long ber_tag;
- unsigned long ber_len;
+ ber_tag_t ber_tag;
+ ber_len_t ber_len;
char *ber_buf;
char *ber_ptr;
BERTranslateProc ber_decode_translate_proc;
};
#define BER_VALID(ber) ((ber)->ber_valid==LBER_VALID_BERELEMENT)
-#define NULLBER ((BerElement *) 0)
+
#define ber_pvt_ber_bytes(ber) ((ber)->ber_ptr - (ber)->ber_buf)
#define ber_pvt_ber_remaining(ber) ((ber)->ber_end - (ber)->ber_ptr)
int (*sbi_setup)( struct sockbuf * sb, void *arg );
int (*sbi_remove)( struct sockbuf *sb );
- long (*sbi_read)( struct sockbuf *sb, void *buf, long len );
- long (*sbi_write)( struct sockbuf *sb, void *buf, long len );
+ ber_slen_t (*sbi_read)( struct sockbuf *sb, void *buf, ber_len_t len );
+ ber_slen_t (*sbi_write)( struct sockbuf *sb, void *buf, ber_len_t len );
int (*sbi_close)( struct sockbuf *sb );
};
};
struct sockbuf_buf {
- long buf_size;
- long buf_ptr;
- long buf_end;
+ ber_len_t buf_size;
+ ber_len_t buf_ptr;
+ ber_len_t buf_end;
char *buf_base;
};
void *sb_sdata; /* security-layer data pointer */
Sockbuf_Sec *sb_sec;
#endif
-
-#ifndef MACOS
- int sb_sd;
-#else /* MACOS */
- void *sb_sd;
-#endif /* MACOS */
+
+ ber_socket_t sb_sd;
+
#ifdef DEADWOOD
long sb_max_incoming;
#endif
#ifdef LDAP_SASL
Sockbuf_Buf sb_sec_buf_in;
Sockbuf_Buf sb_sec_buf_out;
- long sb_sec_prev_len;
+ ber_len_t sb_sec_prev_len;
#endif
};
#define SOCKBUF_VALID(ber) ((sb)->sb_valid==LBER_VALID_SOCKBUF)
#define ber_pvt_sb_get_desc( sb ) ((sb)->sb_sd)
#define ber_pvt_sb_set_desc( sb, val ) ((sb)->sb_sd =(val))
-#define ber_pvt_sb_in_use( sb ) ((sb)->sb_sd!=-1)
+#define ber_pvt_sb_in_use( sb ) ((sb)->sb_sd != AC_SOCKET_INVALID)
#ifdef USE_SASL
#define ber_pvt_sb_data_ready( sb ) \
struct seqorset {
BerElement *sos_ber;
- unsigned long sos_clen;
- unsigned long sos_tag;
+ ber_len_t sos_clen;
+ ber_tag_t sos_tag;
char *sos_first;
char *sos_ptr;
struct seqorset *sos_next;
};
-#define NULLSEQORSET ((Seqorset *) 0)
+
/*
* bprint.c
int errlvl,
int loglvl,
const char *data,
- int len ));
+ ber_len_t len ));
LDAP_F( int )
ber_log_dump LDAP_P((
LDAP_F( int )
ber_pvt_sb_set_readahead LDAP_P(( Sockbuf *sb, int rh ));
-LDAP_F( long )
-ber_pvt_sb_read LDAP_P(( Sockbuf *sb, void *buf, long len ));
+LDAP_F( ber_slen_t )
+ber_pvt_sb_read LDAP_P(( Sockbuf *sb, void *buf, ber_len_t len ));
-LDAP_F( long )
-ber_pvt_sb_write LDAP_P(( Sockbuf *sb, void *buf, long len ));
+LDAP_F( ber_slen_t )
+ber_pvt_sb_write LDAP_P(( Sockbuf *sb, void *buf, ber_len_t len ));
LDAP_F( int )
ber_pvt_sb_udp_set_dst LDAP_P((Sockbuf *sb, void *addr ));
# End Source File
# Begin Source File
+SOURCE=..\..\include\lber_types.h
+# End Source File
+# Begin Source File
+
SOURCE=.\memory.c
# End Source File
# Begin Source File
#if LDAP_MEMORY_DEBUG
struct ber_mem_hdr {
union bmu_align_u {
+ ber_len_t bmu_len_t;
+ ber_tag_t bmu_tag_t;
+ ber_int_t bmu_int_t;
+
size_t bmu_size_t;
void * bmu_voidp;
double bmu_double;
long bmu_long;
char bmu_char[4];
} ber_align;
-#define bm_junk ber_align.bmu_size_t
+#define bm_junk ber_align.bmu_len_t
#define bm_data ber_align.bmu_char[1]
};
#define BER_MEM_JUNK 0xddeeddeeU
void *
-ber_memalloc( size_t s )
+ber_memalloc( ber_len_t s )
{
ber_int_options.lbo_valid = LBER_INITIALIZED;
void *
-ber_memcalloc( size_t n, size_t s )
+ber_memcalloc( ber_len_t n, ber_len_t s )
{
ber_int_options.lbo_valid = LBER_INITIALIZED;
void *
-ber_memrealloc( void* p, size_t s )
+ber_memrealloc( void* p, ber_len_t s )
{
ber_int_options.lbo_valid = LBER_INITIALIZED;
return NULL;
}
- SAFEMEMCPY( new->bv_val, bv->bv_val, (size_t) bv->bv_len );
+ SAFEMEMCPY( new->bv_val, bv->bv_val, bv->bv_len );
new->bv_val[bv->bv_len] = '\0';
new->bv_len = bv->bv_len;
#define sockbuf_io_read( sb, buf, len ) \
((sb)->sb_io->sbi_read( (sb), (buf), (len) ))
-static long have_no_read( Sockbuf *sb, void *buf, long len );
-static long have_no_write( Sockbuf *sb, void *buf, long len );
+static ber_slen_t have_no_read( Sockbuf *sb, void *buf, ber_len_t len );
+static ber_slen_t have_no_write( Sockbuf *sb, void *buf, ber_len_t len );
static int have_no_close( Sockbuf *sb );
static Sockbuf_IO sb_IO_None=
#endif
#ifdef USE_SASL
-static long
+static ber_len_t
packet_length( char *buf )
{
- long size;
+ ber_len_t size;
assert( buf != NULL );
- size = (((unsigned long)buf[0])<<24)|
- (((unsigned long)buf[1])<<16)|
- (((unsigned long)buf[2])<<8)|
- (((unsigned long)buf[3]));
+ size = (((ber_len_t)buf[0])<<24)|
+ (((ber_len_t)buf[1])<<16)|
+ (((ber_len_t)buf[2])<<8)|
+ (((ber_len_t)buf[3]));
if ((size<0) || (size>MAX_BUF_SIZE)) {
/* somebody is trying to mess me up. */
#endif
static int
-grow_buffer( Sockbuf_Buf * buf, long minsize )
+grow_buffer( Sockbuf_Buf * buf, ber_len_t minsize )
{
- long pw;;
+ ber_len_t pw;;
assert( buf != NULL );
}
#ifdef USE_SASL
-static long
-sockbuf_sec_release( Sockbuf *sb, char *buf, long len )
+static ber_slen_t
+sockbuf_sec_release( Sockbuf *sb, char *buf, ber_len_t len )
{
/* when this is called:
* sb->sb_sec_buf_in.buf_base points to a packet.
}
#endif
-static long
-sockbuf_copy_out( Sockbuf *sb, char **buf, long len )
+static ber_len_t
+sockbuf_copy_out( Sockbuf *sb, char **buf, ber_len_t len )
{
- long blen = (sb->sb_buf.buf_end - sb->sb_buf.buf_ptr );
+ ber_len_t blen = (sb->sb_buf.buf_end - sb->sb_buf.buf_ptr );
assert( buf != NULL );
assert( status_is_ok(sb) );
if (blen) {
- long rlen = (blen<len) ? blen : len;
+ ber_len_t rlen = (blen<len) ? blen : len;
memcpy( *buf, sb->sb_buf.buf_base + sb->sb_buf.buf_ptr, rlen );
sb->sb_buf.buf_ptr+=rlen;
*buf+=rlen;
return sb;
}
-Sockbuf *ber_sockbuf_alloc_fd( int fd )
+Sockbuf *ber_sockbuf_alloc_fd( ber_socket_t fd )
{
Sockbuf *sb = ber_sockbuf_alloc();
LBER_FREE(sb);
}
-long
-ber_pvt_sb_read( Sockbuf *sb, void *buf_arg, long len )
+ber_slen_t
+ber_pvt_sb_read( Sockbuf *sb, void *buf_arg, ber_len_t len )
{
char *buf;
- long ret;
+ ber_slen_t ret;
assert( buf_arg != NULL );
assert( sb != NULL );
#ifdef USE_SASL
if (sb->sb_sec) {
- int max;
+ ber_slen_t max;
assert( sb->sb_sec->sbs_release );
assert( sb->sb_sec_buf_in.buf_base );
if (sb->sb_read_ahead) {
} else {
#endif
if (sb->sb_read_ahead) {
- long max;
+ ber_slen_t max;
max = sb->sb_buf.buf_size - sb->sb_buf.buf_end;
- if (max>len) {
+ if (max> (ber_slen_t) len) {
for(;;) {
ret = sockbuf_io_read( sb,
sb->sb_buf.buf_base +
}
#endif
-long ber_pvt_sb_write( Sockbuf *sb, void *buf, long len_arg )
+ber_slen_t ber_pvt_sb_write( Sockbuf *sb, void *buf, ber_len_t len_arg )
{
- long ret;
- long len = len_arg;
+ ber_slen_t ret;
+ ber_len_t len = len_arg;
assert( buf != NULL );
assert( sb != NULL );
* Support for TCP
*/
-static long
-stream_read( Sockbuf *sb, void *buf, long len )
+static ber_slen_t
+stream_read( Sockbuf *sb, void *buf, ber_len_t len )
{
assert( sb != NULL);
assert( SOCKBUF_VALID( sb ) );
#endif
}
-static long
-stream_write( Sockbuf *sb, void *buf, long len )
+static ber_slen_t
+stream_write( Sockbuf *sb, void *buf, ber_len_t len )
{
assert( sb != NULL);
assert( SOCKBUF_VALID( sb ) );
return 0;
}
-static long
-dgram_read( Sockbuf *sb, void *buf, long len )
+static ber_slen_t
+dgram_read( Sockbuf *sb, void *buf, ber_len_t len )
{
#ifdef LDAP_CONNECTIONLESS
- long rc;
+ ber_slen_t rc;
int addrlen;
struct dgram_data *dd;
# endif /* LDAP_CONNECTIONLESS */
}
-static long
-dgram_write( Sockbuf *sb, void *buf, long len )
+static ber_slen_t
+dgram_write( Sockbuf *sb, void *buf, ber_len_t len )
{
#ifdef LDAP_CONNECTIONLESS
- int rc;
+ ber_slen_t rc;
struct dgram_data *dd;
assert( sb != NULL );
* break the servers.
*/
-static long
-have_no_read( Sockbuf *sb, void *buf, long len )
+static ber_slen_t
+have_no_read( Sockbuf *sb, void *buf, ber_len_t len )
{
assert( sb != NULL );
assert( SOCKBUF_VALID( sb ) );
return -1;
}
-static long
-have_no_write( Sockbuf *sb, void *buf, long len )
+static ber_slen_t
+have_no_write( Sockbuf *sb, void *buf, ber_len_t len )
{
assert( sb != NULL );
assert( SOCKBUF_VALID( sb ) );
static int do_abandon LDAP_P((
LDAP *ld,
- int origid,
- int msgid,
+ ber_int_t origid,
+ ber_int_t msgid,
LDAPControl **sctrls,
LDAPControl **cctrls));
static int
do_abandon(
LDAP *ld,
- int origid,
- int msgid,
+ ber_int_t origid,
+ ber_int_t msgid,
LDAPControl **sctrls,
LDAPControl **cctrls)
{
BerElement *ber;
int i, err, sendabandon;
- unsigned int *old_abandon;
+ ber_int_t *old_abandon;
Sockbuf *sb;
LDAPRequest *lr;
err = 0;
if ( sendabandon ) {
/* create a message to send */
- if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
+ if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
err = -1;
ld->ld_errno = LDAP_NO_MEMORY;
} else {
#ifdef LDAP_CONNECTIONLESS
if ( ld->ld_cldapnaddr > 0 ) {
- err = ber_printf( ber, "{isti", /* leave open '}' */
+ err = ber_printf( ber, "{isti", /* '}' */
++ld->ld_msgid, ld->ld_cldapdn,
LDAP_REQ_ABANDON, msgid );
} else
#endif /* LDAP_CONNECTIONLESS */
{
- err = ber_printf( ber, "{iti", /* leave open '}' */
+ err = ber_printf( ber, "{iti", /* '}' */
++ld->ld_msgid,
LDAP_REQ_ABANDON, msgid );
}
} else {
/* close '{' */
- err = ber_printf( ber, "}" );
+ err = ber_printf( ber, /*{*/ "}" );
if( err == -1 ) {
/* encoding error */
old_abandon = ld->ld_abandoned;
- ld->ld_abandoned = (int *) LDAP_REALLOC( (char *)
- ld->ld_abandoned, (i + 2) * sizeof(int) );
+ ld->ld_abandoned = (ber_int_t *) LDAP_REALLOC( (char *)
+ ld->ld_abandoned, (i + 2) * sizeof(ber_int_t) );
if ( ld->ld_abandoned == NULL ) {
ld->ld_abandoned = old_abandon;
assert( msgidp != NULL );
/* create a message to send */
- if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
+ if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
ld->ld_errno = LDAP_NO_MEMORY;
return ld->ld_errno;
}
- rc = ber_printf( ber, "{it{s{", /* leave open '}}}' */
+ rc = ber_printf( ber, "{it{s{", /* '}}}' */
++ld->ld_msgid, LDAP_REQ_ADD, dn );
if ( rc == -1 ) {
}
}
- /* close '{{' */
- if ( ber_printf( ber, "}}" ) == -1 ) {
+ if ( ber_printf( ber, /*{{*/ "}}" ) == -1 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
ber_free( ber, 1 );
return ld->ld_errno;
return ld->ld_errno;
}
- /* close '{' */
- if ( ber_printf( ber, "}" ) == -1 ) {
+ if ( ber_printf( ber, /*{*/ "}" ) == -1 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
ber_free( ber, 1 );
return ld->ld_errno;
static LDAPMessage *msg_dup LDAP_P(( LDAPMessage *msg ));
static int request_cmp LDAP_P(( BerElement *req1, BerElement *req2 ));
static int chain_contains_dn LDAP_P(( LDAPMessage *msg, LDAP_CONST char *dn ));
-static long msg_size LDAP_P(( LDAPMessage *msg ));
+static ber_len_t msg_size LDAP_P(( LDAPMessage *msg ));
static void check_cache_memused LDAP_P(( LDAPCache *lc ));
-static void uncache_entry_or_req LDAP_P(( LDAP *ld, LDAP_CONST char *dn, int msgid ));
+static void uncache_entry_or_req LDAP_P(( LDAP *ld, LDAP_CONST char *dn, ber_int_t msgid ));
#endif
int
-ldap_enable_cache( LDAP *ld, long timeout, long maxmem )
+ldap_enable_cache( LDAP *ld, long timeout, ber_len_t maxmem )
{
#ifndef LDAP_NOCACHE
- if ( ld->ld_cache == NULLLDCACHE ) {
+ if ( ld->ld_cache == NULL ) {
if (( ld->ld_cache = (LDAPCache *)LDAP_MALLOC( sizeof( LDAPCache )))
- == NULLLDCACHE ) {
+ == NULL ) {
ld->ld_errno = LDAP_NO_MEMORY;
return( -1 );
}
ldap_disable_cache( LDAP *ld )
{
#ifndef LDAP_NOCACHE
- if ( ld->ld_cache != NULLLDCACHE ) {
+ if ( ld->ld_cache != NULL ) {
ld->ld_cache->lc_enabled = 0;
}
#endif
ldap_set_cache_options( LDAP *ld, unsigned long opts )
{
#ifndef LDAP_NOCACHE
- if ( ld->ld_cache != NULLLDCACHE ) {
+ if ( ld->ld_cache != NULL ) {
ld->ld_cache->lc_options = opts;
}
#endif
ldap_destroy_cache( LDAP *ld )
{
#ifndef LDAP_NOCACHE
- if ( ld->ld_cache != NULLLDCACHE ) {
+ if ( ld->ld_cache != NULL ) {
ldap_flush_cache( ld );
LDAP_FREE( (char *)ld->ld_cache );
- ld->ld_cache = NULLLDCACHE;
+ ld->ld_cache = NULL;
}
#endif
}
Debug( LDAP_DEBUG_TRACE, "ldap_flush_cache\n", 0, 0, 0 );
- if ( ld->ld_cache != NULLLDCACHE ) {
+ if ( ld->ld_cache != NULL ) {
/* delete all requests in the queue */
- for ( m = ld->ld_cache->lc_requests; m != NULLMSG; m = next ) {
+ for ( m = ld->ld_cache->lc_requests; m != NULL; m = next ) {
next = m->lm_next;
ldap_msgfree( m );
}
- ld->ld_cache->lc_requests = NULLMSG;
+ ld->ld_cache->lc_requests = NULL;
/* delete all messages in the cache */
for ( i = 0; i < LDAP_CACHE_BUCKETS; ++i ) {
for ( m = ld->ld_cache->lc_buckets[ i ];
- m != NULLMSG; m = next ) {
+ m != NULL; m = next ) {
next = m->lm_next;
ldap_msgfree( m );
}
- ld->ld_cache->lc_buckets[ i ] = NULLMSG;
+ ld->ld_cache->lc_buckets[ i ] = NULL;
}
ld->ld_cache->lc_memused = sizeof( LDAPCache );
}
static void
uncache_entry_or_req( LDAP *ld,
const char *dn, /* if non-NULL, uncache entry */
- int msgid ) /* request to uncache (if dn == NULL) */
+ ber_int_t msgid ) /* request to uncache (if dn == NULL) */
{
int i;
LDAPMessage *m, *prev, *next;
Debug( LDAP_DEBUG_TRACE,
- "ldap_uncache_entry_or_req dn %s msgid %d ld_cache %lx\n",
- dn, msgid, (long) ld->ld_cache );
+ "ldap_uncache_entry_or_req dn %s msgid %ld ld_cache %lx\n",
+ dn, (long) msgid, (long) ld->ld_cache );
- if ( ld->ld_cache == NULLLDCACHE ) {
+ if ( ld->ld_cache == NULL ) {
return;
}
/* first check the request queue */
- prev = NULLMSG;
- for ( m = ld->ld_cache->lc_requests; m != NULLMSG; m = next ) {
+ prev = NULL;
+ for ( m = ld->ld_cache->lc_requests; m != NULL; m = next ) {
next = m->lm_next;
if (( dn != NULL && chain_contains_dn( m, dn )) ||
( dn == NULL && m->lm_msgid == msgid )) {
- if ( prev == NULLMSG ) {
+ if ( prev == NULL ) {
ld->ld_cache->lc_requests = next;
} else {
prev->lm_next = next;
/* now check the rest of the cache */
for ( i = 0; i < LDAP_CACHE_BUCKETS; ++i ) {
- prev = NULLMSG;
- for ( m = ld->ld_cache->lc_buckets[ i ]; m != NULLMSG;
+ prev = NULL;
+ for ( m = ld->ld_cache->lc_buckets[ i ]; m != NULL;
m = next ) {
next = m->lm_next;
if (( dn != NULL && chain_contains_dn( m, dn )) ||
( dn == NULL && m->lm_msgid == msgid )) {
- if ( prev == NULLMSG ) {
+ if ( prev == NULL ) {
ld->ld_cache->lc_buckets[ i ] = next;
} else {
prev->lm_next = next;
#endif
void
-ldap_add_request_to_cache( LDAP *ld, unsigned long msgtype, BerElement *request )
+ldap_add_request_to_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request )
{
#ifndef LDAP_NOCACHE
LDAPMessage *new;
- long len;
+ ber_len_t len;
Debug( LDAP_DEBUG_TRACE, "ldap_add_request_to_cache\n", 0, 0, 0 );
ld->ld_errno = LDAP_SUCCESS;
- if ( ld->ld_cache == NULLLDCACHE ||
+ if ( ld->ld_cache == NULL ||
( ld->ld_cache->lc_enabled == 0 )) {
return;
}
if (( new = (LDAPMessage *) LDAP_CALLOC( 1, sizeof(LDAPMessage) ))
!= NULL ) {
- if (( new->lm_ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
+ if (( new->lm_ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
LDAP_FREE( (char *)new );
return;
}
Debug( LDAP_DEBUG_TRACE, "ldap_add_result_to_cache: id %d, type %d\n",
result->lm_msgid, result->lm_msgtype, 0 );
- if ( ld->ld_cache == NULLLDCACHE ||
+ if ( ld->ld_cache == NULL ||
( ld->ld_cache->lc_enabled == 0 )) {
Debug( LDAP_DEBUG_TRACE, "artc: cache disabled\n", 0, 0, 0 );
return;
* result to it. if this result completes the results for the
* request, add the request/result chain to the cache proper.
*/
- prev = NULLMSG;
+ prev = NULL;
for ( m = ld->ld_cache->lc_requests; m != NULL; m = m->lm_next ) {
if ( m->lm_msgid == result->lm_msgid ) {
break;
prev = m;
}
- if ( m != NULLMSG ) { /* found request; add to end of chain */
+ if ( m != NULL ) { /* found request; add to end of chain */
req = m;
- for ( ; m->lm_chain != NULLMSG; m = m->lm_chain )
+ for ( ; m->lm_chain != NULL; m = m->lm_chain )
;
- if (( new = msg_dup( result )) != NULLMSG ) {
- new->lm_chain = NULLMSG;
+ if (( new = msg_dup( result )) != NULL ) {
+ new->lm_chain = NULL;
m->lm_chain = new;
Debug( LDAP_DEBUG_TRACE,
"artc: result added to cache request chain\n",
keep = 1;
}
- if ( prev == NULLMSG ) {
+ if ( prev == NULL ) {
ld->ld_cache->lc_requests = req->lm_next;
} else {
prev->lm_next = req->lm_next;
* will find them.
*/
int
-ldap_check_cache( LDAP *ld, unsigned long msgtype, BerElement *request )
+ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request )
{
#ifndef LDAP_NOCACHE
LDAPMessage *m, *new, *prev, *next;
Debug( LDAP_DEBUG_TRACE, "ldap_check_cache\n", 0, 0, 0 );
- if ( ld->ld_cache == NULLLDCACHE ||
+ if ( ld->ld_cache == NULL ||
( ld->ld_cache->lc_enabled == 0 )) {
return( -1 );
}
c_time = time( NULL );
- prev = NULLMSG;
+ prev = NULL;
hash = cache_hash( &reqber );
- for ( m = ld->ld_cache->lc_buckets[ hash ]; m != NULLMSG; m = next ) {
+ for ( m = ld->ld_cache->lc_buckets[ hash ]; m != NULL; m = next ) {
Debug( LDAP_DEBUG_TRACE,"cc: examining id %d,type %d\n",
m->lm_msgid, m->lm_msgtype, 0 );
if ( difftime(c_time, m->lm_time) > ld->ld_cache->lc_timeout ) {
}
}
- if ( m == NULLMSG ) {
+ if ( m == NULL ) {
return( -1 );
}
* add duplicates of responses to incoming queue
*/
first = 1;
- for ( m = m->lm_chain; m != NULLMSG; m = m->lm_chain ) {
- if (( new = msg_dup( m )) == NULLMSG ) {
+ for ( m = m->lm_chain; m != NULL; m = m->lm_chain ) {
+ if (( new = msg_dup( m )) == NULL ) {
return( -1 );
}
new->lm_msgid = ld->ld_msgid;
- new->lm_chain = NULLMSG;
+ new->lm_chain = NULL;
if ( first ) {
new->lm_next = ld->ld_responses;
ld->ld_responses = new;
cache_hash( BerElement *ber )
{
BerElement bercpy;
- unsigned long len;
+ ber_len_t len;
/*
* just take the length of the packet and mod with # of buckets
msg_dup( LDAPMessage *msg )
{
LDAPMessage *new;
- long len;
+ ber_len_t len;
if (( new = (LDAPMessage *)LDAP_MALLOC( sizeof(LDAPMessage))) != NULL ) {
*new = *msg; /* struct copy */
- if (( new->lm_ber = ber_dup( msg->lm_ber )) == NULLBER ) {
+ if (( new->lm_ber = ber_dup( msg->lm_ber )) == NULL ) {
LDAP_FREE( (char *)new );
- return( NULLMSG );
+ return( NULL );
}
len = msg->lm_ber->ber_end - msg->lm_ber->ber_buf;
if (( new->lm_ber->ber_buf = (char *) ber_memalloc(
(size_t)len )) == NULL ) {
ber_free( new->lm_ber, 0 );
LDAP_FREE( (char *)new );
- return( NULLMSG );
+ return( NULL );
}
SAFEMEMCPY( new->lm_ber->ber_buf, msg->lm_ber->ber_buf,
(size_t)len );
static int
request_cmp( BerElement *req1, BerElement *req2 )
{
- unsigned long len;
+ ber_len_t len;
BerElement r1, r2;
r1 = *req1; /* struct copies */
* check remaining length and bytes if necessary
*/
if (( len = r1.ber_end - r1.ber_ptr ) !=
- (unsigned long) (r2.ber_end - r2.ber_ptr) )
+ (ber_len_t) (r2.ber_end - r2.ber_ptr) )
{
return( -1 ); /* different lengths */
}
{
LDAPMessage *m;
BerElement ber;
- long msgid;
+ ber_int_t msgid;
char *s;
int rc;
* first check the base or dn of the request
*/
ber = *msg->lm_ber; /* struct copy */
- if ( ber_scanf( &ber, "{i{a", &msgid, &s ) != LBER_ERROR ) {
+ if ( ber_scanf( &ber, "{i{a" /*}}*/, &msgid, &s ) != LBER_ERROR ) {
rc = ( strcasecmp( dn, s ) == 0 ) ? 1 : 0;
LDAP_FREE( s );
if ( rc != 0 ) {
* now check the dn of each search result
*/
rc = 0;
- for ( m = msg->lm_chain; m != NULLMSG && rc == 0 ; m = m->lm_chain ) {
+ for ( m = msg->lm_chain; m != NULL && rc == 0 ; m = m->lm_chain ) {
if ( m->lm_msgtype != LDAP_RES_SEARCH_ENTRY ) {
continue;
}
ber = *m->lm_ber; /* struct copy */
- if ( ber_scanf( &ber, "{a", &s ) != LBER_ERROR ) {
+ if ( ber_scanf( &ber, "{a" /*}*/, &s ) != LBER_ERROR ) {
rc = ( strcasecmp( dn, s ) == 0 ) ? 1 : 0;
LDAP_FREE( s );
}
}
-static long
+static ber_len_t
msg_size( LDAPMessage *msg )
{
LDAPMessage *m;
- long size;
+ ber_len_t size;
size = 0;
- for ( m = msg; m != NULLMSG; m = m->lm_chain ) {
+ for ( m = msg; m != NULL; m = m->lm_chain ) {
size += ( sizeof( LDAPMessage ) + m->lm_ber->ber_end -
m->lm_ber->ber_buf );
}
while ( lc->lc_memused > lc->lc_maxmem * SIZE_FACTOR ) {
c_time = time( NULL );
for ( i = 0; i < LDAP_CACHE_BUCKETS; ++i ) {
- prev = NULLMSG;
- for ( m = lc->lc_buckets[ i ]; m != NULLMSG;
+ prev = NULL;
+ for ( m = lc->lc_buckets[ i ]; m != NULL;
m = next ) {
next = m->lm_next;
if ( difftime(c_time, m->lm_time) > remove_threshold) {
- if ( prev == NULLMSG ) {
+ if ( prev == NULL ) {
lc->lc_buckets[ i ] = next;
} else {
prev->lm_next = next;
int
-ldap_translate_from_t61( LDAP *ld, char **bufp, unsigned long *lenp,
+ldap_translate_from_t61( LDAP *ld, char **bufp, ber_len_t *lenp,
int free_input )
{
if ( ld->ld_lber_decode_translate_proc == 0 ) {
int
-ldap_translate_to_t61( LDAP *ld, char **bufp, unsigned long *lenp,
+ldap_translate_to_t61( LDAP *ld, char **bufp, ber_len_t *lenp,
int free_input )
{
if ( ld->ld_lber_encode_translate_proc == 0 ) {
/* --- routine to convert from T.61 to ISO 8859-n --- */
int
-ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input )
+ldap_t61_to_8859( char **bufp, ber_len_t *buflenp, int free_input )
{
Byte *s, *oo, *o;
unsigned int n;
int c;
- unsigned long len;
+ ber_len_t len;
Debug( LDAP_DEBUG_TRACE, "ldap_t61_to_8859 input length: %ld\n",
*buflenp, 0, 0 );
/* --- routine to convert from ISO 8859-n to T.61 --- */
int
-ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input )
+ldap_8859_to_t61( char **bufp, ber_len_t *buflenp, int free_input )
{
Byte *s, *oo, *o, *aux;
int c;
- unsigned long len;
+ ber_len_t len;
const Couple *cc;
Debug( LDAP_DEBUG_TRACE, "ldap_8859_to_t61 input length: %ld\n",
Sockbuf *sb = &ld->ld_sb;
BerElement ber;
char *logdn;
- int ret, id, fromaddr, i;
+ int ret, fromaddr, i;
+ ber_int_t id;
struct timeval tv;
fromaddr = -1;
cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
LDAPMessage **res, char *base )
{
- unsigned long tag, len;
- int baselen, slen, rc;
+ ber_tag_t tag;
+ ber_len_t len;
+ int baselen, slen;
+ ber_tag_t rc;
char *dn, *p, *cookie;
LDAPMessage *chain, *prev, *ldm;
struct berval *bv;
tag = ber_next_element( ber, &len, cookie )) {
if (( ldm = (LDAPMessage *)LDAP_CALLOC( 1, sizeof(LDAPMessage)))
== NULL || ( ldm->lm_ber = ldap_alloc_ber_with_options( ld ))
- == NULLBER ) {
+ == NULL ) {
rc = LDAP_NO_MEMORY;
break; /* return w/error*/
}
break; /* return w/error */
}
- if ( ber_printf( ldm->lm_ber, "to", tag, bv->bv_val,
- bv->bv_len ) == -1 ) {
+ if ( ber_printf( ldm->lm_ber, "tO", tag, bv ) == -1 ) {
break; /* return w/error */
}
ber_bvfree( bv );
rc = LDAP_SUCCESS;
} else if ( tag == LDAP_RES_SEARCH_ENTRY ) {
- if ( ber_scanf( ber, "{aO", &dn, &bv ) == LBER_ERROR ) {
+ if ( ber_scanf( ber, "{aO" /*}*/, &dn, &bv ) == LBER_ERROR ) {
break; /* return w/error */
}
Debug( LDAP_DEBUG_TRACE, "cldap_parsemsg entry %s\n", dn, 0, 0 );
/* dispose of any leftovers */
if ( ldm != NULL ) {
- if ( ldm->lm_ber != NULLBER ) {
+ if ( ldm->lm_ber != NULL ) {
ber_free( ldm->lm_ber, 1 );
}
LDAP_FREE( ldm );
assert( msgidp != NULL );
/* create a message to send */
- if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
+ if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
return( LDAP_NO_MEMORY );
}
- if ( ber_printf( ber, "{it{s{sO}}", /* leave open '}' */
+ if ( ber_printf( ber, "{it{s{sO}}", /* '}' */
++ld->ld_msgid,
LDAP_REQ_COMPARE, dn, attr, &bvalue ) == -1 )
{
return ld->ld_errno;
}
- if( ber_printf( ber, "}" ) == -1 ) {
+ if( ber_printf( ber, /*{*/ "}" ) == -1 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
ber_free( ber, 1 );
return( ld->ld_errno );
}
/* Controls are encoded as a sequence of sequences */
- if( ber_printf( ber, "t{", LDAP_TAG_CONTROLS ) == -1 ) {
+ if( ber_printf( ber, "t{"/*}*/, LDAP_TAG_CONTROLS ) == -1 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
return ld->ld_errno;
}
for( c = ctrls ; *c != NULL; c++ ) {
- if ( ber_printf( ber, "{s",
+ if ( ber_printf( ber, "{s" /*}*/,
(*c)->ldctl_oid ) == -1 )
{
ld->ld_errno = LDAP_ENCODING_ERROR;
if( (*c)->ldctl_iscritical /* only if true */
&& ( ber_printf( ber, "b",
- (*c)->ldctl_iscritical ) == -1 ) )
+ (ber_int_t) (*c)->ldctl_iscritical ) == -1 ) )
{
ld->ld_errno = LDAP_ENCODING_ERROR;
return ld->ld_errno;
}
- if( ber_printf( ber, "}" ) == -1 ) {
+ if( ber_printf( ber, /*{*/"}" ) == -1 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
return ld->ld_errno;
}
}
- if( ber_printf( ber, "}" ) == -1 ) {
+ if( ber_printf( ber, /*{*/"}" ) == -1 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
return ld->ld_errno;
}
LDAPControl ***ctrls )
{
int nctrls;
- unsigned long tag, len;
+ ber_tag_t tag;
+ ber_len_t len;
char *opaque;
assert( ber != NULL );
tctrls[nctrls++] = tctrl;
tctrls[nctrls] = NULL;
- tag = ber_scanf( ber, "{a", &tctrl->ldctl_oid );
+ tag = ber_scanf( ber, "{a" /*}*/, &tctrl->ldctl_oid );
if( tag != LBER_ERROR ) {
tag = ber_peek_tag( ber, &len );
}
if( tag == LBER_BOOLEAN ) {
- tag = ber_scanf( ber, "b", &tctrl->ldctl_iscritical );
+ ber_int_t crit;
+ tag = ber_scanf( ber, "b", &crit );
+ tctrl->ldctl_iscritical = crit ? (char) 0 : (char) ~0;
}
if( tag != LBER_ERROR ) {
/*
* Duplicate an array of LDAPControl
*/
-LDAPControl **ldap_controls_dup( const LDAPControl **controls )
+LDAPControl **ldap_controls_dup( LDAPControl **controls )
{
LDAPControl **new;
int i;
/*
* Duplicate a LDAPControl
*/
-LDAPControl *ldap_control_dup( const LDAPControl *c )
+LDAPControl *ldap_control_dup( LDAPControl *c )
{
LDAPControl *new;
assert( msgidp != NULL );
/* create a message to send */
- if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
+ if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
ld->ld_errno = LDAP_NO_MEMORY;
return( ld->ld_errno );
}
- if ( ber_printf( ber, "{its", /* leave open - '}' */
+ if ( ber_printf( ber, "{its", /* '}' */
++ld->ld_msgid, LDAP_REQ_DELETE, dn ) == -1 )
{
ld->ld_errno = LDAP_ENCODING_ERROR;
return ld->ld_errno;
}
- /* close '{' */
- if ( ber_printf( ber, "}" ) == -1 ) {
+ if ( ber_printf( ber, /*{*/ "}" ) == -1 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
ber_free( ber, 1 );
return( ld->ld_errno );
#include "disptmpl.h"
static void free_disptmpl LDAP_P(( struct ldap_disptmpl *tmpl ));
-static int read_next_tmpl LDAP_P(( char **bufp, long *blenp,
+static int read_next_tmpl LDAP_P(( char **bufp, ber_len_t *blenp,
struct ldap_disptmpl **tmplp, int dtversion ));
static const char *const tmploptions[] = {
int
-ldap_init_templates_buf( char *buf, long buflen,
+ldap_init_templates_buf( char *buf, ber_len_t buflen,
struct ldap_disptmpl **tmpllistp )
{
int rc=-1, version;
static int
-read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
+read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp,
int dtversion )
{
int i, j, tokcnt, samerow, adsource;
#include "ldap-int.h"
-static int next_line LDAP_P(( char **bufp, long *blenp, char **linep ));
+static int next_line LDAP_P(( char **bufp, ber_len_t *blenp, char **linep ));
static char *next_token LDAP_P(( char ** sp ));
int
-next_line_tokens( char **bufp, long *blenp, char ***toksp )
+next_line_tokens( char **bufp, ber_len_t *blenp, char ***toksp )
{
char *p, *line, *token, **toks;
int rc, tokcnt;
static int
-next_line( char **bufp, long *blenp, char **linep )
+next_line( char **bufp, ber_len_t *blenp, char **linep )
{
char *linestart, *line, *p;
- long plen;
+ ber_slen_t plen;
linestart = *bufp;
p = *bufp;
{
LDAPMessage *lm;
BerElement ber;
- long along;
- unsigned long rc;
+ ber_int_t along;
+ ber_tag_t rc;
Debug( LDAP_DEBUG_TRACE, "ldap_result2error\n", 0, 0, 0 );
assert( LDAP_VALID( ld ) );
assert( r != NULL );
- if ( ld == NULL || r == NULLMSG )
+ if ( ld == NULL || r == NULL )
return( LDAP_PARAM_ERROR );
for ( lm = r; lm->lm_chain != NULL; lm = lm->lm_chain )
}
/* create a message to send */
- if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
+ if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
ld->ld_errno = LDAP_NO_MEMORY;
return( ld->ld_errno );
}
- if ( ber_printf( ber, "{it{tstO}", /* leave '}' for later */
+ if ( ber_printf( ber, "{it{tstO}", /* '}' */
++ld->ld_msgid, LDAP_REQ_EXTENDED, LDAP_TAG_EXOP_REQ_OID,
reqoid, LDAP_TAG_EXOP_REQ_VALUE, reqdata ) == -1 )
{
int freeit )
{
BerElement *ber;
- int rc;
- unsigned long tag, len;
+ ber_tag_t rc;
+ ber_tag_t tag;
+ ber_len_t len;
struct berval *resdata;
- long errcode;
+ ber_int_t errcode;
char *resoid;
assert( ld != NULL );
ld->ld_matched = NULL;
}
- rc = ber_scanf( ber, "{iaa", &errcode,
+ rc = ber_scanf( ber, "{iaa" /*}*/, &errcode,
&ld->ld_matched, &ld->ld_matched );
if( rc == LBER_ERROR ) {
}
void *
-ldap_memalloc( size_t s )
+ldap_memalloc( ber_len_t s )
{
return LDAP_MALLOC( s );
}
void *
-ldap_memcalloc( size_t n, size_t s )
+ldap_memcalloc( ber_len_t n, ber_len_t s )
{
return LDAP_CALLOC( n, s );
}
void *
-ldap_memrealloc( void* p, size_t s )
+ldap_memrealloc( void* p, ber_len_t s )
{
return LDAP_REALLOC( p, s );
}
assert( entry != NULL );
assert( ber != NULL );
- if ( (*ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
+ if ( (*ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
*ber = NULL;
return( NULL );
}
}
tmp = *entry->lm_ber; /* struct copy */
- if ( ber_scanf( &tmp, "{a", &dn ) == LBER_ERROR ) {
+ if ( ber_scanf( &tmp, "{a" /*}*/, &dn ) == LBER_ERROR ) {
ld->ld_errno = LDAP_DECODING_ERROR;
return( NULL );
}
#include "ldap-int.h"
-static char ** decode_answer LDAP_P(( unsigned char *answer, int len ));
+static char ** decode_answer LDAP_P(( unsigned char *answer, ber_len_t len ));
#define MAX_TO_SORT 32
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
- if( ld == NULL || chain == NULLMSG ) {
- return NULLMSG;
+ if( ld == NULL || chain == NULL ) {
+ return NULL;
}
return chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
- if ( ld == NULL || entry == NULLMSG ) {
- return NULLMSG;
+ if ( ld == NULL || entry == NULL ) {
+ return NULL;
}
for (
entry = entry->lm_chain;
- entry != NULLMSG;
+ entry != NULL;
entry = entry->lm_chain )
{
if( entry->lm_msgtype == LDAP_RES_SEARCH_ENTRY ) {
}
}
- return( NULLMSG );
+ return( NULL );
}
int
LDAPFiltDesc *
-ldap_init_getfilter_buf( char *buf, long buflen )
+ldap_init_getfilter_buf( char *buf, ber_len_t buflen )
{
LDAPFiltDesc *lfdp;
LDAPFiltList *flp, *nextflp;
void
ldap_build_filter(
char *filtbuf,
- unsigned long buflen,
+ ber_len_t buflen,
LDAP_CONST char *pattern,
LDAP_CONST char *prefix,
LDAP_CONST char *suffix,
ber = *entry->lm_ber;
/* skip sequence, dn, sequence of, and snag the first attr */
- if ( ber_scanf( &ber, "{x{{a", &attr ) == LBER_ERROR ) {
+ if ( ber_scanf( &ber, "{x{{a" /*}}}*/, &attr ) == LBER_ERROR ) {
ld->ld_errno = LDAP_DECODING_ERROR;
return( NULL );
}
LDAP_FREE(attr);
attr = NULL;
- if ( ber_scanf( &ber, "x}{a", &attr ) == LBER_ERROR ) {
+ if ( ber_scanf( &ber, /*{*/ "x}{a" /*}*/, &attr ) == LBER_ERROR ) {
ld->ld_errno = LDAP_DECODING_ERROR;
return( NULL );
}
ber = *entry->lm_ber;
/* skip sequence, dn, sequence of, and snag the first attr */
- if ( ber_scanf( &ber, "{x{{a", &attr ) == LBER_ERROR ) {
+ if ( ber_scanf( &ber, "{x{{a" /* }}} */, &attr ) == LBER_ERROR ) {
ld->ld_errno = LDAP_DECODING_ERROR;
return( NULL );
}
LDAP_FREE( attr );
attr = NULL;
- if ( ber_scanf( &ber, "x}{a", &attr ) == LBER_ERROR ) {
+ if ( ber_scanf( &ber, /*{*/ "x}{a" /*}*/, &attr ) == LBER_ERROR ) {
ld->ld_errno = LDAP_DECODING_ERROR;
return( NULL );
}
{
BerElement *ber;
char *cred;
- int rc, credlen;
+ int rc;
+ ber_len_t credlen;
#ifdef STR_TRANSLATION
int str_translation_on;
#endif /* STR_TRANSLATION */
}
/* create a message to send */
- if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
+ if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
LDAP_FREE( cred );
return( -1 );
}
{
BerElement *ber;
char *cred;
- int rc, credlen;
+ int rc;
+ ber_len_t credlen;
#ifdef STR_TRANSLATION
int str_translation_on;
#endif /* STR_TRANSLATION */
}
/* create a message to send */
- if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
+ if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
LDAP_FREE( cred );
return( -1 );
}
LDAP *ld,
LDAP_CONST char *who,
LDAP_CONST char *service,
- int *len )
+ ber_len_t *len )
{
KTEXT_ST ktxt;
int err;
*/
struct ldapmsg {
- int lm_msgid; /* the message id */
- int lm_msgtype; /* the message type */
+ ber_int_t lm_msgid; /* the message id */
+ ber_tag_t lm_msgtype; /* the message type */
BerElement *lm_ber; /* the ber encoded message contents */
struct ldapmsg *lm_chain; /* for search - next msg in the resp */
struct ldapmsg *lm_next; /* next response */
time_t lm_time; /* used to maintain cache */
};
-#define NULLMSG ((LDAPMessage *)NULL)
+
/*
* structure representing get/set'able options
* which have global defaults.
int ldo_debug;
- int ldo_version; /* version to connect at */
- int ldo_deref;
- int ldo_timelimit;
- int ldo_sizelimit;
+ ber_int_t ldo_version; /* version to connect at */
+ ber_int_t ldo_deref;
+ ber_int_t ldo_timelimit;
+ ber_int_t ldo_sizelimit;
int ldo_defport;
char* ldo_defbase;
* structure used to track outstanding requests
*/
typedef struct ldapreq {
- int lr_msgid; /* the message id */
+ ber_int_t lr_msgid; /* the message id */
int lr_status; /* status of request */
#define LDAP_REQST_INPROGRESS 1
#define LDAP_REQST_CHASINGREFS 2
#define LDAP_REQST_NOTCONNECTED 3
#define LDAP_REQST_WRITING 4
int lr_outrefcnt; /* count of outstanding referrals */
- int lr_origid; /* original request's message id */
+ ber_int_t lr_origid; /* original request's message id */
int lr_parentcnt; /* count of parent requests */
- int lr_res_msgtype; /* result message type */
- int lr_res_errno; /* result LDAP errno */
+ ber_tag_t lr_res_msgtype; /* result message type */
+ ber_int_t lr_res_errno; /* result LDAP errno */
char *lr_res_error; /* result error string */
char *lr_res_matched;/* result matched DN string */
BerElement *lr_ber; /* ber encoded request contents */
LDAPMessage *lc_buckets[LDAP_CACHE_BUCKETS];/* hash table */
LDAPMessage *lc_requests; /* unfulfilled reqs */
long lc_timeout; /* request timeout */
- long lc_maxmem; /* memory to use */
- long lc_memused; /* memory in use */
+ ber_len_t lc_maxmem; /* memory to use */
+ ber_len_t lc_memused; /* memory in use */
int lc_enabled; /* enabled? */
unsigned long lc_options; /* options */
#define LDAP_CACHE_OPT_CACHENOERRS 0x00000001
#define LDAP_CACHE_OPT_CACHEALLERRS 0x00000002
} LDAPCache;
-#define NULLLDCACHE ((LDAPCache *)NULL)
/*
* handy macro for checking if handle is connectionless
#define ld_sctrls ld_options.ldo_sctrls
#define ld_cctrls ld_options.ldo_cctrls
- int ld_version; /* version connected at */
+ ber_int_t ld_version; /* version connected at */
char *ld_host;
int ld_port;
LDAPFiltDesc *ld_filtd; /* from getfilter for ufn searches */
char *ld_ufnprefix; /* for incomplete ufn's */
- int ld_errno;
+ ber_int_t ld_errno;
char *ld_error;
char *ld_matched;
- int ld_msgid;
+ ber_len_t ld_msgid;
/* do not mess with these */
LDAPRequest *ld_requests; /* list of outstanding requests */
LDAPMessage *ld_responses; /* list of outstanding responses */
- int *ld_abandoned; /* array of abandoned requests */
+ ber_int_t *ld_abandoned; /* array of abandoned requests */
LDAPCache *ld_cache; /* non-null if cache is initialized */
/* stuff used by connectionless searches. */
/*
* in cache.c
*/
-void ldap_add_request_to_cache LDAP_P(( LDAP *ld, unsigned long msgtype,
+void ldap_add_request_to_cache LDAP_P(( LDAP *ld, ber_tag_t msgtype,
BerElement *request ));
void ldap_add_result_to_cache LDAP_P(( LDAP *ld, LDAPMessage *result ));
-int ldap_check_cache LDAP_P(( LDAP *ld, unsigned long msgtype, BerElement *request ));
+int ldap_check_cache LDAP_P(( LDAP *ld, ber_tag_t msgtype, BerElement *request ));
/*
* in controls.c
*/
LDAPControl *ldap_control_dup LDAP_P((
- const LDAPControl *ctrl ));
+ LDAPControl *ctrl ));
LDAPControl **ldap_controls_dup LDAP_P((
- const LDAPControl **ctrls ));
+ LDAPControl **ctrls ));
int ldap_int_get_controls LDAP_P((
BerElement *be,
/*
* in dsparse.c
*/
-int next_line_tokens LDAP_P(( char **bufp, long *blenp, char ***toksp ));
+int next_line_tokens LDAP_P(( char **bufp, ber_len_t *blenp, char ***toksp ));
void free_strarray LDAP_P(( char **sap ));
#ifdef HAVE_KERBEROS
LDAP *ld,
LDAP_CONST char *who,
LDAP_CONST char *service,
- int *len ));
+ ber_len_t *len ));
#endif /* HAVE_KERBEROS */
/*
* in request.c
*/
-int ldap_send_initial_request( LDAP *ld, unsigned long msgtype,
+ber_int_t ldap_send_initial_request( LDAP *ld, ber_tag_t msgtype,
const char *dn, BerElement *ber );
BerElement *ldap_alloc_ber_with_options( LDAP *ld );
void ldap_set_ber_options( LDAP *ld, BerElement *ber );
-int ldap_send_server_request( LDAP *ld, BerElement *ber, int msgid,
+int ldap_send_server_request( LDAP *ld, BerElement *ber, ber_int_t msgid,
LDAPRequest *parentreq, LDAPServer *srvlist, LDAPConn *lc,
int bind );
LDAPConn *ldap_new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb,
int connect, int bind );
-LDAPRequest *ldap_find_request_by_msgid( LDAP *ld, int msgid );
+LDAPRequest *ldap_find_request_by_msgid( LDAP *ld, ber_int_t msgid );
void ldap_free_request( LDAP *ld, LDAPRequest *lr );
void ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind );
void ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all );
*/
BerElement *ldap_build_search_req LDAP_P((
LDAP *ld,
- const char *base, int scope,
- const char *filter, char **attrs, int attrsonly,
+ const char *base,
+ ber_int_t scope,
+ const char *filter,
+ char **attrs,
+ ber_int_t attrsonly,
LDAPControl **sctrls,
LDAPControl **cctrls,
- int timelimit,
- int sizelimit ));
+ ber_int_t timelimit,
+ ber_int_t sizelimit ));
/*
* in string.c
*/
#if LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET
extern
-int ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input );
+int ldap_t61_to_8859( char **bufp, ber_len_t *buflenp, int free_input );
extern
-int ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input );
+int ldap_8859_to_t61( char **bufp, ber_len_t *buflenp, int free_input );
#endif /* LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET */
#endif /* STR_TRANSLATION && LDAP_DEFAULT_CHARSET */
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
- if ( ld == NULL || chain == NULLMSG ) {
- return NULLMSG;
+ if ( ld == NULL || chain == NULL ) {
+ return NULL;
}
return chain;
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
- if ( ld == NULL || msg == NULLMSG || msg->lm_chain == NULL ) {
- return NULLMSG;
+ if ( ld == NULL || msg == NULL || msg->lm_chain == NULL ) {
+ return NULL;
}
return( msg->lm_chain );
Debug( LDAP_DEBUG_TRACE, "ldap_modify_ext\n", 0, 0, 0 );
/* create a message to send */
- if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
+ if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
return( LDAP_NO_MEMORY );
}
- if ( ber_printf( ber, "{it{s{", ++ld->ld_msgid, LDAP_REQ_MODIFY, dn )
+ if ( ber_printf( ber, "{it{s{" /*}}}*/, ++ld->ld_msgid, LDAP_REQ_MODIFY, dn )
== -1 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
ber_free( ber, 1 );
for ( i = 0; mods[i] != NULL; i++ ) {
if (( mods[i]->mod_op & LDAP_MOD_BVALUES) != 0 ) {
rc = ber_printf( ber, "{e{s[V]}}",
- mods[i]->mod_op & ~LDAP_MOD_BVALUES,
+ (ber_int_t) ( mods[i]->mod_op & ~LDAP_MOD_BVALUES ),
mods[i]->mod_type, mods[i]->mod_bvalues );
} else {
- rc = ber_printf( ber, "{e{s[v]}}", mods[i]->mod_op,
+ rc = ber_printf( ber, "{e{s[v]}}",
+ (ber_int_t) mods[i]->mod_op,
mods[i]->mod_type, mods[i]->mod_values );
}
}
}
- if ( ber_printf( ber, "}}" ) == -1 ) {
+ if ( ber_printf( ber, /*{{*/ "}}" ) == -1 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
ber_free( ber, 1 );
return( ld->ld_errno );
return ld->ld_errno;
}
- if ( ber_printf( ber, "}" ) == -1 ) {
+ if ( ber_printf( ber, /*{*/ "}" ) == -1 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
ber_free( ber, 1 );
return( ld->ld_errno );
Debug( LDAP_DEBUG_TRACE, "ldap_rename\n", 0, 0, 0 );
/* create a message to send */
- if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
+ if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
return( LDAP_NO_MEMORY );
}
return( ld->ld_errno );
}
- rc = ber_printf( ber, "{it{ssbts}", /* leave '}' for later */
+ rc = ber_printf( ber, "{it{ssbts}", /* '}' */
++ld->ld_msgid, LDAP_REQ_MODDN,
- dn, newrdn, deleteoldrdn,
+ dn, newrdn, (ber_int_t) deleteoldrdn,
LDAP_TAG_NEWSUPERIOR, newSuperior );
} else {
- rc = ber_printf( ber, "{it{ssb}", /* leave '}' for later */
+ rc = ber_printf( ber, "{it{ssb}", /* '}' */
++ld->ld_msgid, LDAP_REQ_MODDN,
- dn, newrdn, deleteoldrdn );
+ dn, newrdn, (ber_int_t) deleteoldrdn );
}
if ( rc < 0 ) {
return ld->ld_errno;
}
- /* close the '{' */
- rc = ber_printf( ber, "}" );
+ rc = ber_printf( ber, /*{*/ "}" );
if ( rc < 0 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
ber_free( ber, 1 );
break;
}
- * (int *) outvalue = ber_pvt_sb_get_desc( &(ld->ld_sb) );
+ * (ber_socket_t *) outvalue = ber_pvt_sb_get_desc( &(ld->ld_sb) );
return LDAP_OPT_SUCCESS;
case LDAP_OPT_DEREF:
* XXX async is not used yet!
*/
{
- int rc, i, s = 0;
+ int rc, i;
+ ber_socket_t s = AC_SOCKET_INVALID;
int connected, use_hp;
struct sockaddr_in sin;
struct hostent *hp = NULL;
assert( ld != NULL );
assert( chain != NULL );
- if ( ld == NULL || chain == NULLMSG ) {
- return NULLMSG;
+ if ( ld == NULL || chain == NULL ) {
+ return NULL;
}
return chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE
assert( ld != NULL );
assert( ref != NULL );
- if ( ld == NULL || ref == NULLMSG ) {
- return NULLMSG;
+ if ( ld == NULL || ref == NULL ) {
+ return NULL;
}
for (
ref = ref->lm_chain;
- ref != NULLMSG;
+ ref != NULL;
ref = ref->lm_chain )
{
if( ref->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) {
}
}
- return( NULLMSG );
+ return( NULL );
}
int
static LDAPServer *dn2servers LDAP_P(( LDAP *ld, char *dn ));
#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */
-static BerElement *re_encode_request LDAP_P(( LDAP *ld, BerElement *origber,
- int msgid, char **dnp ));
+static BerElement *re_encode_request LDAP_P((
+ LDAP *ld,
+ BerElement *origber,
+ ber_int_t msgid,
+ char **dnp ));
BerElement *
{
BerElement *ber;
- if (( ber = ber_alloc_t( ld->ld_lberoptions )) == NULLBER ) {
+ if (( ber = ber_alloc_t( ld->ld_lberoptions )) == NULL ) {
ld->ld_errno = LDAP_NO_MEMORY;
#ifdef STR_TRANSLATION
} else {
}
-int
+ber_int_t
ldap_send_initial_request(
LDAP *ld,
- unsigned long msgtype,
+ ber_tag_t msgtype,
const char *dn,
BerElement *ber )
{
int
-ldap_send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest
- *parentreq, LDAPServer *srvlist, LDAPConn *lc, int bind )
+ldap_send_server_request(
+ LDAP *ld,
+ BerElement *ber,
+ ber_int_t msgid,
+ LDAPRequest *parentreq,
+ LDAPServer *srvlist,
+ LDAPConn *lc,
+ int bind )
{
LDAPRequest *lr;
int incparent;
}
fprintf( stderr, "** Response Queue:\n" );
- if (( lm = ld->ld_responses ) == NULLMSG ) {
+ if (( lm = ld->ld_responses ) == NULL ) {
fprintf( stderr, " Empty\n" );
}
- for ( ; lm != NULLMSG; lm = lm->lm_next ) {
+ for ( ; lm != NULL; lm = lm->lm_next ) {
fprintf( stderr, " * msgid %d, type %d\n",
lm->lm_msgid, lm->lm_msgtype );
if (( l = lm->lm_chain ) != NULL ) {
fprintf( stderr, " chained responses:\n" );
- for ( ; l != NULLMSG; l = l->lm_chain ) {
+ for ( ; l != NULL; l = l->lm_chain ) {
fprintf( stderr,
" * msgid %d, type %d\n",
l->lm_msgid, l->lm_msgtype );
static BerElement *
-re_encode_request( LDAP *ld, BerElement *origber, int msgid, char **dnp )
+re_encode_request( LDAP *ld, BerElement *origber, ber_int_t msgid, char **dnp )
{
/*
* XXX this routine knows way too much about how the lber library works!
*/
- unsigned long along, tag;
- long ver;
+ ber_int_t along;
+ ber_len_t len;
+ ber_tag_t tag;
+ ber_int_t ver;
int rc;
BerElement tmpber, *ber;
char *orig_dn;
Debug( LDAP_DEBUG_TRACE,
- "re_encode_request: new msgid %d, new dn <%s>\n",
- msgid, ( *dnp == NULL ) ? "NONE" : *dnp, 0 );
+ "re_encode_request: new msgid %ld, new dn <%s>\n",
+ (long) msgid, ( *dnp == NULL ) ? "NONE" : *dnp, 0 );
tmpber = *origber;
* followed by a sequence that is tagged with the operation code
*/
if ( ber_scanf( &tmpber, "{i", /*}*/ &along ) != LDAP_TAG_MSGID ||
- ( tag = ber_skip_tag( &tmpber, &along )) == LBER_DEFAULT ) {
+ ( tag = ber_skip_tag( &tmpber, &len )) == LBER_DEFAULT ) {
ld->ld_errno = LDAP_DECODING_ERROR;
return( NULL );
}
- if (( ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
+ if (( ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
return( NULL );
}
/* bind requests have a version number before the DN & other stuff */
- if ( tag == LDAP_REQ_BIND && ber_get_int( &tmpber, (long *)&ver ) ==
+ if ( tag == LDAP_REQ_BIND && ber_get_int( &tmpber, &ver ) ==
LBER_DEFAULT ) {
ld->ld_errno = LDAP_DECODING_ERROR;
ber_free( ber, 1 );
LDAPRequest *
-ldap_find_request_by_msgid( LDAP *ld, int msgid )
+ldap_find_request_by_msgid( LDAP *ld, ber_int_t msgid )
{
LDAPRequest *lr;
#include "ldap-int.h"
-static int ldap_abandoned LDAP_P(( LDAP *ld, int msgid ));
-static int ldap_mark_abandoned LDAP_P(( LDAP *ld, int msgid ));
-static int wait4msg LDAP_P(( LDAP *ld, int msgid, int all, struct timeval *timeout,
+static int ldap_abandoned LDAP_P(( LDAP *ld, ber_int_t msgid ));
+static int ldap_mark_abandoned LDAP_P(( LDAP *ld, ber_int_t msgid ));
+static int wait4msg LDAP_P(( LDAP *ld, ber_int_t msgid, int all, struct timeval *timeout,
LDAPMessage **result ));
-static int try_read1msg LDAP_P(( LDAP *ld, int msgid, int all, Sockbuf *sb, LDAPConn *lc,
- LDAPMessage **result ));
-static unsigned long build_result_ber LDAP_P(( LDAP *ld, BerElement **bp, LDAPRequest *lr ));
+static ber_tag_t try_read1msg LDAP_P(( LDAP *ld, ber_int_t msgid,
+ int all, Sockbuf *sb, LDAPConn *lc, LDAPMessage **result ));
+static ber_tag_t build_result_ber LDAP_P(( LDAP *ld, BerElement **bp, LDAPRequest *lr ));
static void merge_error_info LDAP_P(( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ));
* wait until it arrives or timeout occurs.
*/
- *result = NULLMSG;
- lastlm = NULLMSG;
- for ( lm = ld->ld_responses; lm != NULLMSG; lm = nextlm ) {
+ *result = NULL;
+ lastlm = NULL;
+ for ( lm = ld->ld_responses; lm != NULL; lm = nextlm ) {
nextlm = lm->lm_next;
if ( ldap_abandoned( ld, lm->lm_msgid ) ) {
ldap_mark_abandoned( ld, lm->lm_msgid );
- if ( lastlm == NULLMSG ) {
+ if ( lastlm == NULL ) {
ld->ld_responses = lm->lm_next;
} else {
lastlm->lm_next = nextlm;
&& lm->lm_msgtype != LDAP_RES_SEARCH_ENTRY) )
break;
- for ( tmp = lm; tmp != NULLMSG; tmp = tmp->lm_chain ) {
+ for ( tmp = lm; tmp != NULL; tmp = tmp->lm_chain ) {
if ( tmp->lm_msgtype == LDAP_RES_SEARCH_RESULT )
break;
}
- if ( tmp == NULLMSG ) {
+ if ( tmp == NULL ) {
return( wait4msg( ld, msgid, all, timeout,
result ) );
}
}
lastlm = lm;
}
- if ( lm == NULLMSG ) {
+ if ( lm == NULL ) {
return( wait4msg( ld, msgid, all, timeout, result ) );
}
- if ( lastlm == NULLMSG ) {
- ld->ld_responses = (all == 0 && lm->lm_chain != NULLMSG
+ if ( lastlm == NULL ) {
+ ld->ld_responses = (all == 0 && lm->lm_chain != NULL
? lm->lm_chain : lm->lm_next);
} else {
- lastlm->lm_next = (all == 0 && lm->lm_chain != NULLMSG
+ lastlm->lm_next = (all == 0 && lm->lm_chain != NULL
? lm->lm_chain : lm->lm_next);
}
if ( all == 0 )
- lm->lm_chain = NULLMSG;
- lm->lm_next = NULLMSG;
+ lm->lm_chain = NULL;
+ lm->lm_next = NULL;
*result = lm;
ld->ld_errno = LDAP_SUCCESS;
}
static int
-wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
+wait4msg(
+ LDAP *ld,
+ ber_int_t msgid,
+ int all,
+ struct timeval *timeout,
LDAPMessage **result )
{
int rc;
}
-static int
-try_read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb,
- LDAPConn *lc, LDAPMessage **result )
+static ber_tag_t
+try_read1msg(
+ LDAP *ld,
+ ber_int_t msgid,
+ int all,
+ Sockbuf *sb,
+ LDAPConn *lc,
+ LDAPMessage **result )
{
BerElement *ber;
LDAPMessage *new, *l, *prev, *tmp;
- long id;
- unsigned long tag, len;
+ ber_int_t id;
+ ber_tag_t tag;
+ ber_len_t len;
int foundit = 0;
LDAPRequest *lr;
BerElement tmpber;
int rc, refer_cnt, hadref, simple_request;
- unsigned long lderr;
+ ber_int_t lderr;
assert( ld != NULL );
assert( lc != NULL );
Debug( LDAP_DEBUG_TRACE, "read1msg\n", 0, 0, 0 );
- if ( lc->lconn_ber == NULLBER ) {
+ if ( lc->lconn_ber == NULL ) {
lc->lconn_ber = ldap_alloc_ber_with_options(ld);
if( lc->lconn_ber == NULL ) {
* We read a complete message.
* The connection should no longer need this ber.
*/
- lc->lconn_ber = NULLBER;
+ lc->lconn_ber = NULL;
/* message id */
if ( ber_get_int( ber, &id ) == LBER_ERROR ) {
}
/* if it's been abandoned, toss it */
- if ( ldap_abandoned( ld, (int)id ) ) {
+ if ( ldap_abandoned( ld, id ) ) {
ber_free( ber, 1 );
return( -2 ); /* continue looking */
}
* search response.
*/
- prev = NULLMSG;
- for ( l = ld->ld_responses; l != NULLMSG; l = l->lm_next ) {
+ prev = NULL;
+ for ( l = ld->ld_responses; l != NULL; l = l->lm_next ) {
if ( l->lm_msgid == new->lm_msgid )
break;
prev = l;
}
/* not part of an existing search response */
- if ( l == NULLMSG ) {
+ if ( l == NULL ) {
if ( foundit ) {
*result = new;
ld->ld_errno = LDAP_SUCCESS;
new->lm_msgid, new->lm_msgtype, 0 );
/* part of a search response - add to end of list of entries */
- for ( tmp = l; tmp->lm_chain != NULLMSG &&
+ for ( tmp = l; tmp->lm_chain != NULL &&
tmp->lm_chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY;
tmp = tmp->lm_chain )
; /* NULL */
/* return the whole chain if that's what we were looking for */
if ( foundit ) {
- if ( prev == NULLMSG )
+ if ( prev == NULL )
ld->ld_responses = l->lm_next;
else
prev->lm_next = l->lm_next;
}
-static unsigned long
+static ber_tag_t
build_result_ber( LDAP *ld, BerElement **bp, LDAPRequest *lr )
{
- unsigned long len, tag;
- long along;
+ ber_len_t len;
+ ber_int_t tag;
+ ber_int_t along;
BerElement *ber;
*bp = NULL;
}
if ( ber_printf( ber, "{it{ess}}", lr->lr_msgid,
- (unsigned long) lr->lr_res_msgtype, lr->lr_res_errno,
+ lr->lr_res_msgtype, lr->lr_res_errno,
lr->lr_res_matched ? lr->lr_res_matched : "",
lr->lr_res_error ? lr->lr_res_error : "" ) == -1 ) {
Debug( LDAP_DEBUG_TRACE, "ldap_msgfree\n", 0, 0, 0 );
- for ( ; lm != NULLMSG; lm = next ) {
+ for ( ; lm != NULL; lm = next ) {
next = lm->lm_chain;
type = lm->lm_msgtype;
ber_free( lm->lm_ber, 1 );
Debug( LDAP_DEBUG_TRACE, "ldap_msgdelete\n", 0, 0, 0 );
- prev = NULLMSG;
- for ( lm = ld->ld_responses; lm != NULLMSG; lm = lm->lm_next ) {
+ prev = NULL;
+ for ( lm = ld->ld_responses; lm != NULL; lm = lm->lm_next ) {
if ( lm->lm_msgid == msgid )
break;
prev = lm;
}
- if ( lm == NULLMSG )
+ if ( lm == NULL )
return( -1 );
- if ( prev == NULLMSG )
+ if ( prev == NULL )
ld->ld_responses = lm->lm_next;
else
prev->lm_next = lm->lm_next;
* return 1 if message msgid is waiting to be abandoned, 0 otherwise
*/
static int
-ldap_abandoned( LDAP *ld, int msgid )
+ldap_abandoned( LDAP *ld, ber_int_t msgid )
{
int i;
static int
-ldap_mark_abandoned( LDAP *ld, int msgid )
+ldap_mark_abandoned( LDAP *ld, ber_int_t msgid )
{
int i;
int
cldap_getmsg( LDAP *ld, struct timeval *timeout, BerElement *ber )
{
- int rc;
- unsigned long tag, len;
+ int rc;
+ ber_tag_t tag;
+ ber_len_t len;
if ( ! ber_pvt_sb_data_ready(&ld->ld_sb) ) {
rc = ldap_select1( ld, timeout );
return( -1 );
}
- return( tag );
+ return( 0 );
}
#endif /* LDAP_CONNECTIONLESS */
passwd = "";
/* create a message to send */
- if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
+ if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
return( -1 );
}
typedef struct safe_string {
char * val;
- int size;
- int pos;
+ ber_len_t size;
+ ber_len_t pos;
int at_whsp;
} safe_string;
static char *put_complex_filter LDAP_P((
BerElement *ber,
char *str,
- unsigned long tag,
+ ber_tag_t tag,
int not ));
static int put_filter LDAP_P((
ber = ldap_build_search_req( ld, base, scope, filter, attrs,
attrsonly, sctrls, cctrls, timelimit, sizelimit );
- if ( ber == NULLBER ) {
+ if ( ber == NULL ) {
return ld->ld_errno;
}
ber = ldap_build_search_req( ld, base, scope, filter, attrs,
attrsonly, NULL, NULL, -1, -1 );
- if ( ber == NULLBER ) {
+ if ( ber == NULL ) {
return( -1 );
}
ldap_build_search_req(
LDAP *ld,
LDAP_CONST char *base_in,
- int scope,
+ ber_int_t scope,
LDAP_CONST char *filter_in,
char **attrs,
- int attrsonly,
+ ber_int_t attrsonly,
LDAPControl **sctrls,
LDAPControl **cctrls,
- int timelimit,
- int sizelimit )
+ ber_int_t timelimit,
+ ber_int_t sizelimit )
{
BerElement *ber;
int err;
*/
/* create a message to send */
- if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
- return( NULLBER );
+ if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
+ return( NULL );
}
if ( base_in == NULL ) {
} else {
#endif /* LDAP_CONNECTIONLESS */
err = ber_printf( ber, "{it{seeiib", ++ld->ld_msgid,
- LDAP_REQ_SEARCH, base, scope, ld->ld_deref,
+ LDAP_REQ_SEARCH, base, (ber_int_t) scope, ld->ld_deref,
(sizelimit < 0) ? ld->ld_sizelimit : sizelimit,
(timelimit < 0) ? ld->ld_timelimit : timelimit,
attrsonly );
if ( err == -1 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
ber_free( ber, 1 );
- return( NULLBER );
+ return( NULL );
}
filter = LDAP_STRDUP( filter_in );
if ( err == -1 ) {
ld->ld_errno = LDAP_FILTER_ERROR;
ber_free( ber, 1 );
- return( NULLBER );
+ return( NULL );
}
- if ( ber_printf( ber, "{v}}", attrs ) == -1 ) {
+ if ( ber_printf( ber, /*{*/ "{v}}", attrs ) == -1 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
ber_free( ber, 1 );
- return( NULLBER );
+ return( NULL );
}
/* Put Server Controls */
if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) {
ber_free( ber, 1 );
- return( NULLBER );
+ return( NULL );
}
- if ( ber_printf( ber, "}", attrs ) == -1 ) {
+ if ( ber_printf( ber, /*{*/ "}", attrs ) == -1 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
ber_free( ber, 1 );
- return( NULLBER );
+ return( NULL );
}
return( ber );
}
static char *
-put_complex_filter( BerElement *ber, char *str, unsigned long tag, int not )
+put_complex_filter( BerElement *ber, char *str, ber_tag_t tag, int not )
{
char *next;
*/
/* put explicit tag */
- if ( ber_printf( ber, "t{", tag ) == -1 )
+ if ( ber_printf( ber, "t{" /*}*/, tag ) == -1 )
return( NULL );
str++;
*next++ = ')';
/* flush explicit tagged thang */
- if ( ber_printf( ber, "}" ) == -1 )
+ if ( ber_printf( ber, /*{*/ "}" ) == -1 )
return( NULL );
return( next );
case ')':
Debug( LDAP_DEBUG_TRACE, "put_filter: end\n", 0, 0,
0 );
- if ( ber_printf( ber, "]" ) == -1 )
+ if ( ber_printf( ber, /*[*/ "]" ) == -1 )
return( -1 );
str++;
parens--;
{
char *s;
char *value, savechar;
- unsigned long ftype;
+ ber_tag_t ftype;
int rc;
Debug( LDAP_DEBUG_TRACE, "put_simple_filter \"%s\"\n", str, 0, 0 );
put_substring_filter( BerElement *ber, char *type, char *val )
{
char *nextstar, gotstar = 0;
- unsigned long ftype;
+ ber_tag_t ftype = LDAP_FILTER_SUBSTRINGS;
Debug( LDAP_DEBUG_TRACE, "put_substring_filter \"%s=%s\"\n", type,
val, 0 );
- if ( ber_printf( ber, "t{s{", LDAP_FILTER_SUBSTRINGS, type ) == -1 )
+ if ( ber_printf( ber, "t{s{", ftype, type ) == -1 )
return( -1 );
while ( val != NULL ) {
val = nextstar;
}
- if ( ber_printf( ber, "}}" ) == -1 )
+ if ( ber_printf( ber, /* {{ */ "}}" ) == -1 )
return( -1 );
return( 0 );
int
-ldap_init_searchprefs_buf( char *buf, long buflen,
+ldap_init_searchprefs_buf(
+ char *buf,
+ ber_len_t buflen,
struct ldap_searchobj **solistp )
{
int rc = -1, version;
file_read( char *path, struct berval *bv )
{
FILE *fp;
- long rlen;
+ ber_slen_t rlen;
int eof;
if (( fp = fopen( path, "r" )) == NULL ) {
eof = feof( fp );
fclose( fp );
- if ( (unsigned long) rlen != bv->bv_len ) {
+ if ( (ber_len_t) rlen != bv->bv_len ) {
perror( path );
free( bv->bv_val );
return( -1 );
printf( "\nresult: msgtype %d msgid %d\n",
msgtype, res->lm_msgid );
handle_result( ld, res );
- res = NULLMSG;
+ res = NULL;
break;
case 'm': /* remove */
printf( "\nresult: msgid %d\n",
res->lm_msgid );
handle_result( ld, res );
- res = NULLMSG;
+ res = NULL;
}
#endif /* LDAP_CONNECTIONLESS */
} else {
else {
printf( "\nresult: err %d\n", id );
handle_result( ld, res );
- res = NULLMSG;
+ res = NULL;
}
free_list( types );
break;
{
LDAPMessage *e;
- for ( e = ldap_first_entry( ld, res ); e != NULLMSG;
+ for ( e = ldap_first_entry( ld, res ); e != NULL;
e = ldap_next_entry( ld, e ) )
{
BerElement *ber = NULL;
int j, nonascii;
nonascii = 0;
- for ( j = 0; (unsigned long) j < vals[i]->bv_len; j++ )
+ for ( j = 0; (ber_len_t) j < vals[i]->bv_len; j++ )
if ( !isascii( vals[i]->bv_val[j] ) ) {
nonascii = 1;
break;
}
if ( res->lm_msgtype == LDAP_RES_SEARCH_RESULT
- || res->lm_chain != NULLMSG )
+ || res->lm_chain != NULL )
print_ldap_result( ld, res, "search" );
}
struct ldap_disptmpl *tmpl;
struct timeval timeout;
- if ( dn == NULL && entry == NULLMSG ) {
+ if ( dn == NULL && entry == NULL ) {
ld->ld_errno = LDAP_PARAM_ERROR;
return( ld->ld_errno );
}
if ( tmpllist != NULL ) {
- ldmp = NULLMSG;
+ ldmp = NULL;
if ( entry == NULL ) {
char *ocattrs[2];
Debug( LDAP_DEBUG_TRACE, "ldap_send_unbind\n", 0, 0, 0 );
/* create a message to send */
- if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
+ if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
return( ld->ld_errno );
}
/* fill it in */
- if ( ber_printf( ber, "{itn", ++ld->ld_msgid,
+ if ( ber_printf( ber, "{itn" /*}*/, ++ld->ld_msgid,
LDAP_REQ_UNBIND ) == -1 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
ber_free( ber, 1 );
return ld->ld_errno;
}
- if ( ber_printf( ber, "}", ++ld->ld_msgid,
- LDAP_REQ_UNBIND ) == -1 ) {
+ if ( ber_printf( ber, /*{*/ "}", LDAP_REQ_UNBIND ) == -1 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
ber_free( ber, 1 );
return( ld->ld_errno );
ludp->lud_filter, ludp->lud_attrs, attrsonly, NULL, NULL,
-1, -1 );
- if ( ber == NULLBER ) {
+ if ( ber == NULL ) {
return( -1 );
}
Operation *op
)
{
- int id;
+ ber_int_t id;
Operation *o;
Operation **oo;
{
BerElement *ber = op->o_ber;
char *dn, *last;
- unsigned long len, tag;
+ ber_len_t len;
+ ber_tag_t tag;
Entry *e;
Backend *be;
*/
/* get the name */
- if ( ber_scanf( ber, "{a", &dn ) == LBER_ERROR ) {
+ if ( ber_scanf( ber, "{a", /*}*/ &dn ) == LBER_ERROR ) {
Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
"decoding error" );
extern int ldbm_ignore_nextid_file;
-#include "proto-back-ldbm.h"
-
LDAP_END_DECL
+#include "proto-back-ldbm.h"
+
#endif /* _back_ldbm_h_ */
extern int ldbm_back_modrdn LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
- char *dn, char*newrdn, int deleteoldrdn,
+ char *dn, char* newrdn, int deleteoldrdn,
char *newSuperior ));
extern int ldbm_back_add LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op, char *dn ));
extern int ldbm_back_abandon LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op, int msgid ));
+ Connection *conn, Operation *op, ber_int_t msgid ));
extern int ldbm_back_group LDAP_P(( BackendDB *bd,
Entry *target, char* gr_ndn, char* op_ndn,
char cwd[MAXPATHLEN];
(void) getcwd( cwd, MAXPATHLEN );
- sprintf( cwd, "%s%s%s", cwd, LDAP_DIRSEP, li->li_directory );
+ sprintf( cwd, "%s" LDAP_DIRSEP "%s", cwd, li->li_directory );
free( li->li_directory );
li->li_directory = strdup( cwd );
)
{
BerElement *ber = op->o_ber;
- int version;
- unsigned long method;
+ ber_int_t version;
+ ber_tag_t method;
char *cdn, *ndn;
- unsigned long rc;
+ ber_tag_t rc;
struct berval cred;
Backend *be;
{
BerElement *tber;
- unsigned long tlen, ttag;
+ ber_len_t tlen;
+ ber_tag_t ttag;
tber = ber_dup( op->o_ber );
ttag = ber_skip_tag( tber, &tlen );
void *
ch_malloc(
- unsigned long size
+ ber_len_t size
)
{
void *new;
- if ( (new = (void *) malloc( size )) == NULL ) {
- Debug( LDAP_DEBUG_ANY, "malloc of %lu bytes failed\n", size, 0, 0 );
+ if ( (new = (void *) ber_memalloc( size )) == NULL ) {
+ Debug( LDAP_DEBUG_ANY, "ch_malloc of %lu bytes failed\n",
+ (long) size, 0, 0 );
exit( 1 );
}
void *
ch_realloc(
void *block,
- unsigned long size
+ ber_len_t size
)
{
void *new;
return( ch_malloc( size ) );
}
- if ( (new = (void *) realloc( block, size )) == NULL ) {
- Debug( LDAP_DEBUG_ANY, "realloc of %lu bytes failed\n", size, 0, 0 );
+ if( size == 0 ) {
+ ch_free( block );
+ }
+
+ if ( (new = (void *) ber_memrealloc( block, size )) == NULL ) {
+ Debug( LDAP_DEBUG_ANY, "ch_realloc of %lu bytes failed\n",
+ (long) size, 0, 0 );
exit( 1 );
}
void *
ch_calloc(
- unsigned long nelem,
- unsigned long size
+ ber_len_t nelem,
+ ber_len_t size
)
{
void *new;
- if ( (new = (void *) calloc( nelem, size )) == NULL ) {
- Debug( LDAP_DEBUG_ANY, "calloc of %lu elems of %lu bytes failed\n",
- nelem, size, 0 );
+ if ( (new = (void *) ber_memcalloc( nelem, size )) == NULL ) {
+ Debug( LDAP_DEBUG_ANY, "ch_calloc of %lu elems of %lu bytes failed\n",
+ (long) nelem, (long) size, 0 );
exit( 1 );
}
{
char *new;
- if ( (new = strdup( string )) == NULL ) {
- Debug( LDAP_DEBUG_ANY, "strdup(%s) failed\n", string, 0, 0 );
+ if ( (new = ber_strdup( string )) == NULL ) {
+ Debug( LDAP_DEBUG_ANY, "ch_strdup(%s) failed\n", string, 0, 0 );
exit( 1 );
}
return( new );
}
+void
+ch_free( void *ptr )
+{
+ ber_memfree( ptr );
+}
\ No newline at end of file
/* protected by connections_mutex */
static ldap_pvt_thread_mutex_t connections_mutex;
static Connection *connections = NULL;
-static long conn_nextid = 0;
+static unsigned long conn_nextid = 0;
/* structure state (protected by connections_mutex) */
#define SLAP_C_UNINITIALIZED 0x00 /* MUST BE ZERO (0) */
#define SLAP_C_BINDING 0x03 /* binding */
#define SLAP_C_CLOSING 0x04 /* closing */
-static Connection* connection_get( int s );
+static Connection* connection_get( ber_socket_t s );
static int connection_input( Connection *c );
static void connection_close( Connection *c );
*/
int connections_destroy(void)
{
- int i;
+ ber_socket_t i;
/* should check return of every call */
*/
int connections_shutdown(void)
{
- int i;
+ ber_socket_t i;
ldap_pvt_thread_mutex_lock( &connections_mutex );
return 0;
}
-static Connection* connection_get( int s )
+static Connection* connection_get( ber_socket_t s )
{
/* connections_mutex should be locked by caller */
Connection *c;
Debug( LDAP_DEBUG_ARGS,
- "connection_get(%d)\n",
- s, 0, 0 );
+ "connection_get(%ld)\n",
+ (long) s, 0, 0 );
assert( connections != NULL );
- if(s < 0) {
+ if(s == AC_SOCKET_INVALID) {
return NULL;
}
#else
c = NULL;
{
- int i;
+ ber_socket_t i;
for(i=0; i<dtblsize; i++) {
if( connections[i].c_struct_state == SLAP_C_UNINITIALIZED ) {
}
long connection_init(
- int s,
+ ber_socket_t s,
const char* name,
const char* addr)
{
- long id;
+ unsigned long id;
Connection *c;
assert( connections != NULL );
- if( s < 0 ) {
+ if( s == AC_SOCKET_INVALID ) {
Debug( LDAP_DEBUG_ANY,
- "connection_init(%d): invalid.\n",
- s, 0, 0 );
+ "connection_init(%ld): invalid.\n",
+ (long) s, 0, 0 );
return -1;
}
#else
{
- int i;
+ unsigned int i;
c = NULL;
connection_destroy( c );
}
-long connections_nextid(void)
+unsigned long connections_nextid(void)
{
- long id;
+ unsigned long id;
assert( connections != NULL );
ldap_pvt_thread_mutex_lock( &connections_mutex );
return id;
}
-Connection* connection_first( int *index )
+Connection* connection_first( ber_socket_t *index )
{
assert( connections != NULL );
assert( index != NULL );
return connection_next(NULL, index);
}
-Connection* connection_next( Connection *c, int *index )
+Connection* connection_next( Connection *c, ber_socket_t *index )
{
assert( connections != NULL );
assert( index != NULL );
connection_operation( void *arg_v )
{
struct co_arg *arg = arg_v;
- int tag = arg->co_op->o_tag;
+ ber_tag_t tag = arg->co_op->o_tag;
Connection *conn = arg->co_conn;
#ifdef LDAP_COUNTERS
return NULL;
}
-int connection_read(int s)
+int connection_read(ber_socket_t s)
{
int rc = 0;
Connection *c;
if( c == NULL ) {
Debug( LDAP_DEBUG_ANY,
- "connection_read(%d): no connection!\n",
- s, 0, 0 );
+ "connection_read(%ld): no connection!\n",
+ (long) s, 0, 0 );
slapd_remove(s, 0);
)
{
Operation *op;
- unsigned long tag, len;
- long msgid;
+ ber_tag_t tag;
+ ber_len_t len;
+ ber_int_t msgid;
BerElement *ber;
if ( conn->c_currentber == NULL && (conn->c_currentber = ber_alloc())
struct co_arg *arg;
char *tmpdn;
int status;
- unsigned long tag = op->o_tag;
+ ber_tag_t tag = op->o_tag;
if ( conn->c_dn != NULL ) {
tmpdn = ch_strdup( conn->c_dn );
return status;
}
-int connection_write(int s)
+int connection_write(ber_socket_t s)
{
Connection *c;
assert( connections != NULL );
if( c == NULL ) {
Debug( LDAP_DEBUG_ANY,
- "connection_write(%d): no connection!\n",
- s, 0, 0 );
+ "connection_write(%ld): no connection!\n",
+ (long) s, 0, 0 );
slapd_remove(s, 0);
ldap_pvt_thread_mutex_unlock( &connections_mutex );
return -1;
#endif /* TCP Wrappers */
/* globals */
-int dtblsize;
-static int tcps;
+ber_socket_t dtblsize;
+static ber_socket_t tcps;
#ifdef HAVE_WINSOCK2
/* in nt_main.c */
extern ldap_pvt_thread_cond_t started_event;
+
/* forward reference */
void hit_socket();
/* In wsa_err.c */
/*
* Add a descriptor to daemon control
*/
-static void slapd_add(int s) {
+static void slapd_add(ber_socket_t s) {
ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
assert( !FD_ISSET( s, &slap_daemon.sd_actives ));
}
#endif
- FD_SET( (unsigned) s, &slap_daemon.sd_actives );
- FD_SET( (unsigned) s, &slap_daemon.sd_readers );
+ FD_SET( s, &slap_daemon.sd_actives );
+ FD_SET( s, &slap_daemon.sd_readers );
- Debug( LDAP_DEBUG_CONNS, "daemon: added %d%s%s\n", s,
+ Debug( LDAP_DEBUG_CONNS, "daemon: added %ld%s%s\n",
+ (long) s,
FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "",
FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" );
/*
* Remove the descriptor from daemon control
*/
-void slapd_remove(int s, int wake) {
+void slapd_remove(ber_socket_t s, int wake) {
ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
WAKE_LISTENER(wake);
- Debug( LDAP_DEBUG_CONNS, "daemon: removing %d%s%s\n", s,
+ Debug( LDAP_DEBUG_CONNS, "daemon: removing %ld%s%s\n",
+ (long) s,
FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "",
FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" );
- FD_CLR( (unsigned) s, &slap_daemon.sd_actives );
- FD_CLR( (unsigned) s, &slap_daemon.sd_readers );
- FD_CLR( (unsigned) s, &slap_daemon.sd_writers );
+ FD_CLR( s, &slap_daemon.sd_actives );
+ FD_CLR( s, &slap_daemon.sd_readers );
+ FD_CLR( s, &slap_daemon.sd_writers );
ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
}
-void slapd_clr_write(int s, int wake) {
+void slapd_clr_write(ber_socket_t s, int wake) {
ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
WAKE_LISTENER(wake);
- assert( FD_ISSET( (unsigned) s, &slap_daemon.sd_actives) );
- FD_CLR( (unsigned) s, &slap_daemon.sd_writers );
+ assert( FD_ISSET( s, &slap_daemon.sd_actives) );
+ FD_CLR( s, &slap_daemon.sd_writers );
ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
}
}
-void slapd_set_write(int s, int wake) {
+void slapd_set_write(ber_socket_t s, int wake) {
ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
WAKE_LISTENER(wake);
}
}
-void slapd_clr_read(int s, int wake) {
+void slapd_clr_read(ber_socket_t s, int wake) {
ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
WAKE_LISTENER(wake);
assert( FD_ISSET( s, &slap_daemon.sd_actives) );
- FD_CLR( (unsigned) s, &slap_daemon.sd_readers );
+ FD_CLR( s, &slap_daemon.sd_readers );
ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
}
}
-void slapd_set_read(int s, int wake) {
+void slapd_set_read(ber_socket_t s, int wake) {
ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
WAKE_LISTENER(wake);
assert( FD_ISSET( s, &slap_daemon.sd_actives) );
- FD_SET( (unsigned) s, &slap_daemon.sd_readers );
+ FD_SET( s, &slap_daemon.sd_readers );
ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
}
}
-static void slapd_close(int s) {
- Debug( LDAP_DEBUG_CONNS, "daemon: closing %d\n", s, 0, 0 );
+static void slapd_close(ber_socket_t s) {
+ Debug( LDAP_DEBUG_CONNS, "daemon: closing %ld\n",
+ (long) s, 0, 0 );
tcp_close(s);
}
int
set_socket( struct sockaddr_in *addr )
{
- int tcps = -1;
+ ber_socket_t tcps = AC_SOCKET_INVALID;
+
if ( !daemon_initialized ) sockinit();
#ifdef HAVE_SYSCONF
if( addr != NULL ) {
int tmp;
- if ( (tcps = socket( AF_INET, SOCK_STREAM, 0 )) == -1 ) {
+ if ( (tcps = socket( AF_INET, SOCK_STREAM, 0 )) == AC_SOCKET_INVALID ) {
#ifndef HAVE_WINSOCK
int err = errno;
Debug( LDAP_DEBUG_ANY,
#ifndef HAVE_WINSOCK
if ( tcps >= dtblsize ) {
Debug( LDAP_DEBUG_ANY,
- "daemon: listener descriptor %d is too great\n",
- tcps, dtblsize, 0 );
- return -1;
+ "daemon: listener descriptor %ld is too great %ld\n",
+ (long) tcps, (long) dtblsize, 0 );
+ return( -1);
}
#endif
{
int err = errno;
Debug( LDAP_DEBUG_ANY,
- "slapd(%d): setsockopt() failed errno %d (%s)\n",
- tcps, err,
+ "slapd(%ld): setsockopt() failed errno %d (%s)\n",
+ (long) tcps, err,
err > -1 && err < sys_nerr
? sys_errlist[err] : "unknown" );
}
{
int err = errno;
Debug( LDAP_DEBUG_ANY,
- "slapd(%d): setsockopt(KEEPALIVE) failed errno %d (%s)\n",
- tcps, err,
+ "slapd(%ld): setsockopt(KEEPALIVE) failed errno %d (%s)\n",
+ (long) tcps, err,
err > -1 && err < sys_nerr
? sys_errlist[err] : "unknown" );
}
if ( bind( tcps, (struct sockaddr *) addr, sizeof(*addr) ) == -1 ) {
int err = errno;
- Debug( LDAP_DEBUG_ANY, "daemon: bind(%d) failed errno %d (%s)\n",
- tcps, err,
+ Debug( LDAP_DEBUG_ANY, "daemon: bind(%ld) failed errno %d (%s)\n",
+ (long) tcps, err,
err > -1 && err < sys_nerr
? sys_errlist[err] : "unknown" );
return -1;
struct sockaddr_in *slapd_addr = args->addr;
tcps = args->tcps;
- /*free( ptr ); This seems to be wrong unless I hosed something */
inetd = ( slapd_addr == NULL);
if ( !daemon_initialized ) sockinit();
if ( listen( tcps, 5 ) == -1 ) {
int err = errno;
Debug( LDAP_DEBUG_ANY,
- "daemon: listen(%d, 5) failed errno %d (%s)\n",
- tcps, err,
+ "daemon: listen(%ld, 5) failed errno %d (%s)\n",
+ (long) tcps, err,
err > -1 && err < sys_nerr
? sys_errlist[err] : "unknown" );
return( (void*)-1 );
slapd_add( tcps );
} else {
- if( connection_init( 0, NULL, NULL ) ) {
+ if( connection_init( (ber_socket_t) 0, NULL, NULL ) ) {
Debug( LDAP_DEBUG_ANY,
"connection_init(%d) failed.\n",
0, 0, 0 );
ldap_pvt_thread_cond_signal( &started_event );
#endif
/* initialization complete. Here comes the loop. */
+
while ( !slapd_shutdown ) {
- unsigned int i;
- int ns, nfds;
+ ber_socket_t i;
+ int ns;
+ ber_socket_t nfds;
int ebadf = 0;
#define SLAPD_EBADF_LIMIT 10
}
if ( FD_ISSET( tcps, &readfds ) ) {
- int s;
+ ber_int_t s;
int len = sizeof(from);
long id;
if ( (s = accept( tcps,
- (struct sockaddr *) &from, &len )) == -1 )
+ (struct sockaddr *) &from, &len )) == AC_SOCKET_INVALID )
{
int err = errno;
Debug( LDAP_DEBUG_ANY,
- "daemon: accept(%d) failed errno %d (%s)\n", err,
- tcps, err >= 0 && err < sys_nerr ?
+ "daemon: accept(%ld) failed errno %d (%s)\n", err,
+ (long) tcps, err >= 0 && err < sys_nerr ?
sys_errlist[err] : "unknown");
continue;
}
/* make sure descriptor number isn't too great */
if ( s >= dtblsize ) {
Debug( LDAP_DEBUG_ANY,
- "daemon: %d beyond descriptor table size %d\n",
- s, dtblsize, 0 );
+ "daemon: %ld beyond descriptor table size %ld\n",
+ (long) s, (long) dtblsize, 0 );
slapd_close(s);
continue;
}
#endif
- Debug( LDAP_DEBUG_CONNS, "daemon: new connection on %d\n",
- s, 0, 0 );
+ Debug( LDAP_DEBUG_CONNS, "daemon: new connection on %ld\n",
+ (long) s, 0, 0 );
len = sizeof(from);
if ( getpeername( s, (struct sockaddr *) &from, &len ) == 0 ) {
{
/* DENY ACCESS */
Statslog( LDAP_DEBUG_ANY,
- "fd=%d connection from %s (%s) denied.\n",
- s,
+ "fd=%ld connection from %s (%s) denied.\n",
+ (long) s,
client_name == NULL ? "unknown" : client_name,
client_addr == NULL ? "unknown" : client_addr,
0, 0 );
if( (id = connection_init(s, client_name, client_addr)) < 0 ) {
Debug( LDAP_DEBUG_ANY,
- "daemon: connection_init(%d, %s, %s) failed.\n",
- s,
+ "daemon: connection_init(%ld, %s, %s) failed.\n",
+ (long) s,
client_name == NULL ? "unknown" : client_name,
client_addr == NULL ? "unknown" : client_addr);
slapd_close(s);
}
Statslog( LDAP_DEBUG_STATS,
- "daemon: conn=%d fd=%d connection from %s (%s) accepted.\n",
- id, s,
+ "daemon: conn=%d fd=%ld connection from %s (%s) accepted.\n",
+ id, (long) s,
client_name == NULL ? "unknown" : client_name,
client_addr == NULL ? "unknown" : client_addr,
0 );
for ( i = 0; i < nfds; i++ )
#endif
{
- int wd;
+ ber_socket_t wd;
#ifdef HAVE_WINSOCK
wd = writefds.fd_array[i];
for ( i = 0; i < nfds; i++ )
#endif
{
- int rd;
+ ber_socket_t rd;
#ifdef HAVE_WINSOCK
rd = readfds.fd_array[i];
void hit_socket()
{
- int s, on = 1;
+ ber_socket_t s;
+ int on = 1;
extern struct sockaddr_in bind_addr;
/* throw something at the socket to terminate the select() in the daemon thread. */
- if (( s = socket( AF_INET, SOCK_STREAM, 0 )) == INVALID_SOCKET )
+ if (( s = socket( AF_INET, SOCK_STREAM, 0 )) == AC_SOCKET_INVALID )
Debug( LDAP_DEBUG_ANY,
"slap_set_shutdown: socket failed\n\tWSAGetLastError=%d (%s)\n",
WSAGetLastError(), WSAGetLastErrorString(), 0 );
void sockinit()
{
daemon_initialized = 1;
- return;
}
#endif
{
Filter **new;
int err;
- unsigned long tag, len;
+ ber_tag_t tag;
+ ber_len_t len;
char *last, *ftmp;
Debug( LDAP_DEBUG_FILTER, "begin get_filter_list\n", 0, 0, 0 );
char **fstr
)
{
- unsigned long tag, len, rc;
+ ber_tag_t tag;
+ ber_len_t len;
+ ber_tag_t rc;
char *val, *last;
int syntax;
(void) ber_skip_tag( ber, &len );
}
#endif
- if ( ber_scanf( ber, "{a", &f->f_sub_type ) == LBER_ERROR ) {
+ if ( ber_scanf( ber, "{a" /*}*/, &f->f_sub_type ) == LBER_ERROR ) {
return( LDAP_PROTOCOL_ERROR );
}
attr_normalize( f->f_sub_type );
#include "ldap_defaults.h"
#include "slap.h"
-#include "lutil.h" /* Get lutil_detach() */
-
-int set_socket( struct sockaddr_in *addr );
+#include "lutil.h"
#ifdef LDAP_SIGCHLD
static RETSIGTYPE wait4child( int sig );
fprintf( stderr, "usage: %s [-d ?|debuglevel] [-f configfile] [-p portnumber] [-s sysloglevel]", name );
fprintf( stderr, "\n [-a bind-address] [-i] [-u]" );
#ifdef HAVE_WINSOCK
- fprintf( stderr, " [-v NTserviceName]" );
+ fprintf( stderr, " [-n NTserviceName]" );
#endif
#if LDAP_CONNECTIONLESS
fprintf( stderr, " [-c]" );
time_t starttime;
struct sockaddr_in bind_addr;
-int tcps;
+ber_int_t tcps;
#ifdef HAVE_WINSOCK
void WINAPI ServiceMain( DWORD argc, LPTSTR *argv )
-{
#else
int main( int argc, char **argv )
-{
#endif
-
+{
int i;
int inetd = 0;
int rc;
Debug ( LDAP_DEBUG_ANY, "new config file from registry is: %s\n", configfile, 0, 0 );
}
}
-
#endif
while ( (i = getopt( argc, argv,
"c"
#endif
#ifdef HAVE_WINSOCK
- "v:"
+ "n:"
#endif
)) != EOF ) {
switch ( i ) {
break;
#endif /* SETUID && GETUID */
#ifdef HAVE_WINSOCK
- case 'v': /* NT service name */
+ case 'n': /* NT service name */
NTservice = ch_strdup( optarg );
break;
#endif
goto destroy;
}
-
tcps = set_socket( inetd ? NULL : &bind_addr );
if ( tcps == -1 )
goto destroy;
#ifdef LDAP_SIGCHLD
(void) SIGNAL( LDAP_SIGCHLD, wait4child );
#endif
-#ifdef HAVE_WINSOCK
+#ifdef SIGBREAK
/* SIGBREAK is generated when Ctrl-Break is pressed. */
(void) SIGNAL( SIGBREAK, slap_set_shutdown );
#endif
ldap_pvt_thread_cond_destroy( &started_event );
#endif
-
shutdown:
/* remember an error during shutdown */
rc |= slap_shutdown(-1);
{
char *ndn;
char *last;
- unsigned long tag, len;
+ ber_tag_t tag;
+ ber_len_t len;
LDAPModList *modlist;
LDAPModList **modtail;
#ifdef LDAP_DEBUG
tag != LBER_DEFAULT;
tag = ber_next_element( op->o_ber, &len, last ) )
{
+ ber_int_t mop;
+
(*modtail) = (LDAPModList *) ch_calloc( 1, sizeof(LDAPModList) );
- if ( ber_scanf( op->o_ber, "{i{a[V]}}", &(*modtail)->ml_op,
+ if ( ber_scanf( op->o_ber, "{i{a[V]}}", &mop,
&(*modtail)->ml_type, &(*modtail)->ml_bvalues )
== LBER_ERROR )
{
return;
}
+ (*modtail)->ml_op = mop;
+
if ( (*modtail)->ml_op != LDAP_MOD_ADD &&
(*modtail)->ml_op != LDAP_MOD_DELETE &&
(*modtail)->ml_op != LDAP_MOD_REPLACE )
)
{
char *ndn, *newrdn;
- int deloldrdn;
+ ber_int_t deloldrdn;
Backend *be;
/* Vars for LDAP v3 newSuperior support */
char *newSuperior = NULL;
char *nnewSuperior = NULL;
Backend *newSuperior_be = NULL;
- unsigned long length;
+ ber_len_t length;
Debug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 );
}/* else if ( conn->c_protocol == 0 ) */
- if ( ber_scanf( op->o_ber, "a}", &newSuperior )
+ if ( ber_scanf( op->o_ber, /*{*/ "a}", &newSuperior )
== LBER_ERROR ) {
Debug( LDAP_DEBUG_ANY, "ber_scanf(\"a\"}) failed\n",
"" );
return;
- }/* if ( ber_scanf( ber, "a}", &newSuperior ) == ... ) */
+ }/* if ( ber_scanf( ber, { "a}", &newSuperior ) == ... ) */
Debug( LDAP_DEBUG_ARGS, "do_modrdn: newSuperior=(%s)\n",
val.bv_len = strlen( buf );
attr_merge( e, "totalconnections", vals );
- sprintf( buf, "%d", dtblsize );
+ sprintf( buf, "%ld", (long) dtblsize );
val.bv_val = buf;
val.bv_len = strlen( buf );
attr_merge( e, "dtablesize", vals );
Operation *
slap_op_alloc(
BerElement *ber,
- unsigned long msgid,
- unsigned long tag,
- long id
+ ber_int_t msgid,
+ ber_tag_t tag,
+ ber_int_t id
)
{
Operation *op;
#include <ldap_cdefs.h>
+LDAP_BEGIN_DECL
+
/*
* acl.c
*/
* ch_malloc.c
*/
-void * ch_malloc LDAP_P(( unsigned long size ));
-void * ch_realloc LDAP_P(( void *block, unsigned long size ));
-void * ch_calloc LDAP_P(( unsigned long nelem, unsigned long size ));
+void * ch_malloc LDAP_P(( ber_len_t size ));
+void * ch_realloc LDAP_P(( void *block, ber_len_t size ));
+void * ch_calloc LDAP_P(( ber_len_t nelem, ber_len_t size ));
char * ch_strdup LDAP_P(( const char *string ));
+void ch_free LDAP_P(( void * ));
+#define free ch_free
/*
* charray.c
int connections_destroy LDAP_P((void));
long connection_init LDAP_P((
- int s,
+ ber_socket_t s,
const char* name, const char* addr));
void connection_closing LDAP_P(( Connection *c ));
int connection_state_closing LDAP_P(( Connection *c ));
-int connection_write LDAP_P((int s));
-int connection_read LDAP_P((int s));
+int connection_write LDAP_P((ber_socket_t s));
+int connection_read LDAP_P((ber_socket_t s));
-long connections_nextid(void);
+unsigned long connections_nextid(void);
-Connection* connection_first LDAP_P((int *));
-Connection* connection_next LDAP_P((Connection *, int *));
+Connection* connection_first LDAP_P((ber_socket_t *));
+Connection* connection_next LDAP_P((Connection *, ber_socket_t *));
void connection_done LDAP_P((Connection *));
/*
void slap_op_free LDAP_P(( Operation *op ));
Operation * slap_op_alloc LDAP_P((
- BerElement *ber, unsigned long msgid,
- unsigned long tag, long id ));
+ BerElement *ber, ber_int_t msgid,
+ ber_tag_t tag, ber_int_t id ));
int slap_op_add LDAP_P(( Operation **olist, Operation *op ));
int slap_op_remove LDAP_P(( Operation **olist, Operation *op ));
struct sockaddr_in *addr;
int tcps;
};
+
extern int slapd_daemon LDAP_P((struct slapd_args *args));
+extern int set_socket LDAP_P((struct sockaddr_in *addr));
-extern void slapd_set_write LDAP_P((int s, int wake));
-extern void slapd_clr_write LDAP_P((int s, int wake));
-extern void slapd_set_read LDAP_P((int s, int wake));
-extern void slapd_clr_read LDAP_P((int s, int wake));
+extern void slapd_set_write LDAP_P((ber_socket_t s, int wake));
+extern void slapd_clr_write LDAP_P((ber_socket_t s, int wake));
+extern void slapd_set_read LDAP_P((ber_socket_t s, int wake));
+extern void slapd_clr_read LDAP_P((ber_socket_t s, int wake));
-extern void slapd_remove LDAP_P((int s, int wake));
+extern void slapd_remove LDAP_P((ber_socket_t s, int wake));
extern void slap_set_shutdown LDAP_P((int sig));
extern void slap_do_nothing LDAP_P((int sig));
extern int send_search_entry LDAP_P((Backend *be, Connection *conn, Operation *op, Entry *e, char **attrs, int attrsonly));
extern int str2result LDAP_P(( char *s, int *code, char **matched, char **info ));
-extern int dtblsize;
+extern ber_socket_t dtblsize;
+
+LDAP_END_DECL
#endif /* _proto_slap */
send_ldap_result2(
Connection *conn,
Operation *op,
- int err,
+ ber_int_t err,
char *matched,
char *text,
int nentries
{
BerElement *ber;
int rc;
- unsigned long tag, bytes;
+ ber_tag_t tag;
+ ber_len_t bytes;
if ( err == LDAP_PARTIAL_RESULTS && (text == NULL || *text == '\0') )
err = LDAP_NO_SUCH_OBJECT;
#ifdef LDAP_COMPAT30
- if ( (ber = ber_alloc_t( conn->c_version == 30 ? 0 : LBER_USE_DER ))
- == NULLBER )
+ ber = ber_alloc_t( conn->c_version == 30 ? 0 : LBER_USE_DER );
#else
- if ( (ber = der_alloc()) == NULLBER )
+ ber = der_alloc();
#endif
- {
+ if ( ber == NULL ) {
Debug( LDAP_DEBUG_ANY, "ber_alloc failed\n", 0, 0, 0 );
return;
}
ldap_pvt_thread_mutex_unlock( &num_sent_mutex );
Statslog( LDAP_DEBUG_STATS,
- "conn=%d op=%d RESULT err=%d tag=%lu nentries=%d\n", conn->c_connid,
- op->o_opid, err, tag, nentries );
+ "conn=%ld op=%ld RESULT err=%ld tag=%lu nentries=%d\n",
+ (long) conn->c_connid, (long) op->o_opid,
+ (long) err, (long) tag, nentries );
return;
}
send_ldap_result(
Connection *conn,
Operation *op,
- int err,
+ ber_int_t err,
char *matched,
char *text
)
send_ldap_search_result(
Connection *conn,
Operation *op,
- int err,
+ ber_int_t err,
char *matched,
char *text,
int nentries
edn = e->e_ndn;
#ifdef LDAP_COMPAT30
- if ( (ber = ber_alloc_t( conn->c_version == 30 ? 0 : LBER_USE_DER ))
- == NULLBER )
+ ber = ber_alloc_t( conn->c_version == 30 ? 0 : LBER_USE_DER );
#else
- if ( (ber = der_alloc()) == NULLBER )
+ ber = der_alloc();
#endif
- {
+
+ if ( ber == NULL ) {
Debug( LDAP_DEBUG_ANY, "ber_alloc failed\n", 0, 0, 0 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
"ber_alloc" );
continue;
}
- if (( rc = ber_printf( ber, "{s[", a->a_type )) == -1 ) {
+ if (( rc = ber_printf( ber, "{s[" /*]}*/ , a->a_type )) == -1 ) {
Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
ber_free( ber, 1 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
continue;
}
- if (( rc = ber_printf( ber, "o",
- a->a_vals[i]->bv_val,
- a->a_vals[i]->bv_len )) == -1 )
- {
+ if (( rc = ber_printf( ber, "O", a->a_vals[i] )) == -1 ) {
Debug( LDAP_DEBUG_ANY,
"ber_printf failed\n", 0, 0, 0 );
ber_free( ber, 1 );
}
}
- if (( rc = ber_printf( ber, "]}" )) == -1 ) {
+ if (( rc = ber_printf( ber, /*{[*/ "]}" )) == -1 ) {
Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
ber_free( ber, 1 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
#ifdef LDAP_COMPAT30
if ( conn->c_version == 30 ) {
- rc = ber_printf( ber, "}}}}" );
+ rc = ber_printf( ber, /*{{{{{*/ "}}}}" );
} else
#endif
- rc = ber_printf( ber, "}}}" );
+ rc = ber_printf( ber, /*{{{{*/ "}}}" );
if ( rc == -1 ) {
Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
num_entries_sent++;
ldap_pvt_thread_mutex_unlock( &num_sent_mutex );
- Statslog( LDAP_DEBUG_STATS2, "conn=%d op=%d ENTRY dn=\"%s\"\n",
- conn->c_connid, op->o_opid, e->e_dn, 0, 0 );
+ Statslog( LDAP_DEBUG_STATS2, "conn=%ld op=%ld ENTRY dn=\"%s\"\n",
+ (long) conn->c_connid, (long) op->o_opid, e->e_dn, 0, 0 );
Debug( LDAP_DEBUG_TRACE, "<= send_search_entry\n", 0, 0, 0 );
schema_init( void )
{
int res;
- int code;
- const char *err;
int i;
static int schema_init_done = 0;
)
{
int i, err;
- int scope, deref, attrsonly;
- int sizelimit, timelimit;
+ ber_int_t scope, deref, attrsonly;
+ ber_int_t sizelimit, timelimit;
char *base = NULL, *fstr = NULL;
Filter *filter = NULL;
char **attrs = NULL;
Debug( LDAP_DEBUG_ARGS, " filter: %s\n", fstr, 0, 0 );
/* attributes */
- if ( ber_scanf( op->o_ber, "{v}}", &attrs ) == LBER_ERROR ) {
+ if ( ber_scanf( op->o_ber, /*{*/ "{v}}", &attrs ) == LBER_ERROR ) {
send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "" );
goto return_results;
}
#include <ac/syslog.h>
#include <ac/regex.h>
#include <ac/socket.h>
-#include <ldap_schema.h>
#include "avl.h"
#include "lber.h"
#include "ldap.h"
+#include "ldap_schema.h"
+
#include "ldap_pvt_thread.h"
#include "ldif.h"
+
+LDAP_BEGIN_DECL
+
#ifdef f_next
#undef f_next /* name conflict between sys/file.h on SCO and struct filter */
#endif
#define SLAP_SCHERR_SYN_NOT_FOUND 11
#define SLAP_SCHERR_MR_INCOMPLETE 12
-LDAP_BEGIN_DECL
-
extern int slap_debug;
struct slap_op;
* represents a search filter
*/
typedef struct filter {
- unsigned long f_choice; /* values taken from ldap.h */
+ ber_tag_t f_choice; /* values taken from ldap.h */
union f_un_u {
/* present */
* the id used in the indexes to refer to an entry
*/
typedef unsigned long ID;
-#define NOID ((unsigned long)-1)
+#define NOID ((unsigned long)~0)
/*
* represents an entry in core
struct slap_conn *c, struct slap_op *o ));
int (*bi_op_search) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
- char *base, int scope, int deref, int slimit, int tlimit,
- Filter *f, char *filterstr, char **attrs, int attrsonly));
+ char *base, int scope, int deref,
+ int slimit, int tlimit,
+ Filter *f, char *filterstr, char **attrs,
+ int attrsonly));
int (*bi_op_compare)LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
char *dn, Ava *ava));
/* Bug: be_op_abandon in unused! */
int (*bi_op_abandon) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
- int msgid));
+ ber_int_t msgid));
/* Auxilary Functions */
int (*bi_entry_release_rw) LDAP_P((BackendDB *bd, Entry *e, int rw));
*/
typedef struct slap_op {
- long o_opid; /* id of this operation */
- long o_msgid; /* msgid of the request */
+ ber_int_t o_opid; /* id of this operation */
+ ber_int_t o_msgid; /* msgid of the request */
ldap_pvt_thread_t o_tid; /* thread handling this op */
BerElement *o_ber; /* ber of the request */
- unsigned long o_tag; /* tag of the request */
+ ber_tag_t o_tag; /* tag of the request */
time_t o_time; /* time op was initiated */
char *o_dn; /* dn bound when op was initiated */
char *o_ndn; /* normalized dn bound when op was initiated */
- int o_authtype; /* auth method used to bind dn */
+ ber_tag_t o_authtype; /* auth method used to bind dn */
/* values taken from ldap.h */
/* LDAP_AUTH_* */
/* only can be changed by connect_init */
time_t c_starttime; /* when the connection was opened */
time_t c_activitytime; /* when the connection was last used */
- long c_connid; /* id of this connection for stats*/
+ unsigned long c_connid; /* id of this connection for stats*/
char *c_client_addr; /* address of client */
char *c_client_name; /* name of client */
/* only can be changed by binding thread */
char *c_cdn; /* DN provided by the client */
char *c_dn; /* DN bound to this conn */
- int c_protocol; /* version of the LDAP protocol used by client */
- int c_authtype; /* auth method used to bind c_dn */
+ ber_int_t c_protocol; /* version of the LDAP protocol used by client */
+ ber_tag_t c_authtype; /* auth method used to bind c_dn */
+
#ifdef LDAP_COMPAT
int c_version; /* for compatibility w/ U-Mich 2.0 & 3.0 */
#endif
#define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 )
#endif
-#include "proto-slap.h"
-
LDAP_END_DECL
+#include "proto-slap.h"
+
#endif /* _slap_h_ */
if (( phber = der_alloc()) == NULLBER ) {
return( -1 );
}
- if ( ber_printf( phber, "t{[tB]{B}}", 0xA3, 0x81, faxparamset,
- 31, (char *)pe->pe_prim, len * 8 ) == -1 ) {
+ if ( ber_printf( phber, "t{[tB]{B}}",
+ (ber_tag_t) 0xA3, (ber_tag_t) 0x81, faxparamset, (ber_len_t) 31,
+ (char *)pe->pe_prim, (ber_len_t) (len * 8) ) == -1 )
+ {
ber_free( phber, 1 );
return( -1 );
}
*/
void *
ch_malloc(
- unsigned long size
+ ber_len_t size
)
{
void *new;
if ( (new = (void *) malloc( size )) == NULL ) {
- fprintf( stderr, "malloc of %lu bytes failed\n", size );
+ fprintf( stderr, "malloc of %lu bytes failed\n",
+ (long) size );
exit( 1 );
}
void *
ch_realloc(
void *block,
- unsigned long size
+ ber_len_t size
)
{
void *new;
}
if ( (new = (void *) realloc( block, size )) == NULL ) {
- fprintf( stderr, "realloc of %lu bytes failed\n", size );
+ fprintf( stderr, "realloc of %lu bytes failed\n",
+ (long) size );
exit( 1 );
}
*/
void *
ch_calloc(
- unsigned long nelem,
- unsigned long size
+ ber_len_t nelem,
+ ber_len_t size
)
{
void *new;
if ( (new = (void *) calloc( nelem, size )) == NULL ) {
fprintf( stderr, "calloc of %lu elems of %lu bytes failed\n",
- nelem, size );
+ (long) nelem, (long) size );
exit( 1 );
}
int doargs LDAP_P((int argc, char **argv, struct globals *g));
/* ch_malloc.c */
-void *ch_malloc LDAP_P((unsigned long size));
-void *ch_realloc LDAP_P((void *block, unsigned long size));
-void *ch_calloc LDAP_P((unsigned long nelem, unsigned long size));
+void *ch_malloc LDAP_P((ber_len_t size));
+void *ch_realloc LDAP_P((void *block, ber_len_t size));
+void *ch_calloc LDAP_P((ber_len_t nelem, ber_len_t size));
void ch_free LDAP_P((void *p));
/* config.c */