summaryrefslogtreecommitdiff
path: root/wrappers/python/eduvpncommon/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'wrappers/python/eduvpncommon/__init__.py')
-rw-r--r--wrappers/python/eduvpncommon/__init__.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/wrappers/python/eduvpncommon/__init__.py b/wrappers/python/eduvpncommon/__init__.py
index e69de29..e9d0284 100644
--- a/wrappers/python/eduvpncommon/__init__.py
+++ b/wrappers/python/eduvpncommon/__init__.py
@@ -0,0 +1,30 @@
+from ctypes import *
+from collections import defaultdict
+import pathlib
+import platform
+
+_lib_prefixes = defaultdict(lambda: "lib", {
+ "windows": "",
+})
+
+_lib_suffixes = defaultdict(lambda: ".so", {
+ "windows": ".dll",
+ "darwin": ".dylib",
+})
+
+_os = platform.system().lower()
+
+_libname = "eduvpn_common"
+_libfile = f"{_lib_prefixes[_os]}{_libname}{_lib_suffixes[_os]}"
+# Library should have been copied to the lib/ folder
+lib = cdll.LoadLibrary(str(pathlib.Path(__file__).parent / "lib" / _libfile))
+
+
+class GoSlice(Structure):
+ _fields_ = [("data", POINTER(c_char)), ("len", c_int64), ("cap", c_int64)]
+
+ @staticmethod
+ def make(bs: bytes) -> "GoSlice":
+ return GoSlice((c_char * len(bs))(*bs), len(bs), len(bs))
+
+