This file is indexed.

/usr/share/doc/libcomerr2/html-info/com_err.html is in comerr-dev 2.1-1.42.9-3ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>A Common Error Description Library for UNIX</title>

<meta name="description" content="A Common Error Description Library for UNIX">
<meta name="keywords" content="A Common Error Description Library for UNIX">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="#Top" rel="start" title="Top">
<link href="#SEC_Contents" rel="contents" title="Table of Contents">
<link href="dir.html#Top" rel="up" title="(dir)">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<h1 class="settitle" align="center">A Common Error Description Library for UNIX</h1>







<a name="Top"></a>
<div class="header">
<p>
Next: <a href="#Why-com_005ferr_003f" accesskey="n" rel="next">Why com_err?</a>, Previous: <a href="dir.html#Top" accesskey="p" rel="prev">(dir)</a>, Up: <a href="dir.html#Top" accesskey="u" rel="up">(dir)</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
</div>

<a name="A-Common-Error-Description-Library-for-UNIX"></a>
<h1 class="top">A Common Error Description Library for UNIX</h1>

<p>This manual documents the com_err library.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="#Why-com_005ferr_003f" accesskey="1">Why com_err?</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Error-codes" accesskey="2">Error codes</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Error-table-source-file" accesskey="3">Error table source file</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#The-error_002dtable-compiler" accesskey="4">The error-table compiler</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Run_002dtime-support-routines" accesskey="5">Run-time support routines</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Coding-Conventions" accesskey="6">Coding Conventions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Building-and-Installation" accesskey="7">Building and Installation</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Bug-Reports" accesskey="8">Bug Reports</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Acknowledgements" accesskey="9">Acknowledgements</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>


<hr>
<a name="Why-com_005ferr_003f"></a>
<div class="header">
<p>
Next: <a href="#Error-codes" accesskey="n" rel="next">Error codes</a>, Previous: <a href="#Top" accesskey="p" rel="prev">Top</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
</div>
<a name="Why-com_005ferr_003f-1"></a>
<h2 class="chapter">1 Why com_err?</h2>

<p>In building application software packages, a programmer often has to
deal with a number of libraries, each of which can use a different
error-reporting mechanism.  Sometimes one of two values is returned,
indicating simply SUCCESS or FAILURE, with no description of errors
encountered.  Sometimes it is an index into a table of text strings,
where the name of the table used is dependent on the library being
used when the error is generated; since each table starts numbering at
0 or 1, additional information as to the source of the error code is
needed to determine which table to look at.  Sometimes no text messages are
supplied at all, and the programmer must supply them at any point at which
he may wish to report error conditions.
Often, a global variable is assigned some value describing the error, but
the programmer has to know in each case whether to look at <code>errno</code>,
<code>h_errno</code>, the return value from <code>hes_err()</code>, or whatever other
variables or routines are specified.
And what happens if something
in the procedure of
examining or reporting the error changes the same variable?
</p>
<p>The package we have developed is an attempt to present a common
error-handling mechanism to manipulate the most common form of error code
in a fashion that does not have the problems listed above.
</p>
<p>A list of up to 256 text messages is supplied to a translator we have
written, along with the three- to four-character &ldquo;name&rdquo; of the error
table.  The library using this error table need only call a routine
generated from this error-table source to make the table &ldquo;known&rdquo; to the
com_err library, and any error code the library generates can be converted
to the corresponding error message.  There is also a default format for
error codes accidentally returned before making the table known, which is
of the form &lsquo;<samp>unknown code foo 32</samp>&rsquo;, where &lsquo;<samp>foo</samp>&rsquo; would be the name
of the table.
</p>
<hr>
<a name="Error-codes"></a>
<div class="header">
<p>
Next: <a href="#Error-table-source-file" accesskey="n" rel="next">Error table source file</a>, Previous: <a href="#Why-com_005ferr_003f" accesskey="p" rel="prev">Why com_err?</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
</div>
<a name="Error-codes-1"></a>
<h2 class="chapter">2 Error codes</h2>

