1 
2 /***************************************************************************
3  *                    __            __ _ ___________                       *
4  *                    \ \          / /| |____   ____|                      *
5  *                     \ \        / / | |    | |                           *
6  *                      \ \  /\  / /  | |    | |                           *
7  *                       \ \/  \/ /   | |    | |                           *
8  *                        \  /\  /    | |    | |                           *
9  *                         \/  \/     |_|    |_|                           *
10  *                                                                         *
11  *                           Wiimms ISO Tools                              *
12  *                         http://wit.wiimm.de/                            *
13  *                                                                         *
14  ***************************************************************************
15  *                                                                         *
16  *   This file is part of the WIT project.                                 *
17  *   Visit http://wit.wiimm.de/ for project details and sources.           *
18  *                                                                         *
19  *   Copyright (c) 2009-2013 by Dirk Clemens <wiimm@wiimm.de>              *
20  *                                                                         *
21  ***************************************************************************
22  *                                                                         *
23  *   This program is free software; you can redistribute it and/or modify  *
24  *   it under the terms of the GNU General Public License as published by  *
25  *   the Free Software Foundation; either version 2 of the License, or     *
26  *   (at your option) any later version.                                   *
27  *                                                                         *
28  *   This program is distributed in the hope that it will be useful,       *
29  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
30  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
31  *   GNU General Public License for more details.                          *
32  *                                                                         *
33  *   See file gpl-2.0.txt or http://www.gnu.org/licenses/gpl-2.0.txt       *
34  *                                                                         *
35  ***************************************************************************/
36 
37 #ifndef WIT_ERROR_H
38 #define WIT_ERROR_H 1
39 
40 //
41 ///////////////////////////////////////////////////////////////////////////////
42 ///////////////                  error messages                 ///////////////
43 ///////////////////////////////////////////////////////////////////////////////
44 
45 typedef enum enumError
46 {
47 	ERR_OK,
48 	ERR_DIFFER,
49 	ERR_NOTHING_TO_DO,
50 	ERR_NO_SOURCE_FOUND,
51 	ERR_JOB_IGNORED,
52 	ERR_WARNING,	// separator: below = real errors and not warnings
53 
54 	ERR_INVALID_FILE,
55 	ERR_INVALID_VERSION,
56 
57 	ERR_NO_WDF,
58 	ERR_WDF_VERSION,
59 	ERR_WDF_SPLIT,
60 	ERR_WDF_INVALID,
61 
62 	ERR_NO_CISO,
63 	ERR_CISO_INVALID,
64 
65 	ERR_WPART_INVALID,
66 	ERR_WDISC_INVALID,
67 	ERR_WDISC_NOT_FOUND,
68 
69 	ERR_NO_WBFS_FOUND,
70 	ERR_TO_MUCH_WBFS_FOUND,
71 	ERR_WBFS_INVALID,
72 
73 	ERR_NO_WIA,
74 	ERR_WIA_INVALID,
75 	ERR_BZIP2,
76 	ERR_LZMA,
77 
78 	ERR_ALREADY_EXISTS,
79 	ERR_CANT_OPEN,
80 	ERR_CANT_CREATE,
81 	ERR_CANT_CREATE_DIR,
82 	ERR_WRONG_FILE_TYPE,
83 	ERR_READ_FAILED,
84 	ERR_REMOVE_FAILED,
85 	ERR_WRITE_FAILED,
86 
87 	ERR_WBFS,
88 
89 	ERR_MISSING_PARAM,
90 	ERR_SEMANTIC,
91 	ERR_SYNTAX,
92 
93 	ERR_INTERRUPT,
94 
95 	ERR_ERROR,	// separator: below = hard/fatal errors => exit
96 
97 	ERR_NOT_IMPLEMENTED,
98 	ERR_INTERNAL,
99 	ERR_OUT_OF_MEMORY,
100 	ERR_FATAL,
101 
102 	ERR__N
103 
104 } enumError;
105 
106 //
107 ///////////////////////////////////////////////////////////////////////////////
108 ///////////////                  error interface                ///////////////
109 ///////////////////////////////////////////////////////////////////////////////
110 
111 extern enumError last_error;
112 extern enumError max_error;
113 extern u32 error_count;
114 
115 ///////////////////////////////////////////////////////////////////////////////
116 
117 const char * GetErrorName ( int stat );
118 const char * GetErrorText ( int stat );
119 int PrintError ( const char * func, const char * file, unsigned int line,
120 		int syserr, enumError err_code, const char * format, ... )
121 		__attribute__ ((__format__(__printf__,6,7)));
122 
123 #define OUT_OF_MEMORY PrintError(__FUNCTION__,__FILE__,__LINE__,0,ERR_OUT_OF_MEMORY,0)
124 
125 #define ERROR(se,code,...) PrintError(__FUNCTION__,__FILE__,__LINE__,se,code,__VA_ARGS__)
126 #define ERROR0(code,...) PrintError(__FUNCTION__,__FILE__,__LINE__,0,code,__VA_ARGS__)
127 #define ERROR1(code,...) PrintError(__FUNCTION__,__FILE__,__LINE__,errno,code,__VA_ARGS__)
128 
129 #define WD_ERROR ERROR0
130 
131 ///////////////////////////////////////////////////////////////////////////////
132 
133 void HexDump ( FILE * f, int indent, u64 addr, int addr_fw, int row_len,
134 		const void * data, size_t count );
135 void HexDump16 ( FILE * f, int indent, u64 addr,
136 		const void * data, size_t count );
137 
138 //
139 ///////////////////////////////////////////////////////////////////////////////
140 ///////////////                     END                         ///////////////
141 ///////////////////////////////////////////////////////////////////////////////
142 
143 #endif // WIT_ERROR_H 1
144