Used mainly on NT since stderr doesn't exist when slapd runs as a service.
#define LBER_OPT_LOG_PRINT_FN 0x8001
#define LBER_OPT_MEMORY_FNS 0x8002
#define LBER_OPT_ERROR_FN 0x8003
+#define LBER_OPT_LOG_PRINT_FILE 0x8004
typedef int* (*BER_ERRNO_FN) LDAP_P(( void ));
#include "lber-int.h"
+/*
+ * We don't just set ber_pvt_err_file to stderr here, because in NT,
+ * stderr is a symbol imported from a DLL. As such, the compiler
+ * doesn't recognize the symbol as having a constant address. Thus
+ * we set ber_pvt_err_file to stderr later, when it first gets
+ * referenced.
+ */
+FILE *ber_pvt_err_file;
+
/*
* ber errno
*/
{
assert( data != NULL );
+ if (!ber_pvt_err_file)
+ ber_pvt_err_file = stderr;
+
+ fputs( data, ber_pvt_err_file );
+
+ /* Print to both streams */
+ if (ber_pvt_err_file != stderr)
+ {
fputs( data, stderr );
fflush( stderr );
+ }
+
+ fflush( ber_pvt_err_file );
}
BER_LOG_PRINT_FN ber_pvt_log_print = ber_error_print;
#include "lber-int.h"
+extern void * ber_pvt_err_file; /* bprint.c */
+
struct lber_options ber_int_options = {
LBER_UNINITIALIZED, 0, 0 };
} else if(option == LBER_OPT_LOG_PRINT_FN) {
ber_pvt_log_print = (BER_LOG_PRINT_FN) invalue;
return LBER_OPT_SUCCESS;
+ } else if(option == LBER_OPT_LOG_PRINT_FILE) {
+ ber_pvt_err_file = (void *) invalue;
+ return LBER_OPT_SUCCESS;
}
ber_errno = LBER_ERROR_PARAM;
#include "ldap_log.h"
#include "ldap_defaults.h"
+#include "lber.h"
static FILE *log_file;
int lutil_debug_file( FILE *file )
{
log_file = file;
+ ber_set_option( NULL, LBER_OPT_LOG_PRINT_FILE, file );
return 0;
}
if ( log_file == NULL )
return;
+
+ ber_set_option( NULL, LBER_OPT_LOG_PRINT_FILE, file );
}
#endif
-
va_start( vl, fmt );
#ifdef HAVE_VSNPRINTF