summaryrefslogtreecommitdiffstats
path: root/xpa/python/PythonXPA/client/XPAClient.py
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2017-10-26 16:45:12 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2017-10-26 16:45:12 (GMT)
commitdd1df8d8538f275b17e0d9d50dca19f4d44595fd (patch)
tree624bc07023b33668147eaa9097279c6fc92b4e48 /xpa/python/PythonXPA/client/XPAClient.py
parent79d64f400391ce81b4eda73977cb40099256b348 (diff)
parent6054f36bb658916bd231b9002efb94444e2871c8 (diff)
downloadblt-dd1df8d8538f275b17e0d9d50dca19f4d44595fd.zip
blt-dd1df8d8538f275b17e0d9d50dca19f4d44595fd.tar.gz
blt-dd1df8d8538f275b17e0d9d50dca19f4d44595fd.tar.bz2
Merge commit '6054f36bb658916bd231b9002efb94444e2871c8' as 'xpa'
Diffstat (limited to 'xpa/python/PythonXPA/client/XPAClient.py')
-rw-r--r--xpa/python/PythonXPA/client/XPAClient.py98
1 files changed, 98 insertions, 0 deletions
diff --git a/xpa/python/PythonXPA/client/XPAClient.py b/xpa/python/PythonXPA/client/XPAClient.py
new file mode 100644
index 0000000..29e39eb
--- /dev/null
+++ b/xpa/python/PythonXPA/client/XPAClient.py
@@ -0,0 +1,98 @@
+
+import sys
+from ctypes import *
+
+libxpa=cdll.LoadLibrary("../../libxpa.so.1.0")
+libc=cdll.LoadLibrary(None);
+
+
+#xpa_t = c_void_p
+#xpa = xpa_t(None)
+
+c_byte_p = POINTER(c_byte)
+
+
+
+##############
+
+NXPA = 10
+
+##############
+
+
+def free_bufs(p_arr, len):
+ for i in range(len):
+ if p_arr[i]:
+ print "freeing [", i, "] ", p_arr[i][0], p_arr[i][1]
+ libc.free(p_arr[i])
+
+
+
+
+
+## XPA XPAOpen(char *mode);
+
+XPAOpen = libxpa.XPAOpen
+libxpa.XPAOpen.restype = c_void_p
+libxpa.XPAOpen.argtypes = [c_char_p]
+
+## void XPAClose(XPA xpa);
+XPAClose = libxpa.XPAClose
+libxpa.XPAClose.argtypes = [c_void_p]
+
+
+## int XPAGet(XPA xpa, char *template, char *paramlist, char *mode,
+## char **bufs, int *lens, char **names, char **messages, int n);
+
+XPAGet = libxpa.XPAGet
+libxpa.XPAGet.restype = c_int
+libxpa.XPAGet.argtypes = [c_void_p, c_char_p, c_char_p, c_char_p, \
+ c_byte_p*NXPA, c_int*NXPA, c_byte_p*NXPA, c_byte_p*NXPA, \
+ c_int]
+
+
+## when you want to send something like "hello\0x00 you" use this
+
+## int XPASet(XPA xpa,
+## char *template, char *paramlist, char *mode,
+## char *buf, int len, char **names, char **messages,
+## int n);
+
+#libxpa.XPASet.restype = c_int
+#libxpa.XPASet.argtypes = [c_void_p, c_char_p, c_char_p, c_char_p, \
+# c_byte_p, c_int, c_char_p*NXPA, c_char_p*NXPA, \
+# c_int]
+
+## when you know, you will send strings only, use this one to avoid conversions
+
+XPASet = libxpa.XPASet
+libxpa.XPASet.restype = c_int
+libxpa.XPASet.argtypes = [c_void_p, c_char_p, c_char_p, c_char_p, \
+ c_char_p, c_int, c_byte_p*NXPA, c_byte_p*NXPA, \
+ c_int]
+
+## int XPAInfo(XPA xpa,
+## char *template, char *paramlist, char *mode,
+## char **names, char **messages, int n);
+
+XPAInfo = libxpa.XPAInfo
+libxpa.XPAInfo.restype = c_int
+libxpa.XPAInfo.argtypes = [c_void_p, c_char_p, c_char_p, c_char_p, \
+ c_byte_p*NXPA, c_byte_p*NXPA, \
+ c_int]
+
+## int XPAAccess(XPA xpa,
+## char *template, char *paramlist, char *mode,
+## char **names, char **messages, int n);
+
+XPAAccess = libxpa.XPAAccess
+libxpa.XPAAccess.restype = c_int
+libxpa.XPAAccess.argtypes = [c_void_p, c_char_p, c_char_p, c_char_p, \
+ c_byte_p*NXPA, c_byte_p*NXPA, \
+ c_int]
+
+#del libxpa
+
+
+
+