X-Git-Url: http://git.tuebingen.mpg.de/?p=adu.git;a=blobdiff_plain;f=error.h;h=5a5aefb987dad5f4946844e3153f2c8f12d0f282;hp=895f9f89bdc68d0a1242afc237fe930fc3db1786;hb=d0bef44ffe5b6f985f4ba6a718e08afb50f096c6;hpb=bab4b8635b3e048e1d7c9a914ddace3433f02164 diff --git a/error.h b/error.h index 895f9f8..5a5aefb 100644 --- a/error.h +++ b/error.h @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2008 Andre Noll + * + * Licensed under the GPL v2. For licencing details see COPYING. + */ + +/** \file error.h \brief Error handling functions and macros. */ + /** * This bit indicates whether a number is considered a system error code. * If yes, the system errno is just the result of clearing this bit from @@ -11,6 +19,7 @@ /** Set the system error bit for the given number. */ #define ERRNO_TO_ERROR(num) ((num) | (1 << SYSTEM_ERROR_BIT)) +/** The list of all adu error codes with descriptions. */ #define ALL_ERRORS \ _ERROR(SUCCESS, "success") \ _ERROR(SYNTAX, "syntax error") \ @@ -25,7 +34,16 @@ _ERROR(MMAP, "mmap error") \ _ERROR(OSL, "osl error") \ _ERROR(SIGNAL_SIG_ERR, "signal() returned SIG_ERR") \ - _ERROR(OUTPUT, "error writing output file") \ + _ERROR(OUTPUT, "error writing output") \ + _ERROR(MALFORMED_FORMAT, "malformed format string") \ + _ERROR(BAD_ALIGN_SPEC, "bad alignment specifier") \ + _ERROR(TRAILING_GARBAGE, "trailing garbage after specifier") \ + _ERROR(UNIT, "no unit allowed here") \ + _ERROR(BAD_UNIT, "invalid unit specifier") \ + _ERROR(BAD_ATOM, "invalid atom") \ + _ERROR(BAD_OUTPUT_ARG, "invalid name for output") \ + _ERROR(REGEX, "regular expression error") \ + _ERROR(MKDIR, "could not create directory") /** @@ -34,14 +52,27 @@ */ #define _ERROR(err, msg) E_ ## err, +/** + * \cond (doxygen can not handle multiple definitions of the same macro). + * + * This just creates an enum consisting of the first argument of the above + * error list. + */ enum error_codes { ALL_ERRORS }; #undef _ERROR + +/* + * Here we define the array of error texts used by adu_strerror(). + */ #define _ERROR(err, msg) msg, #define DEFINE_ERRLIST char *adu_errlist[] = {ALL_ERRORS} +/** \endcond */ extern int osl_errno; + +/** Contains the description of all adu error codes. */ extern char *adu_errlist[]; @@ -52,7 +83,7 @@ extern char *adu_errlist[]; * * \return The error text of \a num. */ -static inline const char *adu_strerror(int num) +_static_inline_ const char *adu_strerror(int num) { assert(num > 0); if (num == E_OSL) { @@ -67,13 +98,15 @@ static inline const char *adu_strerror(int num) /** * Wrapper for osl library calls. * + * \param ret The return value of an osl library function. + * * This should be used for all calls to osl functions that return an osl error * code. It changes the return value to \p -E_OSL appropriately so that it can * be used for printing the correct error message. * * \return \a ret if \a ret >= 0, \p -E_OSL otherwise. */ -static inline int osl(int ret) +_static_inline_ int osl(int ret) { if (ret >= 0) return ret;