1 /*******************************************************************************
2 * intf_msg.h: messages interface
4 *******************************************************************************
5 * This library provides basic functions for threads to interact with user
6 * interface, such as message output. If INTF_MSG_QUEUE is defined (which is the
7 * defaul), messages are not printed directly by threads, to bypass console
8 * limitations and slow printf() calls, but sent to a queue and printed later by
10 * If INTF_MSG_QUEUE is not defined, output is directly performed on stderr.
11 *******************************************************************************
16 *******************************************************************************/
18 /*******************************************************************************
20 *******************************************************************************
21 * Store a single message. Messages have a maximal size of INTF_MSG_MSGSIZE.
22 * If DEBUG is defined, messages have a date field and debug messages are
23 * printed with a date to allow more precise profiling.
24 *******************************************************************************/
27 int i_type; /* message type, see below */
28 char * psz_msg; /* the message itself */
31 /* Debugging informations - in DEBUG mode, all messages are dated and debug
32 * messages have calling location informations printed */
33 mtime_t date; /* date of the message (all messages) */
34 char * psz_file; /* file in which the function was called */
35 char * psz_function; /* function from which the function was called */
36 int i_line; /* line at which the function was called */
38 } interface_msg_message_t;
41 #define INTF_MSG_STD 0 /* standard message */
42 #define INTF_MSG_ERR 1 /* error message */
43 #define INTF_MSG_INTF 2 /* interface message */
44 #define INTF_MSG_DBG 3 /* debug message */
46 /*******************************************************************************
48 *******************************************************************************
49 * Store all data requiered by messages interfaces. It has a singe instance in
51 *******************************************************************************/
56 vlc_mutex_t lock; /* message queue lock */
57 int i_count; /* number of messages stored */
58 interface_msg_message_t msg[INTF_MSG_QSIZE]; /* message queue */
63 FILE * p_log_file; /* log file */
66 #ifndef INTF_MSG_QUEUE
68 /* If neither messages queue, neither log file is used, then the structure
69 * is empty. However, empty structures are not allowed in C. Therefore, a
70 * dummy integer is used to fill it. */
71 int i_dummy; /* unused filler */
76 /*******************************************************************************
77 * intf_DbgMsg macros and functions
78 *******************************************************************************
79 * The intf_DbgMsg* functions are defined as macro to be able to use the
80 * compiler extensions and print the file, the function and the line number
81 * from which they have been called. They call _intf_DbgMsg*() functions after
82 * having added debugging informations.
83 * Outside DEBUG mode, intf_DbgMsg* functions do nothing.
84 *******************************************************************************/
88 void _intf_DbgMsg ( char *psz_file, char *psz_function, int i_line,
89 char *psz_format, ... );
90 void _intf_DbgMsgImm ( char *psz_file, char *psz_function, int i_line,
91 char *psz_format, ... );
93 #define intf_DbgMsg( format, args... ) \
94 _intf_DbgMsg( __FILE__, __FUNCTION__, __LINE__, format, ## args )
95 #define intf_DbgMsgImm( format, args... ) \
96 _intf_DbgMsg( __FILE__, __FUNCTION__, __LINE__, format, ## args )
101 #define intf_DbgMsg( format, args... )
102 #define intf_DbgMsgImm( format, args...)
106 /*******************************************************************************
107 * intf_FlushMsg macro and function
108 *******************************************************************************
109 * intf_FlushMsg is a function which flushs message queue and print all messages
110 * remaining. It is only usefull if INTF_MSG_QUEUE is defined. In this case, it
111 * is really a function. In the other case, it is a macro doing nothing.
112 *******************************************************************************/
113 #ifdef INTF_MSG_QUEUE
115 /* Message queue mode */
116 void intf_FlushMsg ( void );
121 #define intf_FlushMsg() ;
125 /*******************************************************************************
127 *******************************************************************************/
128 int intf_InitMsg ( interface_msg_t *p_intf_msg );
129 void intf_TerminateMsg ( interface_msg_t *p_intf_msg );
131 void intf_Msg ( char *psz_format, ... );
132 void intf_ErrMsg ( char *psz_format, ... );
133 void intf_IntfMsg ( char *psz_format, ... );
135 void intf_MsgImm ( char *psz_format, ... );
136 void intf_ErrMsgImm ( char *psz_format, ... );