diff options
Diffstat (limited to 'code/tools/lcc/src/event.c')
-rw-r--r-- | code/tools/lcc/src/event.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/code/tools/lcc/src/event.c b/code/tools/lcc/src/event.c new file mode 100644 index 0000000..4549e3f --- /dev/null +++ b/code/tools/lcc/src/event.c @@ -0,0 +1,28 @@ +#include "c.h" + + +struct entry { + Apply func; + void *cl; +}; + +Events events; +void attach(Apply func, void *cl, List *list) { + struct entry *p; + + NEW(p, PERM); + p->func = func; + p->cl = cl; + *list = append(p, *list); +} +void apply(List event, void *arg1, void *arg2) { + if (event) { + List lp = event; + do { + struct entry *p = lp->x; + (*p->func)(p->cl, arg1, arg2); + lp = lp->link; + } while (lp != event); + } +} + |