<p>Error codes themselves are 32 bit (signed) integers, of which the high
order 24 bits are an identifier of which error table the error code is
from, and the low order 8 bits are a sequential error number within
the table.  An error code may thus be easily decomposed into its component
parts.  Only the lowest 32 bits of an error code are considered significant
on systems which support wider values.
</p>
<p>Error table 0 is defined to match the UNIX system call error table
(<code>sys_errlist</code>); this allows <code>errno</code> values to be used directly
in the library (assuming that <code>errno</code> is of a type with the same width
as <tt>long</tt>).  Other error table numbers are formed by compacting together
the first four characters of the error table name.  The mapping between
characters in the name and numeric values in the error code are defined in
a system-independent fashion, so that two systems that can pass integral
values between them can reliably pass error codes without loss of meaning;
this should work even if the character sets used are not the same.
(However, if this is to be done, error table 0 should be avoided, since the
local system call error tables may differ.)
</p>
<p>Any variable which is to contain an error code should be declared <tt>long</tt>.
The draft proposed American National Standard for C (as of May, 1988)
requires that <tt>long</tt> variables be at least 32 bits; any system which does
not support 32-bit <tt>long</tt> values cannot make use of this package (nor
much other software that assumes an ANSI-C environment base) without
significant effort.
</p>
<hr>
<a name="Error-table-source-file"></a>
<div class="header">
<p>
Next: <a href="#The-error_002dtable-compiler" accesskey="n" rel="next">The error-table compiler</a>, Previous: <a href="#Error-codes" accesskey="p" rel="prev">Error codes</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
</div>
<a name="Error-table-source-file-1"></a>
<h2 class="chapter">3 Error table source file</h2>

<p>The error table source file begins with the declaration of the table name,
as
</p>
<div class="example">
<pre class="example">error_table <var>tablename</var>
</pre></div>

<p>Individual error codes are
specified with
</p>
<div class="example">
<pre class="example">error_code <var>ERROR_NAME</var>, <var>&quot;text message&quot;</var>
</pre></div>

<p>where &lsquo;<samp>ec</samp>&rsquo; can also be used as a short form of &lsquo;<samp>error_code</samp>&rsquo;.  To
indicate the end of the table, use &lsquo;<samp>end</samp>&rsquo;.  Thus, a (short) sample
error table might be:
</p>
<div class="example">
<pre class="example">
        error_table     dsc

        error_code      DSC_DUP_MTG_NAME,
                        &quot;Meeting already exists&quot;

        ec              DSC_BAD_PATH,
                        &quot;A bad meeting pathname was given&quot;

        ec              DSC_BAD_MODES,
                        &quot;Invalid mode for this access control list&quot;

        end

</pre></div>

<hr>
<a name="The-error_002dtable-compiler"></a>
<div class="header">
<p>
Next: <a href="#Run_002dtime-support-routines" accesskey="n" rel="next">Run-time support routines</a>, Previous: <a href="#Error-table-source-file" accesskey="p" rel="prev">Error table source file</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
</div>
<a name="The-error_002dtable-compiler-1"></a>
<h2 class="chapter">4 The error-table compiler</h2>

<p>The error table compiler is named <code>compile_et</code>.  It takes one
argument, the pathname of a file (ending in &lsquo;<samp>.et</samp>&rsquo;, e.g.,
&lsquo;<samp>dsc_err.et</samp>&rsquo;) containing an error table source file.  It parses the
error table, and generates two output files &ndash; a C header file
(&lsquo;<samp>discuss_err.h</samp>&rsquo;) which contains definitions of the numerical values
of the error codes defined in the error table, and a C source file which
should be compiled and linked with the executable.  The header file must be
included in the source of a module which wishes to reference the error
codes defined; the object module generated from the C code may be linked in
to a program which wishes to use the printed forms of the error codes.
</p>
<hr>
<a name="Run_002dtime-support-routines"></a>
<div class="header">
<p>
Next: <a href="#Coding-Conventions" accesskey="n" rel="next">Coding Conventions</a>, Previous: <a href="#The-error_002dtable-compiler" accesskey="p" rel="prev">The error-table compiler</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
</div>
<a name="Run_002dtime-support-routines-1"></a>
<h2 class="chapter">5 Run-time support routines</h2>

<p>Any source file which uses the routines supplied with or produced by the
com_err package should include the header file <samp>&lt;com_err.h&gt;</samp>.  It
contains declarations and definitions which may be needed on some systems.
(Some functions cannot be referenced properly without the return type
declarations in this file.  Some functions may work properly on most
architectures even without the header file, but relying on this is not
recommended.)
</p>
<p>The run-time support routines and variables provided via this package
include the following:
</p>
<div class="example">
<pre class="example">void initialize_<var>xxxx</var>_error_table (void);
</pre></div>

<p>One of these routines is built by the error compiler for each error table.
It makes the <var>xxxx</var> error table &ldquo;known&rdquo; to the error reporting
system.  By convention, this routine should be called in the initialization
routine of the <var>xxxx</var> library.  If the library has no initialization
routine, some combination of routines which form the core of the library
should ensure that this routine is called.  It is not advised to leave it
the caller to make this call.
</p>
<p>There is no harm in calling this routine more than once.
</p>
<div class="example">
<pre class="example">#define ERROR_TABLE_BASE_<var>xxxx</var> <var>nnnnn</var>L
</pre></div>

