X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=Hooks.xs;h=0c9510a4c05d3895a5bf7f04afde9e0c2cc3d9e0;hb=b85e0f01bc196351b28fb97eb8ae37871076722a;hp=af878f3ba502ba703e9dbdde1f90a38d1a7aa222;hpb=d98dbf56343c99b164e93be306735db3f6e6bca5;p=perl%2Fmodules%2Fre-engine-Hooks.git diff --git a/Hooks.xs b/Hooks.xs index af878f3..0c9510a 100644 --- a/Hooks.xs +++ b/Hooks.xs @@ -58,8 +58,7 @@ STATIC SV *reh_hint(pTHX) { typedef struct reh_action { struct reh_action *next; - reh_comp_hook comp; - reh_exec_hook exec; + reh_config cbs; const char *key; STRLEN klen; } reh_action; @@ -73,7 +72,7 @@ STATIC perl_mutex reh_action_list_mutex; #endif /* USE_ITHREADS */ #undef reh_register -void reh_register(pTHX_ const char *key, reh_comp_hook comp, reh_exec_hook exec) { +void reh_register(pTHX_ const char *key, reh_config *cfg) { reh_action *a; char *key_dup; STRLEN i, len; @@ -87,8 +86,7 @@ void reh_register(pTHX_ const char *key, reh_comp_hook comp, reh_exec_hook exec) key_dup[len] = '\0'; a = PerlMemShared_malloc(sizeof *a); - a->comp = comp; - a->exec = exec; + a->cbs = *cfg; a->key = key_dup; a->klen = len; @@ -115,11 +113,11 @@ void reh_call_comp_hook(pTHX_ regexp *rx, regnode *node) { REH_UNLOCK(&reh_action_list_mutex); for (; a; a = a->next) { - if (a->comp) { + if (a->cbs.comp) { char *p = strstr(keys, a->key); if (p && (p + a->klen <= keys + len) && p[a->klen] == ' ') - a->comp(aTHX_ rx, node); + a->cbs.comp(aTHX_ rx, node); } } } @@ -138,11 +136,11 @@ void reh_call_exec_hook(pTHX_ regexp *rx, regnode *node, regmatch_info *reginfo, REH_UNLOCK(&reh_action_list_mutex); for (; a; a = a->next) { - if (a->exec) { + if (a->cbs.exec) { char *p = strstr(keys, a->key); if (p && (p + a->klen <= keys + len) && p[a->klen] == ' ') - a->exec(aTHX_ rx, node, reginfo, st); + a->cbs.exec(aTHX_ rx, node, reginfo, st); } } }