6 /* A hook is a function to call with the supplied hook data, and with
7 call site specific data (e.g., hooks for events are called with a
8 pointer to the current event). */
9 // MD compile fix: int instead of bool as return value
10 typedef int (*lttv_hook
)(void *hook_data
, void *call_data
);
13 /* A list of hooks allows registering hooks to be called later. */
15 typedef GArray _lttv_hooks
;
16 typedef _lttv_hooks lttv_hooks
;
18 lttv_hooks
*lttv_hooks_new();
20 void lttv_hooks_destroy(lttv_hooks
*h
);
22 void lttv_hooks_add(lttv_hooks
*h
, lttv_hook f
, void *hook_data
);
24 void lttv_hooks_remove(lttv_hooks
*h
, lttv_hook f
, void *hook_data
);
26 unsigned lttv_hooks_number(lttv_hooks
*h
);
28 void lttv_hooks_get(lttv_hooks
*h
, unsigned i
, lttv_hook
*f
, void **hook_data
);
30 void lttv_hooks_remove_by_position(lttv_hooks
*h
, unsigned i
);
32 int lttv_hooks_call(lttv_hooks
*h
, void *call_data
);
34 int lttv_hooks_call_check(lttv_hooks
*h
, void *call_data
);
37 /* Sometimes different hooks need to be called based on the case. The
38 case is represented by an unsigned integer id and may represent different
39 event types, for instance. */
41 typedef GPtrArray _lttv_hooks_by_id
;
42 typedef _lttv_hooks_by_id lttv_hooks_by_id
;
44 lttv_hooks_by_id
*lttv_hooks_by_id_new();
46 void lttv_hooks_by_id_destroy(lttv_hooks_by_id
*h
);
48 void lttv_hooks_by_id_add(lttv_hooks_by_id
*h
, lttv_hook f
, void *hook_data
,
51 void lttv_hooks_by_id_call(lttv_hooks_by_id
*h
, void *call_data
, unsigned int id
);