1/**********************************************************************
2 * logPopMsg
3 *
4 *
5 * This code was created by Peter Harvey (mostly during Christmas 98/99).
6 * This code is LGPL. Please ensure that this message remains in future
7 * distributions and uses of this code (thats about all I get out of it).
8 * - Peter Harvey pharvey@codebydesign.com
9 *
10 **********************************************************************/
11
12#include <config.h>
13#include "log.h"
14
15/*!
16 * \brief Returns a specific message.
17 *
18 * This returns a reference to a specific message and does
19 * NOT delete the message or remove it from the log. This is
20 * good for 'peeking' at messages in the stack.
21 *
22 * \param hLog Input. Viable log handle.
23 * \param nMsg Input. This is the index to the desired message. The
24 * index is 1 based with 1 being the oldest message.
25 * \param phMsg Output. A reference to the message in the log. This
26 * message is still maintained/owned by the log. The
27 * reference is only valid until some other code modifies
28 * the log.
29 *
30 * \return int
31 * \retval LOG_NO_DATA No message at nMsg.
32 * \retval LOG_ERROR
33 * \retval LOG_SUCCESS
34 *
35 * \sa logPopMsg
36 */
37int logPeekMsg( HLOG hLog, long nMsg, HLOGMSG *phMsg )
38{
39 /* we must be logOpen to logPeekMsg */
40 if ( !hLog ) return LOG_ERROR;
41
42 /* get reference */
43 /* \todo This can be terribly slow as we scan for each call. We may
44 want to implement this over a vector instead of a list. */
45 *phMsg = (HLOGMSG)lstGoto( hLog->hMessages, nMsg - 1 );
46
47 /* was it found? */
48 if ( lstEOL( hLog->hMessages ) )
49 return LOG_NO_DATA;
50
51 return LOG_SUCCESS;
52}
53
54
55