Возможно ли такое?

Вопросы программирования и использования среды Lazarus.

Модератор: Модераторы

Возможно ли такое?

Сообщение gen » 06.11.2009 11:56:30

Есть *.h фаил для фаилов для С++. Ну это модуль для сишника, в нем написаны константы, названия ф-ий, структуры. Можно ли как -то подрубить его в коде lazarusa ?
То есть в с++
#include <stdio.h>
а в lazaruse?
gen
новенький
 
Сообщения: 74
Зарегистрирован: 18.06.2009 21:04:22

Re: Возможно ли такое?

Сообщение NOPIK » 06.11.2009 12:08:45

прогнать через c2pas
NOPIK
незнакомец
 
Сообщения: 3
Зарегистрирован: 24.02.2008 09:29:08

Re: Возможно ли такое?

Сообщение gen » 06.11.2009 12:35:51

NOPIK писал(а):прогнать через c2pas
, это openc2pas? Виндусовская программа?
У вас нет необходимых прав для просмотра вложений в этом сообщении.
gen
новенький
 
Сообщения: 74
Зарегистрирован: 18.06.2009 21:04:22

Re: Возможно ли такое?

Сообщение v-t-l » 06.11.2009 12:45:47

h2pas - из комплекта fpc
v-t-l
энтузиаст
 
Сообщения: 735
Зарегистрирован: 13.05.2007 16:27:22
Откуда: Belarus

Re: Возможно ли такое?

Сообщение gen » 06.11.2009 13:05:30

v-t-l писал(а):h2pas - из комплекта fpc
,
h2pas /usr/include/usb.h
at line 227 error : syntax error
at line 227 error : syntax error
at line 329 error : syntax error
at line 330 error : syntax error


строка 227
Код: Выделить всё
#define USB_LE16_TO_CPU(x) do { x = ((x & 0xff) << 8) | ((x & 0xff00) >> 8); } while(0)


строка 329 и 330
struct usb_device *usb_device(usb_dev_handle *dev);
struct usb_bus *usb_get_busses(void);


Опции
Where [options] is one or more of:
-d Use external;
-D use external libname name 'func_name';
-e change enum type to list of constants
-c Compact outputmode, less spaces and empty lines
-C Use types in ctypes unit
-i create include files (no unit header)
-l libname Specify the library name for external
-o outputfilename Specify the outputfilename
-p Use "P" instead of "^" for pointers
-pr Pack all records (1 byte alignment)
-P use proc. vars for imports
-s strip comments from inputfile
-S strip comments and don't write info to outputfile.
-t Prepend typedef type names with T
-T Prepend typedef type names with T, and remove _
-u unitname Specify the name of the unit.
-v replace pointer parameters by call by
reference parameters
-w special for win32 headers
-x handle SYS_TRAP of PalmOS header files


мэйби с параметрами какими-то писать нужно?

Добавлено спустя 1 час 38 минут 8 секунд:
Исходный фаил такой
Код: Выделить всё
/*
* Prototypes, structure definitions and macros.
*
* Copyright (c) 2000-2003 Johannes Erdfelt <johannes@erdfelt.com>
*
* This library is covered by the LGPL, read LICENSE for details.
*
* This file (and only this file) may alternatively be licensed under the
* BSD license as well, read LICENSE for details.
*/
#ifndef __USB_H__
#define __USB_H__

#include <unistd.h>
#include <stdlib.h>
#include <limits.h>

#include <dirent.h>

/*
* USB spec information
*
* This is all stuff grabbed from various USB specs and is pretty much
* not subject to change
*/

/*
* Device and/or Interface Class codes
*/
#define USB_CLASS_PER_INTERFACE      0   /* for DeviceClass */
#define USB_CLASS_AUDIO         1
#define USB_CLASS_COMM         2
#define USB_CLASS_HID         3
#define USB_CLASS_PRINTER      7
#define USB_CLASS_PTP         6
#define USB_CLASS_MASS_STORAGE      8
#define USB_CLASS_HUB         9
#define USB_CLASS_DATA         10
#define USB_CLASS_VENDOR_SPEC      0xff

/*
* Descriptor types
*/
#define USB_DT_DEVICE         0x01
#define USB_DT_CONFIG         0x02
#define USB_DT_STRING         0x03
#define USB_DT_INTERFACE      0x04
#define USB_DT_ENDPOINT         0x05

#define USB_DT_HID         0x21
#define USB_DT_REPORT         0x22
#define USB_DT_PHYSICAL         0x23
#define USB_DT_HUB         0x29

/*
* Descriptor sizes per descriptor type
*/
#define USB_DT_DEVICE_SIZE      18
#define USB_DT_CONFIG_SIZE      9
#define USB_DT_INTERFACE_SIZE      9
#define USB_DT_ENDPOINT_SIZE      7
#define USB_DT_ENDPOINT_AUDIO_SIZE   9   /* Audio extension */
#define USB_DT_HUB_NONVAR_SIZE      7

/* All standard descriptors have these 2 fields in common */
struct usb_descriptor_header {
   u_int8_t  bLength;
   u_int8_t  bDescriptorType;
};

/* String descriptor */
struct usb_string_descriptor {
   u_int8_t  bLength;
   u_int8_t  bDescriptorType;
   u_int16_t wData[1];
};

