/*
 * Some "cool" distro defines PATH_MAX as 4095 not as ussaly 4096
 * Becouse many members offset of libusb structures depends on 
 * PATH_MAX value. This makes not portable binary code which
 * uses libusb structures.
 *
 * So this code does it.
 *
 */
 
/* $Id: linux.c 8415 2006-08-21 11:27:31Z mindaugas $ */

#include <stdio.h>

#include <usb.h>

#include "libusbw.h"

struct usb_dev_handle {
	int fd;
	void *bus;
	void *device;

	/*
	 *   Here (actually in memory) goes libusb-specific data,
	 *   I don't need to access the items... Shimizu device
	 *   transmits image through isochronous pipe, but this
	 *   kind of transfer is not implemented in libusb yet. I
	 *   need to access libusb internal data, i.e. open device
	 *   file descriptor to make my own syscall for ISO xfer.
	 */
};

int 
get_fd(struct usb_dev_handle *dev)
{
	if (dev == NULL)
	{
		return -1;
	}

	return dev->fd;
}

struct usb_device *
get_usb_device(struct usb_dev_handle *dev)
{
	if (dev == NULL)
	{
		return NULL;
	}
	
	return usb_device(dev);
}

void *
get_device_descriptor(struct usb_dev_handle *dev)
{
	struct usb_device *usbd;

	usbd = get_usb_device(dev);
	if (usbd == NULL)
	{
		return NULL;
	}

	return &usbd->descriptor;
}

void *
get_config_descriptor(struct usb_dev_handle *dev)
{
	struct usb_device *usbd;

	usbd = get_usb_device(dev);
	if (usbd == NULL)
	{
		return NULL;
	}

	return usbd->config;
}
