summaryrefslogtreecommitdiff
path: root/include/wolf/errors.h
blob: 0b143564f7e1ad47eb954cb5e3fa71c28a5db69a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
    Copyright (C) 2008 Andreas Baumann <abaumann@yahoo.com>

    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 <http://www.gnu.org/licenses/>.
*/

#ifndef WOLF_ERRORS_H
#define WOLF_ERRORS_H

/**
 * @addtogroup wolf_error Common error states
 * @{
 */

/**
 * @file errors.h
 * @brief Global Error States
 * @author Andreas Baumann <abaumann@yahoo.com>
 */

#ifdef __cplusplus
extern "C" {
#endif

#include <sys/types.h>            /* 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 );

#ifdef __cplusplus
}
#endif

/** @} */ /* @addtogroup wolf_error */

#endif /* ifndef WOLF_ERRORS_H */