<p>This symbol contains the value of the first error code entry in the
specified table.
This rarely needs be used by the
programmer.
</p>
<dl>
<dt><a name="index-char"></a>Function: <em>const</em> <strong>char</strong> <em>*error_message (long <var>code</var>);</em></dt>
<dd>
<p>This routine returns the character string error message associated
with <code>code</code>; if this is associated with an unknown error table, or
if the code is associated with a known error table but the code is not
in the table, a string of the form &lsquo;<samp>Unknown code <var>xxxx nn</var></samp>&rsquo; is
returned, where <var>xxxx</var> is the error table name produced by
reversing the compaction performed on the error table number implied
by that error code, and <var>nn</var> is the offset from that base value.
</p>
<p>Although this routine is available for use when needed, its use should be
left to circumstances which render <code>com_err</code> (below) unusable.
</p>
</dd></dl>

<dl>
<dt><a name="index-com_005ferr"></a>Function: <em>void</em> <strong>com_err</strong> <em>(const char *<var>whoami</var>, long <var>error_code</var>, const char *<var>format</var>, ...);             </em></dt>
<dd>
<p>This routine provides an alternate way to print error messages to
standard error; it allows the error message to be passed in as a
parameter, rather than in an external variable.  <em>Provide grammatical
context for &ldquo;message.&rdquo;</em>
</p>
<p>The module reporting the error should be passed in via <var>whoami</var>.
If <var>format</var> is <code>(char *)NULL</code>, the formatted message will not be
printed.  <var>format</var> may not be omitted.
</p>
</dd></dl>

<dl>
<dt><a name="index-com_005ferr_005fva"></a>Function: <em>void</em> <strong>com_err_va</strong> <em>(const char *<var>whoami</var>, long <var>error_code</var>, const char *<var>format</var>, va_list <var>args</var>);</em></dt>
<dd>
<p>This routine provides an interface, equivalent to <code>com_err</code> above,
which may be used by higher-level variadic functions (functions which
accept variable numbers of arguments).
</p>
</dd></dl>

<dl>
<dt><a name="index-_002aset_005fcom_005ferr_005fhook"></a>Function: <em>void</em> <strong>*set_com_err_hook</strong> <em>(void (*<var>proc</var>) (const char *<var>whoami</var>, long <var>error_code</var>, va_list <var>args</var>) (const char *<var>whoami</var>, long <var>error_code</var>, va_list <var>args</var>));</em></dt>
<dt><a name="index-reset_005fcom_005ferr_005fhook"></a>Function: <em>void</em> <strong>reset_com_err_hook</strong> <em>();</em></dt>
<dd>
<p>These two routines allow a routine to be dynamically substituted for
&lsquo;<samp>com_err</samp>&rsquo;.  After &lsquo;<samp>set_com_err_hook</samp>&rsquo; has been called,
calls to &lsquo;<samp>com_err</samp>&rsquo; will turn into calls to the new hook routine.
&lsquo;<samp>reset_com_err_hook</samp>&rsquo; turns off this hook.  This may intended to
be used in daemons (to use a routine which calls <cite>syslog(3)</cite>), or
in a window system application (which could pop up a dialogue box).
</p>
<p>If a program is to be used in an environment in which simply printing
messages to the <code>stderr</code> stream would be inappropriate (such as in a
daemon program which runs without a terminal attached),
<code>set_com_err_hook</code> may be used to redirect output from <code>com_err</code>.
The following is an example of an error handler which uses <cite>syslog(3)</cite>
as supplied in BSD 4.3:
</p>
<div class="example">
<pre class="example">#include &lt;stdio.h&gt;
#include &lt;stdarg.h&gt;
#include &lt;syslog.h&gt;

/* extern openlog (const char * name, int logopt, int facility); */
/* extern syslog (int priority, char * message, ...); */

void hook (const char * whoami, long code,
           const char * format, va_list args)
{
    char buffer[BUFSIZ];
    static int initialized = 0;
    if (!initialized) {
        openlog (whoami,
                 LOG_NOWAIT|LOG_CONS|LOG_PID|LOG_NDELAY,
                 LOG_DAEMON);
        initialized = 1;
    }
    vsprintf (buffer, format, args);
    syslog (LOG_ERR, &quot;%s %s&quot;, error_message (code), buffer);
}
</pre></div>

