X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoder.c;h=71e9122181324fad0325314ddbf78eb75f2fc1a6;hp=79ba8ef9db65344118b94a98b5b56299acfbd251;hb=95e2b2f92b144e1b0edf29819a8585dbbc00f169;hpb=f6527cc4f7625eb5283eee5392312ad5df70e0f3 diff --git a/decoder.c b/decoder.c index 79ba8ef..71e9122 100644 --- a/decoder.c +++ b/decoder.c @@ -43,11 +43,11 @@ static GSList *pd_list = NULL; /* srd.c */ -extern GSList *searchpaths; +extern SRD_PRIV GSList *searchpaths; /* session.c */ -extern GSList *sessions; -extern int max_session_id; +extern SRD_PRIV GSList *sessions; +extern SRD_PRIV int max_session_id; /* module_sigrokdecode.c */ extern SRD_PRIV PyObject *mod_sigrokdecode; @@ -70,7 +70,7 @@ static gboolean srd_check_init(void) * * @return List of decoders, NULL if none are supported or loaded. * - * @since 0.1.0 (but the API changed in 0.2.0) + * @since 0.2.0 */ SRD_API const GSList *srd_decoder_list(void) { @@ -366,6 +366,17 @@ SRD_API int srd_decoder_load(const char *module_name) } Py_CLEAR(py_basedec); + /* + * Check that thіs decoder has the correct PD API version. + * PDs of different API versions are incompatible and cannot work. + */ + py_long = PyObject_GetAttrString(d->py_dec, "api_version"); + if (PyLong_AsLong(py_long) != 2) { + srd_err("Only PDs of API version 2 are supported."); + goto err_out; + } + Py_CLEAR(py_long); + /* Check for a proper start() method. */ if (!PyObject_HasAttrString(d->py_dec, "start")) { srd_err("Protocol decoder %s has no start() method Decoder "