Commit 392390d2 by Baruch Sterin

make it easy to add intialization functions to Abc_FrameInit()/Abc_FrameEnd()

parent 51bf1210
...@@ -59,6 +59,24 @@ extern void Abc2_End ( Abc_Frame_t * pAbc ); ...@@ -59,6 +59,24 @@ extern void Abc2_End ( Abc_Frame_t * pAbc );
extern void Abc85_Init( Abc_Frame_t * pAbc ); extern void Abc85_Init( Abc_Frame_t * pAbc );
extern void Abc85_End( Abc_Frame_t * pAbc ); extern void Abc85_End( Abc_Frame_t * pAbc );
static Abc_FrameInitializer_t* s_InitializerStart = NULL;
static Abc_FrameInitializer_t* s_InitializerEnd = NULL;
void Abc_FrameAddInitializer( Abc_FrameInitializer_t* p )
{
if( ! s_InitializerStart )
s_InitializerStart = p;
p->next = NULL;
p->prev = s_InitializerEnd;
if ( s_InitializerEnd )
s_InitializerEnd->next = p;
s_InitializerEnd = p;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -76,6 +94,8 @@ extern void Abc85_End( Abc_Frame_t * pAbc ); ...@@ -76,6 +94,8 @@ extern void Abc85_End( Abc_Frame_t * pAbc );
***********************************************************************/ ***********************************************************************/
void Abc_FrameInit( Abc_Frame_t * pAbc ) void Abc_FrameInit( Abc_Frame_t * pAbc )
{ {
Abc_FrameInitializer_t* p;
Cmd_Init( pAbc ); Cmd_Init( pAbc );
Cmd_CommandExecute( pAbc, "set checkread" ); Cmd_CommandExecute( pAbc, "set checkread" );
Io_Init( pAbc ); Io_Init( pAbc );
...@@ -96,6 +116,10 @@ void Abc_FrameInit( Abc_Frame_t * pAbc ) ...@@ -96,6 +116,10 @@ void Abc_FrameInit( Abc_Frame_t * pAbc )
Abc85_Init( pAbc ); Abc85_Init( pAbc );
#endif #endif
EXT_ABC_INIT(pAbc) // plugin for external functionality EXT_ABC_INIT(pAbc) // plugin for external functionality
for( p = s_InitializerStart ; p ; p = p->next )
if(p->init)
p->init(pAbc);
} }
...@@ -112,6 +136,12 @@ void Abc_FrameInit( Abc_Frame_t * pAbc ) ...@@ -112,6 +136,12 @@ void Abc_FrameInit( Abc_Frame_t * pAbc )
***********************************************************************/ ***********************************************************************/
void Abc_FrameEnd( Abc_Frame_t * pAbc ) void Abc_FrameEnd( Abc_Frame_t * pAbc )
{ {
Abc_FrameInitializer_t* p;
for( p = s_InitializerEnd ; p ; p = p->prev )
if ( p->destroy )
p->destroy(pAbc);
Abc_End( pAbc ); Abc_End( pAbc );
Io_End( pAbc ); Io_End( pAbc );
Cmd_End( pAbc ); Cmd_End( pAbc );
......
...@@ -132,6 +132,20 @@ struct Abc_Frame_t_ ...@@ -132,6 +132,20 @@ struct Abc_Frame_t_
EXT_ABC_FRAME // plugin for external functionality EXT_ABC_FRAME // plugin for external functionality
}; };
typedef void (*Abc_Frame_Initialization_Func)( Abc_Frame_t * pAbc );
struct Abc_FrameInitializer_t_;
typedef struct Abc_FrameInitializer_t_ Abc_FrameInitializer_t;
struct Abc_FrameInitializer_t_
{
Abc_Frame_Initialization_Func init;
Abc_Frame_Initialization_Func destroy;
Abc_FrameInitializer_t* next;
Abc_FrameInitializer_t* prev;
};
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// GLOBAL VARIABLES /// /// GLOBAL VARIABLES ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -150,6 +164,7 @@ extern ABC_DLL int main( int argc, char * argv[] ); ...@@ -150,6 +164,7 @@ extern ABC_DLL int main( int argc, char * argv[] );
/*=== mvInit.c ===================================================*/ /*=== mvInit.c ===================================================*/
extern ABC_DLL void Abc_FrameInit( Abc_Frame_t * pAbc ); extern ABC_DLL void Abc_FrameInit( Abc_Frame_t * pAbc );
extern ABC_DLL void Abc_FrameEnd( Abc_Frame_t * pAbc ); extern ABC_DLL void Abc_FrameEnd( Abc_Frame_t * pAbc );
extern ABC_DLL void Abc_FrameAddInitializer( Abc_FrameInitializer_t* p );
/*=== mvFrame.c =====================================================*/ /*=== mvFrame.c =====================================================*/
extern ABC_DLL Abc_Frame_t * Abc_FrameAllocate(); extern ABC_DLL Abc_Frame_t * Abc_FrameAllocate();
extern ABC_DLL void Abc_FrameDeallocate( Abc_Frame_t * p ); extern ABC_DLL void Abc_FrameDeallocate( Abc_Frame_t * p );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment