X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decode.c;h=d87f5d282f4061dee3bae7a40844c6daea6df7a8;hp=b57dff504c56851a81bf8e7a994ae6d054b6fcd7;hb=23a13b21b38211c73cbe0418a88060f0586cc065;hpb=3a72d2b31f43788996777b11bff672c0c0e76798 diff --git a/decode.c b/decode.c index b57dff5..d87f5d2 100644 --- a/decode.c +++ b/decode.c @@ -31,13 +31,14 @@ int sigrokdecode_init(void) /* Py_Initialize() returns void and usually cannot fail. */ Py_Initialize(); - /* FIXME */ - /* Allows for ./gui/sigrok-gui in the top-level directory. */ - PySys_SetPath("libsigrokdecode/scripts"); - /* Allows for ./sigrok-gui in the gui/ directory. */ - PySys_SetPath("../libsigrokdecode/scripts"); - /* Allows for sigrok-gui from anywhere given sigrok is installed. */ - PySys_SetPath("/usr/local/share/sigrok"); + /* Add some more search directories for convenience. */ + /* FIXME: Check error code. */ + PyRun_SimpleString( + "import sys;" + "sys.path.append('libsigrokdecode/scripts');" + "sys.path.append('../libsigrokdecode/scripts');" + "sys.path.append('/usr/local/share/sigrok');" + ); return 0; } @@ -50,6 +51,9 @@ int sigrokdecode_init(void) */ int sigrokdecode_load_decoder_file(const char *name) { + /* QUICK HACK */ + name = name; + /* TODO */ return 0; } @@ -64,11 +68,10 @@ int sigrokdecode_load_decoder_file(const char *name) * @param outbuflen TODO * @return 0 upon success, non-zero otherwise. */ -int sigrokdecode_run_decoder(const char *decodername, uint8_t *inbuf, - uint64_t inbuflen, uint8_t **outbuf, - uint64_t *outbuflen) +int sigrokdecode_run_decoder(const char *modulename, const char *decodername, + uint8_t *inbuf, uint64_t inbuflen, + uint8_t **outbuf, uint64_t *outbuflen) { - const char *decoder_filename = "transitioncounter"; /* FIXME */ PyObject *py_name, *py_module, *py_func, *py_args; PyObject *py_value, *py_result; int ret; @@ -88,7 +91,7 @@ int sigrokdecode_run_decoder(const char *decodername, uint8_t *inbuf, return -5; /* Get the name of the decoder module/file as Python string. */ - if (!(py_name = PyString_FromString(decoder_filename))) { + if (!(py_name = PyString_FromString(modulename))) { PyErr_Print(); return -6; }