]> git.sur5r.net Git - openldap/blob - libraries/libldap/print.c
Remove lint
[openldap] / libraries / libldap / print.c
1 /*
2  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6 #include "portable.h"
7
8 #include <stdio.h>
9
10 #include <ac/ctype.h>
11 #include <ac/stdarg.h>
12 #include <ac/string.h>
13 #include <ac/time.h>
14
15 #include "ldap-int.h"
16
17 /*
18  * ldap log 
19  */
20
21 static int ldap_log_check( LDAP *ld, int loglvl )
22 {
23         int errlvl;
24
25         if(ld == NULL) {
26                 errlvl = ldap_debug;
27         } else {
28                 errlvl = ld->ld_errno;
29         }
30
31         return errlvl & loglvl ? 1 : 0;
32 }
33
34 int ldap_log_printf( LDAP *ld, int loglvl, const char *fmt, ... )
35 {
36         char buf[ 1024 ];
37         va_list ap;
38
39         if ( !ldap_log_check( ld, loglvl )) {
40                 return 0;
41         }
42
43         va_start( ap, fmt );
44
45 #ifdef HAVE_VSNPRINTF
46         buf[sizeof(buf) - 1] = '\0';
47         vsnprintf( buf, sizeof(buf)-1, fmt, ap );
48 #elif HAVE_VSPRINTF
49         vsprintf( buf, fmt, ap ); /* hope it's not too long */
50 #else
51         /* use doprnt() */
52         chokeme = "choke me! I don't have a doprnt manual handy!";
53 #endif
54
55         va_end(ap);
56
57         (*ber_pvt_log_print)( buf );
58         return 1;
59 }