| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | .\" $NetBSD: com_err.3,v 1.2 2008/04/30 13:10:51 martin Exp $ | | 1 | .\" $NetBSD: com_err.3,v 1.3 2011/04/28 14:59:27 wiz Exp $ |
2 | .\" | | 2 | .\" |
3 | .\" Copyright (c) 2001 The NetBSD Foundation, Inc. | | 3 | .\" Copyright (c) 2001 The NetBSD Foundation, Inc. |
4 | .\" All rights reserved. | | 4 | .\" All rights reserved. |
5 | .\" | | 5 | .\" |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | | 6 | .\" This code is derived from software contributed to The NetBSD Foundation |
7 | .\" by Gregory McGarry. | | 7 | .\" by Gregory McGarry. |
8 | .\" | | 8 | .\" |
9 | .\" Redistribution and use in source and binary forms, with or without | | 9 | .\" Redistribution and use in source and binary forms, with or without |
10 | .\" modification, are permitted provided that the following conditions | | 10 | .\" modification, are permitted provided that the following conditions |
11 | .\" are met: | | 11 | .\" are met: |
12 | .\" 1. Redistributions of source code must retain the above copyright | | 12 | .\" 1. Redistributions of source code must retain the above copyright |
13 | .\" notice, this list of conditions and the following disclaimer. | | 13 | .\" notice, this list of conditions and the following disclaimer. |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright |
| @@ -32,88 +32,94 @@ | | | @@ -32,88 +32,94 @@ |
32 | .Os | | 32 | .Os |
33 | .Sh NAME | | 33 | .Sh NAME |
34 | .Nm com_err , | | 34 | .Nm com_err , |
35 | .Nm com_err_va , | | 35 | .Nm com_err_va , |
36 | .Nm error_message , | | 36 | .Nm error_message , |
37 | .Nm error_table_name , | | 37 | .Nm error_table_name , |
38 | .Nm init_error_table , | | 38 | .Nm init_error_table , |
39 | .Nm set_com_err_hook , | | 39 | .Nm set_com_err_hook , |
40 | .Nm reset_com_err_hook | | 40 | .Nm reset_com_err_hook |
41 | .Nd common error display library | | 41 | .Nd common error display library |
42 | .Sh LIBRARY | | 42 | .Sh LIBRARY |
43 | Common Error Library (libcom_err, -lcom_err) | | 43 | Common Error Library (libcom_err, -lcom_err) |
44 | .Sh SYNOPSIS | | 44 | .Sh SYNOPSIS |
45 | .Fd #include <stdio.h> | | 45 | .In stdio.h |
46 | .Fd #include <stdarg.h> | | 46 | .In stdarg.h |
47 | .Fd #include <krb5/com_err.h> | | 47 | .In krb5/com_err.h |
48 | .Fd #include \&"XXX_err.h\&" | | 48 | .In \&"XXX_err.h\&" |
49 | .Pp | | 49 | .Pp |
50 | typedef void (*errf)(const char *, long, const char *, ...); | | 50 | typedef void (*errf)(const char *, long, const char *, ...); |
51 | .Ft void | | 51 | .Ft void |
52 | .Fn com_err "const char *whoami" "long code" "const char *format" "..." | | 52 | .Fn com_err "const char *whoami" "long code" "const char *format" "..." |
53 | .Ft void | | 53 | .Ft void |
54 | .Fn com_err_va "const char *whoami" "long code" "const char *format" "..." | | 54 | .Fn com_err_va "const char *whoami" "long code" "const char *format" "..." |
55 | .Ft const char * | | 55 | .Ft const char * |
56 | .Fn error_message "long code" | | 56 | .Fn error_message "long code" |
57 | .Ft const char * | | 57 | .Ft const char * |
58 | .Fn error_table_name "int num" | | 58 | .Fn error_table_name "int num" |
59 | .Ft int | | 59 | .Ft int |
60 | .Fn init_error_table "const char **msgs" "long base" "int count" | | 60 | .Fn init_error_table "const char **msgs" "long base" "int count" |
61 | .Ft errf | | 61 | .Ft errf |
62 | .Fn set_com_err_hook "errf func" | | 62 | .Fn set_com_err_hook "errf func" |
63 | .Ft errf | | 63 | .Ft errf |
64 | .Fn reset_com_err_hook "" | | 64 | .Fn reset_com_err_hook "" |
65 | .Ft void | | 65 | .Ft void |
66 | .Fn add_to_error_table "struct et_list *new_table" | | 66 | .Fn add_to_error_table "struct et_list *new_table" |
67 | .Sh DESCRIPTION | | 67 | .Sh DESCRIPTION |
68 | The | | 68 | The |
69 | .Nm | | 69 | .Nm |
70 | library provides a common error-reporting mechanism for defining and | | 70 | library provides a common error-reporting mechanism for defining and |
71 | accessing error codes and descriptions for application software | | 71 | accessing error codes and descriptions for application software |
72 | packages. Error descriptions are defined in a table and error codes | | 72 | packages. |
73 | are used to index the table. The error table, the descriptions and | | 73 | Error descriptions are defined in a table and error codes are used |
74 | the error codes are generated using | | 74 | to index the table. |
| | | 75 | The error table, the descriptions and the error codes are generated |
| | | 76 | using |
75 | .Xr compile_et 1 . | | 77 | .Xr compile_et 1 . |
76 | .Pp | | 78 | .Pp |
77 | The error table is registered with the | | 79 | The error table is registered with the |
78 | .Nm | | 80 | .Nm |
79 | library by calling its initialisation function defined in its header | | 81 | library by calling its initialisation function defined in its header |
80 | file. The initialisation function is generally defined as | | 82 | file. |
| | | 83 | The initialisation function is generally defined as |
81 | .Fn initialize_<name>_error_table , | | 84 | .Fn initialize_<name>_error_table , |
82 | where | | 85 | where |
83 | .Em name | | 86 | .Em name |
84 | is the name of the error table. | | 87 | is the name of the error table. |
85 | .Pp | | 88 | .Pp |
86 | Any variable which is to contain an error code should be declared | | 89 | Any variable which is to contain an error code should be declared |
87 | .Em <name>_error_number | | 90 | .Em <name>_error_number |
88 | where | | 91 | where |
89 | .Em name | | 92 | .Em name |
90 | is the name of the error table. | | 93 | is the name of the error table. |
91 | .Sh FUNCTIONS | | 94 | .Sh FUNCTIONS |
92 | The following functions are available to the application developer: | | 95 | The following functions are available to the application developer: |
93 | .Bl -tag -width compact | | 96 | .Bl -tag -width compact |
94 | .It Fn com_err "whoami" "code" "format" "..." | | 97 | .It Fn com_err "whoami" "code" "format" "..." |
95 | Displays an error message on standard error composed of the | | 98 | Displays an error message on standard error composed of the |
96 | .Fa whoami | | 99 | .Fa whoami |
97 | string, which should specify the program name, followed by an error | | 100 | string, which should specify the program name, followed by an error |
98 | message generated from | | 101 | message generated from |
99 | .Fa code , | | 102 | .Fa code , |
100 | and a string produced using the | | 103 | and a string produced using the |
101 | .Xr printf 3 | | 104 | .Xr printf 3 |
102 | .Fa format | | 105 | .Fa format |
103 | string and any following arguments. If | | 106 | string and any following arguments. |
| | | 107 | If |
104 | .Fa format | | 108 | .Fa format |
105 | is NULL, the formatted message will not be | | 109 | is |
106 | printed. The argument | | 110 | .Dv NULL , |
| | | 111 | the formatted message will not be printed. |
| | | 112 | The argument |
107 | .Fa format | | 113 | .Fa format |
108 | may not be omitted. | | 114 | may not be omitted. |
109 | .It Fn com_err_va "whoami" "code" "format" "va_list args" | | 115 | .It Fn com_err_va "whoami" "code" "format" "va_list args" |
110 | This routine provides an interface, equivalent to | | 116 | This routine provides an interface, equivalent to |
111 | .Fn com_err , | | 117 | .Fn com_err , |
112 | which may be used by higher-level variadic functions (functions which | | 118 | which may be used by higher-level variadic functions (functions which |
113 | accept variable numbers of arguments). | | 119 | accept variable numbers of arguments). |
114 | .It Fn error_message "code" | | 120 | .It Fn error_message "code" |
115 | Returns the character string error message associate with | | 121 | Returns the character string error message associate with |
116 | .Fa code . | | 122 | .Fa code . |
117 | If | | 123 | If |
118 | .Fa code is associated with an unknown error table, or if | | 124 | .Fa code is associated with an unknown error table, or if |
119 | .Fa code | | 125 | .Fa code |
| @@ -145,28 +151,29 @@ custom error tables that have not been g | | | @@ -145,28 +151,29 @@ custom error tables that have not been g |
145 | Although this routine is available for use when needed, its use should | | 151 | Although this routine is available for use when needed, its use should |
146 | be restricted. | | 152 | be restricted. |
147 | .It Fn set_com_err_hook "func" | | 153 | .It Fn set_com_err_hook "func" |
148 | Provides a hook into the | | 154 | Provides a hook into the |
149 | .Nm | | 155 | .Nm |
150 | library to allow the routine | | 156 | library to allow the routine |
151 | .Fa func | | 157 | .Fa func |
152 | to be dynamically substituted for | | 158 | to be dynamically substituted for |
153 | .Fn com_err . | | 159 | .Fn com_err . |
154 | After | | 160 | After |
155 | .Fn set_com_err_hook | | 161 | .Fn set_com_err_hook |
156 | has been called, calls to | | 162 | has been called, calls to |
157 | .Fn com_err | | 163 | .Fn com_err |
158 | will turn into calls to the new hook routine. This function is | | 164 | will turn into calls to the new hook routine. |
159 | intended to be used in daemons to use a routine which calls | | 165 | This function is intended to be used in daemons to use a routine |
| | | 166 | which calls |
160 | .Xr syslog 3 , | | 167 | .Xr syslog 3 , |
161 | or in a window system application to pop up a dialogue box. | | 168 | or in a window system application to pop up a dialogue box. |
162 | .It Fn reset_com_err_hook "" | | 169 | .It Fn reset_com_err_hook "" |
163 | Turns off the hook set in | | 170 | Turns off the hook set in |
164 | .Fn set_com_err_hook . | | 171 | .Fn set_com_err_hook . |
165 | .It Fn add_to_error_table "new_table" | | 172 | .It Fn add_to_error_table "new_table" |
166 | Add the error table, its messages strings and error codes in | | 173 | Add the error table, its messages strings and error codes in |
167 | .Fa new_table | | 174 | .Fa new_table |
168 | to the internal error table. | | 175 | to the internal error table. |
169 | .El | | 176 | .El |
170 | .Sh EXAMPLES | | 177 | .Sh EXAMPLES |
171 | The following is an example using the table defined in | | 178 | The following is an example using the table defined in |
172 | .Xr compile_et 1 : | | 179 | .Xr compile_et 1 : |