Copyright clean-up (part 1):
[AROS.git] / arch / all-mingw32 / bootstrap / hostlib.c
blobdd6725481fb632fc2e862f686739327b5c244a21
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <stdio.h>
7 #include <windows.h>
9 #include "hostlib.h"
11 #define D(x)
13 static void GetErrorStr(char **error, BOOL condition)
15 if (error != NULL) {
16 if (condition) {
17 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
18 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)error, 0, NULL );
19 } else
20 *error = NULL;
24 void __aros Host_HostLib_FreeErrorStr(char *error)
26 LocalFree(error);
29 void * __aros Host_HostLib_Open(const char *filename, char **error)
31 HMODULE handle;
33 D(printf("[hostlib] Open: filename=%s\n", filename));
34 handle = LoadLibrary(filename);
35 GetErrorStr(error, !handle);
37 return handle;
40 int __aros Host_HostLib_Close(void *handle, char **error)
42 int err;
44 D(printf("[hostlib] Close: handle=0x%p\n", handle));
45 err = !FreeLibrary(handle);
46 GetErrorStr(error, err);
48 return err;
51 void * __aros Host_HostLib_GetPointer(void *handle, const char *symbol, char **error)
53 void *ptr;
55 D(printf("[hostlib] GetPointer: handle=0x%p, symbol=%s\n", handle, symbol));
56 ptr = GetProcAddress(handle, symbol);
57 GetErrorStr(error, !ptr);
58 return ptr;