<p>After making the call
<code>set_com_err_hook (hook);</code>,
any calls to <code>com_err</code> will result in messages being sent to the
<var>syslogd</var> daemon for logging.
The name of the program, &lsquo;<samp>whoami</samp>&rsquo;, is supplied to the
&lsquo;<samp>openlog()</samp>&rsquo; call, and the message is formatted into a buffer and
passed to <code>syslog</code>.
</p>
<p>Note that since the extra arguments to <code>com_err</code> are passed by
reference via the <code>va_list</code> value <code>args</code>, the hook routine may
place any form of interpretation on them, including ignoring them.  For
consistency, <code>printf</code>-style interpretation is suggested, via
<code>vsprintf</code> (or <code>_doprnt</code> on BSD systems without full support for
the ANSI C library).
</p>
</dd></dl>

<hr>
<a name="Coding-Conventions"></a>
<div class="header">
<p>
Next: <a href="#Building-and-Installation" accesskey="n" rel="next">Building and Installation</a>, Previous: <a href="#Run_002dtime-support-routines" accesskey="p" rel="prev">Run-time support routines</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
</div>
<a name="Coding-Conventions-1"></a>
<h2 class="chapter">6 Coding Conventions</h2>

<p>The following conventions are just some general stylistic conventions
to follow when writing robust libraries and programs.  Conventions
similar to this are generally followed inside the UNIX kernel and most
routines in the Multics operating system.  In general, a routine
either succeeds (returning a zero error code, and doing some side
effects in the process), or it fails, doing minimal side effects; in
any event, any invariant which the library assumes must be maintained.
</p>
<p>In general, it is not in the domain of non user-interface library
routines to write error messages to the user&rsquo;s terminal, or halt the
process.  Such forms of &ldquo;error handling&rdquo; should be reserved for
failures of internal invariants and consistancy checks only, as it
provides the user of the library no way to clean up for himself in the
event of total failure.
</p>
<p>Library routines which can fail should be set up to return an error
code.  This should usually be done as the return value of the
function; if this is not acceptable, the routine should return a
&ldquo;null&rdquo; value, and put the error code into a parameter passed by
reference.
</p>
<p>Routines which use the first style of interface can be used from
user-interface levels of a program as follows:
</p>
<div class="example">
<pre class="example">{
    if ((code = initialize_world(getuid(), random())) != 0) {
        com_err(&quot;demo&quot;, code,
                &quot;when trying to initialize world&quot;);
        exit(1);
    }
    if ((database = open_database(&quot;my_secrets&quot;, &amp;code))==NULL) {
        com_err(&quot;demo&quot;, code,
                &quot;while opening my_secrets&quot;);
        exit(1);
    }
}
</pre></div>

<p>A caller which fails to check the return status is in error.  It is
possible to look for code which ignores error returns by using lint;
look for error messages of the form &ldquo;foobar returns value which is
sometimes ignored&rdquo; or &ldquo;foobar returns value which is always
ignored.&rdquo;
</p>
<p>Since libraries may be built out of other libraries, it is often necessary
for the success of one routine to depend on another.  When a lower level
routine returns an error code, the middle level routine has a few possible
options.  It can simply return the error code to its caller after doing
some form of cleanup, it can substitute one of its own, or it can take
corrective action of its own and continue normally.  For instance, a
library routine which makes a &ldquo;connect&rdquo; system call to make a network
connection may reflect the system error code <code>ECONNREFUSED</code>
(Connection refused) to its caller, or it may return a &ldquo;server not
available, try again later,&rdquo; or it may try a different server.
</p>
<p>Cleanup which is typically necessary may include, but not be limited
to, freeing allocated memory which will not be needed any more,
unlocking concurrancy locks, dropping reference counts, closing file
descriptors, or otherwise undoing anything which the procedure did up
to this point.  When there are a lot of things which can go wrong, it
is generally good to write one block of error-handling code which is
branched to, using a goto, in the event of failure.  A common source
of errors in UNIX programs is failing to close file descriptors on
error returns; this leaves a number of &ldquo;zombied&rdquo; file descriptors
open, which eventually causes the process to run out of file
descriptors and fall over.
</p>
<div class="example">
<pre class="example">{
    FILE *f1=NULL, *f2=NULL, *f3=NULL;
    int status = 0;

    if ( (f1 = fopen(FILE1, &quot;r&quot;)) == NULL) {
        status = errno;
        goto error;
    }

    /*
     * Crunch for a while
     */

    if ( (f2 = fopen(FILE2, &quot;w&quot;)) == NULL) {
        status = errno;
        goto error;
    }

    if ( (f3 = fopen(FILE3, &quot;a+&quot;)) == NULL) {
        status = errno;
            goto error;
    }

    /*
     * Do more processing.
     */
    fclose(f1);
    fclose(f2);
    fclose(f3);
    return 0;

error:
    if (f1) fclose(f1);
    if (f2) fclose(f2);
    if (f3) fclose(f3);
    return status;
}
</pre></div>

