summaryrefslogtreecommitdiff
path: root/amiga_lib/stubs/auto.c
blob: bbe61d63142c244ef60c8e44da7e5ca5f6e5d0a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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;
    }
}