1 #include <stdio.h>
2
3 #include <system_includes.h>
4
5 #ifndef __SDL_WRAPPER__
6 /*
7 ** A small routine to open a library and get its default
8 ** interface, and report errors if anything fails.
9 */
getLibIFace(struct Library ** libbase,TEXT * libname,uint32 version,void * ifaceptr)10 BOOL getLibIFace( struct Library **libbase, TEXT *libname, uint32 version, void *ifaceptr )
11 {
12 struct Interface **ifptr = (struct Interface **)ifaceptr;
13
14 *libbase = IExec->OpenLibrary( libname, version );
15 if( *libbase == NULL )
16 {
17 printf( "Unable to open '%s' version %ld\n", libname, version );
18 return FALSE;
19 }
20
21 *ifptr = IExec->GetInterface( *libbase, "main", 1, NULL );
22 if( *ifptr == NULL )
23 {
24 printf( "Unable to get the main interface for '%s'\n", libname );
25 return FALSE;
26 }
27
28 return TRUE;
29 }
30 #endif
31
allocnode(int32 size)32 struct Node *allocnode(int32 size)
33 {
34 #ifndef __SDL_WRAPPER__
35 return IExec->AllocSysObjectTags(ASOT_NODE, ASONODE_Size, size, TAG_DONE);
36 #else
37 struct Node *ptr = malloc(size);
38 if (ptr) memset(ptr, 0, sizeof(struct Node));
39 return ptr;
40 #endif
41 }
42