summaryrefslogtreecommitdiffstats
path: root/xpa/python/PythonXPA/client/XPAClient.py
blob: 29e39eb012c910a53ae32b72b264e40aa2690ecb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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