/* $OpenLDAP$ */1/* This work is part of OpenLDAP Software <http://www.openldap.org/>.2*3* Copyright 1998-2024 The OpenLDAP Foundation.4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted only as authorized by the OpenLDAP8* Public License.9*10* A copy of this license is available in the file LICENSE in the11* top-level directory of the distribution or, alternatively, at12* <http://www.OpenLDAP.org/license.html>.13*/1415#include "portable.h"1617#include <stdio.h>1819#include <ac/ctype.h>20#include <ac/stdarg.h>21#include <ac/string.h>22#include <ac/time.h>2324#include "ldap-int.h"2526/*27* ldap log28*/2930static int ldap_log_check( LDAP *ld, int loglvl )31{32int errlvl;3334if(ld == NULL) {35errlvl = ldap_debug;36} else {37errlvl = ld->ld_debug;38}3940return errlvl & loglvl ? 1 : 0;41}4243int ldap_log_printf( LDAP *ld, int loglvl, const char *fmt, ... )44{45char buf[ 1024 ];46va_list ap;4748if ( !ldap_log_check( ld, loglvl )) {49return 0;50}5152va_start( ap, fmt );5354buf[sizeof(buf) - 1] = '\0';55vsnprintf( buf, sizeof(buf)-1, fmt, ap );5657va_end(ap);5859(*ber_pvt_log_print)( buf );60return 1;61}626364