Logo Search packages:      
Sourcecode: sbnc version File versions  Download package

RESULT< CModule * > CCore::LoadModule ( const char *  Filename  ) 

LoadModule

Attempts to load a bouncer module.

Parameters:
Filename the module's filename

Definition at line 746 of file Core.cpp.

References CModule::GetError(), CModule::GetFilename(), CModule::Init(), CVector< Type >::Insert(), Log(), m_LoadingModules, m_Modules, and UpdateModuleConfig().

Referenced by CClientConnection::ProcessBncCommand(), and StartMainLoop().

                                                        {
      RESULT<bool> Result;

      CModule *Module = new CModule(Filename);

      CHECK_ALLOC_RESULT(Module, new) {
            THROW(CModule *, Generic_OutOfMemory, "new operator failed.");
      } CHECK_ALLOC_RESULT_END;

      Result = Module->GetError();

      if (!IsError(Result)) {
            Result = m_Modules.Insert(Module);

            if (IsError(Result)) {
                  delete Module;

                  LOGERROR("Insert() failed. Could not load module");

                  THROWRESULT(CModule *, Result);
            }

            Log("Loaded module: %s", Module->GetFilename());

            Module->Init(this);

            if (!m_LoadingModules) {
                  UpdateModuleConfig();
            }

            RETURN(CModule *, Module);
      } else {
            static char *ErrorString = NULL;

            free(ErrorString);

            ErrorString = strdup(GETDESCRIPTION(Result));

            CHECK_ALLOC_RESULT(ErrorString, strdup) {
                  delete Module;

                  THROW(CModule *, Generic_OutOfMemory, "strdup() failed.");
            } CHECK_ALLOC_RESULT_END;

            Log("Module %s could not be loaded: %s", Filename, ErrorString);

            delete Module;

            THROW(CModule *, Generic_Unknown, ErrorString);
      }

      THROW(CModule *, Generic_Unknown, NULL);
}


Generated by  Doxygen 1.6.0   Back to index