postfix 代码生存手册

需要输出调试信息用 msg_info 函数,语法同 printf。
日志打在 syslog 里,Ubuntu 默认路径为 /var/log/mail.log

改造 msg_info,使其能够输出文件名及行号。msg.h 的函数声明改成:
#ifdef NO_LINE_NUMBER
extern void PRINTFLIKE(1, 2) msg_info(const char *,...);
#else
extern void msg_info_ext(const char *, const unsigned int, const char *,...);
#define msg_info(fmt,args...) msg_info_ext(__FILE__,__LINE__,(fmt),##args)
#endif

原来的函数定义 msg.c:msg_info 改成
void    msg_info_ext( const char *file
, const unsigned int line_number
, const char *fmt,...)
{

char buff[1024*5] = {0};

snprintf(buff, sizeof(buff), "(%s:%d) ", file, line_number);
strncat(buff, fmt, sizeof(buff)-strlen(buff)-1);

va_list ap;

va_start(ap, fmt);
msg_vprintf(MSG_INFO, buff, ap);
va_end(ap);
}

借助 mantools 下的工具从源代码生成 man 手册。
postfix@ami-nda:~/postfix-2.8.2/src/util$ ../../mantools/srctoman vstream.c | head
.TH VSTREAM 3
.ad
.fi
.SH NAME
vstream
\-
light-weight buffered I/O package
.SH "SYNOPSIS"
.na
.nf
postfix@ami-nda:~/postfix-2.8.2/src/util$ ../../mantools/srctoman vstream.c > VSTREAM.3
postfix@ami-nda:~/postfix-2.8.2/src/util$ man ./VSTREAM.3
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值