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