From: Gerhard Sittig Date: Sun, 21 Aug 2022 11:36:29 +0000 (+0200) Subject: resource: add support for SIGROK_FIRMWARE_PATH env variable X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=4a57cc3582af744bc919ac4fb8f9f6c17250c16a;p=libsigrok.git resource: add support for SIGROK_FIRMWARE_PATH env variable The optional SIGROK_FIRMWARE_DIR environment variable accepts a single directory specification. The SIGROK_FIRMWARE_PATH variable accepts a list of directories to search firmware images. 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 increased usability. --- diff --git a/src/resource.c b/src/resource.c index a30b4b3f..3164b943 100644 --- a/src/resource.c +++ b/src/resource.c @@ -57,6 +57,19 @@ SR_API GSList *sr_resourcepaths_get(int res_type) env = g_getenv("SIGROK_FIRMWARE_DIR"); if (env) l = g_slist_append(l, g_strdup(env)); + + env = g_getenv("SIGROK_FIRMWARE_PATH"); + if (env) { + char **dir_list, **dir_iter, *dir_item; + dir_list = g_strsplit(env, G_SEARCHPATH_SEPARATOR_S, 0); + for (dir_iter = dir_list; *dir_iter; dir_iter++) { + dir_item = *dir_iter; + if (!dir_item || !*dir_item) + continue; + l = g_slist_append(l, g_strdup(dir_item)); + } + g_strfreev(dir_list); + } } l = g_slist_append(l, g_build_filename(g_get_user_data_dir(), subdir, NULL));