HTP  0.3
Data Structures | Defines | Typedefs | Functions
hooks.h File Reference
#include "dslib.h"
Include dependency graph for hooks.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  htp_hook_t
struct  htp_callback_t

Defines

#define HOOK_ERROR   -1
#define HOOK_OK   0
#define HOOK_DECLINED   1

Typedefs

typedef struct htp_hook_t htp_hook_t
typedef struct htp_callback_t htp_callback_t
typedef int(* htp_callback_fn_t )(void *)

Functions

int hook_register (htp_hook_t **hook, htp_callback_fn_t callback_fn)
int hook_run_one (htp_hook_t *hook, void *data)
int hook_run_all (htp_hook_t *hook, void *data)
htp_hook_thook_create (void)
htp_hook_thook_copy (htp_hook_t *hook)
void hook_destroy (htp_hook_t *hook)

Detailed Description

Author:
Ivan Ristic <ivanr@webkreator.com>

Define Documentation

#define HOOK_DECLINED   1
#define HOOK_ERROR   -1
#define HOOK_OK   0

Typedef Documentation

typedef int(* htp_callback_fn_t)(void *)
typedef struct htp_hook_t htp_hook_t

Function Documentation

htp_hook_t* hook_copy ( htp_hook_t hook)

Creates a copy of the provided hook. The hook is allowed to be NULL, in which case this function simply returns a NULL.

Parameters:
hook
Returns:
A copy of the hook, or NULL (if the provided hook was NULL or, if it wasn't, if there was a memory allocation problem while constructing a copy).

Here is the call graph for this function:

Here is the caller graph for this function:

htp_hook_t* hook_create ( void  )

Creates a new hook.

Returns:
New htp_hook_t structure on success, NULL on failure

Here is the call graph for this function:

Here is the caller graph for this function:

void hook_destroy ( htp_hook_t hook)

Destroys an existing hook. It is all right to send a NULL to this method because it will simply return straight away.

Parameters:
hook

Here is the caller graph for this function:

int hook_register ( htp_hook_t **  hook,
htp_callback_fn_t  callback_fn 
)

Registers a new callback with the hook.

Parameters:
hook
callback_fn
Returns:
1 on success, -1 on memory allocation error

Here is the call graph for this function:

Here is the caller graph for this function:

int hook_run_all ( htp_hook_t hook,
void *  data 
)

Runs all the callbacks associated with a given hook. Only stops if one of the callbacks returns an error (HOOK_ERROR).

Parameters:
hook
data
Returns:
HOOK_OK or HOOK_ERROR

Here is the caller graph for this function:

int hook_run_one ( htp_hook_t hook,
void *  data 
)

Run callbacks until one of them accepts to service the hook.

Parameters:
hook
data
Returns:
HOOK_OK on success, HOOK_DECLINED if no callback wanted to run and HOOK_ERROR on error.