mirror of
https://github.com/ErnyTech/Open-USB-Extreme
synced 2025-01-28 11:27:32 +01:00
toD: C completely removed, the C compiler is no longer a dependency
This commit is contained in:
parent
2479dae579
commit
91ef9e42bb
@ -1,27 +1,16 @@
|
||||
cmake_minimum_required(VERSION 2.8.9)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake-d")
|
||||
INCLUDE(CheckIncludeFile)
|
||||
project(Open-USB-Extreme D C)
|
||||
project(Open-USB-Extreme D)
|
||||
|
||||
file(GLOB SOURCES "lib/*.d")
|
||||
file(GLOB HEADERS "include/*.h" "include/*.di")
|
||||
file(GLOB EXAMPLE_SOURCES "examples/*.d")
|
||||
|
||||
include_directories(include)
|
||||
# check headers
|
||||
check_include_file("stdint.h" HAVE_STDINT)
|
||||
if (HAVE_STDINT)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_STDINT")
|
||||
endif()
|
||||
|
||||
check_include_file("stddef.h" HAVE_STDDEF)
|
||||
if (HAVE_STDDEF)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_STDDEF")
|
||||
endif()
|
||||
|
||||
file(GLOB SOURCES "lib/*.c")
|
||||
file(GLOB DSOURCES "lib/*.d")
|
||||
file(GLOB HEADERS "include/*.h")
|
||||
file(GLOB EXAMPLE_SOURCES "examples/*.c")
|
||||
set (CMAKE_CXX_STANDARD 89)
|
||||
#set(CMAKE_C_FLAGS "-Wall -pedantic -Wextra -Werror")
|
||||
set(CMAKE_D_FLAGS "${CMAKE_D_FLAGS} -betterC -O -release")
|
||||
add_library(${PROJECT_NAME} SHARED ${DSOURCES} ${SOURCES})
|
||||
set(CMAKE_D_FLAGS "${CMAKE_D_FLAGS} -betterC -O -release -L-rpath=.")
|
||||
add_library(${PROJECT_NAME} SHARED ${SOURCES})
|
||||
add_executable(open-usbextreme-example ${EXAMPLE_SOURCES})
|
||||
target_link_libraries(open-usbextreme-example ${PROJECT_NAME})
|
||||
|
||||
|
@ -1,40 +1,41 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <usbextreme.h>
|
||||
import core.stdc.stdio;
|
||||
import core.stdc.stdlib;
|
||||
import usbextreme;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
extern(C) 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");
|
||||
|
||||
auto f = fopen(argv[1].ptr, "rb");
|
||||
fseek(f, 0, SEEK_END);
|
||||
long fsize = ftell(f);
|
||||
|
||||
auto fsize = ftell(f);
|
||||
|
||||
if (fsize <= 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned long size = *(unsigned long*) &fsize;
|
||||
|
||||
auto size = *(cast(ulong*) &fsize);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
void *data = malloc(size + 1);
|
||||
auto data = malloc(size + 1);
|
||||
fread(data, size, 1, f);
|
||||
fclose(f);
|
||||
|
||||
usb_extreme_headers headers;
|
||||
|
||||
if(oue_read_headers(&headers, data, size) <= 0) {
|
||||
if (oue_read_headers(&headers, data, size) <= 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
usb_extreme_filestat filestats[10];
|
||||
int nstats = oue_read(filestats, headers, 10);
|
||||
usb_extreme_filestat[10] filestats = void;
|
||||
int nstats = oue_read(filestats.ptr, headers, 10);
|
||||
|
||||
int i;
|
||||
for(i = 0; i < nstats; i++) {
|
||||
printf("Game name [%d]: %s\n", filestats[i].offset, filestats[i].name);
|
||||
printf("Game name [%d]: %s\n", filestats[i].offset, filestats[i].name.ptr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user