From 871d21e2555c345350ec951f1639b4a75dbd4fea Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Sat, 15 Jan 2011 02:37:51 +0100 Subject: [PATCH] Don't expose libsigrokdecode's interal GSList. Instead, add a libsigrokdecode_list_decoders() API call which gives you the list of known protocol decoders. --- decode.c | 14 +++++++++++++- sigrokdecode.h | 4 +--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/decode.c b/decode.c index 536be2c..7125d32 100644 --- a/decode.c +++ b/decode.c @@ -31,7 +31,7 @@ #endif /* The list of protocol decoders. */ -GSList *list_pds; +GSList *list_pds = NULL; /** * Initialize libsigrokdecode. @@ -70,6 +70,18 @@ int sigrokdecode_init(void) 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. * diff --git a/sigrokdecode.h b/sigrokdecode.h index ecd141a..8877611 100644 --- a/sigrokdecode.h +++ b/sigrokdecode.h @@ -49,9 +49,6 @@ #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; @@ -66,6 +63,7 @@ struct sigrokdecode_decoder { }; 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, -- 2.30.2