forked from RangeNetworks/CommonLibs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Exit.h
60 lines (53 loc) · 1.61 KB
/
Exit.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
/*
* Copyright 2014 Range Networks, Inc.
* All Rights Reserved.
*
* This software is distributed under multiple licenses;
* see the COPYING file in the main directory for licensing
* information for this specific distribution.
*
* This use of this software may be subject to additional restrictions.
* See the LEGAL file in the main directory for details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef EXIT_H
#define EXIT_H
#include <list>
#include <sys/types.h>
#include <signal.h>
#include "Threads.h"
/** A C++ wrapper for managing exit codes. Note that this is a helper class
* without implementation.
*/
class Exit
{
public:
enum eCodes
{
SUCCESS = 0, // no error
DETECTFILE, // Unable to detect a required file: CommonLibs SelfDetect
CREATEFILE, // Unable to create a required file: CommonLibs SelfDetect
// Put all error codes above this line, to prevent error number values
// from changing, put after the previous enum value (ie, preserve
// the order. Also, provide a comment indicating which program(s) and
// the purpose.
LIMIT = 256 // all error codes must be less than this
};
private:
inline Exit(void) { /* cannot be constructed */; };
inline ~Exit(void) { /* cannot be destructed */; };
public:
inline static void exit(int status)
{
if (status < SUCCESS || status >= LIMIT)
{
printf("INFO: Unsupported exit status of %d\n", status);
}
::exit(status);
/*NOTREACHED*/
}
};
#endif // EXIT_H
// vim: ts=4 sw=4