/* The list of protocol decoders. */
SRD_PRIV GSList *pd_list = NULL;
+/* srd.c */
+extern GSList *searchpaths;
+
+/* session.c */
extern GSList *sessions;
/* module_sigrokdecode.c */
return SRD_OK;
}
+static void srd_decoder_load_all_path(char *path)
+{
+ GDir *dir;
+ const gchar *direntry;
+
+ if (!(dir = g_dir_open(path, 0, NULL)))
+ /* Not really fatal */
+ return;
+
+ /* This ignores errors returned by srd_decoder_load(). That
+ * function will have logged the cause, but in any case we
+ * want to continue anyway. */
+ while ((direntry = g_dir_read_name(dir)) != NULL) {
+ /* The directory name is the module name (e.g. "i2c"). */
+ srd_decoder_load(direntry);
+ }
+ g_dir_close(dir);
+
+}
+
/**
* Load all installed protocol decoders.
*
*/
SRD_API int srd_decoder_load_all(void)
{
- GDir *dir;
- const gchar *direntry;
+ GSList *l;
if (!srd_check_init())
return SRD_ERR;
- if (!(dir = g_dir_open(DECODERS_DIR, 0, NULL))) {
- srd_err("Unable to open %s for reading.", DECODERS_DIR);
- return SRD_ERR_DECODERS_DIR;
- }
-
- while ((direntry = g_dir_read_name(dir)) != NULL) {
- /* The directory name is the module name (e.g. "i2c"). */
- srd_decoder_load(direntry);
- }
- g_dir_close(dir);
+ for (l = searchpaths; l; l = l->next)
+ srd_decoder_load_all_path(l->data);
return SRD_OK;
}
/** @cond PRIVATE */
+/* Python module search paths */
+SRD_PRIV GSList *searchpaths = NULL;
+
/* session.c */
extern GSList *sessions;
extern int max_session_id;
srd_session_destroy((struct srd_session *)l->data);
srd_decoder_unload_all();
+ g_slist_free_full(searchpaths, g_free);
+ searchpaths = NULL;
/* Py_Finalize() returns void, any finalization errors are ignored. */
Py_Finalize();
PySys_SetPath(wc_new_path);
g_string_free(new_path, TRUE);
g_free(wc_new_path);
+ searchpaths = g_slist_append(searchpaths, g_strdup(path));
return SRD_OK;
}