|
Nameerr, erre, errp, errpe, errsetSynopsis#include <stdio.h> #include "err.h" cc file.c -lerr -lsll DescriptionThe liberr.a library provides functions to report errors. Use of the library facilitates consistent error reporting with flexibility. Function calls are terse, to allow more room for error messages.There are several situations where the style of error reporting must differ. The following scenarios are supported. The library is intended to allow convenient and consistent error formatting and reporting for applications and groups of applications. If the standard changes, consider changing the library.
ModesThe header file, err.h, defines three environment types. These are ERR_STDERR, ERR_STRLST, and ERR_HTML. If ERR_STDERR is specified with errset(), then error messages are prefixed with the program name and written to the standard error file descriptor. If ERR_STRLST is specified, then errors are appended to a list. The list uses libsll format. See the example for calling details. If ERR_HTML is specified, then errors are formatted for HTML, and emitted to the standard output, where CGI output normally goes.Routinesvoid err(char *format, ...);
This routine behaves like printf(3).
Format the error according to the current mode.
Then write it to the appropriate place - file descriptor or list.
This routine behaves like printf(3).
Format the error according to the current mode.
Then write it to the appropriate place - file descriptor or list.
Finally, exit.
Note that this routine is not particularly valuable
in list mode, since the list is lost on exit.
This routine behaves like printf(3).
Format the error according to the current mode.
Then examine errno for a system error and translate it to
a string.
Then write everything to the appropriate place - file descriptor or list.
This routine behaves like printf(3).
Format the error according to the current mode.
Then examine errno for a system error and translate it to
a string.
Then write everything to the appropriate place - file descriptor or list.
Finally, exit.
Note that this routine is not particularly valuable
in list mode, since the list is lost on exit.
Initialize the liberr library. The first argument is the name of the application, usually argv[0]. The library knows how to extract the application name if a full path is present. The second argument is the type of environment. This should be one of ERR_STDERR, ERR_STRLST, or ERR_HTML. This routine may be called to delete the error list. Just call the routine again with the list head. Alternately, one may simply call sll_rmlist(list);. The list is free()'d even if the mode is changed to something else. If the first argument, argv0, is NULL, then the application name is not changed. If errlist is NULL, the list is not free()'d. The routine returns the previous type of environment. This allows a routine to set the state temporarily, for exmple, to collect a list for an operation, then restore normal error reporting for the application. ExampleThis is tsterr.c, which can be found with the sources. Note how the libsll list is traversed.#include DiagnosticsYes. Files
/usr/local/lib/liberr.a /usr/local/include/err.h /usr/local/lib/libsll.a /usr/local/include/sll.h See Alsostrings(3), perrno(3), libsll AuthorStephen Uitti, 1995BugsUse of erre() and errpe() with list mode (ERR_STRLST) is not particularly useful, since the list is lost on exit. |