Example #1
0
/* auto init */
static int BattClock_Init(struct BattClockBase *BattClockBase)
{
    APTR HostLibBase;
    ULONG r;

    HostLibBase = OpenResource("hostlib.resource");
    D(bug("[battclock] HostLibBase = 0x%08lX\n", HostLibBase));

    if (HostLibBase)
    {
        BattClockBase->Lib = HostLib_Open(LIBC_NAME, NULL);
        if (BattClockBase->Lib)
	{
    	    BattClockBase->SysIFace = (struct BattclockInterface *)HostLib_GetInterface(BattClockBase->Lib, Symbols, &r);
    	    D(bug("[battclock] SysIFace = 0x%08lX, unresolved: %u\n", BattClockBase->SysIFace, r));

    	    if (BattClockBase->SysIFace)
	    {
    	        if (!r)
    	            return 1;
    	        HostLib_DropInterface((APTR)BattClockBase->SysIFace);
    	    }
    	    HostLib_Close(BattClockBase->Lib, NULL);
    	}
    }
    return 0;
}
Example #2
0
static int bsdsocket_Init(struct bsdsocketBase *SocketBase)
{
    APTR HostLibBase = OpenResource("hostlib.resource");

    if (!HostLibBase)
	return FALSE;
    SocketBase->HostLibBase = HostLibBase;

    SocketBase->winsock = HostLib_Open("Ws2_32.dll", NULL);
    if (!SocketBase->winsock)
	return FALSE;

    SocketBase->resolver = HostLib_Open("Libs\\Host\\bsdsocket.dll", NULL);
    if (!SocketBase->resolver)
	return FALSE;

    SocketBase->WSIFace = (struct WinSockInterface *)HostLib_GetInterface(SocketBase->winsock, ws_functions, NULL);
    if (!SocketBase->WSIFace)
    {
	D(bug("[socket] Failed to obtain winsock interface\n"));
	return FALSE;
    }

    SocketBase->ResIFace = (struct HostSocketInterface *)HostLib_GetInterface(SocketBase->resolver, res_functions, NULL);
    if (!SocketBase->ResIFace)
	return FALSE;

    NewList((struct List *)&SocketBase->socks);

    Forbid();
    SocketBase->ctl = SocketBase->ResIFace->sock_init();
    Permit();

    if (!SocketBase->ctl)
	return FALSE;

    return TRUE;
}
Example #3
0
/* auto init */
static int BattClock_Init(struct BattClockBase *BattClockBase)
{
    APTR HostLibBase;
    ULONG r;

    HostLibBase = OpenResource("hostlib.resource");
    D(bug("[battclock] HostLibBase = 0x%08lX\n", HostLibBase));
    if (HostLibBase) {
        BattClockBase->Lib = HostLib_Open("kernel32.dll", NULL);
        if (BattClockBase->Lib) {
    	    BattClockBase->KernelIFace = (struct KernelInterface *)HostLib_GetInterface(BattClockBase->Lib, Symbols, &r);
    	    D(bug("[battclock] KernelIFace = 0x%08lX\n", BattClockBase->KernelIFace));
    	    if (BattClockBase->KernelIFace) {
    	        if (!r)
    	            return 1;
    	        HostLib_DropInterface((APTR)BattClockBase->KernelIFace);
    	    }
    	    HostLib_Close(BattClockBase->Lib, NULL);
    	}
    }
    return 0;
}
Example #4
0
APTR *gdi_hostlib_load_so(const char *sofile, const char **names, void **handle)
{
    APTR *funcptr;
    ULONG i;

    D(bug("[gdi] loading functions from %s\n", sofile));

    if ((*handle = HostLib_Open(sofile, NULL)) == NULL) {
        D(kprintf("[gdi] couldn't open '%s'\n", sofile));
        return NULL;
    }

    funcptr = HostLib_GetInterface(*handle, names, &i);
    if (funcptr) {
        if (!i) {
            D(bug("[gdi] done\n"));
            return funcptr;
        }
        D(kprintf("[gdi] couldn't get %lu symbols from '%s'\n", i, sofile));
        HostLib_DropInterface(funcptr);
    }
    HostLib_Close(*handle, NULL);
    return NULL;
}