summaryrefslogtreecommitdiff
path: root/amiga_lib/stubs/auto.c
diff options
context:
space:
mode:
Diffstat (limited to 'amiga_lib/stubs/auto.c')
-rwxr-xr-xamiga_lib/stubs/auto.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/amiga_lib/stubs/auto.c b/amiga_lib/stubs/auto.c
new file mode 100755
index 0000000..bbe61d6
--- /dev/null
+++ b/amiga_lib/stubs/auto.c
@@ -0,0 +1,39 @@
+#include <proto/exec.h>
+#include <proto/dos.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+struct Interface *IHubbub = NULL;
+
+void __init_hubbub_IHubbub(void) __attribute__((constructor));
+void __exit_hubbub_IHubbub(void) __attribute__((destructor));
+
+void __init_hubbub_IHubbub(void)
+{
+ struct Library * LibBase = IExec->OpenLibrary("hubbub.library", 2L);
+
+ if (LibBase)
+ {
+ IHubbub = IExec->GetInterface(LibBase, "main", 1, NULL);
+ }
+
+ if (!IHubbub)
+ {
+ fprintf(stderr, "Could not open hubbub.library v2\n");
+
+ IExec->CloseLibrary(LibBase);
+ exit(EXIT_FAILURE);
+ }
+}
+
+void __exit_hubbub_IHubbub(void)
+{
+ if (IHubbub)
+ {
+ struct Library * LibBase = IHubbub->Data.LibBase;
+
+ IExec->DropInterface(IHubbub);
+ IExec->CloseLibrary(LibBase);
+ IHubbub = NULL;
+ }
+}