-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauxlib.h
126 lines (105 loc) · 3.37 KB
/
auxlib.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Justin Lardinois [email protected]
// auxlib.h - auxiliary library for oc
#ifndef __AUXLIB_H__
#define __AUXLIB_H__
#include <stdarg.h>
//
// DESCRIPTION
// Auxiliary library containing miscellaneous useful things.
//
//
// Error message and exit status utility.
//
void set_execname (char* argv0);
//
// Sets the program name for use by auxlib messages.
// Must called from main before anything else is done,
// passing in argv[0].
//
const char* get_execname (void);
//
// Returns a read-only value previously stored by set_progname.
//
void eprint_status (const char* command, int status);
//
// Print the status returned by wait(2) from a subprocess.
//
int get_exitstatus (void);
//
// Returns the exit status. Default is EXIT_SUCCESS unless
// set_exitstatus (int) is called. The last statement in main
// should be: ``return get_exitstatus();''.
//
void set_exitstatus (int);
//
// Sets the exit status. Remebers only the largest value passed in.
//
void veprintf (const char* format, va_list args);
//
// Prints a message to stderr using the vector form of
// argument list.
//
void eprintf (const char* format, ...);
//
// Print a message to stderr according to the printf format
// specified. Usually called for debug output.
// Precedes the message by the program name if the format
// begins with the characters `%:'.
//
void errprintf (const char* format, ...);
//
// Print an error message according to the printf format
// specified, using eprintf. Sets the exitstatus to EXIT_FAILURE.
//
void syserrprintf (const char* object);
//
// Print a message resulting from a bad system call. The
// object is the name of the object causing the problem and
// the reason is taken from the external variable errno.
// Sets the exit status to EXIT_FAILURE.
//
//
// Support for stub messages.
//
#define STUBPRINTF(...) \
__stubprintf (__FILE__, __LINE__, __func__, __VA_ARGS__)
void __stubprintf (const char* file, int line, const char* func,
const char* format, ...);
//
// Debugging utility.
//
void set_debugflags (const char* flags);
//
// Sets a string of debug flags to be used by DEBUGF statements.
// Uses the address of the string, and does not copy it, so it
// must not be dangling. If a particular debug flag has been set,
// messages are printed. The format is identical to printf format.
// The flag "@" turns on all flags.
//
bool is_debugflag (char flag);
//
// Checks to see if a debugflag is set.
//
#ifdef NDEBUG
// Do not generate any code.
#define DEBUGF(FLAG,...) /**/
#define DEBUGSTMT(FLAG,STMTS) /**/
#else
// Generate debugging code.
void __debugprintf (char flag, const char* file, int line,
const char* func, const char* format, ...);
#define DEBUGF(FLAG,...) \
__debugprintf (FLAG, __FILE__, __LINE__, __func__, __VA_ARGS__)
#define DEBUGSTMT(FLAG,STMTS) \
if (is_debugflag (FLAG)) { DEBUGF (FLAG, "\n"); STMTS }
#endif
//
// Definition of RCSID macro to include RCS info in objs and execbin.
//
#define RCS3(ID,N,X) static const char ID##N[] = X;
#define RCS2(N,X) RCS3(RCS_Id,N,X)
#define RCSH(X) RCS2(__COUNTER__,X)
#define RCSC(X) RCSH(X \
"\0$Compiled: " __FILE__ " " __DATE__ " " __TIME__ " $")
RCSH("$Id: auxlib.h,v 1.1 2013-09-20 19:38:26-07 - - $")
#endif