forked from analogdevicesinc/libiio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backend.c
71 lines (57 loc) · 1.15 KB
/
backend.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// SPDX-License-Identifier: LGPL-2.1-or-later
/*
* libiio - Library for interfacing industrial I/O (IIO) devices
*
* Copyright (C) 2017 Analog Devices, Inc.
* Author: Paul Cercueil <[email protected]>
*/
#include "iio-config.h"
#include "iio-private.h"
#include <string.h>
unsigned int iio_get_backends_count(void)
{
unsigned int count = 0;
count += WITH_LOCAL_BACKEND;
count += WITH_XML_BACKEND;
count += WITH_NETWORK_BACKEND;
count += WITH_USB_BACKEND;
count += WITH_SERIAL_BACKEND;
return count;
}
const char * iio_get_backend(unsigned int index)
{
if (WITH_LOCAL_BACKEND) {
if (index == 0)
return "local";
index--;
}
if (WITH_XML_BACKEND) {
if (index == 0)
return "xml";
index--;
}
if (WITH_NETWORK_BACKEND) {
if (index == 0)
return "ip";
index--;
}
if (WITH_USB_BACKEND) {
if (index == 0)
return "usb";
index--;
}
if (WITH_SERIAL_BACKEND) {
if (index == 0)
return "serial";
index --;
}
return NULL;
}
bool iio_has_backend(const char *backend)
{
unsigned int i;
for (i = 0; i < iio_get_backends_count(); i++)
if (strcmp(backend, iio_get_backend(i)) == 0)
return true;
return false;
}