mirror of
https://github.com/ErnyTech/Open-USB-Extreme
synced 2025-01-15 04:57:33 +01:00
toD: oue_read and remove usbextreme.c
This commit is contained in:
parent
cee71e8c8d
commit
2479dae579
@ -1,5 +1,5 @@
|
||||
// D import file generated from 'dusbextreme.d'
|
||||
module dusbextreme;
|
||||
// D import file generated from 'usbextreme.d'
|
||||
module usbextreme;
|
||||
import std.stdint;
|
||||
enum USBEXTREME_NAME_LENGTH = 32;
|
||||
enum USBEXTREME_ID_LENGTH = 15;
|
||||
@ -43,13 +43,50 @@ align (1) struct usb_extreme_v1
|
||||
char[USBEXTREME_NAME_EXT_LENGTH] name_ext;
|
||||
}
|
||||
}
|
||||
struct usb_extreme_headers
|
||||
{
|
||||
const(void)* first_header;
|
||||
const(usb_extreme_base)* headers;
|
||||
int num_headers;
|
||||
size_t headerslen;
|
||||
UsbExtremeVersion oueVersion;
|
||||
}
|
||||
struct usb_extreme_filestat
|
||||
{
|
||||
int offset;
|
||||
char[USBEXTREME_NAME_LENGTH + USBEXTREME_NAME_EXT_LENGTH] name;
|
||||
SCECdvdMediaType type;
|
||||
uint16_t size;
|
||||
uint8_t video_mode;
|
||||
UsbExtremeVersion usb_extreme_version;
|
||||
}
|
||||
enum UsbExtremeVersion
|
||||
{
|
||||
V0 = 0,
|
||||
V1,
|
||||
}
|
||||
enum SCECdvdMediaType
|
||||
{
|
||||
SCECdGDTFUNCFAIL = -1,
|
||||
SCECdNODISC = 0,
|
||||
SCECdDETCT,
|
||||
SCECdDETCTCD,
|
||||
SCECdDETCTDVDS,
|
||||
SCECdDETCTDVDD,
|
||||
SCECdUNKNOWN,
|
||||
SCECdPSCD = 16,
|
||||
SCECdPSCDDA,
|
||||
SCECdPS2CD,
|
||||
SCECdPS2CDDA,
|
||||
SCECdPS2DVD,
|
||||
SCECdCDDA = 253,
|
||||
SCECdDVDV,
|
||||
SCECdIllegalMediaoffset,
|
||||
}
|
||||
extern (C) int is_oue(const(void)* headers, size_t headerslen);
|
||||
extern (C) UsbExtremeVersion get_version(uint8_t usbExtremeVersion);
|
||||
extern (C) int oue_num_headers(int* num_headers, const(void)* headers, size_t headerslen);
|
||||
extern (C) int oue_point_headers(const(usb_extreme_base)** headers, const(void)* raw_headers, size_t headerslen);
|
||||
extern (C) int oue_version(UsbExtremeVersion* oueVersion, const(void)* headers, size_t headerslen);
|
||||
extern (C) int oue_read_headers(usb_extreme_headers* headers, const(void)* raw_headers, size_t headerslen);
|
||||
extern (C) int oue_read(usb_extreme_filestat* filestat, const(usb_extreme_headers) headers, int filestats_nlen);
|
@ -1,39 +0,0 @@
|
||||
#include <usbextreme.h>
|
||||
#include <string.h>
|
||||
|
||||
int oue_read(usb_extreme_filestat *filestat, const usb_extreme_headers headers, const int filestats_nlen) {
|
||||
int offset = filestats_nlen;
|
||||
usb_extreme_v1 *headers_full = (usb_extreme_v1*) headers.headers;
|
||||
usb_extreme_v1 header;
|
||||
usb_extreme_filestat filestats_temp = {0, {'0'}, 0, 0, 0, 0};
|
||||
u16 size = 0;
|
||||
u8 video_mode = 0;
|
||||
u8 usb_extreme_version;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < headers.num_headers; i++) {
|
||||
if(offset == 0) {
|
||||
return i;
|
||||
}
|
||||
|
||||
header = headers_full[i];
|
||||
strncpy(filestats_temp.name, header.name, USBEXTREME_NAME_LENGTH);
|
||||
usb_extreme_version = header.usb_extreme_version;
|
||||
|
||||
if(usb_extreme_version >= 1) {
|
||||
size = header.size;
|
||||
video_mode = header.video_mode;
|
||||
strncat(filestats_temp.name, header.name_ext, USBEXTREME_NAME_EXT_LENGTH);
|
||||
}
|
||||
|
||||
filestats_temp.size = size;
|
||||
filestats_temp.type = header.type;
|
||||
filestats_temp.offset = i;
|
||||
filestats_temp.video_mode = video_mode;
|
||||
filestats_temp.usb_extreme_version = usb_extreme_version;
|
||||
filestat[i] = filestats_temp;
|
||||
offset -= 1;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
module dusbextreme;
|
||||
module usbextreme;
|
||||
import std.stdint;
|
||||
|
||||
enum USBEXTREME_NAME_LENGTH = 32;
|
||||
@ -38,7 +38,7 @@ align(1) struct usb_extreme_v1 {
|
||||
char[USBEXTREME_NAME_EXT_LENGTH] name_ext;
|
||||
}
|
||||
|
||||
struct usb_extreme_headers{
|
||||
struct usb_extreme_headers {
|
||||
const(void)* first_header;
|
||||
const(usb_extreme_base)* headers;
|
||||
int num_headers;
|
||||
@ -46,11 +46,40 @@ struct usb_extreme_headers{
|
||||
UsbExtremeVersion oueVersion;
|
||||
}
|
||||
|
||||
struct usb_extreme_filestat {
|
||||
int offset;
|
||||
char[USBEXTREME_NAME_LENGTH + USBEXTREME_NAME_EXT_LENGTH] name;
|
||||
SCECdvdMediaType type;
|
||||
uint16_t size;
|
||||
uint8_t video_mode;
|
||||
UsbExtremeVersion usb_extreme_version;
|
||||
}
|
||||
|
||||
enum UsbExtremeVersion {
|
||||
V0 = 0x00,
|
||||
V1
|
||||
}
|
||||
|
||||
enum SCECdvdMediaType {
|
||||
SCECdGDTFUNCFAIL = -1,
|
||||
SCECdNODISC = 0x00,
|
||||
SCECdDETCT,
|
||||
SCECdDETCTCD,
|
||||
SCECdDETCTDVDS,
|
||||
SCECdDETCTDVDD,
|
||||
SCECdUNKNOWN,
|
||||
|
||||
SCECdPSCD = 0x10,
|
||||
SCECdPSCDDA,
|
||||
SCECdPS2CD,
|
||||
SCECdPS2CDDA,
|
||||
SCECdPS2DVD,
|
||||
|
||||
SCECdCDDA = 0xFD,
|
||||
SCECdDVDV,
|
||||
SCECdIllegalMediaoffset
|
||||
}
|
||||
|
||||
extern(C) int is_oue(const(void)* headers, size_t headerslen) {
|
||||
const headers_oeu = cast(const usb_extreme_base*) headers;
|
||||
auto headers_nlen = headerslen / USBEXTREME_HEADER_SIZE;
|
||||
@ -153,3 +182,42 @@ extern(C) int oue_read_headers(usb_extreme_headers* headers, const(void)* raw_he
|
||||
*headers = headers_temp;
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern(C) int oue_read(usb_extreme_filestat* filestat, const(usb_extreme_headers) headers, int filestats_nlen) {
|
||||
import core.stdc.string : strncpy, strncat;
|
||||
|
||||
int offset = filestats_nlen;
|
||||
auto headers_full = cast(usb_extreme_v1*) headers.headers;
|
||||
usb_extreme_v1 header;
|
||||
usb_extreme_filestat filestats_temp = {0, ['0'], SCECdvdMediaType.SCECdNODISC, 0, 0, UsbExtremeVersion.V0};
|
||||
uint16_t size = 0;
|
||||
uint8_t video_mode = 0;
|
||||
uint8_t usb_extreme_version;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < headers.num_headers; i++) {
|
||||
if(offset == 0) {
|
||||
return i;
|
||||
}
|
||||
|
||||
header = headers_full[i];
|
||||
strncpy(filestats_temp.name.ptr, header.name.ptr, USBEXTREME_NAME_LENGTH);
|
||||
usb_extreme_version = header.usb_extreme_version;
|
||||
|
||||
if(usb_extreme_version >= 1) {
|
||||
size = header.size;
|
||||
video_mode = header.video_mode;
|
||||
strncat(filestats_temp.name.ptr, header.name_ext.ptr, USBEXTREME_NAME_EXT_LENGTH);
|
||||
}
|
||||
|
||||
filestats_temp.size = size;
|
||||
filestats_temp.type = cast(SCECdvdMediaType) header.type;
|
||||
filestats_temp.offset = i;
|
||||
filestats_temp.video_mode = video_mode;
|
||||
filestats_temp.usb_extreme_version = cast(UsbExtremeVersion) usb_extreme_version;
|
||||
filestat[i] = filestats_temp;
|
||||
offset -= 1;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user