From 0b924192e70bbd6f63866286f12ff0648418dd99 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 21 Jun 1999 22:52:28 +0000 Subject: [PATCH] Move nt_debug to -llutil and generalize for all platforms. --- libraries/liblutil/Makefile.in | 5 ++- libraries/liblutil/debug.c | 70 ++++++++++++++++++++++++++++++++++ servers/slapd/nt_debug.c | 54 -------------------------- 3 files changed, 73 insertions(+), 56 deletions(-) create mode 100644 libraries/liblutil/debug.c delete mode 100644 servers/slapd/nt_debug.c diff --git a/libraries/liblutil/Makefile.in b/libraries/liblutil/Makefile.in index 03d012a0de..b5932cc985 100644 --- a/libraries/liblutil/Makefile.in +++ b/libraries/liblutil/Makefile.in @@ -3,8 +3,9 @@ ## LIBRARY = liblutil.a -SRCS = base64.c detach.c md5.c passwd.c sha1.c getpass.c lockf.c -OBJS = base64.o detach.o md5.o passwd.o sha1.o getpass.o lockf.o @LIBOBJS@ +SRCS = base64.c debug.c detach.c md5.c passwd.c sha1.c getpass.c lockf.c +OBJS = base64.o debug.o detach.o md5.o passwd.o sha1.o getpass.o lockf.o \ + @LIBOBJS@ LDAP_INCDIR= ../../include LDAP_LIBDIR= ../../libraries diff --git a/libraries/liblutil/debug.c b/libraries/liblutil/debug.c new file mode 100644 index 0000000000..3958d3e8c5 --- /dev/null +++ b/libraries/liblutil/debug.c @@ -0,0 +1,70 @@ +/* + * Copyright (c) 1996, 1998 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#include "portable.h" + +#include + +#include +#include + +#include "ldap_log.h" +#include "ldap_defaults.h" + +static FILE *log_file; + +int lutil_debug_file( FILE *file ) +{ + log_file = log_file; + + return 0; +} + +void (lutil_debug)( int level, int debug, const char *fmt, ... ) +{ + char buffer[4096]; + va_list vl; + + if ( !(level & debug ) ) + return; + +#ifdef HAVE_WINSOCK + if( log_file == NULL ) + { + log_file = fopen( LDAP_RUNDIR LDAP_DIRSEP "slapd.log", "w" ); + + if ( log_file == NULL ) + log_file = fopen( "slapd.log", "w" ); + + if ( log_file == NULL ) + return; + } +#endif + + va_start( vl, fmt ); + + vsnprintf( buffer, sizeof(buffer), fmt, vl ); + buffer[sizeof(buffer)-1] = '\0'; + + if( log_file != NULL ) { + fputs( buffer, log_file ); + fflush( log_file ); + } + + puts(buffer ); + va_end( vl ); +} diff --git a/servers/slapd/nt_debug.c b/servers/slapd/nt_debug.c deleted file mode 100644 index fc9027cbf5..0000000000 --- a/servers/slapd/nt_debug.c +++ /dev/null @@ -1,54 +0,0 @@ - -#include "portable.h" - -#include - -#include -#include - -#include "slap.h" -#include "ldap_defaults.h" - -static FILE *log_file; - -int lutil_debug_file( FILE *file ) -{ - log_file = log_file; - - return 0; -} - -void (lutil_debug)( int level, int debug, const char *fmt, ... ) -{ - char buffer[4096]; - va_list vl; - - if ( !(level & debug ) ) - return; - -#ifdef HAVE_WINSOCK - if( log_file == NULL ) - { - log_file = fopen( LDAP_RUNDIR LDAP_DIRSEP "slapd.log", "w" ); - - if ( log_file == NULL ) - log_file = fopen( "slapd.log", "w" ); - - if ( log_file == NULL ) - return; - } -#endif - - va_start( vl, fmt ); - - vsnprintf( buffer, sizeof(buffer), fmt, vl ); - buffer[sizeof(buffer)-1] = '\0'; - - if( log_file != NULL ) { - fputs( buffer, log_file ); - fflush( log_file ); - } - - puts(buffer ); - va_end( vl ); -} -- 2.39.5