diff options
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c new file mode 100644 index 0000000..db632f2 --- /dev/null +++ b/src/config.c @@ -0,0 +1,33 @@ +#include "config.h" +#include "interpreter.h" +#include <Python.h> + +struct Config +{ + PyObject *object; +}; + +PyObject *_object(Config *c) +{ + return c ? c->object : NULL; +} + +Config *createConfig(const char *argv[], int argc) +{ + PyObject *pyargs = PyList_New(argc); + for (int i = 0; i < argc; i++) + { + PyObject *arg = PyBytes_FromString(argv[i]); + PyList_Insert(pyargs, i, arg); + } + + PyObject *obj = executeFunction("layman.config", "Config", "O", pyargs); + Py_DECREF(pyargs); + if (!obj) + return NULL; + + Config *ret = malloc(sizeof(Config)); + ret->object = obj; + + return ret; +} |