| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | .\" $NetBSD: compile_et.1,v 1.5 2010/04/05 21:33:09 pgoyette Exp $ | | 1 | .\" $NetBSD: compile_et.1,v 1.6 2011/04/28 15:01: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 |
| @@ -25,94 +25,99 @@ | | | @@ -25,94 +25,99 @@ |
25 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 25 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
26 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 26 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
27 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 27 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
28 | .\" POSSIBILITY OF SUCH DAMAGE. | | 28 | .\" POSSIBILITY OF SUCH DAMAGE. |
29 | .\" | | 29 | .\" |
30 | .Dd November 9, 2001 | | 30 | .Dd November 9, 2001 |
31 | .Dt COMPILE_ET 1 | | 31 | .Dt COMPILE_ET 1 |
32 | .Os | | 32 | .Os |
33 | .Sh NAME | | 33 | .Sh NAME |
34 | .Nm compile_et | | 34 | .Nm compile_et |
35 | .Nd error table compiler | | 35 | .Nd error table compiler |
36 | .Sh SYNOPSIS | | 36 | .Sh SYNOPSIS |
37 | .Nm | | 37 | .Nm |
38 | .Op Ar --version | | 38 | .Op Fl Fl help |
39 | .Op Ar --help | | 39 | .Op Fl Fl version |
40 | .Ar file | | 40 | .Ar file |
41 | .Sh DESCRIPTION | | 41 | .Sh DESCRIPTION |
42 | The | | 42 | The |
43 | .Nm | | 43 | .Nm |
44 | utility reads the table describing error-code names and their | | 44 | utility reads the table describing error-code names and their |
45 | associated messages in the file | | 45 | associated messages in the file |
46 | .Ar file | | 46 | .Ar file |
47 | and generates a C source file suitable for use with the | | 47 | and generates a C source file suitable for use with the |
48 | .Xr com_err 3 | | 48 | .Xr com_err 3 |
49 | library. The source file | | 49 | library. |
| | | 50 | The source file |
50 | .Ar file | | 51 | .Ar file |
51 | must end with a suffix of | | 52 | must end with a suffix of |
52 | .Dq .et | | 53 | .Dq .et |
53 | and | | 54 | and |
54 | .Nm | | 55 | .Nm |
55 | writes a C header file | | 56 | writes a C header file |
56 | .Pa file.h | | 57 | .Pa file.h |
57 | which contains definitions of the numerical values of the error codes | | 58 | which contains definitions of the numerical values of the error codes |
58 | defined in the error table and a C source file | | 59 | defined in the error table and a C source file |
59 | .Pa file.c | | 60 | .Pa file.c |
60 | which should be compiled and linked with the executable. | | 61 | which should be compiled and linked with the executable. |
61 | .Pp | | 62 | .Pp |
62 | The source file is a plain ASCII text file. A | | 63 | The source file is a plain ASCII text file. |
| | | 64 | A |
63 | .Dq \&# | | 65 | .Dq \&# |
64 | in the source file | | 66 | in the source file |
65 | is treated as a comment character, and all remaining text to the end | | 67 | is treated as a comment character, and all remaining text to the end |
66 | of the source line will be ignored. The source file consists of the | | 68 | of the source line will be ignored. |
67 | following declarations: | | 69 | The source file consists of the following declarations: |
68 | .Bl -tag -offset indent -width XXXXXX | | 70 | .Bl -tag -offset indent -width XXXXXX |
69 | .It id [ Em base ] Em string | | 71 | .It id [ Em base ] Em string |
70 | Defines an identification string (such as a version string) which is | | 72 | Defines an identification string (such as a version string) which is |
71 | recorded in the generated files. It is mandatory and must be the | | 73 | recorded in the generated files. |
72 | first declaration in the source file. | | 74 | It is mandatory and must be the first declaration in the source |
| | | 75 | file. |
73 | .It et Em name | | 76 | .It et Em name |
74 | Specifies the name of the error table to be | | 77 | Specifies the name of the error table to be |
75 | .Em name . | | 78 | .Em name . |
76 | It is mandatory and must be declared after the id declaration and | | 79 | It is mandatory and must be declared after the id declaration and |
77 | before all other declarations. The name of table is limited to four | | 80 | before all other declarations. |
78 | ASCII characters. The optional argument | | 81 | The name of table is limited to four ASCII characters. |
| | | 82 | The optional argument |
79 | .Em base | | 83 | .Em base |
80 | specifies the base value of error codes the table. | | 84 | specifies the base value of error codes the table. |
81 | .Pp | | 85 | .Pp |
82 | The name of the table is used to construct the name of a function | | 86 | The name of the table is used to construct the name of a function |
83 | .Fn initialize_<name>_error_table | | 87 | .Fn initialize_<name>_error_table |
84 | which must be called to register the error table with the | | 88 | which must be called to register the error table with the |
85 | .Xr com_err 3 | | 89 | .Xr com_err 3 |
86 | library. A re-entrant (thread-safe) version called | | 90 | library. |
| | | 91 | A re-entrant (thread-safe) version called |
87 | .Fn initialize_<name>_error_table_r | | 92 | .Fn initialize_<name>_error_table_r |
88 | is also defined. | | 93 | is also defined. |
89 | .It prefix Op Em string | | 94 | .It prefix Op Em string |
90 | Defines a prefix to be applied to all error code names. If no string | | 95 | Defines a prefix to be applied to all error code names. |
91 | is specified, the prefix is not defined. It is an optional | | 96 | If no string is specified, the prefix is not defined. |
92 | declaration and can appear more than once. | | 97 | It is an optional declaration and can appear more than once. |
93 | .It index Em val | | 98 | .It index Em val |
94 | Specifies the index | | 99 | Specifies the index |
95 | .Em val | | 100 | .Em val |
96 | in the error table for the following error code declaration. | | 101 | in the error table for the following error code declaration. |
97 | Subsequent error codes are allocated sequentially from the same value. | | 102 | Subsequent error codes are allocated sequentially from the same value. |
98 | It is an optional declaration and can appear more than once. | | 103 | It is an optional declaration and can appear more than once. |
99 | .It ec Em cname , Em msg | | 104 | .It ec Em cname , Em msg |
100 | Defines an error code with the name | | 105 | Defines an error code with the name |
101 | .Em cname | | 106 | .Em cname |
102 | and its associated error message | | 107 | and its associated error message |
103 | .Em msg . | | 108 | .Em msg . |
104 | The error codes are assigned sequentially increasing numbers. The | | 109 | The error codes are assigned sequentially increasing numbers. |
105 | name is placed into the C header file as an enumerated type. | | 110 | The name is placed into the C header file as an enumerated type. |
106 | .It end | | 111 | .It end |
107 | Indicates the end of the error table. | | 112 | Indicates the end of the error table. |
108 | .El | | 113 | .El |
109 | .Pp | | 114 | .Pp |
110 | To maintain compatibility, new codes should be added to the end of an | | 115 | To maintain compatibility, new codes should be added to the end of an |
111 | existing table, and codes should not be removed from tables. | | 116 | existing table, and codes should not be removed from tables. |
112 | .Sh EXAMPLES | | 117 | .Sh EXAMPLES |
113 | A short sample error table might be | | 118 | A short sample error table might be |
114 | .Pa test_err.et : | | 119 | .Pa test_err.et : |
115 | .Pp | | 120 | .Pp |
116 | .Bd -literal | | 121 | .Bd -literal |
117 | # example error table source file | | 122 | # example error table source file |
118 | id "\e$Id\e$" | | 123 | id "\e$Id\e$" |
| @@ -123,22 +128,27 @@ A short sample error table might be | | | @@ -123,22 +128,27 @@ A short sample error table might be |
123 | ec NOMEM, "Out of memory" | | 128 | ec NOMEM, "Out of memory" |
124 | ec INVAL, "Invalid argument" | | 129 | ec INVAL, "Invalid argument" |
125 | end | | 130 | end |
126 | .Ed | | 131 | .Ed |
127 | .Pp | | 132 | .Pp |
128 | Compiling the source file | | 133 | Compiling the source file |
129 | .Pa test_err.et | | 134 | .Pa test_err.et |
130 | with | | 135 | with |
131 | .Nm | | 136 | .Nm |
132 | will create a C header file | | 137 | will create a C header file |
133 | .Pa test_err.h | | 138 | .Pa test_err.h |
134 | containing the enumerated type | | 139 | containing the enumerated type |
135 | .Va test_error_number | | 140 | .Va test_error_number |
136 | with values TEST_PERM, TEST_IO, TEST_NOMEM and | | 141 | with values |
137 | TEST_INVAL, and a C source file | | 142 | .Dv TEST_PERM , |
| | | 143 | .Dv TEST_IO , |
| | | 144 | .Dv TEST_NOMEM |
| | | 145 | and |
| | | 146 | .Dv TEST_INVAL , |
| | | 147 | and a C source file |
138 | .Pa test_err.c | | 148 | .Pa test_err.c |
139 | containing the | | 149 | containing the |
140 | .Xr com_err 3 | | 150 | .Xr com_err 3 |
141 | initialisation function | | 151 | initialisation function |
142 | .Fn initialize_test_error_table . | | 152 | .Fn initialize_test_error_table . |
143 | .Sh SEE ALSO | | 153 | .Sh SEE ALSO |
144 | .Xr com_err 3 | | 154 | .Xr com_err 3 |