]> git.sur5r.net Git - openldap/blob - libraries/libldap/print.c
ITS#2657: authzid (and assertion) should apply to most everything
[openldap] / libraries / libldap / print.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6
7 #include "portable.h"
8
9 #include <stdio.h>
10
11 #include <ac/ctype.h>
12 #include <ac/stdarg.h>
13 #include <ac/string.h>
14 #include <ac/time.h>
15
16 #include "ldap-int.h"
17
18 /*
19  * ldap log 
20  */
21
22 static int ldap_log_check( LDAP *ld, int loglvl )
23 {
24         int errlvl;
25
26         if(ld == NULL) {
27                 errlvl = ldap_debug;
28         } else {
29                 errlvl = ld->ld_debug;
30         }
31
32         return errlvl & loglvl ? 1 : 0;
33 }
34
35 int ldap_log_printf( LDAP *ld, int loglvl, const char *fmt, ... )
36 {
37         char buf[ 1024 ];
38         va_list ap;
39
40         if ( !ldap_log_check( ld, loglvl )) {
41                 return 0;
42         }
43
44         va_start( ap, fmt );
45
46         buf[sizeof(buf) - 1] = '\0';
47         vsnprintf( buf, sizeof(buf)-1, fmt, ap );
48
49         va_end(ap);
50
51         (*ber_pvt_log_print)( buf );
52         return 1;
53 }