]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoder.c
srd: SPI: Set default PD options.
[libsigrokdecode.git] / decoder.c
index b5909168fec43b15528a1510ecc3d87eb750b9f2..e25e4e01599556e1db3e9b42d64969d47eece5d4 100644 (file)
--- a/decoder.c
+++ b/decoder.c
@@ -25,7 +25,6 @@
 
 /* The list of protocol decoders. */
 GSList *pd_list = NULL;
-GSList *di_list = NULL;
 
 
 /**
@@ -78,8 +77,6 @@ int srd_load_decoder(const char *name, struct srd_decoder **dec)
        int alen, r, i;
        char **ann;
 
-       fprintf(stdout, "%s: %s\n", __func__, name);
-
        /* "Import" the Python module. */
        if (!(py_mod = PyImport_ImportModule(name))) { /* NEWREF */
                PyErr_Print(); /* Returns void. */
@@ -92,7 +89,7 @@ int srd_load_decoder(const char *name, struct srd_decoder **dec)
                if (PyErr_Occurred())
                        PyErr_Print(); /* Returns void. */
                Py_XDECREF(py_mod);
-               fprintf(stderr, "Decoder class not found in PD module %s\n", name);
+               srd_err("Decoder class not found in PD module %s", name);
                return SRD_ERR_PYTHON; /* TODO: More specific error? */
        }
 
@@ -117,9 +114,6 @@ int srd_load_decoder(const char *name, struct srd_decoder **dec)
        if ((r = h_str(py_res, "author", &(d->author))) < 0)
                return r;
 
-       if ((r = h_str(py_res, "email", &(d->email))) < 0)
-               return r;
-
        if ((r = h_str(py_res, "license", &(d->license))) < 0)
                return r;
 
@@ -133,10 +127,11 @@ int srd_load_decoder(const char *name, struct srd_decoder **dec)
        d->outputformats = NULL;
 
        /* Convert class annotation attribute to GSList of **char */
-       d->annotation = NULL;
-       if ((py_annlist = PyObject_GetAttrString(py_res, "annotation"))) {
+       d->annotations = NULL;
+       if (PyObject_HasAttrString(py_res, "annotations")) {
+               py_annlist = PyObject_GetAttrString(py_res, "annotations");
                if (!PyList_Check(py_annlist)) {
-                       srd_err("Protocol decoder module %s annotation should be a list", name);
+                       srd_err("Protocol decoder module %s annotations should be a list", name);
                        return SRD_ERR_PYTHON;
                }
                alen = PyList_Size(py_annlist);
@@ -150,7 +145,7 @@ int srd_load_decoder(const char *name, struct srd_decoder **dec)
 
                        if (py_strlist_to_char(py_ann, &ann) != SRD_OK)
                                return SRD_ERR_PYTHON;
-                       d->annotation = g_slist_append(d->annotation, ann);
+                       d->annotations = g_slist_append(d->annotations, ann);
                }
        }
 
@@ -167,7 +162,11 @@ int srd_unload_decoder(struct srd_decoder *dec)
 {
        g_free(dec->id);
        g_free(dec->name);
+       g_free(dec->longname);
        g_free(dec->desc);
+       g_free(dec->longdesc);
+       g_free(dec->author);
+       g_free(dec->license);
        g_free(dec->func);
 
        /* TODO: Free everything in inputformats and outputformats. */