文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Advanced Programming in the...Sorrow

Advanced Programming in the...Sorrow

时间:2010-09-28  来源:ashbell

svn   git 

Git_Core,    Kernel 2.6.31.12-default   Backup this codes..........maybe.........


<<Advanced Programming in the UNIX Environment>>

                                           --Second Edition

                                           --By W.Richard Stevens  Stephen A. Rago


SouceCode: Online []  

            http://www.yendor.com/programming/unix/apue/apue.html

ApueBook: Website[]

                                       http://www.apuebook.com/

            include all source code in every chapter!

Error.h:  using vim creat a file named error.h ` # include sys_ret, sys_dump, sys_quit......and so on.......


/********************************************************** *this file use error include sys_ret(), sys_quit() ***********************************************************/

#include "apue.h"
#include <errno.h>
#include <stdarg.h>
static void err_doit(int errnoflag, int error, const char *fmt, va_list ap)
{
    char     buf[MAXLINE];
    vsnprintf(buf, MAXLINE, fmt, ap);
    if (errnoflag)
    snprintf(buf+strlen(buf), MAXLINE-strlen(buf), ":%s", strerror(error));
    strcat(buf, "\n");
    fputs(buf, stderr);
    fflush(NULL);
}
void err_ret(const char *fmt, ...)
{
    va_list        ap;
    va_start    (ap, fmt);
    err_doit(1, errno, fmt, ap);
    va_end(ap);
}
void err_sys(const char *fmt, ...)
{
    va_list        ap;
    va_start(ap, fmt);
    err_doit(1, errno, fmt, ap);
    va_end(ap);
    exit(1);
}
void err_exit(int error, const char *fmt, ...)
{
    va_list        ap;
    va_start(ap, fmt);
    err_doit(1, errno, fmt, ap);
    va_end(ap);
    exit(1);
}
void err_dump(const char *fmt, ...)
{
    va_list     ap;
    va_start(ap, fmt);
    err_doit(1, errno, fmt, ap);
    va_end(ap);
    abort();
    exit(1);
}
void err_msg(const char *fmt, ...)
{
    va_list        ap;
    va_start(ap, fmt);
    err_doit(0, 0, fmt, ap);
    va_end(ap);

}
void err_quit(const char *fmt, ...)
{
    va_list     ap;
    va_start(ap, fmt);
    err_doit(0, 0, fmt, ap);
    va_end(ap);
    exit(1);
}

 


相关阅读 更多 +
排行榜 更多 +
夕鸟

夕鸟

生活实用 下载
partyplay

partyplay

聊天通讯 下载
婚礼纪

婚礼纪

生活实用 下载