-
Notifications
You must be signed in to change notification settings - Fork 1
/
errmacros.h
63 lines (55 loc) · 1.38 KB
/
errmacros.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef __ERRMACROS_H__
#define __ERRMACROS_H__
#include <errno.h>
#define SYSCALL_ERROR(err) \
do { \
if ( (err) == -1 ) \
{ \
perror("Error executing syscall"); \
exit( EXIT_FAILURE ); \
} \
} while(0)
#define CHECK_MKFIFO(err) \
do { \
if ( (err) == -1 ) \
{ \
if ( errno != EEXIST ) \
{ \
perror("Error executing mkfifo"); \
exit( EXIT_FAILURE ); \
} \
} \
} while(0)
#define FILE_OPEN_ERROR(fp) \
do { \
if ( (fp) == NULL ) \
{ \
perror("File open failed"); \
exit( EXIT_FAILURE ); \
} \
} while(0)
#define FILE_CLOSE_ERROR(err) \
do { \
if ( (err) == -1 ) \
{ \
perror("File close failed"); \
exit( EXIT_FAILURE ); \
} \
} while(0)
#define ASPRINTF_ERROR(err) \
do { \
if ( (err) == -1 ) \
{ \
perror("asprintf failed"); \
exit( EXIT_FAILURE ); \
} \
} while(0)
#define FFLUSH_ERROR(err) \
do { \
if ( (err) == EOF ) \
{ \
perror("fflush failed"); \
exit( EXIT_FAILURE ); \
} \
} while(0)
#endif