Mir 1.0
Mir application programming interface
Hooks system

Macros

#define MIRKL_IMPLEMENT_HOOK_GET_PROTO(ns, link, name)    link##_DECLARE(mirkl_dllist_t *) ns##_hook_get_##name(void)
 
#define MIRKL_DECLARE_EXTERNAL_HOOK(ns, link, ret, name, args)
 
#define MIRKL_HOOK_STRUCT(members)    static struct { members } _hooks={0};
 
#define MIRKL_HOOK_LINK(name)
 
#define MIRKL_IMPLEMENT_EXTERNAL_HOOK_BASE(ns, link, name)
 
#define MIRKL_IMPLEMENT_EXTERNAL_HOOK_VOID(ns, link, name, args_decl, args_use)
 
#define MIRKL_HOOK_REALLY_FIRST   (-10)
 
#define MIRKL_HOOK_FIRST   0
 
#define MIRKL_HOOK_MIDDLE   10
 
#define MIRKL_HOOK_LAST   20
 
#define MIRKL_HOOK_REALLY_LAST   30
 

Functions

int mirkl_hook_bubsort_callback (int atag, void *amem, int btag, void *bmem, void *args)
 

Detailed Description

Macro Definition Documentation

◆ MIRKL_DECLARE_EXTERNAL_HOOK

#define MIRKL_DECLARE_EXTERNAL_HOOK (   ns,
  link,
  ret,
  name,
  args 
)
Value:
typedef ret ns##_HOOK_##name##_t args; \
link##_DECLARE(mirkl_error_t *) ns##_hook_##name(ns##_HOOK_##name##_t *pf, \
const char * const *aszPre, \
const char * const *aszSucc, int nOrder); \
link##_DECLARE(ret) ns##_run_##name args; \
MIRKL_IMPLEMENT_HOOK_GET_PROTO(ns,link,name); \
typedef struct ns##_LINK_##name##_t \
{ \
ns##_HOOK_##name##_t *pFunc; \
char name[100]; \
int nOrder; \
} ns##_LINK_##name##_t;
Structure of error object.
Definition: mirkl_error.h:41

macro to declare the hook correctly

◆ MIRKL_HOOK_FIRST

#define MIRKL_HOOK_FIRST   0

run this hook first

◆ MIRKL_HOOK_LAST

#define MIRKL_HOOK_LAST   20

run this hook after every other hook which is defined

◆ MIRKL_HOOK_LINK

#define MIRKL_HOOK_LINK (   name)
Value:
apr_pool_t *pool_##name; \
mirkl_dllist_t *link_##name;

macro to link the hook structure

◆ MIRKL_HOOK_MIDDLE

#define MIRKL_HOOK_MIDDLE   10

run this hook somewhere

◆ MIRKL_HOOK_REALLY_FIRST

#define MIRKL_HOOK_REALLY_FIRST   (-10)

run this hook first, before ANYTHING

◆ MIRKL_HOOK_REALLY_LAST

#define MIRKL_HOOK_REALLY_LAST   30

run this hook last, after EVERYTHING

◆ MIRKL_HOOK_STRUCT

#define MIRKL_HOOK_STRUCT (   members)     static struct { members } _hooks={0};

macro to declare the hook structure

◆ MIRKL_IMPLEMENT_EXTERNAL_HOOK_BASE

#define MIRKL_IMPLEMENT_EXTERNAL_HOOK_BASE (   ns,
  link,
  name 
)

macro to implement the hook

◆ MIRKL_IMPLEMENT_EXTERNAL_HOOK_VOID

#define MIRKL_IMPLEMENT_EXTERNAL_HOOK_VOID (   ns,
  link,
  name,
  args_decl,
  args_use 
)
Value:
link##_DECLARE(void) ns##_run_##name args_decl \
{ \
mirkl_dllist_t *ThisItem; \
ns##_LINK_##name##_t *pHook; \
if(_hooks.link_##name != NULL) { \
for(ThisItem = mirkl_dl_get_first(_hooks.link_##name); ThisItem != NULL; ThisItem = ThisItem->Next) { \
if(ThisItem->Tag > 0) { \
pHook = (ns##_LINK_##name##_t *)ThisItem->Object; \
pHook->pFunc args_use; \
} \
} \
} \
}
#define MIRKL_IMPLEMENT_EXTERNAL_HOOK_BASE(ns, link, name)
Definition: mirkl_hooks.h:65
struct mirkl_dllist_t_ * Next
Next node.
Definition: mirkl_dllist.h:34

Implement a hook that has no return code, and therefore runs all of the registered functions

Parameters
nsThe namespace prefix of the hook functions
linkThe linkage declaration prefix of the hook
nameThe name of the hook
args_declThe declaration of the arguments for the hook
args_useThe names for the arguments for the hook
Note
The link prefix FOO corresponds to FOO_DECLARE() macros, which provide export linkage from the module that IMPLEMENTs the hook, and import linkage from external modules that link to the hook's module.

◆ MIRKL_IMPLEMENT_HOOK_GET_PROTO

#define MIRKL_IMPLEMENT_HOOK_GET_PROTO (   ns,
  link,
  name 
)     link##_DECLARE(mirkl_dllist_t *) ns##_hook_get_##name(void)

macro to return the prototype of the hook function