aboutsummaryrefslogtreecommitdiff
path: root/HOOK.C
diff options
context:
space:
mode:
Diffstat (limited to 'HOOK.C')
-rw-r--r--HOOK.C38
1 files changed, 38 insertions, 0 deletions
diff --git a/HOOK.C b/HOOK.C
new file mode 100644
index 0000000..4da80a6
--- /dev/null
+++ b/HOOK.C
@@ -0,0 +1,38 @@
+/*--------------------------------------------------------------*/
+/* */
+/* hook.c */
+/* */
+/*--------------------------------------------------------------*/
+
+#include <system.h>
+
+typedef struct {
+ struct MsgPort msgport;
+ UWORD *pointer;
+ } Hook;
+
+SetHook(name,ptr) char *name; UWORD *ptr; {
+ Hook *hook = (Hook *)AllocMem(sizeof(Hook),MEMF_CLEAR|MEMF_PUBLIC);
+ struct MsgPort *p = (struct MsgPort *)hook;
+ p->mp_Flags = 0;
+ p->mp_Node.ln_Pri = 0;
+ p->mp_Node.ln_Name = name;
+ p->mp_Node.ln_Type = NT_MSGPORT;
+ AddPort(p);
+ hook->pointer = ptr;
+ }
+
+UWORD *FindHook(name) UBYTE *name; {
+ Hook *hook = (Hook *)FindPort(name);
+ return((hook != NULL)? hook->pointer: NULL);
+ }
+
+RemHook(name) UBYTE *name; {
+ Hook *hook = (Hook *)FindPort(name);
+ if (hook!=NULL) {
+ RemPort(hook);
+ FreeMem(hook,sizeof(Hook));
+ }
+ }
+
+