62 #include <amxc/amxc.h>
71 amxc_llist_it_t* it = slot == NULL ? amxc_llist_get_first(&sig->
slots) :
72 amxc_llist_it_get_next(&slot->
it);
79 it = amxc_llist_it_get_next(&slot->
it);
89 const char*
const sig_name) {
90 amxc_htable_it_t* hit = NULL;
94 hit = amxc_htable_get(signals, sig_name);
105 const char* expression,
109 when_null(slot, exit);
112 slot->
regexp = regexp == NULL ? NULL : strdup(regexp);
113 if(expression != NULL) {
119 if((retval != 0) && (slot != NULL)) {
130 const char* expression,
137 if((expression == NULL) && (slot->
expr == NULL) && (priv == NULL)) {
147 when_null(slot, exit);
148 amxc_llist_append(&sig->
slots, &slot->
it);
158 const char*
const regexp_str,
159 const char* expression,
162 bool use_reg_exp =
false;
165 if((regexp_str != NULL) && (regexp_str[0] != 0)) {
167 retval = regcomp(®exp, regexp_str, REG_NOSUB | REG_EXTENDED);
184 amxc_htable_for_each(it, signals) {
187 when_failed(retval, exit);
197 const char*
const regexp,
198 const char* expression,
202 amxc_llist_for_each(it, sigmngrs) {
222 while(slot != NULL) {
231 amxc_llist_it_t* next = NULL;
232 amxc_llist_it_t* regexp_it = NULL;
233 amxc_htable_for_each(it, signals) {
244 next = amxc_llist_it_get_next(regexp_it);
245 slot = amxc_llist_it_get_data(regexp_it,
amxp_slot_t, it);
256 amxc_llist_for_each(it, sigmngrs) {
265 const char*
const sig_name,
276 if((sig != NULL) && (slot != NULL)) {
280 amxc_llist_it_t* it = amxc_llist_get_first(&sig_mngr->
regexp_slots);
281 amxc_llist_it_t* next = NULL;
284 slot = amxc_llist_it_get_data(it,
amxp_slot_t, it);
285 next = amxc_llist_it_get_next(it);
286 regcomp(®exp, slot->
regexp, REG_NOSUB | REG_EXTENDED);
287 if((slot->
fn == fn) &&
288 ( regexec(®exp, sig_name, 0, NULL, 0) == 0)) {
301 const char*
const sig_name,
302 const char*
const expression,
308 when_null(sig_name, exit);
309 when_true(*sig_name == 0, exit);
312 if(strcmp(sig_name,
"*") == 0) {
313 if(sig_mngr == NULL) {
322 when_null(sig, exit);
331 const char*
const sig_reg_exp,
332 const char*
const expression,
337 when_null(sig_reg_exp, exit);
338 when_true(*sig_reg_exp == 0, exit);
342 when_null(mngr, exit);
354 const char*
const expression,
358 amxc_llist_t* sigmngrs = NULL;
359 amxc_llist_t* pending_sigmngrs = NULL;
381 const char*
const sig_name,
385 when_null(sig_name, exit);
386 when_true(*sig_name == 0, exit);
389 if(strcmp(sig_name,
"*") == 0) {
390 if(sig_mngr == NULL) {
412 const char* sig_name,
416 amxc_llist_it_t* slot_it = NULL;
417 amxc_llist_it_t* next = NULL;
418 const amxc_htable_t* signals = NULL;
422 amxc_htable_for_each(it, signals) {
424 if((sig_name != NULL) && (strcmp(sig_name, sig->
name) != 0)) {
427 slot_it = amxc_llist_get_first(&sig->
slots);
428 while(slot_it != NULL) {
430 next = amxc_llist_it_get_next(slot_it);
431 slot = amxc_llist_it_get_data(slot_it,
amxp_slot_t, it);
432 if(((slot->
fn == fn) || (fn == NULL)) &&
433 ( slot->
priv == priv)) {
440 if(sig_name == NULL) {
441 slot_it = amxc_llist_get_first(&sig_mngr->
regexp_slots);
442 while(slot_it != NULL) {
444 next = amxc_llist_it_get_next(slot_it);
445 slot = amxc_llist_it_get_data(slot_it,
amxp_slot_t, it);
446 if(((slot->
fn == fn) || (fn == NULL)) &&
447 ( slot->
priv == priv)) {
460 amxc_llist_t* sigmngrs = NULL;
461 amxc_llist_t* pending_sigmngrs = NULL;
Ambiorix expression parser and evaluate API header file.
amxp_signal_mngr_t * amxp_get_sigmngr(amxp_signal_mngr_t *sig_mngr)
const amxc_htable_t PRIVATE * amxp_get_signals(const amxp_signal_mngr_t *sig_mngr)
void PRIVATE amxp_get_sigmngrs(amxc_llist_t **sigmngrs, amxc_llist_t **pending_sigmngrs)
void PRIVATE amxp_free_slots(amxc_llist_it_t *it)
static void amxp_slot_disconnect_all_sgmngrs(const amxc_llist_t *const sigmngrs, amxp_slot_fn_t fn)
static void amxp_slot_disconnnect_all_of(const amxp_signal_mngr_t *const sigmngr, amxp_slot_fn_t fn)
static int amxp_slot_connnect_all_sigmngrs(const amxc_llist_t *const sigmngrs, amxp_slot_fn_t fn, const char *const regexp, const char *expression, void *const priv)
static int amxp_slot_disconnect_name(amxp_signal_mngr_t *sig_mngr, const char *const sig_name, amxp_slot_fn_t fn)
static amxp_slot_t * amxp_slot_new(amxp_slot_fn_t fn, const char *regexp, const char *expression, void *const priv)
static int amxp_slot_connect_impl(amxp_signal_t *sig, amxp_slot_fn_t fn, const char *expression, void *const priv)
static void amxp_slot_delete_all(amxp_signal_t *sig, amxp_slot_t *slot, amxp_slot_fn_t fn)
static amxp_slot_t * amxp_slot_find(const amxp_signal_t *const sig, amxp_slot_fn_t fn, amxp_slot_t *start)
static int amxp_slot_connnect_all_of(amxp_signal_mngr_t *const sigmngr, amxp_slot_fn_t fn, const char *const regexp_str, const char *expression, void *const priv)
static amxp_signal_t * amxp_slot_find_signal(const amxp_signal_mngr_t *const sig_mngr, const char *const sig_name)
amxp_expr_status_t amxp_expr_new(amxp_expr_t **expr, const char *expression)
Allocates and initializes an expression.
void amxp_expr_delete(amxp_expr_t **expr)
Deletes a previously allocated expression structure.
void amxp_slot_disconnect_all(amxp_slot_fn_t fn)
Disconnects a slot from all signals it was connected to.
int amxp_slot_connect_all(const char *sig_reg_exp, const char *const expression, amxp_slot_fn_t fn, void *const priv)
Connects a slot to all existing and future signals.
int amxp_slot_disconnect_signal_with_priv(amxp_signal_mngr_t *sig_mngr, const char *sig_name, amxp_slot_fn_t fn, void *priv)
Disconnects a slot from a signal.
int amxp_slot_connect_filtered(amxp_signal_mngr_t *const sig_mngr, const char *const sig_reg_exp, const char *const expression, amxp_slot_fn_t fn, void *const priv)
Connects a slot (function) to signals using a regular expression.
int amxp_slot_disconnect(amxp_signal_mngr_t *const sig_mngr, const char *const sig_name, amxp_slot_fn_t fn)
Disconnects a slot from (a) signal(s).
void(* amxp_slot_fn_t)(const char *const sig_name, const amxc_var_t *const data, void *const priv)
Slot callback function signature.
int amxp_slot_connect(amxp_signal_mngr_t *const sig_mngr, const char *const sig_name, const char *const expression, amxp_slot_fn_t fn, void *const priv)
Connects a slot (function) to a named signal of a signal manager.
int amxp_slot_disconnect_with_priv(amxp_signal_mngr_t *sig_mngr, amxp_slot_fn_t fn, void *priv)
Disconnects a slot from (a) signal(s).
Structure containing the signal manager information.
amxc_llist_t regexp_slots
Structure containing the signal information.
static amxp_signal_mngr_t * sigmngr