# mco_translog_play

> This function reads a specified log file or pipe and, if the log file is “compatible”, iterates its content by calling the user-defined callback and also fires registered events.

> ### For an overview see page TL Applications

### Prototype

        MCO_RET	mco_translog_play (	char const *file_path, mco_db_h db, mco_trans_iterator_callback_t iteration_proc,
                        void *user_ctx, mco_dictionary_h dict, void *mem_ptr, mco_size_t mem_size,
                         mco_translog_register_event_handlers_t register_callback,
                        void *regevent_user_ctx)

### Arguments

file_path | The path and filename of the log file or name of pipe overflow file. Note! It may be 0 if a pipe without an overflow file is used.
db | Connection handle to the original database to which the pipe is connected. Note: May be NULL if the function works with a simple log file.
iteration_proc | User-defined callback function that iterates objects stored in the log. Note! May be NULL if only events handling is desired.
user_ctx | Void pointer to user data that will be passed to the user-defined iteration callback.
dict | Dictionary of the database whose transactions are being logged.
mem_ptr | Pointer to a temporary data buffer to perform iterations if conventional memory is used or 0 if shared memory is used. Note! The pointer must be aligned to 8 bytes. (Using function `malloc()` complies with this requirement.)
mem_size | Size of the temporary data buffer. It should be at least twice the size of the largest stored transaction.
register_callback | User-defined callback function that registers event handlers. Note! May be NULL if only iterating of objects is desired.
regevent_user_ctx | Void pointer to user data that will be passed to the user-defined register event handlers callback.

### Description

> This function is a copy of function `mco_translog_iterate()` but in addition it allows to register a user-defined call-back which registers, in its turn, the event handlers. Function `mco_translog_play()` reads a specified log file or pipe and iterates its content by user-defined callback and fires proper events. (Note that an equivalent to `mco_translog_play()` is not available through the JNI or C# API.)

### Return Codes

MCO_S_OK | The log file was read successfully
User defined code other than MCO_S_OK | If the user-defined callback returns any value other than MCO_S_OK then function`mco_translog_iterate()` aborts and returns this code as its own return code. This is the correct way to break the iteration loop if an error condition occurs inside the user-defined iteration callback.
MCO_E_TL_INVAL | Arguments are wrong or incompatible.
MCO_E_TL_NOT_ITERABLE | The log was created without the flag `MCO_TRANSLOG_ITERABLE`.
MCO_E_TL_LOG_NOT_OPENED | The log file could not be opened.
MCO_E_TL_IO_ERROR | Disk IO error.
MCO_E_VERS_MISMATCH | The log file is incompatible with the runtime settings or the database version.
MCO_E_TL_INVFORMAT | The log file or pipe data is corrupted.
MCO_S_TL_INVDATA | The log file or pipe was not read completely but some transactions were found, or no end-of-file was found.
MCO_E_TL_PIPE_USED | Pipe is already opened by another call of `mco_trans_iterate()`.
MCO_E_TL_PIPE_TERM | Logging was terminated during the previous call of `mco_trans_iterate()` but not reinitialized by writer.
MCO_E_TL_PIPE_LOST | All connections to a pipe were closed and its data was lost before this function was called.
MCO_E_NOMEM | Insufficient memory to complete the operation. Increase the value of `mem_size`.

### Files

Header file:
mco.h
Source file:
mcolog.c
Library:
libmcolog.a