/* Copyright (c) 1996, Ruslan R. Laishev (@RRL) */ #include #include #include #include #include #include #include #include "nntp_log.h" #define INIT_SDESC(dsc, len, ptr) {(dsc).dsc$b_dtype = DSC$K_DTYPE_T;\ (dsc).dsc$b_class = DSC$K_CLASS_S; (dsc).dsc$w_length = (len);\ (dsc).dsc$a_pointer = (ptr);} 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; int lib$date_time (struct dsc$descriptor *); INIT_SDESC (dsc_dt,size,buf); lib$date_time (&dsc_dt); /* * 23-JUN-1997 17:36:03.97 , truncating at millisecondes */ *(buf+20) = 0; return buf; } /* *-------------------------------------------------------------------------------- */ int NNTP_LOG_ERR (char *s, long stat) { if (stat & 0) { NNTP_LOG(LOGW,"%s:%s",s,strerror(EVMSERR,stat)); return 0; } if (stat & 3) { NNTP_LOG(LOGW,"%s:%s",s,strerror(EVMSERR,stat)); return 0; } if (stat & 4) { NNTP_LOG(LOGS,"%s:%s",s,strerror(EVMSERR,stat)); return -1; } NNTP_LOG(LOGE,"%s:%s",s,strerror(EVMSERR,stat)); return -1; } /* *-------------------------------------------------------------------------------- */ void NNTP_LOG ( int lvl, const char *format, ...) { va_list ap; char buf [1024]; if ( lvl > nntp_conf.LogLevel ) return; va_start (ap, format); fprintf(stdout,"\n%s,%s",nntp_log_time (buf,sizeof(buf)),lvl_msg[lvl]); vsprintf(buf, format, ap); fputs(buf,stdout); va_end(ap); }