forked from analogdevicesinc/libiio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backend.c
84 lines (75 loc) · 1.66 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
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* libiio - Library for interfacing industrial I/O (IIO) devices
*
* Copyright (C) 2017 Analog Devices, Inc.
* Author: Paul Cercueil <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
#include "iio-config.h"
#include "iio-private.h"
#include <string.h>
unsigned int iio_get_backends_count(void)
{
unsigned int count = 0;
#ifdef WITH_LOCAL_BACKEND
count++;
#endif
#ifdef WITH_XML_BACKEND
count++;
#endif
#ifdef WITH_NETWORK_BACKEND
count++;
#endif
#ifdef WITH_USB_BACKEND
count++;
#endif
#ifdef WITH_SERIAL_BACKEND
count++;
#endif
return count;
}
const char * iio_get_backend(unsigned int index)
{
#ifdef WITH_LOCAL_BACKEND
if (index == 0)
return "local";
index--;
#endif
#ifdef WITH_XML_BACKEND
if (index == 0)
return "xml";
index--;
#endif
#ifdef WITH_NETWORK_BACKEND
if (index == 0)
return "ip";
index--;
#endif
#ifdef WITH_USB_BACKEND
if (index == 0)
return "usb";
index--;
#endif
#ifdef WITH_SERIAL_BACKEND
if (index == 0)
return "serial";
#endif
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;
}