msgf.c
来自「目前已经有很多介绍计算机网络的书籍」· C语言 代码 · 共 48 行
C
48 行
/* msgf.c : * * Format and log a server message : */#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <errno.h>#include <stdarg.h>#include <syslog.h>#include <sys/types.h>#include "quotes.h"#define MAX_MSGBUF 256/* * Report formatted message : */voidmsgf(char type,const char *format,...) { int er = errno; /* Save errno */ int mtype; va_list ap; char msgbuf[MAX_MSGBUF]; switch ( type ) { case 'w' : mtype = LOG_WARNING; break; case 'e' : mtype = LOG_ERR; break; case 'i' : default : mtype = LOG_INFO; } va_start(ap,format); vsnprintf(msgbuf,sizeof msgbuf-1, format,ap); va_end(ap); syslog(mtype,"%s",msgbuf); errno = er; /* Restore errno */}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?