lq-text: LQT_AddActionOnClose

API void LQT_AddActionOnClose (db, Description, Action, Flags) t_LQTEXT_Database *db; char *Description; int (* Action)( #ifdef HAVE_PROTO t_LQTEXT_Database * # endif ); unsigned int Flags;

Purpose

The given Action function will be called whenever LQT_Close­Database or LQT_Sync­Database is called.

The string Description is used in trace and debugging messages, and also in error messages; it should be a human-readable description of the action that the function is performing, or it could be an ASCII string containing the name of the function. The Description string is not copied; a pointer to it is retained. Therefore, it is an error to free it after calling LQT_Add­Action­On­Close.

The given Flags argument may be any combination of LQT_ON_SYNC and LQT_ON_CLOSE using bitwise or. If the LQT_ON_SYNC flag is given, the given Action is called by LQT_Sync­Database; if LQT_ON_CLOSE is given, the given Action is called by LQT_Close­Database. It is unusual to have an action for the Sync case and not for the Close case, but it is not forbidden.

You can register any number of functions in this way. The most recently registered function is called first, and so on.

LQT_Open­Database uses this function to register the following functions, in order, so that LQT_Flush­Block­Cache is called last:

You can see these called by running a client with the Debug trace flag set (e.g. lqwordlist -t Debug).

See Also:

Notes

The list of functions registered may change between revisions of lq-text, and is given here for illustrative purposes.