Typedefs | Functions
modstack.c File Reference

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

#include "config.h"
#include <ctype.h>
#include "services/modstack.h"
#include "util/module.h"
#include "util/fptr_wlist.h"
#include "dns64/dns64.h"
#include "iterator/iterator.h"
#include "validator/validator.h"
#include "respip/respip.h"

Typedefs

typedef struct module_func_block *(* fbgetfunctype) (void)
 func block get function type
 

Functions

static int count_modules (const char *s)
 count number of modules (words) in the string
 
void modstack_init (struct module_stack *stack)
 Init a stack of modules. More...
 
int modstack_config (struct module_stack *stack, const char *module_conf)
 Read config file module settings and set up the modfunc block. More...
 
const char ** module_list_avail (void)
 The list of module names. More...
 
static fbgetfunctypemodule_funcs_avail (void)
 The list of module func blocks.
 
struct module_func_blockmodule_factory (const char **str)
 Get funcblock for module name. More...
 
int modstack_setup (struct module_stack *stack, const char *module_conf, struct module_env *env)
 Setup modules. More...
 
void modstack_desetup (struct module_stack *stack, struct module_env *env)
 Desetup the modules, deinit, delete. More...
 
int modstack_find (struct module_stack *stack, const char *name)
 Find index of module by name. More...
 
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
 

Detailed Description

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

Function Documentation

◆ modstack_init()

void modstack_init ( struct module_stack stack)

Init a stack of modules.

Parameters
stackinitialised as empty.

References module_stack::mod, and module_stack::num.

Referenced by ub_ctx_create_nopipe().

◆ 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

References count_modules(), log_err(), MAX_MODULE, module_stack::mod, module_factory(), module_stack::num, VERB_QUERY, and verbose().

Referenced by modstack_setup().

◆ module_list_avail()

const char** module_list_avail ( void  )

The list of module names.

Get list of modules available.

Referenced by module_factory(), and usage().

◆ 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.

References module_funcs_avail(), and module_list_avail().

Referenced by modstack_config().

◆ 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.

References fptr_ok, fptr_whitelist_mod_init(), module_func_block::init, log_err(), module_stack::mod, modstack_config(), modstack_desetup(), module_func_block::name, module_env::need_to_validate, module_stack::num, VERB_OPS, and verbose().

Referenced by context_finalize(), and daemon_setup_modules().

◆ 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.

References module_func_block::deinit, fptr_ok, fptr_whitelist_mod_deinit(), module_stack::mod, and module_stack::num.

Referenced by daemon_delete(), modstack_setup(), ub_ctx_create(), and ub_ctx_delete().

◆ 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.

References module_stack::mod, module_func_block::name, and module_stack::num.

Referenced by do_set_option(), get_queries_ratelimit(), get_rrset_bogus(), and mod_get_mem().