Add native library name calculation.
[SquirrelJME.git] / nanocoat / include / sjme / dylib.h
blob252672a92931871737e113f8475eaa10a209f645
1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
10 /**
11 * Dynamic Library loading.
13 * @since 2024/03/27
16 #ifndef SQUIRRELJME_DYLIB_H
17 #define SQUIRRELJME_DYLIB_H
19 #include "sjme/nvm.h"
21 /* Anti-C++. */
22 #ifdef __cplusplus
23 #ifndef SJME_CXX_IS_EXTERNED
24 #define SJME_CXX_IS_EXTERNED
25 #define SJME_CXX_SQUIRRELJME_DYLIB_H
26 extern "C" {
27 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
28 #endif /* #ifdef __cplusplus */
30 /*--------------------------------------------------------------------------*/
32 /**
33 * Opaque dynamic library type.
35 * @since 2024/03/27
37 typedef void* sjme_dylib;
39 /**
40 * Closes the given dynamic library.
42 * @param inLib The library to close.
43 * @return Any error if it occurs.
44 * @since 2024/03/27
46 sjme_errorCode sjme_dylib_close(
47 sjme_attrInNotNull sjme_dylib inLib);
49 /**
50 * Looks up the given symbol in the library.
52 * @param inLib The library to look within.
53 * @param inSymbol The symbol to obtain from the library.
54 * @param outPtr The resultant pointer of the symbol.
55 * @return Any error if it occurs.
56 * @since 2024/03/27
58 sjme_errorCode sjme_dylib_lookup(
59 sjme_attrInNotNull sjme_dylib inLib,
60 sjme_attrInNotNull sjme_lpcstr inSymbol,
61 void** outPtr);
63 /**
64 * Calculates the name of the given library for the current system.
66 * @param inLibName The input library name.
67 * @param outName The resultant library name.
68 * @param outLen The length of the output buffer.
69 * @return Any error code as applicable.
70 * @since 2024/04/13
72 sjme_errorCode sjme_dylib_name(
73 sjme_attrInNotNull sjme_lpcstr inLibName,
74 sjme_attrOutNotNullBuf(outLen) sjme_lpstr outName,
75 sjme_attrInPositive sjme_jint outLen);
77 /**
78 * Opens a dynamic library.
80 * @param libPath The path to the library to open.
81 * @param outLib The resultant opened library.
82 * @return Any error if it occurs.
83 * @since 2024/03/27
85 sjme_errorCode sjme_dylib_open(
86 sjme_attrInNotNull sjme_lpcstr libPath,
87 sjme_attrInOutNotNull sjme_dylib* outLib);
89 /*--------------------------------------------------------------------------*/
91 /* Anti-C++. */
92 #ifdef __cplusplus
93 #ifdef SJME_CXX_SQUIRRELJME_DYLIB_H
95 #undef SJME_CXX_SQUIRRELJME_DYLIB_H
96 #undef SJME_CXX_IS_EXTERNED
97 #endif /* #ifdef SJME_CXX_SQUIRRELJME_DYLIB_H */
98 #endif /* #ifdef __cplusplus */
100 #endif /* SQUIRRELJME_DYLIB_H */