]> git.sur5r.net Git - openldap/blobdiff - libraries/liblber/bprint.c
Move schema needed by slapd to core.schema so that only one file
[openldap] / libraries / liblber / bprint.c
index 6492f975d23832e0f73fc0131698e4dc43258e6a..ec2949eb71fb06026311384606c9fb9662662a75 100644 (file)
@@ -1,6 +1,6 @@
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 
 #include <ac/stdarg.h>
 #include <ac/string.h>
 
-#undef LDAP_F_PRE
-#define LDAP_F_PRE LDAP_F_EXPORT
-
 #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
+ */
+BER_ERRNO_FN ber_int_errno_fn;
+
+int * ber_errno_addr(void)
+{
+       static int ber_int_errno = LBER_ERROR_NONE;
+
+       if( ber_int_errno_fn ) {
+               return (*ber_int_errno_fn)();
+       }
+
+       return &ber_int_errno;
+}
+
 /*
  * Print stuff
  */
@@ -25,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;