/* Copyright (C) 2008 Andreas Baumann 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 . */ #ifndef WOLF_ERRORS_H #define WOLF_ERRORS_H /** * @addtogroup wolf_error Error Handling * @{ */ /** * @file errors.h * @brief Error Handling * @author Andreas Baumann */ #ifdef __cplusplus extern "C" { #endif #include /* for size_t */ /** * @brief Possible error codes of the various libwolf libraries. */ typedef enum { WOLF_OK = 0, /**< no error, everything is fine */ WOLF_ERR_OUT_OF_MEMORY = -1, /**< out of memory in malloc */ WOLF_ERR_INVALID_STATE = -2, /**< the object is called in an illegal moment */ WOLF_ERR_INVALID_VALUE = -3, /**< invalid parameter to a function */ WOLF_ERR_INTERNAL = -4, /**< internal error of the object, usualy rare */ WOLF_ERR_PROGRAMMING = -5, /**< programming mistake, should not happen */ WOLF_ERR_NOT_IMPLEMENTED= -6, /**< not implemented yet */ WOLF_ERR_TIMEOUT = -7 /**< timeout */ } wolf_error_t; /** * Converts the last error into a human readable message. * * @param error the error to retrieve the textual representation for * @param buf the buffer which will hold the error message * @param buflen the size of the buffer * * @returns a pointer to buf for convenience */ char *wolf_error_msg( const wolf_error_t error, char *buf, size_t buflen ); /** * Converts the last system error into a human readable message. * On Windows this is done with FormatMessage and GetLastError, on * Unix with strerror_r and errno. * * @param buf the buffer which will hold the error message * @param buflen the size of the buffer * * @returns a pointer to buf for convenience */ char *wolf_system_error_msg( char *buf, size_t buflen ); #ifdef __cplusplus } #endif /** @} */ /* @addtogroup wolf_error */ #endif /* ifndef WOLF_ERRORS_H */