Line |
Branch |
Exec |
Source |
1 |
|
|
#ifndef UTIL_EXITCODE_H |
2 |
|
|
#define UTIL_EXITCODE_H |
3 |
|
|
|
4 |
|
|
#include <stdio.h> |
5 |
|
|
|
6 |
|
|
// Semantic exit codes, as defined by BSD sysexits(3) |
7 |
|
|
enum { |
8 |
|
|
EC_OK = 0, // Exited normally (EX_OK) |
9 |
|
|
EC_USAGE_ERROR = 64, // Command line usage error (EX_USAGE) |
10 |
|
|
EC_DATA_ERROR = 65, // Input data error (EX_DATAERR) |
11 |
|
|
EC_OS_ERROR = 71, // Operating system error (EX_OSERR) |
12 |
|
|
EC_IO_ERROR = 74, // Input/output error (EX_IOERR) |
13 |
|
|
EC_CONFIG_ERROR = 78, // Configuration error (EX_CONFIG) |
14 |
|
|
}; |
15 |
|
|
|
16 |
|
|
// This exists purely for "self-documentation" purposes. Functions |
17 |
|
|
// returning this type should only return one of the above values. |
18 |
|
|
typedef int ExitCode; |
19 |
|
|
|
20 |
|
✗ |
static inline ExitCode ec_error(const char *prefix, ExitCode ec) |
21 |
|
|
{ |
22 |
|
✗ |
perror(prefix); |
23 |
|
✗ |
return ec; |
24 |
|
|
} |
25 |
|
|
|
26 |
|
|
#endif |
27 |
|
|
|