| 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 Removes the oldest message from the log. |
| 17 | * |
| 18 | * The log is a FIFO stack and we implement a possible max on the |
| 19 | * number of messages we can store. When we hot the max we 'pop' |
| 20 | * a message out. The mem used by the message is automatically |
| 21 | * freed with a call to \sa _logFreeMsg. |
| 22 | * |
| 23 | * \param hLog |
| 24 | * |
| 25 | * \return int |
| 26 | * \retval LOG_NO_DATA |
| 27 | * \retval LOG_ERROR |
| 28 | * \retval LOG_SUCCESS |
| 29 | * |
| 30 | * \sa logPushMsg |
| 31 | * logPeekMsg |
| 32 | */ |
| 33 | int logPopMsg( HLOG hLog ) |
| 34 | { |
| 35 | /* we must be logOpen to logPopMsg */ |
| 36 | if ( !hLog ) return LOG_ERROR; |
| 37 | |
| 38 | /* FIFO */ |
| 39 | lstFirst( hLog->hMessages ); |
| 40 | |
| 41 | /* do we have a message to delete? */ |
| 42 | if ( lstEOL( hLog->hMessages ) ) return LOG_NO_DATA; |
| 43 | |
| 44 | return lstDelete( hLog->hMessages ); |
| 45 | } |
| 46 | |
| 47 | |
| 48 | |