7 #define MAGIC_FREE 0x46524545 /* "FREE" */
8 #define MAGIC_NULL 0x4E554C4C /* "NULL" */
9 #define MAGIC_WINDOW 0x57494E44 /* "WIND" */
10 #define MAGIC_STREAM 0x53545245 /* "STRE" */
11 #define MAGIC_FILEREF 0x46494C45 /* "FILE" */
12 #define MAGIC_SCHANNEL 0x53434841 /* "SCHA" */
14 G_GNUC_INTERNAL gboolean magic_is_valid_or_null(const glui32 goodmagic, const glui32 realmagic, const gchar *function);
15 G_GNUC_INTERNAL gboolean magic_is_valid(const void *obj, const glui32 goodmagic, const glui32 realmagic, const gchar *function);
17 #define VALID_MAGIC(obj, goodmagic, die) \
18 if( !magic_is_valid((obj), (goodmagic), (obj)? (obj)->magic : 0, G_STRFUNC) ) die
19 #define VALID_MAGIC_OR_NULL(obj, goodmagic, die) \
20 if( !magic_is_valid_or_null((goodmagic), (obj)? (obj)->magic : MAGIC_NULL, G_STRFUNC) ) die
22 #define VALID_WINDOW(o, d) VALID_MAGIC(o, MAGIC_WINDOW, d)
23 #define VALID_WINDOW_OR_NULL(o, d) VALID_MAGIC_OR_NULL(o, MAGIC_WINDOW, d)
24 #define VALID_STREAM(o, d) VALID_MAGIC(o, MAGIC_STREAM, d)
25 #define VALID_STREAM_OR_NULL(o, d) VALID_MAGIC_OR_NULL(o, MAGIC_STREAM, d)
26 #define VALID_FILEREF(o, d) VALID_MAGIC(o, MAGIC_FILEREF, d)
27 #define VALID_FILEREF_OR_NULL(o, d) VALID_MAGIC_OR_NULL(o, MAGIC_FILEREF, d)
28 #define VALID_SCHANNEL(o, d) VALID_MAGIC(o, MAGIC_SCHANNEL, d)
29 #define VALID_SCHANNEL_OR_NULL(o, d) VALID_MAGIC_OR_NULL(o, MAGIC_SCHANNEL, d)
31 /* This works with string variables as well as literal strings */
32 #define ILLEGAL(str) g_critical("%s: %s", G_STRFUNC, str)
33 /* This only works with literal strings */
34 #define ILLEGAL_PARAM(str, param) g_critical("%s: " str, G_STRFUNC, param)
36 #define WARNING(msg) g_warning("%s: %s", G_STRFUNC, msg)
37 #define WARNING_S(msg, str) g_warning("%s: %s: %s", G_STRFUNC, msg, str)
38 #define IO_WARNING(msg, str, errmsg) \
39 g_warning("%s: %s \"%s\": %s", G_STRFUNC, msg, str, errmsg)
41 #endif /* __MAGIC_H__ */