xref: /aosp_15_r20/external/e2fsprogs/lib/et/com_err.h (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard Worker /*
2*6a54128fSAndroid Build Coastguard Worker  * Header file for common error description library.
3*6a54128fSAndroid Build Coastguard Worker  *
4*6a54128fSAndroid Build Coastguard Worker  * Copyright 1988, Student Information Processing Board of the
5*6a54128fSAndroid Build Coastguard Worker  * Massachusetts Institute of Technology.
6*6a54128fSAndroid Build Coastguard Worker  *
7*6a54128fSAndroid Build Coastguard Worker  * For copyright and distribution info, see the documentation supplied
8*6a54128fSAndroid Build Coastguard Worker  * with this package.
9*6a54128fSAndroid Build Coastguard Worker  */
10*6a54128fSAndroid Build Coastguard Worker 
11*6a54128fSAndroid Build Coastguard Worker #if !defined(__COM_ERR_H) && !defined(__COM_ERR_H__)
12*6a54128fSAndroid Build Coastguard Worker 
13*6a54128fSAndroid Build Coastguard Worker #ifdef __GNUC__
14*6a54128fSAndroid Build Coastguard Worker #define COM_ERR_ATTR(x) __attribute__(x)
15*6a54128fSAndroid Build Coastguard Worker #else
16*6a54128fSAndroid Build Coastguard Worker #define COM_ERR_ATTR(x)
17*6a54128fSAndroid Build Coastguard Worker #endif
18*6a54128fSAndroid Build Coastguard Worker 
19*6a54128fSAndroid Build Coastguard Worker #include <stddef.h>
20*6a54128fSAndroid Build Coastguard Worker #include <stdarg.h>
21*6a54128fSAndroid Build Coastguard Worker 
22*6a54128fSAndroid Build Coastguard Worker typedef long errcode_t;
23*6a54128fSAndroid Build Coastguard Worker 
24*6a54128fSAndroid Build Coastguard Worker struct error_table {
25*6a54128fSAndroid Build Coastguard Worker 	char const * const * msgs;
26*6a54128fSAndroid Build Coastguard Worker 	long base;
27*6a54128fSAndroid Build Coastguard Worker 	int n_msgs;
28*6a54128fSAndroid Build Coastguard Worker };
29*6a54128fSAndroid Build Coastguard Worker struct et_list;
30*6a54128fSAndroid Build Coastguard Worker 
31*6a54128fSAndroid Build Coastguard Worker extern void com_err (const char *, long, const char *, ...)
32*6a54128fSAndroid Build Coastguard Worker 	COM_ERR_ATTR((format(printf, 3, 4)));
33*6a54128fSAndroid Build Coastguard Worker 
34*6a54128fSAndroid Build Coastguard Worker extern void com_err_va (const char *whoami, errcode_t code, const char *fmt,
35*6a54128fSAndroid Build Coastguard Worker 		 va_list args)
36*6a54128fSAndroid Build Coastguard Worker 	COM_ERR_ATTR((format(printf, 3, 0)));
37*6a54128fSAndroid Build Coastguard Worker 
38*6a54128fSAndroid Build Coastguard Worker extern char const *error_message (long);
39*6a54128fSAndroid Build Coastguard Worker extern void (*com_err_hook) (const char *, long, const char *, va_list);
40*6a54128fSAndroid Build Coastguard Worker extern void (*set_com_err_hook (void (*) (const char *, long,
41*6a54128fSAndroid Build Coastguard Worker 					  const char *, va_list)))
42*6a54128fSAndroid Build Coastguard Worker 	(const char *, long, const char *, va_list);
43*6a54128fSAndroid Build Coastguard Worker extern void (*reset_com_err_hook (void)) (const char *, long,
44*6a54128fSAndroid Build Coastguard Worker 					  const char *, va_list);
45*6a54128fSAndroid Build Coastguard Worker extern int init_error_table(const char * const *msgs, long base, int count);
46*6a54128fSAndroid Build Coastguard Worker extern char *(*set_com_err_gettext (char *(*) (const char *)))
47*6a54128fSAndroid Build Coastguard Worker 	(const char *);
48*6a54128fSAndroid Build Coastguard Worker 
49*6a54128fSAndroid Build Coastguard Worker extern errcode_t add_error_table(const struct error_table * et);
50*6a54128fSAndroid Build Coastguard Worker extern errcode_t remove_error_table(const struct error_table * et);
51*6a54128fSAndroid Build Coastguard Worker extern void add_to_error_table(struct et_list *new_table);
52*6a54128fSAndroid Build Coastguard Worker 
53*6a54128fSAndroid Build Coastguard Worker /* Provided for Heimdall compatibility */
54*6a54128fSAndroid Build Coastguard Worker extern const char *com_right(struct et_list *list, long code);
55*6a54128fSAndroid Build Coastguard Worker extern const char *com_right_r(struct et_list *list, long code, char *str, size_t len);
56*6a54128fSAndroid Build Coastguard Worker extern void initialize_error_table_r(struct et_list **list,
57*6a54128fSAndroid Build Coastguard Worker 				     const char **messages,
58*6a54128fSAndroid Build Coastguard Worker 				     int num_errors,
59*6a54128fSAndroid Build Coastguard Worker 				     long base);
60*6a54128fSAndroid Build Coastguard Worker extern void free_error_table(struct et_list *et);
61*6a54128fSAndroid Build Coastguard Worker 
62*6a54128fSAndroid Build Coastguard Worker /* Provided for compatibility with other com_err libraries */
63*6a54128fSAndroid Build Coastguard Worker extern int et_list_lock(void);
64*6a54128fSAndroid Build Coastguard Worker extern int et_list_unlock(void);
65*6a54128fSAndroid Build Coastguard Worker 
66*6a54128fSAndroid Build Coastguard Worker #define __COM_ERR_H
67*6a54128fSAndroid Build Coastguard Worker #define __COM_ERR_H__
68*6a54128fSAndroid Build Coastguard Worker #endif /* !defined(__COM_ERR_H) && !defined(__COM_ERR_H__)*/
69