From: Ken Raeburn Date: Tue, 30 Jul 2002 23:41:45 +0000 (+0000) Subject: * log.c: Include stdarg.h. X-Git-Tag: krb5-1.3-alpha1~544 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=19cb77bdc9f65482b3dbf78f6d66d02cb482c2a4;p=krb5.git * log.c: Include stdarg.h. (krb_log): Use va_ macros and vfprintf instead of a bunch of pointer arguments. * krb4int.h (krb_log): Declaration updated. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14675 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb4/ChangeLog b/src/lib/krb4/ChangeLog index d25e6fac1..0f9259016 100644 --- a/src/lib/krb4/ChangeLog +++ b/src/lib/krb4/ChangeLog @@ -1,3 +1,10 @@ +2002-07-30 Ken Raeburn + + * log.c: Include stdarg.h. + (krb_log): Use va_ macros and vfprintf instead of a bunch of + pointer arguments. + * krb4int.h (krb_log): Declaration updated. + 2002-07-12 Ken Raeburn * ad_print.c, g_phost.c, g_tkt_svc.c, gethostname.c, mac_glue.c, diff --git a/src/lib/krb4/krb4int.h b/src/lib/krb4/krb4int.h index ecffcf190..54499d20f 100644 --- a/src/lib/krb4/krb4int.h +++ b/src/lib/krb4/krb4int.h @@ -29,8 +29,7 @@ int k_gethostname(char *, int); void kset_logfile(char *); /* log.c */ -void krb_log(char *, char *, char *, char *, char *, char *, char *, - char *, char *, char *, char *); +void krb_log(const char *, ...); void krb_set_logfile(char *); diff --git a/src/lib/krb4/log.c b/src/lib/krb4/log.c index 24cf1b18d..aabcf83cc 100644 --- a/src/lib/krb4/log.c +++ b/src/lib/krb4/log.c @@ -23,6 +23,7 @@ #include #endif #include +#include #include "krb4int.h" #include @@ -53,27 +54,27 @@ static is_open; * The return value is undefined. */ -/*VARARGS1 */ -void krb_log(format,a1,a2,a3,a4,a5,a6,a7,a8,a9,a0) - char *format; - char *a1,*a2,*a3,*a4,*a5,*a6,*a7,*a8,*a9,*a0; +void krb_log(const char *format,...) { FILE *logfile; time_t now; struct tm *tm; + va_list args; - if ((logfile = fopen(log_name,"a")) == NULL) - return; + va_start(args, format); - (void) time(&now); - tm = localtime(&now); + if ((logfile = fopen(log_name,"a")) != NULL) { + (void) time(&now); + tm = localtime(&now); - fprintf(logfile,"%2d-%s-%d %02d:%02d:%02d ",tm->tm_mday, - month_sname(tm->tm_mon + 1),1900+tm->tm_year, - tm->tm_hour, tm->tm_min, tm->tm_sec); - fprintf(logfile,format,a1,a2,a3,a4,a5,a6,a7,a8,a9,a0); - fprintf(logfile,"\n"); - (void) fclose(logfile); + fprintf(logfile,"%2d-%s-%d %02d:%02d:%02d ",tm->tm_mday, + month_sname(tm->tm_mon + 1),1900+tm->tm_year, + tm->tm_hour, tm->tm_min, tm->tm_sec); + vfprintf(logfile,format,args); + fprintf(logfile,"\n"); + (void) fclose(logfile); + } + va_end(args); return; }