/* Copyright (c) 1996, Ruslan R. Laishev (@RRL) */ #include #include #include #include #include "nntp.h" char *lvl_msg[] ={ "%NNTP-I-", "%NNTP-F-", "%NNTP-S-", "%NNTP-E-", "%NNTP-W-", "%NNTP-D-" }; /* *-------------------------------------------------------------------------------- */ char *nntp_log_time ( char *buf, int size ) { struct dsc$descriptor dsc_dt; INIT_SDESC (dsc_dt,size,buf); lib$date_time (&dsc_dt); *(buf+20) = 0; return buf; } /* *-------------------------------------------------------------------------------- */ void NNTP_LOG ( int lvl, const char *format, ...) { va_list ap; char buf [2048],buf1[32]; short len; struct dsc$descriptor buf_dsc; if ( lvl > nntp_conf._w_loglevel ) return; len = sprintf(buf,"%s,%s",nntp_log_time (buf1,sizeof(buf1)),lvl_msg[lvl]); va_start (ap, format); len += vsprintf(&buf[len], format, ap); va_end(ap); INIT_SDESC(buf_dsc,len,buf); lib$put_output(&buf_dsc); } /* *-------------------------------------------------------------------------------- */ void NNTP_LOGT ( WCTX *Wctxp, int lvl, const char *format, ...) { va_list ap; char buf [2048],buf1[32]; char *type[] = {"Null","Suck","Feed","Clnt","Expr"}; short len; struct dsc$descriptor buf_dsc; if ( lvl > nntp_conf._w_loglevel ) return; if ( (Wctxp->wctx$b_type != nntp_conf._w_logtype) && nntp_conf._w_logtype ) return; len = sprintf(buf,"%s,%s[%s(%03d)]", nntp_log_time (buf1,sizeof(buf1)), lvl_msg[lvl], type[Wctxp->wctx$b_type], Wctxp->wctx$b_indx); va_start (ap, format); len += vsprintf(&buf[len], format, ap); va_end(ap); INIT_SDESC(buf_dsc,len,buf); lib$put_output(&buf_dsc); }