]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoder.c
srd: extra module path can now optionally be passed to srd_init()
[libsigrokdecode.git] / decoder.c
index e039e377655382b2d9fdb0b9fcbf3fc028be0b03..841e4321180a45ff3d79b6c512bdc54eb81e8e3b 100644 (file)
--- a/decoder.c
+++ b/decoder.c
 #include <glib.h>
 
 /* The list of protocol decoders. */
-GSList *pd_list = NULL;
+SRD_PRIV GSList *pd_list = NULL;
 
 /* module_sigrokdecode.c */
-extern PyObject *mod_sigrokdecode;
+extern SRD_PRIV PyObject *mod_sigrokdecode;
 
 /**
  * Returns the list of supported/loaded protocol decoders.
@@ -36,7 +36,7 @@ extern PyObject *mod_sigrokdecode;
  *
  * @return List of decoders, NULL if none are supported or loaded.
  */
-GSList *srd_list_decoders(void)
+SRD_API GSList *srd_list_decoders(void)
 {
        return pd_list;
 }
@@ -47,7 +47,7 @@ GSList *srd_list_decoders(void)
  * @param id The ID string of the decoder to return.
  * @return The decoder with the specified ID, or NULL if not found.
  */
-struct srd_decoder *srd_get_decoder_by_id(const char *id)
+SRD_API struct srd_decoder *srd_get_decoder_by_id(const char *id)
 {
        GSList *l;
        struct srd_decoder *dec;
@@ -95,6 +95,7 @@ static int get_probes(struct srd_decoder *d, char *attr, GSList **pl)
                }
 
                if (!(p = g_try_malloc(sizeof(struct srd_probe)))) {
+                       srd_err("Failed to g_malloc() struct srd_probe.");
                        ret = SRD_ERR_MALLOC;
                        goto err_out;
                }
@@ -126,7 +127,7 @@ err_out:
  *
  * @return SRD_OK upon success, a (negative) error code otherwise.
  */
-int srd_load_decoder(const char *name, struct srd_decoder **dec)
+SRD_API int srd_load_decoder(const char *name, struct srd_decoder **dec)
 {
        PyObject *py_basedec, *py_method, *py_attr, *py_annlist, *py_ann;
        struct srd_decoder *d;
@@ -138,7 +139,7 @@ int srd_load_decoder(const char *name, struct srd_decoder **dec)
        py_basedec = py_method = py_attr = NULL;
 
        if (!(d = g_try_malloc0(sizeof(struct srd_decoder)))) {
-               srd_dbg("Failed to malloc struct srd_decoder.");
+               srd_dbg("Failed to g_malloc() struct srd_decoder.");
                ret = SRD_ERR_MALLOC;
                goto err_out;
        }
@@ -280,7 +281,7 @@ err_out:
        return ret;
 }
 
-char *srd_decoder_doc(struct srd_decoder *dec)
+SRD_API char *srd_decoder_doc(struct srd_decoder *dec)
 {
        PyObject *py_str;
        char *doc;
@@ -327,16 +328,15 @@ static void free_probes(GSList *probelist)
  *
  * @return SRD_OK upon success, a (negative) error code otherwise.
  */
-int srd_unload_decoder(struct srd_decoder *dec)
+SRD_API int srd_unload_decoder(struct srd_decoder *dec)
 {
-
        srd_dbg("unloading decoder %s", dec->name);
 
        /* 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. */
-       srd_instance_free_all(NULL);
+       srd_inst_free_all(NULL);
 
        free_probes(dec->probes);
        free_probes(dec->opt_probes);
@@ -362,7 +362,7 @@ int srd_unload_decoder(struct srd_decoder *dec)
        return SRD_OK;
 }
 
-int srd_load_all_decoders(void)
+SRD_API int srd_load_all_decoders(void)
 {
        GDir *dir;
        GError *error;
@@ -392,7 +392,7 @@ int srd_load_all_decoders(void)
 /**
  * TODO
  */
-int srd_unload_all_decoders(void)
+SRD_API int srd_unload_all_decoders(void)
 {
        GSList *l;
        struct srd_decoder *dec;