Fix spelling of member of struct num_format.
[adu.git] / error.h
diff --git a/error.h b/error.h
index 895f9f89bdc68d0a1242afc237fe930fc3db1786..010af4559bcb9b0a4e3ca5f329dd35629be762a7 100644 (file)
--- a/error.h
+++ b/error.h
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2008 Andre Noll <maan@tuebingen.mpg.de>
+ *
+ * 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") \
        _ERROR(EMPTY, "file empty") \
        _ERROR(MMAP, "mmap error") \
        _ERROR(OSL, "osl error") \
-       _ERROR(SIGNAL_SIG_ERR, "signal() returned SIG_ERR") \
-       _ERROR(OUTPUT, "error writing output file") \
+       _ERROR(SIGACTION, "could not install signal handler") \
+       _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")
 
 
 /**
  */
 #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[];
 
-
-/**
- * adu's version of strerror(3).
- *
- * \param num The error number.
- *
- * \return The error text of \a num.
- */
-static inline const char *adu_strerror(int num)
-{
-       assert(num > 0);
-       if (num == E_OSL) {
-               assert(osl_errno > 0);
-               return osl_strerror((osl_errno));
-       }
-       if (IS_SYSTEM_ERROR(num))
-               return strerror((num) & ((1 << SYSTEM_ERROR_BIT) - 1));
-       return adu_errlist[num];
-}
+extern 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;