Data Structures | Typedefs | Functions

cb_list.h File Reference

manage lists of callback functions More...

Go to the source code of this file.

Data Structures

struct  cb_list_entry_s
 Callback List entry type. More...


typedef uint16_t(* cb_function_t )(void *)
 callback function type
typedef struct cb_list_entry_s cb_list_entry_t
 Callback List entry type.
typedef cb_list_entry_tcb_list_t
 type pointer to a callback list


void callback_iterate (cb_list_t list)
 call all functions in callback list
uint16_t callback_iterate_and_until0 (cb_list_t list)
 call functions in callback list, until AND of results is 0
void cb_register_call (cb_list_t *list, cb_function_t fkt2call, void *arg)
 Register a call back function into the given list.

Detailed Description

manage lists of callback functions

Typedef Documentation

Callback List entry type.

The register function will dynamically create a new entry based on this type

Function Documentation

void callback_iterate ( cb_list_t  list  )  [inline]

call all functions in callback list

Iterates over all functions registered in list

list pointer to first item in list

  cb_list_entry_t * p;
  for (p = list; p; p = p->next_entry) {
    (*p->pTargetFkt) (p->FktArg);

void cb_register_call ( cb_list_t list,
cb_function_t  fkt2call,
void *  arg 
) [inline]

Register a call back function into the given list.

The function will add an entry to the list of functions to be called

The new entry is added to the front of the list.

list pointer to list variable
fkt2call function to be called
arg argument to give to fkt2call

  cb_list_entry_t * n;

  // create new element
  n = malloc(sizeof(cb_list_entry_t));
  // link in current start element
  n->next_entry = *list;
  // initialize
  n->pTargetFkt = fkt2call;
  n->FktArg = arg;
  // store new element into first
  *list = n;