Electroneum
modstack.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  module_stack
 

Functions

void modstack_init (struct module_stack *stack)
 
int modstack_config (struct module_stack *stack, const char *module_conf)
 
struct module_func_blockmodule_factory (const char **str)
 
const char ** module_list_avail (void)
 
int modstack_setup (struct module_stack *stack, const char *module_conf, struct module_env *env)
 
void modstack_desetup (struct module_stack *stack, struct module_env *env)
 
int modstack_find (struct module_stack *stack, const char *name)
 
size_t mod_get_mem (struct module_env *env, const char *name)
 

Detailed Description

This file contains functions to help maintain a stack of modules.

Definition in file modstack.h.

Function Documentation

◆ mod_get_mem()

size_t mod_get_mem ( struct module_env env,
const char *  name 
)

fetch memory for a module by name, returns 0 if module not there

◆ modstack_config()

int modstack_config ( struct module_stack stack,
const char *  module_conf 
)

Read config file module settings and set up the modfunc block

Parameters
stackthe stack of modules (empty before call).
module_confstring what modules to insert.
Returns
false on error

◆ modstack_desetup()

void modstack_desetup ( struct module_stack stack,
struct module_env env 
)

Desetup the modules, deinit, delete.

Parameters
stackmade empty.
envmodule env for module deinit() calls.

◆ modstack_find()

int modstack_find ( struct module_stack stack,
const char *  name 
)

Find index of module by name.

Parameters
stackto look in
namethe name to look for
Returns
-1 on failure, otherwise index number.

◆ modstack_init()

void modstack_init ( struct module_stack stack)

Init a stack of modules

Parameters
stackinitialised as empty.

◆ modstack_setup()

int modstack_setup ( struct module_stack stack,
const char *  module_conf,
struct module_env env 
)

Setup modules. Assigns ids and calls module_init.

Parameters
stackif not empty beforehand, it will be desetup()ed. It is then modstack_configged().
module_confstring what modules to insert.
envmodule environment which is inited by the modules. environment should have a superalloc, cfg, env.need_to_validate is set by the modules.
Returns
on false a module init failed.

◆ module_factory()

struct module_func_block* module_factory ( const char **  str)

Get funcblock for module name

Parameters
strstring with module name. Advanced to next value on success. The string is assumed whitespace separated list of module names.
Returns
funcblock or NULL on error.

◆ module_list_avail()

const char** module_list_avail ( void  )

Get list of modules available.

Returns
list of modules available. Static strings, ends with NULL.