/* HID descriptor */
struct usb_hid_descriptor {
   u_int8_t  bLength;
   u_int8_t  bDescriptorType;
   u_int16_t bcdHID;
   u_int8_t  bCountryCode;
   u_int8_t  bNumDescriptors;
   /* u_int8_t  bReportDescriptorType; */
   /* u_int16_t wDescriptorLength; */
   /* ... */
};

/* Endpoint descriptor */
#define USB_MAXENDPOINTS   32
struct usb_endpoint_descriptor {
   u_int8_t  bLength;
   u_int8_t  bDescriptorType;
   u_int8_t  bEndpointAddress;
   u_int8_t  bmAttributes;
   u_int16_t wMaxPacketSize;
   u_int8_t  bInterval;
   u_int8_t  bRefresh;
   u_int8_t  bSynchAddress;

   unsigned char *extra;   /* Extra descriptors */
   int extralen;
};

#define USB_ENDPOINT_ADDRESS_MASK   0x0f    /* in bEndpointAddress */
#define USB_ENDPOINT_DIR_MASK      0x80

#define USB_ENDPOINT_TYPE_MASK      0x03    /* in bmAttributes */
#define USB_ENDPOINT_TYPE_CONTROL   0
#define USB_ENDPOINT_TYPE_ISOCHRONOUS   1
#define USB_ENDPOINT_TYPE_BULK      2
#define USB_ENDPOINT_TYPE_INTERRUPT   3

/* Interface descriptor */
#define USB_MAXINTERFACES   32
struct usb_interface_descriptor {
   u_int8_t  bLength;
   u_int8_t  bDescriptorType;
   u_int8_t  bInterfaceNumber;
   u_int8_t  bAlternateSetting;
   u_int8_t  bNumEndpoints;
   u_int8_t  bInterfaceClass;
   u_int8_t  bInterfaceSubClass;
   u_int8_t  bInterfaceProtocol;
   u_int8_t  iInterface;

   struct usb_endpoint_descriptor *endpoint;

   unsigned char *extra;   /* Extra descriptors */
   int extralen;
};

#define USB_MAXALTSETTING   128   /* Hard limit */
struct usb_interface {
   struct usb_interface_descriptor *altsetting;

   int num_altsetting;
};

/* Configuration descriptor information.. */
#define USB_MAXCONFIG      8
struct usb_config_descriptor {
   u_int8_t  bLength;
   u_int8_t  bDescriptorType;
   u_int16_t wTotalLength;
   u_int8_t  bNumInterfaces;
   u_int8_t  bConfigurationValue;
   u_int8_t  iConfiguration;
   u_int8_t  bmAttributes;
   u_int8_t  MaxPower;

   struct usb_interface *interface;

   unsigned char *extra;   /* Extra descriptors */
   int extralen;
};

/* Device descriptor */
struct usb_device_descriptor {
   u_int8_t  bLength;
   u_int8_t  bDescriptorType;
   u_int16_t bcdUSB;
   u_int8_t  bDeviceClass;
   u_int8_t  bDeviceSubClass;
   u_int8_t  bDeviceProtocol;
   u_int8_t  bMaxPacketSize0;
   u_int16_t idVendor;
   u_int16_t idProduct;
   u_int16_t bcdDevice;
   u_int8_t  iManufacturer;
   u_int8_t  iProduct;
   u_int8_t  iSerialNumber;
   u_int8_t  bNumConfigurations;
};

struct usb_ctrl_setup {
   u_int8_t  bRequestType;
   u_int8_t  bRequest;
   u_int16_t wValue;
   u_int16_t wIndex;
   u_int16_t wLength;
};

/*
* Standard requests
*/
#define USB_REQ_GET_STATUS      0x00
#define USB_REQ_CLEAR_FEATURE      0x01
/* 0x02 is reserved */
#define USB_REQ_SET_FEATURE      0x03
/* 0x04 is reserved */
#define USB_REQ_SET_ADDRESS      0x05
#define USB_REQ_GET_DESCRIPTOR      0x06
#define USB_REQ_SET_DESCRIPTOR      0x07
#define USB_REQ_GET_CONFIGURATION   0x08
#define USB_REQ_SET_CONFIGURATION   0x09
#define USB_REQ_GET_INTERFACE      0x0A
#define USB_REQ_SET_INTERFACE      0x0B
#define USB_REQ_SYNCH_FRAME      0x0C

#define USB_TYPE_STANDARD      (0x00 << 5)
#define USB_TYPE_CLASS         (0x01 << 5)
#define USB_TYPE_VENDOR         (0x02 << 5)
#define USB_TYPE_RESERVED      (0x03 << 5)

#define USB_RECIP_DEVICE      0x00
#define USB_RECIP_INTERFACE      0x01
#define USB_RECIP_ENDPOINT      0x02
#define USB_RECIP_OTHER         0x03

/*
* Various libusb API related stuff
*/

#define USB_ENDPOINT_IN         0x80
#define USB_ENDPOINT_OUT      0x00

/* Error codes */
#define USB_ERROR_BEGIN         500000

/*
* This is supposed to look weird. This file is generated from autoconf
* and I didn't want to make this too complicated.
*/
#if 0
#define USB_LE16_TO_CPU(x) do { x = ((x & 0xff) << 8) | ((x & 0xff00) >> 8); } while(0)
#else
#define USB_LE16_TO_CPU(x)
#endif

/* Data types */
struct usb_device;
struct usb_bus;

