module.c File Reference

#include "stdinc.h"
#include "server.h"

Go to the source code of this file.

Functions

char * GetModErr (int status)
void init_modules ()
int load_protocol ()
int load_modules ()
char * create_mod_temp (char *file)
int module_open (char *filename, int type)
int module_exists (char *fileName)
char * find_module_dir (char *module)
void module_free (Module *m)
int module_close (char *filename)
Modulemodule_find (char *filename)
void purge_modules ()
ModuleQEntryfind_mod_que (char *file)
int addto_mod_que (char *file, int op, int load)
int run_mod_que (int load)
int mod_event_shutdown (int ac, void *args)
int mod_event_rehash (int ac, void *args)

Function Documentation

int addto_mod_que ( char *  file,
int  op,
int  load 
)
char* create_mod_temp ( char *  file  ) 

Create a temporary module file.

Parameters:
filename (string) Path to module file we are copying
Returns:
(string) Pointer to the file name that we just created.
Note:
- this file name must be free'd upon delete.

Definition at line 245 of file module.c.

References CfgSettings, format_filename, MAXPATH, MAXREADBUFFER, Conf::network, strlcat(), and TMP_DIR.

Referenced by module_open().

ModuleQEntry* find_mod_que ( char *  file  ) 

Module Que Opporations

Definition at line 605 of file module.c.

References DLINK_FOREACH, moduleque, and ModuleQEntry::name.

char* find_module_dir ( char *  module  ) 

Definition at line 446 of file module.c.

References CLIENT_MOD_DIR, CONTRIB_PATH, CPATH, module_exists(), MPATH, and PPATH.

char* GetModErr ( int  status  ) 

Return a module error string.

Parameters:
status Error code we are returning.
Note:
negative value of status is representive of module side errors, these are custom errors that modules must define.

Definition at line 41 of file module.c.

References mod_err_msg, and MOD_ERR_MSG.

Referenced by load_modules(), load_protocol(), and run_mod_que().

void init_modules (  ) 
int load_modules (  ) 
int load_protocol (  ) 

load_protocol() - Load our given protocol if it fails toss a critical error and return

Returns:
bool true - Module has loaded successfully false - Module failed to load see logs

Definition at line 121 of file module.c.

References alog(), CfgSettings, get_config_entry(), GetModErr(), LOG_FATAL, MOD_TYPE_PROTOCOL, module_open(), Conf::protocol, sendto_console(), and strlcpy().

Referenced by init_modules().

int mod_event_rehash ( int  ,
void *   
)

Event Hooks

Definition at line 709 of file module.c.

References MOD_LOAD_POST, MOD_LOAD_PRE, MOD_LOAD_STD, and run_mod_que().

Referenced by init_modules().

int mod_event_shutdown ( int  ac,
void *  args 
)

Module Loader Event Hooks

Definition at line 703 of file module.c.

References purge_modules().

Referenced by init_modules().

int module_close ( char *  filename  ) 
int module_exists ( char *  fileName  ) 

Definition at line 426 of file module.c.

Referenced by find_module_dir(), and module_free().

Module* module_find ( char *  filename  ) 

Definition at line 540 of file module.c.

References DLINK_FOREACH, modules, and Module::name.

Referenced by load_modules(), module_close(), module_open(), and run_mod_que().

void module_free ( Module m  ) 

Definition at line 493 of file module.c.

References dlink_find_delete(), dlink_free(), Module::file, module_exists(), and modules.

Referenced by module_close(), module_open(), and purge_modules().

int module_open ( char *  filename,
int  type 
)

module_open() - Load our module file symbols

Parameters:
filename The file we are trying to link against.
type Type of module we are loading.

  • 0 MOD_TYPE_UNKNOWN Unknown module type it was either loaded after or manualy.
  • 1 MOD_TYPE_PROTOCOL
  • 2 MOD_TYPE_CORE
  • 3 MOD_TYPE_STD
  • 4 MOD_TYPE_CLIENT
Returns:
int
  • 0 = MOD_ERR_OK Loading is successful no error.
    • 1 = MOD_ERR_STOP We recieve a stop either from the module or core.
  • 2 = MOD_ERR_CRIT Criticial error happened while loading.
  • 3 = MOD_ERR_FATAL Fatal error occured while loading.
  • 4 = MOD_ERR_EXISTS Module is already loaded.
  • 5 = MOD_ERR_NOFILE No such file/directory
  • 6 = MOD_ERR_IO We were unable to read symbols from the module file.
  • 7 = MOD_ERR_API No open/closeing functions loaded
  • 8 = MOD_ERR_ABI In Omega ABI refers to the BINARY INTERFACE version which is used to in dicate wether a module will run or not if this is returned the ABI values do not match.
  • 9 = MOD_ERR_MEMORY We were unable to allocate memory.
  • 10 = MOD_ERR_UNLOAD Module file is unsafe to unload
  • 11 = MOD_ERR_SYNTAX Someything funky was passed to us.
  • 13 = MOD_ERR_NOMOD Core is running in skeleton no moudles cannot be loaded
Note:
we dont wanna exit if a module fails just return fail status, so the caller can handle errors.

Definition at line 333 of file module.c.

References ABI_VERSION, Module::age, create_mod_temp(), dlink_add_tail(), dlink_create(), Module::file, Module::handle, Module::mi, MOD_ERR_API, MOD_ERR_EXISTS, MOD_ERR_IO, MOD_ERR_MEMORY, MOD_ERR_OK, ModuleInfo::mod_register, module_find(), module_free(), modules, Module::name, throwModErr, and Module::type.

Referenced by load_modules(), load_protocol(), and run_mod_que().

void purge_modules (  ) 
int run_mod_que ( int  load  ) 
Generated on Mon Jul 19 21:53:05 2010 for Omega Security Services by  doxygen 1.6.3