X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoder.c;h=d7780d5b8e5d0d6fe086a27ce363c7011e4d1a9e;hp=365e906a5a8d3424d0e711e387b6226d3126d0e2;hb=8ad6e500312084cd4ae43c7bda476cc7370cda20;hpb=9d122fd5d66aa178547ec4222ab5f526f8a14cf7 diff --git a/decoder.c b/decoder.c index 365e906..d7780d5 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_decoders_list(void) +SRD_API 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_decoders_list(); l; l = l->next) { + for (l = srd_decoder_list(); l; l = l->next) { dec = l->data; if (!strcmp(dec->id, id)) return dec; @@ -134,7 +134,7 @@ SRD_API int srd_decoder_load(const char *module_name) int alen, ret, i; char **ann; - srd_dbg("Loading module '%s'.", module_name); + srd_dbg("Loading protocol decoder '%s'.", module_name); py_basedec = py_method = py_attr = NULL; @@ -148,7 +148,7 @@ SRD_API int srd_decoder_load(const char *module_name) /* Import the Python module. */ if (!(d->py_mod = PyImport_ImportModule(module_name))) { - catch_exception("import of '%s' failed.", module_name); + catch_exception("Import of '%s' failed.", module_name); goto err_out; } @@ -156,7 +156,8 @@ SRD_API int srd_decoder_load(const char *module_name) if (!(d->py_dec = PyObject_GetAttrString(d->py_mod, "Decoder"))) { /* This generated an AttributeError exception. */ PyErr_Clear(); - srd_err("Decoder class not found in protocol decoder %s.", module_name); + srd_err("Decoder class not found in protocol decoder %s.", + module_name); goto err_out; } @@ -240,7 +241,7 @@ SRD_API int srd_decoder_load(const char *module_name) d->inputformats = NULL; d->outputformats = NULL; - /* Convert class annotation attribute to GSList of **char */ + /* Convert class annotation attribute to GSList of **char. */ d->annotations = NULL; if (PyObject_HasAttrString(d->py_dec, "annotations")) { py_annlist = PyObject_GetAttrString(d->py_dec, "annotations"); @@ -288,10 +289,10 @@ err_out: * * @param dec The loaded protocol decoder. * - * @return A newly allocated buffer containing the docstring. The caller should - * free this after use. + * @return A newly allocated buffer containing the protocol decoder's + * documentation. The caller is responsible for free'ing the buffer. */ -SRD_API char *srd_decoder_doc(struct srd_decoder *dec) +SRD_API char *srd_decoder_doc(const struct srd_decoder *dec) { PyObject *py_str; char *doc; @@ -328,7 +329,6 @@ static void free_probes(GSList *probelist) g_free(p); } g_slist_free(probelist); - } /** @@ -340,12 +340,14 @@ static void free_probes(GSList *probelist) */ SRD_API int srd_decoder_unload(struct srd_decoder *dec) { - srd_dbg("unloading decoder %s", dec->name); + srd_dbg("Unloading protocol decoder '%s'.", dec->name); - /* Since any instances of this decoder need to be released as well, + /* + * Since any instances of this decoder need to be released as well, * but they could be anywhere in the stack, just free the entire * stack. A frontend reloading a decoder thus has to restart all - * instances, and rebuild the stack. */ + * instances, and rebuild the stack. + */ srd_inst_free_all(NULL); free_probes(dec->probes); @@ -377,7 +379,7 @@ SRD_API int srd_decoder_unload(struct srd_decoder *dec) * * @return SRD_OK upon success, a (negative) error code otherwise. */ -SRD_API int srd_decoders_load_all(void) +SRD_API int srd_decoder_load_all(void) { GDir *dir; GError *error; @@ -402,12 +404,12 @@ SRD_API int srd_decoders_load_all(void) * * @return SRD_OK upon success, a (negative) error code otherwise. */ -SRD_API int srd_decoders_unload_all(void) +SRD_API int srd_decoder_unload_all(void) { GSList *l; struct srd_decoder *dec; - for (l = srd_decoders_list(); l; l = l->next) { + for (l = srd_decoder_list(); l; l = l->next) { dec = l->data; srd_decoder_unload(dec); }