From: Bert Vermeulen Date: Mon, 2 Sep 2013 12:24:32 +0000 (+0200) Subject: New API function sr_session_dev_list() X-Git-Tag: libsigrok-0.2.2~64 X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=2bb311b482d587a7d20c35bf54f084bc0011d72d New API function sr_session_dev_list() This exposes the list of devices added to the session. In the case of loading a session from file, these struct sr_dev_inst are otherwise not exposed to the frontend. See bug 145. --- diff --git a/session.c b/session.c index 15be92c8..b52c91a3 100644 --- a/session.c +++ b/session.c @@ -179,6 +179,31 @@ SR_API int sr_session_dev_add(const struct sr_dev_inst *sdi) return SR_OK; } +/** + * List all device instances attached to the current session. + * + * @param devlist A pointer where the device instance list will be + * stored on return. If no devices are in the session, + * this will be NULL. Each element in the list points + * to a struct sr_dev_inst *. + * The list must be freed by the caller, but not the + * elements pointed to. + * + * @return SR_OK upon success, SR_ERR upon invalid arguments. + */ +SR_API int sr_session_dev_list(GSList **devlist) +{ + + *devlist = NULL; + + if (!session) + return SR_ERR; + + *devlist = g_slist_copy(session->devs); + + return SR_OK; +} + /** * Remove all datafeed callbacks in the current session. *