Implement libusb_get_version() and update libusb manual page.

Approved by:	re (glebius)
Requested by:	swills
MFC after:	1 week
This commit is contained in:
Hans Petter Selasky 2016-06-16 07:48:21 +00:00
parent dc87c22a61
commit 14b896ce80
4 changed files with 32 additions and 1 deletions

View File

@ -65,6 +65,7 @@ CFLAGS+= -I ../../sys
.endif
# LibUSB v1.0
MLINKS += libusb.3 libusb_get_version.3
MLINKS += libusb.3 libusb_init.3
MLINKS += libusb.3 libusb_exit.3
MLINKS += libusb.3 libusb_strerror.3

View File

@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd January 5, 2014
.Dd June 16, 2016
.Dt LIBUSB 3
.Os
.Sh NAME
@ -43,6 +43,10 @@ The
library contains interfaces for directly managing a usb device.
The current implementation supports v1.0 of the libusb API.
.Sh LIBRARY INITIALISATION AND DEINITIALISATION
.Ft "const struct libusb_version *"
.Fn libusb_get_version "void"
This function returns version information about LibUSB.
.Pp
.Ft int
.Fn libusb_init "libusb_context **ctx"
This function initialises libusb.

View File

@ -235,6 +235,15 @@ struct libusb_pollfd {
short events;
};
struct libusb_version {
const uint16_t major;
const uint16_t minor;
const uint16_t micro;
const uint16_t nano;
const char *rc;
const char *describe;
};
typedef struct libusb_context libusb_context;
typedef struct libusb_device libusb_device;
typedef struct libusb_device_handle libusb_device_handle;
@ -384,6 +393,7 @@ typedef struct libusb_transfer {
/* Library initialisation */
void libusb_set_debug(libusb_context * ctx, int level);
const struct libusb_version *libusb_get_version(void);
const char *libusb_strerror(int code);
const char *libusb_error_name(int code);
int libusb_init(libusb_context ** context);

View File

@ -69,6 +69,22 @@ static void libusb10_submit_transfer_sub(struct libusb20_device *, uint8_t);
/* Library initialisation / deinitialisation */
static const struct libusb_version libusb_version = {
.major = 1,
.minor = 0,
.micro = 0,
.nano = 2016,
.rc = "",
.describe = "http://www.freebsd.org"
};
const struct libusb_version *
libusb_get_version(void)
{
return (&libusb_version);
}
void
libusb_set_debug(libusb_context *ctx, int level)
{