⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msgf.c

📁 实战Linux socket编程例题源代码
💻 C
字号:
/* 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -