From f4ae338484c4f540252a0732b3baa28a71f73ae5 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Thu, 19 Feb 2026 13:27:04 -0700 Subject: [PATCH 1/2] Remove some files that were mistakingly recreated by recent merges --- CMakeLists.txt | 33 +---------- portable/CMakeLists.txt | 39 ------------- portable/headers.cmake | 60 -------------------- portable/sources.cmake | 16 ------ portable/time/VariableClock.h | 71 ----------------------- qdecoder/src/CMakeLists.txt | 46 --------------- regex/CMakeLists.txt | 41 -------------- regex/regex.cpp | 103 ---------------------------------- sqlite/CMakeLists.txt | 50 ----------------- unistd/CMakeLists.txt | 5 -- uuid/CMakeLists.txt | 80 -------------------------- xxhash/CMakeLists.txt | 41 -------------- 12 files changed, 2 insertions(+), 583 deletions(-) delete mode 100644 portable/CMakeLists.txt delete mode 100644 portable/headers.cmake delete mode 100644 portable/sources.cmake delete mode 100644 portable/time/VariableClock.h delete mode 100644 qdecoder/src/CMakeLists.txt delete mode 100644 regex/CMakeLists.txt delete mode 100644 regex/regex.cpp delete mode 100644 sqlite/CMakeLists.txt delete mode 100644 uuid/CMakeLists.txt delete mode 100644 xxhash/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 3660db5..ef6f6d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ set(CMAKE_C_STANDARD 23) add_definitions(-DTRACE_MSG_FUNCTIONS) add_definitions(-D_CRT_DECLARE_NONSTDC_NAMES=0) -#define _CRT_SECURE_NO_DEPRECATE +#define _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_WARNINGS #define _WINSOCK_DEPRECATED_NO_WARNINGS #define _CRT_NONSTDC_NO_WARNINGS @@ -44,37 +44,8 @@ if(NOT WIN32 AND NOT APPLE) message("Linking rt pthread dl") endif(NOT WIN32 AND NOT APPLE) -#add_subdirectory(portable) -#add_subdirectory(sqlite) -#add_subdirectory(uuid) -#add_subdirectory(regex) -#add_subdirectory(xxhash) -#add_subdirectory(lmdb) -if(WITH_TESTS) - add_subdirectory(test) -endif() -option(BUILD_PORTABLE "Build portable" OFF) -option(BUILD_SQLITE "Build sqlite" OFF) -option(BUILD_UUID "Build uuid" OFF) -option(BUILD_REGEX "Build regex" OFF) -option(BUILD_XXHASH "Build xxhash" OFF) +option(WITH_TESTS "Build tests" OFF) -if (BUILD_PORTABLE) - message("Buliding portable") - add_subdirectory(portable) -endif (BUILD_PORTABLE) -if (BUILD_SQLITE) - add_subdirectory(sqlite) -endif (BUILD_SQLITE) -if (BUILD_UUID) - add_subdirectory(uuid) -endif (BUILD_UUID) -if (BUILD_REGEX) - add_subdirectory(regex) -endif (BUILD_REGEX) -if (BUILD_XXHASH) - add_subdirectory(xxhash) -endif (BUILD_XXHASH) if (WITH_TESTS) add_subdirectory(test) endif (WITH_TESTS) diff --git a/portable/CMakeLists.txt b/portable/CMakeLists.txt deleted file mode 100644 index cdf37c6..0000000 --- a/portable/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -# libunistd/portable/CMakeLists.txt - -project(libportable) -message("--- Building library ${PROJECT_NAME} ---") - -file(STRINGS headers.cmake HEADERS) -file(STRINGS sources.cmake SOURCES) - -source_group("Header Files" FILES "${HEADERS}") -source_group("Source Files" FILES "${SOURCES}") - -include(GNUInstallDirs) -if (BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS AND BUILD_PORTABLE_SHARED) - set(lib_type SHARED) -else () - set(lib_type STATIC) -endif () -add_library("${PROJECT_NAME}" ${lib_type} "${HEADERS}" "${SOURCES}") - -####################################### -# Export / installation configuration # -####################################### - -# setup the version PROJECT_NAME -set_property(TARGET "${PROJECT_NAME}" PROPERTY VERSION "${${PROJECT_NAME}_VERSION}") -set_property(TARGET "${PROJECT_NAME}" PROPERTY SOVERSION "${${PROJECT_NAME}_VERSION_MAJOR}") - -# install rules -list(APPEND installable_libs "${PROJECT_NAME}") -if (TARGET "${DEPENDANT_LIBRARY}") - list(APPEND installable_libs "${DEPENDANT_LIBRARY}") -endif (TARGET "${DEPENDANT_LIBRARY}") -install(TARGETS ${installable_libs} - EXPORT "${PROJECT_NAME}Targets" - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") -install(FILES ${HEADERS} - TYPE "INCLUDE") diff --git a/portable/headers.cmake b/portable/headers.cmake deleted file mode 100644 index fdcb27d..0000000 --- a/portable/headers.cmake +++ /dev/null @@ -1,60 +0,0 @@ -CMakeLists.txt -headers.cmake -Astring.h -AtomicCounter.h -AtomicLock.h -AtomicLock0.h -AtomicMutex.h -Breakpoint.h -ipc/BsdMulticast.h -ipc/BsdPacketServer.h -ipc/BsdSocket.h -ipc/BsdSocketClient.h -ipc/BsdSocketPool.h -ipc/BsdSocketServer.h -ipc/BsdSocketStartup.h -Buffer.h -Cfile.h -CommandLine.h -Counter.h -CppTypes.h -endian.h -Finder.h -Folder.h -homedir.h -http/HtmlPage.h -http/Http.h -http/HttpDecoder.h -Logger.h -MsgBuffer.h -Network.h -ipc/Packet.h -ipc/PacketBuffer.h -ipc/PacketMarker.h -ipc/PacketQueue.h -ipc/PacketReader.h -ipc/PacketSizer.h -ipc/PacketWriter.h -QtHelpers.h -pump/Pump.h -Random.h -SoftLock.h -StdBlob.h -StdCopy.h -StdDevice.h -StdFile.h -StdPipe.h -strcpy.h -SystemCall.h -thread_semaphore.h -time/Timecode.h -pump/TimerPump.h -time/Timespan.h -time/Timestamp.h -UnrealLogger.h -time/VariableClock.h -Vec3d.h -VerboseCounter.h -time/WallClock.h -time/Watchdog.h -WormFile.h diff --git a/portable/sources.cmake b/portable/sources.cmake deleted file mode 100644 index 61f1337..0000000 --- a/portable/sources.cmake +++ /dev/null @@ -1,16 +0,0 @@ -CMakeLists.txt -sources.cmake -ipc/BsdPacketServer.cpp -ipc/BsdSocket.cpp -ipc/BsdSocketClient.cpp -ipc/BsdSocketPool.cpp -ipc/BsdSocketServer.cpp -ipc/BsdSocketStartup.cpp -CommandLine.cpp -http/Http.cpp -Network.cpp -ipc/PacketReader.cpp -pump/Pump.cpp -time/Timestamp.cpp -time/VariableClock.cpp -WormFile.cpp \ No newline at end of file diff --git a/portable/time/VariableClock.h b/portable/time/VariableClock.h deleted file mode 100644 index 1c2e74b..0000000 --- a/portable/time/VariableClock.h +++ /dev/null @@ -1,71 +0,0 @@ -// VariableClock.h -// Copyright 2016 Robin.Rowe@CinePaint.org -// License open source MIT - -#ifndef VariableClock_h -#define VariableClock_h - -#include -#include -#include - -namespace portable -{ - -class VariableClock -{ static double speed; - static timeval dayStart; - static timespec clockStart; -public: - VariableClock() - { SetSpeed(1.); - } - static bool IsNormaltime() - { if(speed<=0.) - { return true;// negative time ignored - } - if(speed<1.) - { return false;// fractional speed - } - if(speed>1.) - { return false;// high speed - } - return true;// 1X speed - } - static void SetSpeed(double speed=1.) - { ::gettimeofday(&dayStart,nullptr); - ::clock_gettime(CLOCK_MONOTONIC,&clockStart); - VariableClock::speed = speed; - } - static int gettimeofday(struct timeval* tv, struct timezone* tz) - { if(IsNormaltime()) - { return ::gettimeofday(tv,tz); - } - timeval delta; - ::gettimeofday(&delta,tz); - delta.tv_sec-=dayStart.tv_sec; - delta.tv_sec=static_cast(double(delta.tv_sec)*speed); - delta.tv_usec-=dayStart.tv_usec; - delta.tv_usec=static_cast(double(delta.tv_usec)*speed); - tv->tv_sec=dayStart.tv_sec+delta.tv_sec; - tv->tv_usec=dayStart.tv_usec+delta.tv_sec; - return 0; - } - static int clock_gettime(clockid_t clk_id, struct timespec *tp) - { if(IsNormaltime()) - { return ::clock_gettime(clk_id,tp); - } - timespec delta; - ::clock_gettime(clk_id,&delta); - delta.tv_sec-=clockStart.tv_sec; - delta.tv_sec=static_cast(double(delta.tv_sec)*speed); - delta.tv_nsec-=clockStart.tv_nsec; - delta.tv_nsec=static_cast(double(delta.tv_nsec)*speed); - tp->tv_sec=clockStart.tv_sec+delta.tv_sec; - tp->tv_nsec=clockStart.tv_nsec+delta.tv_nsec; - return 0; -} }; - -} - -#endif diff --git a/qdecoder/src/CMakeLists.txt b/qdecoder/src/CMakeLists.txt deleted file mode 100644 index 4e78c53..0000000 --- a/qdecoder/src/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -# libqdecoder -# Copyright Robin.Rowe@cinepaint.org 2015/7/19 -# License MIT or BSD - -cmake_minimum_required(VERSION 2.8) -project(CMake_qdecoder) - -#version number -set(CMake_qdecoder_VERSION_MAJOR 1) -set(CMake_qdecoder_VERSION_MINOR 0) -set(CMake_qdecoder_VERSION_PATCH 0) - -file(GLOB qdecoder_HDR "*.h") -source_group("Header Files" FILES "${qdecoder_HDR}") - -file(GLOB qdecoder_SRC "*.cpp") -source_group("Source Files" FILES "${qdecoder_SRC}") - -if (BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS) - set(lib_type SHARED) -else () - set(lib_type STATIC) -endif () -set(LIBRARY_NAME "qdecoder") -add_library( ${LIBRARY_NAME} ${lib_type} ${qdecoder_HDR} ${qdecoder_SRC} ) - -####################################### -# Export / installation configuration # -####################################### - -# setup the version LIBRARY_NAME -set_property(TARGET "${LIBRARY_NAME}" PROPERTY VERSION "${${LIBRARY_NAME}_VERSION}") -set_property(TARGET "${LIBRARY_NAME}" PROPERTY SOVERSION "${${LIBRARY_NAME}_VERSION_MAJOR}") - -# install rules -list(APPEND installable_libs "${LIBRARY_NAME}") -if (TARGET "${DEPENDANT_LIBRARY}") - list(APPEND installable_libs "${DEPENDANT_LIBRARY}") -endif (TARGET "${DEPENDANT_LIBRARY}") -install(TARGETS ${installable_libs} - EXPORT "${LIBRARY_NAME}Targets" - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") -install(FILES ${qdecoder_HDR} - TYPE "INCLUDE") diff --git a/regex/CMakeLists.txt b/regex/CMakeLists.txt deleted file mode 100644 index 946d85f..0000000 --- a/regex/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -# libunistd/lmdb/CMakeLists.txt - -project(libregex) -message("--- Building library ${PROJECT_NAME} ---") - -set(Header_Files "regex.h") -source_group("Header Files" FILES "${Header_Files}") - -set(Source_Files "regex.cpp") -source_group("Source Files" FILES "${Source_Files}") - -if (BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS) - set(lib_type SHARED) -else () - set(lib_type STATIC) -endif () -set(LIBRARY_NAME "${PROJECT_NAME}") -add_library(${LIBRARY_NAME} ${lib_type} ${Header_Files} ${Source_Files} ) - -####################################### -# Export / installation configuration # -####################################### - -include(GNUInstallDirs) - -# setup the version LIBRARY_NAME -set_property(TARGET "${LIBRARY_NAME}" PROPERTY VERSION "${${LIBRARY_NAME}_VERSION}") -set_property(TARGET "${LIBRARY_NAME}" PROPERTY SOVERSION "${${LIBRARY_NAME}_VERSION_MAJOR}") - -# install rules -list(APPEND installable_libs "${LIBRARY_NAME}") -if (TARGET "${DEPENDANT_LIBRARY}") - list(APPEND installable_libs "${DEPENDANT_LIBRARY}") -endif (TARGET "${DEPENDANT_LIBRARY}") -install(TARGETS ${installable_libs} - EXPORT "${LIBRARY_NAME}Targets" - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") -install(FILES ${Header_Files} - TYPE "INCLUDE") diff --git a/regex/regex.cpp b/regex/regex.cpp deleted file mode 100644 index f9a54f3..0000000 --- a/regex/regex.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// fnmatch.cpp -// Copyright (c) 2022/10/19 Tomer Lev -// License open source MIT - -#include -#include -#include - -#include "regex.h" - -using namespace std::regex_constants; - -const std::vector ERROR_MESSAGE = -{ "Success", /* REG_NOERROR */ - "No match", /* REG_NOMATCH */ - "Invalid regular expression", /* REG_BADPAT */ - "Invalid collation character", /* REG_ECOLLATE */ - "Invalid character class name", /* REG_ECTYPE */ - "Trailing backslash", /* REG_EESCAPE */ - "Invalid back reference", /* REG_ESUBREG */ - "Unmatched [ or [^", /* REG_EBRACK */ - "Unmatched ( or \\( or ) or \\)", /* REG_EPAREN */ - "Unmatched \\{", /* REG_EBRACE */ - "Invalid content of \\{\\}", /* REG_BADBR */ - "Invalid range end", /* REG_ERANGE */ - "Memory exhausted", /* REG_ESPACE */ - "Invalid preceding regular expression", /* REG_BADRPT */ - "Premature end of regular expression", /* REG_EEND */ - "Regular expression too big", /* REG_ESIZE */ -}; - -const std::map ERROR_TYPE = -{ {error_collate, REG_ECOLLATE}, - {error_ctype, REG_ECTYPE}, - {error_escape, REG_EESCAPE}, - {error_backref, REG_ESUBREG}, - {error_brack, REG_EBRACK}, - {error_paren, REG_EPAREN}, - {error_brace, REG_EBRACE}, - {error_badbrace, REG_BADBR}, - {error_range, REG_ERANGE}, - {error_space, REG_ESPACE}, - {error_badrepeat, REG_BADRPT}, - {error_complexity, REG_ESIZE}, -<<<<<<< HEAD - {error_stack, REG_ESIZE} -======= - {error_stack, REG_ESIZE}, - /*{error_parse, REG_BADPAT},*/ - {error_syntax, REG_BADPAT} ->>>>>>> bccd5e70ec493ab91d0f1f3e5deb0842d04e503d -}; - -int getErrorCode(error_type err) -{ auto errorItem = ERROR_TYPE.find(err); - if (errorItem == ERROR_TYPE.end()) - { return REG_EUNKNOWN; - } - return errorItem->second; -} - -int regcomp(regex_t *preg, const char *regex, int cflags) -{ try - { preg->pattern = std::make_unique(regex, cflags); - } - catch (const std::regex_error& e) - { return getErrorCode(e.code()); - } - return REG_NOERROR; -} - -int regexec(const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags) -{ try - { std::cmatch matches; - bool foundMatch = std::regex_search(string, matches, *preg->pattern, std::regex_constants::match_flag_type(eflags)); - if (!foundMatch) - { return REG_NOMATCH; - } - size_t maxMatches = sizeof(pmatch) / sizeof(regmatch_t); - for (size_t i = 0; i < matches.size() && i < maxMatches; ++i) - { pmatch[i].rm_so = matches.position(i); - pmatch[i].rm_eo = matches.position(i) + matches.length(i); - } - } - catch (const std::regex_error& e) - { return getErrorCode(e.code()); - } - return REG_NOERROR; -} - -size_t regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size) -{ if (errcode < 0 || errcode >= REG_MAXERR || errbuf_size == 0) - { return 0; - } - const std::string& message = ERROR_MESSAGE[errcode]; - std::fill(errbuf, errbuf + errbuf_size, 0); - memcpy_s(errbuf, errbuf_size, message.c_str(), message.size()); - return std::min(message.size(), errbuf_size); -} - -void regfree(regex_t *preg) -{ preg->pattern.reset(); -} diff --git a/sqlite/CMakeLists.txt b/sqlite/CMakeLists.txt deleted file mode 100644 index 5353c17..0000000 --- a/sqlite/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -# libunistd/sqlite/CMakeLists.txt - -project(libsqlite) -message("--- Building library ${PROJECT_NAME} ---") - -set(SOURCES - source/sqlite3.h - source/sqlite3ext.h - source/sqlite3.c -) - -set(Header_Files "source/sqlite3.h" "source/sqlite3ext.h") -source_group("Header Files" FILES "${Header_Files}") - -set(Source_Files "source/sqlite3.c") -source_group("Source Files" FILES "${Source_Files}") - -if (BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS) - set(lib_type SHARED) -else () - set(lib_type STATIC) -endif () -set(LIBRARY_NAME "${PROJECT_NAME}") -add_library(${LIBRARY_NAME} ${lib_type} ${Header_Files} ${Source_Files} ) - -# TODO: install executable -add_executable(sqlite ${Header_Files} ${Source_Files} source/shell.c) - -####################################### -# Export / installation configuration # -####################################### - -include(GNUInstallDirs) - -# setup the version LIBRARY_NAME -set_property(TARGET "${LIBRARY_NAME}" PROPERTY VERSION "${${LIBRARY_NAME}_VERSION}") -set_property(TARGET "${LIBRARY_NAME}" PROPERTY SOVERSION "${${LIBRARY_NAME}_VERSION_MAJOR}") - -# install rules -list(APPEND installable_libs "${LIBRARY_NAME}") -if (TARGET "${DEPENDANT_LIBRARY}") - list(APPEND installable_libs "${DEPENDANT_LIBRARY}") -endif (TARGET "${DEPENDANT_LIBRARY}") -install(TARGETS ${installable_libs} - EXPORT "${LIBRARY_NAME}Targets" - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") -install(FILES ${Header_Files} - TYPE "INCLUDE") diff --git a/unistd/CMakeLists.txt b/unistd/CMakeLists.txt index 0f335f8..98c42d5 100644 --- a/unistd/CMakeLists.txt +++ b/unistd/CMakeLists.txt @@ -25,11 +25,6 @@ add_library(${LIBRARY_NAME} target_include_directories(${LIBRARY_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(${LIBRARY_NAME} LINK_PUBLIC shlwapi) -if (lib_type STREQUAL "STATIC") - target_link_libraries(${LIBRARY_NAME} LINK_PUBLIC libportable) -else () - target_link_libraries(${LIBRARY_NAME} PRIVATE libportable) -endif () ####################################### # Export / installation configuration # diff --git a/uuid/CMakeLists.txt b/uuid/CMakeLists.txt deleted file mode 100644 index 8999de9..0000000 --- a/uuid/CMakeLists.txt +++ /dev/null @@ -1,80 +0,0 @@ -# libunistd/libuuid/CMakeLists.txt - -project(libuuid) -message("--- Building library ${PROJECT_NAME} ---") - -if(WIN32) -include_directories( - "${CMAKE_CURRENT_SOURCE_DIR}/../unistd" -) -endif(WIN32) - -add_definitions( - -DHAVE_UNISTD_H - -DHAVE_ERR - -DHAVE_ERRX - -DHAVE_WARN - -DHAVE_WARNX - -DHAVE_STDLIB_H - -DHAVE_USLEEP - -DHAVE_SYS_TIME_H - ) - -set(HEADERS - uuid.h - all-io.h - c.h - randutils.h - uuidd.h - uuidP.h -) -source_group("Header Files" FILES "${HEADERS}") - -set(SOURCES - clear.cpp - compare.cpp - copy.cpp - gen_uuid.cpp - isnull.cpp - pack.cpp - parse.cpp - unpack.cpp - unparse.cpp - uuid_time.cpp - randutils.cpp -) -source_group("Source Files" FILES "${SOURCES}") - -if (BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS) - set(lib_type SHARED) -else () - set(lib_type STATIC) -endif () -set(LIBRARY_NAME "${PROJECT_NAME}") -add_library(${LIBRARY_NAME} ${lib_type} ${HEADERS} ${SOURCES} ) -if(WITH_TESTS) - add_subdirectory(test) -endif() - -####################################### -# Export / installation configuration # -####################################### - -include(GNUInstallDirs) - -# setup the version LIBRARY_NAME -set_property(TARGET "${LIBRARY_NAME}" PROPERTY VERSION "${${LIBRARY_NAME}_VERSION}") -set_property(TARGET "${LIBRARY_NAME}" PROPERTY SOVERSION "${${LIBRARY_NAME}_VERSION_MAJOR}") - -# install rules -list(APPEND installable_libs "${LIBRARY_NAME}") -if (TARGET "${DEPENDANT_LIBRARY}") - list(APPEND installable_libs "${DEPENDANT_LIBRARY}") -endif (TARGET "${DEPENDANT_LIBRARY}") -install(TARGETS ${installable_libs} - EXPORT "${LIBRARY_NAME}Targets" - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") -install(FILES ${HEADERS} - TYPE "INCLUDE") diff --git a/xxhash/CMakeLists.txt b/xxhash/CMakeLists.txt deleted file mode 100644 index 0640a06..0000000 --- a/xxhash/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -# libunistd/xxhash/CMakeLists.txt - -project(libxxhash) -message("--- Building library ${PROJECT_NAME} ---") - -set(Header_Files "xxhash.h") -source_group("Header Files" FILES "${Header_Files}") - -set(Source_Files "xxhash.c" "xxhsum.c") -source_group("Source Files" FILES "${Source_Files}") - -if (BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS) - set(lib_type SHARED) -else () - set(lib_type STATIC) -endif () -set(LIBRARY_NAME "${PROJECT_NAME}") -add_library(${LIBRARY_NAME} ${lib_type} ${Header_Files} ${Source_Files} ) - -####################################### -# Export / installation configuration # -####################################### - -include(GNUInstallDirs) - -# setup the version LIBRARY_NAME -set_property(TARGET "${LIBRARY_NAME}" PROPERTY VERSION "${${LIBRARY_NAME}_VERSION}") -set_property(TARGET "${LIBRARY_NAME}" PROPERTY SOVERSION "${${LIBRARY_NAME}_VERSION_MAJOR}") - -# install rules -list(APPEND installable_libs "${LIBRARY_NAME}") -if (TARGET "${DEPENDANT_LIBRARY}") - list(APPEND installable_libs "${DEPENDANT_LIBRARY}") -endif (TARGET "${DEPENDANT_LIBRARY}") -install(TARGETS ${installable_libs} - EXPORT "${LIBRARY_NAME}Targets" - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") -install(FILES ${Header_Files} - TYPE "INCLUDE") From 13b47d3239b52f277690eb5b84557a13ae69603c Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Thu, 19 Feb 2026 13:37:46 -0700 Subject: [PATCH 2/2] Remove tests that are related to removed 3rdparty libs --- test/CMakeLists.txt | 6 - test/test_PosixQueue/CMakeLists.txt | 7 - test/test_PosixQueue/mq_receive/main.cpp | 47 ------ test/test_PosixQueue/mq_send/main.cpp | 37 ----- test/test_Pump/CMakeLists.txt | 4 - test/test_Pump/test_Pump.cpp | 23 --- test/test_lmdb/CMakeLists.txt | 16 -- test/test_lmdb/ProductData.h | 51 ------- test/test_lmdb/data.mdb | Bin 1048576 -> 0 bytes test/test_lmdb/lock.mdb | Bin 8192 -> 0 bytes test/test_lmdb/sample-mdb.c | 89 ----------- test/test_lmdb/test-lmdb-full.cpp | 179 ----------------------- test/test_lmdb/test-lmdb.cpp | 98 ------------- test/test_logger/CMakeLists.txt | 6 - test/test_logger/main.cpp | 50 ------- test/test_sqlite/CMakeLists.txt | 6 - test/test_sqlite/main.cpp | 86 ----------- test/test_wormfile/CMakeLists.txt | 4 - test/test_wormfile/main.cpp | 43 ------ 19 files changed, 752 deletions(-) delete mode 100644 test/test_PosixQueue/CMakeLists.txt delete mode 100644 test/test_PosixQueue/mq_receive/main.cpp delete mode 100644 test/test_PosixQueue/mq_send/main.cpp delete mode 100644 test/test_Pump/CMakeLists.txt delete mode 100644 test/test_Pump/test_Pump.cpp delete mode 100644 test/test_lmdb/CMakeLists.txt delete mode 100644 test/test_lmdb/ProductData.h delete mode 100644 test/test_lmdb/data.mdb delete mode 100644 test/test_lmdb/lock.mdb delete mode 100644 test/test_lmdb/sample-mdb.c delete mode 100644 test/test_lmdb/test-lmdb-full.cpp delete mode 100644 test/test_lmdb/test-lmdb.cpp delete mode 100644 test/test_logger/CMakeLists.txt delete mode 100644 test/test_logger/main.cpp delete mode 100644 test/test_sqlite/CMakeLists.txt delete mode 100644 test/test_sqlite/main.cpp delete mode 100644 test/test_wormfile/CMakeLists.txt delete mode 100644 test/test_wormfile/main.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 90f7068..9506e77 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -7,13 +7,7 @@ endif(WIN32) include_directories("${CMAKE_CURRENT_SOURCE_DIR}/..") -add_subdirectory(test_PosixQueue) add_subdirectory(test_unit) -add_subdirectory(test_wormfile) add_subdirectory(test_scandir) -add_subdirectory(test_lmdb) -add_subdirectory(test_sqlite) add_subdirectory(test_mman) add_subdirectory(test_semaphore) -add_subdirectory(test_logger) -add_subdirectory(test_Pump) diff --git a/test/test_PosixQueue/CMakeLists.txt b/test/test_PosixQueue/CMakeLists.txt deleted file mode 100644 index 8c61f3a..0000000 --- a/test/test_PosixQueue/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -# libunistd/test/test_PosixQueue/CMakeList.txt - -add_executable(test_mq_receive mq_receive/main.cpp) -target_link_libraries(test_mq_receive libportable) - -add_executable(test_mq_send mq_send/main.cpp) -target_link_libraries(test_mq_send libportable) \ No newline at end of file diff --git a/test/test_PosixQueue/mq_receive/main.cpp b/test/test_PosixQueue/mq_receive/main.cpp deleted file mode 100644 index 4298b13..0000000 --- a/test/test_PosixQueue/mq_receive/main.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// mq_receive.cpp -// Copyright 2016 Robin.Rowe@Cinepaint.org -// License open source MIT - -#include -#include -#include -#include -#include -#include -#include -#include -using namespace std; - -const char* QUEUE_NAME="/test_queue"; -const unsigned MAX_SIZE=1024; -const char* MSG_STOP="quit"; - -int main() -{ char buffer[MAX_SIZE + 1]; - bool isGo=true; - mq_attr attr; - attr.mq_flags = 0; - attr.mq_maxmsg = 10; - attr.mq_msgsize = MAX_SIZE; - attr.mq_curmsgs = 0; - cout << "opening message queue "<< QUEUE_NAME << endl; - mqd_t mq = mq_open(QUEUE_NAME, O_CREAT | O_RDONLY, 0644, &attr); - if(mq<0) - { perror("mq_open"); - return 1; - } - while(isGo) - { ssize_t bytes_read = mq_receive(mq, buffer, MAX_SIZE, NULL); - if(bytes_read < 0) - { perror("mq_read"); - return 2; - } - buffer[bytes_read-1] = 0; - cout << "received: " << buffer << endl; - if (!strcmp(buffer, MSG_STOP)) - { isGo=false; - } } - mq_close(mq); - mq_unlink(QUEUE_NAME); - return 0; -} \ No newline at end of file diff --git a/test/test_PosixQueue/mq_send/main.cpp b/test/test_PosixQueue/mq_send/main.cpp deleted file mode 100644 index 496d18c..0000000 --- a/test/test_PosixQueue/mq_send/main.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// mq_send.cpp -// Copyright 2016 Robin.Rowe@Cinepaint.org -// License open source MIT - -#include -#include -#include -#include -#include -#include -#include -using namespace std; - -const char* QUEUE_NAME="/test_queue"; -const unsigned MAX_SIZE=1024; -const char* MSG_STOP="quit"; - -int main() -{ char buffer[MAX_SIZE]; - mqd_t mq = mq_open(QUEUE_NAME, O_WRONLY, 0644); - if(mq<0) - { perror("mq_open"); - return 1; - } - buffer[0]=0; - cout << "Send to server (enter \"quit\" to stop it):\n"; - while(strncmp(buffer, MSG_STOP, strlen(MSG_STOP))) - { cout<< "> "; - cin.getline(buffer,MAX_SIZE); - int ok = mq_send(mq, buffer, strlen(buffer)+1, 0); - if(ok<0) - { perror("mq_send"); - return 2; - } } - mq_close(mq); - return 0; -} \ No newline at end of file diff --git a/test/test_Pump/CMakeLists.txt b/test/test_Pump/CMakeLists.txt deleted file mode 100644 index 5507d27..0000000 --- a/test/test_Pump/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -# libunistd/test/Pump/CMakeList.txt - -add_executable(test_Pump test_Pump.cpp) -target_link_libraries(test_Pump libportable) \ No newline at end of file diff --git a/test/test_Pump/test_Pump.cpp b/test/test_Pump/test_Pump.cpp deleted file mode 100644 index 129b9ac..0000000 --- a/test/test_Pump/test_Pump.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// test_Pump.cpp -// Created by Robin Rowe 2019-10-18 -// License MIT open source - -#include -#include -using namespace std; - -int main(int argc,char* argv[]) -{ cout << "Testing Pump" << endl; - portable::Pump pump("TestPump"); - pump.StartJoin(); - cout << "Shutdown main" << endl; - return 0; -} - -/* -Testing Pump -Trace: Pump hooked SIGINT (portable::Pump::Pump@25) -SIGINT interrupt -Shutdown TestPump -Shutdown main -*/ \ No newline at end of file diff --git a/test/test_lmdb/CMakeLists.txt b/test/test_lmdb/CMakeLists.txt deleted file mode 100644 index aa8c073..0000000 --- a/test/test_lmdb/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# lmdb/CMakeLists.txt - -set(NAME test_lmdb) -set(INCDIR - ${CMAKE_CURRENT_SOURCE_DIR}/../../lmdb/liblmdb - ${CMAKE_CURRENT_SOURCE_DIR}/../.. -) -#message("INCDIR = " ${INCDIR}) - -add_executable(test_lmdb_c sample-mdb.c) -target_include_directories(test_lmdb_c PUBLIC ${INCDIR}) -target_link_libraries(test_lmdb_c liblmdb) - -add_executable(${NAME} test-lmdb.cpp ProductData.h) -target_include_directories(${NAME} PUBLIC ${INCDIR}) -target_link_libraries(${NAME} liblmdb) \ No newline at end of file diff --git a/test/test_lmdb/ProductData.h b/test/test_lmdb/ProductData.h deleted file mode 100644 index 22ecd81..0000000 --- a/test/test_lmdb/ProductData.h +++ /dev/null @@ -1,51 +0,0 @@ -// ProductData.h -// Created by Robin Rowe on 12/21/2015 -// Copyright (c) 2015 Robin.Rowe@CinePaint.org -// OpenLDAP Public License - -#ifndef ProductData_h -#define ProductData_h - -#include -#include -#include -#include -using namespace std; - -struct ProductData -: public lmdb::Item -{ int id; - std::string product; - std::string description; - std::string buffer; - ProductData() - : id(0) - {} - virtual void Set() override - { key.ToMval(&id,sizeof(id)); - buffer = product; - buffer += delimiter; - buffer += description; - buffer += delimiter; - value.ToMval(buffer); - } - virtual bool Retrieve() override - { key.ResetOffset(); - if(!key.FromMval(&id,sizeof(id))) - { return false; - } - value.ResetOffset(); - if(!value.FromMval(product,delimiter)) - { return false; - } - if(!value.FromMval(description,delimiter)) - { return false; - } - return true; - } - virtual std::ostream& Print(std::ostream& os) const override - { return os << id << ", " << product << ", " << description; - } -}; - //Buffer((void*) name.c_str(),name.size()+1); -#endif \ No newline at end of file diff --git a/test/test_lmdb/data.mdb b/test/test_lmdb/data.mdb deleted file mode 100644 index af86a974315782949f18a7d0de8a6e07ca2aaa4f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1048576 zcmeI*v2lYi6aY}gaS}RmxfEF;3uJCeS2>T7D(4O25dw&B9W*pDF8pXDfh4#`_5CHB zQXI`#`91!9Kg6lAe9f)CXi~XSYWebR8uK!hxhTC#ZGL4rZa*8ZL4W`O0t5&UAV7cs z0RjXF)DS3fd7b$GdG=6c_EO6oqWv`Wk8zK)@frjO5FkK+009C72oNAZfItm_$iJtw zOK<7ip4%F;nu7oV0t5&UAV7cs0RjXF5V)m4USGdYpZ!C0Un!M*yZHZ>@5Q|d5FkK+ z009C72oNAZfIv-wW&B_E+Yj;osXfX6*W@-A0RjXF5FkK+009C72oTsrAb-8D=~wsX zBlg`#JNDmO|G&xWa1#Oq2oNAZfB*pk1PBlyu!+Dj{~zDo8{+@>bm;T{2P*(Jc@u6z zfB*pk1PBlyK!5-N0tD6tKE^K1W&eKU^J6`K?CW34|Cj&k8{+@2{b@V#|2n@O1PBly zK!5-N0t5&UAVA=%0ulE|oF8$2. - */ -#include -#include - -int main(int argc,char * argv[]) -{ - int rc; - MDB_env *env; - MDB_dbi dbi; - MDB_val key, data; - MDB_txn *txn; - MDB_cursor *cursor; - char sval[32]; - - rc = mdb_env_create(&env); - rc = mdb_env_open(env, "/Code/github/libunistd/build/test", 0, 0664); - rc = mdb_txn_begin(env, NULL, 0, &txn); - rc = mdb_open(txn, NULL, 0, &dbi); -#if 0 - mdb_txn_abort(txn); - rc = mdb_txn_begin(env, NULL, 0, &txn); -#endif - key.mv_size = sizeof(int); - int k=32; - key.mv_data = &k;//sval; - int d=100; - data.mv_size = sizeof(int);//sizeof(sval); - data.mv_data = &d;//sval; -#pragma warning(disable:4996) - sprintf(sval, "%03x %d foo bar", 32, 3141592); - rc = mdb_put(txn, dbi, &key, &data, 0); - rc = mdb_txn_commit(txn); -#define HIDE_DOUBLE_FREE_BUG -#ifndef HIDE_DOUBLE_FREE_BUG - rc = mdb_txn_commit(txn); -/* -mdb.c:3470 rc = MDB_BAD_TXN; -mdb.c:3471 goto fail; // Jumps away here due to double-commit... -... -mdb.c:5076 free(env->me_dirty_list); -mdb.c:5076 free(env->me_txn0); // Double-free crashes here... -*/ -#endif - if (rc) { - fprintf(stderr, "mdb_txn_commit: (%d) %s\n", rc, mdb_strerror(rc)); - goto leave; - } - rc = mdb_txn_begin(env, NULL, MDB_RDONLY, &txn); - rc = mdb_cursor_open(txn, dbi, &cursor); - while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) { - int* k=(int*)key.mv_data; - int* d=(int*)data.mv_data; - printf("key: '%d', data: '%d'\n",*k,*d); -/* -#if 1 - printf("key: '%s', data: '%s'\n", - (char *) key.mv_data, - (char *) data.mv_data); -#else - printf("key: %p '%.*s', data: %p '%.*s'\n", - key.mv_data, (int) key.mv_size, (char *) key.mv_data, - data.mv_data, (int) data.mv_size, (char *) data.mv_data); -#endif -*/ - } - // key: 00865FDC '020 ', data: 00865FE0 '020 3141592 foo bar' - // key: '020 020 3141592 foo bar', data: '020 3141592 foo bar' - mdb_cursor_close(cursor); - mdb_txn_abort(txn); -leave: - mdb_close(env, dbi); - mdb_env_close(env); - return 0; -} \ No newline at end of file diff --git a/test/test_lmdb/test-lmdb-full.cpp b/test/test_lmdb/test-lmdb-full.cpp deleted file mode 100644 index 04e9e8a..0000000 --- a/test/test_lmdb/test-lmdb-full.cpp +++ /dev/null @@ -1,179 +0,0 @@ -// test-lmdb.cpp -// Created by Robin Rowe on 12/21/2015 -// Copyright (c) 2015 Robin.Rowe@CinePaint.org -// OpenLDAP Public License - -#include - -#include "lmdb.h" -#include "memory.h" - -class Lmdb -{ MDB_env *env; - MDB_dbi dbi; - MDB_txn *txn; - int rc; -public: - ~Lmdb() - { mdb_txn_abort(txn); - mdb_close(env, dbi); - mdb_env_close(env); - } - Lmdb() - { rc = mdb_env_create(&env); - } - bool BeginWrite() - { rc = mdb_txn_begin(env,NULL,0,&txn); - if(rc) - { return false; - } - return true; - } - bool BeginRead() - { rc = mdb_txn_begin(env, NULL, MDB_RDONLY, &txn); - if(rc) - { return false; - } - return true; - } - bool Open(const char* path,const char* dbname) - { if(rc) - { return false; - } - rc = mdb_env_open(env,path,0,0664); - if(rc) - { return false; - } - if(!BeginWrite()) - { return false; - } - rc = mdb_open(txn, dbname, 0, &dbi); - Commit(); - return 0==rc; - } - bool operator!() const - { return 0!=rc; - } - bool Commit() - { rc = mdb_txn_commit(txn); - return 0==rc; - } - const char* toString() const - { return mdb_strerror(rc); - } - MDB_dbi GetDbi() - { return dbi; - } - MDB_txn* GetTxn() - { return txn; - } -}; - -class Cursor -{ MDB_cursor *cursor; - Lmdb& lmdb; - int rc; -public: - ~Cursor() - { mdb_cursor_close(cursor); - } - Cursor(Lmdb& lmdb) - : lmdb(lmdb) - { rc = mdb_cursor_open(lmdb.GetTxn(),lmdb.GetDbi(),&cursor); - } - bool operator!() const - { return 0!=rc; - } - MDB_cursor* GetCursor() - { return cursor; - } - bool DropDatum(bool isDelAllKeys=false) - { const unsigned flags = isDelAllKeys ? 0:MDB_NODUPDATA; - rc = mdb_cursor_del(cursor,flags); - return 0==rc; - } -}; - -template -class Datum -{ MDB_val key; - MDB_val data; - K k; - V v; - int rc; -public: - Datum(K k,V v) - { Set(k,v); - } - void Set(K k,V v) - { memcpy(&this->k,&k,sizeof(K)); - memcpy(&this->v,&v,sizeof(V)); - key.mv_size = sizeof(K); - key.mv_data = &this->k; - data.mv_size = sizeof(V); - data.mv_data = &this->v; - } - bool Put(Lmdb& lmdb) - { rc = mdb_put(lmdb.GetTxn(), lmdb.GetDbi(), &key, &data, 0); - return 0==rc; - } - bool Get(Cursor& cursor) - { rc = mdb_cursor_get(cursor.GetCursor(), &key, &data, MDB_NEXT); - if(0!=rc) - { return false; - } - memcpy(&k,key.mv_data,sizeof(K)); - memcpy(&v,data.mv_data,sizeof(V)); - return true; - } - K& Key() - { return k; - } - V& Value() - { return v; - } -}; - -int main(int argc,char * argv[]) -{ Lmdb db; - if(!db.Open("/Code/trasec/test",NULL)) - { return 1; - } - if(!db.BeginWrite()) - { return 2; - } - Datum datum(41,14000); - if(!datum.Put(db)) - { return 3; - } - if(!db.Commit()) - { fprintf(stderr, "mdb_txn_commit: %s\n", db.toString()); - return 4; - } - if(!db.BeginWrite()) - { return 5; - } - Cursor cursor(db); - if(!cursor) - { return 6; - } - while(datum.Get(cursor)) - { const int& k=datum.Key(); - const int& v=datum.Value(); - printf("key: '%d', data: '%d'\n",k,v); - if(32==k) - { cursor.DropDatum(); - } - } - db.Commit(); - return 0; -} - -/* - // key: 00865FDC '020 ', data: 00865FE0 '020 3141592 foo bar' - // key: '020 020 3141592 foo bar', data: '020 3141592 foo bar' -key: '32', data: '100' -key: '41', data: '14000' -key: '540029488', data: '540029488' -*/ - diff --git a/test/test_lmdb/test-lmdb.cpp b/test/test_lmdb/test-lmdb.cpp deleted file mode 100644 index 6e43b01..0000000 --- a/test/test_lmdb/test-lmdb.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// test-lmdb.cpp -// Created by Robin Rowe on 12/21/2015 -// Copyright (c) 2015 Robin.Rowe@CinePaint.org -// OpenLDAP Public License - -#include -#include -#include -#include -#include -#include -#include -#include "ProductData.h" -using namespace std; - -enum STATUS -{ ok, - open_failed, - lock_failed, - write_failed, - cursor_failed -}; - -int main(int argc,char * argv[]) -{ lmdb::LightningDb db; -// const char* filename = "/Code/github/libunistd/build/test/lmdb/data.mdb"; - const char* filename = "./test-lmdb"; -#if 1 - db.Drop(filename); -#endif - if(!db.Open(filename,MDB_CREATE)) - { return open_failed; - } - lmdb::Transaction tr(db); - if(!tr) - { return lock_failed; - } - { - ProductData data; - data.id = 41; - data.product = "Widget"; - data.description = "Generic"; - cout << "Put: " << data << endl; - if(!tr.Put(data)) - { return write_failed; - } - data.id = 32; - data.product = "Gadget"; - data.description = "Special"; - cout << "Put: " << data << endl; - if(!tr.Put(data)) - { return write_failed; - } - tr.Commit(); - } - { lmdb::Cursor cursor(db,tr,0); - if(!cursor) - { return cursor_failed; - } - ProductData data; - bool ok = cursor.GetFirst(data); - while(ok) - { cout << "Cursor: " << data << endl; - if(32==data.id) - { cursor.Drop(); - cout << "Dropped id #" << 32 << endl; - } - ok = cursor.Get(data); - } } - puts("Done"); - db.Close(); - return 0; -} - -/* Output: - - LMDB: ok - LMDB: drop db failed - LMDB: Transaction ok - LMDB: open - LMDB: Transaction ok - Put: 41, Widget, Generic - LMDB: put ok - Put: 32, Gadget, Special - LMDB: put ok - LMDB: Transaction ok - LMDB: Cursor ok - LMDB: Cursor get ok - Cursor: 32, Gadget, Special - LMDB: Cursor drop ok - Dropped id #32 - LMDB: Cursor get ok - Cursor: 41, Widget, Generic - LMDB: Cursor get not found - Done - -*/ - diff --git a/test/test_logger/CMakeLists.txt b/test/test_logger/CMakeLists.txt deleted file mode 100644 index 8e293e8..0000000 --- a/test/test_logger/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -# libunistd/test/test_logger/CMakeList.txt - -add_definitions(-DTRACE_MSG_FUNCTIONS) - -add_executable(test_logger main.cpp) - diff --git a/test/test_logger/main.cpp b/test/test_logger/main.cpp deleted file mode 100644 index bd17dda..0000000 --- a/test/test_logger/main.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// test/test_logger/main.cpp: -// robin.rowe@cinepaint.org 2019/10/16 - -#include -#include -using namespace std; -using namespace portable; - -#define P(name) cout << "** " << #name << " ** " - -int main() -{ -#ifdef OLD_SYSLOG - P(SysLogMsg); - SysLogMsg("msg",__FUNCTION__); -#ifdef TEST_DEBUG_BREAK - P(SysLogError); - SysLogError("msg","function"); -#endif - P(LogMsg); - LogMsg("msg"); - P(LogError); - LogError("msg"); - P(SYSLOG); - SYSLOG("msg"); -#ifdef TEST_DEBUG_BREAK - P(SYSERR); - SYSERR("msg"); -#endif - P(SystemLog); - SystemLog(__FILE__,__LINE__,"msg"); - P(StatusMsg); - StatusMsg("msg"); -#endif - P(tty_msg); - tty_msg("tag","msg"); - P(status_msg); - status_msg("msg"); - P(warning_msg); - warning_msg("msg"); - P(trace_msg); - trace_msg("msg"); - P(error_msg); - error_msg("msg"); - P(return_msg); - enum { RETURN_NAME }; - return_msg(RETURN_NAME); - return 0; -} - diff --git a/test/test_sqlite/CMakeLists.txt b/test/test_sqlite/CMakeLists.txt deleted file mode 100644 index 294872a..0000000 --- a/test/test_sqlite/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -# libunistd/test/test_sqlite/CMakeList.txt - -include_directories("..") -add_executable(test_sqlite main.cpp) -link_directories(${LIBSQLITE_LIB_DIRS}/sqlite) -target_link_libraries(test_sqlite libsqlite) diff --git a/test/test_sqlite/main.cpp b/test/test_sqlite/main.cpp deleted file mode 100644 index ccb8421..0000000 --- a/test/test_sqlite/main.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// test/sqlite/main.h -// Robin.Rowe@Cinepaint.org -// 2018/9/19 - -#include -#include -#include - -enum -{ SUCCESS, - BAD_OPEN, - BAD_EXEC, - BAD_EXEC2, - BAD_EXEC3, - BAD_BIND, - BAD_BIND2, - BAD_STATEMENT -}; - -int ExitMsg(const char* status,const char* msg,int code) -{ printf("%s: %s\n",status,msg); - return code; -} - -#define exit_return(status,x) return ExitMsg(status,#x,x) - -int main(int argc, char* argv[]) -{ sqlite::Db db; - const char* dbName = "test.db"; - db.DropFile(dbName); - if(!db.Open(dbName)) - { exit_return(dbName,BAD_OPEN); - } - fprintf(stderr, "Opened database successfully\n"); - const char* sql = "CREATE TABLE COMPANY(" - "ID INT PRIMARY KEY NOT NULL," - "NAME TEXT NOT NULL," - "AGE INT NOT NULL," - "ADDRESS CHAR(50)," - "SALARY REAL );"; - if(!db.Exec(sql,sqlite::Db::PrintCb,&db)) - { exit_return(db.GetErrorMsg(),BAD_EXEC); - } - else - { puts("Table created successfully"); - } - sql = "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) " - "VALUES (1, 'Paul', 32, 'California', 20000.00 ); " - "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) " - "VALUES (2, 'Allen', 25, 'Texas', 15000.00 ); " - "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)" - "VALUES (3, 'Teddy', 23, 'Norway', 20000.00 );" - "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)" - "VALUES (4, 'Mark', 25, 'Rich-Mond ', 65000.00 );"; - if(!db.Exec(sql,sqlite::Db::PrintCb,&db)) - { exit_return(db.GetErrorMsg(),BAD_EXEC2); - } - else - { puts("Table inserted successfully"); - } - sql = "SELECT * from COMPANY"; - if(!db.Exec(sql,sqlite::Db::PrintCb,&db)) - { exit_return(db.GetErrorMsg(),BAD_EXEC3); - } - else - { puts("Table queried successfully"); - } - const char* query = "SELECT id, name FROM COMPANY WHERE id = ?1;"; - sqlite::Statement s(db,query); - if(!s) - { exit_return(db.GetErrorMsg(),BAD_STATEMENT); - } - if(!s.Bind(2)) - { exit_return(db.GetErrorMsg(),BAD_BIND); - } - while(s.Step()) - { int id = 0; - const char* name = 0; - s.Get(id,0); - s.Get(name,1); - printf("bind = %i,%s\n",id,name); - } - exit_return("Done",SUCCESS); -} -//$g++ test.c -l sqlite3 - diff --git a/test/test_wormfile/CMakeLists.txt b/test/test_wormfile/CMakeLists.txt deleted file mode 100644 index 6115d9a..0000000 --- a/test/test_wormfile/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -# libunistd/test/WormFile/CMakeList.txt - -add_executable(test_WormFile main.cpp) -target_link_libraries(test_WormFile libportable) \ No newline at end of file diff --git a/test/test_wormfile/main.cpp b/test/test_wormfile/main.cpp deleted file mode 100644 index b710b27..0000000 --- a/test/test_wormfile/main.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// WormFile test main -// Robin Rowe 2017/3/21 - -#include -#include -#include -using namespace std; - -int main() -{ portable::WormFile wormFile; - const char* filename = "test.wrm"; - if(!wormFile.Open(filename)) - { cout << "Can't open "< buffer(length); - if(!wormFile.Read(&buffer[0],length)) - { cout << "Can't read "<< filename << endl; - return 5; - } - if(strcmp(data,&buffer[0])) - { cout <<"Blob data mismatch" << endl; - return 6; - } - cout << "SUCCESS!" << endl; - return 0; -}