]> git.sesse.net Git - vlc/blob - src/misc/messages.c
Put msg_context_global_key to the internal header.
[vlc] / src / misc / messages.c
1 /*****************************************************************************
2  * messages.c: messages interface
3  * This library provides an interface to the message queue to be used by other
4  * modules, especially intf modules. See vlc_config.h for output configuration.
5  *****************************************************************************
6  * Copyright (C) 1998-2005 the VideoLAN team
7  * $Id$
8  *
9  * Authors: Vincent Seguin <seguin@via.ecp.fr>
10  *          Samuel Hocevar <sam@zoy.org>
11  *
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.
16  *
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.
21  *
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25  *****************************************************************************/
26
27 /*****************************************************************************
28  * Preamble
29  *****************************************************************************/
30
31 #ifdef HAVE_CONFIG_H
32 # include "config.h"
33 #endif
34
35 #include <vlc/vlc.h>
36
37 #include <stdarg.h>                                       /* va_list for BSD */
38
39 #ifdef HAVE_FCNTL_H
40 #   include <fcntl.h>                  /* O_CREAT, O_TRUNC, O_WRONLY, O_SYNC */
41 #endif
42
43 #include <errno.h>                                                  /* errno */
44
45 #ifdef WIN32
46 #   include <vlc_network.h>          /* 'net_strerror' and 'WSAGetLastError' */
47 #endif
48
49 #ifdef HAVE_UNISTD_H
50 #   include <unistd.h>                                   /* close(), write() */
51 #endif
52
53 #include <assert.h>
54
55 #include <vlc_charset.h>
56 #include "../libvlc.h"
57
58 /*****************************************************************************
59  * Local macros
60  *****************************************************************************/
61 #if defined(HAVE_VA_COPY)
62 #   define vlc_va_copy(dest,src) va_copy(dest,src)
63 #elif defined(HAVE___VA_COPY)
64 #   define vlc_va_copy(dest,src) __va_copy(dest,src)
65 #else
66 #   define vlc_va_copy(dest,src) (dest)=(src)
67 #endif
68
69 #define QUEUE(i) p_this->p_libvlc->msg_bank.queues[i]
70 #define LOCK_BANK vlc_mutex_lock( &p_this->p_libvlc->msg_bank.lock );
71 #define UNLOCK_BANK vlc_mutex_unlock( &p_this->p_libvlc->msg_bank.lock );
72
73 /*****************************************************************************
74  * Local prototypes
75  *****************************************************************************/
76 static void QueueMsg ( vlc_object_t *, int, int , const char *,
77                        const char *, va_list );
78 static void FlushMsg ( msg_queue_t * );
79 static void PrintMsg ( vlc_object_t *, msg_item_t * );
80
81 /**
82  * Initialize messages queues
83  * This function initializes all message queues
84  */
85 void __msg_Create( vlc_object_t *p_this )
86 {
87     int i;
88     vlc_mutex_init( (vlc_object_t *)NULL,
89                     &(p_this->p_libvlc->msg_bank.lock) );
90
91     for( i = 0; i < 2; i++ )
92     {
93          vlc_mutex_init( (vlc_object_t *)NULL, &QUEUE(i).lock );
94          QUEUE(i).b_overflow = false;
95          QUEUE(i).i_id = i;
96          QUEUE(i).i_start = 0;
97          QUEUE(i).i_stop = 0;
98          QUEUE(i).i_sub = 0;
99          QUEUE(i).pp_sub = 0;
100     }
101
102 #ifdef UNDER_CE
103     QUEUE(MSG_QUEUE_NORMAL).logfile =
104         CreateFile( L"vlc-log.txt", GENERIC_WRITE,
105                     FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
106                     CREATE_ALWAYS, 0, NULL );
107     SetFilePointer( QUEUE(MSG_QUEUE_NORMAL).logfile, 0, NULL, FILE_END );
108 #endif
109 }
110
111 /**
112  * Flush all message queues
113  */
114 void __msg_Flush( vlc_object_t *p_this )
115 {
116     int i;
117     for( i = 0 ; i < NB_QUEUES ; i++ )
118     {
119         vlc_mutex_lock( &QUEUE(i).lock );
120         FlushMsg( &QUEUE(i) );
121         vlc_mutex_unlock( &QUEUE(i).lock );
122     }
123 }
124
125 /**
126  * Destroy the message queues
127  *
128  * This functions prints all messages remaining in the queues,
129  * then frees all the allocated ressources
130  * No other messages interface functions should be called after this one.
131  */
132 void __msg_Destroy( vlc_object_t *p_this )
133 {
134     int i;
135     for( i = NB_QUEUES -1 ; i >= 0;  i-- )
136     {
137         if( QUEUE(i).i_sub )
138             msg_Err( p_this, "stale interface subscribers" );
139
140         FlushMsg( &QUEUE(i) );
141
142 #ifdef UNDER_CE
143         if( i == MSG_QUEUE_NORMAL )
144             CloseHandle( QUEUE(MSG_QUEUE_NORMAL).logfile );
145 #endif
146         /* Destroy lock */
147         vlc_mutex_destroy( &QUEUE(i).lock );
148     }
149     vlc_mutex_destroy( &(p_this->p_libvlc->msg_bank.lock) );
150 }
151
152 /**
153  * Subscribe to a message queue.
154  */
155 msg_subscription_t *__msg_Subscribe( vlc_object_t *p_this, int i )
156 {
157     msg_subscription_t *p_sub = malloc( sizeof( msg_subscription_t ) );
158
159     assert( i < NB_QUEUES );
160
161     LOCK_BANK;
162     vlc_mutex_lock( &QUEUE(i).lock );
163
164     TAB_APPEND( QUEUE(i).i_sub, QUEUE(i).pp_sub, p_sub );
165
166     p_sub->i_start = QUEUE(i).i_start;
167     p_sub->pi_stop = &QUEUE(i).i_stop;
168     p_sub->p_msg   = QUEUE(i).msg;
169     p_sub->p_lock  = &QUEUE(i).lock;
170
171     vlc_mutex_unlock( &QUEUE(i).lock );
172     UNLOCK_BANK;
173
174     return p_sub;
175 }
176
177 /**
178  * Unsubscribe from a message queue.
179  */
180 void __msg_Unsubscribe( vlc_object_t *p_this, msg_subscription_t *p_sub )
181 {
182     int i,j;
183
184     LOCK_BANK;
185     for( i = 0 ; i< NB_QUEUES ; i++ )
186     {
187         vlc_mutex_lock( &QUEUE(i).lock );
188         for( j = 0 ; j< QUEUE(i).i_sub ; j++ )
189         {
190             if( QUEUE(i).pp_sub[j] == p_sub )
191             {
192                 REMOVE_ELEM( QUEUE(i).pp_sub, QUEUE(i).i_sub, j );
193                 free( p_sub );
194             }
195         }
196         vlc_mutex_unlock( & QUEUE(i).lock );
197     }
198     UNLOCK_BANK;
199 }
200
201 /*****************************************************************************
202  * __msg_*: print a message
203  *****************************************************************************
204  * These functions queue a message for later printing.
205  *****************************************************************************/
206 void __msg_Generic( vlc_object_t *p_this, int i_queue, int i_type,
207                     const char *psz_module,
208                     const char *psz_format, ... )
209 {
210     va_list args;
211
212     va_start( args, psz_format );
213     QueueMsg( p_this, i_queue, i_type, psz_module, psz_format, args );
214     va_end( args );
215 }
216
217 void __msg_GenericVa( vlc_object_t *p_this, int i_queue,
218                       int i_type, const char *psz_module,
219                       const char *psz_format, va_list args )
220 {
221     QueueMsg( p_this, i_queue, i_type, psz_module, psz_format, args );
222 }
223
224 /* Generic functions used when variadic macros are not available. */
225 #define DECLARE_MSG_FN( FN_NAME, FN_TYPE ) \
226     void FN_NAME( vlc_object_t *p_this, const char *psz_format, ... ) \
227     { \
228         va_list args; \
229         va_start( args, psz_format ); \
230         QueueMsg( p_this,MSG_QUEUE_NORMAL, FN_TYPE, "unknown", \
231                   psz_format, args ); \
232         va_end( args ); \
233     } \
234     struct _
235 /**
236  * Output an informational message.
237  * \note Do not use this for debug messages
238  * \see input_AddInfo
239  */
240 DECLARE_MSG_FN( __msg_Info, VLC_MSG_INFO );
241 /**
242  * Output an error message.
243  */
244 DECLARE_MSG_FN( __msg_Err,  VLC_MSG_ERR );
245 /**
246  * Output a waring message
247  */
248 DECLARE_MSG_FN( __msg_Warn, VLC_MSG_WARN );
249 /**
250  * Output a debug message
251  */
252 DECLARE_MSG_FN( __msg_Dbg,  VLC_MSG_DBG );
253
254 /**
255  * Add a message to a queue
256  *
257  * This function provides basic functionnalities to other msg_* functions.
258  * It adds a message to a queue (after having printed all stored messages if it
259  * is full). If the message can't be converted to string in memory, it issues
260  * a warning.
261  */
262 static void QueueMsg( vlc_object_t *p_this, int i_queue, int i_type,
263                       const char *psz_module,
264                       const char *psz_format, va_list _args )
265 {
266     int         i_header_size;             /* Size of the additionnal header */
267     vlc_object_t *p_obj;
268     char *       psz_str = NULL;                 /* formatted message string */
269     char *       psz_header = NULL;
270     va_list      args;
271     msg_item_t * p_item = NULL;                        /* pointer to message */
272     msg_item_t   item;                    /* message in case of a full queue */
273     msg_queue_t *p_queue;
274
275 #if !defined(HAVE_VASPRINTF) || defined(__APPLE__) || defined(SYS_BEOS)
276     int          i_size = strlen(psz_format) + INTF_MAX_MSG_SIZE;
277 #endif
278
279     if( p_this == NULL )
280     {
281 #ifndef NDEBUG
282         if( i_type == VLC_MSG_DBG )
283             return;
284 #endif
285         utf8_vfprintf( stderr, psz_format, _args );
286         fputc ('\n', stderr);
287         return;
288     }
289
290     if( p_this->i_flags & OBJECT_FLAGS_QUIET ||
291         (p_this->i_flags & OBJECT_FLAGS_NODBG && i_type == VLC_MSG_DBG) )
292         return;
293
294 #ifndef __GLIBC__
295     /* Expand %m to strerror(errno) - only once */
296     char buf[strlen( psz_format ) + 2001], *ptr;
297     strcpy( buf, psz_format );
298     ptr = (char*)buf;
299     psz_format = (const char*) buf;
300
301     for( ;; )
302     {
303         ptr = strchr( ptr, '%' );
304         if( ptr == NULL )
305             break;
306
307         if( ptr[1] == 'm' )
308         {
309             char errbuf[2001];
310             size_t errlen;
311
312 #ifndef WIN32
313             strerror_r( errno, errbuf, 1001 );
314 #else
315             int sockerr = WSAGetLastError( );
316             if( sockerr )
317             {
318                 strncpy( errbuf, net_strerror( sockerr ), 1001 );
319                 WSASetLastError( sockerr );
320             }
321             if ((sockerr == 0)
322              || (strcmp ("Unknown network stack error", errbuf) == 0))
323                 strncpy( errbuf, strerror( errno ), 1001 );
324 #endif
325             errbuf[1000] = 0;
326
327             /* Escape '%' from the error string */
328             for( char *percent = strchr( errbuf, '%' );
329                  percent != NULL;
330                  percent = strchr( percent + 2, '%' ) )
331             {
332                 memmove( percent + 1, percent, strlen( percent ) + 1 );
333             }
334
335             errlen = strlen( errbuf );
336             memmove( ptr + errlen, ptr + 2, strlen( ptr + 2 ) + 1 );
337             memcpy( ptr, errbuf, errlen );
338             break; /* Only once, so we don't overflow */
339         }
340
341         /* Looks for conversion specifier... */
342         do
343             ptr++;
344         while( *ptr && ( strchr( "diouxXeEfFgGaAcspn%", *ptr ) == NULL ) );
345         if( *ptr )
346             ptr++; /* ...and skip it */
347     }
348 #endif
349
350     /* Convert message to string  */
351 #if defined(HAVE_VASPRINTF) && !defined(__APPLE__) && !defined( SYS_BEOS )
352     vlc_va_copy( args, _args );
353     if( vasprintf( &psz_str, psz_format, args ) == -1 )
354         psz_str = NULL;
355     va_end( args );
356 #else
357     psz_str = (char*) malloc( i_size );
358 #endif
359
360     if( psz_str == NULL )
361     {
362 #ifdef __GLIBC__
363         fprintf( stderr, "main warning: can't store message (%m): " );
364 #else
365         char psz_err[1001];
366 #ifndef WIN32
367         /* we're not using GLIBC, so we are sure that the error description
368          * will be stored in the buffer we provide to strerror_r() */
369         strerror_r( errno, psz_err, 1001 );
370 #else
371         strncpy( psz_err, strerror( errno ), 1001 );
372 #endif
373         psz_err[1000] = '\0';
374         fprintf( stderr, "main warning: can't store message (%s): ", psz_err );
375 #endif
376         vlc_va_copy( args, _args );
377         /* We should use utf8_vfprintf - but it calls malloc()... */
378         vfprintf( stderr, psz_format, args );
379         va_end( args );
380         fputs( "\n", stderr );
381         return;
382     }
383
384     i_header_size = 0;
385     p_obj = p_this;
386     while( p_obj != NULL )
387     {
388         char *psz_old = NULL;
389         if( p_obj->psz_header )
390         {
391             i_header_size += strlen( p_obj->psz_header ) + 4;
392             if( psz_header )
393             {
394                 psz_old = strdup( psz_header );
395                 psz_header = (char*)realloc( psz_header, i_header_size );
396                 snprintf( psz_header, i_header_size , "[%s] %s",
397                           p_obj->psz_header, psz_old );
398             }
399             else
400             {
401                 psz_header = (char *)malloc( i_header_size );
402                 snprintf( psz_header, i_header_size, "[%s]",
403                           p_obj->psz_header );
404             }
405         }
406         free( psz_old );
407         p_obj = p_obj->p_parent;
408     }
409
410 #if !defined(HAVE_VASPRINTF) || defined(__APPLE__) || defined(SYS_BEOS)
411     vlc_va_copy( args, _args );
412     vsnprintf( psz_str, i_size, psz_format, args );
413     va_end( args );
414     psz_str[ i_size - 1 ] = 0; /* Just in case */
415 #endif
416
417     assert( i_queue < NB_QUEUES );
418     LOCK_BANK;
419     p_queue = &QUEUE(i_queue) ;
420     vlc_mutex_lock( &p_queue->lock );
421
422     /* Check there is room in the queue for our message */
423     if( p_queue->b_overflow )
424     {
425         FlushMsg( p_queue );
426
427         if( ((p_queue->i_stop - p_queue->i_start + 1) % VLC_MSG_QSIZE) == 0 )
428         {
429             /* Still in overflow mode, print from a dummy item */
430             p_item = &item;
431         }
432         else
433         {
434             /* Pheeew, at last, there is room in the queue! */
435             p_queue->b_overflow = false;
436         }
437     }
438     else if( ((p_queue->i_stop - p_queue->i_start + 2) % VLC_MSG_QSIZE) == 0 )
439     {
440         FlushMsg( p_queue );
441
442         if( ((p_queue->i_stop - p_queue->i_start + 2) % VLC_MSG_QSIZE) == 0 )
443         {
444             p_queue->b_overflow = true;
445
446             if( p_queue->i_id == MSG_QUEUE_NORMAL )
447             {
448                /* Put the overflow message in the queue */
449                 p_item = p_queue->msg + p_queue->i_stop;
450                 p_queue->i_stop = (p_queue->i_stop + 1) % VLC_MSG_QSIZE;
451
452                 p_item->i_type =        VLC_MSG_WARN;
453                 p_item->i_object_id =   p_this->i_object_id;
454                 p_item->psz_object_type = p_this->psz_object_type;
455                 p_item->psz_module =    strdup( "message" );
456                 p_item->psz_msg =       strdup( "message queue overflowed" );
457                 p_item->psz_header =    NULL;
458
459                PrintMsg( p_this, p_item );
460                /* We print from a dummy item */
461                p_item = &item;
462             }
463         }
464     }
465
466     if( !p_queue->b_overflow )
467     {
468         /* Put the message in the queue */
469         p_item = p_queue->msg + p_queue->i_stop;
470         p_queue->i_stop = (p_queue->i_stop + 1) % VLC_MSG_QSIZE;
471     }
472
473     /* Fill message information fields */
474     p_item->i_type =        i_type;
475     p_item->i_object_id =   p_this->i_object_id;
476     p_item->psz_object_type = p_this->psz_object_type;
477     p_item->psz_module =    strdup( psz_module );
478     p_item->psz_msg =       psz_str;
479     p_item->psz_header =    psz_header;
480
481     if( p_queue->i_id == MSG_QUEUE_NORMAL )
482         PrintMsg( p_this, p_item );
483
484     if( p_queue->b_overflow )
485     {
486         free( p_item->psz_module );
487         free( p_item->psz_msg );
488         free( p_item->psz_header );
489     }
490
491     vlc_mutex_unlock ( &p_queue->lock );
492     UNLOCK_BANK;
493 }
494
495 /* following functions are local */
496
497 /*****************************************************************************
498  * FlushMsg
499  *****************************************************************************
500  * Print all messages remaining in queue. MESSAGE QUEUE MUST BE LOCKED, since
501  * this function does not check the lock.
502  *****************************************************************************/
503 static void FlushMsg ( msg_queue_t *p_queue )
504 {
505     int i_index, i_start, i_stop;
506
507     /* Get the maximum message index that can be freed */
508     i_stop = p_queue->i_stop;
509
510     /* Check until which value we can free messages */
511     for( i_index = 0; i_index < p_queue->i_sub; i_index++ )
512     {
513         i_start = p_queue->pp_sub[ i_index ]->i_start;
514
515         /* If this subscriber is late, we don't free messages before
516          * his i_start value, otherwise he'll miss messages */
517         if(   ( i_start < i_stop
518                && (p_queue->i_stop <= i_start || i_stop <= p_queue->i_stop) )
519            || ( i_stop < i_start
520                && (i_stop <= p_queue->i_stop && p_queue->i_stop <= i_start) ) )
521         {
522             i_stop = i_start;
523         }
524     }
525
526     /* Free message data */
527     for( i_index = p_queue->i_start;
528          i_index != i_stop;
529          i_index = (i_index+1) % VLC_MSG_QSIZE )
530     {
531         free( p_queue->msg[i_index].psz_msg );
532         free( p_queue->msg[i_index].psz_module );
533         free( p_queue->msg[i_index].psz_header );
534     }
535
536     /* Update the new start value */
537     p_queue->i_start = i_index;
538 }
539
540 /*****************************************************************************
541  * PrintMsg: output a standard message item to stderr
542  *****************************************************************************
543  * Print a message to stderr, with colour formatting if needed.
544  *****************************************************************************/
545 static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item )
546 {
547 #   define COL(x)  "\033[" #x ";1m"
548 #   define RED     COL(31)
549 #   define GREEN   COL(32)
550 #   define YELLOW  COL(33)
551 #   define WHITE   COL(0)
552 #   define GRAY    "\033[0m"
553
554 #ifdef UNDER_CE
555     int i_dummy;
556 #endif
557     static const char * ppsz_type[4] = { "", " error", " warning", " debug" };
558     static const char *ppsz_color[4] = { WHITE, RED, YELLOW, GRAY };
559     const char *psz_object;
560     int i_type = p_item->i_type;
561
562     switch( i_type )
563     {
564         case VLC_MSG_ERR:
565             if( p_this->p_libvlc->i_verbose < 0 ) return;
566             break;
567         case VLC_MSG_INFO:
568             if( p_this->p_libvlc->i_verbose < 0 ) return;
569             break;
570         case VLC_MSG_WARN:
571             if( p_this->p_libvlc->i_verbose < 1 ) return;
572             break;
573         case VLC_MSG_DBG:
574             if( p_this->p_libvlc->i_verbose < 2 ) return;
575             break;
576     }
577
578     psz_object = p_item->psz_object_type;
579
580 #ifdef UNDER_CE
581 #   define CE_WRITE(str) WriteFile( QUEUE(MSG_QUEUE_NORMAL).logfile, \
582                                     str, strlen(str), &i_dummy, NULL );
583     CE_WRITE( p_item->psz_module );
584     CE_WRITE( " " );
585     CE_WRITE( psz_object );
586     CE_WRITE( ppsz_type[i_type] );
587     CE_WRITE( ": " );
588     CE_WRITE( p_item->psz_msg );
589     CE_WRITE( "\r\n" );
590     FlushFileBuffers( QUEUE(MSG_QUEUE_NORMAL).logfile );
591
592 #else
593     /* Send the message to stderr */
594     if( p_this->p_libvlc->b_color )
595     {
596         if( p_item->psz_header )
597         {
598             utf8_fprintf( stderr, "[" GREEN "%.8i" GRAY "] %s %s %s%s: %s%s" GRAY
599                               "\n",
600                          p_item->i_object_id, p_item->psz_header,
601                          p_item->psz_module, psz_object,
602                          ppsz_type[i_type], ppsz_color[i_type],
603                          p_item->psz_msg );
604         }
605         else
606         {
607              utf8_fprintf( stderr, "[" GREEN "%.8i" GRAY "] %s %s%s: %s%s" GRAY "\n",
608                          p_item->i_object_id, p_item->psz_module, psz_object,
609                          ppsz_type[i_type], ppsz_color[i_type],
610                          p_item->psz_msg );
611         }
612     }
613     else
614     {
615         if( p_item->psz_header )
616         {
617             utf8_fprintf( stderr, "[%.8i] %s %s %s%s: %s\n", p_item->i_object_id,
618                          p_item->psz_header, p_item->psz_module,
619                          psz_object, ppsz_type[i_type], p_item->psz_msg );
620         }
621         else
622         {
623             utf8_fprintf( stderr, "[%.8i] %s %s%s: %s\n", p_item->i_object_id,
624                          p_item->psz_module, psz_object, ppsz_type[i_type],
625                          p_item->psz_msg );
626         }
627     }
628
629 #   if defined(WIN32)
630     fflush( stderr );
631 #   endif
632 #endif
633 }
634
635 static msg_context_t* GetContext(void)
636 {
637     msg_context_t *p_ctx = vlc_threadvar_get( &msg_context_global_key );
638     if( p_ctx == NULL )
639     {
640         MALLOC_NULL( p_ctx, msg_context_t );
641         p_ctx->psz_message = NULL;
642         vlc_threadvar_set( &msg_context_global_key, p_ctx );
643     }
644     return p_ctx;
645 }
646
647 void msg_StackSet( int i_code, const char *psz_message, ... )
648 {
649     va_list ap;
650     msg_context_t *p_ctx = GetContext();
651     assert( p_ctx );
652
653     va_start( ap, psz_message );
654     free( p_ctx->psz_message );
655
656     if( vasprintf( &p_ctx->psz_message, psz_message, ap ) == -1 )
657         p_ctx->psz_message = NULL;
658     va_end( ap );
659
660     p_ctx->i_code = i_code;
661 }
662
663 void msg_StackAdd( const char *psz_message, ... )
664 {
665     char *psz_tmp;
666     va_list ap;
667     msg_context_t *p_ctx = GetContext();
668     assert( p_ctx );
669
670     va_start( ap, psz_message );
671     if( vasprintf( &psz_tmp, psz_message, ap ) == -1 )
672         psz_tmp = NULL;
673     va_end( ap );
674
675     if( !p_ctx->psz_message )
676         p_ctx->psz_message = psz_tmp;
677     else
678     {
679         char *psz_old = malloc( strlen( p_ctx->psz_message ) + 1 );
680         memcpy( psz_old, p_ctx->psz_message, strlen( p_ctx->psz_message ) + 1 );
681         p_ctx->psz_message = realloc( p_ctx->psz_message,
682                                       strlen( p_ctx->psz_message ) +
683                                       /* ':', ' ', '0' */
684                                       strlen( psz_tmp ) + 3 );
685         sprintf( p_ctx->psz_message, "%s: %s", psz_tmp, psz_old );
686         free( psz_tmp ); free( psz_old );
687     }
688 }
689
690 const char* msg_StackMsg( void )
691 {
692     msg_context_t *p_ctx = GetContext();
693     assert( p_ctx );
694     return p_ctx->psz_message;
695 }