UNIX/Linux系统调用_常用头文件
来源:互联网 发布:连体睡衣淘宝 编辑:程序博客网 时间:2024/06/09 18:39
#ifndef _APUE_H
#define _APUE_H
#define _XOPEN_SOURCE 600 /* Single UNIX Speciation v3*/
#include<sys/types.h> /*some systems still require this*/
#include<sys/stat.h>
#include<sys/termios.h> /*for winsize*/
#ifndef TIOCGWINSZ
#include <sys/ioctl.h>
#endif
#include<stdio.h>
#include<stdlib.h>
#include<stddef.h> /*for offsetof*/
#include<string.h>
#include<unistd.h>
#include<signal.h> /*for SIG_ERR*/
#define MAXLINE 4096
/* defalut file access permission for new file*/
#define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | IROHR)
/** Default permission for new directiories*/
#define DIR_MODE (FILE_MODE | S_IXUSR | S_IXGRP | S_IXOTH)
typedef void Sigfunc(int); /*for single handlers*/
#if defined(SIG_IGN) && ! defined(SIG_ERR)
#define SIG_ERR ((Sigfunc *)-1)
#endif
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
/*两套出错处理函数:以log_ 和 err_*/
void err_dump(const char*, ...);
void err_msg(const char*, ...);
void err_quit(const char*, ...);
void err_exit(const char*, ...);
void err_ret(const char*, ...);
void err_ret(const char*, ...);
void err_sys(const char*, ...);
void log_msg(const char*,...);
void log_open(const char*,int,int);
void log_quit(const char*,...);
void log_ret(const char*,...);
void log_sys(const char*,...);
#endif /*apue.h*/
-----------------------------------------------------------------------------------------------------------------
#include "apue.h"
#include<errno.h> /*for definition of errno*/
#include<stdarg.h> /*ISO C variable aruments,it define "va_list"*/
/*Nonfatal error related to system call,print a message and return*/
/*caller specifies "errorflag"*/
static void err_doit(int,int,const char *,va_list);
void err_quit(const char * fmt,...)
{
va_list ap;
va_start(ap,fmt);
err_doit(0,0,fmt,ap);
va_end(ap);
exit(0);
};
/*fatal error related to system call*/
/*print a message and return*/
void err_sys(const char * fmt,...)
{
va_list ap;
va_start(ap,fmt);
err_doit(0,errno,fmt,ap);
va_end(ap);
exit(0);
};
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");
fflush(stdout); /*in case stdout and stderr are the same*/
fputs(buf,stderr);
fflush(NULL); /*flush all stdio output streams*/
}
- UNIX/Linux系统调用_常用头文件
- UNIX & LINUX 系统头文件
- Unix/linux系统调用_目录与文件
- Linux系统常用头文件的说明
- Stuny Linux - 系统调用_文件访问
- Unix/Linux头文件说明
- Linux常用头文件
- Linux 常用头文件
- Linux常用头文件
- linux 常用头文件
- linux 常用头文件
- linux 常用头文件
- linux 常用头文件
- linux常用头文件
- linux常用头文件
- Linux常用头文件
- Linux 常用头文件
- linux常用头文件
- C++ STL中判断list为空,size()==0和empty()有什么区别
- 局域网共享设置图解教程(学校版)
- 通过CSS3 Media Query实现响应式Web设计
- 教你修改firebug的字体和大小
- 浅谈java工厂模式
- UNIX/Linux系统调用_常用头文件
- 判断是否有适当的应用能打开intent
- 枚举变量如何计算
- VS2008 编译 live555
- php 得到、修改、删除、配置文件
- 黑马程序员 java多线程笔记(二)
- 开源游戏AI引擎列表与游戏中的人工智能
- 用批处理批量压缩图片
- from.....import 与 import