Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Header file for common error description library. |
| 3 | * |
| 4 | * Copyright 1988, Student Information Processing Board of the |
| 5 | * Massachusetts Institute of Technology. |
| 6 | * |
| 7 | * For copyright and distribution info, see the documentation supplied |
| 8 | * with this package. |
| 9 | */ |
| 10 | |
Theodore Ts'o | 58f9d9e | 2003-05-06 00:31:55 -0400 | [diff] [blame] | 11 | #if !defined(__COM_ERR_H) && !defined(__COM_ERR_H__) |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 12 | |
Theodore Ts'o | 2540bb7 | 2003-11-26 23:19:28 -0500 | [diff] [blame] | 13 | #ifdef __GNUC__ |
| 14 | #define COM_ERR_ATTR(x) __attribute__(x) |
| 15 | #else |
| 16 | #define COM_ERR_ATTR(x) |
| 17 | #endif |
| 18 | |
Theodore Ts'o | 1601b10 | 2010-03-14 19:34:53 -0400 | [diff] [blame] | 19 | #include <stddef.h> |
Theodore Ts'o | 91835c1 | 2003-03-30 22:26:13 -0500 | [diff] [blame] | 20 | #include <stdarg.h> |
| 21 | |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 22 | typedef long errcode_t; |
| 23 | |
Theodore Ts'o | 00aba96 | 2003-03-19 19:46:02 -0500 | [diff] [blame] | 24 | struct error_table { |
| 25 | char const * const * msgs; |
Theodore Ts'o | 91835c1 | 2003-03-30 22:26:13 -0500 | [diff] [blame] | 26 | long base; |
Theodore Ts'o | 8ce2309 | 2003-11-22 13:54:38 -0500 | [diff] [blame] | 27 | int n_msgs; |
Theodore Ts'o | 00aba96 | 2003-03-19 19:46:02 -0500 | [diff] [blame] | 28 | }; |
Theodore Ts'o | 91835c1 | 2003-03-30 22:26:13 -0500 | [diff] [blame] | 29 | struct et_list; |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 30 | |
Theodore Ts'o | 2540bb7 | 2003-11-26 23:19:28 -0500 | [diff] [blame] | 31 | extern void com_err (const char *, long, const char *, ...) |
| 32 | COM_ERR_ATTR((format(printf, 3, 4))); |
| 33 | |
Theodore Ts'o | 91835c1 | 2003-03-30 22:26:13 -0500 | [diff] [blame] | 34 | extern void com_err_va (const char *whoami, errcode_t code, const char *fmt, |
Theodore Ts'o | 2540bb7 | 2003-11-26 23:19:28 -0500 | [diff] [blame] | 35 | va_list args) |
| 36 | COM_ERR_ATTR((format(printf, 3, 0))); |
| 37 | |
Theodore Ts'o | 91835c1 | 2003-03-30 22:26:13 -0500 | [diff] [blame] | 38 | extern char const *error_message (long); |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 39 | extern void (*com_err_hook) (const char *, long, const char *, va_list); |
Theodore Ts'o | efc6f62 | 2008-08-27 23:07:54 -0400 | [diff] [blame] | 40 | extern void (*set_com_err_hook (void (*) (const char *, long, |
Theodore Ts'o | 91835c1 | 2003-03-30 22:26:13 -0500 | [diff] [blame] | 41 | const char *, va_list))) |
| 42 | (const char *, long, const char *, va_list); |
Theodore Ts'o | efc6f62 | 2008-08-27 23:07:54 -0400 | [diff] [blame] | 43 | extern void (*reset_com_err_hook (void)) (const char *, long, |
Theodore Ts'o | 91835c1 | 2003-03-30 22:26:13 -0500 | [diff] [blame] | 44 | const char *, va_list); |
Theodore Ts'o | 58f9d9e | 2003-05-06 00:31:55 -0400 | [diff] [blame] | 45 | extern int init_error_table(const char * const *msgs, long base, int count); |
Theodore Ts'o | 4259052 | 2011-10-05 00:58:40 -0400 | [diff] [blame] | 46 | extern char *(*set_com_err_gettext (char *(*) (const char *))) |
| 47 | (const char *); |
Theodore Ts'o | 91835c1 | 2003-03-30 22:26:13 -0500 | [diff] [blame] | 48 | |
| 49 | extern errcode_t add_error_table(const struct error_table * et); |
| 50 | extern errcode_t remove_error_table(const struct error_table * et); |
| 51 | extern void add_to_error_table(struct et_list *new_table); |
| 52 | |
Theodore Ts'o | d035509 | 2003-05-05 23:07:32 -0400 | [diff] [blame] | 53 | /* Provided for Heimdall compatibility */ |
| 54 | extern const char *com_right(struct et_list *list, long code); |
Theodore Ts'o | 1601b10 | 2010-03-14 19:34:53 -0400 | [diff] [blame] | 55 | extern const char *com_right_r(struct et_list *list, long code, char *str, size_t len); |
Theodore Ts'o | efc6f62 | 2008-08-27 23:07:54 -0400 | [diff] [blame] | 56 | extern void initialize_error_table_r(struct et_list **list, |
| 57 | const char **messages, |
Theodore Ts'o | d035509 | 2003-05-05 23:07:32 -0400 | [diff] [blame] | 58 | int num_errors, |
| 59 | long base); |
| 60 | extern void free_error_table(struct et_list *et); |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 61 | |
Theodore Ts'o | d3395ae | 2009-04-22 14:41:32 -0400 | [diff] [blame] | 62 | /* Provided for compatibility with other com_err libraries */ |
| 63 | extern int et_list_lock(void); |
| 64 | extern int et_list_unlock(void); |
| 65 | |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 66 | #define __COM_ERR_H |
Theodore Ts'o | 58f9d9e | 2003-05-06 00:31:55 -0400 | [diff] [blame] | 67 | #define __COM_ERR_H__ |
| 68 | #endif /* !defined(__COM_ERR_H) && !defined(__COM_ERR_H__)*/ |