/*
* To maintain compatibility with applications already built with libusb,
* we must only add entries to the end of this structure. NEVER delete or
* move members and only change types if you really know what you're doing.
*/
struct usb_device {
  struct usb_device *next, *prev;

  char filename[PATH_MAX + 1];

  struct usb_bus *bus;

  struct usb_device_descriptor descriptor;
  struct usb_config_descriptor *config;

  void *dev;      /* Darwin support */

  u_int8_t devnum;

  unsigned char num_children;
  struct usb_device **children;
};

struct usb_bus {
  struct usb_bus *next, *prev;

  char dirname[PATH_MAX + 1];

  struct usb_device *devices;
  u_int32_t location;

  struct usb_device *root_dev;
};

struct usb_dev_handle;
typedef struct usb_dev_handle usb_dev_handle;

/* Variables */
extern struct usb_bus *usb_busses;

#ifdef __cplusplus
extern "C" {
#endif

/* Function prototypes */

/* usb.c */
usb_dev_handle *usb_open(struct usb_device *dev);
int usb_close(usb_dev_handle *dev);
int usb_get_string(usb_dev_handle *dev, int index, int langid, char *buf,
   size_t buflen);
int usb_get_string_simple(usb_dev_handle *dev, int index, char *buf,
   size_t buflen);

/* descriptors.c */
int usb_get_descriptor_by_endpoint(usb_dev_handle *udev, int ep,
   unsigned char type, unsigned char index, void *buf, int size);
int usb_get_descriptor(usb_dev_handle *udev, unsigned char type,
   unsigned char index, void *buf, int size);

/* <arch>.c */
int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int size,
   int timeout);
int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size,
   int timeout);
int usb_interrupt_write(usb_dev_handle *dev, int ep, char *bytes, int size,
        int timeout);
int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int size,
        int timeout);
int usb_control_msg(usb_dev_handle *dev, int requesttype, int request,
   int value, int index, char *bytes, int size, int timeout);
int usb_set_configuration(usb_dev_handle *dev, int configuration);
int usb_claim_interface(usb_dev_handle *dev, int interface);
int usb_release_interface(usb_dev_handle *dev, int interface);
int usb_set_altinterface(usb_dev_handle *dev, int alternate);
int usb_resetep(usb_dev_handle *dev, unsigned int ep);
int usb_clear_halt(usb_dev_handle *dev, unsigned int ep);
int usb_reset(usb_dev_handle *dev);

#if 1
#define LIBUSB_HAS_GET_DRIVER_NP 1
int usb_get_driver_np(usb_dev_handle *dev, int interface, char *name,
   unsigned int namelen);
#define LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP 1
int usb_detach_kernel_driver_np(usb_dev_handle *dev, int interface);
#endif

char *usb_strerror(void);

void usb_init(void);
void usb_set_debug(int level);
int usb_find_busses(void);
int usb_find_devices(void);
struct usb_device *usb_device(usb_dev_handle *dev);
struct usb_bus *usb_get_busses(void);

#ifdef __cplusplus
}
#endif

#endif /* __USB_H__ */



Если использовать c2pas , то получим

Код: Выделить всё
(*
* Prototypes, structure definitions and macros.
*
* Copyright (c) 2000-2003 Johannes Erdfelt <johannes@erdfelt.com>
*
* This library is covered by the LGPL, read LICENSE for details.
*
* This file (and only this file) may alternatively be licensed under the
* BSD license as well, read LICENSE for details.
*)
#ifndef __USB_H__
#define __USB_H__

#include <unistd.h>
#include <stdlib.h>
#include <limits.h>

#include <dirent.h>

(*
* USB spec information
*
* This is all stuff grabbed from various USB specs and is pretty much
* not subject to change
*)

(*
* Device and/or Interface Class codes
*)
#define USB_CLASS_PER_INTERFACE      0   (* for DeviceClass *)
#define USB_CLASS_AUDIO         1
#define USB_CLASS_COMM         2
#define USB_CLASS_HID         3
#define USB_CLASS_PRINTER      7
#define USB_CLASS_PTP         6
#define USB_CLASS_MASS_STORAGE      8
#define USB_CLASS_HUB         9
#define USB_CLASS_DATA         10
#define USB_CLASS_VENDOR_SPEC      0xff

(*
* Descriptor types
*)
#define USB_DT_DEVICE         0x01
#define USB_DT_CONFIG         0x02
#define USB_DT_STRING         0x03
#define USB_DT_INTERFACE      0x04
#define USB_DT_ENDPOINT         0x05

#define USB_DT_HID         0x21
#define USB_DT_REPORT         0x22
#define USB_DT_PHYSICAL         0x23
#define USB_DT_HUB         0x29

(*
* Descriptor sizes per descriptor type
*)
#define USB_DT_DEVICE_SIZE      18
#define USB_DT_CONFIG_SIZE      9
#define USB_DT_INTERFACE_SIZE      9
#define USB_DT_ENDPOINT_SIZE      7
#define USB_DT_ENDPOINT_AUDIO_SIZE   9   (* Audio extension *)
#define USB_DT_HUB_NONVAR_SIZE      7

(* All standard descriptors have these 2 fields in common *)
struct usb_descriptor_header begin
   u_int8_t  bLength;
   u_int8_t  bDescriptorType;
end; ;

(* String descriptor *)
struct usb_string_descriptor begin
   u_int8_t  bLength;
   u_int8_t  bDescriptorType;
   u_int16_t wData[1];
