XMMS2
xmms_error.h
Go to the documentation of this file.
1 /* XMMS2 - X Music Multiplexer System
2  * Copyright (C) 2003-2011 XMMS2 Team
3  *
4  * PLUGINS ARE NOT CONSIDERED TO BE DERIVED WORK !!!
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  */
16 
17 
18 
19 
20 #ifndef __XMMS_ERROR_H__
21 #define __XMMS_ERROR_H__
22 
23 #include <glib.h>
24 #include "xmmsc/xmmsc_errorcodes.h"
25 
26 #define XMMS_ERROR_MESSAGE_MAXLEN 255
27 
28 G_BEGIN_DECLS
29 
30 typedef struct xmms_error_St {
33 } xmms_error_t;
34 
35 static inline void
36 xmms_error_set (xmms_error_t *err, xmms_error_code_t code, const gchar *message)
37 {
38  g_return_if_fail (err);
39 
40  err->code = code;
41  if (message) {
42  g_strlcpy (err->message, message, XMMS_ERROR_MESSAGE_MAXLEN);
43  } else {
44  err->message[0] = 0;
45  }
46 }
47 
48 static inline void
49 xmms_error_reset (xmms_error_t *err)
50 {
51  g_return_if_fail (err);
52 
53  err->code = XMMS_ERROR_NONE;
54  err->message[0] = 0;
55 }
56 
57 #define xmms_error_iserror(e) ((e)->code != XMMS_ERROR_NONE)
58 #define xmms_error_isok(e) ((e)->code == XMMS_ERROR_NONE)
59 
60 #define xmms_error_type_get(e) ((e)->code)
61 
62 const gchar *xmms_error_message_get (xmms_error_t *err);
63 
64 G_END_DECLS
65 
66 #endif
xmms_error_code_t
const gchar * xmms_error_message_get(xmms_error_t *err)
Get the human readable error.
Definition: error.c:38
#define XMMS_ERROR_MESSAGE_MAXLEN
Definition: xmms_error.h:26
gchar message[XMMS_ERROR_MESSAGE_MAXLEN+1]
Definition: xmms_error.h:32
xmms_error_code_t code
Definition: xmms_error.h:31
G_BEGIN_DECLS struct xmms_error_St xmms_error_t