2 * This file is part of the libsigrokdecode project.
4 * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
5 * Copyright (C) 2012 Bert Vermeulen <bert@biot.com>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "libsigrokdecode-internal.h" /* First, so we avoid a _POSIX_C_SOURCE warning. */
23 #include "libsigrokdecode.h"
29 * Listing, loading, unloading, and handling protocol decoders.
33 * @defgroup grp_decoder Protocol decoders
35 * Handling protocol decoders.
42 /* The list of loaded protocol decoders. */
43 static GSList *pd_list = NULL;
46 extern SRD_PRIV GSList *searchpaths;
49 extern SRD_PRIV GSList *sessions;
50 extern SRD_PRIV int max_session_id;
52 /* module_sigrokdecode.c */
53 extern SRD_PRIV PyObject *mod_sigrokdecode;
57 static gboolean srd_check_init(void)
59 if (max_session_id < 0) {
60 srd_err("Library is not initialized.");
67 * Returns the list of loaded protocol decoders.
69 * This is a GSList of pointers to struct srd_decoder items.
71 * @return List of decoders, NULL if none are supported or loaded.
75 SRD_API const GSList *srd_decoder_list(void)
81 * Get the decoder with the specified ID.
83 * @param id The ID string of the decoder to return.
85 * @return The decoder with the specified ID, or NULL if not found.
89 SRD_API struct srd_decoder *srd_decoder_get_by_id(const char *id)
92 struct srd_decoder *dec;
94 for (l = pd_list; l; l = l->next) {
96 if (!strcmp(dec->id, id))
103 static void channel_free(void *data)
105 struct srd_channel *ch = data;
116 static void variant_free(void *data)
118 GVariant *var = data;
123 g_variant_unref(var);
126 static void annotation_row_free(void *data)
128 struct srd_decoder_annotation_row *row = data;
133 g_slist_free(row->ann_classes);
139 static void decoder_option_free(void *data)
141 struct srd_decoder_option *opt = data;
146 g_slist_free_full(opt->values, &variant_free);
147 variant_free(opt->def);
153 static void decoder_free(struct srd_decoder *dec)
155 PyGILState_STATE gstate;
160 gstate = PyGILState_Ensure();
161 Py_XDECREF(dec->py_dec);
162 Py_XDECREF(dec->py_mod);
163 PyGILState_Release(gstate);
165 g_slist_free_full(dec->options, &decoder_option_free);
166 g_slist_free_full(dec->binary, (GDestroyNotify)&g_strfreev);
167 g_slist_free_full(dec->annotation_rows, &annotation_row_free);
168 g_slist_free_full(dec->annotations, (GDestroyNotify)&g_strfreev);
169 g_slist_free_full(dec->opt_channels, &channel_free);
170 g_slist_free_full(dec->channels, &channel_free);
172 g_slist_free_full(dec->outputs, g_free);
173 g_slist_free_full(dec->inputs, g_free);
174 g_slist_free_full(dec->tags, g_free);
175 g_free(dec->license);
177 g_free(dec->longname);
184 static int get_channels(const struct srd_decoder *d, const char *attr,
185 GSList **out_pdchl, int offset)
187 PyObject *py_channellist, *py_entry;
188 struct srd_channel *pdch;
191 PyGILState_STATE gstate;
193 gstate = PyGILState_Ensure();
195 if (!PyObject_HasAttrString(d->py_dec, attr)) {
196 /* No channels of this type specified. */
197 PyGILState_Release(gstate);
203 py_channellist = PyObject_GetAttrString(d->py_dec, attr);
207 if (!PyTuple_Check(py_channellist)) {
208 srd_err("Protocol decoder %s %s attribute is not a tuple.",
213 for (i = PyTuple_Size(py_channellist) - 1; i >= 0; i--) {
214 py_entry = PyTuple_GetItem(py_channellist, i);
218 if (!PyDict_Check(py_entry)) {
219 srd_err("Protocol decoder %s %s attribute is not "
220 "a list of dict elements.", d->name, attr);
223 pdch = g_malloc(sizeof(struct srd_channel));
224 /* Add to list right away so it doesn't get lost. */
225 pdchl = g_slist_prepend(pdchl, pdch);
227 if (py_dictitem_as_str(py_entry, "id", &pdch->id) != SRD_OK)
229 if (py_dictitem_as_str(py_entry, "name", &pdch->name) != SRD_OK)
231 if (py_dictitem_as_str(py_entry, "desc", &pdch->desc) != SRD_OK)
234 pdch->order = offset + i;
237 Py_DECREF(py_channellist);
240 PyGILState_Release(gstate);
245 srd_exception_catch("Failed to get %s list of %s decoder",
249 g_slist_free_full(pdchl, &channel_free);
250 Py_XDECREF(py_channellist);
251 PyGILState_Release(gstate);
253 return SRD_ERR_PYTHON;
256 static int get_options(struct srd_decoder *d)
258 PyObject *py_opts, *py_opt, *py_str, *py_values, *py_default, *py_item;
260 struct srd_decoder_option *o;
263 PyGILState_STATE gstate;
265 gstate = PyGILState_Ensure();
267 if (!PyObject_HasAttrString(d->py_dec, "options")) {
268 /* No options, that's fine. */
269 PyGILState_Release(gstate);
275 /* If present, options must be a tuple. */
276 py_opts = PyObject_GetAttrString(d->py_dec, "options");
280 if (!PyTuple_Check(py_opts)) {
281 srd_err("Protocol decoder %s: options attribute is not "
286 for (opt = PyTuple_Size(py_opts) - 1; opt >= 0; opt--) {
287 py_opt = PyTuple_GetItem(py_opts, opt);
291 if (!PyDict_Check(py_opt)) {
292 srd_err("Protocol decoder %s options: each option "
293 "must consist of a dictionary.", d->name);
297 o = g_malloc0(sizeof(struct srd_decoder_option));
298 /* Add to list right away so it doesn't get lost. */
299 options = g_slist_prepend(options, o);
301 py_str = PyDict_GetItemString(py_opt, "id");
303 srd_err("Protocol decoder %s option %zd has no ID.",
307 if (py_str_as_str(py_str, &o->id) != SRD_OK)
310 py_str = PyDict_GetItemString(py_opt, "desc");
312 if (py_str_as_str(py_str, &o->desc) != SRD_OK)
316 py_default = PyDict_GetItemString(py_opt, "default");
318 gvar = py_obj_to_variant(py_default);
320 srd_err("Protocol decoder %s option 'default' has "
321 "invalid default value.", d->name);
324 o->def = g_variant_ref_sink(gvar);
327 py_values = PyDict_GetItemString(py_opt, "values");
330 * A default is required if a list of values is
331 * given, since it's used to verify their type.
334 srd_err("No default for option '%s'.", o->id);
337 if (!PyTuple_Check(py_values)) {
338 srd_err("Option '%s' values should be a tuple.", o->id);
342 for (i = PyTuple_Size(py_values) - 1; i >= 0; i--) {
343 py_item = PyTuple_GetItem(py_values, i);
347 if (py_default && (Py_TYPE(py_default) != Py_TYPE(py_item))) {
348 srd_err("All values for option '%s' must be "
349 "of the same type as the default.",
353 gvar = py_obj_to_variant(py_item);
355 srd_err("Protocol decoder %s option 'values' "
356 "contains invalid value.", d->name);
359 o->values = g_slist_prepend(o->values,
360 g_variant_ref_sink(gvar));
364 d->options = options;
366 PyGILState_Release(gstate);
371 srd_exception_catch("Failed to get %s decoder options", d->name);
374 g_slist_free_full(options, &decoder_option_free);
376 PyGILState_Release(gstate);
378 return SRD_ERR_PYTHON;
381 /* Convert annotation class attribute to GSList of char **. */
382 static int get_annotations(struct srd_decoder *dec)
384 PyObject *py_annlist, *py_ann;
388 PyGILState_STATE gstate;
390 gstate = PyGILState_Ensure();
392 if (!PyObject_HasAttrString(dec->py_dec, "annotations")) {
393 PyGILState_Release(gstate);
399 py_annlist = PyObject_GetAttrString(dec->py_dec, "annotations");
403 if (!PyTuple_Check(py_annlist)) {
404 srd_err("Protocol decoder %s annotations should "
405 "be a tuple.", dec->name);
409 for (i = PyTuple_Size(py_annlist) - 1; i >= 0; i--) {
410 py_ann = PyTuple_GetItem(py_annlist, i);
414 if (!PyTuple_Check(py_ann) || PyTuple_Size(py_ann) != 2) {
415 srd_err("Protocol decoder %s annotation %zd should "
416 "be a tuple with two elements.",
420 if (py_strseq_to_char(py_ann, &annpair) != SRD_OK)
423 annotations = g_slist_prepend(annotations, annpair);
425 dec->annotations = annotations;
426 Py_DECREF(py_annlist);
427 PyGILState_Release(gstate);
432 srd_exception_catch("Failed to get %s decoder annotations", dec->name);
435 g_slist_free_full(annotations, (GDestroyNotify)&g_strfreev);
436 Py_XDECREF(py_annlist);
437 PyGILState_Release(gstate);
439 return SRD_ERR_PYTHON;
442 /* Convert annotation_rows to GSList of 'struct srd_decoder_annotation_row'. */
443 static int get_annotation_rows(struct srd_decoder *dec)
445 PyObject *py_ann_rows, *py_ann_row, *py_ann_classes, *py_item;
446 GSList *annotation_rows;
447 struct srd_decoder_annotation_row *ann_row;
450 PyGILState_STATE gstate;
452 gstate = PyGILState_Ensure();
454 if (!PyObject_HasAttrString(dec->py_dec, "annotation_rows")) {
455 PyGILState_Release(gstate);
459 annotation_rows = NULL;
461 py_ann_rows = PyObject_GetAttrString(dec->py_dec, "annotation_rows");
465 if (!PyTuple_Check(py_ann_rows)) {
466 srd_err("Protocol decoder %s annotation_rows "
467 "must be a tuple.", dec->name);
471 for (i = PyTuple_Size(py_ann_rows) - 1; i >= 0; i--) {
472 py_ann_row = PyTuple_GetItem(py_ann_rows, i);
476 if (!PyTuple_Check(py_ann_row) || PyTuple_Size(py_ann_row) != 3) {
477 srd_err("Protocol decoder %s annotation_rows "
478 "must contain only tuples of 3 elements.",
482 ann_row = g_malloc0(sizeof(struct srd_decoder_annotation_row));
483 /* Add to list right away so it doesn't get lost. */
484 annotation_rows = g_slist_prepend(annotation_rows, ann_row);
486 py_item = PyTuple_GetItem(py_ann_row, 0);
489 if (py_str_as_str(py_item, &ann_row->id) != SRD_OK)
492 py_item = PyTuple_GetItem(py_ann_row, 1);
495 if (py_str_as_str(py_item, &ann_row->desc) != SRD_OK)
498 py_ann_classes = PyTuple_GetItem(py_ann_row, 2);
502 if (!PyTuple_Check(py_ann_classes)) {
503 srd_err("Protocol decoder %s annotation_rows tuples "
504 "must have a tuple of numbers as 3rd element.",
509 for (k = PyTuple_Size(py_ann_classes) - 1; k >= 0; k--) {
510 py_item = PyTuple_GetItem(py_ann_classes, k);
514 if (!PyLong_Check(py_item)) {
515 srd_err("Protocol decoder %s annotation row "
516 "class tuple must only contain numbers.",
520 class_idx = PyLong_AsSize_t(py_item);
521 if (PyErr_Occurred())
524 ann_row->ann_classes = g_slist_prepend(ann_row->ann_classes,
525 GSIZE_TO_POINTER(class_idx));
528 dec->annotation_rows = annotation_rows;
529 Py_DECREF(py_ann_rows);
530 PyGILState_Release(gstate);
535 srd_exception_catch("Failed to get %s decoder annotation rows",
539 g_slist_free_full(annotation_rows, &annotation_row_free);
540 Py_XDECREF(py_ann_rows);
541 PyGILState_Release(gstate);
543 return SRD_ERR_PYTHON;
546 /* Convert binary classes to GSList of char **. */
547 static int get_binary_classes(struct srd_decoder *dec)
549 PyObject *py_bin_classes, *py_bin_class;
553 PyGILState_STATE gstate;
555 gstate = PyGILState_Ensure();
557 if (!PyObject_HasAttrString(dec->py_dec, "binary")) {
558 PyGILState_Release(gstate);
564 py_bin_classes = PyObject_GetAttrString(dec->py_dec, "binary");
568 if (!PyTuple_Check(py_bin_classes)) {
569 srd_err("Protocol decoder %s binary classes should "
570 "be a tuple.", dec->name);
574 for (i = PyTuple_Size(py_bin_classes) - 1; i >= 0; i--) {
575 py_bin_class = PyTuple_GetItem(py_bin_classes, i);
579 if (!PyTuple_Check(py_bin_class)
580 || PyTuple_Size(py_bin_class) != 2) {
581 srd_err("Protocol decoder %s binary classes should "
582 "consist only of tuples of 2 elements.",
586 if (py_strseq_to_char(py_bin_class, &bin) != SRD_OK)
589 bin_classes = g_slist_prepend(bin_classes, bin);
591 dec->binary = bin_classes;
592 Py_DECREF(py_bin_classes);
593 PyGILState_Release(gstate);
598 srd_exception_catch("Failed to get %s decoder binary classes",
602 g_slist_free_full(bin_classes, (GDestroyNotify)&g_strfreev);
603 Py_XDECREF(py_bin_classes);
604 PyGILState_Release(gstate);
606 return SRD_ERR_PYTHON;
609 /* Check whether the Decoder class defines the named method. */
610 static int check_method(PyObject *py_dec, const char *mod_name,
611 const char *method_name)
615 PyGILState_STATE gstate;
617 gstate = PyGILState_Ensure();
619 py_method = PyObject_GetAttrString(py_dec, method_name);
621 srd_exception_catch("Protocol decoder %s Decoder class "
622 "has no %s() method", mod_name, method_name);
623 PyGILState_Release(gstate);
624 return SRD_ERR_PYTHON;
627 is_callable = PyCallable_Check(py_method);
628 Py_DECREF(py_method);
630 PyGILState_Release(gstate);
633 srd_err("Protocol decoder %s Decoder class attribute '%s' "
634 "is not a method.", mod_name, method_name);
635 return SRD_ERR_PYTHON;
642 * Get the API version of the specified decoder.
644 * @param d The decoder to use. Must not be NULL.
646 * @return The API version of the decoder, or 0 upon errors.
650 SRD_PRIV long srd_decoder_apiver(const struct srd_decoder *d)
654 PyGILState_STATE gstate;
659 gstate = PyGILState_Ensure();
661 py_apiver = PyObject_GetAttrString(d->py_dec, "api_version");
662 apiver = (py_apiver && PyLong_Check(py_apiver))
663 ? PyLong_AsLong(py_apiver) : 0;
664 Py_XDECREF(py_apiver);
666 PyGILState_Release(gstate);
672 * Load a protocol decoder module into the embedded Python interpreter.
674 * @param module_name The module name to be loaded.
676 * @return SRD_OK upon success, a (negative) error code otherwise.
680 SRD_API int srd_decoder_load(const char *module_name)
682 PyObject *py_basedec;
683 struct srd_decoder *d;
686 const char *fail_txt;
687 PyGILState_STATE gstate;
689 if (!srd_check_init())
695 gstate = PyGILState_Ensure();
697 if (PyDict_GetItemString(PyImport_GetModuleDict(), module_name)) {
698 /* Module was already imported. */
699 PyGILState_Release(gstate);
703 d = g_malloc0(sizeof(struct srd_decoder));
706 d->py_mod = py_import_by_name(module_name);
708 fail_txt = "import by name failed";
712 if (!mod_sigrokdecode) {
713 srd_err("sigrokdecode module not loaded.");
714 fail_txt = "sigrokdecode(3) not loaded";
718 /* Get the 'Decoder' class as Python object. */
719 d->py_dec = PyObject_GetAttrString(d->py_mod, "Decoder");
721 fail_txt = "no 'Decoder' attribute in imported module";
725 py_basedec = PyObject_GetAttrString(mod_sigrokdecode, "Decoder");
727 fail_txt = "no 'Decoder' attribute in sigrokdecode(3)";
731 is_subclass = PyObject_IsSubclass(d->py_dec, py_basedec);
732 Py_DECREF(py_basedec);
735 srd_err("Decoder class in protocol decoder module %s is not "
736 "a subclass of sigrokdecode.Decoder.", module_name);
737 fail_txt = "not a subclass of sigrokdecode.Decoder";
742 * Check that this decoder has the correct PD API version.
743 * PDs of different API versions are incompatible and cannot work.
745 apiver = srd_decoder_apiver(d);
747 srd_exception_catch("Only PD API version 3 is supported, "
748 "decoder %s has version %ld", module_name, apiver);
749 fail_txt = "API version mismatch";
753 /* Check Decoder class for required methods. */
755 if (check_method(d->py_dec, module_name, "reset") != SRD_OK) {
756 fail_txt = "no 'reset()' method";
760 if (check_method(d->py_dec, module_name, "start") != SRD_OK) {
761 fail_txt = "no 'start()' method";
765 if (check_method(d->py_dec, module_name, "decode") != SRD_OK) {
766 fail_txt = "no 'decode()' method";
770 /* Store required fields in newly allocated strings. */
771 if (py_attr_as_str(d->py_dec, "id", &(d->id)) != SRD_OK) {
772 fail_txt = "no 'id' attribute";
776 if (py_attr_as_str(d->py_dec, "name", &(d->name)) != SRD_OK) {
777 fail_txt = "no 'name' attribute";
781 if (py_attr_as_str(d->py_dec, "longname", &(d->longname)) != SRD_OK) {
782 fail_txt = "no 'longname' attribute";
786 if (py_attr_as_str(d->py_dec, "desc", &(d->desc)) != SRD_OK) {
787 fail_txt = "no 'desc' attribute";
791 if (py_attr_as_str(d->py_dec, "license", &(d->license)) != SRD_OK) {
792 fail_txt = "no 'license' attribute";
796 if (py_attr_as_strlist(d->py_dec, "inputs", &(d->inputs)) != SRD_OK) {
797 fail_txt = "missing or malformed 'inputs' attribute";
801 if (py_attr_as_strlist(d->py_dec, "outputs", &(d->outputs)) != SRD_OK) {
802 fail_txt = "missing or malformed 'outputs' attribute";
806 if (py_attr_as_strlist(d->py_dec, "tags", &(d->tags)) != SRD_OK) {
807 fail_txt = "missing or malformed 'tags' attribute";
811 /* All options and their default values. */
812 if (get_options(d) != SRD_OK) {
813 fail_txt = "cannot get options";
817 /* Check and import required channels. */
818 if (get_channels(d, "channels", &d->channels, 0) != SRD_OK) {
819 fail_txt = "cannot get channels";
823 /* Check and import optional channels. */
824 if (get_channels(d, "optional_channels", &d->opt_channels,
825 g_slist_length(d->channels)) != SRD_OK) {
826 fail_txt = "cannot get optional channels";
830 if (get_annotations(d) != SRD_OK) {
831 fail_txt = "cannot get annotations";
835 if (get_annotation_rows(d) != SRD_OK) {
836 fail_txt = "cannot get annotation rows";
840 if (get_binary_classes(d) != SRD_OK) {
841 fail_txt = "cannot get binary classes";
845 PyGILState_Release(gstate);
847 /* Append it to the list of loaded decoders. */
848 pd_list = g_slist_append(pd_list, d);
853 /* Don't show a message for the "common" directory, it's not a PD. */
854 if (strcmp(module_name, "common")) {
855 srd_exception_catch("Failed to load decoder %s: %s",
856 module_name, fail_txt);
862 srd_err("Failed to load decoder %s: %s", module_name, fail_txt);
864 PyGILState_Release(gstate);
866 return SRD_ERR_PYTHON;
870 * Return a protocol decoder's docstring.
872 * @param dec The loaded protocol decoder. Must not be NULL.
874 * @return A newly allocated buffer containing the protocol decoder's
875 * documentation. The caller is responsible for free'ing the buffer.
879 SRD_API char *srd_decoder_doc_get(const struct srd_decoder *dec)
883 PyGILState_STATE gstate;
885 if (!srd_check_init())
888 if (!dec || !dec->py_mod)
891 gstate = PyGILState_Ensure();
893 if (!PyObject_HasAttrString(dec->py_mod, "__doc__"))
896 if (!(py_str = PyObject_GetAttrString(dec->py_mod, "__doc__"))) {
897 srd_exception_catch("Failed to get docstring");
902 if (py_str != Py_None)
903 py_str_as_str(py_str, &doc);
906 PyGILState_Release(gstate);
911 PyGILState_Release(gstate);
917 * Unload the specified protocol decoder.
919 * @param dec The struct srd_decoder to be unloaded.
921 * @return SRD_OK upon success, a (negative) error code otherwise.
925 SRD_API int srd_decoder_unload(struct srd_decoder *dec)
927 struct srd_session *sess;
930 if (!srd_check_init())
937 * Since any instances of this decoder need to be released as well,
938 * but they could be anywhere in the stack, just free the entire
939 * stack. A frontend reloading a decoder thus has to restart all
940 * instances, and rebuild the stack.
942 for (l = sessions; l; l = l->next) {
944 srd_inst_free_all(sess);
947 /* Remove the PD from the list of loaded decoders. */
948 pd_list = g_slist_remove(pd_list, dec);
955 static void srd_decoder_load_all_zip_path(char *zip_path)
957 PyObject *zipimport_mod, *zipimporter_class, *zipimporter;
958 PyObject *prefix_obj, *files, *key, *value, *set, *modname;
962 PyGILState_STATE gstate;
964 set = files = prefix_obj = zipimporter = zipimporter_class = NULL;
966 gstate = PyGILState_Ensure();
968 zipimport_mod = py_import_by_name("zipimport");
969 if (zipimport_mod == NULL)
972 zipimporter_class = PyObject_GetAttrString(zipimport_mod, "zipimporter");
973 if (zipimporter_class == NULL)
976 zipimporter = PyObject_CallFunction(zipimporter_class, "s", zip_path);
977 if (zipimporter == NULL)
980 prefix_obj = PyObject_GetAttrString(zipimporter, "prefix");
981 if (prefix_obj == NULL)
984 files = PyObject_GetAttrString(zipimporter, "_files");
985 if (files == NULL || !PyDict_Check(files))
988 set = PySet_New(NULL);
992 if (py_str_as_str(prefix_obj, &prefix) != SRD_OK)
995 prefix_len = strlen(prefix);
997 while (PyDict_Next(files, &pos, &key, &value)) {
999 if (py_str_as_str(key, &path) == SRD_OK) {
1000 if (strlen(path) > prefix_len
1001 && memcmp(path, prefix, prefix_len) == 0
1002 && (slash = strchr(path + prefix_len, '/'))) {
1004 modname = PyUnicode_FromStringAndSize(path + prefix_len,
1005 slash - (path + prefix_len));
1006 if (modname == NULL) {
1009 PySet_Add(set, modname);
1018 while ((modname = PySet_Pop(set))) {
1020 if (py_str_as_str(modname, &modname_str) == SRD_OK) {
1021 /* The directory name is the module name (e.g. "i2c"). */
1022 srd_decoder_load(modname_str);
1023 g_free(modname_str);
1031 Py_XDECREF(prefix_obj);
1032 Py_XDECREF(zipimporter);
1033 Py_XDECREF(zipimporter_class);
1034 Py_XDECREF(zipimport_mod);
1036 PyGILState_Release(gstate);
1039 static void srd_decoder_load_all_path(char *path)
1042 const gchar *direntry;
1044 if (!(dir = g_dir_open(path, 0, NULL))) {
1045 /* Not really fatal. Try zipimport method too. */
1046 srd_decoder_load_all_zip_path(path);
1051 * This ignores errors returned by srd_decoder_load(). That
1052 * function will have logged the cause, but in any case we
1053 * want to continue anyway.
1055 while ((direntry = g_dir_read_name(dir)) != NULL) {
1056 /* The directory name is the module name (e.g. "i2c"). */
1057 srd_decoder_load(direntry);
1063 * Load all installed protocol decoders.
1065 * @return SRD_OK upon success, a (negative) error code otherwise.
1069 SRD_API int srd_decoder_load_all(void)
1073 if (!srd_check_init())
1076 for (l = searchpaths; l; l = l->next)
1077 srd_decoder_load_all_path(l->data);
1082 static void srd_decoder_unload_cb(void *arg, void *ignored)
1086 srd_decoder_unload((struct srd_decoder *)arg);
1090 * Unload all loaded protocol decoders.
1092 * @return SRD_OK upon success, a (negative) error code otherwise.
1096 SRD_API int srd_decoder_unload_all(void)
1098 g_slist_foreach(pd_list, srd_decoder_unload_cb, NULL);
1099 g_slist_free(pd_list);