Mercurial > code
view err.h @ 39:70a7bbe96b1d
Organise like parray
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 02 Oct 2011 10:55:00 +0200 |
parents | ed6ae3b865c9 |
children | f773c76b1f3c |
line wrap: on
line source
/* * err.h -- formtted error messages (portable version) * * Copyright (c) 2011, David Demelier <markand@malikania.fr> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _ERR_H_ #define _ERR_H_ #include <stdarg.h> /* * Attribute noreturn may helps. This may produce a warning with GCC 4.5: * * int a; * * if ((a = getstate() < 0) * errx(1, "State failed"); * * Because compilator does not know that errx will call exit may produce * a warning like `a may be used uninitialized'. */ #ifdef __GNUC__ #define _NORETURN_ __attribute__ ((noreturn)) #endif /* * err() functions append the format message to the stderr FILE pointer. They * also append the system error using strerror(errno). Then the functions exit * with the error code given as first argument. */ void err(int, const char *, ...) _NORETURN_; void verr(int, const char *, va_list) _NORETURN_; /* * errx() functions are similar to err() except that they do not append the * system error message. */ void errx(int, const char *, ...) _NORETURN_; void verrx(int, const char *, va_list) _NORETURN_; /* * warn() functions are similar to err() but they do not call exit(). */ void warn(const char *, ...); void vwarn(const char *, va_list); /* * warnx() functions are similar to warn() except that they do not append the * system error message. */ void warnx(const char *, ...); void vwarnx(const char *, va_list); #endif /* _ERR_H_ */