]> sigrok.org Git - libsigrokdecode.git/commitdiff
Don't expose libsigrokdecode's interal GSList.
authorUwe Hermann <redacted>
Sat, 15 Jan 2011 01:37:51 +0000 (02:37 +0100)
committerUwe Hermann <redacted>
Sat, 15 Jan 2011 01:53:29 +0000 (02:53 +0100)
Instead, add a libsigrokdecode_list_decoders() API call which gives you
the list of known protocol decoders.

decode.c
sigrokdecode.h

index 536be2c347315c4ac941d0490d5c307b17ab8733..7125d32f44f9b63c6709d4ebe0fd5508814f14ce 100644 (file)
--- a/decode.c
+++ b/decode.c
@@ -31,7 +31,7 @@
 #endif
 
 /* The list of protocol decoders. */
 #endif
 
 /* The list of protocol decoders. */
-GSList *list_pds;
+GSList *list_pds = NULL;
 
 /**
  * Initialize libsigrokdecode.
 
 /**
  * Initialize libsigrokdecode.
@@ -70,6 +70,18 @@ int sigrokdecode_init(void)
        return SIGROKDECODE_OK;
 }
 
        return SIGROKDECODE_OK;
 }
 
+/**
+ * Returns the list of supported/loaded protocol decoders.
+ *
+ * This is a GSList containing the names of the decoders as strings.
+ *
+ * @return List of decoders, NULL if none are supported or loaded.
+ */
+GSList *sigrokdecode_list_decoders(void)
+{
+       return list_pds;
+}
+
 /**
  * Helper function to handle Python strings.
  *
 /**
  * Helper function to handle Python strings.
  *
index ecd141ae15a8f7a001406b664cf38330acee45d9..88776112d4cf5306f6fa59fd49f0cfa8b96778c2 100644 (file)
@@ -49,9 +49,6 @@
 #define SIGROKDECODE_ERR_PYTHON                -4 /* Python C API error */
 #define SIGROKDECODE_ERR_DECODERS_DIR  -5 /* Protocol decoder path invalid */
 
 #define SIGROKDECODE_ERR_PYTHON                -4 /* Python C API error */
 #define SIGROKDECODE_ERR_DECODERS_DIR  -5 /* Protocol decoder path invalid */
 
-/* The list of loaded protocol decoders. */
-GSList *list_pds;
-
 /* TODO: Documentation. */
 struct sigrokdecode_decoder {
        char *id;
 /* TODO: Documentation. */
 struct sigrokdecode_decoder {
        char *id;
@@ -66,6 +63,7 @@ struct sigrokdecode_decoder {
 };
 
 int sigrokdecode_init(void);
 };
 
 int sigrokdecode_init(void);
+GSList *sigrokdecode_list_decoders(void);
 int sigrokdecode_load_decoder(const char *name, struct sigrokdecode_decoder **dec);
 int sigrokdecode_run_decoder(struct sigrokdecode_decoder *dec,
                             uint8_t *inbuf, uint64_t inbuflen,
 int sigrokdecode_load_decoder(const char *name, struct sigrokdecode_decoder **dec);
 int sigrokdecode_run_decoder(struct sigrokdecode_decoder *dec,
                             uint8_t *inbuf, uint64_t inbuflen,