blob: 6f1c1868a1b9c292b4b96f05cdd5e30a56de18a6 [file] [log] [blame]
Theodore Ts'o3839e651997-04-26 13:21:57 +00001.\" Copyright (c) 1988 Massachusetts Institute of Technology,
Theodore Ts'o1d0fc061999-10-23 02:51:33 +00002.\" Student Information Processing Board.
Theodore Ts'o3839e651997-04-26 13:21:57 +00003.\"
4.TH COM_ERR 3 "22 Nov 1988" SIPB
5.SH NAME
6com_err \- common error display routine
7.SH SYNOPSIS
8.nf
Theodore Ts'o1d0fc061999-10-23 02:51:33 +00009 #include <et/com_err.h>
Theodore Ts'o3839e651997-04-26 13:21:57 +000010.PP
11void com_err (whoami, code, format, ...);
12 const char *whoami;
13 long code;
14 const char *format;
15.PP
16proc = set_com_err_hook (proc);
17.fi
18void (*
19.I proc
20) (const char *, long, const char *, va_list);
21.nf
22.PP
23proc = reset_com_err_hook ();
24.PP
25void initialize_XXXX_error_table ();
26.fi
27.SH DESCRIPTION
28.I Com_err
29displays an error message on the standard error stream
30.I stderr
31(see
32.IR stdio (3S))
33composed of the
34.I whoami
35string, which should specify the program name or some subportion of
36a program, followed by an error message generated from the
37.I code
38value (derived from
39.IR compile_et (1)),
40and a string produced using the
41.I format
42string and any following arguments, in the same style as
43.IR fprintf (3).
44
45The behavior of
46.I com_err
47can be modified using
48.I set_com_err_hook;
49this defines a procedure which is called with the arguments passed to
50.I com_err,
51instead of the default internal procedure which sends the formatted
52text to error output. Thus the error messages from a program can all
53easily be diverted to another form of diagnostic logging, such as
54.IR syslog (3).
55.I Reset_com_err_hook
56may be used to restore the behavior of
57.I com_err
58to its default form. Both procedures return the previous ``hook''
59value. These ``hook'' procedures must have the declaration given for
60.I proc
61above in the synopsis.
62
63The
64.I initialize_XXXX_error_table
65routine is generated mechanically by
66.IR compile_et (1)
67from a source file containing names and associated strings. Each
68table has a name of up to four characters, which is used in place of
69the
70.B XXXX
71in the name of the routine. These routines should be called before
72any of the corresponding error codes are used, so that the
73.I com_err
74library will recognize error codes from these tables when they are
75used.
76
77The
78.B com_err.h
79header file should be included in any source file that uses routines
80from the
81.I com_err
82library; executable files must be linked using
83.I ``-lcom_err''
84in order to cause the
85.I com_err
86library to be included.
87
88.\" .IR for manual entries
89.\" .PP for paragraph breaks
90
91.SH "SEE ALSO"
92compile_et (1), syslog (3).
93
94Ken Raeburn, "A Common Error Description Library for UNIX".