end; ;

(* HID descriptor *)
struct usb_hid_descriptor begin
   u_int8_t  bLength;
   u_int8_t  bDescriptorType;
   u_int16_t bcdHID;
   u_int8_t  bCountryCode;
   u_int8_t  bNumDescriptors;
   (* u_int8_t  bReportDescriptorType; *)
   (* u_int16_t wDescriptorLength; *)
   (* ... *)
end; ;

(* Endpoint descriptor *)
#define USB_MAXENDPOINTS   32
struct usb_endpoint_descriptor begin
   u_int8_t  bLength;
   u_int8_t  bDescriptorType;
   u_int8_t  bEndpointAddress;
   u_int8_t  bmAttributes;
   u_int16_t wMaxPacketSize;
   u_int8_t  bInterval;
   u_int8_t  bRefresh;
   u_int8_t  bSynchAddress;

   unsigned char *extra;   (* Extra descriptors *)
   Integer extralen;
end; ;

#define USB_ENDPOINT_ADDRESS_MASK   0x0f    (* in bEndpointAddress *)
#define USB_ENDPOINT_DIR_MASK      0x80

#define USB_ENDPOINT_TYPE_MASK      0x03    (* in bmAttributes *)
#define USB_ENDPOINT_TYPE_CONTROL   0
#define USB_ENDPOINT_TYPE_ISOCHRONOUS   1
#define USB_ENDPOINT_TYPE_BULK      2
#define USB_ENDPOINT_TYPE_INTERRUPT   3

(* Interface descriptor *)
#define USB_MAXINTERFACES   32
struct usb_interface_descriptor begin
   u_int8_t  bLength;
   u_int8_t  bDescriptorType;
   u_int8_t  bInterfaceNumber;
   u_int8_t  bAlternateSetting;
   u_int8_t  bNumEndpoints;
   u_int8_t  bInterfaceClass;
   u_int8_t  bInterfaceSubClass;
   u_int8_t  bInterfaceProtocol;
   u_int8_t  iInterface;

   struct usb_endpoint_descriptor *endpoint;

   unsigned char *extra;   (* Extra descriptors *)
   Integer extralen;
end; ;

#define USB_MAXALTSETTING   128   (* Hard limit *)
struct usb_interface begin
   struct usb_interface_descriptor *altsetting;

   Integer num_altsetting;
end; ;

(* Configuration descriptor information.. *)
#define USB_MAXCONFIG      8
struct usb_config_descriptor begin
   u_int8_t  bLength;
   u_int8_t  bDescriptorType;
   u_int16_t wTotalLength;
   u_int8_t  bNumInterfaces;
   u_int8_t  bConfigurationValue;
   u_int8_t  iConfiguration;
   u_int8_t  bmAttributes;
   u_int8_t  MaxPower;

   struct usb_interface *interface;

   unsigned char *extra;   (* Extra descriptors *)
   Integer extralen;
end; ;

(* Device descriptor *)
struct usb_device_descriptor begin
   u_int8_t  bLength;
   u_int8_t  bDescriptorType;
   u_int16_t bcdUSB;
   u_int8_t  bDeviceClass;
   u_int8_t  bDeviceSubClass;
   u_int8_t  bDeviceProtocol;
   u_int8_t  bMaxPacketSize0;
   u_int16_t idVendor;
   u_int16_t idProduct;
   u_int16_t bcdDevice;
   u_int8_t  iManufacturer;
   u_int8_t  iProduct;
   u_int8_t  iSerialNumber;
   u_int8_t  bNumConfigurations;
end; ;

struct usb_ctrl_setup begin
   u_int8_t  bRequestType;
   u_int8_t  bRequest;
   u_int16_t wValue;
   u_int16_t wIndex;
   u_int16_t wLength;
end; ;

(*
* Standard requests
*)
#define USB_REQ_GET_STATUS      0x00
#define USB_REQ_CLEAR_FEATURE      0x01
(* 0x02 is reserved *)
#define USB_REQ_SET_FEATURE      0x03
(* 0x04 is reserved *)
#define USB_REQ_SET_ADDRESS      0x05
#define USB_REQ_GET_DESCRIPTOR      0x06
#define USB_REQ_SET_DESCRIPTOR      0x07
#define USB_REQ_GET_CONFIGURATION   0x08
#define USB_REQ_SET_CONFIGURATION   0x09
#define USB_REQ_GET_INTERFACE      0x0A
#define USB_REQ_SET_INTERFACE      0x0B
#define USB_REQ_SYNCH_FRAME      0x0C

#define USB_TYPE_STANDARD      (0x00 << 5)
#define USB_TYPE_CLASS         (0x01 << 5)
#define USB_TYPE_VENDOR         (0x02 << 5)
#define USB_TYPE_RESERVED      (0x03 << 5)

#define USB_RECIP_DEVICE      0x00
#define USB_RECIP_INTERFACE      0x01
#define USB_RECIP_ENDPOINT      0x02
#define USB_RECIP_OTHER         0x03

(*
* Various libusb API related stuff
*)

#define USB_ENDPOINT_IN         0x80
#define USB_ENDPOINT_OUT      0x00

(* Error codes *)
#define USB_ERROR_BEGIN         500000

