2000-04-26 04:03:38 -04:00
|
|
|
#ifndef __SIGNAL_H
|
|
|
|
#define __SIGNAL_H
|
|
|
|
|
2002-04-15 09:59:09 -04:00
|
|
|
#define SIGNAL_PRIORITY_LOW 100
|
|
|
|
#define SIGNAL_PRIORITY_DEFAULT 0
|
|
|
|
#define SIGNAL_PRIORITY_HIGH -100
|
|
|
|
|
2001-01-03 02:34:12 -05:00
|
|
|
#define SIGNAL_MAX_ARGUMENTS 6
|
2002-04-15 09:59:09 -04:00
|
|
|
typedef void (*SIGNAL_FUNC) (const void *, const void *,
|
|
|
|
const void *, const void *,
|
|
|
|
const void *, const void *);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2002-04-15 09:59:09 -04:00
|
|
|
extern void *signal_user_data; /* use signal_get_user_data() macro to access */
|
2000-06-25 19:39:23 -04:00
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
/* bind a signal */
|
2002-04-15 09:59:09 -04:00
|
|
|
void signal_add_full(const char *module, int priority,
|
|
|
|
const char *signal, SIGNAL_FUNC func, void *user_data);
|
|
|
|
void signal_add_full_id(const char *module, int priority,
|
|
|
|
int signal, SIGNAL_FUNC func, void *user_data);
|
|
|
|
#define signal_add(signal, func) \
|
|
|
|
signal_add_full(MODULE_NAME, SIGNAL_PRIORITY_DEFAULT, (signal), (SIGNAL_FUNC) (func), NULL)
|
|
|
|
#define signal_add_first(signal, func) \
|
|
|
|
signal_add_full(MODULE_NAME, SIGNAL_PRIORITY_HIGH, (signal), (SIGNAL_FUNC) (func), NULL)
|
|
|
|
#define signal_add_last(signal, func) \
|
|
|
|
signal_add_full(MODULE_NAME, SIGNAL_PRIORITY_LOW, (signal), (SIGNAL_FUNC) (func), NULL)
|
|
|
|
|
|
|
|
#define signal_add_data(signal, func, data) \
|
|
|
|
signal_add_full(MODULE_NAME, SIGNAL_PRIORITY_DEFAULT, (signal), (SIGNAL_FUNC) (func), data)
|
|
|
|
#define signal_add_first_data(signal, func, data) \
|
|
|
|
signal_add_full(MODULE_NAME, SIGNAL_PRIORITY_HIGH, (signal), (SIGNAL_FUNC) (func), data)
|
|
|
|
#define signal_add_last_data(signal, func, data) \
|
|
|
|
signal_add_full(MODULE_NAME, SIGNAL_PRIORITY_LOW, (signal), (SIGNAL_FUNC) (func), data)
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
/* unbind signal */
|
2002-04-15 09:59:09 -04:00
|
|
|
void signal_remove_full(const char *signal, SIGNAL_FUNC func, void *user_data);
|
|
|
|
#define signal_remove(signal, func) \
|
|
|
|
signal_remove_full((signal), (SIGNAL_FUNC) (func), NULL)
|
|
|
|
#define signal_remove_data(signal, func, data) \
|
|
|
|
signal_remove_full((signal), (SIGNAL_FUNC) (func), data)
|
|
|
|
void signal_remove_id(int signal_id, SIGNAL_FUNC func, void *user_data);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
/* emit signal */
|
|
|
|
int signal_emit(const char *signal, int params, ...);
|
|
|
|
int signal_emit_id(int signal_id, int params, ...);
|
|
|
|
|
2002-04-27 17:53:25 -04:00
|
|
|
/* continue currently emitted signal with different parameters */
|
|
|
|
void signal_continue(int params, ...);
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
/* stop the current ongoing signal emission */
|
|
|
|
void signal_stop(void);
|
|
|
|
/* stop ongoing signal emission by signal name */
|
|
|
|
void signal_stop_by_name(const char *signal);
|
|
|
|
|
2001-01-03 02:34:12 -05:00
|
|
|
/* return the name of the signal that is currently being emitted */
|
|
|
|
const char *signal_get_emitted(void);
|
|
|
|
/* return the ID of the signal that is currently being emitted */
|
|
|
|
int signal_get_emitted_id(void);
|
2001-01-07 03:23:06 -05:00
|
|
|
/* return TRUE if specified signal was stopped */
|
|
|
|
int signal_is_stopped(int signal_id);
|
2002-04-15 09:59:09 -04:00
|
|
|
/* return the user data of the signal function currently being emitted */
|
|
|
|
#define signal_get_user_data() signal_user_data
|
2001-01-03 02:34:12 -05:00
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
/* remove all signals that belong to `module' */
|
|
|
|
void signals_remove_module(const char *module);
|
|
|
|
|
2002-04-15 09:59:09 -04:00
|
|
|
/* signal name -> ID */
|
|
|
|
#define signal_get_uniq_id(signal) \
|
|
|
|
module_get_uniq_id_str("signals", signal)
|
|
|
|
/* signal ID -> name */
|
|
|
|
#define signal_get_id_str(signal_id) \
|
|
|
|
module_find_id_str("signals", signal_id)
|
|
|
|
|
|
|
|
void signals_init(void);
|
|
|
|
void signals_deinit(void);
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
#endif
|