mirror of
https://github.com/ErnyTech/Open-USB-Extreme
synced 2025-01-15 13:07:33 +01:00
62f3e85393
Signed-off-by: Ernesto Castellotti <erny.castell@gmail.com>
41 lines
861 B
C
41 lines
861 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <usbextreme.h>
|
|
|
|
int main(int argc, char *argv[]) {
|
|
if (argc < 2) {
|
|
printf("Usage: open-usbextreme-example <path/to/ul.cfg>\n");
|
|
return 1;
|
|
}
|
|
|
|
FILE *f = fopen(argv[1], "rb");
|
|
fseek(f, 0, SEEK_END);
|
|
long fsize = ftell(f);
|
|
|
|
if (fsize <= 0) {
|
|
return 1;
|
|
}
|
|
|
|
unsigned long size = *(unsigned long*) &fsize;
|
|
fseek(f, 0, SEEK_SET);
|
|
|
|
void *data = malloc(size + 1);
|
|
fread(data, size, 1, f);
|
|
fclose(f);
|
|
|
|
usb_extreme_headers headers;
|
|
|
|
if(oue_read_headers(&headers, data, size) <= 0) {
|
|
return 1;
|
|
}
|
|
|
|
usb_extreme_filestat filestats[10];
|
|
int nstats = oue_read(filestats, headers, 10);
|
|
|
|
int i;
|
|
for(i = 0; i < nstats; i++) {
|
|
printf("Game name [%d]: %s\n", filestats[i].offset, filestats[i].name);
|
|
}
|
|
return 0;
|
|
}
|