diff options
author | Aki <please@ignore.pl> | 2021-10-16 00:59:39 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2021-10-16 00:59:39 +0200 |
commit | 5368f164a1c68c094c6649424f052c5180ce5269 (patch) | |
tree | 62db630fdac27755c1b002d972637a6f86d18366 | |
parent | 71165bdec129a2f52b9fc20e5a18338dfc413f11 (diff) | |
download | hwd-python-5368f164a1c68c094c6649424f052c5180ce5269.zip hwd-python-5368f164a1c68c094c6649424f052c5180ce5269.tar.gz hwd-python-5368f164a1c68c094c6649424f052c5180ce5269.tar.bz2 |
Added methods for value manipulation in daemon
-rw-r--r-- | src/hwdmodule.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/hwdmodule.cpp b/src/hwdmodule.cpp index d0565df..3d21e08 100644 --- a/src/hwdmodule.cpp +++ b/src/hwdmodule.cpp @@ -11,8 +11,27 @@ static PyObject * hwd_stop_server(PyObject * self, PyObject * args) } +static PyObject * hwd_get_value(PyObject * self, PyObject * args) +{ + const int value = hwd::get_value(); + return PyLong_FromLong(value); +} + + +static PyObject * hwd_set_value(PyObject * self, PyObject * args) +{ + int value = 0; + if (!PyArg_ParseTuple(args, "i", &value)) + return NULL; + hwd::set_value(value); + Py_RETURN_NONE; +} + + static PyMethodDef HwdMethods[] = { {"stop_server", hwd_stop_server, METH_VARARGS, "Shutdown daemon instance"}, + {"get_value", hwd_get_value, METH_VARARGS, "Gets value from the daemon instance"}, + {"set_value", hwd_set_value, METH_VARARGS, "Sets integer value in the daemon instance"}, {NULL, NULL, 0, NULL} }; |