X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoder.c;h=cbca0b840376c60de504dcc1bd91cdd449c6bef4;hp=4cf419791fec21af4bbe6a3d25ddfdf2518d439f;hb=42515b0f25613499167b66c1d8a659526fb46b8d;hpb=29590b14fc508a0b951ea0b87e98f7741808bab0 diff --git a/decoder.c b/decoder.c index 4cf4197..cbca0b8 100644 --- a/decoder.c +++ b/decoder.c @@ -36,7 +36,7 @@ extern SRD_PRIV PyObject *mod_sigrokdecode; * * @return List of decoders, NULL if none are supported or loaded. */ -SRD_API GSList *srd_decoder_list(void) +SRD_API const GSList *srd_decoder_list(void) { return pd_list; } @@ -53,7 +53,7 @@ SRD_API struct srd_decoder *srd_decoder_get_by_id(const char *id) GSList *l; struct srd_decoder *dec; - for (l = srd_decoder_list(); l; l = l->next) { + for (l = pd_list; l; l = l->next) { dec = l->data; if (!strcmp(dec->id, id)) return dec; @@ -134,6 +134,8 @@ SRD_API int srd_decoder_load(const char *module_name) struct srd_decoder *d; int alen, ret, i; char **ann; + struct srd_probe *p; + GSList *l; srd_dbg("Loading protocol decoder '%s'.", module_name); @@ -222,6 +224,19 @@ SRD_API int srd_decoder_load(const char *module_name) if (get_probes(d, "optional_probes", &d->opt_probes) != SRD_OK) goto err_out; + /* + * Fix order numbers for the optional probes. + * + * Example: + * Required probes: r1, r2, r3. Optional: o1, o2, o3, o4. + * 'order' fields in the d->probes list = 0, 1, 2. + * 'order' fields in the d->opt_probes list = 3, 4, 5, 6. + */ + for (l = d->opt_probes; l; l = l->next) { + p = l->data; + p->order += g_slist_length(d->probes); + } + /* Store required fields in newly allocated strings. */ if (py_attr_as_str(d->py_dec, "id", &(d->id)) != SRD_OK) goto err_out; @@ -400,7 +415,7 @@ SRD_API int srd_decoder_unload_all(void) GSList *l; struct srd_decoder *dec; - for (l = srd_decoder_list(); l; l = l->next) { + for (l = pd_list; l; l = l->next) { dec = l->data; srd_decoder_unload(dec); }