Example #1
0
static int gdi_hostlib_init(LIBBASETYPEPTR LIBBASE) {
    D(bug("[gdi] hostlib init\n"));

/*  if ((KernelBase = OpenResource("kernel.resource")) == NULL) {
        kprintf("[gdi] couldn't open kernel.resource");
        return FALSE;
    }*/
    if ((HostLibBase = OpenResource("hostlib.resource")) == NULL) {
        kprintf("[gdi] couldn't open hostlib.resource");
        return FALSE;
    }

    gdi_func = (struct gdi_func *)gdi_hostlib_load_so(GDI_SOFILE, gdi_func_names, &gdi_handle);
    if (!gdi_func)
        return FALSE;
    user_func = (struct user_func *)gdi_hostlib_load_so(USER_SOFILE, user_func_names, &user_handle);
    if (user_func) {
        native_func = (struct native_func *)gdi_hostlib_load_so(NATIVE_SOFILE, native_func_names, &native_handle);
        if (native_func)
            return TRUE;
        HostLib_DropInterface((APTR *)user_func);
    	HostLib_Close(user_handle, NULL);
    }
    HostLib_DropInterface((APTR *)gdi_func);
    HostLib_Close(gdi_handle, NULL);
    return FALSE;
}
Example #2
0
static int gdi_hostlib_expunge(LIBBASETYPEPTR LIBBASE) {
    D(bug("[gdi] hostlib expunge\n"));

    if (gdi_func != NULL)
        HostLib_DropInterface((APTR *)gdi_func);
    if (gdi_handle != NULL)
        HostLib_Close(gdi_handle, NULL);

    if (native_func != NULL)
        HostLib_DropInterface((APTR *)native_func);
    if (native_handle != NULL)
        HostLib_Close(native_handle, NULL);

    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(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 #4
0
static int bsdsocket_Cleanup(struct bsdsocketBase *SocketBase)
{
    APTR HostLibBase = SocketBase->HostLibBase;

    D(bug("[socket] Cleanup, HostLibBase is 0x%p\n", HostLibBase));
    if (!HostLibBase)
	return TRUE;

    if (SocketBase->ResIFace)
    {
	if (SocketBase->ctl)
	{
	    int res;

	    Forbid();
	    res = SocketBase->ResIFace->sock_shutdown(SocketBase->ctl);
	    Permit();
	    
	    if (res)
		return FALSE;
	}
    }
	
    if (SocketBase->WSIFace)
	HostLib_DropInterface((void **)SocketBase->WSIFace);

    if (SocketBase->winsock)
	HostLib_Close(SocketBase->winsock, NULL);

    return TRUE;
}
Example #5
0
static int HostDisk_Cleanup(struct HostDiskBase *hdskBase)
{
    D(bug("hostdisk: Expunge(0x%p)\n", hdskBase));

    if (!HostLibBase)
        return TRUE;

    if (hdskBase->iface)
        HostLib_DropInterface((APTR *)hdskBase->iface);

    if (hdskBase->KernelHandle)
        HostLib_Close(hdskBase->KernelHandle, NULL);

    return TRUE;
}
Example #6
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 #7
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;
}