1 /*
2  * File:   ErrorContext.h
3  * Author: Yavor Nikolov
4  *
5  * Created on 29 October 2011, 18:14
6  */
7 
8 #ifndef ERRORCONTEXT_H
9 #define ERRORCONTEXT_H
10 
11 #include "pbzip2.h"
12 
13 namespace pbzip2
14 {
15 
16 class ErrorContext
17 {
18 private:
19 	static ErrorContext * _instance;
20 	static pthread_mutex_t _err_ctx_mutex;
21 
22 	int _first_kernel_err_no;
23 	int _last_kernel_err_no;
24 
25 private:
ErrorContext()26 	ErrorContext():
27 		_first_kernel_err_no( 0 ),
28 		_last_kernel_err_no( 0 )
29 	{
30 	}
31 
32 	ErrorContext( ErrorContext const & s );
33 	void operator=( ErrorContext const & s );
34 public:
35 	static ErrorContext * getInstance();
36 	void printErrorMessages( FILE * out = stderr );
37 	void saveError();
38 	void reset();
39 
40 	static void printErrnoMsg( FILE * out, int err );
41 	static void syncPrintErrnoMsg( FILE * out, int err );
42 };
43 
44 } // namespace pbzip2
45 
46 #endif /* ERRORCONTEXT_H */
47 
48