--- /dev/null
+/* Generic assert.h */
+/*
+ * Copyright 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.
+ */
+
+#ifndef _AC_ASSERT_H
+#define _AC_ASSERT_H
+
+#ifdef LDAP_DEBUG
+
+#if defined( HAVE_ASSERT_H ) || defined( STDC_HEADERS )
+#undef NDEBUG
+#include <assert.h>
+#else
+#define LDAP_NEED_ASSERT 1
+
+/*
+ * no assert()... must be a very old compiler.
+ * create a replacement and hope it works
+ */
+
+void lber_pvt_assert(char* file, int line, char* test);
+#define assert(test) \
+ ((test) \
+ ? (void)0 \
+ : lber_pvt_assert( __FILE__, __LINE__, LDAP_STRING(test)) )
+
+#endif
+
+#else
+/* no asserts */
+#define assert(test) ((void)0)
+#endif
+
+#endif /* _AC_ASSERT_H */
/* begin of postamble */
+/*
+ * DEVEL implies TEST implies DEBUG
+ */
+#if !defined( LDAP_TEST) && defined( LDAP_DEVEL )
+#define LDAP_TEST
+#endif
+
+#if !defined( LDAP_DEBUG) && defined( LDAP_TEST )
+#define LDAP_DEBUG
+#endif
+
#ifdef HAVE_STDDEF_H
# include <stddef.h>
#endif
#include "ldap_cdefs.h"
#include "ldap_features.h"
+#include "ac/assert.h"
+
#endif /* _LDAP_PORTABLE_H */
LIBRARY = liblber.la
XLIBRARY = ../liblber.a
-SRCS= decode.c encode.c io.c bprint.c options.c sockbuf.c
-OBJS= decode.lo encode.lo io.lo bprint.lo options.lo sockbuf.lo
+SRCS= assert.c decode.c encode.c io.c bprint.c options.c sockbuf.c
+OBJS= assert.lo decode.lo encode.lo io.lo bprint.lo options.lo sockbuf.lo
XSRCS= version.c
PROGRAMS= dtest etest idtest
--- /dev/null
+/*
+ * Copyright 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.
+ */
+
+#include "portable.h"
+
+#ifdef LDAP_NEED_ASSERT
+
+#include <ac/stdio.h>
+
+/*
+ * helper for our private assert() macro
+ *
+ * note: if assert() doesn't exist, like abort() or raise() won't either.
+ * could use kill() but that might be problematic. I'll just ignore this
+ * issue for now.
+ */
+
+void lber_pvt_assert(char* file, int line, char* test)
+{
+ fprintf(stderr,
+ "Assertion failed: %s, file %s, line %d\n",
+ test, file, line);
+
+ abort();
+}
+
+#endif
#include "lber-int.h"
-#ifdef LDAP_DEBUG
-#include <assert.h>
-#else
-#define assert(cond)
-#endif
-
static long BerRead LDAP_P(( Sockbuf *sb, char *buf, long len ));
static int ber_realloc LDAP_P(( BerElement *ber, unsigned long len ));
#include "lber-int.h"
-#ifdef LDAP_DEBUG
-#include <assert.h>
+#ifdef LDAP_TEST
#undef TEST_PARTIAL_READ
#undef TEST_PARTIAL_WRITE
-#else
-#define assert( cond )
#endif
#define MAX_BUF_SIZE 65535
#include <sys/ioctl.h>
#endif
-#ifdef LDAP_DEBUG
-#include <assert.h>
-#else
-#define assert( cond )
-#endif
-
#ifdef HAVE_TCPD
#include <tcpd.h>
if ( (c[i].c_state != SLAP_C_INACTIVE)
&& (c[i].c_state != SLAP_C_CLOSING) )
{
-#ifdef LDAP_DEBUG
assert(lber_pvt_sb_in_use( &c[i].c_sb ));
-#endif
+
FD_SET( lber_pvt_sb_get_desc(&c[i].c_sb),
&readfds );
if (lber_pvt_sb_data_ready(&c[i].c_sb))
void
slap_op_free( Operation *op )
{
-#ifdef LDAP_DEBUG
assert( op->o_next == NULL );
-#endif
ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
#include <ac/syslog.h>
#include <ac/regex.h>
-#undef NDEBUG
-#include <assert.h>
-
#include "avl.h"
#ifndef ldap_debug