mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-02-03 20:40:05 -05:00
Added LBER_OPT_LOG_PRINT_FILE to redirect the output of ber_error_print.
Used mainly on NT since stderr doesn't exist when slapd runs as a service.
This commit is contained in:
parent
2d9a7620b5
commit
65d7521be1
4 changed files with 30 additions and 1 deletions
|
|
@ -105,6 +105,7 @@ typedef int (*BERTranslateProc) LDAP_P((
|
|||
#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 ));
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,15 @@
|
|||
|
||||
#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
|
||||
*/
|
||||
|
|
@ -38,8 +47,19 @@ ber_error_print( char *data )
|
|||
{
|
||||
assert( data != NULL );
|
||||
|
||||
if (!ber_pvt_err_file)
|
||||
ber_pvt_err_file = stderr;
|
||||
|
||||
fputs( data, ber_pvt_err_file );
|
||||
|
||||
/* Print to both streams */
|
||||
if (ber_pvt_err_file != stderr)
|
||||
{
|
||||
fputs( data, stderr );
|
||||
fflush( stderr );
|
||||
}
|
||||
|
||||
fflush( ber_pvt_err_file );
|
||||
}
|
||||
|
||||
BER_LOG_PRINT_FN ber_pvt_log_print = ber_error_print;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#include "lber-int.h"
|
||||
|
||||
extern void * ber_pvt_err_file; /* bprint.c */
|
||||
|
||||
struct lber_options ber_int_options = {
|
||||
LBER_UNINITIALIZED, 0, 0 };
|
||||
|
||||
|
|
@ -130,6 +132,9 @@ ber_set_option(
|
|||
} 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;
|
||||
|
|
|
|||
|
|
@ -29,12 +29,14 @@
|
|||
|
||||
#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;
|
||||
}
|
||||
|
|
@ -57,9 +59,10 @@ void (lutil_debug)( int level, int debug, const char *fmt, ... )
|
|||
|
||||
if ( log_file == NULL )
|
||||
return;
|
||||
|
||||
ber_set_option( NULL, LBER_OPT_LOG_PRINT_FILE, file );
|
||||
}
|
||||
#endif
|
||||
|
||||
va_start( vl, fmt );
|
||||
|
||||
#ifdef HAVE_VSNPRINTF
|
||||
|
|
|
|||
Loading…
Reference in a new issue