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