]> git.alsa-project.org Git - tinycompress.git/commitdiff
handle TINYCOMPRESS_PLUGIN_DIR environment variable
authorJaroslav Kysela <perex@perex.cz>
Tue, 20 Oct 2020 16:45:11 +0000 (18:45 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 20 Oct 2020 16:48:43 +0000 (18:48 +0200)
The path specified in environment variable TINYCOMPRESS_PLUGIN_DIR
can be used to modify the build-in path at runtime.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/lib/compress.c

index f27374455f19cc1fe370fc0500c1c23c361769a6..68f1b55c710319cc2f08b97a967ac91b3660c9d5 100644 (file)
@@ -117,11 +117,16 @@ static int populate_compress_plugin_ops(struct compress *compress, const char *n
        char lib_name[128];
        void *dl_hdl;
        const char *err = NULL;
+       const char *s;
 
        token = strdup(name);
        compr_name = strtok_r(token, ":", &token_saveptr);
 
-       snprintf(lib_name, sizeof(lib_name), "%slibtinycompress_module_%s.so", TINYCOMPRESS_PLUGIN_DIR, compr_name);
+       s = getenv("TINYCOMPRESS_PLUGIN_DIR");
+       if (s == NULL)
+               s = TINYCOMPRESS_PLUGIN_DIR;
+
+       snprintf(lib_name, sizeof(lib_name), "%slibtinycompress_module_%s.so", s, compr_name);
 
        free(token);
        dl_hdl = dlopen(lib_name, RTLD_NOW);