.\" .\" libexplain - Explain errno values returned by libc functions .\" Copyright (C) 2008-2011 Peter Miller .\" Written by Peter Miller .\" .\" This program is free software; you can redistribute it and/or modify .\" it under the terms of the GNU General Public License as published by .\" the Free Software Foundation; either version 3 of the License, or (at .\" your option) any later version. .\" .\" This program is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU .\" General Public License for more details. .\" .\" You should have received a copy of the GNU General Public License .\" along with this program. If not, see . .\" .ad l .hy 0 .nf .so etc/version.so libexplain \*(v)

libexplain \*(v)

The libexplain project provides a library which may be used to explain Unix and Linux system call errors. This will make your application's error messages much more informative to your users.

The library is not quite a drop-in replacement for strerror, but it comes close. Each system call has a dedicated libexplain function, for example

fd = open(path, flags, mode);
if (fd < 0)
{
    fprintf(stderr, "%s\en", explain_open(path, flags, mode));
    exit(EXIT_FAILURE);
}

‘I think it's totally awesome, in the category of “why hasn't this existed for n years” awesome.’ — Parker san
If, for example, you were to try to open no-such-dir/some-file, you would see a message like

open(pathname = "no-such-dir/some-file", flags = O_RDONLY) failed, No such file or directory (2, ENOENT) because there is no "no-such-dir" directory in the current directory

The good news is that for each of these functions there is a wrapper function, in this case explain_open_or_die(3), that includes the above code fragment. Adding good error reporting is as simple as using a different, but similarly named, function. The library also provides thread safe variants of each explanation function.

The coverage for system calls is being improved all the time, as you can see from this documentation page generated from the source code. .so etc/coverage.so

Documentation


Download

There are several ways you can obtain the software, as either source code or pre-compiled binaries.

[*] Master Sources

The following files are available for download from this web site:

File Description
libexplain-\*(V).README The README file form the tarball.
libexplain-\*(V).tar.gz The complete source.
libexplain-\*(V).pdf The reference manual, in PDF format.


[*] Sourceforge Downloads


[*] Ubuntu Packages

If you use Ubuntu Linux, there are pre-built packages available for installation using the normal sudo apt-get install method, from this package archive (PPA).

Instructions are available there for how to manually add the PPA to your /etc/apt/sources.list file, but the following commands are sufficient on recent versions of Ubuntu:

sudo add-apt-repository ppa:pmiller-opensource/ppa
sudo apt-get update
sudo apt-get install libexplain-dev


[*] Debian Packages


[*] Aegis
  • Libexplain is developed using Aegis DVCS
  • The Aegis repository for this project is available.
  • The complete source is available in aedist(1) format.
.\" ------------------------------------------------------------------------


Services provided by SourceForge

Services provided by Debian

.\" ------------------------------------------------------------------------
Libexplain is written and owned by Peter Miller <pmiller@opensource.org.au> and is freely distributable under the terms and conditions of the GNU LGPL, so you may use libexplain with proprietary programs. There is more Software by Peter Miller at his home page.
.\" ------------------------------------------------------------------------
SourceForge.net Logo This page is hosted by SourceForge.
This page has been accessed approximately number times since .ds MO1 Jan .ds MO2 Feb .ds MO3 Mar .ds MO4 Apr .ds MO5 May .ds MO6 Jun .ds MO7 Jul .ds MO8 Aug .ds MO9 Sep .ds MO10 Oct .ds MO11 Nov .ds MO12 Dec .nr y4 \n[yr]+1900 \n[dy]-\*[MO\n[mo]]-\n[y4].