(*
* This is supposed to look weird. This file is generated from autoconf
* and I didn't want to make this too complicated.
*)
#if 0
#define USB_LE16_TO_CPU(x) then do begin x := ((x & 0xff) << 8) or ((x & 0xff00) >> 8); end; while(0) do
else
#define USB_LE16_TO_CPU(x)
#endif

(* Data types *)
struct usb_device;
struct usb_bus;

(*
* To maintain compatibility with applications already built with libusb,
* we must only add entries to the end of this structure. NEVER delete or
* move members and only change types if you really know what you're doing.
*)
struct usb_device begin
  struct usb_device *next, *prev;

  char filename[PATH_MAX + 1];

  struct usb_bus *bus;

  struct usb_device_descriptor descriptor;
  struct usb_config_descriptor *config;

  void *dev;      (* Darwin support *)

  u_int8_t devnum;

  unsigned char num_children;
  struct usb_device **children;
end; ;

struct usb_bus begin
  struct usb_bus *next, *prev;

  char dirname[PATH_MAX + 1];

  struct usb_device *devices;
  u_int32_t location;

  struct usb_device *root_dev;
end; ;

struct usb_dev_handle;
typedef struct usb_dev_handle usb_dev_handle;

(* Variables *)
extern struct usb_bus *usb_busses;

#ifdef __cplusplus
extern 'C' begin
#endif

(* Function prototypes *)

(* usb.c *)
usb_dev_handle *usb_open(struct usb_device *dev);
Integer usb_close(usb_dev_handle *dev);
Integer usb_get_string(usb_dev_handle *dev, Integer index, Integer langid, char *buf,
   size_t buflen);
Integer usb_get_string_simple(usb_dev_handle *dev, Integer index, char *buf,
   size_t buflen);

(* descriptors.c *)
Integer usb_get_descriptor_by_endpoint(usb_dev_handle *udev, Integer ep,
   unsigned char type, unsigned char index, void *buf, Integer size);
Integer usb_get_descriptor(usb_dev_handle *udev, unsigned char type,
   unsigned char index, void *buf, Integer size);

(* <arch>.c *)
Integer usb_bulk_write(usb_dev_handle *dev, Integer ep, char *bytes, Integer size,
   Integer timeout);
Integer usb_bulk_read(usb_dev_handle *dev, Integer ep, char *bytes, Integer size,
   Integer timeout);
Integer usb_interrupt_write(usb_dev_handle *dev, Integer ep, char *bytes, Integer size,
        Integer timeout);
Integer usb_interrupt_read(usb_dev_handle *dev, Integer ep, char *bytes, Integer size,
        Integer timeout);
Integer usb_control_msg(usb_dev_handle *dev, Integer requesttype, Integer request,
   Integer value, Integer index, char *bytes, Integer size, Integer timeout);
Integer usb_set_configuration(usb_dev_handle *dev, Integer configuration);
Integer usb_claim_interface(usb_dev_handle *dev, Integer interface);
Integer usb_release_interface(usb_dev_handle *dev, Integer interface);
Integer usb_set_altinterface(usb_dev_handle *dev, Integer alternate);
Integer usb_resetep(usb_dev_handle *dev, unsigned Integer ep);
Integer usb_clear_halt(usb_dev_handle *dev, unsigned Integer ep);
Integer usb_reset(usb_dev_handle *dev);

#if 1
#define LIBUSB_HAS_GET_DRIVER_NP 1
Integer usb_get_driver_np(usb_dev_handle *dev, Integer interface, char *name,
   unsigned Integer namelen) then ;
#define LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP 1
Integer usb_detach_kernel_driver_np(usb_dev_handle *dev, Integer interface);
#endif

char *usb_strerror(void);

void usb_init(void);
void usb_set_debug(Integer level);
Integer usb_find_busses(void);
Integer usb_find_devices(void);
struct usb_device *usb_device(usb_dev_handle *dev);
struct usb_bus *usb_get_busses(void);

#ifdef __cplusplus
end;
#endif

#endif (* __USB_H__ *)



А если h2pas

Код: Выделить всё

unit usb;
interface

