1160971Smarcel/* 2160971Smarcel * Copyright (c) 1997, 1998, 2002 Kungliga Tekniska H��gskolan 3160971Smarcel * (Royal Institute of Technology, Stockholm, Sweden). 4160971Smarcel * All rights reserved. 5160971Smarcel * 6160971Smarcel * Redistribution and use in source and binary forms, with or without 7160971Smarcel * modification, are permitted provided that the following conditions 8160971Smarcel * are met: 9160971Smarcel * 10160971Smarcel * 1. Redistributions of source code must retain the above copyright 11160971Smarcel * notice, this list of conditions and the following disclaimer. 12160971Smarcel * 13160971Smarcel * 2. Redistributions in binary form must reproduce the above copyright 14160971Smarcel * notice, this list of conditions and the following disclaimer in the 15160971Smarcel * documentation and/or other materials provided with the distribution. 16160971Smarcel * 17160971Smarcel * 3. Neither the name of the Institute nor the names of its contributors 18160971Smarcel * may be used to endorse or promote products derived from this software 19160971Smarcel * without specific prior written permission. 20160971Smarcel * 21160971Smarcel * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 22160971Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23160971Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24160971Smarcel * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 25160971Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26160971Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27160971Smarcel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28160971Smarcel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29160971Smarcel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30160971Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31160971Smarcel * SUCH DAMAGE. 32160971Smarcel */ 33160971Smarcel 34160971Smarcel#include "kcm_locl.h" 35160971Smarcel 36160971SmarcelRCSID("$Id$"); 37160971Smarcel 38160971Smarcelstatic krb5_log_facility *logf; 39160971Smarcel 40169187Smarcelvoid 41169187Smarcelkcm_openlog(void) 42169187Smarcel{ 43160971Smarcel char **s = NULL, **p; 44160971Smarcel krb5_initlog(kcm_context, "kcm", &logf); 45160971Smarcel s = krb5_config_get_strings(kcm_context, NULL, "kcm", "logging", NULL); 46160971Smarcel if(s == NULL) 47160971Smarcel s = krb5_config_get_strings(kcm_context, NULL, "logging", "kcm", NULL); 48169187Smarcel if(s){ 49169187Smarcel for(p = s; *p; p++) 50169187Smarcel krb5_addlog_dest(kcm_context, logf, *p); 51160971Smarcel krb5_config_free_strings(s); 52160971Smarcel }else 53160971Smarcel krb5_addlog_dest(kcm_context, logf, DEFAULT_LOG_DEST); 54169187Smarcel krb5_set_warn_dest(kcm_context, logf); 55160971Smarcel} 56169187Smarcel 57169187Smarcelchar* 58169187Smarcelkcm_log_msg_va(int level, const char *fmt, va_list ap) 59169187Smarcel{ 60160971Smarcel char *msg; 61160971Smarcel krb5_vlog_msg(kcm_context, logf, &msg, level, fmt, ap); 62160971Smarcel return msg; 63160971Smarcel} 64160971Smarcel 65169187Smarcelchar* 66169187Smarcelkcm_log_msg(int level, const char *fmt, ...) 67169187Smarcel{ 68169187Smarcel va_list ap; 69169187Smarcel char *s; 70169187Smarcel va_start(ap, fmt); 71160971Smarcel s = kcm_log_msg_va(level, fmt, ap); 72160971Smarcel va_end(ap); 73160971Smarcel return s; 74160971Smarcel} 75160971Smarcel 76160971Smarcelvoid 77160971Smarcelkcm_log(int level, const char *fmt, ...) 78160971Smarcel{ 79160971Smarcel va_list ap; 80160971Smarcel char *s; 81169187Smarcel va_start(ap, fmt); 82169187Smarcel s = kcm_log_msg_va(level, fmt, ap); 83181044Smarcel if(s) free(s); 84160971Smarcel va_end(ap); 85} 86