| 1 | /********************************************************************** |
| 2 | * logClose |
| 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 Closes log. |
| 17 | * |
| 18 | * This will clear all messages and close the log. All memory used |
| 19 | * by the messages is automatically freed by calls to _logFreeMsg. |
| 20 | * All remaining mem used by the log is also freed - including the |
| 21 | * log handle itself. |
| 22 | * |
| 23 | * \param hLog A log handle init by \sa logOpen. |
| 24 | * |
| 25 | * \return int |
| 26 | * \retval LOG_SUCCESS |
| 27 | * |
| 28 | * \sa logOpen |
| 29 | */ |
| 30 | int logClose( HLOG hLog ) |
| 31 | { |
| 32 | /* we must be logOpen to logClose */ |
| 33 | if ( !hLog ) return LOG_ERROR; |
| 34 | |
| 35 | /* clear all messages - including the handle */ |
| 36 | /* _logFreeMsg will automatically be called for each msg */ |
| 37 | lstClose( hLog->hMessages ); |
| 38 | |
| 39 | /* free remaining mem used by log - including the handle */ |
| 40 | if ( hLog->pszProgramName ) free( hLog->pszProgramName ); |
| 41 | if ( hLog->pszLogFile ) free( hLog->pszLogFile ); |
| 42 | free( hLog ); |
| 43 | |
| 44 | return LOG_SUCCESS; |
| 45 | } |
| 46 | |
| 47 | |
| 48 | |