1 /*
2 * Copyright © 2019 Pino Toscano <toscano.pino@tiscali.it>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include "libusbi.h"
20
21 static int
null_get_device_list(struct libusb_context * ctx,struct discovered_devs ** discdevs)22 null_get_device_list(struct libusb_context * ctx,
23 struct discovered_devs **discdevs)
24 {
25 return LIBUSB_SUCCESS;
26 }
27
28 static int
null_open(struct libusb_device_handle * handle)29 null_open(struct libusb_device_handle *handle)
30 {
31 return LIBUSB_ERROR_NOT_SUPPORTED;
32 }
33
34 static void
null_close(struct libusb_device_handle * handle)35 null_close(struct libusb_device_handle *handle)
36 {
37 }
38
39 static int
null_get_active_config_descriptor(struct libusb_device * dev,void * buf,size_t len)40 null_get_active_config_descriptor(struct libusb_device *dev,
41 void *buf, size_t len)
42 {
43 return LIBUSB_ERROR_NOT_SUPPORTED;
44 }
45
46 static int
null_get_config_descriptor(struct libusb_device * dev,uint8_t idx,void * buf,size_t len)47 null_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
48 void *buf, size_t len)
49 {
50 return LIBUSB_ERROR_NOT_SUPPORTED;
51 }
52
53 static int
null_set_configuration(struct libusb_device_handle * handle,int config)54 null_set_configuration(struct libusb_device_handle *handle, int config)
55 {
56 return LIBUSB_ERROR_NOT_SUPPORTED;
57 }
58
59 static int
null_claim_interface(struct libusb_device_handle * handle,uint8_t iface)60 null_claim_interface(struct libusb_device_handle *handle, uint8_t iface)
61 {
62 return LIBUSB_ERROR_NOT_SUPPORTED;
63 }
64
65 static int
null_release_interface(struct libusb_device_handle * handle,uint8_t iface)66 null_release_interface(struct libusb_device_handle *handle, uint8_t iface)
67 {
68 return LIBUSB_ERROR_NOT_SUPPORTED;
69 }
70
71 static int
null_set_interface_altsetting(struct libusb_device_handle * handle,uint8_t iface,uint8_t altsetting)72 null_set_interface_altsetting(struct libusb_device_handle *handle, uint8_t iface,
73 uint8_t altsetting)
74 {
75 return LIBUSB_ERROR_NOT_SUPPORTED;
76 }
77
78 static int
null_clear_halt(struct libusb_device_handle * handle,unsigned char endpoint)79 null_clear_halt(struct libusb_device_handle *handle, unsigned char endpoint)
80 {
81 return LIBUSB_ERROR_NOT_SUPPORTED;
82 }
83
84 static int
null_submit_transfer(struct usbi_transfer * itransfer)85 null_submit_transfer(struct usbi_transfer *itransfer)
86 {
87 return LIBUSB_ERROR_NOT_SUPPORTED;
88 }
89
90 static int
null_cancel_transfer(struct usbi_transfer * itransfer)91 null_cancel_transfer(struct usbi_transfer *itransfer)
92 {
93 return LIBUSB_ERROR_NOT_SUPPORTED;
94 }
95
96 const struct usbi_os_backend usbi_backend = {
97 .name = "Null backend",
98 .caps = 0,
99 .get_device_list = null_get_device_list,
100 .open = null_open,
101 .close = null_close,
102 .get_active_config_descriptor = null_get_active_config_descriptor,
103 .get_config_descriptor = null_get_config_descriptor,
104 .set_configuration = null_set_configuration,
105 .claim_interface = null_claim_interface,
106 .release_interface = null_release_interface,
107 .set_interface_altsetting = null_set_interface_altsetting,
108 .clear_halt = null_clear_halt,
109 .submit_transfer = null_submit_transfer,
110 .cancel_transfer = null_cancel_transfer,
111 };
112