botsense/bsProxy/bsProxyMod.c
static BsProxyModIF_T *ModDllNewIF(const char *sModUri, void *dllHandle)
{
  BsProxyModIF_T *pModIF = NEW(BsProxyModIF_T);
  int             rc = BS_OK;

  pModIF->m_sModUri   = new_strdup(sModUri);  // self reference
  pModIF->m_dllHandle = dllHandle;            // opaque dll handle
  pModIF->m_uRefCnt   = 1;                    // module reference count

  //
  // Init
  //
  pModIF->m_fnModInit = (BsModInitFunc_P)ModDllSym(pModIF, BSMOD_SYM_INIT_S);

  if( pModIF->m_fnModInit == NULL )
  {
    rc = -BS_ECODE_BAD_MOD;
  }

  //
  // Exit
  //
  pModIF->m_fnModExit = (BsModExitFunc_P)ModDllSym(pModIF, BSMOD_SYM_EXIT_S);

  if( pModIF->m_fnModExit == NULL )
  {
    rc = -BS_ECODE_BAD_MOD;
  }

  //
  // Open
  //
  pModIF->m_fnModOpen = (BsModOpenFunc_P)ModDllSym(pModIF, BSMOD_SYM_OPEN_S);

  if( pModIF->m_fnModOpen == NULL )
  {
    rc = -BS_ECODE_BAD_MOD;
  }

  //
  // Close
  //
  pModIF->m_fnModClose = (BsModCloseFunc_P)ModDllSym(pModIF, BSMOD_SYM_CLOSE_S);

  if( pModIF->m_fnModClose == NULL )
  {
    rc = -BS_ECODE_BAD_MOD;
  }


  //
  // Request
  //
  pModIF->m_fnModRequest = (BsModRequestFunc_P)ModDllSym(pModIF,
                                                         BSMOD_SYM_REQUEST_S);

  if( pModIF->m_fnModRequest == NULL )
  {
    rc = -BS_ECODE_BAD_MOD;
  }

  //
  // Trace
  //
  pModIF->m_fnModTrace = (BsModTraceFunc_P)ModDllSym(pModIF, BSMOD_SYM_TRACE_S);

  if( pModIF->m_fnModTrace == NULL )
  {
    rc = -BS_ECODE_BAD_MOD;
  }

  //
  // Info
  //
  pModIF->m_fnModInfo = (BsModInfoFunc_P)ModDllSym(pModIF, BSMOD_SYM_INFO_S);

  if( pModIF->m_fnModInfo == NULL )
  {
    rc = -BS_ECODE_BAD_MOD;
  }

  // Error clean up.
  if( rc < 0 )
  {
    ModDllDeleteIF(pModIF);
    pModIF = NULL;
  }

  return pModIF;
}
/*!
 * \brief Allocate an attached exported module interface block.
 *
 * \note dlsym() can return NULL with no errors if the symbol's value is NULL.
 * Checking the dlerror() return is the safe way to determine if an error has
 * occurred. However, a bsProxy compatible module's exported interface is
 * required to be defined.
 *
 * \param sModUri     Expanded, canonical name of the interface module.
 * \param dllHandle   DLL handle.
 *
 * \return
 * On success, returns a pointer to the module's exported interface.\n
 * On failure, returns NULL.
 */
\brief Allocate an attached exported module interface block.
\note dlsym() can return NULL with no errors if the symbol's value is NULL.
Checking the dlerror() return is the safe way to determine if an error has
occurred. However, a bsProxy compatible module's exported interface is
required to be defined.

\param sModUri     Expanded, canonical name of the interface module.
\param dllHandle   DLL handle.

