diff options
author | Gerhard Sittig <gerhard.sittig@gmx.net> | 2022-08-21 13:54:58 +0200 |
---|---|---|
committer | Gerhard Sittig <gerhard.sittig@gmx.net> | 2022-08-21 13:54:58 +0200 |
commit | 1105c425345961fa527a7994845bc487b1c7bdf5 (patch) | |
tree | 9b5dea3f685900630a16b45e71bedee352cebfba /srd.c | |
parent | ec5fc441e38e59a57cd508abf420e30fc3c28e0d (diff) | |
download | libsigrokdecode-1105c425345961fa527a7994845bc487b1c7bdf5.tar.gz libsigrokdecode-1105c425345961fa527a7994845bc487b1c7bdf5.zip |
srd: add support for SIGROKDECODE_PATH environment variable
The optional SIGROKDECODE_DIR environment variable accepts a single
directory specification. The SIGROKDECODE_PATH variable accepts a list
of directories to search protocol decoders. The list separator is
platform dependent (colon or semicolon). Empty items are explicitly
ignored. Both variables get evaluated. Behaviour remains backwards
compatible, just gets extended for improved usability.
Diffstat (limited to 'srd.c')
-rw-r--r-- | srd.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -285,6 +285,22 @@ SRD_API int srd_init(const char *path) return ret; } } + env_path = g_getenv("SIGROKDECODE_PATH"); + if (env_path) { + char **dir_list, **dir_iter, *dir_item; + dir_list = g_strsplit(env_path, G_SEARCHPATH_SEPARATOR_S, 0); + for (dir_iter = dir_list; *dir_iter; dir_iter++) { + dir_item = *dir_iter; + if (!dir_item || !*dir_item) + continue; + ret = srd_decoder_searchpath_add(dir_item); + if (ret != SRD_OK) { + Py_Finalize(); + return ret; + } + } + g_strfreev(dir_list); + } /* Initialize the Python GIL (this also happens to acquire it). */ PyEval_InitThreads(); |