X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoder.c;h=9c57b1c337652840417de01829fc0c5d75654636;hp=1151f057f2b5c3e2d4fa5f05ed0fda10cb7e7df6;hb=fb83ab342944ce8bddfeb87220f311954be8d0a9;hpb=95e40a0ce2e27ba6ea7c97d9956918336160bf7b diff --git a/decoder.c b/decoder.c index 1151f05..9c57b1c 100644 --- a/decoder.c +++ b/decoder.c @@ -165,6 +165,8 @@ static void decoder_free(struct srd_decoder *dec) g_slist_free_full(dec->opt_channels, &channel_free); g_slist_free_full(dec->channels, &channel_free); + g_slist_free_full(dec->outputs, g_free); + g_slist_free_full(dec->inputs, g_free); g_free(dec->license); g_free(dec->desc); g_free(dec->longname); @@ -682,8 +684,8 @@ SRD_API int srd_decoder_load(const char *module_name) * PDs of different API versions are incompatible and cannot work. */ apiver = srd_decoder_apiver(d); - if (apiver != 2) { - srd_exception_catch("Only PD API version 2 is supported, " + if (apiver != 2 && apiver != 3) { + srd_exception_catch("Only PD API version 2/3 is supported, " "decoder %s has version %ld", module_name, apiver); fail_txt = "API version mismatch"; goto err_out; @@ -727,6 +729,16 @@ SRD_API int srd_decoder_load(const char *module_name) goto err_out; } + if (py_attr_as_strlist(d->py_dec, "inputs", &(d->inputs)) != SRD_OK) { + fail_txt = "missing or malformed 'inputs' attribute"; + goto err_out; + } + + if (py_attr_as_strlist(d->py_dec, "outputs", &(d->outputs)) != SRD_OK) { + fail_txt = "missing or malformed 'outputs' attribute"; + goto err_out; + } + /* All options and their default values. */ if (get_options(d) != SRD_OK) { fail_txt = "cannot get options"; @@ -767,13 +779,12 @@ SRD_API int srd_decoder_load(const char *module_name) return SRD_OK; except_out: - if (fail_txt) { + /* Don't show a message for the "common" directory, it's not a PD. */ + if (strcmp(module_name, "common")) { srd_exception_catch("Failed to load decoder %s: %s", module_name, fail_txt); - fail_txt = NULL; - } else { - srd_exception_catch("Failed to load decoder %s", module_name); } + fail_txt = NULL; err_out: if (fail_txt) srd_err("Failed to load decoder %s: %s", module_name, fail_txt); @@ -849,7 +860,7 @@ SRD_API int srd_decoder_unload(struct srd_decoder *dec) */ for (l = sessions; l; l = l->next) { sess = l->data; - srd_inst_free_all(sess, NULL); + srd_inst_free_all(sess); } /* Remove the PD from the list of loaded decoders. */