1 /*****************************************************************************
2 * messages.h: messages interface
3 * This library provides basic functions for threads to interact with user
4 * interface, such as message output.
5 *****************************************************************************
6 * Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
7 * $Id: vlc_messages.h,v 1.11 2004/01/25 18:17:08 zorglub Exp $
9 * Authors: Vincent Seguin <seguin@via.ecp.fr>
10 * Samuel Hocevar <sam@zoy.org>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
25 *****************************************************************************/
29 * \defgroup messages Messages
30 * This library provides basic functions for threads to interact with user
31 * interface, such as message output.
38 * Store a single message.
42 int i_type; /**< message type, see below */
46 char * psz_msg; /**< the message itself */
49 mtime_t date; /* date of the message */
50 char * psz_file; /* file in which the function was called */
51 char * psz_function; /* function from which the function was called */
52 int i_line; /* line at which the function was called */
57 /** standard messages */
58 #define VLC_MSG_INFO 0
61 /** warning messages */
62 #define VLC_MSG_WARN 2
67 * Store all data requiered by messages interfaces.
71 /** Message queue lock */
73 vlc_bool_t b_configured;
74 vlc_bool_t b_overflow;
77 msg_item_t msg[VLC_MSG_QSIZE]; /**< message queue */
83 msg_subscription_t **pp_sub;
85 /* Logfile for WinCE */
92 * Used by interface plugins which subscribe to the message bank.
94 struct msg_subscription_t
103 /*****************************************************************************
105 *****************************************************************************/
106 VLC_EXPORT( void, __msg_Generic, ( vlc_object_t *, int, const char *, const char *, ... ) ATTRIBUTE_FORMAT( 4, 5 ) );
107 VLC_EXPORT( void, __msg_GenericVa, ( vlc_object_t *, int, const char *, const char *, va_list args ) );
108 VLC_EXPORT( void, __msg_Info, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
109 VLC_EXPORT( void, __msg_Err, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
110 VLC_EXPORT( void, __msg_Warn, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
111 VLC_EXPORT( void, __msg_Dbg, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
113 #ifdef HAVE_VARIADIC_MACROS
115 # define msg_Info( p_this, psz_format, args... ) \
116 __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_INFO, MODULE_STRING, \
117 psz_format, ## args )
119 # define msg_Err( p_this, psz_format, args... ) \
120 __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_ERR, MODULE_STRING, \
121 psz_format, ## args )
123 # define msg_Warn( p_this, psz_format, args... ) \
124 __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_WARN, MODULE_STRING, \
125 psz_format, ## args )
127 # define msg_Dbg( p_this, psz_format, args... ) \
128 __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_DBG, MODULE_STRING, \
129 psz_format, ## args )
131 #elif defined(_MSC_VER) /* To avoid warnings and even errors with c++ files */
133 inline void msg_Info( void *p_this, const char *psz_format, ... )
136 va_start( ap, psz_format );
137 __msg_GenericVa( ( vlc_object_t *)p_this, VLC_MSG_INFO, MODULE_STRING,
141 inline void msg_Err( void *p_this, const char *psz_format, ... )
144 va_start( ap, psz_format );
145 __msg_GenericVa( ( vlc_object_t *)p_this, VLC_MSG_ERR, MODULE_STRING,
149 inline void msg_Warn( void *p_this, const char *psz_format, ... )
152 va_start( ap, psz_format );
153 __msg_GenericVa( ( vlc_object_t *)p_this, VLC_MSG_WARN, MODULE_STRING,
157 inline void msg_Dbg( void *p_this, const char *psz_format, ... )
160 va_start( ap, psz_format );
161 __msg_GenericVa( ( vlc_object_t *)p_this, VLC_MSG_DBG, MODULE_STRING,
168 # define msg_Info __msg_Info
169 # define msg_Err __msg_Err
170 # define msg_Warn __msg_Warn
171 # define msg_Dbg __msg_Dbg
173 #endif /* HAVE_VARIADIC_MACROS */
175 #define msg_Create(a) __msg_Create(VLC_OBJECT(a))
176 #define msg_Flush(a) __msg_Flush(VLC_OBJECT(a))
177 #define msg_Destroy(a) __msg_Destroy(VLC_OBJECT(a))
178 void __msg_Create ( vlc_object_t * );
179 void __msg_Flush ( vlc_object_t * );
180 void __msg_Destroy ( vlc_object_t * );
182 #define msg_Subscribe(a) __msg_Subscribe(VLC_OBJECT(a))
183 #define msg_Unsubscribe(a,b) __msg_Unsubscribe(VLC_OBJECT(a),b)
184 VLC_EXPORT( msg_subscription_t*, __msg_Subscribe, ( vlc_object_t * ) );
185 VLC_EXPORT( void, __msg_Unsubscribe, ( vlc_object_t *, msg_subscription_t * ) );