/*1* Copyright (c) 1997, 1998, 2002 Kungliga Tekniska Högskolan2* (Royal Institute of Technology, Stockholm, Sweden).3* All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8*9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11*12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* 3. Neither the name of the Institute nor the names of its contributors17* may be used to endorse or promote products derived from this software18* without specific prior written permission.19*20* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND21* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE22* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE23* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE24* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL25* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS26* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)27* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT28* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY29* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF30* SUCH DAMAGE.31*/3233#include "kcm_locl.h"3435RCSID("$Id$");3637static krb5_log_facility *logf;3839void40kcm_openlog(void)41{42char **s = NULL, **p;43krb5_initlog(kcm_context, "kcm", &logf);44s = krb5_config_get_strings(kcm_context, NULL, "kcm", "logging", NULL);45if(s == NULL)46s = krb5_config_get_strings(kcm_context, NULL, "logging", "kcm", NULL);47if(s){48for(p = s; *p; p++)49krb5_addlog_dest(kcm_context, logf, *p);50krb5_config_free_strings(s);51}else52krb5_addlog_dest(kcm_context, logf, DEFAULT_LOG_DEST);53krb5_set_warn_dest(kcm_context, logf);54}5556char*57kcm_log_msg_va(int level, const char *fmt, va_list ap)58{59char *msg;60krb5_vlog_msg(kcm_context, logf, &msg, level, fmt, ap);61return msg;62}6364char*65kcm_log_msg(int level, const char *fmt, ...)66{67va_list ap;68char *s;69va_start(ap, fmt);70s = kcm_log_msg_va(level, fmt, ap);71va_end(ap);72return s;73}7475void76kcm_log(int level, const char *fmt, ...)77{78va_list ap;79char *s;80va_start(ap, fmt);81s = kcm_log_msg_va(level, fmt, ap);82if(s) free(s);83va_end(ap);84}858687