Skip to content

Commit

Permalink
scan context: allow mutltiple backends for scanning context
Browse files Browse the repository at this point in the history
In the past iio_create_scan_context() would take a null terminated
string, like "local" or "ip", and would filter only on that backend.

In addition do that, allow multiple, like "local:ip:usb:", or "ip:usb:"

Signed-off-by: Robin Getz <[email protected]>
  • Loading branch information
rgetz committed Jun 1, 2020
1 parent 3df16ee commit d532845
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions iio.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,10 @@ enum iio_modifier {


/** @brief Create a scan context
* @param backend A NULL-terminated string containing the backend to use for
* scanning. If NULL, all the available backends are used.
* @param backend A NULL-terminated string containing the backend(s) to use for
* scanning (example: pre version 0.20 : "local", "ip", or "usb"; post version
* 0.20 can handle multiple, including "local:usb:", "ip:usb:", "local:usb:ip:").
* If NULL, all the available backends are used.
* @param flags Unused for now. Set to 0.
* @return on success, a pointer to a iio_scan_context structure
* @return On failure, NULL is returned and errno is set appropriately */
Expand Down
6 changes: 3 additions & 3 deletions scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,15 @@ struct iio_scan_context * iio_create_scan_context(
return NULL;
}

if (!backend || !strcmp(backend, "local"))
if (!backend || strstr(backend, "local"))
ctx->scan_local = true;

#ifdef WITH_USB_BACKEND
if (!backend || !strcmp(backend, "usb"))
if (!backend || strstr(backend, "usb"))
ctx->usb_ctx = usb_context_scan_init();
#endif
#ifdef HAVE_DNS_SD
if (!backend || !strcmp(backend, "ip"))
if (!backend || strstr(backend, "ip"))
ctx->dnssd_ctx = dnssd_context_scan_init();
#endif

Expand Down

0 comments on commit d532845

Please sign in to comment.