{
  Automatically converted by H2Pas 1.0.0 from /usr/include/usb.h
  The following command line parameters were used:
    /usr/include/usb.h
}

    Type
    Pchar  = ^char;
    Pusb_dev_handle  = ^usb_dev_handle;
    Pusb_device  = ^usb_device;
{$IFDEF FPC}
{$PACKRECORDS C}
{$ENDIF}


  {
   * Prototypes, structure definitions and macros.
   *
   * Copyright (c) 2000-2003 Johannes Erdfelt <johannes@erdfelt.com>
   *
   * This library is covered by the LGPL, read LICENSE for details.
   *
   * This file (and only this file) may alternatively be licensed under the
   * BSD license as well, read LICENSE for details.
    }
{$ifndef __USB_H__}
{$define __USB_H__} 
{$include <unistd.h>}
{$include <stdlib.h>}
{$include <limits.h>}
{$include <dirent.h>}
  {
   * USB spec information
   *
   * This is all stuff grabbed from various USB specs and is pretty much
   * not subject to change
    }
  {
   * Device and/or Interface Class codes
    }
  { for DeviceClass  }

  const
     USB_CLASS_PER_INTERFACE = 0;     
     USB_CLASS_AUDIO = 1;     
     USB_CLASS_COMM = 2;     
     USB_CLASS_HID = 3;     
     USB_CLASS_PRINTER = 7;     
     USB_CLASS_PTP = 6;     
     USB_CLASS_MASS_STORAGE = 8;     
     USB_CLASS_HUB = 9;     
     USB_CLASS_DATA = 10;     
     USB_CLASS_VENDOR_SPEC = $ff;     
  {
   * Descriptor types
    }
     USB_DT_DEVICE = $01;     
     USB_DT_CONFIG = $02;     
     USB_DT_STRING = $03;     
     USB_DT_INTERFACE = $04;     
     USB_DT_ENDPOINT = $05;     
     USB_DT_HID = $21;     
     USB_DT_REPORT = $22;     
     USB_DT_PHYSICAL = $23;     
     USB_DT_HUB = $29;     
  {
   * Descriptor sizes per descriptor type
    }
     USB_DT_DEVICE_SIZE = 18;     
     USB_DT_CONFIG_SIZE = 9;     
     USB_DT_INTERFACE_SIZE = 9;     
     USB_DT_ENDPOINT_SIZE = 7;     
  { Audio extension  }
     USB_DT_ENDPOINT_AUDIO_SIZE = 9;     
     USB_DT_HUB_NONVAR_SIZE = 7;     
  { All standard descriptors have these 2 fields in common  }

  type
     usb_descriptor_header = record
          bLength : u_int8_t;
          bDescriptorType : u_int8_t;
       end;

  { String descriptor  }
     usb_string_descriptor = record
          bLength : u_int8_t;
          bDescriptorType : u_int8_t;
          wData : array[0..0] of u_int16_t;
       end;

  { HID descriptor  }
  { u_int8_t  bReportDescriptorType;  }
  { u_int16_t wDescriptorLength;  }
  { ...  }
     usb_hid_descriptor = record
          bLength : u_int8_t;
          bDescriptorType : u_int8_t;
          bcdHID : u_int16_t;
          bCountryCode : u_int8_t;
          bNumDescriptors : u_int8_t;
       end;

  { Endpoint descriptor  }

  const
     USB_MAXENDPOINTS = 32;     
  { Extra descriptors  }

  type
     usb_endpoint_descriptor = record
          bLength : u_int8_t;
          bDescriptorType : u_int8_t;
          bEndpointAddress : u_int8_t;
          bmAttributes : u_int8_t;
          wMaxPacketSize : u_int16_t;
          bInterval : u_int8_t;
          bRefresh : u_int8_t;
          bSynchAddress : u_int8_t;
          extra : ^byte;
          extralen : longint;
       end;

  { in bEndpointAddress  }

  const
     USB_ENDPOINT_ADDRESS_MASK = $0f;     
     USB_ENDPOINT_DIR_MASK = $80;     
  { in bmAttributes  }
     USB_ENDPOINT_TYPE_MASK = $03;     
     USB_ENDPOINT_TYPE_CONTROL = 0;     
     USB_ENDPOINT_TYPE_ISOCHRONOUS = 1;     
     USB_ENDPOINT_TYPE_BULK = 2;     
     USB_ENDPOINT_TYPE_INTERRUPT = 3;     
  { Interface descriptor  }
     USB_MAXINTERFACES = 32;     
  { Extra descriptors  }

  type
     usb_interface_descriptor = record
          bLength : u_int8_t;
          bDescriptorType : u_int8_t;
          bInterfaceNumber : u_int8_t;
          bAlternateSetting : u_int8_t;
          bNumEndpoints : u_int8_t;
          bInterfaceClass : u_int8_t;
          bInterfaceSubClass : u_int8_t;
          bInterfaceProtocol : u_int8_t;
          iInterface : u_int8_t;
          endpoint : ^usb_endpoint_descriptor;
          extra : ^byte;
          extralen : longint;
       end;

  { Hard limit  }

  const
     USB_MAXALTSETTING = 128;     

  type
     usb_interface = record
          altsetting : ^usb_interface_descriptor;
          num_altsetting : longint;
       end;

  { Configuration descriptor information..  }

  const
     USB_MAXCONFIG = 8;     
  { Extra descriptors  }

  type
     usb_config_descriptor = record
          bLength : u_int8_t;
          bDescriptorType : u_int8_t;
          wTotalLength : u_int16_t;
          bNumInterfaces : u_int8_t;
          bConfigurationValue : u_int8_t;
          iConfiguration : u_int8_t;
          bmAttributes : u_int8_t;
          MaxPower : u_int8_t;
          interface : ^usb_interface;
          extra : ^byte;
          extralen : longint;
       end;

  { Device descriptor  }
     usb_device_descriptor = record
          bLength : u_int8_t;
          bDescriptorType : u_int8_t;
          bcdUSB : u_int16_t;
          bDeviceClass : u_int8_t;
          bDeviceSubClass : u_int8_t;
          bDeviceProtocol : u_int8_t;
          bMaxPacketSize0 : u_int8_t;
          idVendor : u_int16_t;
          idProduct : u_int16_t;
          bcdDevice : u_int16_t;
          iManufacturer : u_int8_t;
          iProduct : u_int8_t;
          iSerialNumber : u_int8_t;
          bNumConfigurations : u_int8_t;
       end;

     usb_ctrl_setup = record
          bRequestType : u_int8_t;
          bRequest : u_int8_t;
          wValue : u_int16_t;
          wIndex : u_int16_t;
          wLength : u_int16_t;
       end;

  {
   * Standard requests
    }

  const
     USB_REQ_GET_STATUS = $00;     
     USB_REQ_CLEAR_FEATURE = $01;     
  { 0x02 is reserved  }
     USB_REQ_SET_FEATURE = $03;     
  { 0x04 is reserved  }
     USB_REQ_SET_ADDRESS = $05;     
     USB_REQ_GET_DESCRIPTOR = $06;     
     USB_REQ_SET_DESCRIPTOR = $07;     
     USB_REQ_GET_CONFIGURATION = $08;     
     USB_REQ_SET_CONFIGURATION = $09;     
     USB_REQ_GET_INTERFACE = $0A;     
     USB_REQ_SET_INTERFACE = $0B;     
     USB_REQ_SYNCH_FRAME = $0C;     
     USB_TYPE_STANDARD = $00 shl 5;     
     USB_TYPE_CLASS = $01 shl 5;     
     USB_TYPE_VENDOR = $02 shl 5;     
     USB_TYPE_RESERVED = $03 shl 5;     
     USB_RECIP_DEVICE = $00;     
     USB_RECIP_INTERFACE = $01;     
     USB_RECIP_ENDPOINT = $02;     
     USB_RECIP_OTHER = $03;     
  {
   * Various libusb API related stuff
    }
     USB_ENDPOINT_IN = $80;     
     USB_ENDPOINT_OUT = $00;     
  { Error codes  }
     USB_ERROR_BEGIN = 500000;     
  {
   * This is supposed to look weird. This file is generated from autoconf
   * and I didn't want to make this too complicated.
    }
{$if 0}
(* error
#define USB_LE16_TO_CPU(x) do { x = ((x & 0xff) << 8) | ((x & 0xff00) >> 8); } while(0)
in declaration at line 227 *)
(* error
#define USB_LE16_TO_CPU(x) do { x = ((x & 0xff) << 8) | ((x & 0xff00) >> 8); } while(0)
{$else}
in define line 229 *)
{$endif}
    { Data types  }

    type
       usb_device = record
           {undefined structure}
         end;

       usb_bus = record
           {undefined structure}
         end;

    {
     * To maintain compatibility with applications already built with libusb,
     * we must only add entries to the end of this structure. NEVER delete or
     * move members and only change types if you really know what you're doing.
      }
    { Darwin support  }
       usb_device = record
            next : ^usb_device;
            prev : ^usb_device;
            filename : array[0..(PATH_MAX+1)-1] of char;
            bus : ^usb_bus;
            descriptor : usb_device_descriptor;
            config : ^usb_config_descriptor;
            dev : pointer;
            devnum : u_int8_t;
            num_children : byte;
            children : ^^usb_device;
         end;

       usb_bus = record
            next : ^usb_bus;
            prev : ^usb_bus;
            dirname : array[0..(PATH_MAX+1)-1] of char;
            devices : ^usb_device;
            location : u_int32_t;
            root_dev : ^usb_device;
         end;

       usb_dev_handle = record
           {undefined structure}
         end;

    { Variables  }

      var
         usb_busses : ^usb_bus;cvar;external;
{ C++ extern C conditionnal removed }
    { Function prototypes  }
    { usb.c  }

    function usb_open(dev:pusb_device):^usb_dev_handle;

    function usb_close(dev:pusb_dev_handle):longint;

    function usb_get_string(dev:pusb_dev_handle; index:longint; langid:longint; buf:pchar; buflen:size_t):longint;

    function usb_get_string_simple(dev:pusb_dev_handle; index:longint; buf:pchar; buflen:size_t):longint;

    { descriptors.c  }
    function usb_get_descriptor_by_endpoint(udev:pusb_dev_handle; ep:longint; _type:byte; index:byte; buf:pointer;
               size:longint):longint;

    function usb_get_descriptor(udev:pusb_dev_handle; _type:byte; index:byte; buf:pointer; size:longint):longint;

    { <arch>.c  }
    function usb_bulk_write(dev:pusb_dev_handle; ep:longint; bytes:pchar; size:longint; timeout:longint):longint;

    function usb_bulk_read(dev:pusb_dev_handle; ep:longint; bytes:pchar; size:longint; timeout:longint):longint;

    function usb_interrupt_write(dev:pusb_dev_handle; ep:longint; bytes:pchar; size:longint; timeout:longint):longint;

    function usb_interrupt_read(dev:pusb_dev_handle; ep:longint; bytes:pchar; size:longint; timeout:longint):longint;

    function usb_control_msg(dev:pusb_dev_handle; requesttype:longint; request:longint; value:longint; index:longint;
               bytes:pchar; size:longint; timeout:longint):longint;

    function usb_set_configuration(dev:pusb_dev_handle; configuration:longint):longint;

    function usb_claim_interface(dev:pusb_dev_handle; interface:longint):longint;

    function usb_release_interface(dev:pusb_dev_handle; interface:longint):longint;

    function usb_set_altinterface(dev:pusb_dev_handle; alternate:longint):longint;

    function usb_resetep(dev:pusb_dev_handle; ep:dword):longint;

    function usb_clear_halt(dev:pusb_dev_handle; ep:dword):longint;

    function usb_reset(dev:pusb_dev_handle):longint;

