diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..5af5f169d93f062fd3c9ba6defa1cd7593cec620 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,19 @@ +project(TPO C) +cmake_minimum_required(VERSION 2.8) + +set(CMAKE_VERBOSE_MAKEFILE ON) +set(CMAKE_COLOR_MAKEFILE ON) +set(CMAKE_C_STANDARD 11) + +set(Python_ADDITIONAL_VERSIONS 3.7) +find_package (PythonLibs REQUIRED) +include_directories(${PYTHON_INCLUDE_DIR} include/) + +file(GLOB TPO_INCLUDES include/*.h) +file(GLOB TPO_SRCS src/*.c) + +add_library(${PROJECT_NAME} SHARED ${TPO_INCLUDES} ${TPO_SRCS} ) + +target_link_libraries(${PROJECT_NAME} ${PYTHON_LIBRARIES}) + +target_link_libraries(${PROJECT_NAME} dap_crypto_python_module) diff --git a/test/include/tpo.h b/test/include/tpo.h new file mode 100644 index 0000000000000000000000000000000000000000..610a133560775742ec7f2f2fca205450183c08b2 --- /dev/null +++ b/test/include/tpo.h @@ -0,0 +1,51 @@ +#define PY_SSIZE_T_CLEAN +#include "Python.h" +#include "libdap-crypto-python.h" +#include "libdap_crypto_data_type.h" +#include "libdap_crypto_key_type_python.h" + +#ifdef __cplusplus +extern "C" { +#endif + +PyObject *TPO_init(PyObject *self, PyObject *args); +PyObject *TPO_deinit(PyObject *self, PyObject *args); + +static PyMethodDef TPOPythonMethods[] = { + {"init", TPO_init, METH_VARARGS, "Initialization of the python-cellframe interface DAP (Deus Applicaions Prototypes)"}, + {"deinit", TPO_deinit, METH_VARARGS, "Deinitialization of the python-cellframe interface DAP (Deus Applicaions Prototypes)"}, +// {"setLogLevel", (PyCFunction)dap_set_log_level, METH_VARARGS, "Setting the logging level"}, +// {"logIt", (PyCFunction)dap_log_it, METH_VARARGS, "The wrapper of the log_it function for the libdap library"}, +// {"logItDebug", (PyCFunction)dap_log_it_debug, METH_VARARGS, "The log_it wrapper for the libdap library displays information with the logging level DEBUG"}, +// {"logItInfo", (PyCFunction)dap_log_it_info, METH_VARARGS, "The log_it wrapper for the libdap library displays information with the logging level INFO"}, +// {"logItNotice", (PyCFunction)dap_log_it_notice, METH_VARARGS, "The log_it wrapper for the libdap library displays information with the logging level NOTICE"}, +// {"logItMessage", (PyCFunction)dap_log_it_message, METH_VARARGS, "The log_it wrapper for the libdap library displays information with the logging level MESSAGE"}, +// {"logItDap", (PyCFunction)dap_log_it_dap, METH_VARARGS, "The log_it wrapper for the libdap library displays information with the logging level DAP"}, +// {"logItWarning", (PyCFunction)dap_log_it_warning, METH_VARARGS, "The log_it wrapper for the libdap library displays information with the logging level WARNING"}, +// {"logItAtt", (PyCFunction)dap_log_it_att, METH_VARARGS, "The log_it wrapper for the libdap library displays information with the logging level ATT"}, +// {"logItError", (PyCFunction)dap_log_it_error, METH_VARARGS, "The log_it wrapper for the libdap library displays information with the logging level ERROR"}, +// {"logItCritical", (PyCFunction)dap_log_it_critical, METH_VARARGS, "The log_it wrapper for the libdap library displays information with the logging level CRITICAL"}, +// {"configGetItem", (PyCFunction)py_m_dap_config_get_item, METH_VARARGS, ""}, +// {"configGetItemDefault", (PyCFunction)py_m_dap_config_get_item_default, METH_VARARGS, ""}, + //{"deinit", dap_server_core_deinit, METH_NOARGS, "Deinitialization of the DAP (Deus Applicaions Prototypes) server core library"}, + //{"loop", dap_server_core_loop, METH_VARARGS, ""}, + //{"listen", dap_server_core_listen, METH_VARARGS, ""}, + {NULL, NULL, 0, NULL} +}; + +static struct PyModuleDef TPOModule = { + PyModuleDef_HEAD_INIT, + "libTPO", /* name of module */ + NULL, /* module documentation, may be NULL */ + -1, /* size of per-interpreter state of the module, + or -1 if the module keeps state in global variables. */ + TPOPythonMethods +}; + +PyMODINIT_FUNC PyInit_libTPO(void); + + +#ifdef __cplusplus +} +#endif + diff --git a/test/src/tpo.c b/test/src/tpo.c new file mode 100644 index 0000000000000000000000000000000000000000..0721d93cd5da13fce2f77e6f6f0a2ee9eeec4121 --- /dev/null +++ b/test/src/tpo.c @@ -0,0 +1,26 @@ +#include "tpo.h" + +PyObject *TPO_init(PyObject *self, PyObject *args){ + if (dap_crypto_init() != 0) + return NULL; + return PyLong_FromLong(0); +} +PyObject *TPO_deinit(PyObject *self, PyObject *args){ + dap_common_deinit(); + return PyLong_FromLong(0); +} + +PyMODINIT_FUNC PyInit_libTPO(void){ + + if (PyType_Ready(&dapCrypto_dapCryptoType) < 0 || + PyType_Ready(&CryptoKeyTypeObjecy_CryptoKeyTypeObjecyType) < 0 || + PyType_Ready(&CryptoDataTypeObjecy_CryptoDataTypeObjecyType) < 0) + return NULL; + + PyObject *module = PyModule_Create(&TPOModule); + PyModule_AddObject(module, "Crypto", (PyObject*)&dapCrypto_dapCryptoType); + PyModule_AddObject(module, "CryptoKeyType", (PyObject*)&CryptoKeyTypeObjecy_CryptoKeyTypeObjecyType); + PyModule_AddObject(module, "CryptoDataType", (PyObject*)&CryptoDataTypeObjecy_CryptoDataTypeObjecyType); + return module; +} +