<hr>
<a name="Building-and-Installation"></a>
<div class="header">
<p>
Next: <a href="#Bug-Reports" accesskey="n" rel="next">Bug Reports</a>, Previous: <a href="#Coding-Conventions" accesskey="p" rel="prev">Coding Conventions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
</div>
<a name="Building-and-Installation-1"></a>
<h2 class="chapter">7 Building and Installation</h2>

<p>The distribution of this package will probably be done as a compressed
&ldquo;tar&rdquo;-format file available via anonymous FTP from SIPB.MIT.EDU.
Retrieve &lsquo;<samp>pub/com_err.tar.Z</samp>&rsquo; and extract the contents.  A subdirectory
<tt>profiled</tt> should be created to hold objects compiled for profiling.
Running &ldquo;make all&rdquo; should then be sufficient to build the library and
error-table compiler.  The files &lsquo;<samp>libcom_err.a</samp>&rsquo;,
&lsquo;<samp>libcom_err_p.a</samp>&rsquo;, &lsquo;<samp>com_err.h</samp>&rsquo;, and &lsquo;<samp>compile_et</samp>&rsquo; should be
installed for use; &lsquo;<samp>com_err.3</samp>&rsquo; and &lsquo;<samp>compile_et.1</samp>&rsquo; can also be
installed as manual pages.
</p>
<hr>
<a name="Bug-Reports"></a>
<div class="header">
<p>
Next: <a href="#Acknowledgements" accesskey="n" rel="next">Acknowledgements</a>, Previous: <a href="#Building-and-Installation" accesskey="p" rel="prev">Building and Installation</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
</div>
<a name="Bug-Reports-1"></a>
<h2 class="chapter">8 Bug Reports</h2>

<p>The principal author of this library is: Ken
Raeburn, <tt>raeburn@MIT.EDU</tt>.  
</p>
<p>This version of the com_err library is being maintained by Theodore
Ts&rsquo;o, and so bugs and comments should be sent to <tt>tytso@thunk.org</tt>.
</p>

<hr>
<a name="Acknowledgements"></a>
<div class="header">
<p>
Previous: <a href="#Bug-Reports" accesskey="p" rel="prev">Bug Reports</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
</div>
<a name="Acknowledgements-1"></a>
<h2 class="chapter">9 Acknowledgements</h2>

<p>I would like to thank: Bill Sommerfeld, for his help with some of this
documentation, and catching some of the bugs the first time around;
Honeywell Information Systems, for not killing off the <em>Multics</em>
operating system before I had an opportunity to use it; Honeywell&rsquo;s
customers, who persuaded them not to do so, for a while; Ted Anderson of
CMU, for catching some problems before version 1.2 left the nest; Stan
Zanarotti and several others of MIT&rsquo;s Student Information Processing Board,
for getting us started with &ldquo;discuss,&rdquo; for which this package was
originally written; and everyone I&rsquo;ve talked into &mdash; I mean, asked to read
this document and the &ldquo;man&rdquo; pages.
</p>
<a name="SEC_Contents"></a>
<h2 class="contents-heading">Table of Contents</h2>

<div class="contents">

<ul class="no-bullet">
  <li><a name="toc-Why-com_005ferr_003f-1" href="#Why-com_005ferr_003f">1 Why com_err?</a></li>
  <li><a name="toc-Error-codes-1" href="#Error-codes">2 Error codes</a></li>
  <li><a name="toc-Error-table-source-file-1" href="#Error-table-source-file">3 Error table source file</a></li>
  <li><a name="toc-The-error_002dtable-compiler-1" href="#The-error_002dtable-compiler">4 The error-table compiler</a></li>
  <li><a name="toc-Run_002dtime-support-routines-1" href="#Run_002dtime-support-routines">5 Run-time support routines</a></li>
  <li><a name="toc-Coding-Conventions-1" href="#Coding-Conventions">6 Coding Conventions</a></li>
  <li><a name="toc-Building-and-Installation-1" href="#Building-and-Installation">7 Building and Installation</a></li>
  <li><a name="toc-Bug-Reports-1" href="#Bug-Reports">8 Bug Reports</a></li>
  <li><a name="toc-Acknowledgements-1" href="#Acknowledgements">9 Acknowledgements</a></li>
</ul>
</div>

<hr>



</body>
</html>