{$if 1}

    const
       LIBUSB_HAS_GET_DRIVER_NP = 1;       

    function usb_get_driver_np(dev:pusb_dev_handle; interface:longint; name:pchar; namelen:dword):longint;


    const
       LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP = 1;       

    function usb_detach_kernel_driver_np(dev:pusb_dev_handle; interface:longint):longint;

{$endif}

    function usb_strerror:^char;

    procedure usb_init;

    procedure usb_set_debug(level:longint);

    function usb_find_busses:longint;

    function usb_find_devices:longint;

(* error
struct usb_device *usb_device(usb_dev_handle *dev);
in declaration at line 329 *)
(* error
struct usb_bus *usb_get_busses(void);
in declaration at line 330 *)
{ C++ end of extern C conditionnal removed }
{$endif}
    { __USB_H__  }

implementation

    function usb_open(dev:pusb_device):^usb_dev_handle;
    begin
      { You must implement this function }
    end;
    function usb_close(dev:pusb_dev_handle):longint;
    begin
      { You must implement this function }
    end;
    function usb_get_string(dev:pusb_dev_handle; index:longint; langid:longint; buf:pchar; buflen:size_t):longint;
    begin
      { You must implement this function }
    end;
    function usb_get_string_simple(dev:pusb_dev_handle; index:longint; buf:pchar; buflen:size_t):longint;
    begin
      { You must implement this function }
    end;
    function usb_get_descriptor_by_endpoint(udev:pusb_dev_handle; ep:longint; _type:byte; index:byte; buf:pointer;
               size:longint):longint;
    begin
      { You must implement this function }
    end;
    function usb_get_descriptor(udev:pusb_dev_handle; _type:byte; index:byte; buf:pointer; size:longint):longint;
    begin
      { You must implement this function }
    end;
    function usb_bulk_write(dev:pusb_dev_handle; ep:longint; bytes:pchar; size:longint; timeout:longint):longint;
    begin
      { You must implement this function }
    end;
    function usb_bulk_read(dev:pusb_dev_handle; ep:longint; bytes:pchar; size:longint; timeout:longint):longint;
    begin
      { You must implement this function }
    end;
    function usb_interrupt_write(dev:pusb_dev_handle; ep:longint; bytes:pchar; size:longint; timeout:longint):longint;
    begin
      { You must implement this function }
    end;
    function usb_interrupt_read(dev:pusb_dev_handle; ep:longint; bytes:pchar; size:longint; timeout:longint):longint;
    begin
      { You must implement this function }
    end;
    function usb_control_msg(dev:pusb_dev_handle; requesttype:longint; request:longint; value:longint; index:longint;
               bytes:pchar; size:longint; timeout:longint):longint;
    begin
      { You must implement this function }
    end;
    function usb_set_configuration(dev:pusb_dev_handle; configuration:longint):longint;
    begin
      { You must implement this function }
    end;
    function usb_claim_interface(dev:pusb_dev_handle; interface:longint):longint;
    begin
      { You must implement this function }
    end;
    function usb_release_interface(dev:pusb_dev_handle; interface:longint):longint;
    begin
      { You must implement this function }
    end;
    function usb_set_altinterface(dev:pusb_dev_handle; alternate:longint):longint;
    begin
      { You must implement this function }
    end;
    function usb_resetep(dev:pusb_dev_handle; ep:dword):longint;
    begin
      { You must implement this function }
    end;
    function usb_clear_halt(dev:pusb_dev_handle; ep:dword):longint;
    begin
      { You must implement this function }
    end;
    function usb_reset(dev:pusb_dev_handle):longint;
    begin
      { You must implement this function }
    end;
    function usb_get_driver_np(dev:pusb_dev_handle; interface:longint; name:pchar; namelen:dword):longint;
    begin
      { You must implement this function }
    end;
    function usb_detach_kernel_driver_np(dev:pusb_dev_handle; interface:longint):longint;
    begin
      { You must implement this function }
    end;
    function usb_strerror:^char;
    begin
      { You must implement this function }
    end;
    procedure usb_init;
    begin
      { You must implement this function }
    end;
    procedure usb_set_debug(level:longint);
    begin
      { You must implement this function }
    end;
    function usb_find_busses:longint;
    begin
      { You must implement this function }
    end;
    function usb_find_devices:longint;
    begin
      { You must implement this function }
    end;

end.



Чувствую ни 1 ни 2 правильно не конвертировал. В 1 много непонятного,такое чувство что кусками перевел только. Во втором смущает implementation. Может ,то что после него удалить? просто все эти ф-ии в SO библиотеке описаны+ не нарушится ли связь с дин библиотекой?
gen
новенький
 
Сообщения: 74
Зарегистрирован: 18.06.2009 21:04:22

Re: Возможно ли такое?

Сообщение v-t-l » 06.11.2009 15:05:57

а если опцию -D задействовать?
v-t-l
энтузиаст
 
Сообщения: 735
Зарегистрирован: 13.05.2007 16:27:22
Откуда: Belarus

Re: Возможно ли такое?

Сообщение gen » 06.11.2009 15:35:47

v-t-l писал(а):а если опцию -D задействовать?
, все равно.

Добавлено спустя 6 минут 53 секунды:
на самом деле я нашел этот pp. Но все равно надо разобраться как производить конвертирование до конца,чтобы правильно было.
http://www.sciencetronics.com/download/fpc_libusb.tgz
gen
новенький
 
Сообщения: 74
Зарегистрирован: 18.06.2009 21:04:22


Вернуться в Lazarus

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 35

Рейтинг@Mail.ru
cron