summaryrefslogtreecommitdiff
path: root/src/bindings/mono/eo_mono/NativeModule_Unix.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bindings/mono/eo_mono/NativeModule_Unix.cs')
-rw-r--r--src/bindings/mono/eo_mono/NativeModule_Unix.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/bindings/mono/eo_mono/NativeModule_Unix.cs b/src/bindings/mono/eo_mono/NativeModule_Unix.cs
new file mode 100644
index 0000000..9aba31b
--- /dev/null
+++ b/src/bindings/mono/eo_mono/NativeModule_Unix.cs
@@ -0,0 +1,43 @@
1using System;
2using System.Runtime.InteropServices;
3
4namespace Efl { namespace Eo {
5
6public partial class NativeModule
7{
8 public const int RTLD_NOW = 0x002;
9
10 [DllImport(efl.Libs.Libdl)]
11 public static extern IntPtr dlopen(string fileName, int flag);
12 [DllImport(efl.Libs.Libdl)]
13 public static extern int dlclose(IntPtr handle);
14
15 public static void UnloadLibrary(IntPtr handle)
16 {
17 dlclose(handle);
18 }
19
20 public static IntPtr LoadLibrary(string filename)
21 {
22 Console.WriteLine("Loading library {0}", filename);
23 var r = dlopen(filename, RTLD_NOW);
24 if (r == IntPtr.Zero)
25 {
26 r = dlopen("lib" + filename, RTLD_NOW);
27 if (r == IntPtr.Zero)
28 {
29 r = dlopen(filename + ".so", RTLD_NOW);
30 if (r == IntPtr.Zero)
31 {
32 r = dlopen("lib" + filename + ".so", RTLD_NOW);
33 }
34 }
35 }
36 return r;
37 }
38}
39
40
41
42
43} }