mirror of
https://github.com/ErnyTech/Open-USB-Extreme
synced 2025-02-06 02:26:48 +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)
|
cmake_minimum_required(VERSION 2.8.9)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake-d")
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake-d")
|
||||||
INCLUDE(CheckIncludeFile)
|
project(Open-USB-Extreme D)
|
||||||
project(Open-USB-Extreme D C)
|
|
||||||
|
file(GLOB SOURCES "lib/*.d")
|
||||||
|
file(GLOB HEADERS "include/*.h" "include/*.di")
|
||||||
|
file(GLOB EXAMPLE_SOURCES "examples/*.d")
|
||||||
|
|
||||||
include_directories(include)
|
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)
|
set(CMAKE_D_FLAGS "${CMAKE_D_FLAGS} -betterC -O -release -L-rpath=.")
|
||||||
if (HAVE_STDDEF)
|
add_library(${PROJECT_NAME} SHARED ${SOURCES})
|
||||||
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})
|
|
||||||
add_executable(open-usbextreme-example ${EXAMPLE_SOURCES})
|
add_executable(open-usbextreme-example ${EXAMPLE_SOURCES})
|
||||||
target_link_libraries(open-usbextreme-example ${PROJECT_NAME})
|
target_link_libraries(open-usbextreme-example ${PROJECT_NAME})
|
||||||
|
|
||||||
|
@ -1,40 +1,41 @@
|
|||||||
#include <stdio.h>
|
import core.stdc.stdio;
|
||||||
#include <stdlib.h>
|
import core.stdc.stdlib;
|
||||||
#include <usbextreme.h>
|
import usbextreme;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
extern(C) int main(int argc, char[]* argv) {
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
printf("Usage: open-usbextreme-example <path/to/ul.cfg>\n");
|
printf("Usage: open-usbextreme-example <path/to/ul.cfg>\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *f = fopen(argv[1], "rb");
|
auto f = fopen(argv[1].ptr, "rb");
|
||||||
fseek(f, 0, SEEK_END);
|
fseek(f, 0, SEEK_END);
|
||||||
long fsize = ftell(f);
|
auto fsize = ftell(f);
|
||||||
|
|
||||||
if (fsize <= 0) {
|
if (fsize <= 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long size = *(unsigned long*) &fsize;
|
auto size = *(cast(ulong*) &fsize);
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
void *data = malloc(size + 1);
|
auto data = malloc(size + 1);
|
||||||
fread(data, size, 1, f);
|
fread(data, size, 1, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
usb_extreme_headers headers;
|
usb_extreme_headers headers;
|
||||||
|
|
||||||
if(oue_read_headers(&headers, data, size) <= 0) {
|
if (oue_read_headers(&headers, data, size) <= 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_extreme_filestat filestats[10];
|
usb_extreme_filestat[10] filestats = void;
|
||||||
int nstats = oue_read(filestats, headers, 10);
|
int nstats = oue_read(filestats.ptr, headers, 10);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < nstats; 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;
|
return 0;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user