blob: 27a36ea07a0bab671afa77dd97bdab5e6f599fd7 [file] [log] [blame]
Theodore Ts'o3839e651997-04-26 13:21:57 +00001/*
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'o58f9d9e2003-05-06 00:31:55 -040011#if !defined(__COM_ERR_H) && !defined(__COM_ERR_H__)
Theodore Ts'o3839e651997-04-26 13:21:57 +000012
Theodore Ts'o2540bb72003-11-26 23:19:28 -050013#ifdef __GNUC__
14#define COM_ERR_ATTR(x) __attribute__(x)
15#else
16#define COM_ERR_ATTR(x)
17#endif
18
Theodore Ts'o1601b102010-03-14 19:34:53 -040019#include <stddef.h>
Theodore Ts'o91835c12003-03-30 22:26:13 -050020#include <stdarg.h>
21
Theodore Ts'o3839e651997-04-26 13:21:57 +000022typedef long errcode_t;
23
Theodore Ts'o00aba962003-03-19 19:46:02 -050024struct error_table {
25 char const * const * msgs;
Theodore Ts'o91835c12003-03-30 22:26:13 -050026 long base;
Theodore Ts'o8ce23092003-11-22 13:54:38 -050027 int n_msgs;
Theodore Ts'o00aba962003-03-19 19:46:02 -050028};
Theodore Ts'o91835c12003-03-30 22:26:13 -050029struct et_list;
Theodore Ts'of3db3561997-04-26 13:34:30 +000030
Theodore Ts'o2540bb72003-11-26 23:19:28 -050031extern void com_err (const char *, long, const char *, ...)
32 COM_ERR_ATTR((format(printf, 3, 4)));
33
Theodore Ts'o91835c12003-03-30 22:26:13 -050034extern void com_err_va (const char *whoami, errcode_t code, const char *fmt,
Theodore Ts'o2540bb72003-11-26 23:19:28 -050035 va_list args)
36 COM_ERR_ATTR((format(printf, 3, 0)));
37
Theodore Ts'o91835c12003-03-30 22:26:13 -050038extern char const *error_message (long);
Theodore Ts'of3db3561997-04-26 13:34:30 +000039extern void (*com_err_hook) (const char *, long, const char *, va_list);
Theodore Ts'oefc6f622008-08-27 23:07:54 -040040extern void (*set_com_err_hook (void (*) (const char *, long,
Theodore Ts'o91835c12003-03-30 22:26:13 -050041 const char *, va_list)))
42 (const char *, long, const char *, va_list);
Theodore Ts'oefc6f622008-08-27 23:07:54 -040043extern void (*reset_com_err_hook (void)) (const char *, long,
Theodore Ts'o91835c12003-03-30 22:26:13 -050044 const char *, va_list);
Theodore Ts'o58f9d9e2003-05-06 00:31:55 -040045extern int init_error_table(const char * const *msgs, long base, int count);
Theodore Ts'o42590522011-10-05 00:58:40 -040046extern char *(*set_com_err_gettext (char *(*) (const char *)))
47 (const char *);
Theodore Ts'o91835c12003-03-30 22:26:13 -050048
49extern errcode_t add_error_table(const struct error_table * et);
50extern errcode_t remove_error_table(const struct error_table * et);
51extern void add_to_error_table(struct et_list *new_table);
52
Theodore Ts'od0355092003-05-05 23:07:32 -040053/* Provided for Heimdall compatibility */
54extern const char *com_right(struct et_list *list, long code);
Theodore Ts'o1601b102010-03-14 19:34:53 -040055extern const char *com_right_r(struct et_list *list, long code, char *str, size_t len);
Theodore Ts'oefc6f622008-08-27 23:07:54 -040056extern void initialize_error_table_r(struct et_list **list,
57 const char **messages,
Theodore Ts'od0355092003-05-05 23:07:32 -040058 int num_errors,
59 long base);
60extern void free_error_table(struct et_list *et);
Theodore Ts'o3839e651997-04-26 13:21:57 +000061
Theodore Ts'od3395ae2009-04-22 14:41:32 -040062/* Provided for compatibility with other com_err libraries */
63extern int et_list_lock(void);
64extern int et_list_unlock(void);
65
Theodore Ts'o3839e651997-04-26 13:21:57 +000066#define __COM_ERR_H
Theodore Ts'o58f9d9e2003-05-06 00:31:55 -040067#define __COM_ERR_H__
68#endif /* !defined(__COM_ERR_H) && !defined(__COM_ERR_H__)*/