]> sigrok.org Git - libsigrok.git/commitdiff
resource: add support for SIGROK_FIRMWARE_PATH env variable
authorGerhard Sittig <redacted>
Sun, 21 Aug 2022 11:36:29 +0000 (13:36 +0200)
committerGerhard Sittig <redacted>
Sun, 21 Aug 2022 15:45:11 +0000 (17:45 +0200)
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.

src/resource.c

index a30b4b3f744ee0d154926038e6dfce67dcb029ba..3164b94313f5cf82b31ec023a15c6283252c3e89 100644 (file)
@@ -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));