\return
On success, returns a pointer to the module's exported interface.\n
On failure, returns NULL.
\ brief Allocate an attached exported module interface block . \ note dlsym () can return NULL with no errors if the symbol ' s value is NULL . Checking the dlerror () return is the safe way to determine if an error has occurred . However a bsProxy compatible module ' s exported interface is required to be defined . \ param sModUri Expanded canonical name of the interface module . \ param dllHandle DLL handle . \ return On success returns a pointer to the module ' s exported interface . \ n On failure returns NULL .
static BsProxyModIF_T *ModDllNewIF(const char *sModUri, void *dllHandle)
{
  BsProxyModIF_T *pModIF = NEW(BsProxyModIF_T);
  int             rc = BS_OK;
  pModIF->m_sModUri   = new_strdup(sModUri);  
  pModIF->m_dllHandle = dllHandle;            
  pModIF->m_uRefCnt   = 1;                    
   Init
  pModIF->m_fnModInit = (BsModInitFunc_P)ModDllSym(pModIF, BSMOD_SYM_INIT_S);
  if( pModIF->m_fnModInit == NULL )
  {
    rc = -BS_ECODE_BAD_MOD;
  }
   Exit
  pModIF->m_fnModExit = (BsModExitFunc_P)ModDllSym(pModIF, BSMOD_SYM_EXIT_S);
  if( pModIF->m_fnModExit == NULL )
  {
    rc = -BS_ECODE_BAD_MOD;
  }
   Open
  pModIF->m_fnModOpen = (BsModOpenFunc_P)ModDllSym(pModIF, BSMOD_SYM_OPEN_S);
  if( pModIF->m_fnModOpen == NULL )
  {
    rc = -BS_ECODE_BAD_MOD;
  }
   Close
  pModIF->m_fnModClose = (BsModCloseFunc_P)ModDllSym(pModIF, BSMOD_SYM_CLOSE_S);
  if( pModIF->m_fnModClose == NULL )
  {
    rc = -BS_ECODE_BAD_MOD;
  }
   Request
  pModIF->m_fnModRequest = (BsModRequestFunc_P)ModDllSym(pModIF,
                                                         BSMOD_SYM_REQUEST_S);
  if( pModIF->m_fnModRequest == NULL )
  {
    rc = -BS_ECODE_BAD_MOD;
  }
   Trace
  pModIF->m_fnModTrace = (BsModTraceFunc_P)ModDllSym(pModIF, BSMOD_SYM_TRACE_S);
  if( pModIF->m_fnModTrace == NULL )
  {
    rc = -BS_ECODE_BAD_MOD;
  }
   Info
  pModIF->m_fnModInfo = (BsModInfoFunc_P)ModDllSym(pModIF, BSMOD_SYM_INFO_S);
  if( pModIF->m_fnModInfo == NULL )
  {
    rc = -BS_ECODE_BAD_MOD;
  }
   Error clean up.
  if( rc < 0 )
  {
    ModDllDeleteIF(pModIF);
    pModIF = NULL;
  }
  return pModIF;
}
static BsProxyModIF_T * ModDllNewIF ( const char * sModUri , void * dllHandle ) { BsProxyModIF_T * pModIF = NEW ( BsProxyModIF_T ) ; int rc = BS_OK ; pModIF -> m_sModUri = new_strdup ( sModUri ) ; pModIF -> m_dllHandle = dllHandle ; pModIF -> m_uRefCnt = 1 ; pModIF -> m_fnModInit = ( BsModInitFunc_P ) ModDllSym ( pModIF , BSMOD_SYM_INIT_S ) ; if ( pModIF -> m_fnModInit == NULL ) { rc = - BS_ECODE_BAD_MOD ; } pModIF -> m_fnModExit = ( BsModExitFunc_P ) ModDllSym ( pModIF , BSMOD_SYM_EXIT_S ) ; if ( pModIF -> m_fnModExit == NULL ) { rc = - BS_ECODE_BAD_MOD ; } pModIF -> m_fnModOpen = ( BsModOpenFunc_P ) ModDllSym ( pModIF , BSMOD_SYM_OPEN_S ) ; if ( pModIF -> m_fnModOpen == NULL ) { rc = - BS_ECODE_BAD_MOD ; } pModIF -> m_fnModClose = ( BsModCloseFunc_P ) ModDllSym ( pModIF , BSMOD_SYM_CLOSE_S ) ; if ( pModIF -> m_fnModClose == NULL ) { rc = - BS_ECODE_BAD_MOD ; } pModIF -> m_fnModRequest = ( BsModRequestFunc_P ) ModDllSym ( pModIF , BSMOD_SYM_REQUEST_S ) ; if ( pModIF -> m_fnModRequest == NULL ) { rc = - BS_ECODE_BAD_MOD ; } pModIF -> m_fnModTrace = ( BsModTraceFunc_P ) ModDllSym ( pModIF , BSMOD_SYM_TRACE_S ) ; if ( pModIF -> m_fnModTrace == NULL ) { rc = - BS_ECODE_BAD_MOD ; } pModIF -> m_fnModInfo = ( BsModInfoFunc_P ) ModDllSym ( pModIF , BSMOD_SYM_INFO_S ) ; if ( pModIF -> m_fnModInfo == NULL ) { rc = - BS_ECODE_BAD_MOD ; } if ( rc < 0 ) { ModDllDeleteIF ( pModIF ) ; pModIF = NULL ; } return pModIF ; }
\brief Allocate an attached exported module interface block.
\ brief Allocate an attached exported module interface block .
// self reference // opaque dll handle // module reference count // // Init // // // Exit // // // Open // // // Close // // // Request // // // Trace // // // Info // // Error clean up.