diff --git a/.gitmodules b/.gitmodules index d7271e4..7b4acd7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,9 @@ -[submodule "tools/ext/zlib"] - path = externals/zlib - url = https://github.com/madler/zlib.git -[submodule "tools/ext/cppformat"] - path = externals/cppformat - url = https://github.com/cppformat/cppformat.git -[submodule "tools/ext/excmd"] +[submodule "externals/excmd"] path = externals/excmd url = https://github.com/exjam/excmd +[submodule "externals/fmt"] + path = externals/fmt + url = https://github.com/fmtlib/fmt +[submodule "externals/zlib"] + path = externals/zlib + url = https://github.com/madler/zlib.git diff --git a/.travis.yml b/.travis.yml index d7fa2c8..12d5008 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,8 @@ matrix: - zlib1g-dev env: - MATRIX_EVAL="CC=gcc-6 && CXX=g++-6" + - os: osx + osx_image: xcode8.3 cache: directories: @@ -25,7 +27,8 @@ git: submodules: true before_script: - - wget https://freefr.dl.sourceforge.net/project/devkitpro/devkitPPC/devkitPPC_r29-1/devkitPPC_r29-1-x86_64-linux.tar.bz2 -O /tmp/devkitPPC.tar.bz2 + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget https://freefr.dl.sourceforge.net/project/devkitpro/devkitPPC/devkitPPC_r29-1/devkitPPC_r29-1-x86_64-linux.tar.bz2 -O /tmp/devkitPPC.tar.bz2; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget https://freefr.dl.sourceforge.net/project/devkitpro/devkitPPC/devkitPPC_r29-1/devkitPPC_r29-1-x86_64-osx.tar.bz2 -O /tmp/devkitPPC.tar.bz2; fi - tar -xjf /tmp/devkitPPC.tar.bz2 - export DEVKITPPC=$PWD/devkitPPC diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 5b9180f..c078e31 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -1,10 +1,10 @@ project(libraries) include(ExternalProject) -# cppformat -set(CPPFORMAT_DIR "cppformat") -externalproject_add(cppformat - SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${CPPFORMAT_DIR}" +# fmtlib +set(FMTLIB_DIR "fmt") +externalproject_add(fmtlib + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${FMTLIB_DIR}" CMAKE_CACHE_ARGS -DCMAKE_C_COMPILER:string=${CMAKE_C_COMPILER} -DCMAKE_C_FLAGS:string=${CMAKE_C_FLAGS} @@ -14,28 +14,28 @@ externalproject_add(cppformat -DFMT_INSTALL:string=off -DFMT_TEST:string=off INSTALL_COMMAND "") -externalproject_get_property(cppformat BINARY_DIR) -set_target_properties(cppformat PROPERTIES FOLDER libraries) +externalproject_get_property(fmtlib BINARY_DIR) +set_target_properties(fmtlib PROPERTIES FOLDER libraries) if(MSVC) - set(CPPFORMAT_IMPORTED_LOCATION - IMPORTED_LOCATION_DEBUG "${BINARY_DIR}/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}cppformat${CMAKE_FIND_LIBRARY_SUFFIXES}" - IMPORTED_LOCATION_RELEASE "${BINARY_DIR}/Release/${CMAKE_FIND_LIBRARY_PREFIXES}cppformat${CMAKE_FIND_LIBRARY_SUFFIXES}" - IMPORTED_LOCATION_RELWITHDEBINFO "${BINARY_DIR}/RelWithDebInfo/${CMAKE_FIND_LIBRARY_PREFIXES}cppformat${CMAKE_FIND_LIBRARY_SUFFIXES}" - IMPORTED_LOCATION_MINSIZEREL "${BINARY_DIR}/MinSizeRel/${CMAKE_FIND_LIBRARY_PREFIXES}cppformat${CMAKE_FIND_LIBRARY_SUFFIXES}") + set(FMTLIB_IMPORTED_LOCATION + IMPORTED_LOCATION_DEBUG "${BINARY_DIR}/fmt/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}fmt${CMAKE_FIND_LIBRARY_SUFFIXES}" + IMPORTED_LOCATION_RELEASE "${BINARY_DIR}/fmt/Release/${CMAKE_FIND_LIBRARY_PREFIXES}fmt${CMAKE_FIND_LIBRARY_SUFFIXES}" + IMPORTED_LOCATION_RELWITHDEBINFO "${BINARY_DIR}/fmt/RelWithDebInfo/${CMAKE_FIND_LIBRARY_PREFIXES}fmt${CMAKE_FIND_LIBRARY_SUFFIXES}" + IMPORTED_LOCATION_MINSIZEREL "${BINARY_DIR}/fmt/MinSizeRel/${CMAKE_FIND_LIBRARY_PREFIXES}fmt${CMAKE_FIND_LIBRARY_SUFFIXES}") else() - set(CPPFORMAT_IMPORTED_LOCATION - IMPORTED_LOCATION "${BINARY_DIR}/${CMAKE_FIND_LIBRARY_PREFIXES}cppformat.a") + set(FMTLIB_IMPORTED_LOCATION + IMPORTED_LOCATION "${BINARY_DIR}/fmt/${CMAKE_FIND_LIBRARY_PREFIXES}fmt.a") endif() -add_library(cppformat_import STATIC IMPORTED GLOBAL) -add_dependencies(cppformat_import cppformat) -set_target_properties(cppformat_import PROPERTIES ${CPPFORMAT_IMPORTED_LOCATION}) +add_library(fmtlib_import STATIC IMPORTED GLOBAL) +add_dependencies(fmtlib_import fmtlib) +set_target_properties(fmtlib_import PROPERTIES ${FMTLIB_IMPORTED_LOCATION}) -add_library(cppformat_final INTERFACE) -target_include_directories(cppformat_final INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/${CPPFORMAT_DIR}") -target_link_libraries(cppformat_final INTERFACE cppformat_import) -set(CPPFORMAT_LINK cppformat_final PARENT_SCOPE) +add_library(fmtlib_final INTERFACE) +target_include_directories(fmtlib_final INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/${FMTLIB_DIR}") +target_link_libraries(fmtlib_final INTERFACE fmtlib_import) +set(FMTLIB_LINK fmtlib_final PARENT_SCOPE) # excmd set(EXCMD_DIR "excmd") diff --git a/externals/cppformat b/externals/cppformat deleted file mode 160000 index 804ad8f..0000000 --- a/externals/cppformat +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 804ad8f4df7e01259374a1d2f458775f1b2d1164 diff --git a/externals/fmt b/externals/fmt new file mode 160000 index 0000000..3983438 --- /dev/null +++ b/externals/fmt @@ -0,0 +1 @@ +Subproject commit 398343897f98b88ade80bbebdcbe82a36c65a980 diff --git a/samples/gx2/triangle/src/main.c b/samples/gx2/triangle/src/main.c index 02deaee..e0bd431 100644 --- a/samples/gx2/triangle/src/main.c +++ b/samples/gx2/triangle/src/main.c @@ -116,5 +116,6 @@ exit: WHBUnmountSdCard(); WHBGfxShutdown(); WHBProcShutdown(); + WHBLogUdpDeinit(); return result; } diff --git a/src/crt/fs_dev.c b/src/crt/fs_dev.c index dab72a2..401c4af 100644 --- a/src/crt/fs_dev.c +++ b/src/crt/fs_dev.c @@ -16,12 +16,12 @@ static int fs_translate_error(FSStatus error); static int fs_open(struct _reent *r, void *fileStruct, const char *path, int flags, int mode); -static int fs_close(struct _reent *r, int fd); -static ssize_t fs_write(struct _reent *r, int fd, const char *ptr, size_t len); -static ssize_t fs_write_safe(struct _reent *r, int fd, const char *ptr, size_t len); -static ssize_t fs_read(struct _reent *r, int fd, char *ptr, size_t len); -static off_t fs_seek(struct _reent *r, int fd, off_t pos, int dir); -static int fs_fstat(struct _reent *r, int fd, struct stat *st); +static int fs_close(struct _reent *r, void *fd); +static ssize_t fs_write(struct _reent *r, void *fd, const char *ptr, size_t len); +static ssize_t fs_write_safe(struct _reent *r, void *fd, const char *ptr, size_t len); +static ssize_t fs_read(struct _reent *r, void *fd, char *ptr, size_t len); +static off_t fs_seek(struct _reent *r, void *fd, off_t pos, int dir); +static int fs_fstat(struct _reent *r, void *fd, struct stat *st); static int fs_stat(struct _reent *r, const char *file, struct stat *st); static int fs_link(struct _reent *r, const char *existing, const char *newLink); static int fs_unlink(struct _reent *r, const char *name); @@ -33,10 +33,10 @@ static int fs_dirreset(struct _reent *r, DIR_ITER *dirState); static int fs_dirnext(struct _reent *r, DIR_ITER *dirState, char *filename, struct stat *filestat); static int fs_dirclose(struct _reent *r, DIR_ITER *dirState); static int fs_statvfs(struct _reent *r, const char *path, struct statvfs *buf); -static int fs_ftruncate(struct _reent *r, int fd, off_t len); -static int fs_fsync(struct _reent *r, int fd); +static int fs_ftruncate(struct _reent *r, void *fd, off_t len); +static int fs_fsync(struct _reent *r, void *fd); static int fs_chmod(struct _reent *r, const char *path, mode_t mode); -static int fs_fchmod(struct _reent *r, int fd, mode_t mode); +static int fs_fchmod(struct _reent *r, void *fd, mode_t mode); static int fs_rmdir(struct _reent *r, const char *name); /** @@ -292,7 +292,7 @@ fs_open(struct _reent *r, static int fs_close(struct _reent *r, - int fd) + void *fd) { FSStatus rc; fs_file_t *file = (fs_file_t*)fd; @@ -313,7 +313,7 @@ fs_close(struct _reent *r, static ssize_t fs_write(struct _reent *r, - int fd, + void *fd, const char *ptr, size_t len) { @@ -373,7 +373,7 @@ fs_write(struct _reent *r, static ssize_t fs_write_safe(struct _reent *r, - int fd, + void *fd, const char *ptr, size_t len) { @@ -433,7 +433,7 @@ fs_write_safe(struct _reent *r, static ssize_t fs_read(struct _reent *r, - int fd, + void *fd, char *ptr, size_t len) { @@ -502,7 +502,7 @@ fs_read(struct _reent *r, static off_t fs_seek(struct _reent *r, - int fd, + void *fd, off_t pos, int whence) { @@ -565,7 +565,7 @@ fs_seek(struct _reent *r, static int fs_fstat(struct _reent *r, - int fd, + void *fd, struct stat *st) { FSStatus rc; @@ -613,7 +613,7 @@ fs_stat(struct _reent *r, if (rc >= 0) { fs_file_t tmpfd = { .fd = fd }; - rc = fs_fstat(r, (int)&tmpfd, st); + rc = fs_fstat(r, &tmpfd, st); FSCloseFile(fsClient, &fsCmd, fd, -1); return rc; } @@ -940,7 +940,7 @@ fs_statvfs(struct _reent *r, static int fs_ftruncate(struct _reent *r, - int fd, + void *fd, off_t len) { FSStatus rc; @@ -975,7 +975,7 @@ fs_ftruncate(struct _reent *r, static int fs_fsync(struct _reent *r, - int fd) + void *fd) { FSStatus rc; fs_file_t *file = (fs_file_t*)fd; @@ -1024,7 +1024,7 @@ fs_chmod(struct _reent *r, static int fs_fchmod(struct _reent *r, - int fd, + void *fd, mode_t mode) { //TODO: FSChangeMode and FSStatFile? diff --git a/src/libwhb/include/whb/commandserver.h b/src/libwhb/include/whb/commandserver.h new file mode 100644 index 0000000..59f5d3f --- /dev/null +++ b/src/libwhb/include/whb/commandserver.h @@ -0,0 +1,29 @@ +#pragma once +#include + +/** + * \defgroup whb_commandserver Network Command Server + * \ingroup whb + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define WHB_SERVER_BUFFER_SIZE 1024 + +BOOL +WHBCommandServerInit(); + +void +WHBCommandServerStop(); + +BOOL +WHBCommandServerListen(char * stringLocation); + +#ifdef __cplusplus +} +#endif + +/** @} */ diff --git a/src/libwhb/include/whb/libmanager.h b/src/libwhb/include/whb/libmanager.h new file mode 100644 index 0000000..d088997 --- /dev/null +++ b/src/libwhb/include/whb/libmanager.h @@ -0,0 +1,27 @@ +#pragma once + +/** + * \defgroup whb_socketinit Socket Library Initialization Manager + * \ingroup whb + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Socket Library (nsysnet.rpl) + */ + +void +WHBInitializeSocketLibrary(); + +void +WHBDeinitializeSocketLibrary(); + +#ifdef __cplusplus +} +#endif + +/** @} */ diff --git a/src/libwhb/include/whb/log.h b/src/libwhb/include/whb/log.h index 10871b0..f2c1964 100644 --- a/src/libwhb/include/whb/log.h +++ b/src/libwhb/include/whb/log.h @@ -16,9 +16,18 @@ typedef void (*LogHandlerFn)(const char *msg); BOOL WHBAddLogHandler(LogHandlerFn fn); +BOOL +WHBRemoveLogHandler(LogHandlerFn fn); + +BOOL +WHBLogWrite(const char *str); + BOOL WHBLogPrint(const char *str); +BOOL +WHBLogWritef(const char *fmt, ...); + BOOL WHBLogPrintf(const char *fmt, ...); diff --git a/src/libwhb/include/whb/log_cafe.h b/src/libwhb/include/whb/log_cafe.h index bc40515..023b5fe 100644 --- a/src/libwhb/include/whb/log_cafe.h +++ b/src/libwhb/include/whb/log_cafe.h @@ -14,6 +14,9 @@ extern "C" { BOOL WHBLogCafeInit(); +BOOL +WHBLogCafeDeinit(); + #ifdef __cplusplus } #endif diff --git a/src/libwhb/include/whb/log_udp.h b/src/libwhb/include/whb/log_udp.h index 28ba5d7..00900c6 100644 --- a/src/libwhb/include/whb/log_udp.h +++ b/src/libwhb/include/whb/log_udp.h @@ -14,6 +14,9 @@ extern "C" { BOOL WHBLogUdpInit(); +BOOL +WHBLogUdpDeinit(); + #ifdef __cplusplus } #endif diff --git a/src/libwhb/src/commandserver.c b/src/libwhb/src/commandserver.c new file mode 100644 index 0000000..a2c1831 --- /dev/null +++ b/src/libwhb/src/commandserver.c @@ -0,0 +1,138 @@ +#include +#include +#include +#include +#include +#include + +#include + +#define SERVER_PORT 4406 + +int +sSocket = -1; + +int +sClient = -1; + +struct sockaddr_in +sAddr; + +static inline void +closeSocket(const char * funcName) +{ + int ret = socketclose(sSocket); + if(ret < 0) { + WHBLogPrintf("%s: Error occurred closing socket: %d", funcName, socketlasterr()); + } + else { + sSocket = -1; + } +} + +static inline void +closeClient(const char * funcName) +{ + int ret = socketclose(sClient); + if(ret < 0) { + WHBLogPrintf("%s: Error occurred closing client socket: %d", funcName, socketlasterr()); + } + else { + sClient = -1; + } +} + +BOOL +WHBCommandServerInit() +{ + int ret = 0; + + if(sSocket >= 0) { + WHBLogPrintf("%s: Command server is already running.", __FUNCTION__); + return TRUE; + } + + WHBInitializeSocketLibrary(); + + sSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + if(sSocket < 0) { + WHBLogPrintf("%s: Error occurred while creating socket: %d", __FUNCTION__, socketlasterr()); + sSocket = -1; + return FALSE; + } + + memset(&sAddr, 0, sizeof(struct sockaddr_in)); + sAddr.sin_family = AF_INET; + sAddr.sin_port = htons(SERVER_PORT); + sAddr.sin_addr.s_addr = htonl(INADDR_ANY); + + ret = bind(sSocket, (struct sockaddr *)&sAddr, sizeof(struct sockaddr_in)); + if(ret < 0) { + WHBLogPrintf("%s: Error occurred while binding to socket: %d", __FUNCTION__, socketlasterr()); + closeSocket(__FUNCTION__); + return FALSE; + } + + ret = listen(sSocket, 3); + if(ret < 0) { + WHBLogPrintf("%s: Error occurred while setting socket to listen mode: %d", __FUNCTION__, socketlasterr()); + closeSocket(__FUNCTION__); + return FALSE; + } + + return TRUE; +} + +void +WHBCommandServerStop() +{ + if(sSocket < 0) { + WHBLogPrintf("%s: Socket is already closed.", __FUNCTION__); + return; + } + + if(sClient >= 0) { + closeClient(__FUNCTION__); + } + closeSocket(__FUNCTION__); + WHBDeinitializeSocketLibrary(); +} + +BOOL +WHBCommandServerListen(char * stringLocation) +{ + char buffer[WHB_SERVER_BUFFER_SIZE]; + memset(buffer, 0, WHB_SERVER_BUFFER_SIZE); + + int ret; + struct sockaddr_in sClientAddr; + socklen_t sClientAddrLen = sizeof(struct sockaddr_in); + + if(sSocket < 0) { + WHBLogPrintf("%s: Socket is not open. Please run WHBCommandServerInit() first.", __FUNCTION__); + return FALSE; + } + + if(sClient < 0) { + sClient = accept(sSocket, (struct sockaddr *)&sClientAddr, &sClientAddrLen); + if(sClient < 0) { + WHBLogPrintf("%s: Error occurred while accepting a client connection: %d", __FUNCTION__, socketlasterr()); + return FALSE; + } + } + + ret = recv(sClient, buffer, WHB_SERVER_BUFFER_SIZE, 0); + if(ret < 0) { + WHBLogPrintf("%s: Error occurred while receiving data from client: %d", __FUNCTION__, socketlasterr()); + closeClient(__FUNCTION__); + return FALSE; + } + if(ret == 0) { + WHBLogPrintf("%s: Remote socket was closed. Closing client connection...", __FUNCTION__); + closeClient(__FUNCTION__); + return FALSE; + } + + memcpy(stringLocation, buffer, WHB_SERVER_BUFFER_SIZE); + return TRUE; +} diff --git a/src/libwhb/src/libmanager.c b/src/libwhb/src/libmanager.c new file mode 100644 index 0000000..3701b00 --- /dev/null +++ b/src/libwhb/src/libmanager.c @@ -0,0 +1,33 @@ +#include + +/** + * Socket Library (nsysnet.rpl) + */ + +static BOOL +isSocketInitialized = FALSE; + +static unsigned int +numberOfSocketClients = 0; + +void +WHBInitializeSocketLibrary() +{ + if(!isSocketInitialized) { + isSocketInitialized = TRUE; + socket_lib_init(); + } + numberOfSocketClients++; +} + +void +WHBDeinitializeSocketLibrary() +{ + if(numberOfSocketClients > 0) { + numberOfSocketClients--; + } + if(isSocketInitialized && numberOfSocketClients == 0) { + isSocketInitialized = FALSE; + socket_lib_finish(); + } +} diff --git a/src/libwhb/src/log.c b/src/libwhb/src/log.c index 6b52c25..eccd15e 100644 --- a/src/libwhb/src/log.c +++ b/src/libwhb/src/log.c @@ -10,6 +10,17 @@ static LogHandlerFn sHandlers[MAX_HANDLERS] = { 0 }; +static inline void +dispatchMessage(const char * str) +{ + int i; + for (i = 0; i < MAX_HANDLERS; ++i) { + if (sHandlers[i]) { + sHandlers[i](str); + } + } +} + BOOL WHBAddLogHandler(LogHandlerFn fn) { @@ -26,36 +37,85 @@ WHBAddLogHandler(LogHandlerFn fn) } BOOL -WHBLogPrint(const char *str) +WHBRemoveLogHandler(LogHandlerFn fn) { int i; - for (i = 0; i < MAX_HANDLERS; ++i) { - if (sHandlers[i]) { - sHandlers[i](str); + for(i = 0; i < MAX_HANDLERS; ++i) { + if(sHandlers[i] == fn) { + sHandlers[i] = NULL; + return TRUE; } } + return FALSE; +} + +BOOL +WHBLogWrite(const char *str) +{ + dispatchMessage(str); return TRUE; } BOOL -WHBLogPrintf(const char *fmt, ...) +WHBLogPrint(const char *str) +{ + char *buf = MEMAllocFromDefaultHeapEx(PRINTF_BUFFER_LENGTH, 4); + if(!buf) { + return FALSE; + } + + snprintf(buf, PRINTF_BUFFER_LENGTH, "%s\n", str); + dispatchMessage(buf); + + MEMFreeToDefaultHeap(buf); + return TRUE; +} + +BOOL +WHBLogWritef(const char *fmt, ...) { char *buf = MEMAllocFromDefaultHeapEx(PRINTF_BUFFER_LENGTH, 4); va_list va; - BOOL result; if (!buf) { return FALSE; } va_start(va, fmt); - vsnprintf(buf, PRINTF_BUFFER_LENGTH, fmt, va); - result = WHBLogPrint(buf); + dispatchMessage(buf); MEMFreeToDefaultHeap(buf); va_end(va); - return result; + return TRUE; +} + +BOOL +WHBLogPrintf(const char *fmt, ...) +{ + char *buf1 = MEMAllocFromDefaultHeapEx(PRINTF_BUFFER_LENGTH, 4); + char *buf2 = MEMAllocFromDefaultHeapEx(PRINTF_BUFFER_LENGTH, 4); + va_list va; + + if (!buf1) { + return FALSE; + } + + if(!buf2) { + MEMFreeToDefaultHeap(buf1); + return FALSE; + } + + va_start(va, fmt); + + vsnprintf(buf1, PRINTF_BUFFER_LENGTH, fmt, va); + snprintf(buf2, PRINTF_BUFFER_LENGTH, "%s\n", buf1); + dispatchMessage(buf2); + + MEMFreeToDefaultHeap(buf1); + MEMFreeToDefaultHeap(buf2); + va_end(va); + return TRUE; } diff --git a/src/libwhb/src/log_cafe.c b/src/libwhb/src/log_cafe.c index a1367d3..34d067e 100644 --- a/src/libwhb/src/log_cafe.c +++ b/src/libwhb/src/log_cafe.c @@ -1,15 +1,29 @@ #include #include +#include + static void cafeLogHandler(const char * msg) { - OSReport("%s\n", msg); + int length = strlen(msg); + + if(msg[length-1] != '\n') { + OSReport("%s\n", msg); + } + else { + OSReport(msg); + } } BOOL WHBLogCafeInit() { - WHBAddLogHandler(cafeLogHandler); - return TRUE; + return WHBAddLogHandler(cafeLogHandler); +} + +BOOL +WHBLogCafeDeinit() +{ + return WHBRemoveLogHandler(cafeLogHandler); } diff --git a/src/libwhb/src/log_udp.c b/src/libwhb/src/log_udp.c index 713d4cc..2e5cd5e 100644 --- a/src/libwhb/src/log_udp.c +++ b/src/libwhb/src/log_udp.c @@ -4,6 +4,7 @@ #include #include #include +#include static int sSocket = -1; @@ -28,7 +29,7 @@ BOOL WHBLogUdpInit() { int broadcastEnable = 1; - socket_lib_init(); + WHBInitializeSocketLibrary(); sSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (sSocket < 0) { @@ -42,6 +43,16 @@ WHBLogUdpInit() sSendAddr.sin_port = htons(SERVER_PORT); sSendAddr.sin_addr.s_addr = htonl(INADDR_BROADCAST); - WHBAddLogHandler(udpLogHandler); - return TRUE; + return WHBAddLogHandler(udpLogHandler); +} + +BOOL +WHBLogUdpDeinit() +{ + if(shutdown(sSocket, SHUT_WR) != 0) { + return FALSE; + } + + WHBDeinitializeSocketLibrary(); + return WHBRemoveLogHandler(udpLogHandler); } diff --git a/tools/implcheck/CMakeLists.txt b/tools/implcheck/CMakeLists.txt index 718a441..58d926a 100644 --- a/tools/implcheck/CMakeLists.txt +++ b/tools/implcheck/CMakeLists.txt @@ -7,8 +7,8 @@ add_executable(implcheck ${SOURCE_FILES} ${HEADER_FILES}) set_target_properties(implcheck PROPERTIES FOLDER tools) target_link_libraries(implcheck PRIVATE - ${CPPFORMAT_LINK} ${EXCMD_LINK} + ${FMTLIB_LINK} ${ZLIB_LINK}) install(TARGETS implcheck RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") diff --git a/tools/implcheck/main.cpp b/tools/implcheck/main.cpp index 8316b0d..dac6ce4 100644 --- a/tools/implcheck/main.cpp +++ b/tools/implcheck/main.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include diff --git a/tools/readrpl/CMakeLists.txt b/tools/readrpl/CMakeLists.txt index d9a490f..31a6b29 100644 --- a/tools/readrpl/CMakeLists.txt +++ b/tools/readrpl/CMakeLists.txt @@ -7,8 +7,8 @@ add_executable(readrpl ${SOURCE_FILES} ${HEADER_FILES}) set_target_properties(readrpl PROPERTIES FOLDER tools) target_link_libraries(readrpl PRIVATE - ${CPPFORMAT_LINK} ${EXCMD_LINK} + ${FMTLIB_LINK} ${ZLIB_LINK}) install(TARGETS readrpl RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") diff --git a/tools/readrpl/main.cpp b/tools/readrpl/main.cpp index 5519e41..836d6bb 100644 --- a/tools/readrpl/main.cpp +++ b/tools/readrpl/main.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -700,7 +700,7 @@ int main(int argc, char **argv) if (header.magic != elf::HeaderMagic) { std::cout << "Invalid ELF magic header" << std::endl; - return false; + return -1; } // Read sections diff --git a/tools/udplogserver/main.cpp b/tools/udplogserver/main.cpp index 60bc9ba..fdec456 100644 --- a/tools/udplogserver/main.cpp +++ b/tools/udplogserver/main.cpp @@ -90,7 +90,8 @@ int main(int argc, char **argv) if (recvd > 0) { buffer[recvd] = 0; - std::cout << buffer << std::endl; + std::cout << buffer; + std::cout.flush(); } } }