Commit ff3908b9bed7f7c5641f98f05929dc3b178617bf
1 parent
d60dc771
Exists in
master
and in
5 other branches
Implementando extensão python.
Showing
4 changed files
with
58 additions
and
0 deletions
Show diff stats
src/python/get.cc
... | ... | @@ -61,3 +61,50 @@ PyObject * terminal_is_ready(PyObject *self, PyObject *args) { |
61 | 61 | |
62 | 62 | } |
63 | 63 | |
64 | +PyObject * terminal_cmp_string_at(PyObject *self, PyObject *args) { | |
65 | + | |
66 | + int row, col, rc; | |
67 | + const char *text; | |
68 | + | |
69 | + if (!PyArg_ParseTuple(args, "iis", &row, &col, &text)) { | |
70 | + PyErr_SetString(terminalError, strerror(EINVAL)); | |
71 | + return NULL; | |
72 | + } | |
73 | + | |
74 | + try { | |
75 | + | |
76 | + rc = ((pw3270_TerminalObject *) self)->session->cmp_string_at(row,col,text); | |
77 | + | |
78 | + } catch(std::exception &e) { | |
79 | + | |
80 | + PyErr_SetString(terminalError, e.what()); | |
81 | + return NULL; | |
82 | + } | |
83 | + | |
84 | + return PyLong_FromLong(rc); | |
85 | + | |
86 | +} | |
87 | + | |
88 | +PyObject * terminal_get_string_at(PyObject *self, PyObject *args) { | |
89 | + | |
90 | + int row, col, sz; | |
91 | + string rc; | |
92 | + | |
93 | + if (!PyArg_ParseTuple(args, "iii", &row, &col, &sz)) { | |
94 | + PyErr_SetString(terminalError, strerror(EINVAL)); | |
95 | + return NULL; | |
96 | + } | |
97 | + | |
98 | + try { | |
99 | + | |
100 | + rc = ((pw3270_TerminalObject *) self)->session->get_string_at(row,col,sz); | |
101 | + | |
102 | + } catch(std::exception &e) { | |
103 | + | |
104 | + PyErr_SetString(terminalError, e.what()); | |
105 | + return NULL; | |
106 | + } | |
107 | + | |
108 | + return PyString_FromString(rc.c_str()); | |
109 | + | |
110 | +} | ... | ... |
src/python/private.h
... | ... | @@ -36,6 +36,8 @@ |
36 | 36 | #include <lib3270/config.h> |
37 | 37 | #include <pw3270/class.h> |
38 | 38 | |
39 | + using namespace std; | |
40 | + | |
39 | 41 | typedef struct { |
40 | 42 | |
41 | 43 | PyObject_HEAD |
... | ... | @@ -61,6 +63,9 @@ |
61 | 63 | PyObject * terminal_connect(PyObject *self, PyObject *args); |
62 | 64 | PyObject * terminal_disconnect(PyObject *self, PyObject *args); |
63 | 65 | |
66 | + PyObject * terminal_get_string_at(PyObject *self, PyObject *args); | |
67 | + PyObject * terminal_cmp_string_at(PyObject *self, PyObject *args); | |
68 | + | |
64 | 69 | } |
65 | 70 | |
66 | 71 | #endif // PRIVATE_H_INCLUDED | ... | ... |
src/python/py3270.cc
... | ... | @@ -59,6 +59,9 @@ static PyMethodDef terminal_methods[] = { |
59 | 59 | { "Connect", terminal_connect, METH_VARARGS, "Connect to the host." }, |
60 | 60 | { "Disconnect", terminal_disconnect, METH_NOARGS, "Disconnect from host." }, |
61 | 61 | |
62 | + { "CmpStringAt", terminal_cmp_string_at, METH_VARARGS, "Compare string with terminal buffer at the position." }, | |
63 | + { "GetStringAt", terminal_get_string_at, METH_VARARGS, "Get string from terminal buffer." }, | |
64 | + | |
62 | 65 | {NULL} // Sentinel |
63 | 66 | |
64 | 67 | }; | ... | ... |