diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2017-10-26 16:45:12 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2017-10-26 16:45:12 (GMT) |
commit | 6054f36bb658916bd231b9002efb94444e2871c8 (patch) | |
tree | a815500ec9bf0e100f4075a825213605c382def0 /python/PythonXPA/client/XPAClient.py | |
download | blt-6054f36bb658916bd231b9002efb94444e2871c8.zip blt-6054f36bb658916bd231b9002efb94444e2871c8.tar.gz blt-6054f36bb658916bd231b9002efb94444e2871c8.tar.bz2 |
Squashed 'xpa/' content from commit d6a54301
git-subtree-dir: xpa
git-subtree-split: d6a543018b46c5a6c47b5ff91e0e131549595ca6
Diffstat (limited to 'python/PythonXPA/client/XPAClient.py')
-rw-r--r-- | python/PythonXPA/client/XPAClient.py | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/python/PythonXPA/client/XPAClient.py b/python/PythonXPA/client/XPAClient.py new file mode 100644 index 0000000..29e39eb --- /dev/null +++ b/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 + + + + |