• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef ERROR_H
2 #define ERROR_H
3 /*
4  * Create a squashfs filesystem.  This is a highly compressed read only
5  * filesystem.
6  *
7  * Copyright (c) 2012, 2013, 2014
8  * Phillip Lougher <phillip@squashfs.org.uk>
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2,
13  * or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23  *
24  * error.h
25  */
26 
27 extern int exit_on_error;
28 
29 extern void prep_exit();
30 extern void progressbar_error(char *fmt, ...);
31 extern void progressbar_info(char *fmt, ...);
32 
33 #ifdef SQUASHFS_TRACE
34 #define TRACE(s, args...) \
35 		do { \
36 			progressbar_info("squashfs: "s, ## args);\
37 		} while(0)
38 #else
39 #define TRACE(s, args...)
40 #endif
41 
42 #define INFO(s, args...) \
43 		do {\
44 			 if(!silent)\
45 				progressbar_info(s, ## args);\
46 		} while(0)
47 
48 #define ERROR(s, args...) \
49 		do {\
50 			progressbar_error(s, ## args); \
51 		} while(0)
52 
53 #define ERROR_START(s, args...) \
54 		do { \
55 			disable_progress_bar(); \
56 			fprintf(stderr, s, ## args); \
57 		} while(0)
58 
59 #define ERROR_EXIT(s, args...) \
60 		do {\
61 			if (exit_on_error) { \
62 				fprintf(stderr, "\n"); \
63 				EXIT_MKSQUASHFS(); \
64 			} else { \
65 				fprintf(stderr, s, ## args); \
66 				enable_progress_bar(); \
67 			} \
68 		} while(0)
69 
70 #define EXIT_MKSQUASHFS() \
71 		do {\
72 			prep_exit();\
73 			exit(1);\
74 		} while(0)
75 
76 #define BAD_ERROR(s, args...) \
77 		do {\
78 			progressbar_error("FATAL ERROR:" s, ##args); \
79 			EXIT_MKSQUASHFS();\
80 		} while(0)
81 
82 #define EXIT_UNSQUASH(s, args...) BAD_ERROR(s, ##args)
83 
84 #define MEM_ERROR() \
85 	do {\
86 		progressbar_error("FATAL ERROR: Out of memory (%s)\n", \
87 								__func__); \
88 		EXIT_MKSQUASHFS();\
89 	} while(0)
90 #endif
91