├── .cmakelintrc ├── monolibtic.cpp ├── ffi-cdecl ├── lpeg_cdecl.c ├── koreader-lfs_cdecl.c ├── lua-rapidjson_cdecl.c ├── openlipclua_cdecl.c ├── luasocket_cdecl.c ├── koreader-cre_cdecl.c ├── koreader-djvu_cdecl.c ├── koreader-nnsvg_cdecl.c ├── koreader-xtext_cdecl.c ├── koreader-input_cdecl.c ├── android-luajit-launcher_cdecl.c ├── luasec_cdecl.c ├── zlib_decl.c ├── include │ └── README ├── ion_kobo_decl.c ├── utf8proc_decl.c ├── turbojpeg_decl.c ├── crypto_decl.c ├── zstd_decl.c ├── linux_fb_decl.c ├── rtc_cdecl.c ├── einkfb_decl.c ├── mxcfb_sony_decl.c ├── tffi_wrap_cdecl.c ├── libwebp_decl.c ├── giflib_decl.c ├── mxcfb_cervantes_decl.c ├── mxcfb_remarkable_decl.c ├── zeromq_cdecl.c ├── inotify_decl.c ├── lodepng_decl.c ├── koptcontext_cdecl.c ├── harfbuzz_cdecl.c ├── sqlite3_cdecl.c ├── leptonica_cdecl.c ├── blitbuffer_cdecl.c └── sunxi_kobo_decl.c ├── origin.ldflags ├── utils ├── bincheck │ ├── stub.h │ ├── libinkview.c │ └── liblipc.c ├── fake_tty.py └── binfind.py ├── spec └── unit │ ├── data │ ├── Alice.pdf │ ├── Paper.pdf │ ├── sample.jpg │ ├── simple.pdf │ ├── testfont.ttf │ ├── 2col.jbig2.pdf │ ├── simple-out.pdf │ ├── encrypted-aes.zip │ ├── testdocument.odt │ ├── testdocument.pdf │ ├── encrypted-none.zip │ ├── encrypted-plain.zip │ ├── simple-out-annotated.pdf │ ├── transparency_various_bg.png │ ├── simple-out-annotation-deleted.pdf │ └── simple.svg │ ├── crypto_spec.lua │ ├── freetype_spec.lua │ ├── nnsvg_spec.lua │ ├── framebuffer_spec.lua │ ├── md5_spec.lua │ ├── ffi_wrapper.lua │ ├── font_spec.lua │ ├── qrencode_spec.lua │ └── png_spec.lua ├── .gitmodules ├── .luarc.json ├── thirdparty ├── spec │ ├── cluacov │ │ └── CMakeLists.txt │ ├── luacov │ │ └── CMakeLists.txt │ ├── say │ │ └── CMakeLists.txt │ ├── busted │ │ └── CMakeLists.txt │ ├── penlight │ │ └── CMakeLists.txt │ ├── luafilesystem │ │ └── CMakeLists.txt │ ├── luassert │ │ └── CMakeLists.txt │ ├── luasystem │ │ └── CMakeLists.txt │ ├── lua-term │ │ └── CMakeLists.txt │ ├── mediator_lua │ │ └── CMakeLists.txt │ └── lua_cliargs │ │ └── CMakeLists.txt ├── lunasvg │ ├── cmake_tweaks.patch │ ├── xtended │ │ ├── CMakeLists.txt │ │ ├── xtextelement.h │ │ ├── ximageelement.h │ │ └── xtspanelement.h │ └── CMakeLists.txt ├── md4c │ ├── cmake_tweaks.patch │ └── CMakeLists.txt ├── popen-noshell │ ├── overlay │ │ └── CMakeLists.txt │ ├── kindle_legacy.patch │ └── CMakeLists.txt ├── koreader-lfs │ ├── lfs-visibility.patch │ ├── overlay │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── czmq │ ├── android.patch │ ├── fix_prefix_handling.patch │ ├── cmake_tweaks.patch │ └── CMakeLists.txt ├── libressl │ ├── android.patch │ ├── cmake_tweaks.patch │ └── CMakeLists.txt ├── lua-ljsqlite3 │ ├── notes.txt │ ├── __meta.lua │ ├── CMakeLists.txt │ └── LICENSE ├── dkjson │ └── CMakeLists.txt ├── luasocket │ ├── luajit-compat.patch │ ├── enforce-cloexec.patch │ └── overlay │ │ └── CMakeLists.txt ├── luasec │ ├── visibility.patch │ ├── overlay │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── lua-Spore │ └── CMakeLists.txt ├── djvulibre │ ├── android.patch │ ├── no_references_to_install_dir.patch │ ├── djvulibre-no-locale-mangling.patch │ └── CMakeLists.txt ├── lodepng │ ├── overlay │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── freetype2 │ ├── ftcalc_gcc12_arm_neon_fix.patch │ └── CMakeLists.txt ├── luajson │ └── CMakeLists.txt ├── tesseract │ ├── no_debug_fonts.patch │ └── CMakeLists.txt ├── libarchive │ ├── android.patch │ ├── ignore_locale_and_use_utf8.patch │ └── CMakeLists.txt ├── lua-htmlparser │ └── CMakeLists.txt ├── leptonica │ ├── cmake_tweaks.patch │ └── fmemopen-arm-compat-symbol.patch ├── libzmq │ ├── disable_eventfd.patch │ ├── cmake_tweaks.patch │ └── CMakeLists.txt ├── luajit │ ├── koreader-luajit-verbose-build.patch │ └── koreader-luajit-enable-table_pack.patch ├── curl │ ├── clock_gettime_needs_rt.patch │ ├── fetch-ca-bundle.sh │ ├── no_glibc_2.6_or_above_symbols.patch │ └── use_-pthread.patch ├── dropbear │ ├── nochdir-hack.patch │ ├── dbscp-path.patch │ ├── localoptions.h.cmake │ ├── fix__GNU_SOURCE_warnings.patch │ └── reduce_build_verbosity.patch ├── minizip │ ├── overlay │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── turbo │ ├── overlay │ │ └── CMakeLists.txt │ ├── d7a8a247a4a2689b0f207162eb804141c87c4899.patch │ └── CMakeLists.txt ├── nanosvg │ └── CMakeLists.txt ├── xxhash │ ├── overlay │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── sdl2 │ ├── cmake_tweaks.patch │ └── CMakeLists.txt ├── mupdf │ ├── honor_cflags.patch │ ├── no_arm_asm.patch │ ├── relink_on_xlibs_change.patch │ └── free-html-doc-fonts-on-close.patch ├── lj-wpaclient │ └── CMakeLists.txt ├── libjpeg-turbo │ ├── no_cmake_rpath_shenanigans.patch │ └── CMakeLists.txt ├── proxy-libintl │ └── CMakeLists.txt ├── giflib │ ├── overlay │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── sdcv │ ├── ignore_hidden.patch │ ├── compat_with_newer_glib.patch │ └── sdcv-no-unknown-dict-warning.patch ├── srell │ ├── readme_ja.txt │ ├── readme_en.txt │ └── license.txt ├── lpeg │ ├── overlay │ │ └── CMakeLists.txt │ ├── CMakeLists.txt │ └── luajit.patch ├── cpu_features │ └── CMakeLists.txt ├── ffi-cdecl │ └── ffi-cdecl.patch ├── utf8proc │ └── CMakeLists.txt ├── brotli │ └── CMakeLists.txt ├── sqlite │ └── CMakeLists.txt ├── android-luajit-launcher │ └── CMakeLists.txt ├── openlipclua │ └── CMakeLists.txt ├── kobo-usbms │ └── CMakeLists.txt ├── harfbuzz │ ├── no-subset.patch │ └── android.patch ├── fribidi │ └── CMakeLists.txt ├── lua-rapidjson │ ├── CMakeLists.txt │ └── cmake_tweaks.patch ├── libiconv │ └── CMakeLists.txt ├── libunibreak │ └── CMakeLists.txt ├── zstd │ ├── CMakeLists.txt │ └── no_qsort_r.patch ├── libpng │ └── CMakeLists.txt ├── xz │ └── cmake_tweaks.patch ├── libk2pdfopt │ └── CMakeLists.txt ├── openssh │ └── CMakeLists.txt ├── tar │ └── tar-1.33-remove-o_path-usage.patch ├── libwebp │ ├── cmake_tweaks.patch │ └── CMakeLists.txt ├── luarocks │ └── CMakeLists.txt ├── zlib │ └── CMakeLists.txt ├── zsync2 │ └── CMakeLists.txt └── glib │ ├── CMakeLists.txt │ └── no_glibc_2.6_or_above_symbols.patch ├── .gitignore ├── CMakeLists.txt ├── cmake ├── crengine │ └── CMakeLists.txt └── koreader │ └── CMakeLists.txt ├── nnsvg.h ├── cache-key.base ├── ffi ├── zlib_h.lua ├── utf8proc_h.lua ├── input_SDL2_0.lua ├── posix_types_64b_h.lua ├── posix_types_x64_h.lua ├── __gc.lua ├── MD5.lua ├── posix_types_def_h.lua ├── posix_types_x86_h.lua ├── ion_kobo_h.lua ├── zstd_h.lua ├── crypto_h.lua ├── zlib.lua ├── framebuffer_einkfb.lua ├── drawcontext.lua ├── einkfb_h.lua ├── mxcfb_sony_h.lua ├── fbink_input_h.lua ├── zeromq_h.lua ├── kobolight.lua ├── libwebp_h.lua ├── inotify_h.lua ├── rtc_h.lua ├── framebuffer_dummy.lua └── mxcfb_cervantes_h.lua ├── .luacheckrc ├── xtext.h ├── .ci ├── lint_script.sh ├── helper_shellchecks.sh ├── common.sh ├── test_script.sh └── build_script.sh ├── test-runner ├── busted_config.lua └── busted_helper.lua ├── drawcontext.h ├── koptcontext.h ├── djvu.h ├── input ├── input.h └── inkview-compat.c ├── cre.h ├── ev_replay.py └── libxss-dummy.c /.cmakelintrc: -------------------------------------------------------------------------------- 1 | filter=-linelength 2 | -------------------------------------------------------------------------------- /monolibtic.cpp: -------------------------------------------------------------------------------- 1 | // Nothing to see here… 2 | -------------------------------------------------------------------------------- /ffi-cdecl/lpeg_cdecl.c: -------------------------------------------------------------------------------- 1 | cdecl_func(luaopen_lpeg) 2 | -------------------------------------------------------------------------------- /ffi-cdecl/koreader-lfs_cdecl.c: -------------------------------------------------------------------------------- 1 | cdecl_func(luaopen_lfs) 2 | -------------------------------------------------------------------------------- /ffi-cdecl/lua-rapidjson_cdecl.c: -------------------------------------------------------------------------------- 1 | cdecl_func(luaopen_rapidjson) 2 | -------------------------------------------------------------------------------- /ffi-cdecl/openlipclua_cdecl.c: -------------------------------------------------------------------------------- 1 | cdecl_func(luaopen_libopenlipclua) 2 | -------------------------------------------------------------------------------- /origin.ldflags: -------------------------------------------------------------------------------- 1 | --disable-new-dtags -rpath $ORIGIN -rpath $ORIGIN/libs 2 | -------------------------------------------------------------------------------- /utils/bincheck/stub.h: -------------------------------------------------------------------------------- 1 | #define STUB(FuncName) void FuncName(void) {} 2 | -------------------------------------------------------------------------------- /ffi-cdecl/luasocket_cdecl.c: -------------------------------------------------------------------------------- 1 | cdecl_func(luaopen_mime_mcore) 2 | cdecl_func(luaopen_socket_score) 3 | -------------------------------------------------------------------------------- /spec/unit/data/Alice.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/HEAD/spec/unit/data/Alice.pdf -------------------------------------------------------------------------------- /spec/unit/data/Paper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/HEAD/spec/unit/data/Paper.pdf -------------------------------------------------------------------------------- /spec/unit/data/sample.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/HEAD/spec/unit/data/sample.jpg -------------------------------------------------------------------------------- /spec/unit/data/simple.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/HEAD/spec/unit/data/simple.pdf -------------------------------------------------------------------------------- /ffi-cdecl/koreader-cre_cdecl.c: -------------------------------------------------------------------------------- 1 | #include "cre.h" 2 | #include "ffi-cdecl.h" 3 | 4 | cdecl_func(luaopen_cre) 5 | -------------------------------------------------------------------------------- /spec/unit/data/testfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/HEAD/spec/unit/data/testfont.ttf -------------------------------------------------------------------------------- /ffi-cdecl/koreader-djvu_cdecl.c: -------------------------------------------------------------------------------- 1 | #include "djvu.h" 2 | #include "ffi-cdecl.h" 3 | 4 | cdecl_func(luaopen_djvu) 5 | -------------------------------------------------------------------------------- /ffi-cdecl/koreader-nnsvg_cdecl.c: -------------------------------------------------------------------------------- 1 | #include "nnsvg.h" 2 | #include "ffi-cdecl.h" 3 | 4 | cdecl_func(luaopen_nnsvg) 5 | -------------------------------------------------------------------------------- /ffi-cdecl/koreader-xtext_cdecl.c: -------------------------------------------------------------------------------- 1 | #include "xtext.h" 2 | #include "ffi-cdecl.h" 3 | 4 | cdecl_func(luaopen_xtext) 5 | -------------------------------------------------------------------------------- /spec/unit/data/2col.jbig2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/HEAD/spec/unit/data/2col.jbig2.pdf -------------------------------------------------------------------------------- /spec/unit/data/simple-out.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/HEAD/spec/unit/data/simple-out.pdf -------------------------------------------------------------------------------- /ffi-cdecl/koreader-input_cdecl.c: -------------------------------------------------------------------------------- 1 | #include "input/input.h" 2 | #include "ffi-cdecl.h" 3 | 4 | cdecl_func(luaopen_input) 5 | -------------------------------------------------------------------------------- /spec/unit/data/encrypted-aes.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/HEAD/spec/unit/data/encrypted-aes.zip -------------------------------------------------------------------------------- /spec/unit/data/testdocument.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/HEAD/spec/unit/data/testdocument.odt -------------------------------------------------------------------------------- /spec/unit/data/testdocument.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/HEAD/spec/unit/data/testdocument.pdf -------------------------------------------------------------------------------- /spec/unit/data/encrypted-none.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/HEAD/spec/unit/data/encrypted-none.zip -------------------------------------------------------------------------------- /spec/unit/data/encrypted-plain.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/HEAD/spec/unit/data/encrypted-plain.zip -------------------------------------------------------------------------------- /ffi-cdecl/android-luajit-launcher_cdecl.c: -------------------------------------------------------------------------------- 1 | #include "ffi-cdecl.h" 2 | 3 | cdecl_func(Java_org_koreader_launcher_Assets_extract) 4 | -------------------------------------------------------------------------------- /spec/unit/data/simple-out-annotated.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/HEAD/spec/unit/data/simple-out-annotated.pdf -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "kpvcrlib/crengine"] 2 | path = thirdparty/kpvcrlib/crengine 3 | url = https://github.com/koreader/crengine.git 4 | -------------------------------------------------------------------------------- /spec/unit/data/transparency_various_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/HEAD/spec/unit/data/transparency_various_bg.png -------------------------------------------------------------------------------- /spec/unit/data/simple-out-annotation-deleted.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koreader/koreader-base/HEAD/spec/unit/data/simple-out-annotation-deleted.pdf -------------------------------------------------------------------------------- /.luarc.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", 3 | "runtime.version": "LuaJIT", 4 | } 5 | 6 | -------------------------------------------------------------------------------- /ffi-cdecl/luasec_cdecl.c: -------------------------------------------------------------------------------- 1 | cdecl_func(luaopen_ssl_config) 2 | cdecl_func(luaopen_ssl_context) 3 | cdecl_func(luaopen_ssl_core) 4 | cdecl_func(luaopen_ssl_x509) 5 | -------------------------------------------------------------------------------- /thirdparty/spec/cluacov/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://luarocks.org/manifests/luarocks/cluacov-0.1.4-1.src.rock 3 | 076273d593b0aa95666f1d3238d6549e 4 | ) 5 | -------------------------------------------------------------------------------- /thirdparty/spec/luacov/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://luarocks.org/manifests/hisham/luacov-0.15.0-1.src.rock 3 | 5a3bc7c5b5ee85eb06cc8c4cc5cc3d94 4 | ) 5 | -------------------------------------------------------------------------------- /thirdparty/spec/say/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://luarocks.org/manifests/lunarmodules/say-1.4.1-3.src.rock 3 | 3b776612edf1e659b2a1e95698597e44 4 | ) 5 | -------------------------------------------------------------------------------- /spec/unit/crypto_spec.lua: -------------------------------------------------------------------------------- 1 | describe("crypto smoke test", function() 2 | it("should load ffi/crypto", function() 3 | require("ffi/crypto") 4 | end) 5 | end) 6 | -------------------------------------------------------------------------------- /thirdparty/spec/busted/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://luarocks.org/manifests/lunarmodules/busted-2.2.0-1.src.rock 3 | 85aa90d2d9d0213fcd8528bc489a3519 4 | ) 5 | -------------------------------------------------------------------------------- /thirdparty/spec/penlight/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://luarocks.org/manifests/tieske/penlight-1.14.0-2.src.rock 3 | ab64b4b635e2514db64b4eabfd9d2220 4 | ) 5 | -------------------------------------------------------------------------------- /thirdparty/spec/luafilesystem/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://luarocks.org/manifests/hisham/luafilesystem-1.8.0-1.src.rock 3 | 93bd2cbd66d6fc25ff89920ef9293c6e 4 | ) 5 | -------------------------------------------------------------------------------- /thirdparty/spec/luassert/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://luarocks.org/manifests/lunarmodules/luassert-1.9.0-1.src.rock 3 | 0df52010a5a5f728da0b9b7615a82da6 4 | ) 5 | -------------------------------------------------------------------------------- /thirdparty/spec/luasystem/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://luarocks.org/manifests/lunarmodules/luasystem-0.6.3-1.src.rock 3 | 79a7639b9a2ede81a20e9da77065b4e6 4 | ) 5 | -------------------------------------------------------------------------------- /ffi-cdecl/zlib_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ffi-cdecl.h" 4 | 5 | cdecl_func(compressBound) 6 | cdecl_func(compress2) 7 | cdecl_func(crc32) 8 | cdecl_func(uncompress) 9 | 10 | -------------------------------------------------------------------------------- /thirdparty/spec/lua-term/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://github.com/hoelzro/lua-term/archive/0.08.tar.gz 3 | 672b60c1e856129891fe29e23632c032 4 | ROCKSPEC lua-term-0.8-1.rockspec 5 | ) 6 | -------------------------------------------------------------------------------- /thirdparty/spec/mediator_lua/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://github.com/Olivine-Labs/mediator_lua/archive/v1.1.2-0.tar.gz 3 | 3ef01fc6ced99f6e4c2a229e91c459bf 4 | ROCKSPEC mediator_lua-1.1.2-0.rockspec 5 | ) 6 | -------------------------------------------------------------------------------- /thirdparty/spec/lua_cliargs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | spec_rock( 2 | https://github.com/lunarmodules/lua_cliargs/archive/refs/tags/v3.0.2.tar.gz 3 | a5d712064c5c08beb69d816e1a7b8378 4 | ROCKSPEC rockspecs/lua_cliargs-3.0.2-1.rockspec 5 | ) 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_* 2 | ._* 3 | *.gz 4 | *.swp 5 | *.swo 6 | cscope.* 7 | *.orig 8 | tags 9 | 10 | /.cproject 11 | /.project 12 | 13 | /toolchain/android-ndk-r* 14 | /toolchain/android-sdk-linux 15 | /build 16 | 17 | /thirdparty/**/build 18 | -------------------------------------------------------------------------------- /thirdparty/lunasvg/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | --- i/CMakeLists.txt 2 | +++ w/CMakeLists.txt 3 | @@ -1,4 +1,4 @@ 4 | -cmake_minimum_required(VERSION 3.3) 5 | +cmake_minimum_required(VERSION 3.17.5) 6 | 7 | project(lunasvg VERSION 2.3.8 LANGUAGES CXX C) 8 | 9 | -------------------------------------------------------------------------------- /thirdparty/md4c/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | --- i/CMakeLists.txt 2 | +++ w/CMakeLists.txt 3 | @@ -1,5 +1,5 @@ 4 | 5 | -cmake_minimum_required(VERSION 3.5) 6 | +cmake_minimum_required(VERSION 3.17.5) 7 | project(MD4C C) 8 | 9 | set(MD_VERSION_MAJOR 0) 10 | -------------------------------------------------------------------------------- /thirdparty/popen-noshell/overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(popen-noshell LANGUAGES C) 3 | 4 | add_library(popen_noshell STATIC popen_noshell.c) 5 | 6 | install(TARGETS popen_noshell) 7 | install(FILES popen_noshell.h TYPE INCLUDE) 8 | -------------------------------------------------------------------------------- /utils/bincheck/libinkview.c: -------------------------------------------------------------------------------- 1 | #include "stub.h" 2 | STUB(ClearTimer) 3 | STUB(GetCurrentTask) 4 | STUB(GetTouchInfo) 5 | STUB(InkViewMain) 6 | STUB(LeaveInkViewMain) 7 | STUB(SendEventTo) 8 | STUB(SetHardTimer) 9 | STUB(SetPanelType) 10 | STUB(SetWeakTimer) 11 | STUB(iv_sleepmode) 12 | -------------------------------------------------------------------------------- /thirdparty/koreader-lfs/lfs-visibility.patch: -------------------------------------------------------------------------------- 1 | --- a/src/lfs.h 2 | +++ b/src/lfs.h 3 | @@ -24,7 +24,7 @@ 4 | #define fileno(f) (_fileno(f)) 5 | #endif 6 | #else 7 | -#define LFS_EXPORT 8 | +#define LFS_EXPORT __attribute__((visibility("default"))) 9 | #endif 10 | 11 | #ifdef __cplusplus 12 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(koreader LANGUAGES C CXX) 3 | 4 | include(${CMAKE_KOVARS}) 5 | include(koreader_targets) 6 | 7 | foreach(NAME IN LISTS KOREADER_TARGETS) 8 | setup_target(${NAME}) 9 | endforeach() 10 | 11 | # vim: foldmethod=marker foldlevel=0 12 | -------------------------------------------------------------------------------- /cmake/crengine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_ARGS -DCMAKE_KOVARS=${CMAKE_KOVARS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) 2 | 3 | list(APPEND BUILD_CMD COMMAND ninja) 4 | 5 | external_project( 6 | BUILD_ALWAYS 7 | CMAKE_ARGS ${CMAKE_ARGS} 8 | BUILD_COMMAND ${BUILD_CMD} 9 | ) 10 | -------------------------------------------------------------------------------- /ffi-cdecl/include/README: -------------------------------------------------------------------------------- 1 | The include file "einkfb.h" is distributed with Amazons Linux kernel sources 2 | for the Kindle. It has no further copyright notice, so it's assumed to be 3 | released under the GPLv2 originally. Under the "any later version" clause, it 4 | should be OK to include it in this GPLv3 application. 5 | 6 | -------------------------------------------------------------------------------- /utils/fake_tty.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os, pty, sys 4 | 5 | os.environ['TERM'] = 'xterm-256color' 6 | status = pty.spawn(sys.argv[1:]) 7 | if os.WIFEXITED(status): 8 | exit(os.WEXITSTATUS(status)) 9 | if os.WIFSIGNALED(status): 10 | exit(-os.WTERMSIG(status)) 11 | raise ValueError(status) 12 | -------------------------------------------------------------------------------- /thirdparty/czmq/android.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -89,6 +89,7 @@ 4 | if(HAVE_CLOCK_GETTIME) 5 | list(APPEND MORE_LIBRARIES -lrt) 6 | endif() 7 | +list(APPEND MORE_LIBRARIES -llog) 8 | 9 | ######################################################################## 10 | # ZMQ dependency 11 | -------------------------------------------------------------------------------- /thirdparty/libressl/android.patch: -------------------------------------------------------------------------------- 1 | --- i/CMakeLists.txt 2 | +++ w/CMakeLists.txt 3 | @@ -98,7 +98,6 @@ 4 | add_definitions(-D_BSD_SOURCE) 5 | add_definitions(-D_POSIX_SOURCE) 6 | add_definitions(-D_GNU_SOURCE) 7 | - set(PLATFORM_LIBS ${PLATFORM_LIBS} pthread) 8 | endif() 9 | 10 | if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") 11 | -------------------------------------------------------------------------------- /thirdparty/lua-ljsqlite3/notes.txt: -------------------------------------------------------------------------------- 1 | lua-ljsqlite3 is copied from upstream commit: d742002 2 | A few patches from forks have been merged: 3 | * https://github.com/Codezerker/lua-ljsqlite3/commit/4efb927a6514039ec657ce977154b6ea3596f2ce 4 | * https://github.com/mnemnion/lua-ljsqlite3/commit/c81b2ed8efec34af24876a5b1489650a3f891e53 5 | 6 | -------------------------------------------------------------------------------- /thirdparty/dkjson/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build in source tree. 2 | set(BINARY_DIR ${SOURCE_DIR}) 3 | 4 | append_install_commands(INSTALL_CMD dkjson.lua DESTINATION common) 5 | 6 | external_project( 7 | DOWNLOAD URL d7754634dcbe6e95f3b6b55fd4ca5ceb 8 | http://dkolf.de/dkjson-lua/dkjson-2.8.tar.gz 9 | INSTALL_COMMAND ${INSTALL_CMD} 10 | ) 11 | -------------------------------------------------------------------------------- /thirdparty/lua-ljsqlite3/__meta.lua: -------------------------------------------------------------------------------- 1 | return { 2 | name = "ljsqlite3", 3 | version = "1.0.2", 4 | require = { 5 | luajit = "2.0", 6 | clib_sqlite3 = "3", 7 | xsys = "1.0", 8 | }, 9 | license = "MIT ", 10 | homepage = "http://scilua.org/ljsqlite3.html", 11 | description = "SQlite3 interface", 12 | } 13 | -------------------------------------------------------------------------------- /thirdparty/lua-ljsqlite3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LJSQLITE3_MOD ${OUTPUT_DIR}/common/lua-ljsqlite3/init.lua) 2 | 3 | add_custom_command( 4 | OUTPUT ${LJSQLITE3_MOD} 5 | MAIN_DEPENDENCY init.lua 6 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/init.lua ${LJSQLITE3_MOD} 7 | ) 8 | 9 | add_custom_target(lua-ljsqlite3 ALL DEPENDS ${LJSQLITE3_MOD}) 10 | -------------------------------------------------------------------------------- /thirdparty/luasocket/luajit-compat.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/compat.h b/src/compat.h 2 | --- a/src/compat.h 3 | +++ b/src/compat.h 4 | @@ -1,3 +1,4 @@ 5 | +#if 0 // not necessary for luajit 6 | #ifndef COMPAT_H 7 | #define COMPAT_H 8 | 9 | @@ -20,3 +21,4 @@ void *luasocket_testudata ( lua_State *L, int arg, const char *tname); 10 | #endif 11 | 12 | #endif 13 | +#endif 14 | -------------------------------------------------------------------------------- /thirdparty/luasec/visibility.patch: -------------------------------------------------------------------------------- 1 | --- a/src/compat.h 2 | +++ b/src/compat.h 3 | @@ -15,7 +15,7 @@ 4 | #if defined(_WIN32) 5 | #define LSEC_API __declspec(dllexport) 6 | #else 7 | -#define LSEC_API extern 8 | +#define LSEC_API extern __attribute__ ((visibility("default"))) 9 | #endif 10 | 11 | //------------------------------------------------------------------------------ 12 | -------------------------------------------------------------------------------- /thirdparty/lua-Spore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build in source tree. 2 | set(BINARY_DIR ${SOURCE_DIR}) 3 | 4 | append_install_commands(INSTALL_CMD src/Spore.lua DESTINATION common) 5 | append_tree_install_commands(INSTALL_CMD src/Spore common/Spore) 6 | 7 | external_project( 8 | DOWNLOAD GIT 0.4.2 9 | https://framagit.org/fperrad/lua-Spore 10 | INSTALL_COMMAND ${INSTALL_CMD} 11 | ) 12 | -------------------------------------------------------------------------------- /thirdparty/lunasvg/xtended/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(lunasvg PRIVATE 2 | "${CMAKE_CURRENT_LIST_DIR}/ximageelement.cpp" 3 | "${CMAKE_CURRENT_LIST_DIR}/xtextelement.cpp" 4 | "${CMAKE_CURRENT_LIST_DIR}/xtspanelement.cpp" 5 | ) 6 | 7 | target_include_directories(lunasvg PRIVATE "${CMAKE_CURRENT_LIST_DIR}") 8 | 9 | install(FILES xlunasvg.h DESTINATION ${LUNASVG_INCDIR}) 10 | -------------------------------------------------------------------------------- /nnsvg.h: -------------------------------------------------------------------------------- 1 | // nnsvg.cpp 2 | // Lua interface to wrap nanosvg. 3 | 4 | #ifndef _NNSVG_H 5 | #define _NNSVG_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | // Symbol visibility 12 | #define DLL_PUBLIC __attribute__((visibility("default"))) 13 | #define DLL_LOCAL __attribute__((visibility("hidden"))) 14 | 15 | DLL_PUBLIC int luaopen_nnsvg(lua_State *L); 16 | #endif 17 | -------------------------------------------------------------------------------- /thirdparty/djvulibre/android.patch: -------------------------------------------------------------------------------- 1 | diff --git a/libdjvu/DjVuToPS.cpp b/libdjvu/DjVuToPS.cpp 2 | index f72a4c9..51b2ce3 100644 3 | --- a/libdjvu/DjVuToPS.cpp 4 | +++ b/libdjvu/DjVuToPS.cpp 5 | @@ -59,6 +59,9 @@ 6 | #if NEED_GNUG_PRAGMAS 7 | # pragma implementation 8 | #endif 9 | +#ifdef __ANDROID__ 10 | +# undef UNIX 11 | +#endif 12 | 13 | #include "DjVuToPS.h" 14 | #include "IFFByteStream.h" 15 | -------------------------------------------------------------------------------- /thirdparty/lodepng/overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(lodepng LANGUAGES C) 3 | 4 | file(WRITE lodepng.c "#include \"lodepng.cpp\"\n") 5 | add_library(lodepng) 6 | target_sources(lodepng PRIVATE lodepng.c) 7 | target_compile_definitions(lodepng PRIVATE LODEPNG_NO_COMPILE_ANCILLARY_CHUNKS) 8 | 9 | install(TARGETS lodepng) 10 | install(FILES lodepng.h TYPE INCLUDE) 11 | -------------------------------------------------------------------------------- /thirdparty/freetype2/ftcalc_gcc12_arm_neon_fix.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c 2 | index 7d6e12e2..f7c99126 100644 3 | --- a/src/base/ftcalc.c 4 | +++ b/src/base/ftcalc.c 5 | @@ -737,7 +737,8 @@ 6 | 7 | shift = FT_MSB( val ) - 12; 8 | 9 | - if ( shift > 0 ) 10 | + if ( shift < 0 ) 11 | + shift = 0; 12 | { 13 | xx >>= shift; 14 | xy >>= shift; 15 | -------------------------------------------------------------------------------- /thirdparty/luajson/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build in source tree. 2 | set(BINARY_DIR ${SOURCE_DIR}) 3 | 4 | append_install_commands(INSTALL_CMD lua/json.lua DESTINATION common) 5 | append_tree_install_commands(INSTALL_CMD lua/json common/json) 6 | 7 | external_project( 8 | DOWNLOAD GIT 6ecaf9bea8b121a9ffca5a470a2080298557b55d 9 | https://github.com/harningt/luajson.git 10 | INSTALL_COMMAND ${INSTALL_CMD} 11 | ) 12 | -------------------------------------------------------------------------------- /thirdparty/tesseract/no_debug_fonts.patch: -------------------------------------------------------------------------------- 1 | --- a/src/ccstruct/debugpixa.h 2 | +++ b/src/ccstruct/debugpixa.h 3 | @@ -14,7 +14,7 @@ public: 4 | // TODO(rays) add another constructor with size control. 5 | DebugPixa() { 6 | pixa_ = pixaCreate(0); 7 | -#ifdef TESSERACT_DISABLE_DEBUG_FONTS 8 | +#if 1//def TESSERACT_DISABLE_DEBUG_FONTS 9 | fonts_ = NULL; 10 | #else 11 | fonts_ = bmfCreate(nullptr, 14); 12 | -------------------------------------------------------------------------------- /ffi-cdecl/ion_kobo_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | // specialized ION headers 3 | #include "include/ion-kobo.h" 4 | 5 | #include "ffi-cdecl.h" 6 | 7 | cdecl_type(ion_user_handle_t) 8 | cdecl_struct(ion_allocation_data) 9 | cdecl_struct(ion_fd_data) 10 | cdecl_struct(ion_handle_data) 11 | 12 | cdecl_const(ION_IOC_ALLOC) 13 | cdecl_const(ION_IOC_FREE) 14 | cdecl_const(ION_IOC_MAP) 15 | 16 | cdecl_enum(ion_heap_mask) 17 | -------------------------------------------------------------------------------- /spec/unit/freetype_spec.lua: -------------------------------------------------------------------------------- 1 | require("ffi_wrapper") 2 | local Freetype = require("ffi/freetype") 3 | 4 | describe("Freetype module", function() 5 | it("should create new face size without error", function() 6 | assert.has_no.errors(function() 7 | local ftsize = Freetype.newFaceSize('./fonts/droid/DroidSansMono.ttf', 18) 8 | assert.are_not.equals(ftsize, nil) 9 | end) 10 | end) 11 | end) 12 | -------------------------------------------------------------------------------- /thirdparty/libarchive/android.patch: -------------------------------------------------------------------------------- 1 | --- i/libarchive/archive_read_disk_posix.c 2 | +++ w/libarchive/archive_read_disk_posix.c 3 | @@ -1825,7 +1825,7 @@ 4 | /* pathconf(_PC_REX_*) operations are not supported. */ 5 | #if defined(HAVE_STATVFS) 6 | set_statvfs_transfer_size(t->current_filesystem, &svfs); 7 | -#else 8 | +#elif defined(HAVE_STRUCT_STATFS) 9 | set_statfs_transfer_size(t->current_filesystem, &sfs); 10 | #endif 11 | } 12 | -------------------------------------------------------------------------------- /thirdparty/lua-htmlparser/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build in source tree. 2 | set(BINARY_DIR ${SOURCE_DIR}) 3 | 4 | append_install_commands(INSTALL_CMD src/htmlparser.lua DESTINATION common) 5 | append_tree_install_commands(INSTALL_CMD src/htmlparser common/htmlparser) 6 | 7 | external_project( 8 | DOWNLOAD GIT 5ce9a775a345cf458c0388d7288e246bb1b82bff 9 | https://github.com/msva/lua-htmlparser 10 | INSTALL_COMMAND ${INSTALL_CMD} 11 | ) 12 | -------------------------------------------------------------------------------- /cache-key.base: -------------------------------------------------------------------------------- 1 | # Includes. 2 | *.[ch] 3 | *.cpp 4 | *.patch 5 | /CMakeLists.txt 6 | /Makefile 7 | /Makefile.defs 8 | /cmake 9 | /luafilesystem 10 | /origin.ldflags 11 | /thirdparty/*/* 12 | /utils/gen_linker_exports.sh 13 | 14 | # Excludes. 15 | !*.lua 16 | !/ffi-cdecl/** 17 | !/test-runner/** 18 | !/utils/bincheck/* 19 | 20 | # Exceptions. 21 | /ffi-cdecl/koptcontext_cdecl.c 22 | /ffi-cdecl/wrap-mupdf_cdecl.c 23 | 24 | # vim: ft=gitignore 25 | -------------------------------------------------------------------------------- /ffi-cdecl/utf8proc_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ffi-cdecl.h" 4 | 5 | cdecl_c99_type(utf8proc_uint8_t, uint8_t); 6 | cdecl_c99_type(utf8proc_int32_t, int32_t); 7 | cdecl_c99_type(utf8proc_ssize_t, ssize_t); 8 | 9 | cdecl_func(utf8proc_encode_char); 10 | cdecl_func(utf8proc_iterate); 11 | cdecl_func(utf8proc_NFC); 12 | cdecl_func(utf8proc_NFKC_Casefold); 13 | cdecl_func(utf8proc_tolower); 14 | cdecl_func(utf8proc_toupper); 15 | -------------------------------------------------------------------------------- /thirdparty/leptonica/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | --- i/CMakeLists.txt 2 | +++ w/CMakeLists.txt 3 | @@ -8,8 +8,7 @@ 4 | # 5 | # ############################################################################## 6 | 7 | -cmake_minimum_required(VERSION 3.5) 8 | -cmake_policy(SET CMP0054 NEW) 9 | +cmake_minimum_required(VERSION 3.17.5) 10 | 11 | # In-source builds are disabled. 12 | if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") 13 | -------------------------------------------------------------------------------- /thirdparty/libzmq/disable_eventfd.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -541,10 +541,6 @@ 4 | if(NOT MSVC) 5 | check_include_files(ifaddrs.h ZMQ_HAVE_IFADDRS) 6 | check_include_files(sys/uio.h ZMQ_HAVE_UIO) 7 | - check_include_files(sys/eventfd.h ZMQ_HAVE_EVENTFD) 8 | - if(ZMQ_HAVE_EVENTFD AND NOT CMAKE_CROSSCOMPILING) 9 | - zmq_check_efd_cloexec() 10 | - endif() 11 | endif() 12 | 13 | if(ZMQ_HAVE_WINDOWS) 14 | -------------------------------------------------------------------------------- /thirdparty/luajit/koreader-luajit-verbose-build.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/Makefile b/src/Makefile 2 | index 9bc109d8..1a38d2fe 100644 3 | --- a/src/Makefile 4 | +++ b/src/Makefile 5 | @@ -597,10 +597,10 @@ endif 6 | endif 7 | endif 8 | 9 | -Q= @ 10 | -E= @echo 11 | -#Q= 12 | -#E= @: 13 | +#Q= @ 14 | +#E= @echo 15 | +Q= 16 | +E= @: 17 | 18 | ############################################################################## 19 | # Make targets. 20 | -------------------------------------------------------------------------------- /ffi/zlib_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | long unsigned int compressBound(long unsigned int); 7 | int compress2(unsigned char *, long unsigned int *, const unsigned char *, long unsigned int, int); 8 | long unsigned int crc32(long unsigned int, const unsigned char *, unsigned int); 9 | int uncompress(unsigned char *, long unsigned int *, const unsigned char *, long unsigned int); 10 | ]] 11 | -------------------------------------------------------------------------------- /thirdparty/curl/clock_gettime_needs_rt.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -1964,7 +1964,11 @@ 4 | curl_internal_test(HAVE_POSIX_STRERROR_R) 5 | 6 | if(NOT WIN32) 7 | + set(CMAKE_REQUIRED_LIBRARIES -lrt) 8 | curl_internal_test(HAVE_CLOCK_GETTIME_MONOTONIC) # Check clock_gettime(CLOCK_MONOTONIC, x) support 9 | + if(HAVE_CLOCK_GETTIME_MONOTONIC) 10 | + list(APPEND CURL_LIBS "rt") 11 | + endif() 12 | endif() 13 | 14 | if(APPLE) 15 | -------------------------------------------------------------------------------- /ffi-cdecl/turbojpeg_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ffi-cdecl.h" 4 | 5 | cdecl_enum(TJINIT) 6 | cdecl_enum(TJSAMP) 7 | cdecl_enum(TJPF) 8 | cdecl_enum(TJPARAM) 9 | 10 | cdecl_type(tjhandle) 11 | 12 | cdecl_func(tj3Init) 13 | cdecl_func(tj3Set) 14 | cdecl_func(tj3Get) 15 | cdecl_func(tj3Compress8) 16 | cdecl_func(tj3DecompressHeader) 17 | cdecl_func(tj3Decompress8) 18 | cdecl_func(tj3Destroy) 19 | cdecl_func(tj3SaveImage8) 20 | cdecl_func(tj3Free) 21 | -------------------------------------------------------------------------------- /thirdparty/dropbear/nochdir-hack.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/svr-main.c b/src/svr-main.c 2 | index 6373e59..eb3a5bc 100644 3 | --- a/src/svr-main.c 4 | +++ b/src/svr-main.c 5 | @@ -185,7 +185,7 @@ static void main_noinetd(int argc, char ** argv, const char* multipath) { 6 | closefds = 1; 7 | } 8 | #endif 9 | - if (daemon(0, closefds) < 0) { 10 | + if (daemon(1, closefds) < 0) { 11 | dropbear_exit("Failed to daemonize: %s", strerror(errno)); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /thirdparty/minizip/overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(minizip LANGUAGES C) 3 | 4 | file(GLOB AES_SRC aes/*.c) 5 | file(GLOB AES_HDR aes/*.h) 6 | 7 | add_library(aes STATIC ${AES_SRC}) 8 | target_compile_definitions(aes PRIVATE -DHAVE_AES) 9 | target_compile_options(aes PRIVATE -Wno-error=implicit-function-declaration) 10 | 11 | install(TARGETS aes) 12 | install(FILES ${AES_HDR} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/aes) 13 | -------------------------------------------------------------------------------- /thirdparty/turbo/overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(turbo LANGUAGES C) 3 | 4 | find_package(PkgConfig REQUIRED) 5 | pkg_check_modules(OpenSSL openssl REQUIRED IMPORTED_TARGET) 6 | 7 | add_library(tffi_wrap) 8 | target_include_directories(tffi_wrap PRIVATE deps/http-parser) 9 | target_link_libraries(tffi_wrap PRIVATE PkgConfig::OpenSSL) 10 | target_sources(tffi_wrap PRIVATE deps/http-parser/http_parser.c deps/turbo_ffi_wrap.c) 11 | -------------------------------------------------------------------------------- /thirdparty/nanosvg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build in source tree. 2 | set(BINARY_DIR ${SOURCE_DIR}) 3 | 4 | append_install_commands( 5 | INSTALL_CMD 6 | src/nanosvg.h src/nanosvgrast.h 7 | ${THIRDPARTY_DIR}/nanosvg/stb_image_write.h 8 | DESTINATION ${STAGING_DIR}/include 9 | ) 10 | 11 | external_project( 12 | DOWNLOAD GIT ea6a6aca009422bba0dbad4c80df6e6ba0c82183 13 | https://github.com/memononen/nanosvg.git 14 | INSTALL_COMMAND ${INSTALL_CMD} 15 | ) 16 | -------------------------------------------------------------------------------- /thirdparty/lunasvg/xtended/xtextelement.h: -------------------------------------------------------------------------------- 1 | #ifndef TEXTELEMENT_H 2 | #define TEXTELEMENT_H 3 | 4 | #include "graphicselement.h" 5 | 6 | namespace lunasvg { 7 | 8 | class TextElement : public GraphicsElement 9 | { 10 | public: 11 | TextElement(); 12 | 13 | void layout(LayoutContext* context, LayoutContainer* current) const override; 14 | 15 | std::unique_ptr clone() const override; 16 | }; 17 | 18 | } // namespace lunasvg 19 | 20 | #endif // TEXTELEMENT_H 21 | -------------------------------------------------------------------------------- /thirdparty/xxhash/overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(xxhash LANGUAGES C) 3 | 4 | add_library(xxhash) 5 | set_target_properties(xxhash PROPERTIES SOVERSION 0) 6 | target_sources(xxhash PRIVATE xxhash.c) 7 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") 8 | target_compile_definitions(xxhash PRIVATE XXH_NO_INLINE_HINTS) 9 | endif() 10 | 11 | install(TARGETS xxhash) 12 | install(FILES xxh3.h xxhash.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include) 13 | -------------------------------------------------------------------------------- /thirdparty/sdl2/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | diff --git a/CMakeLists.txt b/CMakeLists.txt 2 | index e45b53e20..50f2f242a 100644 3 | --- a/CMakeLists.txt 4 | +++ b/CMakeLists.txt 5 | @@ -5,7 +5,7 @@ endif() 6 | # MSVC runtime library flags are selected by an abstraction. 7 | set(CMAKE_POLICY_DEFAULT_CMP0091 NEW) 8 | 9 | -cmake_minimum_required(VERSION 3.0.0...3.10) 10 | +cmake_minimum_required(VERSION 3.17.5) 11 | project(SDL2 C) 12 | 13 | if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) 14 | -------------------------------------------------------------------------------- /ffi-cdecl/crypto_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ffi-cdecl.h" 4 | 5 | cdecl_func(PKCS5_PBKDF2_HMAC_SHA1) 6 | cdecl_func(EVP_CIPHER_CTX_new); 7 | cdecl_func(EVP_CIPHER_CTX_free); 8 | cdecl_func(EVP_CIPHER_CTX_set_padding); 9 | cdecl_func(EVP_CIPHER_block_size); 10 | cdecl_func(EVP_DecryptInit_ex); 11 | cdecl_func(EVP_DecryptUpdate); 12 | cdecl_func(EVP_DecryptFinal_ex); 13 | cdecl_func(EVP_aes_128_ecb); 14 | cdecl_func(EVP_aes_192_ecb); 15 | cdecl_func(EVP_aes_256_ecb); 16 | -------------------------------------------------------------------------------- /thirdparty/mupdf/honor_cflags.patch: -------------------------------------------------------------------------------- 1 | diff --git a/Makerules b/Makerules 2 | index ba4df2189..bd4d6c217 100644 3 | --- a/Makerules 4 | +++ b/Makerules 5 | @@ -148,10 +148,10 @@ else 6 | endif 7 | 8 | ifeq ($(build),debug) 9 | - CFLAGS += -pipe -g 10 | + CFLAGS += -g 11 | LDFLAGS += -g 12 | else ifeq ($(build),release) 13 | - CFLAGS += -pipe -O2 -DNDEBUG 14 | + CFLAGS += -DNDEBUG 15 | LDFLAGS += $(LDREMOVEUNREACH) -Wl,-s 16 | else ifeq ($(build),small) 17 | CFLAGS += -pipe -Os -DNDEBUG 18 | -------------------------------------------------------------------------------- /thirdparty/lj-wpaclient/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build in source tree. 2 | set(BINARY_DIR ${SOURCE_DIR}) 3 | 4 | append_install_commands(INSTALL_CMD 5 | consts_h.lua poll_h.lua select_h.lua 6 | socket_h.lua socket.lua time_h.lua 7 | wpaclient.lua wpa_ctrl.lua 8 | DESTINATION ${OUTPUT_DIR}/common/lj-wpaclient 9 | ) 10 | 11 | external_project( 12 | DOWNLOAD GIT 0d5c8ee336b699dbb35850a7336d24e89e1aac24 13 | https://github.com/koreader/lj-wpaclient.git 14 | INSTALL_COMMAND ${INSTALL_CMD} 15 | ) 16 | -------------------------------------------------------------------------------- /.luacheckrc: -------------------------------------------------------------------------------- 1 | unused_args = false 2 | unused_secondaries = false 3 | std = "luajit" 4 | -- ignore implicit self 5 | self = false 6 | 7 | globals = { 8 | "G_defaults", 9 | "table.pack", 10 | "table.unpack", 11 | } 12 | 13 | exclude_files = { 14 | "build/*", 15 | "ffi/sha2.lua", 16 | "luafilesystem/*", 17 | "thirdparty/*", 18 | } 19 | 20 | files["spec/unit/*"].std = "+busted" 21 | 22 | -- TODO: clean up and enforce max line width (631) 23 | ignore = { 24 | "631", 25 | "dummy", 26 | } 27 | -------------------------------------------------------------------------------- /ffi-cdecl/zstd_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ffi-cdecl.h" 4 | 5 | cdecl_const(ZSTD_CLEVEL_DEFAULT) 6 | 7 | cdecl_func(ZSTD_compress) 8 | cdecl_func(ZSTD_decompress) 9 | cdecl_func(ZSTD_getFrameContentSize) 10 | cdecl_func(ZSTD_compressBound) 11 | cdecl_func(ZSTD_isError) 12 | cdecl_func(ZSTD_getErrorName) 13 | 14 | cdecl_type(ZSTD_DCtx) 15 | cdecl_type(ZSTD_ResetDirective) 16 | cdecl_func(ZSTD_createDCtx) 17 | cdecl_func(ZSTD_freeDCtx) 18 | cdecl_func(ZSTD_decompressDCtx) 19 | cdecl_func(ZSTD_DCtx_reset) 20 | -------------------------------------------------------------------------------- /thirdparty/czmq/fix_prefix_handling.patch: -------------------------------------------------------------------------------- 1 | --- a/src/zsys.c 2 | +++ b/src/zsys.c 3 | @@ -334,9 +334,7 @@ 4 | zsys_set_thread_name_prefix (s_thread_name_prefix); 5 | 6 | if (getenv ("ZSYS_THREAD_NAME_PREFIX_STR")) 7 | - zsys_set_thread_name_prefix_str (getenv ("ZSYS_THREAD_NAME_PREFIX")); 8 | - else 9 | - zsys_set_thread_name_prefix_str (s_thread_name_prefix_str); 10 | + zsys_set_thread_name_prefix_str (getenv ("ZSYS_THREAD_NAME_PREFIX_STR")); 11 | 12 | return s_process_ctx; 13 | } 14 | -------------------------------------------------------------------------------- /thirdparty/libjpeg-turbo/no_cmake_rpath_shenanigans.patch: -------------------------------------------------------------------------------- 1 | diff --git a/CMakeLists.txt b/CMakeLists.txt 2 | index f131247..b7e1276 100644 3 | --- a/CMakeLists.txt 4 | +++ b/CMakeLists.txt 5 | @@ -304,10 +304,6 @@ endif() 6 | report_option(ENABLE_SHARED "Shared libraries") 7 | report_option(ENABLE_STATIC "Static libraries") 8 | 9 | -if(ENABLE_SHARED) 10 | - set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}) 11 | -endif() 12 | - 13 | if(WITH_JPEG8 OR WITH_JPEG7) 14 | set(WITH_ARITH_ENC 1) 15 | set(WITH_ARITH_DEC 1) 16 | -------------------------------------------------------------------------------- /thirdparty/proxy-libintl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(proxy-libintl LANGUAGES) 2 | 3 | list(APPEND CFG_CMD COMMAND 4 | ${MESON_SETUP} --default-library=static 5 | "${SOURCE_DIR}" 6 | ) 7 | 8 | list(APPEND BUILD_CMD COMMAND ninja) 9 | 10 | list(APPEND BUILD_CMD COMMAND ${MESON_INSTALL}) 11 | 12 | external_project( 13 | DOWNLOAD URL 7cc93d2fec98a5b9820888135d2e8844 14 | https://github.com/frida/proxy-libintl/archive/refs/tags/0.4.tar.gz 15 | CONFIGURE_COMMAND ${CFG_CMD} 16 | BUILD_COMMAND ${BUILD_CMD} 17 | ) 18 | -------------------------------------------------------------------------------- /thirdparty/mupdf/no_arm_asm.patch: -------------------------------------------------------------------------------- 1 | diff --git a/include/mupdf/fitz/system.h b/include/mupdf/fitz/system.h 2 | index 3f2c13ccc..65fb15609 100644 3 | --- a/include/mupdf/fitz/system.h 4 | +++ b/include/mupdf/fitz/system.h 5 | @@ -84,11 +84,13 @@ typedef unsigned __int64 uint64_t; 6 | */ 7 | 8 | /* ARCH_ARM is only used for 32bit ARM stuff. */ 9 | +#if 0 10 | #if defined(__arm__) || defined(__thumb__) 11 | #ifndef ARCH_ARM 12 | #define ARCH_ARM 13 | #endif 14 | #endif 15 | +#endif 16 | 17 | /* Detect NEON */ 18 | #ifndef ARCH_HAS_NEON 19 | -------------------------------------------------------------------------------- /thirdparty/leptonica/fmemopen-arm-compat-symbol.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/utils2.c b/src/utils2.c 2 | index bac9621..4f7c696 100644 3 | --- a/src/utils2.c 4 | +++ b/src/utils2.c 5 | @@ -1632,6 +1632,7 @@ FILE *fp; 6 | return (FILE *)ERROR_PTR("data not defined", procName, NULL); 7 | 8 | #if HAVE_FMEMOPEN 9 | + __asm__(".symver fmemopen,fmemopen@GLIBC_2.4"); 10 | if ((fp = fmemopen((void *)data, size, "rb")) == NULL) 11 | return (FILE *)ERROR_PTR("stream not opened", procName, NULL); 12 | #else /* write to tmp file */ 13 | -------------------------------------------------------------------------------- /thirdparty/mupdf/relink_on_xlibs_change.patch: -------------------------------------------------------------------------------- 1 | diff --git a/Makefile b/Makefile 2 | index ac5f9fc9d..13253ac0b 100644 3 | --- a/Makefile 4 | +++ b/Makefile 5 | @@ -299,7 +299,7 @@ generate: source/html/css-properties.h 6 | # --- Library --- 7 | 8 | ifeq ($(shared),yes) 9 | - $(OUT)/libmupdf.$(SO)$(SO_VERSION): $(MUPDF_OBJ) $(THIRD_OBJ) 10 | + $(OUT)/libmupdf.$(SO)$(SO_VERSION): $(MUPDF_OBJ) $(THIRD_OBJ) $(XLIBS) 11 | $(LINK_SO_CMD) $(THIRD_LIBS) $(LIBCRYPTO_LIBS) $(LIBS) 12 | ifeq ($(OS),OpenBSD) 13 | # should never create symlink 14 | -------------------------------------------------------------------------------- /thirdparty/giflib/overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(giflib LANGUAGES C) 3 | 4 | add_library(gif) 5 | set_target_properties(gif PROPERTIES SOVERSION 7) 6 | if(DEFINED ANDROID_STL) 7 | target_compile_definitions(gif PRIVATE -DS_IREAD=S_IRUSR -DS_IWRITE=S_IWUSR) 8 | endif() 9 | target_sources(gif PRIVATE 10 | dgif_lib.c egif_lib.c 11 | gifalloc.c gif_err.c gif_font.c gif_hash.c 12 | openbsd-reallocarray.c quantize.c 13 | ) 14 | 15 | install(TARGETS gif) 16 | install(FILES gif_lib.h TYPE INCLUDE) 17 | -------------------------------------------------------------------------------- /ffi-cdecl/linux_fb_decl.c: -------------------------------------------------------------------------------- 1 | // standard Linux framebuffer headers 2 | #include 3 | 4 | #include 5 | 6 | #include "ffi-cdecl.h" 7 | 8 | cdecl_const(FBIOGET_FSCREENINFO) 9 | cdecl_const(FBIOGET_VSCREENINFO) 10 | cdecl_const(FBIOPUT_VSCREENINFO) 11 | 12 | cdecl_const(FB_TYPE_PACKED_PIXELS) 13 | 14 | cdecl_const(FB_ROTATE_UR) 15 | cdecl_const(FB_ROTATE_CW) 16 | cdecl_const(FB_ROTATE_UD) 17 | cdecl_const(FB_ROTATE_CCW) 18 | 19 | cdecl_struct(fb_bitfield) 20 | cdecl_struct(fb_fix_screeninfo) 21 | cdecl_struct(fb_var_screeninfo) 22 | -------------------------------------------------------------------------------- /thirdparty/koreader-lfs/overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(koreader-lfs LANGUAGES C) 3 | 4 | find_package(PkgConfig REQUIRED) 5 | pkg_check_modules(LuaJIT luajit REQUIRED IMPORTED_TARGET) 6 | 7 | if(BUILD_SHARED_LIBS) 8 | add_library(koreader-lfs MODULE) 9 | else() 10 | add_library(koreader-lfs STATIC) 11 | endif() 12 | set_target_properties(koreader-lfs PROPERTIES C_VISIBILITY_PRESET hidden) 13 | target_link_libraries(koreader-lfs PRIVATE PkgConfig::LuaJIT) 14 | target_sources(koreader-lfs PRIVATE src/lfs.c) 15 | -------------------------------------------------------------------------------- /xtext.h: -------------------------------------------------------------------------------- 1 | // xtext.cpp 2 | // Lua interface to wrap a utf8 string into a XText object 3 | // that provides various text shaping and layout methods 4 | // with the help of Fribidi, Harfbuzz and libunibreak. 5 | 6 | #ifndef _XTEXT_H 7 | #define _XTEXT_H 8 | 9 | extern "C" 10 | { 11 | #include 12 | #include 13 | #include 14 | } 15 | 16 | // Symbol visibility 17 | #define DLL_PUBLIC __attribute__((visibility("default"))) 18 | #define DLL_LOCAL __attribute__((visibility("hidden"))) 19 | 20 | DLL_PUBLIC int luaopen_xtext(lua_State *L); 21 | #endif 22 | -------------------------------------------------------------------------------- /thirdparty/libarchive/ignore_locale_and_use_utf8.patch: -------------------------------------------------------------------------------- 1 | --- a/libarchive/archive_string.c 2 | +++ b/libarchive/archive_string.c 3 | @@ -445,6 +445,7 @@ 4 | default_iconv_charset(const char *charset) { 5 | if (charset != NULL && charset[0] != '\0') 6 | return charset; 7 | +#if 0 8 | #if HAVE_LOCALE_CHARSET && !defined(__APPLE__) 9 | /* locale_charset() is broken on Mac OS */ 10 | return locale_charset(); 11 | @@ -453,6 +454,9 @@ 12 | #else 13 | return ""; 14 | #endif 15 | +#else 16 | + return "UTF-8"; 17 | +#endif 18 | } 19 | 20 | #if defined(_WIN32) && !defined(__CYGWIN__) 21 | -------------------------------------------------------------------------------- /thirdparty/sdcv/ignore_hidden.patch: -------------------------------------------------------------------------------- 1 | --- a/src/utils.cpp 2 | +++ b/src/utils.cpp 3 | @@ -64,6 +64,10 @@ 4 | const gchar *filename; 5 | 6 | while ((filename = g_dir_read_name(dir)) != nullptr) { 7 | + if (filename[0] == '.') { 8 | + // Ignore hidden entries. 9 | + continue; 10 | + } 11 | const std::string fullfilename(dirname + G_DIR_SEPARATOR_S + filename); 12 | if (g_file_test(fullfilename.c_str(), G_FILE_TEST_IS_DIR)) 13 | __for_each_file(fullfilename, suff, order_list, disable_list, f); 14 | -------------------------------------------------------------------------------- /.ci/lint_script.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 4 | # shellcheck source=/dev/null 5 | source "${CI_DIR}/common.sh" 6 | 7 | exit_code=0 8 | 9 | "${CI_DIR}/helper_shellchecks.sh" || exit_code=1 10 | 11 | echo -e "\n${ANSI_GREEN}Luacheck results${ANSI_RESET}" 12 | luacheck ${PARALLEL_JOBS:+-j "${PARALLEL_JOBS}"} -q ffi spec || exit_code=1 13 | 14 | echo -e "\n${ANSI_GREEN}CMakeLint results${ANSI_RESET}" 15 | mapfile -t cmake_files < <(git ls-files '*.cmake' '*/CMakeLists.txt') 16 | cmakelint "${cmake_files[@]}" || exit_code=1 17 | 18 | exit ${exit_code} 19 | -------------------------------------------------------------------------------- /thirdparty/srell/readme_ja.txt: -------------------------------------------------------------------------------- 1 | ■使用法 2 | 3 | 次のファイルを同じディレクトリに置き、srell.hppをincludeするだけです。 4 | ・srell.hpp 5 | ・srell_ucfdata2.hpp(case folding用データ) 6 | ・srell_updata.hpp(Unicode property用データ) 7 | 8 | ■付属物 9 | 以下のディレクトリ内にあるものはおまけのようなものです。 10 | SRELL側からは参照していませんので、削除してしまってもライブラリの動作に 11 | 影響はありません。 12 | 13 | ・misc 14 | 簡単なテスト及びベンチマークプログラムのソースが入っています。 15 | 16 | ・single-header 17 | srell.hppの中にsrell_ucfdata2.hppとsrell_updata.hppとを統合してしまい、 18 | これ単体で使用できるようにしたstandalone版が入っています。 19 | 20 | ・unicode 21 | 最新のUnicodeデータからsrell_ucfdata.hpp及びsrell_updata.hppを作るため 22 | のプログラムのソースが入っています。 23 | 24 | -------------------------------------------------------------------------------- /thirdparty/lpeg/overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(lpeg LANGUAGES C) 3 | 4 | find_package(PkgConfig REQUIRED) 5 | pkg_check_modules(LuaJIT luajit REQUIRED IMPORTED_TARGET) 6 | 7 | if(BUILD_SHARED_LIBS) 8 | add_library(lpeg MODULE) 9 | else() 10 | add_library(lpeg STATIC) 11 | endif() 12 | set_target_properties(lpeg PROPERTIES 13 | C_STANDARD 99 14 | PREFIX "" 15 | ) 16 | target_link_libraries(lpeg PRIVATE PkgConfig::LuaJIT) 17 | target_sources(lpeg PRIVATE 18 | lpcap.c 19 | lpcode.c 20 | lpcset.c 21 | lpprint.c 22 | lptree.c 23 | lpvm.c 24 | ) 25 | -------------------------------------------------------------------------------- /thirdparty/md4c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES cmake_tweaks.patch) 2 | 3 | list(APPEND CMAKE_ARGS 4 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 5 | -DBUILD_SHARED_LIBS=FALSE 6 | ) 7 | 8 | list(APPEND BUILD_CMD COMMAND ninja) 9 | 10 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 11 | 12 | external_project( 13 | DOWNLOAD URL 8ead909cfe31884295e81e2eee32bac9 14 | https://github.com/mity/md4c/archive/refs/tags/release-0.5.2.tar.gz 15 | PATCH_FILES ${PATCH_FILES} 16 | CMAKE_ARGS ${CMAKE_ARGS} 17 | BUILD_COMMAND ${BUILD_CMD} 18 | INSTALL_COMMAND ${INSTALL_CMD} 19 | ) 20 | -------------------------------------------------------------------------------- /thirdparty/popen-noshell/kindle_legacy.patch: -------------------------------------------------------------------------------- 1 | diff --git a/popen_noshell.c b/popen_noshell.c 2 | index 61e0eff..8da4145 100644 3 | --- a/popen_noshell.c 4 | +++ b/popen_noshell.c 5 | @@ -334,7 +334,7 @@ FILE *popen_noshell(const char *file, const char * const *argv, const char *type 6 | // issue #7: O_CLOEXEC, so that child processes don't inherit and hold opened the 7 | // file descriptors of the parent. 8 | // The child process turns this off for its fd of the pipe. 9 | - if (pipe2(pipefd, O_CLOEXEC) != 0) return NULL; 10 | + if (pipe(pipefd) != 0) return NULL; 11 | 12 | if (_popen_noshell_fork_mode) { // use fork() 13 | -------------------------------------------------------------------------------- /.ci/helper_shellchecks.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 4 | # shellcheck source=/dev/null 5 | source "${CI_DIR}/common.sh" 6 | 7 | # shellcheck disable=2016 8 | mapfile -t shellscript_locations < <({ git grep -lE '^#!(/usr)?/bin/(env )?(bash|sh)' && git submodule --quiet foreach '[ "$path" = "thirdparty/kpvcrlib/crengine" ] && git grep -lE "^#!(/usr)?/bin/(env )?(bash|sh)" | grep .ci | sed "s|^|$path/|" || git grep -lE "^#!(/usr)?/bin/(env )?(bash|sh)" | sed "s|^|$path/|"' && git ls-files './*.sh'; } | sort | uniq) 9 | 10 | ./utils/shellcheck.sh "${shellscript_locations[@]}" 11 | -------------------------------------------------------------------------------- /thirdparty/cpu_features/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_ARGS 2 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 3 | # Project options. 4 | -DANDROID=${ANDROID} 5 | -DBUILD_EXECUTABLE=FALSE 6 | -DBUILD_TESTING=FALSE 7 | ) 8 | 9 | list(APPEND BUILD_CMD COMMAND ninja) 10 | 11 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 12 | 13 | external_project( 14 | DOWNLOAD URL 32f6f561c24dce66ed4bc0384b22c026 15 | https://github.com/google/cpu_features/archive/refs/tags/v0.10.1.tar.gz 16 | CMAKE_ARGS ${CMAKE_ARGS} 17 | BUILD_COMMAND ${BUILD_CMD} 18 | INSTALL_COMMAND ${INSTALL_CMD} 19 | ) 20 | -------------------------------------------------------------------------------- /ffi-cdecl/rtc_cdecl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "ffi-cdecl.h" 7 | 8 | cdecl_struct(rtc_time) 9 | cdecl_struct(rtc_wkalrm) 10 | 11 | cdecl_const(RTC_AIE_ON) 12 | cdecl_const(RTC_AIE_OFF) 13 | cdecl_const(RTC_WKALM_SET) 14 | cdecl_const(RTC_WKALM_RD) 15 | cdecl_const(RTC_RD_TIME) 16 | 17 | cdecl_type(time_t) 18 | cdecl_struct(tm) 19 | cdecl_func(time) 20 | cdecl_func(gmtime) 21 | cdecl_func(gmtime_r) 22 | cdecl_func(localtime) 23 | cdecl_func(localtime_r) 24 | cdecl_func(timegm) 25 | cdecl_func(mktime) 26 | cdecl_func(settimeofday) 27 | cdecl_func(tzset) 28 | -------------------------------------------------------------------------------- /thirdparty/curl/fetch-ca-bundle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | output="$1" 4 | outdir="$(dirname "${output}")" 5 | 6 | mkdir -p "${outdir}" && curl \ 7 | --etag-compare "${output}.etag" \ 8 | --etag-save "${output}.etag" \ 9 | --output "${output}" \ 10 | --retry 3 \ 11 | https://curl.se/ca/cacert.pem 12 | code=$? 13 | 14 | if [ ${code} -ne 0 ]; then 15 | if [ -r "${output}" ]; then 16 | code=0 17 | severity=WARNING 18 | else 19 | severity=ERROR 20 | fi 21 | printf '\033[31;1m%s:\033[0m failed to fetch “%s”\n' "${severity}" "${output}" 1>&2 22 | fi 23 | 24 | exit ${code} 25 | 26 | # vim: sw=4 27 | -------------------------------------------------------------------------------- /thirdparty/ffi-cdecl/ffi-cdecl.patch: -------------------------------------------------------------------------------- 1 | --- a/ffi-cdecl.lua 2 | +++ b/ffi-cdecl.lua 3 | @@ -1,5 +1,5 @@ 4 | local script_dir = arg["script"]:gsub("[^/]+$","") 5 | -package.path = script_dir .. "gcc-lua-cdecl/?.lua;" .. package.path 6 | +package.path = script_dir .. "/?.lua;" .. package.path 7 | 8 | local gcc = require("gcc") 9 | local cdecl = require("gcc.cdecl") 10 | @@ -73,7 +73,7 @@ 11 | ::continue:: 12 | end 13 | 14 | - local f = assert(io.open(arg.output, "w")) 15 | + local f = arg.output == '-' and io.stdout or assert(io.open(arg.output, "w")) 16 | if arg.output:match(".*%.(.*)") == "py" then 17 | f:write([=[ 18 | """ 19 | -------------------------------------------------------------------------------- /ffi-cdecl/einkfb_decl.c: -------------------------------------------------------------------------------- 1 | // standard Linux framebuffer headers 2 | #include 3 | 4 | #include 5 | // specialized eink framebuffer headers 6 | typedef unsigned int u_int; 7 | typedef unsigned long u_long; 8 | #include "include/einkfb.h" 9 | 10 | #include "ffi-cdecl.h" 11 | 12 | cdecl_enum(fx_type) 13 | cdecl_struct(update_area_t) 14 | cdecl_enum(orientation_t) 15 | 16 | cdecl_enum(einkfb_events_t) 17 | cdecl_struct(einkfb_event_t) 18 | 19 | cdecl_const(FBIO_EINK_UPDATE_DISPLAY) 20 | cdecl_const(FBIO_EINK_UPDATE_DISPLAY_AREA) 21 | cdecl_const(FBIO_EINK_SET_DISPLAY_ORIENTATION) 22 | cdecl_const(FBIO_EINK_GET_DISPLAY_ORIENTATION) 23 | 24 | -------------------------------------------------------------------------------- /thirdparty/mupdf/free-html-doc-fonts-on-close.patch: -------------------------------------------------------------------------------- 1 | diff --git a/source/html/html-doc.c b/source/html/html-doc.c 2 | index 4bfa1f325..5c0ea1637 100644 3 | --- a/source/html/html-doc.c 4 | +++ b/source/html/html-doc.c 5 | @@ -49,6 +49,11 @@ static void 6 | htdoc_drop_document(fz_context *ctx, fz_document *doc_) 7 | { 8 | html_document *doc = (html_document*)doc_; 9 | + /* Purge glyph cache so fonts can be freed. */ 10 | + fz_try(ctx) 11 | + fz_purge_glyph_cache(ctx); 12 | + fz_catch(ctx) 13 | + { /* Swallow error, but continue dropping */ } 14 | fz_drop_archive(ctx, doc->zip); 15 | fz_drop_html(ctx, doc->html); 16 | fz_drop_html_font_set(ctx, doc->set); 17 | -------------------------------------------------------------------------------- /ffi/utf8proc_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | typedef uint8_t utf8proc_uint8_t; 7 | typedef int32_t utf8proc_int32_t; 8 | typedef ssize_t utf8proc_ssize_t; 9 | utf8proc_ssize_t utf8proc_encode_char(utf8proc_int32_t, utf8proc_uint8_t *); 10 | utf8proc_ssize_t utf8proc_iterate(const utf8proc_uint8_t *, utf8proc_ssize_t, utf8proc_int32_t *); 11 | utf8proc_uint8_t *utf8proc_NFC(const utf8proc_uint8_t *); 12 | utf8proc_uint8_t *utf8proc_NFKC_Casefold(const utf8proc_uint8_t *); 13 | utf8proc_int32_t utf8proc_tolower(utf8proc_int32_t); 14 | utf8proc_int32_t utf8proc_toupper(utf8proc_int32_t); 15 | ]] 16 | -------------------------------------------------------------------------------- /thirdparty/lodepng/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_ARGS 2 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 3 | -DBUILD_SHARED_LIBS=$> 4 | ) 5 | 6 | list(APPEND BUILD_CMD COMMAND ninja) 7 | 8 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 9 | 10 | if(NOT MONOLIBTIC) 11 | append_shared_lib_install_commands(INSTALL_CMD lodepng) 12 | endif() 13 | 14 | external_project( 15 | DOWNLOAD GIT 0b1d9ccfc2093e5d6620cd9a11d03ee6ff6705f5 16 | https://github.com/lvandeve/lodepng.git 17 | PATCH_OVERLAY overlay 18 | CMAKE_ARGS ${CMAKE_ARGS} 19 | BUILD_COMMAND ${BUILD_CMD} 20 | INSTALL_COMMAND ${INSTALL_CMD} 21 | ) 22 | -------------------------------------------------------------------------------- /thirdparty/utf8proc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_ARGS 2 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 3 | -DBUILD_SHARED_LIBS=$> 4 | ) 5 | 6 | list(APPEND BUILD_CMD COMMAND ninja) 7 | 8 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 9 | 10 | if(NOT MONOLIBTIC) 11 | append_shared_lib_install_commands(INSTALL_CMD utf8proc VERSION 3) 12 | endif() 13 | 14 | external_project( 15 | DOWNLOAD URL 98a792951dd10caec3dc242825eef3d5 16 | https://github.com/JuliaStrings/utf8proc/archive/refs/tags/v2.11.2.tar.gz 17 | CMAKE_ARGS ${CMAKE_ARGS} 18 | BUILD_COMMAND ${BUILD_CMD} 19 | INSTALL_COMMAND ${INSTALL_CMD} 20 | ) 21 | -------------------------------------------------------------------------------- /thirdparty/brotli/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES cmake_tweaks.patch) 2 | 3 | list(APPEND CMAKE_ARGS 4 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 5 | -DBUILD_SHARED_LIBS=FALSE 6 | # Project options. 7 | -DBROTLI_DISABLE_TESTS=TRUE 8 | ) 9 | 10 | list(APPEND BUILD_CMD COMMAND ninja) 11 | 12 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 13 | 14 | external_project( 15 | DOWNLOAD URL 3a6a3dba82a3604792d3cb0bd41bca60 16 | https://github.com/google/brotli/archive/refs/tags/v1.1.0.tar.gz 17 | PATCH_FILES ${PATCH_FILES} 18 | CMAKE_ARGS ${CMAKE_ARGS} 19 | BUILD_COMMAND ${BUILD_CMD} 20 | INSTALL_COMMAND ${INSTALL_CMD} 21 | ) 22 | -------------------------------------------------------------------------------- /ffi/input_SDL2_0.lua: -------------------------------------------------------------------------------- 1 | -- load common SDL input/video library 2 | local SDL = require("ffi/SDL2_0") 3 | 4 | return { 5 | open = SDL.open, 6 | waitForEvent = SDL.waitForEvent, 7 | -- NOPs: 8 | fakeTapInput = function() end, 9 | close = function() end, 10 | -- Input & Output are handled as one, and we call SDL_Quit in fb:close already 11 | closeAll = function() end, 12 | -- Tell front that we're a custom imp with no concept of paths/fd 13 | is_ffi = true, 14 | hasClipboardText = SDL.hasClipboardText, 15 | getClipboardText = SDL.getClipboardText, 16 | setClipboardText = SDL.setClipboardText, 17 | gameControllerRumble = SDL.gameControllerRumble, 18 | } 19 | -------------------------------------------------------------------------------- /thirdparty/sqlite/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_ARGS 2 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 3 | -DBUILD_SHARED_LIBS=$> 4 | ) 5 | 6 | list(APPEND BUILD_CMD COMMAND ninja) 7 | 8 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 9 | 10 | if(NOT MONOLIBTIC) 11 | append_shared_lib_install_commands(INSTALL_CMD sqlite3 VERSION 0) 12 | endif() 13 | 14 | external_project( 15 | DOWNLOAD URL e5427c52a22f1b47e048f649c07746f7 16 | https://www.sqlite.org/2025/sqlite-amalgamation-3510100.zip 17 | PATCH_OVERLAY overlay 18 | CMAKE_ARGS ${CMAKE_ARGS} 19 | BUILD_COMMAND ${BUILD_CMD} 20 | INSTALL_COMMAND ${INSTALL_CMD} 21 | ) 22 | -------------------------------------------------------------------------------- /utils/bincheck/liblipc.c: -------------------------------------------------------------------------------- 1 | #include "stub.h" 2 | STUB(LipcHasharrayKeys) 3 | STUB(LipcHasharrayGetInt) 4 | STUB(LipcHasharrayNew) 5 | STUB(LipcClose) 6 | STUB(LipcSetIntProperty) 7 | STUB(LipcHasharrayPutInt) 8 | STUB(LipcOpenNoName) 9 | STUB(LipcFreeString) 10 | STUB(LipcHasharrayDestroy) 11 | STUB(LipcSetStringProperty) 12 | STUB(LipcGetStringProperty) 13 | STUB(LipcHasharrayAddHash) 14 | STUB(LipcHasharrayGetHashCount) 15 | STUB(LipcHasharrayPutString) 16 | STUB(LipcOpenEx) 17 | STUB(LipcGetErrorString) 18 | STUB(LipcGetIntProperty) 19 | STUB(LipcGetServiceName) 20 | STUB(LipcHasharrayToString) 21 | STUB(LipcHasharrayGetString) 22 | STUB(LipcAccessHasharrayProperty) 23 | STUB(LipcHasharrayCheckKey) 24 | -------------------------------------------------------------------------------- /thirdparty/android-luajit-launcher/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_ARGS 2 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 3 | -DBUILD_SHARED_LIBS=$> 4 | ) 5 | 6 | list(APPEND BUILD_CMD COMMAND ninja) 7 | 8 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 9 | 10 | if(NOT MONOLIBTIC) 11 | append_shared_lib_install_commands(INSTALL_CMD 7z) 12 | endif() 13 | append_shared_lib_install_commands(INSTALL_CMD ioctl) 14 | append_shared_lib_install_commands(INSTALL_CMD luajit-launcher) 15 | 16 | external_project( 17 | CMAKE_ARGS ${CMAKE_ARGS} 18 | SOURCE_SUBDIR jni 19 | BUILD_COMMAND ${BUILD_CMD} 20 | INSTALL_COMMAND ${INSTALL_CMD} 21 | ) 22 | -------------------------------------------------------------------------------- /thirdparty/xxhash/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_ARGS 2 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 3 | -DBUILD_SHARED_LIBS=$> 4 | ) 5 | 6 | list(APPEND BUILD_CMD COMMAND ninja) 7 | 8 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 9 | 10 | if(NOT MONOLIBTIC) 11 | append_shared_lib_install_commands(INSTALL_CMD xxhash VERSION 0) 12 | endif() 13 | 14 | external_project( 15 | DOWNLOAD URL 599804eb9555e51c05f1b821f9212a07 16 | https://github.com/Cyan4973/xxHash/archive/refs/tags/v0.8.3.tar.gz 17 | PATCH_OVERLAY overlay 18 | CMAKE_ARGS ${CMAKE_ARGS} 19 | BUILD_COMMAND ${BUILD_CMD} 20 | INSTALL_COMMAND ${INSTALL_CMD} 21 | ) 22 | -------------------------------------------------------------------------------- /thirdparty/libzmq/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -2,9 +2,9 @@ 4 | project(ZeroMQ) 5 | 6 | if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin) 7 | - cmake_minimum_required(VERSION 3.0.2) 8 | + cmake_minimum_required(VERSION 3.17.5) 9 | else() 10 | - cmake_minimum_required(VERSION 2.8.12) 11 | + cmake_minimum_required(VERSION 3.17.5) 12 | endif() 13 | 14 | include(CheckIncludeFiles) 15 | @@ -1469,6 +1469,10 @@ 16 | if(BUILD_SHARED) 17 | target_link_libraries(libzmq ${CMAKE_THREAD_LIBS_INIT}) 18 | 19 | + if(HAVE_CLOCK_GETTIME) 20 | + target_link_libraries(libzmq -lrt) 21 | + endif() 22 | + 23 | if(QNX) 24 | target_link_libraries(libzmq -lsocket) 25 | endif() 26 | -------------------------------------------------------------------------------- /thirdparty/openlipclua/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_ARGS 2 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 3 | -DBUILD_SHARED_LIBS=$> 4 | ) 5 | 6 | list(APPEND BUILD_CMD COMMAND ninja) 7 | 8 | if(MONOLIBTIC) 9 | append_install_commands(INSTALL_CMD liblipc.so libopenlipclua.a DESTINATION ${STAGING_DIR}/lib) 10 | else() 11 | append_binary_install_command(INSTALL_CMD libopenlipclua.so DESTINATION common) 12 | endif() 13 | 14 | external_project( 15 | DOWNLOAD GIT 96c2d16696a482664b4e84eb3b6d851f807a44d1 16 | https://github.com/notmarek/openlipclua.git 17 | CMAKE_ARGS ${CMAKE_ARGS} 18 | BUILD_COMMAND ${BUILD_CMD} 19 | INSTALL_COMMAND ${INSTALL_CMD} 20 | ) 21 | -------------------------------------------------------------------------------- /ffi/posix_types_64b_h.lua: -------------------------------------------------------------------------------- 1 | local ffi = require("ffi") 2 | 3 | ffi.cdef[[ 4 | typedef long int off_t; 5 | typedef long int time_t; 6 | typedef long int suseconds_t; 7 | struct timeval { 8 | time_t tv_sec; 9 | suseconds_t tv_usec; 10 | }; 11 | struct timespec { 12 | time_t tv_sec; 13 | long int tv_nsec; 14 | }; 15 | struct statvfs { 16 | long unsigned int f_bsize; 17 | long unsigned int f_frsize; 18 | long unsigned int f_blocks; 19 | long unsigned int f_bfree; 20 | long unsigned int f_bavail; 21 | long unsigned int f_files; 22 | long unsigned int f_ffree; 23 | long unsigned int f_favail; 24 | long unsigned int f_fsid; 25 | long unsigned int f_flag; 26 | long unsigned int f_namemax; 27 | int __f_spare[6]; 28 | }; 29 | ]] 30 | -------------------------------------------------------------------------------- /ffi/posix_types_x64_h.lua: -------------------------------------------------------------------------------- 1 | local ffi = require("ffi") 2 | 3 | ffi.cdef[[ 4 | typedef long int off_t; 5 | typedef long int time_t; 6 | typedef long int suseconds_t; 7 | struct timeval { 8 | time_t tv_sec; 9 | suseconds_t tv_usec; 10 | }; 11 | struct timespec { 12 | time_t tv_sec; 13 | long int tv_nsec; 14 | }; 15 | struct statvfs { 16 | long unsigned int f_bsize; 17 | long unsigned int f_frsize; 18 | long unsigned int f_blocks; 19 | long unsigned int f_bfree; 20 | long unsigned int f_bavail; 21 | long unsigned int f_files; 22 | long unsigned int f_ffree; 23 | long unsigned int f_favail; 24 | long unsigned int f_fsid; 25 | long unsigned int f_flag; 26 | long unsigned int f_namemax; 27 | int __f_spare[6]; 28 | }; 29 | ]] 30 | -------------------------------------------------------------------------------- /test-runner/busted_config.lua: -------------------------------------------------------------------------------- 1 | local lfs = require("lfs") 2 | 3 | local testsuites = {} 4 | local roots = {} 5 | local lpaths = {} 6 | for entry in lfs.dir("spec") do 7 | local attr = lfs.attributes("spec/" .. entry .. "/unit") 8 | if attr and attr.mode == "directory" then 9 | local testroot = "spec/" .. entry .. "/unit" 10 | local testpath = testroot .. "/?.lua" 11 | testsuites[entry] = {} 12 | testsuites[entry].ROOT = {testroot} 13 | testsuites[entry].lpath = testpath 14 | table.insert(roots, testroot) 15 | table.insert(lpaths, testpath) 16 | end 17 | end 18 | 19 | testsuites.all = { 20 | ROOT = roots, 21 | lpath = table.concat(lpaths, ";"), 22 | } 23 | 24 | return testsuites 25 | -------------------------------------------------------------------------------- /ffi/__gc.lua: -------------------------------------------------------------------------------- 1 | -- This is https://github.com/katlogic/__gc/raw/master/__gc.lua 2 | local rg = assert(rawget) 3 | local proxy_key = "__gc_proxy" 4 | local rs = assert(rawset) 5 | local gmt = assert(debug.getmetatable) 6 | local smt = assert(setmetatable) 7 | local np = assert(newproxy) 8 | 9 | return function(t, mt) 10 | if mt ~= nil and rg(mt, "__gc") and not rg(t, "__gc_proxy") then 11 | local p = np(true) 12 | rs(t, proxy_key, p) 13 | gmt(p).__gc = function() 14 | rs(t, proxy_key, nil) 15 | local nmt = gmt(t) 16 | if not nmt then return end 17 | local fin = rg(nmt, "__gc") 18 | if fin then return fin(t) end 19 | end 20 | end 21 | return smt(t, mt) 22 | end 23 | -------------------------------------------------------------------------------- /ffi/MD5.lua: -------------------------------------------------------------------------------- 1 | --[[-- 2 | MD5 hash library. 3 | 4 | 5 | Deprecated except for sumFile. Use sha2 instead. 6 | 7 | @module ffi.md5 8 | ]] 9 | 10 | local sha2 = require "ffi/sha2" 11 | 12 | local md5 = {} 13 | 14 | --- Calculate md5 sum for a file. 15 | ---- @string filename 16 | ---- @treturn string md5 sum in Lua string 17 | function md5.sumFile(filename) 18 | local update = sha2.md5() 19 | local fd, err = io.open(filename, "rb") 20 | if err ~= nil then 21 | return nil, err 22 | end 23 | while true do 24 | local bytes = fd:read(8192) 25 | if not bytes then 26 | fd:close() 27 | break 28 | end 29 | update(bytes) 30 | end 31 | return update() 32 | end 33 | 34 | return md5 35 | -------------------------------------------------------------------------------- /thirdparty/djvulibre/no_references_to_install_dir.patch: -------------------------------------------------------------------------------- 1 | --- a/libdjvu/DjVuMessage.cpp 2 | +++ b/libdjvu/DjVuMessage.cpp 3 | @@ -117,7 +117,7 @@ static const char localestring[]="locale"; 4 | 5 | 6 | // directory names for searching messages 7 | -#ifdef AUTOCONF 8 | +#if 0//def AUTOCONF 9 | static const char DjVuDataDir[] = DIR_DATADIR "/djvu/osi"; 10 | #endif /* AUTOCONF */ 11 | static const char ModuleDjVuDir[] ="share/djvu/osi"; 12 | @@ -291,7 +291,7 @@ DjVuMessage::GetProfilePaths(void) 13 | appendPath(GURL::UTF8(ProfilesDjVuDir,mpath),pathsmap,paths); 14 | } 15 | #endif 16 | -#if defined(AUTOCONF) 17 | +#if 0//defined(AUTOCONF) 18 | GURL dpath = GURL::Filename::UTF8(DjVuDataDir); 19 | appendPath(dpath,pathsmap,paths); 20 | #endif 21 | -------------------------------------------------------------------------------- /ffi/posix_types_def_h.lua: -------------------------------------------------------------------------------- 1 | local ffi = require("ffi") 2 | 3 | ffi.cdef[[ 4 | typedef long int off_t; 5 | typedef long int time_t; 6 | typedef long int suseconds_t; 7 | struct timeval { 8 | time_t tv_sec; 9 | suseconds_t tv_usec; 10 | }; 11 | struct timespec { 12 | time_t tv_sec; 13 | long int tv_nsec; 14 | }; 15 | struct statvfs { 16 | long unsigned int f_bsize; 17 | long unsigned int f_frsize; 18 | long unsigned int f_blocks; 19 | long unsigned int f_bfree; 20 | long unsigned int f_bavail; 21 | long unsigned int f_files; 22 | long unsigned int f_ffree; 23 | long unsigned int f_favail; 24 | long unsigned int f_fsid; 25 | int __f_unused; 26 | long unsigned int f_flag; 27 | long unsigned int f_namemax; 28 | int __f_spare[6]; 29 | }; 30 | ]] 31 | -------------------------------------------------------------------------------- /ffi/posix_types_x86_h.lua: -------------------------------------------------------------------------------- 1 | local ffi = require("ffi") 2 | 3 | ffi.cdef[[ 4 | typedef long int off_t; 5 | typedef long int time_t; 6 | typedef long int suseconds_t; 7 | struct timeval { 8 | time_t tv_sec; 9 | suseconds_t tv_usec; 10 | }; 11 | struct timespec { 12 | time_t tv_sec; 13 | long int tv_nsec; 14 | }; 15 | struct statvfs { 16 | long unsigned int f_bsize; 17 | long unsigned int f_frsize; 18 | long unsigned int f_blocks; 19 | long unsigned int f_bfree; 20 | long unsigned int f_bavail; 21 | long unsigned int f_files; 22 | long unsigned int f_ffree; 23 | long unsigned int f_favail; 24 | long unsigned int f_fsid; 25 | int __f_unused; 26 | long unsigned int f_flag; 27 | long unsigned int f_namemax; 28 | int __f_spare[6]; 29 | }; 30 | ]] 31 | -------------------------------------------------------------------------------- /spec/unit/nnsvg_spec.lua: -------------------------------------------------------------------------------- 1 | describe("nnsvg library", function() 2 | it("should load libkoreader-nnsvg library", function() 3 | local NnSVG = require("libs/libkoreader-nnsvg") 4 | assert.are_not.equal(NnSVG, nil) 5 | assert.are_not.equal(NnSVG.new, nil) 6 | end) 7 | 8 | describe("NnSVG.new", function() 9 | it("should parse SVG image", function() 10 | local svg_file = "spec/base/unit/data/simple.svg" 11 | local NnSVG = require("libs/libkoreader-nnsvg") 12 | local svg_image = NnSVG.new(svg_file) 13 | local native_w, native_h = svg_image:getSize() 14 | assert.are.equal(native_w, 744) 15 | assert.are.equal(native_h, 1052) 16 | end) 17 | 18 | end) 19 | end) 20 | -------------------------------------------------------------------------------- /thirdparty/kobo-usbms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build in source tree. 2 | set(BINARY_DIR ${SOURCE_DIR}) 3 | 4 | list(APPEND BUILD_CMD COMMAND make CROSS_TC=${CHOST}) 5 | append_autotools_vars(BUILD_CMD) 6 | # Make sure the binaries in the `KoboUSBMS.tar.gz` archive are stripped. 7 | list(APPEND BUILD_CMD "STRIP=${STRIP} --strip-unneeded") 8 | list(APPEND BUILD_CMD kobo) 9 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") 10 | list(APPEND BUILD_CMD DEBUG=1) 11 | endif() 12 | 13 | append_install_commands(INSTALL_CMD ${CMAKE_BUILD_TYPE}/KoboUSBMS.tar.gz DESTINATION data) 14 | 15 | external_project( 16 | DOWNLOAD GIT a35a8f639699deaae2e2ee446b5f6c2d2096c1bb 17 | https://github.com/koreader/KoboUSBMS.git 18 | BUILD_COMMAND ${BUILD_CMD} 19 | INSTALL_COMMAND ${INSTALL_CMD} 20 | ) 21 | -------------------------------------------------------------------------------- /thirdparty/minizip/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) 2 | 3 | list(APPEND BUILD_CMD COMMAND ninja) 4 | 5 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 6 | 7 | external_project( 8 | # NOTE: 53a657318af1fccc4bac7ed230729302b2391d1d is the tip 9 | # of the 1.2 branch. The fcrypt API we need is gone in master. 10 | # FIXME: Even then, something in said branch seems to upset MuPDF 11 | # with our custom patch as-is, so keep using the current code... 12 | DOWNLOAD GIT 0b46a2b4ca317b80bc53594688883f7188ac4d08 13 | https://github.com/nmoinvaz/minizip 14 | PATCH_OVERLAY overlay 15 | CMAKE_ARGS ${CMAKE_ARGS} 16 | BUILD_COMMAND ${BUILD_CMD} 17 | INSTALL_COMMAND ${INSTALL_CMD} 18 | ) 19 | -------------------------------------------------------------------------------- /thirdparty/sdcv/compat_with_newer_glib.patch: -------------------------------------------------------------------------------- 1 | --- i/src/stardict_lib.cpp 2 | +++ w/src/stardict_lib.cpp 3 | @@ -1047,9 +1047,9 @@ 4 | } 5 | // Upper the first character and lower others. 6 | if (!bFound) { 7 | - gchar *nextchar = g_utf8_next_char(sWord); 8 | - gchar *firstchar = g_utf8_strup(sWord, nextchar - sWord); 9 | - nextchar = g_utf8_strdown(nextchar, -1); 10 | + size_t nextchar_pos = g_utf8_next_char(sWord) - sWord; 11 | + gchar *firstchar = g_utf8_strup(sWord, nextchar_pos); 12 | + gchar *nextchar = g_utf8_strdown(sWord + nextchar_pos, -1); 13 | casestr = g_strdup_printf("%s%s", firstchar, nextchar); 14 | g_free(firstchar); 15 | g_free(nextchar); 16 | 17 | -------------------------------------------------------------------------------- /ffi-cdecl/mxcfb_sony_decl.c: -------------------------------------------------------------------------------- 1 | // standard Linux framebuffer headers 2 | #include 3 | 4 | #include 5 | // specialized eink framebuffer headers 6 | #include "include/mxcfb-sony.h" 7 | 8 | #include "ffi-cdecl.h" 9 | 10 | cdecl_const(UPDATE_MODE_PARTIAL) 11 | cdecl_const(UPDATE_MODE_FULL) 12 | 13 | cdecl_const(WAVEFORM_MODE_AUTO) 14 | cdecl_const(TEMP_USE_AMBIENT) 15 | 16 | cdecl_const(EPDC_FLAG_ENABLE_INVERSION) 17 | cdecl_const(EPDC_FLAG_FORCE_MONOCHROME) 18 | cdecl_const(EPDC_FLAG_USE_ALT_BUFFER) 19 | cdecl_const(EPDC_FLAG_SP1_1) 20 | cdecl_const(EPDC_FLAG_SP1_2) 21 | 22 | cdecl_struct(mxcfb_rect) 23 | cdecl_struct(mxcfb_alt_buffer_data) 24 | cdecl_struct(mxcfb_update_data) 25 | 26 | cdecl_const(MXCFB_SEND_UPDATE) 27 | 28 | cdecl_const(MXCFB_WAIT_FOR_UPDATE_COMPLETE) 29 | -------------------------------------------------------------------------------- /thirdparty/srell/readme_en.txt: -------------------------------------------------------------------------------- 1 | How to Use 2 | 3 | Put the following three files in one directory, and include srell.hpp. 4 | 1. srell.hpp 5 | 2. srell_ucfdata2.hpp (data for case folding) 6 | 3. srell_updata.hpp (data for Unicode properties) 7 | 8 | The files in the following directories are supplements. As SRELL does not use 9 | them, it is safe to remove them. 10 | 11 | * misc 12 | Contains a source code file for a simple test and benchmark program. 13 | 14 | * single-header 15 | Contains a standalone version of srell.hpp into which srell_ucfdata2.hpp 16 | and srell_updata.hpp have been merged. 17 | 18 | * unicode 19 | Contains source code files for programs that generate srell_ucfdata.hpp and 20 | srell_update.hpp from latest Unicode data text files. 21 | 22 | -------------------------------------------------------------------------------- /thirdparty/curl/no_glibc_2.6_or_above_symbols.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -1796,8 +1796,6 @@ 4 | check_symbol_exists("getifaddrs" "${CURL_INCLUDES};stdlib.h" HAVE_GETIFADDRS) # ifaddrs.h 5 | check_symbol_exists("freeaddrinfo" "${CURL_INCLUDES}" HAVE_FREEADDRINFO) # ws2tcpip.h sys/socket.h netdb.h 6 | check_function_exists("pipe" HAVE_PIPE) 7 | -check_function_exists("pipe2" HAVE_PIPE2) 8 | -check_function_exists("eventfd" HAVE_EVENTFD) 9 | check_symbol_exists("ftruncate" "unistd.h" HAVE_FTRUNCATE) 10 | check_symbol_exists("getpeername" "${CURL_INCLUDES}" HAVE_GETPEERNAME) # winsock2.h unistd.h proto/bsdsocket.h 11 | check_symbol_exists("getsockname" "${CURL_INCLUDES}" HAVE_GETSOCKNAME) # winsock2.h unistd.h proto/bsdsocket.h 12 | -------------------------------------------------------------------------------- /.ci/common.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | set -o pipefail 5 | 6 | ANSI_RED="\033[31;1m" 7 | # shellcheck disable=SC2034 8 | ANSI_GREEN="\033[32;1m" 9 | ANSI_RESET="\033[0m" 10 | 11 | travis_retry() { 12 | local result=0 13 | local count=1 14 | set +e 15 | 16 | while [ ${count} -le 3 ]; do 17 | [ ${result} -ne 0 ] && { 18 | echo -e "\n${ANSI_RED}The command \"$*\" failed. Retrying, ${count} of 3.${ANSI_RESET}\n" >&2 19 | } 20 | "$@" 21 | result=$? 22 | [ ${result} -eq 0 ] && break 23 | count=$((count + 1)) 24 | sleep 1 25 | done 26 | 27 | [ ${count} -gt 3 ] && { 28 | echo -e "\n${ANSI_RED}The command \"$*\" failed 3 times.${ANSI_RESET}\n" >&2 29 | } 30 | 31 | set -e 32 | return ${result} 33 | } 34 | -------------------------------------------------------------------------------- /spec/unit/framebuffer_spec.lua: -------------------------------------------------------------------------------- 1 | describe("Framebuffer unit tests", function() 2 | local fb 3 | 4 | setup(function() 5 | fb = require("ffi/framebuffer_dummy"):new{ 6 | dummy = true, 7 | device = { 8 | device_dpi = 167, 9 | } 10 | } 11 | end) 12 | 13 | it("should set & update DPI", function() 14 | assert.are.equals(160, fb:getDPI()) 15 | 16 | fb:setDPI(120) 17 | assert.are.equals(120, fb:getDPI()) 18 | 19 | fb:setDPI(60) 20 | assert.are.equals(60, fb:getDPI()) 21 | end) 22 | 23 | it("should scale by DPI", function() 24 | fb:setDPI(167) 25 | assert.are.equals(31, fb:scaleBySize(30)) 26 | 27 | fb:setDPI(167 * 3) 28 | assert.are.equals(62, fb:scaleBySize(30)) 29 | end) 30 | end) 31 | -------------------------------------------------------------------------------- /ffi-cdecl/tffi_wrap_cdecl.c: -------------------------------------------------------------------------------- 1 | #include "http-parser/http_parser.h" 2 | #include "turbo_ffi_wrap.h" 3 | 4 | #include "ffi-cdecl.h" 5 | 6 | cdecl_func(http_body_is_final) 7 | cdecl_func(http_errno_description) 8 | cdecl_func(http_errno_name) 9 | cdecl_func(http_method_str) 10 | cdecl_func(http_parser_execute) 11 | cdecl_func(http_parser_init) 12 | cdecl_func(http_parser_parse_url) 13 | cdecl_func(http_parser_pause) 14 | cdecl_func(http_parser_settings_init) 15 | cdecl_func(http_parser_url_init) 16 | cdecl_func(http_parser_version) 17 | cdecl_func(http_should_keep_alive) 18 | cdecl_func(turbo_bswap_u64) 19 | cdecl_func(turbo_parser_check) 20 | cdecl_func(turbo_parser_wrapper_exit) 21 | cdecl_func(turbo_parser_wrapper_init) 22 | cdecl_func(turbo_websocket_mask) 23 | cdecl_func(url_field) 24 | cdecl_func(url_field_is_set) 25 | cdecl_func(validate_hostname) 26 | -------------------------------------------------------------------------------- /thirdparty/popen-noshell/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(LEGACY) 2 | # Revert 8d7a98d on legacy devices, pipe2 was introduced in Linux 2.6.27 & glibc 2.9 3 | list(APPEND PATCH_FILES kindle_legacy.patch) 4 | endif() 5 | 6 | list(APPEND CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) 7 | 8 | list(APPEND BUILD_CMD COMMAND ninja) 9 | 10 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 11 | 12 | external_project( 13 | # NOTE: As of right now (1f9eaf4eeef348d1efe0f3c7fe8ab670653cfbb1), 14 | # wait until stuff settles down before bumping this. 15 | DOWNLOAD GIT e715396a4951ee91c40a98d2824a130f158268bb 16 | https://github.com/famzah/popen-noshell.git 17 | PATCH_OVERLAY overlay 18 | PATCH_FILES ${PATCH_FILES} 19 | CMAKE_ARGS ${CMAKE_ARGS} 20 | BUILD_COMMAND ${BUILD_CMD} 21 | INSTALL_COMMAND ${INSTALL_CMD} 22 | ) 23 | -------------------------------------------------------------------------------- /.ci/test_script.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 4 | # shellcheck source=/dev/null 5 | source "${CI_DIR}/common.sh" 6 | 7 | exit_code=0 8 | 9 | echo -e "${ANSI_GREEN}Bincheck results${ANSI_RESET}" 10 | make bincheck || exit_code=1 11 | 12 | if [ "${EMULATE_READER}" = "1" ]; then 13 | echo -e "\n${ANSI_GREEN}Testsuite${ANSI_RESET}" 14 | ( 15 | # install test data 16 | travis_retry make test-data 17 | # finally make test 18 | travis_retry make --assume-old=all test T="-o '${PWD}/test-results.xml'" 19 | ) || exit_code=1 20 | else 21 | if [ "${TARGET}" = "android" ] && [ -f build/luajit ]; then 22 | echo -e "\n${ANSI_RED}ERROR${ANSI_RESET}: android build should not include luajit binary." 23 | exit_code=1 24 | fi 25 | fi 26 | 27 | exit ${exit_code} 28 | -------------------------------------------------------------------------------- /thirdparty/libressl/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | --- i/CMakeLists.txt 2 | +++ w/CMakeLists.txt 3 | @@ -13,7 +13,7 @@ 4 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 5 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 6 | 7 | -cmake_minimum_required (VERSION 3.16.4) 8 | +cmake_minimum_required (VERSION 3.17.5) 9 | 10 | if(MSVC) 11 | cmake_policy(SET CMP0091 NEW) 12 | @@ -569,8 +569,8 @@ 13 | # Create pkgconfig files. 14 | set(prefix ${CMAKE_INSTALL_PREFIX}) 15 | set(exec_prefix \${prefix}) 16 | - set(libdir \${exec_prefix}/${CMAKE_INSTALL_LIBDIR}) 17 | - set(includedir \${prefix}/${CMAKE_INSTALL_INCLUDEDIR}) 18 | + set(libdir \${exec_prefix}/lib) 19 | + set(includedir \${prefix}/include) 20 | if(PLATFORM_LIBS) 21 | string(REGEX REPLACE ";" " -l" PLATFORM_LDADD ";${PLATFORM_LIBS}") 22 | endif() 23 | -------------------------------------------------------------------------------- /thirdparty/harfbuzz/no-subset.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/meson.build b/src/meson.build 2 | index 44c858c04..068b31a18 100644 3 | --- a/src/meson.build 4 | +++ b/src/meson.build 5 | @@ -673,7 +673,7 @@ defs_list += [harfbuzz_subset_def] 6 | 7 | libharfbuzz_subset = library('harfbuzz-subset', hb_subset_sources, 8 | include_directories: incconfig, 9 | - dependencies: [m_dep], 10 | + dependencies: [m_dep, disabler()], 11 | link_with: [libharfbuzz], 12 | cpp_args: cpp_args + extra_hb_cpp_args, 13 | soversion: hb_so_version, 14 | @@ -684,7 +684,7 @@ libharfbuzz_subset = library('harfbuzz-subset', hb_subset_sources, 15 | ) 16 | 17 | custom_target('harfbuzz-subset.cc', 18 | - build_by_default: true, 19 | + build_by_default: false, 20 | output: 'harfbuzz-subset.cc', 21 | input: hb_base_sources + hb_subset_sources, 22 | command: [find_program('gen-harfbuzzcc.py'), 23 | -------------------------------------------------------------------------------- /thirdparty/lpeg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES luajit.patch) 2 | 3 | list(APPEND CMAKE_ARGS 4 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 5 | -DBUILD_SHARED_LIBS=$> 6 | ) 7 | 8 | list(APPEND BUILD_CMD COMMAND ninja) 9 | 10 | if(MONOLIBTIC) 11 | append_install_commands(INSTALL_CMD lpeg.a DESTINATION ${STAGING_DIR}/lib) 12 | else() 13 | append_binary_install_command(INSTALL_CMD lpeg.so DESTINATION common) 14 | endif() 15 | append_install_commands(INSTALL_CMD ${SOURCE_DIR}/re.lua DESTINATION common) 16 | 17 | external_project( 18 | DOWNLOAD URL 842a538b403b5639510c9b6fffd2c75b 19 | http://distcache.FreeBSD.org/ports-distfiles/lpeg-1.1.0.tar.gz 20 | PATCH_OVERLAY overlay 21 | PATCH_FILES ${PATCH_FILES} 22 | CMAKE_ARGS ${CMAKE_ARGS} 23 | BUILD_COMMAND ${BUILD_CMD} 24 | INSTALL_COMMAND ${INSTALL_CMD} 25 | ) 26 | -------------------------------------------------------------------------------- /thirdparty/fribidi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CFG_CMD COMMAND 2 | ${MESON_SETUP} --default-library=$,static,shared> 3 | -Dbin=false 4 | -Ddocs=false 5 | -Dtests=false 6 | ${SOURCE_DIR} 7 | ) 8 | 9 | list(APPEND BUILD_CMD COMMAND ninja) 10 | 11 | list(APPEND INSTALL_CMD COMMAND ${MESON_INSTALL}) 12 | 13 | if(NOT MONOLIBTIC) 14 | set(LIB_SPEC fribidi VERSION 0) 15 | if(APPLE) 16 | append_shared_lib_fix_commands(INSTALL_CMD ${LIB_SPEC} ID) 17 | endif() 18 | append_shared_lib_install_commands(INSTALL_CMD ${LIB_SPEC}) 19 | endif() 20 | 21 | external_project( 22 | DOWNLOAD URL 333ad150991097a627755b752b87f9ff 23 | https://github.com/fribidi/fribidi/releases/download/v1.0.16/fribidi-1.0.16.tar.xz 24 | CONFIGURE_COMMAND ${CFG_CMD} 25 | BUILD_COMMAND ${BUILD_CMD} 26 | INSTALL_COMMAND ${INSTALL_CMD} 27 | ) 28 | -------------------------------------------------------------------------------- /thirdparty/lua-rapidjson/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES cmake_tweaks.patch) 2 | 3 | list(APPEND CMAKE_ARGS 4 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 5 | -DBUILD_SHARED_LIBS=$> 6 | # Project options. 7 | -DLUA_INCLUDE_DIR=${LUAJIT_INC} 8 | -DLUA_LIBRARIES=${LUAJIT_LIB} 9 | ) 10 | 11 | list(APPEND BUILD_CMD COMMAND ninja) 12 | 13 | if(MONOLIBTIC) 14 | append_install_commands(INSTALL_CMD rapidjson.a DESTINATION ${STAGING_DIR}/lib) 15 | else() 16 | append_binary_install_command(INSTALL_CMD rapidjson.so DESTINATION common) 17 | endif() 18 | 19 | external_project( 20 | DOWNLOAD GIT e84973356255bde06a70ce6263a3a0ef5c8f4ad4 21 | https://github.com/NiLuJe/lua-rapidjson 22 | PATCH_FILES ${PATCH_FILES} 23 | CMAKE_ARGS ${CMAKE_ARGS} 24 | BUILD_COMMAND ${BUILD_CMD} 25 | INSTALL_COMMAND ${INSTALL_CMD} 26 | ) 27 | -------------------------------------------------------------------------------- /ffi/ion_kobo_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | typedef int ion_user_handle_t; 7 | struct ion_allocation_data { 8 | size_t len; 9 | size_t align; 10 | unsigned int heap_id_mask; 11 | unsigned int flags; 12 | ion_user_handle_t handle; 13 | }; 14 | struct ion_fd_data { 15 | ion_user_handle_t handle; 16 | int fd; 17 | }; 18 | struct ion_handle_data { 19 | ion_user_handle_t handle; 20 | }; 21 | static const int ION_IOC_ALLOC = 3222554880; 22 | static const int ION_IOC_FREE = 3221506305; 23 | static const int ION_IOC_MAP = 3221768450; 24 | enum ion_heap_mask { 25 | ION_HEAP_MASK_SYSTEM = 1, 26 | ION_HEAP_MASK_SYSTEM_CONTIG = 2, 27 | ION_HEAP_MASK_CARVEOUT = 4, 28 | ION_HEAP_MASK_CHUNK = 8, 29 | ION_HEAP_MASK_DMA = 16, 30 | ION_HEAP_MASK_CUSTOM = 32, 31 | ION_HEAP_MASK_SECURE = 64, 32 | }; 33 | ]] 34 | -------------------------------------------------------------------------------- /thirdparty/dropbear/dbscp-path.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/svr-chansession.c b/src/svr-chansession.c 2 | index 11205f3..c5578fe 100644 3 | --- a/src/svr-chansession.c 4 | +++ b/src/svr-chansession.c 5 | @@ -682,6 +682,17 @@ static int sessioncommand(struct Channel *channel, struct ChanSess *chansess, 6 | TRACE(("leave sessioncommand, command too long %d", cmdlen)) 7 | return DROPBEAR_FAILURE; 8 | } 9 | + 10 | +#ifdef DBSCP_PATH 11 | + // HACK. This is terrible. Truly, truly awful. 12 | + if (strncmp(chansess->cmd, "scp", 3) == 0) { 13 | + char* mangled_cmd = m_malloc(cmdlen + sizeof(DBSCP_PATH)); 14 | + snprintf(mangled_cmd, cmdlen + sizeof(DBSCP_PATH) + 1, "%s/%s", DBSCP_PATH, chansess->cmd); 15 | + m_free(chansess->cmd); 16 | + chansess->cmd = m_strdup(mangled_cmd); 17 | + m_free(mangled_cmd); 18 | + } 19 | +#endif 20 | } 21 | if (issubsys) { 22 | #if DROPBEAR_SFTPSERVER 23 | -------------------------------------------------------------------------------- /thirdparty/giflib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(ANDROID) 2 | # Use `limits.h` instead of `stdint.h`. 3 | list(APPEND PATCH_CMD COMMAND ${ISED} "s|stdint.h|limits.h|g" openbsd-reallocarray.c) 4 | endif() 5 | 6 | list(APPEND CMAKE_ARGS 7 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 8 | -DBUILD_SHARED_LIBS=$> 9 | ) 10 | 11 | list(APPEND BUILD_CMD COMMAND ninja) 12 | 13 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 14 | 15 | if(NOT MONOLIBTIC) 16 | append_shared_lib_install_commands(INSTALL_CMD gif VERSION 7) 17 | endif() 18 | 19 | external_project( 20 | DOWNLOAD URL 913dd251492134e235ee3c9a91987a4d 21 | https://sourceforge.net/projects/giflib/files/giflib-5.2.2.tar.gz 22 | PATCH_OVERLAY overlay 23 | PATCH_COMMAND ${PATCH_CMD} 24 | CMAKE_ARGS ${CMAKE_ARGS} 25 | BUILD_COMMAND ${BUILD_CMD} 26 | INSTALL_COMMAND ${INSTALL_CMD} 27 | ) 28 | -------------------------------------------------------------------------------- /thirdparty/sdcv/sdcv-no-unknown-dict-warning.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/sdcv.cpp b/src/sdcv.cpp 2 | index 3a10e3c..46db492 100644 3 | --- a/src/sdcv.cpp 4 | +++ b/src/sdcv.cpp 5 | @@ -190,8 +190,6 @@ try { 6 | auto it = bookname_to_ifo.find(*p); 7 | if (it != bookname_to_ifo.end()) { 8 | order_list.push_back(it->second); 9 | - } else { 10 | - fprintf(stderr, _("Unknown dictionary: %s\n"), *p); 11 | } 12 | } 13 | } else { 14 | @@ -207,8 +205,6 @@ try { 15 | auto it = bookname_to_ifo.find(line); 16 | if (it != bookname_to_ifo.end()) { 17 | order_list.push_back(it->second); 18 | - } else { 19 | - fprintf(stderr, _("Unknown dictionary: %s\n"), line.c_str()); 20 | } 21 | } 22 | fclose(ordering_file); 23 | -------------------------------------------------------------------------------- /ffi/zstd_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | static const int ZSTD_CLEVEL_DEFAULT = 3; 7 | size_t ZSTD_compress(void *, size_t, const void *, size_t, int); 8 | size_t ZSTD_decompress(void *, size_t, const void *, size_t); 9 | long long unsigned int ZSTD_getFrameContentSize(const void *, size_t); 10 | size_t ZSTD_compressBound(size_t); 11 | unsigned int ZSTD_isError(size_t); 12 | const char *ZSTD_getErrorName(size_t); 13 | typedef struct ZSTD_DCtx_s ZSTD_DCtx; 14 | typedef enum { 15 | ZSTD_reset_session_only = 1, 16 | ZSTD_reset_parameters = 2, 17 | ZSTD_reset_session_and_parameters = 3, 18 | } ZSTD_ResetDirective; 19 | ZSTD_DCtx *ZSTD_createDCtx(void); 20 | size_t ZSTD_freeDCtx(ZSTD_DCtx *); 21 | size_t ZSTD_decompressDCtx(ZSTD_DCtx *, void *, size_t, const void *, size_t); 22 | size_t ZSTD_DCtx_reset(ZSTD_DCtx *, ZSTD_ResetDirective); 23 | ]] 24 | -------------------------------------------------------------------------------- /thirdparty/tesseract/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES 2 | k2pdfopt.patch 3 | cmake_tweaks.patch 4 | no_debug_fonts.patch 5 | ) 6 | 7 | list(APPEND CMAKE_ARGS 8 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 9 | # Project options. 10 | -DANDROID=${ANDROID} 11 | -DBUILD_TRAINING_TOOLS=FALSE 12 | -DDISABLE_ARCHIVE=TRUE 13 | -DDISABLE_CURL=TRUE 14 | -DDISABLE_TIFF=TRUE 15 | -DGRAPHICS_DISABLED=TRUE 16 | -DINSTALL_CONFIGS=FALSE 17 | ) 18 | 19 | list(APPEND BUILD_CMD COMMAND ninja) 20 | 21 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 22 | 23 | external_project( 24 | DOWNLOAD URL dbc5e603ddde25bdec84c30ac47a2afb 25 | https://github.com/tesseract-ocr/tesseract/archive/refs/tags/5.5.1.tar.gz 26 | PATCH_FILES ${PATCH_FILES} 27 | CMAKE_ARGS ${CMAKE_ARGS} 28 | BUILD_COMMAND ${BUILD_CMD} 29 | INSTALL_COMMAND ${INSTALL_CMD} 30 | ) 31 | -------------------------------------------------------------------------------- /thirdparty/luasec/overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(luasec LANGUAGES C) 3 | 4 | find_package(PkgConfig REQUIRED) 5 | pkg_check_modules(LuaJIT luajit REQUIRED IMPORTED_TARGET) 6 | pkg_check_modules(OpenSSL openssl REQUIRED IMPORTED_TARGET) 7 | 8 | if(BUILD_SHARED_LIBS) 9 | add_library(ssl MODULE) 10 | else() 11 | add_library(ssl STATIC) 12 | endif() 13 | set_target_properties(ssl PROPERTIES C_VISIBILITY_PRESET hidden PREFIX "") 14 | target_compile_definitions(ssl PRIVATE -DWITH_LUASOCKET) 15 | target_include_directories(ssl PRIVATE ${CMAKE_INSTALL_PREFIX}/include) 16 | target_link_libraries(ssl PRIVATE 17 | ${CMAKE_INSTALL_PREFIX}/lib/libluasocket.a 18 | PkgConfig::LuaJIT 19 | PkgConfig::OpenSSL 20 | ) 21 | target_sources(ssl PRIVATE 22 | src/options.c 23 | src/x509.c 24 | src/context.c 25 | src/ssl.c 26 | src/config.c 27 | src/ec.c 28 | ) 29 | -------------------------------------------------------------------------------- /thirdparty/luasocket/enforce-cloexec.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/usocket.c b/src/usocket.c 2 | index 7965db6..fc1f607 100644 3 | --- a/src/usocket.c 4 | +++ b/src/usocket.c 5 | @@ -122,8 +122,15 @@ int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds, 6 | \*-------------------------------------------------------------------------*/ 7 | int socket_create(p_socket ps, int domain, int type, int protocol) { 8 | *ps = socket(domain, type, protocol); 9 | - if (*ps != SOCKET_INVALID) return IO_DONE; 10 | - else return errno; 11 | + if (*ps != SOCKET_INVALID) { 12 | + // Enforce CLOEXEC 13 | + int flags = fcntl(*ps, F_GETFD, 0); 14 | + flags |= O_CLOEXEC; 15 | + fcntl(*ps, F_SETFD, flags); 16 | + return IO_DONE; 17 | + } else { 18 | + return errno; 19 | + } 20 | } 21 | 22 | /*-------------------------------------------------------------------------*\ 23 | -------------------------------------------------------------------------------- /thirdparty/lunasvg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES 2 | cmake_tweaks.patch 3 | extended.patch 4 | ) 5 | 6 | list(APPEND CMAKE_ARGS 7 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 8 | -DBUILD_SHARED_LIBS=$> 9 | # Project options. 10 | -DXTENDED_DIR=${CMAKE_CURRENT_SOURCE_DIR}/xtended 11 | ) 12 | 13 | list(APPEND BUILD_CMD COMMAND ninja) 14 | 15 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 16 | 17 | if(NOT MONOLIBTIC) 18 | append_shared_lib_install_commands(INSTALL_CMD lunasvg) 19 | endif() 20 | 21 | external_project( 22 | DOWNLOAD GIT 59d6f6ba835c1b7c7a0f9d4ea540ec3981777885 23 | https://github.com/sammycage/lunasvg.git 24 | PATCH_FILES ${PATCH_FILES} 25 | CMAKE_ARGS ${CMAKE_ARGS} 26 | BUILD_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/xtended/* 27 | BUILD_COMMAND ${BUILD_CMD} 28 | INSTALL_COMMAND ${INSTALL_CMD} 29 | ) 30 | -------------------------------------------------------------------------------- /ffi-cdecl/libwebp_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "ffi-cdecl.h" 6 | 7 | cdecl_const(WEBP_DEMUX_ABI_VERSION) 8 | cdecl_enum(WEBP_CSP_MODE) 9 | 10 | cdecl_struct(WebPData) 11 | cdecl_type(WebPData) 12 | 13 | cdecl_struct(WebPAnimInfo) 14 | cdecl_type(WebPAnimInfo) 15 | 16 | cdecl_struct(WebPAnimDecoderOptions) 17 | cdecl_type(WebPAnimDecoderOptions) 18 | // cdecl_func(WebPAnimDecoderOptionsInit) // inline in demux.h 19 | cdecl_func(WebPAnimDecoderOptionsInitInternal) // we need to use this one 20 | 21 | cdecl_struct(WebPAnimDecoder) 22 | cdecl_type(WebPAnimDecoder) 23 | // cdecl_func(WebPAnimDecoderNew) // inline in demux.h 24 | cdecl_func(WebPAnimDecoderNewInternal) // we need to use this one 25 | cdecl_func(WebPAnimDecoderGetInfo) 26 | cdecl_func(WebPAnimDecoderGetNext) 27 | cdecl_func(WebPAnimDecoderReset) 28 | cdecl_func(WebPAnimDecoderDelete) 29 | -------------------------------------------------------------------------------- /thirdparty/luasec/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES visibility.patch) 2 | 3 | list(APPEND CMAKE_ARGS 4 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 5 | -DBUILD_SHARED_LIBS=$> 6 | ) 7 | 8 | list(APPEND BUILD_CMD COMMAND ninja) 9 | 10 | if(MONOLIBTIC) 11 | append_install_commands(INSTALL_CMD ssl.a DESTINATION ${STAGING_DIR}/lib) 12 | else() 13 | append_binary_install_command(INSTALL_CMD ssl.so DESTINATION common) 14 | endif() 15 | append_install_commands(INSTALL_CMD ${SOURCE_DIR}/src/ssl.lua DESTINATION common) 16 | append_install_commands(INSTALL_CMD ${SOURCE_DIR}/src/https.lua DESTINATION common/ssl) 17 | 18 | external_project( 19 | DOWNLOAD GIT v1.3.2 20 | https://github.com/brunoos/luasec 21 | PATCH_OVERLAY overlay 22 | PATCH_FILES ${PATCH_FILES} 23 | CMAKE_ARGS ${CMAKE_ARGS} 24 | BUILD_COMMAND ${BUILD_CMD} 25 | INSTALL_COMMAND ${INSTALL_CMD} 26 | ) 27 | -------------------------------------------------------------------------------- /thirdparty/libiconv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CFG_CMD COMMAND env) 2 | append_autotools_vars(CFG_CMD) 3 | list(APPEND CFG_CMD 4 | ${SOURCE_DIR}/configure --host=${CHOST} --prefix=/ 5 | --enable-shared=false --enable-static=true 6 | --disable-nls 7 | --with-threads=none 8 | ) 9 | 10 | list(APPEND BUILD_CMD COMMAND make) 11 | 12 | list(APPEND INSTALL_CMD COMMAND make DESTDIR=${STAGING_DIR} install) 13 | # Get rid of libtool crap… 14 | list(APPEND INSTALL_CMD COMMAND rm -f ${STAGING_DIR}/lib/libiconv.la ${STAGING_DIR}/lib/libcharset.la) 15 | 16 | external_project( 17 | DOWNLOAD URL ace8b5f2db42f7b3b3057585e80d9808 18 | http://ftpmirror.gnu.org/libiconv/libiconv-1.15.tar.gz 19 | https://ftp.wayne.edu/gnu/libiconv/libiconv-1.15.tar.gz 20 | http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz 21 | CONFIGURE_COMMAND ${CFG_CMD} 22 | BUILD_COMMAND ${BUILD_CMD} 23 | INSTALL_COMMAND ${INSTALL_CMD} 24 | ) 25 | -------------------------------------------------------------------------------- /thirdparty/luajit/koreader-luajit-enable-table_pack.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/lib_table.c b/src/lib_table.c 2 | index d159360b..a3f146ce 100644 3 | --- a/src/lib_table.c 4 | +++ b/src/lib_table.c 5 | @@ -267,7 +267,6 @@ LJLIB_CF(table_sort) 6 | return 0; 7 | } 8 | 9 | -#if LJ_52 10 | LJLIB_PUSH("n") 11 | LJLIB_CF(table_pack) 12 | { 13 | @@ -283,7 +282,6 @@ LJLIB_CF(table_pack) 14 | lj_gc_check(L); 15 | return 1; 16 | } 17 | -#endif 18 | 19 | LJLIB_NOREG LJLIB_CF(table_new) LJLIB_REC(.) 20 | { 21 | @@ -316,10 +314,8 @@ static int luaopen_table_clear(lua_State *L) 22 | LUALIB_API int luaopen_table(lua_State *L) 23 | { 24 | LJ_LIB_REG(L, LUA_TABLIBNAME, table); 25 | -#if LJ_52 26 | lua_getglobal(L, "unpack"); 27 | lua_setfield(L, -2, "unpack"); 28 | -#endif 29 | lj_lib_prereg(L, LUA_TABLIBNAME ".new", luaopen_table_new, tabV(L->top-1)); 30 | lj_lib_prereg(L, LUA_TABLIBNAME ".clear", luaopen_table_clear, tabV(L->top-1)); 31 | return 1; 32 | -------------------------------------------------------------------------------- /ffi/crypto_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | int PKCS5_PBKDF2_HMAC_SHA1(const char *, int, const unsigned char *, int, int, int, unsigned char *); 7 | struct evp_cipher_ctx_st *EVP_CIPHER_CTX_new(void); 8 | void EVP_CIPHER_CTX_free(struct evp_cipher_ctx_st *); 9 | int EVP_CIPHER_CTX_set_padding(struct evp_cipher_ctx_st *, int); 10 | int EVP_CIPHER_block_size(const struct evp_cipher_st *); 11 | int EVP_DecryptInit_ex(struct evp_cipher_ctx_st *, const struct evp_cipher_st *, struct engine_st *, const unsigned char *, const unsigned char *); 12 | int EVP_DecryptUpdate(struct evp_cipher_ctx_st *, unsigned char *, int *, const unsigned char *, int); 13 | int EVP_DecryptFinal_ex(struct evp_cipher_ctx_st *, unsigned char *, int *); 14 | const struct evp_cipher_st *EVP_aes_128_ecb(void); 15 | const struct evp_cipher_st *EVP_aes_192_ecb(void); 16 | const struct evp_cipher_st *EVP_aes_256_ecb(void); 17 | ]] 18 | -------------------------------------------------------------------------------- /ffi/zlib.lua: -------------------------------------------------------------------------------- 1 | --[[-- 2 | LuaJIT FFI wrapper for zlib. 3 | 4 | @module ffi.zlib 5 | ]] 6 | 7 | local ffi = require("ffi") 8 | require("ffi/zlib_h") 9 | 10 | local libz = ffi.loadlib("z", 1) 11 | 12 | local zlib = {} 13 | 14 | -- Data compression/decompression of strings via zlib 15 | -- from http://luajit.org/ext_ffi_tutorial.html 16 | function zlib.zlib_compress(data) 17 | local n = libz.compressBound(#data) 18 | local buf = ffi.new("uint8_t[?]", n) 19 | local buflen = ffi.new("unsigned long[1]", n) 20 | local res = libz.compress2(buf, buflen, data, #data, 9) 21 | assert(res == 0) 22 | return ffi.string(buf, buflen[0]) 23 | end 24 | 25 | function zlib.zlib_uncompress(zdata, datalen) 26 | local buf = ffi.new("uint8_t[?]", datalen) 27 | local buflen = ffi.new("unsigned long[1]", datalen) 28 | local res = libz.uncompress(buf, buflen, zdata, #zdata) 29 | assert(res == 0) 30 | return ffi.string(buf, buflen[0]) 31 | end 32 | 33 | return zlib 34 | -------------------------------------------------------------------------------- /thirdparty/curl/use_-pthread.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -590,6 +590,7 @@ 4 | if(WIN32) 5 | set(USE_THREADS_WIN32 ON) 6 | else() 7 | + set(THREADS_PREFER_PTHREAD_FLAG TRUE) 8 | find_package(Threads REQUIRED) 9 | set(USE_THREADS_POSIX ${CMAKE_USE_PTHREADS_INIT}) 10 | set(HAVE_PTHREAD_H ${CMAKE_USE_PTHREADS_INIT}) 11 | @@ -2377,12 +2379,12 @@ 12 | if(BUILD_SHARED_LIBS) 13 | set(ENABLE_SHARED "yes") 14 | set(LIBCURL_PC_REQUIRES "") 15 | - set(LIBCURL_PC_LIBS "") 16 | + set(LIBCURL_PC_LIBS "-pthread") 17 | set(LIBCURL_PC_CFLAGS "") 18 | else() 19 | set(ENABLE_SHARED "no") 20 | set(LIBCURL_PC_REQUIRES "${LIBCURL_PC_REQUIRES_PRIVATE}") 21 | - set(LIBCURL_PC_LIBS "${LIBCURL_PC_LIBS_PRIVATE}") 22 | + set(LIBCURL_PC_LIBS "-pthread ${LIBCURL_PC_LIBS_PRIVATE}") 23 | set(LIBCURL_PC_CFLAGS "${LIBCURL_PC_CFLAGS_PRIVATE}") 24 | endif() 25 | if(BUILD_STATIC_LIBS) 26 | -------------------------------------------------------------------------------- /thirdparty/harfbuzz/android.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/hb-buffer-verify.cc b/src/hb-buffer-verify.cc 2 | index e1ccd5b94..e62b8fb9f 100644 3 | --- a/src/hb-buffer-verify.cc 4 | +++ b/src/hb-buffer-verify.cc 5 | @@ -46,11 +46,13 @@ buffer_verify_error (hb_buffer_t *buffer, 6 | { 7 | va_list ap; 8 | va_start (ap, fmt); 9 | +#ifndef HB_NO_BUFFER_MESSAGE 10 | if (buffer->messaging ()) 11 | { 12 | buffer->message_impl (font, fmt, ap); 13 | } 14 | else 15 | +#endif 16 | { 17 | fprintf (stderr, "harfbuzz "); 18 | vfprintf (stderr, fmt, ap); 19 | diff --git a/src/hb.hh b/src/hb.hh 20 | index 34a6df8a0..506d3be7c 100644 21 | --- a/src/hb.hh 22 | +++ b/src/hb.hh 23 | @@ -493,6 +493,10 @@ static int HB_UNUSED _hb_errno = 0; 24 | #define HB_NO_SETLOCALE 1 25 | #endif 26 | 27 | +#if !defined(HB_NO_SETLOCALE) && defined(__ANDROID__) && __ANDROID_API__ < 21 28 | +#define HB_NO_SETLOCALE 1 29 | +#endif 30 | + 31 | #ifndef HB_NO_SETLOCALE 32 | 33 | #include 34 | -------------------------------------------------------------------------------- /thirdparty/turbo/d7a8a247a4a2689b0f207162eb804141c87c4899.patch: -------------------------------------------------------------------------------- 1 | From d7a8a247a4a2689b0f207162eb804141c87c4899 Mon Sep 17 00:00:00 2001 2 | From: John Abrahamsen 3 | Date: Thu, 15 Jun 2023 21:58:50 +0200 4 | Subject: [PATCH] Fix bug, where memory would/could be free'd while being used 5 | in HTTP parser. 6 | 7 | --- 8 | turbo/httputil.lua | 2 +- 9 | 1 file changed, 1 insertion(+), 1 deletion(-) 10 | 11 | diff --git a/turbo/httputil.lua b/turbo/httputil.lua 12 | index 4f86508c..cf7f326c 100644 13 | --- a/turbo/httputil.lua 14 | +++ b/turbo/httputil.lua 15 | @@ -136,8 +136,8 @@ function httputil.HTTPParser:parse_url(url) 16 | if htpurl == nil then 17 | error("Could not allocate memory") 18 | end 19 | - ffi.gc(htpurl, ffi.C.free) 20 | self.http_parser_url = ffi.cast("struct http_parser_url *", htpurl) 21 | + ffi.gc(self.http_parser_url, ffi.C.free) 22 | local rc = libturbo_parser.http_parser_parse_url( 23 | url, 24 | url:len(), 25 | -------------------------------------------------------------------------------- /ffi/framebuffer_einkfb.lua: -------------------------------------------------------------------------------- 1 | local ffi = require("ffi") 2 | require("ffi/posix_h") 3 | require("ffi/einkfb_h") 4 | local C = ffi.C 5 | 6 | local framebuffer = {} 7 | 8 | local function einkfb_update(fb, refreshtype, x, y, w, h) 9 | x, y, w, h = fb.bb:getBoundedRect(x, y, w, h) 10 | x, y, w, h = fb.bb:getPhysicalRect(x, y, w, h) 11 | 12 | local refarea = ffi.new("struct update_area_t[1]") 13 | 14 | refarea[0].x1 = x or 0 15 | refarea[0].y1 = y or 0 16 | refarea[0].x2 = x + w 17 | refarea[0].y2 = y + h 18 | refarea[0].buffer = nil 19 | refarea[0].which_fx = refreshtype 20 | 21 | C.ioctl(fb.fd, C.FBIO_EINK_UPDATE_DISPLAY_AREA, refarea); 22 | end 23 | 24 | function framebuffer:refreshPartialImp(x, y, w, h) 25 | einkfb_update(self, C.fx_update_partial, x, y, w, h) 26 | end 27 | 28 | function framebuffer:refreshFullImp(x, y, w, h) 29 | einkfb_update(self, C.fx_update_full, x, y, w, h) 30 | end 31 | 32 | return require("ffi/framebuffer_linux"):extend(framebuffer) 33 | -------------------------------------------------------------------------------- /test-runner/busted_helper.lua: -------------------------------------------------------------------------------- 1 | -- Create `$KO_HOME` directory. 2 | local lfs = require("lfs") 3 | lfs.mkdir(os.getenv("KO_HOME")) 4 | -- Preload necessary busted modules and their dependencies (which 5 | -- are normally dynamically loaded during the testsuite execution). 6 | require("pl.dir") 7 | require("pl.List") 8 | require("busted.execute") 9 | require("busted.modules.files.lua") 10 | require("busted.modules.test_file_loader") 11 | -- Patch `package.path / package.cpath`: filter-out paths 12 | -- specific to the test framework (e.g. `spec/rocks/…`). 13 | local function filter_rocks(path) 14 | local filtered = {} 15 | for spec in string.gmatch(path, "([^;]+)") do 16 | if not spec:match("spec/rocks/") then 17 | table.insert(filtered, spec) 18 | end 19 | end 20 | return table.concat(filtered, ';') 21 | end 22 | package.path = filter_rocks(package.path) 23 | package.cpath = filter_rocks(package.cpath) 24 | -- Setup `ffi.loadlib` support. 25 | require("ffi/loadlib") 26 | -------------------------------------------------------------------------------- /thirdparty/libunibreak/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CFG_CMD COMMAND env) 2 | append_autotools_vars(CFG_CMD) 3 | list(APPEND CFG_CMD 4 | ${SOURCE_DIR}/configure --host=${CHOST} --prefix=${STAGING_DIR} 5 | --disable-$,shared,static> 6 | --enable-$,static,shared> 7 | --enable-silent-rules 8 | ) 9 | 10 | list(APPEND BUILD_CMD COMMAND make) 11 | 12 | list(APPEND INSTALL_CMD COMMAND make install) 13 | 14 | if(NOT MONOLIBTIC) 15 | set(LIB_SPEC unibreak VERSION 6) 16 | if(APPLE) 17 | append_shared_lib_fix_commands(INSTALL_CMD ${LIB_SPEC} ID) 18 | endif() 19 | append_shared_lib_install_commands(INSTALL_CMD ${LIB_SPEC}) 20 | endif() 21 | 22 | external_project( 23 | DOWNLOAD URL 8df410d010e03de1a339a400a920335e 24 | https://github.com/adah1972/libunibreak/releases/download/libunibreak_6_1/libunibreak-6.1.tar.gz 25 | CONFIGURE_COMMAND ${CFG_CMD} 26 | BUILD_COMMAND ${BUILD_CMD} 27 | INSTALL_COMMAND ${INSTALL_CMD} 28 | ) 29 | -------------------------------------------------------------------------------- /drawcontext.h: -------------------------------------------------------------------------------- 1 | /* 2 | KindlePDFViewer: a DC abstraction 3 | Copyright (C) 2012 Hans-Werner Hilse 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | #ifndef _DRAWCONTEXT_H 19 | #define _DRAWCONTEXT_H 20 | 21 | typedef struct DrawContext { 22 | int rotate; 23 | double zoom; 24 | double gamma; 25 | int offset_x; 26 | int offset_y; 27 | } DrawContext; 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /thirdparty/zstd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(GLIBC_VERSION_MAX AND GLIBC_VERSION_MAX VERSION_LESS "2.8") 2 | list(APPEND PATCH_FILES no_qsort_r.patch) 3 | endif() 4 | 5 | list(APPEND CMAKE_ARGS 6 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 7 | # Project options. 8 | -DZSTD_BUILD_PROGRAMS=FALSE 9 | -DZSTD_BUILD_SHARED=$> 10 | -DZSTD_BUILD_STATIC=$ 11 | -DZSTD_LEGACY_SUPPORT=FALSE 12 | -DZSTD_MULTITHREAD_SUPPORT=FALSE 13 | ) 14 | 15 | list(APPEND BUILD_CMD COMMAND ninja) 16 | 17 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 18 | 19 | if(NOT MONOLIBTIC) 20 | append_shared_lib_install_commands(INSTALL_CMD zstd VERSION 1) 21 | endif() 22 | 23 | external_project( 24 | DOWNLOAD URL 780fc1896922b1bc52a4e90980cdda48 25 | https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-1.5.7.tar.gz 26 | PATCH_FILES ${PATCH_FILES} 27 | SOURCE_SUBDIR build/cmake 28 | CMAKE_ARGS ${CMAKE_ARGS} 29 | BUILD_COMMAND ${BUILD_CMD} 30 | INSTALL_COMMAND ${INSTALL_CMD} 31 | ) 32 | -------------------------------------------------------------------------------- /koptcontext.h: -------------------------------------------------------------------------------- 1 | /* 2 | KindlePDFViewer: a KOPTContext abstraction 3 | Copyright (C) 2012 Huang Xin 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | #ifndef _KOPTCONTEXT_H 19 | #define _KOPTCONTEXT_H 20 | 21 | #include 22 | #include 23 | #include 24 | #include "context.h" 25 | #include "koptocr.h" 26 | 27 | int luaopen_koptcontext(lua_State *L); 28 | #endif 29 | -------------------------------------------------------------------------------- /thirdparty/libpng/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_ARGS 2 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 3 | # Project options. 4 | -DPNG_DEBUG_POSTFIX= 5 | -DPNG_FRAMEWORK=FALSE 6 | -DPNG_HARDWARE_OPTIMIZATIONS=$ 7 | -DPNG_SHARED=$> 8 | -DPNG_STATIC=$ 9 | -DPNG_TESTS=FALSE 10 | -DPNG_TOOLS=FALSE 11 | ) 12 | # Rely on `-mfpu=neon` ifdefs for enabling NEON on 32bits ARM. 13 | if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm") 14 | list(APPEND CMAKE_ARGS -DPNG_ARM_NEON=on) 15 | endif() 16 | 17 | list(APPEND BUILD_CMD COMMAND ninja) 18 | 19 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 20 | 21 | if(NOT MONOLIBTIC) 22 | append_shared_lib_install_commands(INSTALL_CMD png16 VERSION 16) 23 | endif() 24 | 25 | external_project( 26 | DOWNLOAD URL d30515199d151810133b6da2cfdde93f 27 | https://github.com/pnggroup/libpng/archive/refs/tags/v1.6.53.tar.gz 28 | CMAKE_ARGS ${CMAKE_ARGS} 29 | BUILD_COMMAND ${BUILD_CMD} 30 | INSTALL_COMMAND ${INSTALL_CMD} 31 | ) 32 | -------------------------------------------------------------------------------- /thirdparty/xz/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -77,7 +77,7 @@ 4 | # 5 | ############################################################################# 6 | 7 | -cmake_minimum_required(VERSION 3.20...4.2 FATAL_ERROR) 8 | +cmake_minimum_required(VERSION 3.17.5 FATAL_ERROR) 9 | 10 | include(CMakePushCheckState) 11 | include(CheckIncludeFile) 12 | @@ -1629,8 +1629,6 @@ 13 | # paths will be used. 14 | set(prefix "${CMAKE_INSTALL_PREFIX}") 15 | set(exec_prefix "\${prefix}") 16 | -cmake_path(APPEND libdir "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}") 17 | -cmake_path(APPEND includedir "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") 18 | 19 | # Threads::Threads is linked in only when using POSIX threads. 20 | # Use an empty value if using Windows threads or if threading is disabled. 21 | @@ -2323,7 +2321,7 @@ 22 | 23 | set(ENABLE_SCRIPTS OFF) 24 | 25 | -if(UNIX) 26 | +if(FALSE) 27 | # NOTE: These depend on the xz tool and decoder support. 28 | option(XZ_TOOL_SCRIPTS "Install the scripts \ 29 | xzdiff, xzgrep, xzmore, xzless, and their symlinks" ON) 30 | -------------------------------------------------------------------------------- /thirdparty/koreader-lfs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES 2 | # Ensure only the right symbols are exported. 3 | lfs-visibility.patch 4 | # Avoid precision loss on 32-bit arches (LFS is always built w/ LARGEFILE 5 | # support, but lua_Integer is always a ptrdiff_t, which is not wide enough). 6 | lfs-pushnumber-for-wide-types.patch 7 | ) 8 | 9 | list(APPEND CMAKE_ARGS 10 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 11 | -DBUILD_SHARED_LIBS=$> 12 | ) 13 | 14 | list(APPEND BUILD_CMD COMMAND ninja) 15 | 16 | if(MONOLIBTIC) 17 | append_install_commands(INSTALL_CMD libkoreader-lfs.a DESTINATION ${STAGING_DIR}/lib) 18 | else() 19 | append_binary_install_command(INSTALL_CMD libkoreader-lfs.so DESTINATION libs) 20 | endif() 21 | 22 | external_project( 23 | DOWNLOAD GIT ff2cbc21f1a2fd34d30c0840ff2abb0121d46131 24 | https://github.com/lunarmodules/luafilesystem 25 | PATCH_OVERLAY overlay 26 | PATCH_FILES ${PATCH_FILES} 27 | CMAKE_ARGS ${CMAKE_ARGS} 28 | BUILD_COMMAND ${BUILD_CMD} 29 | INSTALL_COMMAND ${INSTALL_CMD} 30 | ) 31 | -------------------------------------------------------------------------------- /thirdparty/libressl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES cmake_tweaks.patch) 2 | if(ANDROID) 3 | list(APPEND PATCH_FILES android.patch) 4 | endif() 5 | 6 | list(APPEND CMAKE_ARGS 7 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 8 | -DBUILD_SHARED_LIBS=$> 9 | # Project options. 10 | -DLIBRESSL_APPS=OFF 11 | -DLIBRESSL_TESTS=OFF 12 | -DENABLE_ASM=${WANT_SIMD} 13 | ) 14 | 15 | list(APPEND BUILD_CMD COMMAND ninja) 16 | 17 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 18 | 19 | if(NOT MONOLIBTIC) 20 | append_shared_lib_install_commands(INSTALL_CMD crypto VERSION 57) 21 | append_shared_lib_install_commands(INSTALL_CMD ssl VERSION 60) 22 | endif() 23 | 24 | external_project( 25 | DOWNLOAD URL 3eac6e95cd4ba1f03055181b950427da 26 | https://cdn.openbsd.org/pub/OpenBSD/LibreSSL/libressl-4.2.1.tar.gz 27 | https://cloudflare.cdn.openbsd.org/pub/OpenBSD/LibreSSL/libressl-4.2.1.tar.gz 28 | PATCH_FILES ${PATCH_FILES} 29 | CMAKE_ARGS ${CMAKE_ARGS} 30 | BUILD_COMMAND ${BUILD_CMD} 31 | INSTALL_COMMAND ${INSTALL_CMD} 32 | ) 33 | -------------------------------------------------------------------------------- /ffi-cdecl/giflib_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ffi-cdecl.h" 4 | 5 | cdecl_const(GIF_OK) 6 | cdecl_const(GIF_ERROR) 7 | 8 | cdecl_type(GifWord) 9 | cdecl_type(GifByteType) 10 | 11 | cdecl_type(GifColorType) 12 | cdecl_struct(GifColorType) 13 | 14 | cdecl_type(ColorMapObject) 15 | cdecl_struct(ColorMapObject) 16 | 17 | cdecl_type(GifImageDesc) 18 | cdecl_struct(GifImageDesc) 19 | 20 | cdecl_type(ExtensionBlock) 21 | cdecl_struct(ExtensionBlock) 22 | 23 | cdecl_type(GraphicsControlBlock) 24 | cdecl_struct(GraphicsControlBlock) 25 | 26 | cdecl_type(SavedImage) 27 | cdecl_struct(SavedImage) 28 | 29 | cdecl_type(GifFileType) 30 | cdecl_struct(GifFileType) 31 | 32 | cdecl_func(DGifOpenFileName) 33 | cdecl_func(DGifOpenFileHandle) 34 | cdecl_func(DGifCloseFile) 35 | 36 | cdecl_func(DGifSlurp) 37 | 38 | cdecl_func(GifErrorString) 39 | 40 | cdecl_func(DGifSavedExtensionToGCB) 41 | cdecl_const(DISPOSAL_UNSPECIFIED) 42 | cdecl_const(DISPOSE_DO_NOT) 43 | cdecl_const(DISPOSE_BACKGROUND) 44 | cdecl_const(DISPOSE_PREVIOUS) 45 | cdecl_const(NO_TRANSPARENT_COLOR) 46 | 47 | cdecl_type(InputFunc) 48 | cdecl_func(DGifOpen) 49 | -------------------------------------------------------------------------------- /ffi/drawcontext.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Drawcontext structure 3 | 4 | FFI frontend 5 | ]] 6 | 7 | local ffi = require "ffi" 8 | 9 | ffi.cdef[[ 10 | typedef struct DrawContext { 11 | int rotate; 12 | double zoom; 13 | double gamma; 14 | int offset_x; 15 | int offset_y; 16 | } DrawContext; 17 | ]] 18 | 19 | local DC = {} 20 | local DC_mt = {__index={}} 21 | 22 | function DC_mt.__index:setRotate(rotate) self.rotate = rotate end 23 | function DC_mt.__index:getRotate() return self.rotate end 24 | function DC_mt.__index:setZoom(zoom) self.zoom = zoom end 25 | function DC_mt.__index:getZoom() return self.zoom end 26 | function DC_mt.__index:setOffset(x, y) 27 | self.offset_x = x or 0 28 | self.offset_y = y or 0 29 | end 30 | function DC_mt.__index:getOffset() return self.offset_x, self.offset_y end 31 | function DC_mt.__index:setGamma(gamma) self.gamma = gamma end 32 | function DC_mt.__index:getGamma() return self.gamma end 33 | 34 | local dctype = ffi.metatype("DrawContext", DC_mt) 35 | 36 | function DC.new(rotate, zoom, x, y, gamma) 37 | return dctype(rotate or 0, zoom or 1.0, gamma or -1.0, x or 0, y or 0) 38 | end 39 | 40 | return DC 41 | -------------------------------------------------------------------------------- /thirdparty/dropbear/localoptions.h.cmake: -------------------------------------------------------------------------------- 1 | #cmakedefine DEBUG_TRACE @DEBUG_TRACE@ 2 | #cmakedefine DROPBEAR_DEFPORT "@DROPBEAR_DEFPORT@" 3 | #cmakedefine01 DROPBEAR_SMALL_CODE 4 | #cmakedefine01 DROPBEAR_X11FWD 5 | #cmakedefine01 INETD_MODE 6 | #cmakedefine01 LOG_COMMANDS 7 | // Paths. 8 | #cmakedefine DBSCP_PATH "@DBSCP_PATH@" 9 | #cmakedefine DEFAULT_PATH "@DEFAULT_PATH@" 10 | #cmakedefine DROPBEAR_PATH_SSH_PROGRAM "@DROPBEAR_PATH_SSH_PROGRAM@" 11 | #cmakedefine DROPBEAR_PIDFILE "@DROPBEAR_PIDFILE@" 12 | #cmakedefine SFTPSERVER_PATH "@SFTPSERVER_PATH@" 13 | // Keys. 14 | #cmakedefine DSS_PRIV_FILENAME "@DSS_PRIV_FILENAME@" 15 | #cmakedefine RSA_PRIV_FILENAME "@RSA_PRIV_FILENAME@" 16 | #cmakedefine ECDSA_PRIV_FILENAME "@ECDSA_PRIV_FILENAME@" 17 | #cmakedefine ED25519_PRIV_FILENAME "@ED25519_PRIV_FILENAME@" 18 | // Extra part of the SSH server identification string. 19 | #define IDENT_VERSION_PART "_" DROPBEAR_VERSION " (KOReader)" 20 | // Disable mlkem769 (post-quantum key exchange): sntrup761 is 21 | // already available and much lighter in terms of code size. 22 | #define DROPBEAR_MLKEM768 0 23 | -------------------------------------------------------------------------------- /thirdparty/dropbear/fix__GNU_SOURCE_warnings.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/config.h.in b/src/config.h.in 2 | index 589786e..dd79699 100644 3 | --- a/src/config.h.in 4 | +++ b/src/config.h.in 5 | @@ -450,7 +450,9 @@ 6 | #undef _FILE_OFFSET_BITS 7 | 8 | /* Use GNU extensions if glibc */ 9 | +#ifndef _GNU_SOURCE 10 | #undef _GNU_SOURCE 11 | +#endif 12 | 13 | /* Define for large files, on AIX-style hosts. */ 14 | #undef _LARGE_FILES 15 | diff --git a/src/dbutil.c b/src/dbutil.c 16 | index a70025e..81031c6 100644 17 | --- a/src/dbutil.c 18 | +++ b/src/dbutil.c 19 | @@ -51,7 +51,9 @@ 20 | #include "config.h" 21 | 22 | #ifdef __linux__ 23 | +#ifndef _GNU_SOURCE 24 | #define _GNU_SOURCE 25 | +#endif 26 | /* To call clock_gettime() directly */ 27 | #include 28 | #endif /* __linux */ 29 | diff --git a/src/scpmisc.c b/src/scpmisc.c 30 | index c2f053e..bd117b8 100644 31 | --- a/src/scpmisc.c 32 | +++ b/src/scpmisc.c 33 | @@ -43,7 +43,9 @@ 34 | 35 | /*RCSID("OpenBSD: xmalloc.c,v 1.16 2001/07/23 18:21:46 stevesk Exp ");*/ 36 | 37 | +#ifndef _GNU_SOURCE 38 | #define _GNU_SOURCE 39 | +#endif 40 | #include "includes.h" 41 | #include "scpmisc.h" 42 | 43 | -------------------------------------------------------------------------------- /thirdparty/libk2pdfopt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(NOT MONOLIBTIC) 2 | set(CMAKE_PATCH_FILE ${CMAKE_BINARY_DIR}/k2pdfopt_exports.cmake) 3 | target_exports(k2pdfopt FILELIST_VAR CDECLS_FILES WRITE_TO_FILE ${CMAKE_PATCH_FILE} CDECLS koptcontext_cdecl) 4 | list(APPEND PATCH_CMD COMMAND ${ISED} "\$p" -e "\$s|.*|include(${CMAKE_PATCH_FILE})|" lib/CMakeLists.txt) 5 | endif() 6 | 7 | list(APPEND CMAKE_ARGS 8 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 9 | -DBUILD_SHARED_LIBS=$> 10 | # Project options. 11 | -DANDROID=${ANDROID} 12 | ) 13 | 14 | list(APPEND BUILD_CMD COMMAND ninja) 15 | 16 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 17 | 18 | if(NOT MONOLIBTIC) 19 | append_shared_lib_install_commands(INSTALL_CMD k2pdfopt VERSION 2) 20 | endif() 21 | 22 | external_project( 23 | DOWNLOAD GIT 59ced371378312d8f332d9a35f5b4a3c33b18954 24 | https://github.com/koreader/libk2pdfopt.git 25 | PATCH_COMMAND ${PATCH_CMD} 26 | CMAKE_ARGS ${CMAKE_ARGS} 27 | SOURCE_SUBDIR lib 28 | BUILD_COMMAND ${BUILD_CMD} 29 | BUILD_DEPENDS ${CDECLS_FILES} 30 | INSTALL_COMMAND ${INSTALL_CMD} 31 | ) 32 | -------------------------------------------------------------------------------- /djvu.h: -------------------------------------------------------------------------------- 1 | /* 2 | KindlePDFViewer: DjvuLibre abstraction for Lua 3 | Copyright (C) 2011 Hans-Werner Hilse 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | #ifndef _DJVU_H 19 | #define _DJVU_H 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | // Symbol visibility 26 | #define DLL_PUBLIC __attribute__((visibility("default"))) 27 | #define DLL_LOCAL __attribute__((visibility("hidden"))) 28 | 29 | DLL_PUBLIC int luaopen_djvu(lua_State *L); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /input/input.h: -------------------------------------------------------------------------------- 1 | /* 2 | KindlePDFViewer: input abstraction for Lua 3 | Copyright (C) 2011 Hans-Werner Hilse 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | #ifndef _KO_INPUT_H 19 | #define _KO_INPUT_H 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | // Symbol visibility 26 | #define DLL_PUBLIC __attribute__((visibility("default"))) 27 | #define DLL_LOCAL __attribute__((visibility("hidden"))) 28 | 29 | DLL_PUBLIC int luaopen_input(lua_State *L); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /ffi-cdecl/mxcfb_cervantes_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "include/mxcfb-cervantes.h" 4 | #include "ffi-cdecl.h" 5 | 6 | cdecl_const(UPDATE_MODE_PARTIAL) 7 | cdecl_const(UPDATE_MODE_FULL) 8 | 9 | cdecl_const(TEMP_USE_AMBIENT) 10 | 11 | cdecl_const(WAVEFORM_MODE_AUTO) 12 | 13 | cdecl_const(WAVEFORM_MODE_INIT) 14 | cdecl_const(WAVEFORM_MODE_DU) 15 | cdecl_const(WAVEFORM_MODE_GC16) 16 | cdecl_const(WAVEFORM_MODE_A2) 17 | cdecl_const(WAVEFORM_MODE_GL16) 18 | cdecl_const(WAVEFORM_MODE_GLR16) 19 | cdecl_const(WAVEFORM_MODE_GLD16) 20 | 21 | cdecl_const(EPDC_FLAG_ENABLE_INVERSION) 22 | cdecl_const(EPDC_FLAG_FORCE_MONOCHROME) 23 | cdecl_const(EPDC_FLAG_USE_ALT_BUFFER) 24 | cdecl_const(EPDC_FLAG_USE_CMAP) 25 | cdecl_const(EPDC_FLAG_TEST_COLLISION) 26 | cdecl_const(EPDC_FLAG_GROUP_UPDATE) 27 | cdecl_const(EPDC_FLAG_USE_DITHERING_Y1) 28 | cdecl_const(EPDC_FLAG_USE_DITHERING_Y4) 29 | cdecl_const(EPDC_FLAG_USE_AAD) 30 | cdecl_const(EPDC_FLAG_USE_DITHERING_NTX_D8) 31 | 32 | cdecl_struct(mxcfb_rect) 33 | 34 | cdecl_struct(mxcfb_alt_buffer_data) 35 | cdecl_struct(mxcfb_update_data) 36 | 37 | cdecl_const(MXCFB_SEND_UPDATE) 38 | cdecl_const(MXCFB_WAIT_FOR_UPDATE_COMPLETE) 39 | -------------------------------------------------------------------------------- /thirdparty/lpeg/luajit.patch: -------------------------------------------------------------------------------- 1 | diff -Nuarp lpeg-1.1.0-orig/lptree.c lpeg-1.1.0/lptree.c 2 | --- lpeg-1.1.0-orig/lptree.c 2023-06-26 18:30:55.000000000 +0200 3 | +++ lpeg-1.1.0/lptree.c 2024-06-18 21:45:18.373041624 +0200 4 | @@ -1382,8 +1382,8 @@ static struct luaL_Reg metareg[] = { 5 | }; 6 | 7 | 8 | -int luaopen_lpeg (lua_State *L); 9 | -int luaopen_lpeg (lua_State *L) { 10 | +LUALIB_API int luaopen_lpeg (lua_State *L); 11 | +LUALIB_API int luaopen_lpeg (lua_State *L) { 12 | luaL_newmetatable(L, PATTERN_T); 13 | lua_pushnumber(L, MAXBACK); /* initialize maximum backtracking */ 14 | lua_setfield(L, LUA_REGISTRYINDEX, MAXSTACKIDX); 15 | diff -Nuarp lpeg-1.1.0-orig/lptypes.h lpeg-1.1.0/lptypes.h 16 | --- lpeg-1.1.0-orig/lptypes.h 2023-06-26 18:30:55.000000000 +0200 17 | +++ lpeg-1.1.0/lptypes.h 2024-06-18 21:51:11.192651835 +0200 18 | @@ -34,8 +34,14 @@ 19 | 20 | #define lua_rawlen lua_objlen 21 | 22 | +#ifdef luaL_setfuncs 23 | +#undef luaL_setfuncs 24 | #define luaL_setfuncs(L,f,n) luaL_register(L,NULL,f) 25 | +#endif 26 | +#ifdef luaL_newlib 27 | +#undef luaL_newlib 28 | #define luaL_newlib(L,f) luaL_register(L,"lpeg",f) 29 | +#endif 30 | 31 | typedef size_t lua_Unsigned; 32 | 33 | -------------------------------------------------------------------------------- /thirdparty/freetype2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES 2 | # Work around GCC 12 ARM NEON bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117811). 3 | ftcalc_gcc12_arm_neon_fix.patch 4 | ) 5 | 6 | list(APPEND CFG_CMD COMMAND 7 | ${MESON_SETUP} --default-library=$,static,shared> 8 | -Derror_strings=$,true,false> 9 | -Dbrotli=enabled 10 | -Dharfbuzz=disabled 11 | -Dmmap=enabled 12 | -Dzlib=system 13 | ${SOURCE_DIR} 14 | ) 15 | 16 | list(APPEND BUILD_CMD COMMAND ninja) 17 | 18 | list(APPEND INSTALL_CMD COMMAND ${MESON_INSTALL}) 19 | 20 | if(NOT MONOLIBTIC) 21 | set(LIB_SPEC freetype VERSION 6) 22 | if(APPLE) 23 | append_shared_lib_fix_commands(INSTALL_CMD ${LIB_SPEC} ID) 24 | endif() 25 | append_shared_lib_install_commands(INSTALL_CMD ${LIB_SPEC}) 26 | endif() 27 | 28 | external_project( 29 | DOWNLOAD URL 813676dfd2a03716e149208d99586006 30 | https://github.com/freetype/freetype/archive/refs/tags/VER-2-14-1.tar.gz 31 | PATCH_FILES ${PATCH_FILES} 32 | CONFIGURE_COMMAND ${CFG_CMD} 33 | BUILD_COMMAND ${BUILD_CMD} 34 | INSTALL_COMMAND ${INSTALL_CMD} 35 | ) 36 | -------------------------------------------------------------------------------- /ffi-cdecl/mxcfb_remarkable_decl.c: -------------------------------------------------------------------------------- 1 | // standard Linux framebuffer headers 2 | #include 3 | 4 | #include 5 | // specialized eink framebuffer headers 6 | #include "include/mxcfb-remarkable.h" 7 | 8 | #include "ffi-cdecl.h" 9 | 10 | cdecl_const(UPDATE_MODE_PARTIAL) 11 | cdecl_const(UPDATE_MODE_FULL) 12 | 13 | cdecl_const(WAVEFORM_MODE_INIT) 14 | cdecl_const(WAVEFORM_MODE_DU) 15 | cdecl_const(WAVEFORM_MODE_GC16) 16 | cdecl_const(WAVEFORM_MODE_GL16) 17 | cdecl_const(WAVEFORM_MODE_A2) 18 | 19 | cdecl_const(WAVEFORM_MODE_AUTO) 20 | 21 | cdecl_const(TEMP_USE_AMBIENT) 22 | cdecl_const(TEMP_USE_REMARKABLE) 23 | 24 | cdecl_const(EPDC_FLAG_ENABLE_INVERSION) 25 | cdecl_const(EPDC_FLAG_FORCE_MONOCHROME) 26 | cdecl_const(EPDC_FLAG_USE_CMAP) 27 | cdecl_const(EPDC_FLAG_USE_ALT_BUFFER) 28 | cdecl_const(EPDC_FLAG_USE_DITHERING_Y1) 29 | cdecl_const(EPDC_FLAG_USE_DITHERING_Y4) 30 | cdecl_const(EPDC_FLAG_USE_REGAL) 31 | 32 | cdecl_enum(mxcfb_dithering_mode) 33 | 34 | cdecl_struct(mxcfb_rect) 35 | cdecl_struct(mxcfb_alt_buffer_data) 36 | cdecl_struct(mxcfb_update_data) 37 | cdecl_struct(mxcfb_update_marker_data) 38 | 39 | cdecl_const(MXCFB_SEND_UPDATE) 40 | 41 | cdecl_const(MXCFB_WAIT_FOR_UPDATE_COMPLETE) 42 | -------------------------------------------------------------------------------- /thirdparty/openssh/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(NOT APPLE AND MONOLIBTIC) 2 | # Need `-pthread` for static OpenSSL's crypto library. 3 | string(APPEND LDFLAGS " -pthread") 4 | endif() 5 | list(APPEND CFG_CMD COMMAND env) 6 | if(LEGACY OR POCKETBOOK) 7 | # Avoid pulling-in `utimensat@@GLIBC_2.6` in `sftp-server`. 8 | list(APPEND CFG_CMD ac_cv_func_utimensat=no) 9 | endif() 10 | append_autotools_vars(CFG_CMD) 11 | list(APPEND CFG_CMD 12 | ${SOURCE_DIR}/configure --host=${CHOST} 13 | --disable-etc-default-login 14 | --disable-lastlog 15 | --with-md5-passwords 16 | --without-hardening 17 | --without-openssl 18 | --without-stackprotect 19 | --without-zlib 20 | ) 21 | 22 | set(PROGRAMS sftp-server) 23 | 24 | list(APPEND BUILD_CMD COMMAND make ${PROGRAMS}) 25 | 26 | append_binary_install_command(INSTALL_CMD ${PROGRAMS}) 27 | 28 | external_project( 29 | DOWNLOAD URL 801b5ad6da38e0045de20dd5dd2f6a80 30 | https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-10.2p1.tar.gz 31 | https://cloudflare.cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-10.2p1.tar.gz 32 | CONFIGURE_COMMAND ${CFG_CMD} 33 | BUILD_COMMAND ${BUILD_CMD} 34 | INSTALL_COMMAND ${INSTALL_CMD} 35 | ) 36 | -------------------------------------------------------------------------------- /.ci/build_script.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 4 | # shellcheck source=/dev/null 5 | source "${CI_DIR}/common.sh" 6 | 7 | docker-make() { 8 | local cmdlist=( 9 | 'source /home/ko/.bashrc' 10 | 'cd /home/ko/base' 11 | 'sudo chown -R ko:ko .' 12 | "env MAKEFLAGS='${MAKEFLAGS}' make $(printf '%q ' "$@")" 13 | ) 14 | if [[ -z "${CCACHE_DIR}" ]]; then 15 | CCACHE_DIR="$(ccache --get-config cache_dir)" 16 | fi 17 | mkdir -p "${CCACHE_DIR}" 18 | echo "using host cache dir: ${CCACHE_DIR}" 19 | sudo chmod -R 777 "${CCACHE_DIR}" 20 | DOCKER_HOME=/home/ko 21 | DOCKER_CCACHE_DIR="${DOCKER_HOME}/.cache/ccache" 22 | echo "using docker cache dir: ${DOCKER_CCACHE_DIR}" 23 | docker run --rm -t \ 24 | -e CCACHE_DIR="${DOCKER_CCACHE_DIR}" \ 25 | -v "${CCACHE_DIR}:${DOCKER_CCACHE_DIR}" \ 26 | -v "${PWD}:${DOCKER_HOME}/base" "${DOCKER_IMG}" \ 27 | /bin/bash -c "$(printf '%s && ' "${cmdlist[@]}")true" 28 | } 29 | 30 | if [[ -z "${DOCKER_IMG}" ]]; then 31 | make TARGET="${TARGET}" "$@" 32 | else 33 | docker-make TARGET="${TARGET}" VERBOSE=1 "$@" 34 | fi 35 | 36 | # vim: sw=4 37 | -------------------------------------------------------------------------------- /ffi-cdecl/zeromq_cdecl.c: -------------------------------------------------------------------------------- 1 | // CPPFLAGS="-I/var/tmp/niluje/libzmq/include -I/var/tmp/niluje/czmq/include" 2 | #include 3 | #include 4 | 5 | #include "ffi-cdecl.h" 6 | 7 | cdecl_type(zmsg_t) 8 | cdecl_type(zhash_t) 9 | cdecl_type(zsock_t) 10 | cdecl_type(zframe_t) 11 | cdecl_type(zpoller_t) 12 | 13 | cdecl_const(ZFRAME_MORE) 14 | cdecl_const(ZFRAME_REUSE) 15 | cdecl_const(ZMQ_IDENTITY) 16 | cdecl_const(ZMQ_STREAM) 17 | 18 | cdecl_func(zmq_getsockopt) 19 | cdecl_func(zmq_send) 20 | 21 | cdecl_func(zsock_bind) 22 | cdecl_func(zsock_connect) 23 | cdecl_func(zsock_destroy) 24 | cdecl_func(zsock_new) 25 | cdecl_func(zsock_resolve) 26 | 27 | cdecl_func(zframe_data) 28 | cdecl_func(zframe_destroy) 29 | cdecl_func(zframe_recv) 30 | cdecl_func(zframe_send) 31 | cdecl_func(zframe_size) 32 | 33 | cdecl_func(zmsg_addmem) 34 | cdecl_func(zmsg_destroy) 35 | cdecl_func(zmsg_new) 36 | cdecl_func(zmsg_pop) 37 | cdecl_func(zmsg_popstr) 38 | cdecl_func(zmsg_send) 39 | cdecl_func(zmsg_size) 40 | 41 | cdecl_func(zstr_free) 42 | cdecl_func(zstr_send) 43 | 44 | cdecl_func(zhash_cursor) 45 | cdecl_func(zhash_destroy) 46 | cdecl_func(zhash_unpack) 47 | 48 | cdecl_func(zpoller_destroy) 49 | cdecl_func(zpoller_new) 50 | cdecl_func(zpoller_wait) 51 | -------------------------------------------------------------------------------- /cre.h: -------------------------------------------------------------------------------- 1 | /* 2 | KindlePDFViewer: CREngine abstraction for Lua 3 | Copyright (C) 2012 Hans-Werner Hilse 4 | Qingping Hou 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #ifndef _CRENGING_H 21 | #define _CRENGING_H 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | // Symbol visibility 28 | #define DLL_PUBLIC __attribute__((visibility("default"))) 29 | #define DLL_LOCAL __attribute__((visibility("hidden"))) 30 | 31 | DLL_PUBLIC int luaopen_cre(lua_State *L); 32 | #endif 33 | -------------------------------------------------------------------------------- /thirdparty/tar/tar-1.33-remove-o_path-usage.patch: -------------------------------------------------------------------------------- 1 | diff -Nuarp tar-1.33-ori/gnu/fchmodat.c tar-1.33/gnu/fchmodat.c 2 | --- tar-1.33-ori/gnu/fchmodat.c 2021-01-07 15:29:44.000000000 +0100 3 | +++ tar-1.33/gnu/fchmodat.c 2021-01-16 00:41:39.414012004 +0100 4 | @@ -68,7 +68,7 @@ fchmodat (int dir, char const *file, mod 5 | { 6 | struct stat st; 7 | 8 | -# if defined O_PATH && defined AT_EMPTY_PATH 9 | +# if defined NOPE_PATH && defined AT_EMPTY_PATH 10 | /* Open a file descriptor with O_NOFOLLOW, to make sure we don't 11 | follow symbolic links, if /proc is mounted. O_PATH is used to 12 | avoid a failure if the file is not readable. 13 | diff -Nuarp tar-1.33-ori/gnu/lchmod.c tar-1.33/gnu/lchmod.c 14 | --- tar-1.33-ori/gnu/lchmod.c 2021-01-07 15:28:45.000000000 +0100 15 | +++ tar-1.33/gnu/lchmod.c 2021-01-16 00:41:28.708012124 +0100 16 | @@ -45,7 +45,7 @@ 17 | int 18 | lchmod (char const *file, mode_t mode) 19 | { 20 | -#if defined O_PATH && defined AT_EMPTY_PATH 21 | +#if defined NOPE_PATH && defined AT_EMPTY_PATH 22 | /* Open a file descriptor with O_NOFOLLOW, to make sure we don't 23 | follow symbolic links, if /proc is mounted. O_PATH is used to 24 | avoid a failure if the file is not readable. 25 | -------------------------------------------------------------------------------- /ffi-cdecl/inotify_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ffi-cdecl.h" 4 | 5 | cdecl_const(IN_ACCESS) 6 | cdecl_const(IN_ATTRIB) 7 | cdecl_const(IN_CLOSE_WRITE) 8 | cdecl_const(IN_CLOSE_NOWRITE) 9 | cdecl_const(IN_CREATE) 10 | cdecl_const(IN_DELETE) 11 | cdecl_const(IN_DELETE_SELF) 12 | cdecl_const(IN_MODIFY) 13 | cdecl_const(IN_MOVE_SELF) 14 | cdecl_const(IN_MOVED_FROM) 15 | cdecl_const(IN_MOVED_TO) 16 | cdecl_const(IN_OPEN) 17 | 18 | /* convenience macros */ 19 | cdecl_const(IN_ALL_EVENTS) 20 | cdecl_const(IN_MOVE) 21 | cdecl_const(IN_CLOSE) 22 | 23 | /* bits for mask of inotify_add_watch() */ 24 | cdecl_const(IN_DONT_FOLLOW) /* from 2.6.15 */ 25 | cdecl_const(IN_EXCL_UNLINK) /* from 2.6.36 */ 26 | cdecl_const(IN_MASK_ADD) 27 | cdecl_const(IN_ONESHOT) 28 | cdecl_const(IN_ONLYDIR) /* from 2.6.15 */ 29 | 30 | /* may be set for events read() */ 31 | cdecl_const(IN_IGNORED) 32 | cdecl_const(IN_ISDIR) 33 | cdecl_const(IN_Q_OVERFLOW) 34 | cdecl_const(IN_UNMOUNT) 35 | 36 | /* flags for inotify_init1() */ 37 | cdecl_const(IN_NONBLOCK) 38 | cdecl_const(IN_CLOEXEC) 39 | 40 | cdecl_func(inotify_init) 41 | cdecl_func(inotify_init1) /* from 2.6.27 */ 42 | cdecl_func(inotify_add_watch) 43 | cdecl_func(inotify_rm_watch) 44 | 45 | cdecl_struct(inotify_event) 46 | -------------------------------------------------------------------------------- /thirdparty/libjpeg-turbo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES 2 | no_cmake_rpath_shenanigans.patch 3 | no_12_or_16_bits_precision.patch 4 | ) 5 | 6 | list(APPEND CMAKE_ARGS 7 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 8 | # Project options. 9 | -DENABLE_SHARED=$> 10 | -DENABLE_STATIC=$ 11 | -DWITH_JAVA=OFF 12 | -DWITH_JPEG8=ON 13 | -DWITH_TESTS=OFF 14 | -DWITH_TOOLS=OFF 15 | # Make sure we disable ASM if we don't support SIMD. 16 | -DREQUIRE_SIMD=$ 17 | -DWITH_SIMD=$ 18 | # Reproducible builds: use release date. 19 | -DBUILD=20240508 20 | ) 21 | 22 | list(APPEND BUILD_CMD COMMAND ninja) 23 | 24 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 25 | 26 | if(NOT MONOLIBTIC) 27 | append_shared_lib_install_commands(INSTALL_CMD jpeg VERSION 8) 28 | append_shared_lib_install_commands(INSTALL_CMD turbojpeg VERSION 0.4.0) 29 | endif() 30 | 31 | external_project( 32 | DOWNLOAD GIT 3.1.3 33 | https://github.com/libjpeg-turbo/libjpeg-turbo.git 34 | PATCH_FILES ${PATCH_FILES} 35 | CMAKE_ARGS ${CMAKE_ARGS} 36 | BUILD_COMMAND ${BUILD_CMD} 37 | INSTALL_COMMAND ${INSTALL_CMD} 38 | ) 39 | -------------------------------------------------------------------------------- /spec/unit/md5_spec.lua: -------------------------------------------------------------------------------- 1 | require("ffi_wrapper") 2 | 3 | describe("MD5 module", function() 4 | local md5, sha2 5 | 6 | setup(function() 7 | md5 = require("ffi/MD5") 8 | sha2 = require("ffi/sha2") 9 | end) 10 | 11 | it("should calculate correct MD5 hashes", function() 12 | assert.is_equal("d41d8cd98f00b204e9800998ecf8427e", sha2.md5("")) 13 | assert.is_equal("93b885adfe0da089cdf634904fd59f71", sha2.md5("\0")) 14 | assert.is_equal("1b05aba914a8b12315c7ee52b42f3d35", sha2.md5("0123456789abcdefX")) 15 | end) 16 | 17 | it("should calculate MD5 sum by updating", function() 18 | local update = sha2.md5() 19 | update("0123456789") 20 | update("abcdefghij") 21 | assert.is_equal(sha2.md5("0123456789abcdefghij"), update()) 22 | end) 23 | 24 | it("should calculate MD5 sum of a file", function() 25 | assert.is_equal( 26 | "ee53c8f032c3d047cb3d1999c8ff5e09", 27 | md5.sumFile("spec/base/unit/data/2col.jbig2.pdf")) 28 | end) 29 | 30 | it("should error out on non-exist file", function() 31 | local ok, err = md5.sumFile("foo/bar/abc/123/baz.pdf") 32 | assert.is.falsy(ok) 33 | assert.is_not_nil(err) 34 | end) 35 | end) 36 | 37 | -------------------------------------------------------------------------------- /thirdparty/libwebp/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | --- i/cmake/deps.cmake 2 | +++ w/cmake/deps.cmake 3 | @@ -52,20 +52,8 @@ endif() 4 | set(LT_OBJDIR ".libs/") 5 | 6 | # Only useful for vwebp, so useless for now. 7 | -find_package(OpenGL) 8 | -set(WEBP_HAVE_GL ${OPENGL_FOUND}) 9 | - 10 | -# Check if we need to link to the C math library. We do not look for it as it is 11 | -# not found when cross-compiling, while it is here. 12 | -check_c_source_compiles( 13 | - " 14 | - #include 15 | - int main(int argc, char** argv) { 16 | - return (int)pow(argc, 2.5); 17 | - } 18 | - " 19 | - HAVE_MATH_LIBRARY) 20 | -if(NOT HAVE_MATH_LIBRARY) 21 | +check_library_exists(m floor "" HAVE_MATH_LIBRARY) 22 | +if(HAVE_MATH_LIBRARY) 23 | message(STATUS "Adding -lm flag.") 24 | list(APPEND SHARPYUV_DEP_LIBRARIES m) 25 | list(APPEND WEBP_DEP_LIBRARIES m) 26 | @@ -128,9 +116,6 @@ endif() 27 | 28 | # Check for specific headers. 29 | include(CheckIncludeFiles) 30 | -check_include_files(GLUT/glut.h HAVE_GLUT_GLUT_H) 31 | -check_include_files(GL/glut.h HAVE_GL_GLUT_H) 32 | -check_include_files(OpenGL/glut.h HAVE_OPENGL_GLUT_H) 33 | check_include_files(shlwapi.h HAVE_SHLWAPI_H) 34 | check_include_files(unistd.h HAVE_UNISTD_H) 35 | check_include_files(wincodec.h HAVE_WINCODEC_H) 36 | -------------------------------------------------------------------------------- /spec/unit/ffi_wrapper.lua: -------------------------------------------------------------------------------- 1 | -- Check if we're running a busted version recent enough that we don't need to deal with the LuaJIT hacks... 2 | -- That currently means > 2.0.0 (i.e., scm-2, which isn't on LuaRocks...). 3 | local busted_ok = false 4 | for name, _ in pairs(package.loaded) do 5 | if name == "busted.luajit" then 6 | busted_ok = true 7 | break 8 | end 9 | end 10 | 11 | -- Whee! 12 | if busted_ok then 13 | return 14 | end 15 | 16 | -- Don't try to overwrite metatables so we can use --auto-insulate-tests 17 | -- Shamelessly copied from https://github.com/Olivine-Labs/busted/commit/2dfff99bda01fd3da56fd23415aba5a2a4cc0ffd 18 | local ffi = require "ffi" 19 | 20 | local original_metatype = ffi.metatype 21 | local original_store = {} 22 | ffi.metatype = function (primary, ...) 23 | if original_store[primary] then 24 | return original_store[primary] 25 | end 26 | local success, result, err = pcall(original_metatype, primary, ...) 27 | if not success then 28 | -- hard error was thrown 29 | error(result, 2) 30 | end 31 | if not result then 32 | -- soft error was returned 33 | return result, err 34 | end 35 | -- it worked, store and return 36 | original_store[primary] = result 37 | return result 38 | end 39 | -------------------------------------------------------------------------------- /ffi-cdecl/lodepng_decl.c: -------------------------------------------------------------------------------- 1 | #define LODEPNG_NO_COMPILE_ANCILLARY_CHUNKS 2 | #include 3 | 4 | #include "ffi-cdecl.h" 5 | 6 | cdecl_enum(LodePNGColorType) 7 | cdecl_type(LodePNGColorType) 8 | cdecl_type(LodePNGDecompressSettings) 9 | cdecl_struct(LodePNGDecompressSettings) 10 | cdecl_struct(LodePNGDecoderSettings) 11 | cdecl_type(LodePNGDecoderSettings) 12 | cdecl_enum(LodePNGFilterStrategy) 13 | cdecl_type(LodePNGFilterStrategy) 14 | cdecl_type(LodePNGCompressSettings) 15 | cdecl_struct(LodePNGCompressSettings) 16 | cdecl_struct(LodePNGEncoderSettings) 17 | cdecl_type(LodePNGEncoderSettings) 18 | cdecl_struct(LodePNGColorMode) 19 | cdecl_type(LodePNGColorMode) 20 | cdecl_struct(LodePNGInfo) 21 | cdecl_type(LodePNGInfo) 22 | cdecl_struct(LodePNGState) 23 | cdecl_type(LodePNGState) 24 | cdecl_func(lodepng_error_text) 25 | cdecl_func(lodepng_decode32_file) 26 | cdecl_func(lodepng_decode32) 27 | cdecl_func(lodepng_decode24_file) 28 | cdecl_func(lodepng_decode24) 29 | cdecl_func(lodepng_decode_memory) 30 | cdecl_func(lodepng_decode_file) 31 | cdecl_func(lodepng_encode32_file) 32 | cdecl_func(lodepng_encode_file) 33 | cdecl_func(lodepng_state_init) 34 | cdecl_func(lodepng_state_cleanup) 35 | cdecl_func(lodepng_state_copy) 36 | cdecl_func(lodepng_decode) 37 | cdecl_func(lodepng_inspect) 38 | cdecl_func(lodepng_encode) 39 | -------------------------------------------------------------------------------- /ev_replay.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding:utf-8 -*- 3 | 4 | import pprint 5 | import struct 6 | import argparse 7 | 8 | EV_LOG = "ev_double.log" 9 | EV_PIPE = "/tmp/emu_event" 10 | 11 | def gen_ev_from_log_entry(line): 12 | values = line.split("|") 13 | return { 14 | "time": { 15 | "sec": int(values[3]), 16 | "usec": int(values[4]), 17 | }, 18 | "type": int(values[0]), 19 | "code": int(values[1]), 20 | "value": int(values[2]), 21 | } 22 | 23 | if __name__ == "__main__": 24 | parser = argparse.ArgumentParser() 25 | parser.add_argument("ev_log", type=str, 26 | help="event log file to replay") 27 | args = parser.parse_args() 28 | 29 | # parse ev log into dictionaries 30 | evs = [gen_ev_from_log_entry(line.strip()) 31 | for line in open(args.ev_log)] 32 | #pprint.pprint(evs) 33 | 34 | # replay evs 35 | ev_pipe = open(EV_PIPE, "w") 36 | for ev in evs: 37 | #@TODO also simulate timing here 25.02 2013 (houqp) 38 | ev_pipe.write( 39 | struct.pack("llHHi", 40 | ev["time"]["sec"], ev["time"]["usec"], 41 | ev["type"], 42 | ev["code"], 43 | ev["value"]) 44 | ) 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ffi-cdecl/koptcontext_cdecl.c: -------------------------------------------------------------------------------- 1 | #define K2PDFOPT_EXPORT 2 | #define WILLUS_EXPORT 3 | 4 | #include "koptcrop.h" 5 | #include "koptimize.h" 6 | #include "koptocr.h" 7 | #include "koptreflow.h" 8 | 9 | #include "ffi-cdecl.h" 10 | 11 | // FIXME: only declared in `koptocr.c`… 12 | PIX* bitmap2pix(WILLUSBITMAP *src, int x, int y, int w, int h); 13 | 14 | cdecl_type(BBox) 15 | cdecl_type(BOXA) 16 | cdecl_type(NUMA) 17 | cdecl_type(PIX) 18 | cdecl_type(POINT2D) 19 | cdecl_type(WRECTMAP) 20 | cdecl_type(WRECTMAPS) 21 | cdecl_type(WILLUSBITMAP) 22 | cdecl_type(HYPHENINFO) 23 | cdecl_type(TEXTROW) 24 | cdecl_type(TEXTROWS) 25 | cdecl_type(BMPREGION) 26 | cdecl_type(PAGEREGION) 27 | cdecl_type(PAGEREGIONS) 28 | cdecl_struct(KOPTContext) 29 | cdecl_type(KOPTContext) 30 | 31 | cdecl_func(bmp_init) 32 | cdecl_func(bmp_free) 33 | cdecl_func(bmp_alloc) 34 | cdecl_func(bmp_bytewidth) 35 | cdecl_func(bmp_copy) 36 | cdecl_func(wrectmaps_init) 37 | cdecl_func(wrectmaps_free) 38 | cdecl_func(wrectmap_inside) 39 | cdecl_func(k2pdfopt_get_reflowed_word_boxes) 40 | cdecl_func(k2pdfopt_get_native_word_boxes) 41 | cdecl_func(k2pdfopt_tocr_single_word) 42 | cdecl_func(k2pdfopt_reflow_bmp) 43 | cdecl_func(k2pdfopt_tocr_end) 44 | cdecl_func(k2pdfopt_crop_bmp) 45 | cdecl_func(k2pdfopt_optimize_bmp) 46 | cdecl_func(pixmap_to_bmp) 47 | cdecl_func(bitmap2pix) 48 | -------------------------------------------------------------------------------- /thirdparty/czmq/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -6,7 +6,7 @@ 4 | ######################################################################## 5 | # Project setup 6 | ######################################################################## 7 | -cmake_minimum_required(VERSION 2.8.12) 8 | +cmake_minimum_required(VERSION 3.17.5) 9 | project(czmq) 10 | enable_language(C) 11 | enable_testing() 12 | @@ -123,6 +123,13 @@ 13 | set(MORE_LIBRARIES) 14 | endif() 15 | 16 | +set(CMAKE_REQUIRED_LIBRARIES -lrt) 17 | +check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME) 18 | +set(CMAKE_REQUIRED_LIBRARIES) 19 | +if(HAVE_CLOCK_GETTIME) 20 | + list(APPEND MORE_LIBRARIES -lrt) 21 | +endif() 22 | + 23 | list(APPEND CMAKE_MODULE_PATH "${SOURCE_DIR}") 24 | set(OPTIONAL_LIBRARIES) 25 | set(OPTIONAL_LIBRARIES_STATIC) 26 | @@ -544,6 +549,7 @@ 27 | ######################################################################## 28 | # executables 29 | ######################################################################## 30 | +if(FALSE) 31 | add_executable( 32 | zmakecert 33 | "${SOURCE_DIR}/src/zmakecert.c" 34 | @@ -631,6 +637,7 @@ 35 | ${OPTIONAL_LIBRARIES_STATIC} 36 | ) 37 | endif() 38 | +endif() 39 | 40 | ######################################################################## 41 | # tests 42 | -------------------------------------------------------------------------------- /thirdparty/libzmq/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES cmake_tweaks.patch) 2 | if(LEGACY OR POCKETBOOK) 3 | list(APPEND PATCH_FILES disable_eventfd.patch) 4 | endif() 5 | 6 | list(APPEND CMAKE_ARGS 7 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 8 | # Project options. 9 | -DBUILD_SHARED=$> 10 | -DBUILD_STATIC=$ 11 | -DENABLE_DRAFTS=FALSE 12 | -DWITH_DOC=FALSE 13 | -DWITH_LIBBSD=FALSE 14 | -DZMQ_BUILD_FRAMEWORK=FALSE 15 | -DZMQ_BUILD_TESTS=FALSE 16 | # Disable some dependencies (which will automatically 17 | # disable the corresponding project optional features). 18 | -DCMAKE_DISABLE_FIND_PACKAGE_AsciiDoc=TRUE 19 | ) 20 | if(LEGACY OR POCKETBOOK) 21 | list(APPEND CMAKE_ARGS -DPOLLER=epoll) 22 | endif() 23 | 24 | list(APPEND BUILD_CMD COMMAND ninja) 25 | 26 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 27 | 28 | if(NOT MONOLIBTIC) 29 | append_shared_lib_install_commands(INSTALL_CMD zmq VERSION 5) 30 | endif() 31 | 32 | external_project( 33 | DOWNLOAD URL ae933b1e98411fd7cb8309f9502d2737 34 | https://github.com/zeromq/libzmq/releases/download/v4.3.5/zeromq-4.3.5.tar.gz 35 | PATCH_FILES ${PATCH_FILES} 36 | CMAKE_ARGS ${CMAKE_ARGS} 37 | BUILD_COMMAND ${BUILD_CMD} 38 | INSTALL_COMMAND ${INSTALL_CMD} 39 | ) 40 | -------------------------------------------------------------------------------- /spec/unit/data/simple.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 16 | 18 | 19 | 21 | image/svg+xml 22 | 24 | 25 | 26 | 27 | 28 | 30 | Simple test document 39 | 40 | 41 | -------------------------------------------------------------------------------- /thirdparty/luasocket/overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.17.5) 2 | project(luasocket LANGUAGES C) 3 | 4 | find_package(PkgConfig REQUIRED) 5 | pkg_check_modules(LuaJIT luajit REQUIRED IMPORTED_TARGET) 6 | 7 | add_library(luasocket STATIC) 8 | set_target_properties(luasocket PROPERTIES C_VISIBILITY_PRESET hidden) 9 | target_sources(luasocket PRIVATE 10 | src/auxiliar.c 11 | src/buffer.c 12 | src/compat.c 13 | src/except.c 14 | src/inet.c 15 | src/io.c 16 | src/options.c 17 | src/select.c 18 | src/tcp.c 19 | src/timeout.c 20 | src/udp.c 21 | ) 22 | if(APPLE) 23 | target_sources(luasocket PRIVATE src/usocket.c) 24 | elseif(LINUX) 25 | target_sources(luasocket PRIVATE src/usocket.c) 26 | elseif(WIN32) 27 | # TODO 28 | message(FATAL_ERROR "Windows is not supported") 29 | endif() 30 | target_link_libraries(luasocket PRIVATE PkgConfig::LuaJIT) 31 | 32 | foreach(MOD mcore score) 33 | if(BUILD_SHARED_LIBS) 34 | add_library(${MOD} MODULE) 35 | else() 36 | add_library(${MOD} STATIC) 37 | endif() 38 | set_target_properties(${MOD} PROPERTIES C_VISIBILITY_PRESET hidden PREFIX "") 39 | target_link_libraries(${MOD} PRIVATE luasocket PkgConfig::LuaJIT) 40 | endforeach() 41 | target_sources(mcore PRIVATE src/mime.c) 42 | target_sources(score PRIVATE src/luasocket.c) 43 | -------------------------------------------------------------------------------- /thirdparty/lunasvg/xtended/ximageelement.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGEELEMENT_H 2 | #define IMAGEELEMENT_H 3 | 4 | #include "graphicselement.h" 5 | #include "layoutcontext.h" 6 | 7 | namespace lunasvg { 8 | 9 | class ImageElement : public GraphicsElement 10 | { 11 | public: 12 | ImageElement(); 13 | 14 | void layout(LayoutContext* context, LayoutContainer* current) const override; 15 | 16 | std::unique_ptr clone() const override; 17 | }; 18 | 19 | class LayoutImage : public LayoutObject 20 | { 21 | public: 22 | LayoutImage(); 23 | 24 | void render(RenderState& state) const; 25 | Rect map(const Rect& rect) const; 26 | const Rect& fillBoundingBox() const; 27 | const Rect& strokeBoundingBox() const; 28 | 29 | public: 30 | external_context_t * external_context; 31 | std::string href; 32 | double x; 33 | double y; 34 | double width; 35 | double height; 36 | PreserveAspectRatio preserveAspectRatio; 37 | Transform transform; 38 | FillData fillData; 39 | StrokeData strokeData; 40 | Visibility visibility; 41 | WindRule clipRule; 42 | double opacity; 43 | const LayoutMask* masker; 44 | const LayoutClipPath* clipper; 45 | 46 | private: 47 | mutable Rect m_fillBoundingBox{Rect::Invalid}; 48 | mutable Rect m_strokeBoundingBox{Rect::Invalid}; 49 | }; 50 | 51 | } // namespace lunasvg 52 | 53 | #endif // IMAGEELEMENT_H 54 | -------------------------------------------------------------------------------- /thirdparty/dropbear/reduce_build_verbosity.patch: -------------------------------------------------------------------------------- 1 | diff --git a/Makefile.in b/Makefile.in 2 | index fe63a80..effe613 100644 3 | --- a/Makefile.in 4 | +++ b/Makefile.in 5 | @@ -168,7 +168,7 @@ $(OBJ_DIR): 6 | mkdir -p $@ 7 | 8 | $(OBJ_DIR)/%.o: $(srcdir)/%.c $(HEADERS) | $(OBJ_DIR) 9 | - $(CC) $(CFLAGS) $(CPPFLAGS) $< -o $@ -c 10 | + $(if $V,,@echo " * ${CC} $@"; )$(CC) $(CFLAGS) $(CPPFLAGS) $< -o $@ -c 11 | 12 | fuzz/%.o: $(srcdir)/../fuzz/%.c $(HEADERS) 13 | $(CC) $(CFLAGS) $(CPPFLAGS) $< -o $@ -c 14 | diff --git a/libtomcrypt/Makefile.in b/libtomcrypt/Makefile.in 15 | index ec135c5..cb77a07 100644 16 | --- a/libtomcrypt/Makefile.in 17 | +++ b/libtomcrypt/Makefile.in 18 | @@ -243,7 +243,7 @@ $(TOBJECTS): $(HEADERS) tests/tomcrypt_test.h 19 | #This is necessary for compatibility with BSD make (namely on OpenBSD) 20 | .SUFFIXES: .o .c 21 | .c.o: 22 | - $(CC) $(LTC_CFLAGS) -c $< -o $@ 23 | + $(if $V,,@echo " * ${CC} $@"; )$(CC) $(LTC_CFLAGS) -c $< -o $@ 24 | 25 | #Create libtomcrypt.a 26 | $(LIBMAIN_S): $(OBJECTS) 27 | diff --git a/libtommath/Makefile.in b/libtommath/Makefile.in 28 | index 3cacdd8..7b9c1d4 100644 29 | --- a/libtommath/Makefile.in 30 | +++ b/libtommath/Makefile.in 31 | @@ -10,8 +10,6 @@ CFLAGS += -I$(srcdir) -I../libtomcrypt/src/headers/ -I$(srcdir)/../libtomcrypt/s 32 | CFLAGS += -Wno-deprecated 33 | CFLAGS += $(CPPFLAGS) 34 | 35 | -V = 1 36 | - 37 | ifeq ($V,1) 38 | silent= 39 | else 40 | -------------------------------------------------------------------------------- /ffi-cdecl/harfbuzz_cdecl.c: -------------------------------------------------------------------------------- 1 | // CPPFLAGS="-I/usr/include/freetype2" 2 | 3 | #include 4 | #include 5 | #include 6 | #include "ffi-cdecl.h" 7 | 8 | // The few bits we actually rely on for ffi/harfbuzz.lua 9 | cdecl_c99_type(hb_codepoint_t, uint32_t) 10 | cdecl_union(_hb_var_int_t) 11 | cdecl_type(hb_var_int_t) 12 | 13 | cdecl_type(hb_face_t) 14 | cdecl_type(hb_language_t) 15 | cdecl_type(hb_ot_name_id_t) 16 | cdecl_struct(hb_ot_name_entry_t) 17 | cdecl_type(hb_ot_name_entry_t) 18 | cdecl_type(hb_set_t) 19 | 20 | cdecl_func(hb_ot_name_list_names) 21 | cdecl_func(hb_language_to_string) 22 | cdecl_func(hb_ot_name_get_utf8) 23 | cdecl_func(hb_set_create) 24 | cdecl_func(hb_face_collect_unicodes) 25 | cdecl_func(hb_set_set) 26 | cdecl_func(hb_set_intersect) 27 | cdecl_func(hb_set_get_population) 28 | cdecl_func(hb_set_destroy) 29 | cdecl_func(hb_face_destroy) 30 | cdecl_func(hb_set_add_range) 31 | 32 | // And in front (frontend/fontlist.lua) 33 | cdecl_type(hb_blob_t) 34 | cdecl_type(hb_memory_mode_t) 35 | cdecl_type(hb_destroy_func_t) 36 | 37 | cdecl_const(HB_OT_NAME_ID_FONT_FAMILY) 38 | cdecl_const(HB_OT_NAME_ID_FONT_SUBFAMILY) 39 | cdecl_const(HB_OT_NAME_ID_FULL_NAME) 40 | 41 | cdecl_type(FT_Face) 42 | 43 | cdecl_func(hb_blob_create) 44 | cdecl_func(hb_face_create) 45 | cdecl_func(hb_blob_destroy) 46 | cdecl_func(hb_face_get_glyph_count) 47 | cdecl_func(hb_ft_face_create_referenced) 48 | -------------------------------------------------------------------------------- /thirdparty/luarocks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build in source tree. 2 | set(BINARY_DIR ${SOURCE_DIR}) 3 | 4 | list(APPEND CFG_CMD COMMAND 5 | ./configure 6 | --prefix=${STAGING_DIR} 7 | --with-lua=${STAGING_DIR} 8 | ) 9 | 10 | list(APPEND BUILD_CMD COMMAND make) 11 | 12 | list(APPEND INSTALL_CMD COMMAND make install) 13 | 14 | # Try to use our compilation flags. 15 | set(LD ${CC}) 16 | set(LIBFLAGS ${DYNLIB_LDFLAGS}) 17 | foreach(VAR CC CFLAGS LD LIBFLAGS) 18 | list(APPEND INSTALL_CMD COMMAND ${STAGING_DIR}/bin/luarocks config -- ${VAR} "${${VAR}}") 19 | endforeach() 20 | # Luarocks needs to be told where librt is when building 21 | # luasystem with clang in our Ubuntu based docker image. 22 | if(EMULATE_READER AND NOT APPLE) 23 | # NOTE: `librt.so.1` may not exists (e.g. on Alpine Linux), in which 24 | # case `find_compiler_lib_path` will return a false value ("NOTFOUND"). 25 | find_compiler_lib_path(RT_LIB librt.so.1) 26 | if(RT_LIB) 27 | get_filename_component(RT_LIBDIR ${RT_LIB} DIRECTORY) 28 | list(APPEND INSTALL_CMD COMMAND ${STAGING_DIR}/bin/luarocks config -- RT_LIBDIR "${RT_LIBDIR}") 29 | endif() 30 | endif() 31 | 32 | external_project( 33 | DOWNLOAD URL 56d10945997f2eab5922f24195550a1d 34 | https://github.com/luarocks/luarocks/archive/refs/tags/v3.12.2.tar.gz 35 | CONFIGURE_COMMAND ${CFG_CMD} 36 | BUILD_COMMAND ${BUILD_CMD} 37 | INSTALL_COMMAND ${INSTALL_CMD} 38 | ) 39 | -------------------------------------------------------------------------------- /libxss-dummy.c: -------------------------------------------------------------------------------- 1 | // Dummy symbol resolver for AppImage 2 | // See https://github.com/koreader/koreader/issues/4627 3 | // Thanks to https://github.com/AppImage/pkg2appimage/issues/127#issuecomment-278397037 4 | #include 5 | typedef unsigned long ulong; 6 | typedef unsigned int uint; 7 | typedef struct XScreenSaverInfo XScreenSaverInfo; 8 | Bool XScreenSaverQueryExtension(Display *dpy, int *event_base_return, int *error_base_return) { return False; } 9 | Status XScreenSaverQueryVersion(Display *dpy, int *major_version_return, int *minor_version_return) { return False; } 10 | XScreenSaverInfo *XScreenSaverAllocInfo(void) { return NULL; } 11 | Status XScreenSaverQueryInfo(Display *dpy, Drawable drawable, XScreenSaverInfo *saver_info) { return 0; } 12 | void XScreenSaverSelectInput(register Display *dpy, Drawable drawable, ulong mask) {} 13 | void XScreenSaverSetAttributes(Display *dpy, Drawable drawable, int x, int y, uint width, uint height, 14 | uint border_width, int depth, uint class, Visual *visual, ulong valuemask, XSetWindowAttributes *attributes) {} 15 | void XScreenSaverUnsetAttributes(register Display *dpy, Drawable drawable) {} 16 | Status XScreenSaverRegister(Display *dpy, int screen, XID xid, Atom type) { return 0; } 17 | Status XScreenSaverUnregister(Display *dpy, int screen) { return 0; } 18 | Status XScreenSaverGetRegistered(Display *dpy, int screen, XID *xid, Atom *type) { return 0; } 19 | void XScreenSaverSuspend(Display *dpy, Bool suspend) {} 20 | -------------------------------------------------------------------------------- /ffi/einkfb_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | enum fx_type { 7 | fx_mask = 11, 8 | fx_buf_is_mask = 14, 9 | fx_none = -1, 10 | fx_flash = 20, 11 | fx_invert = 21, 12 | fx_update_partial = 0, 13 | fx_update_full = 1, 14 | fx_update_fast = 2, 15 | fx_update_slow = 3, 16 | fx_buffer_load = 99, 17 | fx_buffer_display_partial = 100, 18 | fx_buffer_display_full = 101, 19 | }; 20 | struct update_area_t { 21 | int x1; 22 | int y1; 23 | int x2; 24 | int y2; 25 | enum fx_type which_fx; 26 | uint8_t *buffer; 27 | }; 28 | enum orientation_t { 29 | orientation_portrait = 0, 30 | orientation_portrait_upside_down = 1, 31 | orientation_landscape = 2, 32 | orientation_landscape_upside_down = 3, 33 | }; 34 | enum einkfb_events_t { 35 | einkfb_event_update_display = 0, 36 | einkfb_event_update_display_area = 1, 37 | einkfb_event_blank_display = 2, 38 | einkfb_event_rotate_display = 3, 39 | einkfb_event_null = -1, 40 | }; 41 | struct einkfb_event_t { 42 | enum einkfb_events_t event; 43 | enum fx_type update_mode; 44 | int x1; 45 | int y1; 46 | int x2; 47 | int y2; 48 | enum orientation_t orientation; 49 | }; 50 | static const int FBIO_EINK_UPDATE_DISPLAY = 18139; 51 | static const int FBIO_EINK_UPDATE_DISPLAY_AREA = 18141; 52 | static const int FBIO_EINK_SET_DISPLAY_ORIENTATION = 18160; 53 | static const int FBIO_EINK_GET_DISPLAY_ORIENTATION = 18161; 54 | ]] 55 | -------------------------------------------------------------------------------- /thirdparty/lua-ljsqlite3/LICENSE: -------------------------------------------------------------------------------- 1 | =============================================================================== 2 | 3 | LJSQLite3: SQlite3 Interface. 4 | 5 | Copyright (C) 2014-2016 Stefano Peluchetti. All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | [ MIT license: http://opensource.org/licenses/MIT ] 26 | 27 | =============================================================================== -------------------------------------------------------------------------------- /ffi/mxcfb_sony_h.lua: -------------------------------------------------------------------------------- 1 | local ffi = require("ffi") 2 | 3 | ffi.cdef[[ 4 | struct mxcfb_rect { 5 | unsigned int top; 6 | unsigned int left; 7 | unsigned int width; 8 | unsigned int height; 9 | }; 10 | 11 | struct mxcfb_alt_buffer_data { 12 | void* virt_addr; 13 | unsigned int phys_addr; 14 | unsigned int width; 15 | unsigned int height; 16 | struct mxcfb_rect alt_update_region; 17 | }; 18 | 19 | struct mxcfb_update_data { 20 | struct mxcfb_rect update_region; 21 | unsigned int waveform_mode; 22 | unsigned int update_mode; 23 | unsigned int update_marker; 24 | int temp; 25 | unsigned int flags; 26 | struct mxcfb_alt_buffer_data alt_buffer_data; 27 | }; 28 | 29 | static const int UPDATE_MODE_PARTIAL = 0; 30 | static const int UPDATE_MODE_FULL = 1; 31 | 32 | static const int WAVEFORM_MODE_INIT = 0; 33 | static const int WAVEFORM_MODE_DU = 1; 34 | static const int WAVEFORM_MODE_GC16 = 2; 35 | static const int WAVEFORM_MODE_GC4 = 3; 36 | static const int WAVEFORM_MODE_A2 = 4; 37 | static const int WAVEFORM_MODE_AUTO = 257; 38 | static const int TEMP_USE_AMBIENT = 4096; 39 | static const int TEMP_USE_AUTO = 4097; // this does not exist, simply use a value different than above 40 | static const int EPDC_FLAG_ENABLE_INVERSION = 1; 41 | static const int EPDC_FLAG_FORCE_MONOCHROME = 2; 42 | static const int EPDC_FLAG_USE_ALT_BUFFER = 256; 43 | 44 | static const int MXCFB_SEND_UPDATE = 1078216238; 45 | static const int MXCFB_WAIT_FOR_UPDATE_COMPLETE = 1074021935; 46 | ]] 47 | -------------------------------------------------------------------------------- /thirdparty/turbo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES 2 | # Drop duplicate cdefs, make sure turbo find its 3 | # libtffi_wrap library, and pull in upstream fixes. 4 | turbo.patch 5 | d7a8a247a4a2689b0f207162eb804141c87c4899.patch 6 | ) 7 | 8 | # Remove the 7 years-old copy of a CA bundle that turbo doesn't actually use. 9 | list(APPEND PATCH_CMD COMMAND rm turbo/ca-certificates.crt) 10 | # Some of the LUA files are executables for no good reason. 11 | list(APPEND PATCH_CMD COMMAND chmod a-x turbo/platform.lua turbo/socket_ffi.lua turbo/syscall.lua) 12 | 13 | list(APPEND CMAKE_ARGS 14 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 15 | -DBUILD_SHARED_LIBS=$> 16 | ) 17 | 18 | list(APPEND BUILD_CMD COMMAND ninja) 19 | 20 | if(MONOLIBTIC) 21 | append_install_commands(INSTALL_CMD libtffi_wrap.a DESTINATION ${STAGING_DIR}/lib) 22 | else() 23 | append_binary_install_command(INSTALL_CMD libtffi_wrap${LIB_EXT} DESTINATION libs) 24 | endif() 25 | append_install_commands(INSTALL_CMD ${SOURCE_DIR}/turbo.lua ${SOURCE_DIR}/turbovisor.lua DESTINATION common) 26 | append_tree_install_commands(INSTALL_CMD ${SOURCE_DIR}/turbo common/turbo) 27 | 28 | external_project( 29 | DOWNLOAD GIT v2.1.3 30 | https://github.com/kernelsauce/turbo 31 | PATCH_OVERLAY overlay 32 | PATCH_FILES ${PATCH_FILES} 33 | PATCH_COMMAND ${PATCH_CMD} 34 | CMAKE_ARGS ${CMAKE_ARGS} 35 | BUILD_COMMAND ${BUILD_CMD} 36 | INSTALL_COMMAND ${INSTALL_CMD} 37 | ) 38 | -------------------------------------------------------------------------------- /thirdparty/zlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Pre-emptively rename `zconf.h`: this is normaly done 2 | # by `CMakeLists.txt` at configure time, and wreaks havoc 3 | # with `build.d` generation. Since the later is done before 4 | # configuring, a missing `zconf.h` would endlessly trigger 5 | # a new zlib build. 6 | list(APPEND PATCH_CMD COMMAND mv zconf.h zconf.h.included) 7 | 8 | list(APPEND CMAKE_ARGS 9 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 10 | # Project options. 11 | -DINSTALL_PKGCONFIG_DIR=${STAGING_DIR}/lib/pkgconfig 12 | ) 13 | 14 | list(APPEND BUILD_CMD COMMAND ninja zlib zlibstatic) 15 | 16 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 17 | 18 | append_install_commands(INSTALL_CMD ${SOURCE_DIR}/contrib/minizip/crypt.h DESTINATION ${STAGING_DIR}/include/contrib/minizip) 19 | if(MONOLIBTIC) 20 | # The CMake build system does not support building & installing only 21 | # a static / shared library, so we have to manually cleanup after the 22 | # install step. 23 | list(APPEND INSTALL_CMD COMMAND sh -c "rm -v \"$1\"*" -- ${STAGING_DIR}/lib/libz${LIB_EXT}) 24 | else() 25 | append_shared_lib_install_commands(INSTALL_CMD z VERSION 1) 26 | endif() 27 | 28 | external_project( 29 | DOWNLOAD URL 5e6af153311327e516690d300527ec9e 30 | https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.xz 31 | PATCH_COMMAND ${PATCH_CMD} 32 | CMAKE_ARGS ${CMAKE_ARGS} 33 | BUILD_COMMAND ${BUILD_CMD} 34 | INSTALL_COMMAND ${INSTALL_CMD} 35 | ) 36 | -------------------------------------------------------------------------------- /ffi-cdecl/sqlite3_cdecl.c: -------------------------------------------------------------------------------- 1 | #include "sqlite3.h" 2 | #include "ffi-cdecl.h" 3 | 4 | cdecl_type(sqlite3) 5 | cdecl_type(sqlite3_context) 6 | cdecl_type(sqlite3_stmt) 7 | cdecl_type(sqlite3_value) 8 | 9 | cdecl_func(sqlite3_aggregate_context) 10 | cdecl_func(sqlite3_bind_blob) 11 | cdecl_func(sqlite3_bind_double) 12 | cdecl_func(sqlite3_bind_int64) 13 | cdecl_func(sqlite3_bind_null) 14 | cdecl_func(sqlite3_bind_parameter_index) 15 | cdecl_func(sqlite3_bind_text) 16 | cdecl_func(sqlite3_busy_timeout) 17 | cdecl_func(sqlite3_clear_bindings) 18 | cdecl_func(sqlite3_close_v2) 19 | cdecl_func(sqlite3_column_blob) 20 | cdecl_func(sqlite3_column_bytes) 21 | cdecl_func(sqlite3_column_count) 22 | cdecl_func(sqlite3_column_double) 23 | cdecl_func(sqlite3_column_int64) 24 | cdecl_func(sqlite3_column_name) 25 | cdecl_func(sqlite3_column_text) 26 | cdecl_func(sqlite3_column_type) 27 | cdecl_func(sqlite3_create_function) 28 | cdecl_func(sqlite3_errmsg) 29 | cdecl_func(sqlite3_exec) 30 | cdecl_func(sqlite3_finalize) 31 | cdecl_func(sqlite3_open_v2) 32 | cdecl_func(sqlite3_prepare_v2) 33 | cdecl_func(sqlite3_reset) 34 | cdecl_func(sqlite3_result_blob) 35 | cdecl_func(sqlite3_result_double) 36 | cdecl_func(sqlite3_result_error) 37 | cdecl_func(sqlite3_result_int64) 38 | cdecl_func(sqlite3_result_text) 39 | cdecl_func(sqlite3_step) 40 | cdecl_func(sqlite3_value_blob) 41 | cdecl_func(sqlite3_value_bytes) 42 | cdecl_func(sqlite3_value_double) 43 | cdecl_func(sqlite3_value_int64) 44 | cdecl_func(sqlite3_value_text) 45 | cdecl_func(sqlite3_value_type) 46 | -------------------------------------------------------------------------------- /ffi/fbink_input_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | typedef enum { 7 | INPUT_UNKNOWN = 0, 8 | INPUT_POINTINGSTICK = 1, 9 | INPUT_MOUSE = 2, 10 | INPUT_TOUCHPAD = 4, 11 | INPUT_TOUCHSCREEN = 8, 12 | INPUT_JOYSTICK = 16, 13 | INPUT_TABLET = 32, 14 | INPUT_KEY = 64, 15 | INPUT_KEYBOARD = 128, 16 | INPUT_ACCELEROMETER = 256, 17 | INPUT_POWER_BUTTON = 65536, 18 | INPUT_SLEEP_COVER = 131072, 19 | INPUT_PAGINATION_BUTTONS = 262144, 20 | INPUT_HOME_BUTTON = 524288, 21 | INPUT_LIGHT_BUTTON = 1048576, 22 | INPUT_MENU_BUTTON = 2097152, 23 | INPUT_DPAD = 4194304, 24 | INPUT_ROTATION_EVENT = 8388608, 25 | INPUT_SCALED_TABLET = 16777216, 26 | INPUT_VOLUME_BUTTONS = 33554432, 27 | INPUT_KINDLE_FRAME_TAP = 67108864, 28 | } __attribute__((packed)) INPUT_DEVICE_TYPE_E; 29 | typedef uint32_t INPUT_DEVICE_TYPE_T; 30 | typedef enum { 31 | SCAN_ONLY = 1, 32 | OPEN_BLOCKING = 2, 33 | MATCH_ALL = 4, 34 | EXCLUDE_ALL = 8, 35 | NO_RECAP = 16, 36 | } __attribute__((packed)) INPUT_SETTINGS_TYPE_E; 37 | typedef uint32_t INPUT_SETTINGS_TYPE_T; 38 | typedef struct { 39 | INPUT_DEVICE_TYPE_T type; 40 | int fd; 41 | bool matched; 42 | char name[256]; 43 | char path[4096]; 44 | } FBInkInputDevice; 45 | FBInkInputDevice *fbink_input_scan(INPUT_DEVICE_TYPE_T, INPUT_DEVICE_TYPE_T, INPUT_SETTINGS_TYPE_T, size_t *); 46 | FBInkInputDevice *fbink_input_check(const char *, INPUT_DEVICE_TYPE_T, INPUT_DEVICE_TYPE_T, INPUT_SETTINGS_TYPE_T); 47 | ]] 48 | -------------------------------------------------------------------------------- /ffi/zeromq_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | typedef struct _zmsg_t zmsg_t; 7 | typedef struct _zhash_t zhash_t; 8 | typedef struct _zsock_t zsock_t; 9 | typedef struct _zframe_t zframe_t; 10 | typedef struct _zpoller_t zpoller_t; 11 | static const int ZFRAME_MORE = 1; 12 | static const int ZFRAME_REUSE = 2; 13 | static const int ZMQ_IDENTITY = 5; 14 | static const int ZMQ_STREAM = 11; 15 | int zmq_getsockopt(void *, int, void *, size_t *); 16 | int zmq_send(void *, const void *, size_t, int); 17 | int zsock_bind(zsock_t *, const char *, ...); 18 | int zsock_connect(zsock_t *, const char *, ...); 19 | void zsock_destroy(zsock_t **); 20 | zsock_t *zsock_new(int); 21 | void *zsock_resolve(void *); 22 | unsigned char *zframe_data(zframe_t *); 23 | void zframe_destroy(zframe_t **); 24 | zframe_t *zframe_recv(void *); 25 | int zframe_send(zframe_t **, void *, int); 26 | size_t zframe_size(zframe_t *); 27 | int zmsg_addmem(zmsg_t *, const void *, size_t); 28 | void zmsg_destroy(zmsg_t **); 29 | zmsg_t *zmsg_new(void); 30 | zframe_t *zmsg_pop(zmsg_t *); 31 | char *zmsg_popstr(zmsg_t *); 32 | int zmsg_send(zmsg_t **, void *); 33 | size_t zmsg_size(zmsg_t *); 34 | void zstr_free(char **); 35 | int zstr_send(void *, const char *); 36 | const char *zhash_cursor(zhash_t *); 37 | void zhash_destroy(zhash_t **); 38 | zhash_t *zhash_unpack(zframe_t *); 39 | void zpoller_destroy(zpoller_t **); 40 | zpoller_t *zpoller_new(void *, ...); 41 | void *zpoller_wait(zpoller_t *, int); 42 | ]] 43 | -------------------------------------------------------------------------------- /ffi/kobolight.lua: -------------------------------------------------------------------------------- 1 | local ffi = require("ffi") 2 | local bor = bit.bor 3 | local C = ffi.C 4 | 5 | -- for closing on garbage collection, we need a pointer or aggregate 6 | -- cdata object (not a plain "int"). So we encapsulate in a struct. 7 | ffi.cdef[[ 8 | typedef struct light_fd { int ld; } light_fd; 9 | ]] 10 | 11 | -- for ioctl header definition: 12 | require("ffi/posix_h") 13 | 14 | local kobolight = {} 15 | local kobolight_mt = {__index={}} 16 | 17 | function kobolight_mt.__index:close() 18 | -- this is redundant to garbage collection of the 19 | -- whole object and not strictly needed. 20 | -- it allows to force-close immediately, though. 21 | if self.light_fd and self.light_fd.ld ~= -1 then 22 | C.close(self.light_fd.ld) 23 | self.light_fd.ld = -1 24 | end 25 | end 26 | 27 | function kobolight_mt.__index:setBrightness(brightness) 28 | assert(brightness >= 0 and brightness <= 100, 29 | "Wrong brightness value given!") 30 | 31 | assert(C.ioctl(self.light_fd.ld, 241, ffi.cast("int", brightness)) == 0, 32 | "cannot change brightess value") 33 | end 34 | 35 | function kobolight.open(device) 36 | local light = { 37 | light_fd = nil, 38 | } 39 | 40 | local ld = C.open(device or "/dev/ntx_io", bor(C.O_RDONLY, C.O_NONBLOCK, C.O_CLOEXEC)) 41 | assert(ld ~= -1, "cannot open ntx_io character device") 42 | light.light_fd = ffi.gc( 43 | ffi.new("light_fd", ld), 44 | function (light_fd) C.close(light_fd.ld) end 45 | ) 46 | 47 | setmetatable(light, kobolight_mt) 48 | return light 49 | end 50 | 51 | return kobolight 52 | -------------------------------------------------------------------------------- /thirdparty/zsync2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES cmake_tweaks.patch) 2 | 3 | list(APPEND CMAKE_ARGS 4 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 5 | -DOPENSSL_USE_STATIC_LIBS=$ 6 | # Options. 7 | -DBUILD_CPR_TESTS=FALSE 8 | -DBUILD_TESTING=FALSE 9 | -DCPR_FORCE_OPENSSL_BACKEND=TRUE 10 | -DUSE_SYSTEM_CURL=TRUE 11 | ) 12 | 13 | list(APPEND BUILD_CMD COMMAND ninja zsync2) 14 | 15 | append_binary_install_command(INSTALL_CMD src/zsync2) 16 | 17 | # NOTE: We're currently using our own fork instead of upstream's (https://github.com/AppImage/zsync2): 18 | ## * Enable range requests optimizations on the CLI 19 | ## * Re-implement the -u flag for compatibility w/ the old zsync CLI 20 | ## * Minor CLI output cleanup 21 | ## * Squish all the warnings 22 | ## * Prevent passing a malformed referer URL 23 | ## * Don't print seven billion progress bars 24 | ## * Rebase against zsync master (c.f., rebase-zsync-libs branch) 25 | ## * Rebase against zlib 1.3.0.1 (c.f., rebase-zlib branch) 26 | ## * Workaround potential download loops, like what happened w/ the 2019.12 -> 2020.01 update. 27 | ## * Mangle logging to play nice w/ FBInk 28 | ## * Plug memory leaks 29 | # c.f., https://github.com/NiLuJe/zsync2 for more details. 30 | 31 | external_project( 32 | DOWNLOAD GIT e281e1eb4466ff6b3866c25dbe62a3e150fa5bfd 33 | https://github.com/NiLuJe/zsync2.git 34 | PATCH_FILES ${PATCH_FILES} 35 | CMAKE_ARGS ${CMAKE_ARGS} 36 | BUILD_COMMAND ${BUILD_CMD} 37 | INSTALL_COMMAND ${INSTALL_CMD} 38 | ) 39 | -------------------------------------------------------------------------------- /ffi/libwebp_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | static const int WEBP_DEMUX_ABI_VERSION = 263; 7 | enum WEBP_CSP_MODE { 8 | MODE_RGB = 0, 9 | MODE_RGBA = 1, 10 | MODE_BGR = 2, 11 | MODE_BGRA = 3, 12 | MODE_ARGB = 4, 13 | MODE_RGBA_4444 = 5, 14 | MODE_RGB_565 = 6, 15 | MODE_rgbA = 7, 16 | MODE_bgrA = 8, 17 | MODE_Argb = 9, 18 | MODE_rgbA_4444 = 10, 19 | MODE_YUV = 11, 20 | MODE_YUVA = 12, 21 | MODE_LAST = 13, 22 | }; 23 | struct WebPData { 24 | const uint8_t *bytes; 25 | size_t size; 26 | }; 27 | typedef struct WebPData WebPData; 28 | struct WebPAnimInfo { 29 | uint32_t canvas_width; 30 | uint32_t canvas_height; 31 | uint32_t loop_count; 32 | uint32_t bgcolor; 33 | uint32_t frame_count; 34 | uint32_t pad[4]; 35 | }; 36 | typedef struct WebPAnimInfo WebPAnimInfo; 37 | struct WebPAnimDecoderOptions { 38 | enum WEBP_CSP_MODE color_mode; 39 | int use_threads; 40 | uint32_t padding[7]; 41 | }; 42 | typedef struct WebPAnimDecoderOptions WebPAnimDecoderOptions; 43 | int WebPAnimDecoderOptionsInitInternal(WebPAnimDecoderOptions *, int); 44 | struct WebPAnimDecoder; 45 | typedef struct WebPAnimDecoder WebPAnimDecoder; 46 | WebPAnimDecoder *WebPAnimDecoderNewInternal(const WebPData *, const WebPAnimDecoderOptions *, int); 47 | int WebPAnimDecoderGetInfo(const WebPAnimDecoder *, WebPAnimInfo *); 48 | int WebPAnimDecoderGetNext(WebPAnimDecoder *, uint8_t **, int *); 49 | void WebPAnimDecoderReset(WebPAnimDecoder *); 50 | void WebPAnimDecoderDelete(WebPAnimDecoder *); 51 | ]] 52 | -------------------------------------------------------------------------------- /ffi/inotify_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | static const int IN_ACCESS = 1; 7 | static const int IN_ATTRIB = 4; 8 | static const int IN_CLOSE_WRITE = 8; 9 | static const int IN_CLOSE_NOWRITE = 16; 10 | static const int IN_CREATE = 256; 11 | static const int IN_DELETE = 512; 12 | static const int IN_DELETE_SELF = 1024; 13 | static const int IN_MODIFY = 2; 14 | static const int IN_MOVE_SELF = 2048; 15 | static const int IN_MOVED_FROM = 64; 16 | static const int IN_MOVED_TO = 128; 17 | static const int IN_OPEN = 32; 18 | static const int IN_ALL_EVENTS = 4095; 19 | static const int IN_MOVE = 192; 20 | static const int IN_CLOSE = 24; 21 | static const int IN_DONT_FOLLOW = 33554432; 22 | static const int IN_EXCL_UNLINK = 67108864; 23 | static const int IN_MASK_ADD = 536870912; 24 | static const int IN_ONESHOT = 2147483648; 25 | static const int IN_ONLYDIR = 16777216; 26 | static const int IN_IGNORED = 32768; 27 | static const int IN_ISDIR = 1073741824; 28 | static const int IN_Q_OVERFLOW = 16384; 29 | static const int IN_UNMOUNT = 8192; 30 | static const int IN_NONBLOCK = 2048; 31 | static const int IN_CLOEXEC = 524288; 32 | int inotify_init(void) __attribute__((nothrow, leaf)); 33 | int inotify_init1(int) __attribute__((nothrow, leaf)); 34 | int inotify_add_watch(int, const char *, uint32_t) __attribute__((nothrow, leaf)); 35 | int inotify_rm_watch(int, int) __attribute__((nothrow, leaf)); 36 | struct inotify_event { 37 | int wd; 38 | uint32_t mask; 39 | uint32_t cookie; 40 | uint32_t len; 41 | char name[]; 42 | }; 43 | ]] 44 | -------------------------------------------------------------------------------- /thirdparty/zstd/no_qsort_r.patch: -------------------------------------------------------------------------------- 1 | --- a/lib/dictBuilder/cover.c 2 | +++ b/lib/dictBuilder/cover.c 3 | @@ -241,7 +241,7 @@ 4 | unsigned d; 5 | } COVER_ctx_t; 6 | 7 | -#if !defined(_GNU_SOURCE) && !defined(__APPLE__) && !defined(_MSC_VER) 8 | +#if 1 9 | /* C90 only offers qsort() that needs a global context. */ 10 | static COVER_ctx_t *g_coverCtx = NULL; 11 | #endif 12 | @@ -290,7 +290,7 @@ 13 | */ 14 | #if (defined(_WIN32) && defined(_MSC_VER)) || defined(__APPLE__) 15 | static int WIN_CDECL COVER_strict_cmp(void* g_coverCtx, const void* lp, const void* rp) { 16 | -#elif defined(_GNU_SOURCE) 17 | +#elif 0 18 | static int COVER_strict_cmp(const void *lp, const void *rp, void *g_coverCtx) { 19 | #else /* C90 fallback.*/ 20 | static int COVER_strict_cmp(const void *lp, const void *rp) { 21 | @@ -306,7 +306,7 @@ 22 | */ 23 | #if (defined(_WIN32) && defined(_MSC_VER)) || defined(__APPLE__) 24 | static int WIN_CDECL COVER_strict_cmp8(void* g_coverCtx, const void* lp, const void* rp) { 25 | -#elif defined(_GNU_SOURCE) 26 | +#elif 0 27 | static int COVER_strict_cmp8(const void *lp, const void *rp, void *g_coverCtx) { 28 | #else /* C90 fallback.*/ 29 | static int COVER_strict_cmp8(const void *lp, const void *rp) { 30 | @@ -328,7 +328,7 @@ 31 | qsort_r(ctx->suffix, ctx->suffixSize, sizeof(U32), 32 | ctx, 33 | (ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp)); 34 | -#elif defined(_GNU_SOURCE) 35 | +#elif 0 36 | qsort_r(ctx->suffix, ctx->suffixSize, sizeof(U32), 37 | (ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp), 38 | ctx); 39 | -------------------------------------------------------------------------------- /thirdparty/glib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES 2 | # We only care about `libglib-2.0.a`. 3 | libglib-only.patch 4 | # We don't need regex support, and removing it gets rid of the pcre2 dependency. 5 | no_regex_support.patch 6 | ) 7 | if(LEGACY OR POCKETBOOK) 8 | # Avoid pulling-in `__sched_cpucount@GLIBC_2.6`, `eventfd@GLIBC_2.7`, 9 | # `pipe2@GLIBC_2.9` or `mkostemp@GLIBC_2.7`. 10 | list(APPEND PATCH_FILES no_glibc_2.6_or_above_symbols.patch) 11 | endif() 12 | 13 | if(ANDROID OR APPLE) 14 | set(ICONV gnu) 15 | else() 16 | set(ICONV libc) 17 | endif() 18 | 19 | list(APPEND CFG_CMD COMMAND 20 | ${MESON_SETUP} --default-library=static 21 | -Dglib_assert=false 22 | -Dglib_debug=disabled 23 | -Dtests=false 24 | -Dxattr=false 25 | ${SOURCE_DIR} 26 | ) 27 | 28 | list(APPEND BUILD_CMD COMMAND ninja glib/libglib-2.0.a) 29 | 30 | list(APPEND INSTALL_CMD COMMAND ${MESON_INSTALL} --tags devel) 31 | # Don't install the pkg-config entry: 32 | # - sdcv is the only user, and needs to be manually coaxed into using our GLib anyway. 33 | # - when building SDL2 for the AppImage, IBus headers include some GObject headers, 34 | # which our patched version does not include. 35 | list(APPEND INSTALL_CMD COMMAND rm -f ${STAGING_DIR}/lib/pkgconfig/glib-2.0.pc) 36 | 37 | external_project( 38 | DOWNLOAD URL d101f1acab6805d4d6d3104e9634b8e3 39 | https://download.gnome.org/sources/glib/2.82/glib-2.82.1.tar.xz 40 | PATCH_FILES ${PATCH_FILES} 41 | CONFIGURE_COMMAND ${CFG_CMD} 42 | BUILD_COMMAND ${BUILD_CMD} 43 | INSTALL_COMMAND ${INSTALL_CMD} 44 | ) 45 | -------------------------------------------------------------------------------- /ffi-cdecl/leptonica_cdecl.c: -------------------------------------------------------------------------------- 1 | // CPPFLAGS="-I/var/tmp/niluje/leptonica/src" 2 | #include 3 | 4 | #include "ffi-cdecl.h" 5 | 6 | cdecl_type(l_int8) 7 | cdecl_type(l_uint8) 8 | cdecl_type(l_int16) 9 | cdecl_type(l_uint16) 10 | cdecl_type(l_int32) 11 | cdecl_type(l_uint32) 12 | cdecl_type(l_float32) 13 | cdecl_type(l_float64) 14 | 15 | cdecl_type(BOX) 16 | cdecl_type(BOXA) 17 | cdecl_type(NUMA) 18 | cdecl_type(PIX) 19 | cdecl_type(PIXA) 20 | 21 | cdecl_const(L_NOCOPY) 22 | cdecl_const(L_COPY) 23 | cdecl_const(L_CLONE) 24 | 25 | cdecl_func(boxAdjustSides) 26 | cdecl_func(boxCreate) 27 | cdecl_func(boxDestroy) 28 | cdecl_func(boxGetGeometry) 29 | cdecl_func(boxOverlapRegion) 30 | cdecl_func(boxaAddBox) 31 | cdecl_func(boxaClipToBox) 32 | cdecl_func(boxaCombineOverlaps) 33 | cdecl_func(boxaCreate) 34 | cdecl_func(boxaDestroy) 35 | cdecl_func(boxaGetBox) 36 | cdecl_func(boxaGetBoxGeometry) 37 | cdecl_func(boxaGetCount) 38 | cdecl_func(numaCreateFromFArray) 39 | cdecl_func(numaDestroy) 40 | cdecl_func(numaGetCount) 41 | cdecl_func(numaGetFArray) 42 | cdecl_func(numaGetIValue) 43 | cdecl_func(pixClipRectangle) 44 | cdecl_func(pixClone) 45 | cdecl_func(pixConnCompBB) 46 | cdecl_func(pixConvertRGBToGrayFast) 47 | cdecl_func(pixConvertTo32) 48 | cdecl_func(pixDestroy) 49 | cdecl_func(pixDrawBoxaRandom) 50 | cdecl_func(pixGetDepth) 51 | cdecl_func(pixGetHeight) 52 | cdecl_func(pixGetRegionsBinary) 53 | cdecl_func(pixGetWidth) 54 | cdecl_func(pixInvert) 55 | cdecl_func(pixMultiplyByColor) 56 | cdecl_func(pixSplitIntoBoxa) 57 | cdecl_func(pixThresholdToBinary) 58 | cdecl_func(pixWriteMemPng) 59 | cdecl_func(pixWritePng) 60 | -------------------------------------------------------------------------------- /ffi/rtc_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | struct rtc_time { 7 | int tm_sec; 8 | int tm_min; 9 | int tm_hour; 10 | int tm_mday; 11 | int tm_mon; 12 | int tm_year; 13 | int tm_wday; 14 | int tm_yday; 15 | int tm_isdst; 16 | }; 17 | struct rtc_wkalrm { 18 | unsigned char enabled; 19 | unsigned char pending; 20 | struct rtc_time time; 21 | }; 22 | static const int RTC_AIE_ON = 28673; 23 | static const int RTC_AIE_OFF = 28674; 24 | static const int RTC_WKALM_SET = 1076391951; 25 | static const int RTC_WKALM_RD = 2150133776; 26 | static const int RTC_RD_TIME = 2149871625; 27 | typedef long int time_t; 28 | struct tm { 29 | int tm_sec; 30 | int tm_min; 31 | int tm_hour; 32 | int tm_mday; 33 | int tm_mon; 34 | int tm_year; 35 | int tm_wday; 36 | int tm_yday; 37 | int tm_isdst; 38 | long int tm_gmtoff; 39 | const char *tm_zone; 40 | }; 41 | time_t time(time_t *) __attribute__((nothrow, leaf)); 42 | struct tm *gmtime(const time_t *) __attribute__((nothrow, leaf)); 43 | struct tm *gmtime_r(const time_t *restrict, struct tm *restrict) __attribute__((nothrow, leaf)); 44 | struct tm *localtime(const time_t *) __attribute__((nothrow, leaf)); 45 | struct tm *localtime_r(const time_t *restrict, struct tm *restrict) __attribute__((nothrow, leaf)); 46 | time_t timegm(struct tm *) __attribute__((nothrow, leaf)); 47 | time_t mktime(struct tm *) __attribute__((nothrow, leaf)); 48 | int settimeofday(const struct timeval *, const struct timezone *) __attribute__((nothrow, leaf)); 49 | void tzset(void) __attribute__((nothrow, leaf)); 50 | ]] 51 | -------------------------------------------------------------------------------- /ffi/framebuffer_dummy.lua: -------------------------------------------------------------------------------- 1 | local BB = require("ffi/blitbuffer") 2 | 3 | local framebuffer = {} 4 | 5 | function framebuffer:init() 6 | self.bb = BB.new(600, 800) 7 | self.bb:fill(BB.COLOR_WHITE) 8 | 9 | framebuffer.parent.init(self) 10 | end 11 | 12 | function framebuffer:resize(w, h) 13 | end 14 | 15 | function framebuffer:_newBB(w, h) 16 | local rotation 17 | local inverse 18 | 19 | if self.bb then 20 | rotation = self.bb:getRotation() 21 | inverse = self.bb:getInverse() == 1 22 | self.bb:free() 23 | end 24 | if self.invert_bb then self.invert_bb:free() end 25 | 26 | -- we present this buffer to the outside 27 | local bb = BB.new(w, h, BB.TYPE_BBRGB32) 28 | local flash = os.getenv("EMULATE_READER_FLASH") 29 | if flash then 30 | -- in refresh emulation mode, we use a shadow blitbuffer 31 | -- and blit refresh areas from it. 32 | self.bb = BB.new(w, h, BB.TYPE_BBRGB32) 33 | else 34 | self.bb = bb 35 | end 36 | self.invert_bb = BB.new(w, h, BB.TYPE_BBRGB32) 37 | 38 | if rotation then 39 | self.bb:setRotation(rotation) 40 | end 41 | 42 | -- reinit inverse mode on resize 43 | if inverse then 44 | self.bb:invert() 45 | end 46 | end 47 | 48 | function framebuffer:_render(bb, x, y, w, h) 49 | end 50 | 51 | function framebuffer:refreshFullImp(x, y, w, h) 52 | end 53 | 54 | function framebuffer:setWindowTitle(new_title) 55 | end 56 | 57 | function framebuffer:setWindowIcon(icon) 58 | end 59 | 60 | function framebuffer:close() 61 | end 62 | 63 | return require("ffi/framebuffer"):extend(framebuffer) 64 | -------------------------------------------------------------------------------- /ffi-cdecl/blitbuffer_cdecl.c: -------------------------------------------------------------------------------- 1 | #include "blitbuffer.h" 2 | #include "ffi-cdecl.h" 3 | 4 | /* cdecl_type(Color4L) */ 5 | /* cdecl_struct(Color4L) */ 6 | /* cdecl_type(Color4U) */ 7 | /* cdecl_struct(Color4U) */ 8 | cdecl_type(Color8) 9 | cdecl_struct(Color8) 10 | cdecl_type(Color8A) 11 | cdecl_struct(Color8A) 12 | cdecl_type(ColorRGB16) 13 | cdecl_struct(ColorRGB16) 14 | cdecl_type(ColorRGB24) 15 | cdecl_struct(ColorRGB24) 16 | cdecl_type(ColorRGB32) 17 | cdecl_struct(ColorRGB32) 18 | 19 | cdecl_type(BlitBuffer) 20 | cdecl_struct(BlitBuffer) 21 | /* cdecl_type(BlitBuffer4) */ 22 | /* cdecl_struct(BlitBuffer4) */ 23 | cdecl_type(BlitBuffer8) 24 | cdecl_struct(BlitBuffer8) 25 | cdecl_type(BlitBuffer8A) 26 | cdecl_struct(BlitBuffer8A) 27 | cdecl_type(BlitBufferRGB16) 28 | cdecl_struct(BlitBufferRGB16) 29 | cdecl_type(BlitBufferRGB24) 30 | cdecl_struct(BlitBufferRGB24) 31 | cdecl_type(BlitBufferRGB32) 32 | cdecl_struct(BlitBufferRGB32) 33 | 34 | cdecl_func(BB_add_blit_from) 35 | cdecl_func(BB_alpha_blit_from) 36 | cdecl_func(BB_blend_rect) 37 | cdecl_func(BB_blend_RGB32_over_rect) 38 | cdecl_func(BB_blend_RGB_multiply_rect) 39 | cdecl_func(BB_blend_RGB32_multiply_rect) 40 | cdecl_func(BB_blit_to) 41 | cdecl_func(BB_color_blit_from) 42 | cdecl_func(BB_color_blit_from_RGB32) 43 | cdecl_func(BB_dither_alpha_blit_from) 44 | cdecl_func(BB_dither_blit_to) 45 | cdecl_func(BB_dither_pmulalpha_blit_from) 46 | cdecl_func(BB_fill) 47 | cdecl_func(BB_fill_rect) 48 | cdecl_func(BB_fill_rect_RGB32) 49 | cdecl_func(BB_hatch_rect) 50 | cdecl_func(BB_invert_blit_from) 51 | cdecl_func(BB_invert_rect) 52 | cdecl_func(BB_paint_rounded_corner) 53 | cdecl_func(BB_pmulalpha_blit_from) 54 | -------------------------------------------------------------------------------- /thirdparty/sdl2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES 2 | cmake_tweaks.patch 3 | # Remove workarounds for standalone applications and add 4 | # a couple of actions to be used from the osx main menu. 5 | cocoa.patch 6 | ) 7 | if(APPIMAGE) 8 | # Tweak pkg-config search path (allow system packages), 9 | # help stupid cmake find system libraries, and fail if 10 | # required features / subsystems can't be enabled. 11 | list(APPEND PATCH_FILES appimage.patch) 12 | endif() 13 | 14 | list(APPEND CMAKE_ARGS 15 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 16 | # Project options. 17 | -DSDL2_DISABLE_SDL2MAIN=ON 18 | -DSDL_CMAKE_DEBUG_POSTFIX= # Remove 'd' suffix for the debug build library. 19 | -DSDL_SHARED=ON 20 | -DSDL_STATIC=OFF 21 | -DSDL_TEST=OFF 22 | # We don't need audio support. 23 | -DSDL_AUDIO=OFF 24 | -DSDL_LIBSAMPLERATE=OFF 25 | ) 26 | if(APPIMAGE) 27 | list(APPEND CMAKE_ARGS 28 | # Miscellaneous video features/subsystems we don't care about. 29 | -DSDL_DIRECTFB=OFF 30 | -DSDL_KMSDRM=OFF 31 | -DSDL_RPI=OFF 32 | ) 33 | endif() 34 | 35 | list(APPEND BUILD_CMD COMMAND ninja) 36 | 37 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 38 | 39 | append_shared_lib_install_commands(INSTALL_CMD SDL2-2.0 VERSION 0) 40 | 41 | external_project( 42 | DOWNLOAD URL 7b234751c91737168d88c83041ca5aa9 43 | https://github.com/libsdl-org/SDL/releases/download/release-2.32.10/SDL2-2.32.10.tar.gz 44 | PATCH_FILES ${PATCH_FILES} 45 | CMAKE_ARGS ${CMAKE_ARGS} 46 | BUILD_COMMAND ${BUILD_CMD} 47 | INSTALL_COMMAND ${INSTALL_CMD} 48 | ) 49 | -------------------------------------------------------------------------------- /utils/binfind.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import platform 5 | import sys 6 | 7 | 8 | def iself(path): 9 | if path.endswith('.dbg'): 10 | return False 11 | with open(path, 'rb') as fp: 12 | return fp.read(4) == b'\x7FELF' 13 | 14 | def ismacho(path): 15 | if path.endswith('.dSYM'): 16 | return False 17 | if path.endswith('.tbd'): 18 | return True 19 | with open(path, 'rb') as fp: 20 | # NOTE: check for 64-bits little endian binaries only. 21 | return fp.read(4) in b'\xcf\xfa\xed\xfe' 22 | 23 | def any_darwin_bin(paths): 24 | return any( 25 | p.endswith('.dylib') or p.endswith('.tbd') 26 | or (os.path.isfile(p) and ismacho(p)) 27 | for p in paths 28 | ) 29 | 30 | def binfind(pathlist, darwin=None): 31 | if darwin is None: 32 | darwin = platform.system() == 'Darwin' 33 | isbin = ismacho if darwin else iself 34 | for path in pathlist: 35 | if not os.path.isdir(path): 36 | assert os.path.isfile(path), path 37 | if isbin(path): 38 | yield path 39 | for dirpath, _dirnames, filenames in os.walk(path): 40 | for entry in filenames: 41 | entry = os.path.join(dirpath, entry) 42 | if os.access(entry, os.X_OK) and isbin(entry): 43 | yield entry 44 | 45 | 46 | def main(args, darwin=None): 47 | if darwin is None: 48 | darwin = platform.system() == 'Darwin' or any_darwin_bin(args) 49 | print('\n'.join(sorted(binfind(args, darwin=darwin)))) 50 | 51 | if __name__ == '__main__': 52 | sys.exit(main(sys.argv[1:])) 53 | -------------------------------------------------------------------------------- /thirdparty/lua-rapidjson/cmake_tweaks.patch: -------------------------------------------------------------------------------- 1 | --- i/CMakeLists.txt 2 | +++ w/CMakeLists.txt 3 | @@ -1,4 +1,4 @@ 4 | -cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) 5 | +cmake_minimum_required(VERSION 3.17.5 FATAL_ERROR) 6 | 7 | project(lua-rapidjson) 8 | 9 | @@ -24,19 +24,6 @@ if (LUA_RAPIDJSON_VERSION) 10 | endif() 11 | 12 | if(UNIX) 13 | - if(APPLE) 14 | - set(PLAT "macosx") 15 | - set(LINK_FLAGS "-bundle -undefined dynamic_lookup -all_load") 16 | - else(APPLE) 17 | - set(PLAT "linux") 18 | - set(LINK_FLAGS "-shared") 19 | - endif(APPLE) 20 | - add_compile_options(-g -Wall -fPIC) 21 | - include(CheckCXXCompilerFlag) 22 | - CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_ARCH_NATIVE) 23 | - if (COMPILER_SUPPORTS_ARCH_NATIVE) 24 | - add_compile_options(-march=native) 25 | - endif() 26 | else(UNIX) 27 | if(WIN32) 28 | set(PLAT "win32") 29 | @@ -69,7 +56,11 @@ 30 | src/calibre.hpp 31 | ) 32 | 33 | -add_library(lua-rapidjson MODULE ${SOURCES}) 34 | +if(BUILD_SHARED_LIBS) 35 | + add_library(lua-rapidjson MODULE ${SOURCES}) 36 | +else() 37 | + add_library(lua-rapidjson STATIC ${SOURCES}) 38 | +endif() 39 | if(${CMAKE_VERSION} VERSION_LESS "3.1.0") 40 | if(CMAKE_COMPILER_IS_GNUCXX) 41 | execute_process(COMMAND "${CMAKE_CXX_COMPILER} -dumpversion" OUTPUT_VARIABLE GCC_VERSION) 42 | @@ -84,9 +71,7 @@ endif() 43 | 44 | source_group(src FILES ${SOURCES}) 45 | 46 | -if (WIN32) 47 | - target_link_libraries(lua-rapidjson ${LUA_LIBRARIES}) 48 | -endif() 49 | +target_link_libraries(lua-rapidjson m ${LUA_LIBRARIES}) 50 | 51 | if (LINK_FLAGS) 52 | set_target_properties(lua-rapidjson PROPERTIES 53 | -------------------------------------------------------------------------------- /thirdparty/libwebp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES cmake_tweaks.patch) 2 | 3 | list(APPEND CMAKE_ARGS 4 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 5 | -DBUILD_SHARED_LIBS=$> 6 | # Project options. 7 | # Note: we could build libwebpdecoder.so only, which would be smaller and fine 8 | # decoding single frame webp images. But it fails on animated webp images, not 9 | # even rendering the first frame. We need the regular libraries (`libwebp.so` 10 | # and `libwebpdemux.so`) to handle them (but we can left out the encoder, 11 | # `libwebpmux.so`). 12 | -DWEBP_BUILD_ANIM_UTILS=FALSE 13 | -DWEBP_BUILD_CWEBP=FALSE 14 | -DWEBP_BUILD_DWEBP=FALSE 15 | -DWEBP_BUILD_EXTRAS=FALSE 16 | -DWEBP_BUILD_GIF2WEBP=FALSE 17 | -DWEBP_BUILD_IMG2WEBP=FALSE 18 | -DWEBP_BUILD_LIBWEBPMUX=FALSE 19 | -DWEBP_BUILD_VWEBP=FALSE 20 | -DWEBP_BUILD_WEBPINFO=FALSE 21 | -DWEBP_BUILD_WEBPMUX=FALSE 22 | -DWEBP_ENABLE_SIMD=$ 23 | ) 24 | 25 | list(APPEND BUILD_CMD COMMAND ninja) 26 | 27 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 28 | 29 | if(NOT MONOLIBTIC) 30 | append_shared_lib_install_commands(INSTALL_CMD sharpyuv VERSION 0) 31 | append_shared_lib_install_commands(INSTALL_CMD webpdemux VERSION 2) 32 | append_shared_lib_install_commands(INSTALL_CMD webp VERSION 7) 33 | endif() 34 | 35 | external_project( 36 | DOWNLOAD URL cceb6447180f961473b181c9ef38b630 37 | https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.6.0.tar.gz 38 | PATCH_FILES ${PATCH_FILES} 39 | CMAKE_ARGS ${CMAKE_ARGS} 40 | BUILD_COMMAND ${BUILD_CMD} 41 | INSTALL_COMMAND ${INSTALL_CMD} 42 | ) 43 | -------------------------------------------------------------------------------- /thirdparty/lunasvg/xtended/xtspanelement.h: -------------------------------------------------------------------------------- 1 | #ifndef TSPANELEMENT_H 2 | #define TSPANELEMENT_H 3 | 4 | #include "geometryelement.h" 5 | #include "layoutcontext.h" 6 | 7 | namespace lunasvg { 8 | 9 | enum class TextAnchor 10 | { 11 | Start, 12 | Middle, 13 | End, 14 | }; 15 | 16 | enum class LengthAdjust 17 | { 18 | None, 19 | Spacing, 20 | SpacingAndGlyphs, 21 | }; 22 | 23 | // Text drawing state, passed from to/by all sub- 24 | typedef struct { 25 | double cursor_x; 26 | double cursor_y; 27 | double current_start_x; 28 | double current_start_y; 29 | double current_end_x; 30 | double current_end_y; 31 | bool current_started; 32 | bool last_was_space; 33 | bool is_pre; 34 | bool is_vertical_rl; 35 | TextAnchor text_anchor; 36 | TextAnchor current_text_anchor; 37 | LengthAdjust current_length_adjust; 38 | double current_adjust_text_length; 39 | std::unique_ptr current_group; 40 | } text_state_t; 41 | 42 | class TSpanElement : public GeometryElement 43 | { 44 | public: 45 | // Limited support for , that we make just a special kind of with TSpanElement(ElementID::TextPath) 46 | TSpanElement(ElementID id=ElementID::TSpan); 47 | 48 | static void addCurrentGroup(LayoutGroup* parent, text_state_t &text_state); 49 | 50 | void layoutText(LayoutContext* context, LayoutGroup* parent, text_state_t &text_state) const; 51 | 52 | void layout(LayoutContext* context, LayoutContainer* current) const override; // not used 53 | 54 | Path path() const override { return Path{}; } // not used 55 | 56 | std::unique_ptr clone() const override; 57 | }; 58 | 59 | } // namespace lunasvg 60 | 61 | #endif // TSPANELEMENT_H 62 | -------------------------------------------------------------------------------- /thirdparty/djvulibre/djvulibre-no-locale-mangling.patch: -------------------------------------------------------------------------------- 1 | diff --git a/libdjvu/GString.cpp b/libdjvu/GString.cpp 2 | index b17ed2a..5f844bd 100644 3 | --- a/libdjvu/GString.cpp 4 | +++ b/libdjvu/GString.cpp 5 | @@ -88,14 +88,7 @@ 6 | #endif 7 | #include 8 | 9 | -#ifndef LC_NUMERIC //MingW 10 | -# undef DO_CHANGELOCALE 11 | -# define LC_NUMERIC 0 12 | -#endif 13 | -#ifndef DO_CHANGELOCALE 14 | -# define DO_CHANGELOCALE 0 15 | -#endif 16 | - 17 | +#undef DO_CHANGELOCALE 18 | 19 | #ifdef HAVE_NAMESPACES 20 | namespace DJVU { 21 | @@ -241,11 +234,6 @@ GStringRep::UTF8::create(const char fmt[],va_list& args) 22 | 23 | #define NATIVE_CREATE(x) UTF8::create( x ); 24 | 25 | -#ifdef LC_ALL 26 | -#undef LC_ALL 27 | -#endif 28 | -#define LC_ALL 0 29 | - 30 | class GStringRep::ChangeLocale 31 | { 32 | public: 33 | diff --git a/libdjvu/ddjvuapi.cpp b/libdjvu/ddjvuapi.cpp 34 | index c6cecfe..c0fef7d 100644 35 | --- a/libdjvu/ddjvuapi.cpp 36 | +++ b/libdjvu/ddjvuapi.cpp 37 | @@ -358,12 +358,6 @@ ddjvu_context_create(const char *programname) 38 | ddjvu_context_t *ctx = 0; 39 | G_TRY 40 | { 41 | -#ifdef LC_ALL 42 | - setlocale(LC_ALL,""); 43 | -# ifdef LC_NUMERIC 44 | - setlocale(LC_NUMERIC, "C"); 45 | -# endif 46 | -#endif 47 | if (programname) 48 | djvu_programname(programname); 49 | DjVuMessage::use_language(); 50 | diff --git a/tools/common.h b/tools/common.h 51 | index e28fb58..873fbb7 100644 52 | --- a/tools/common.h 53 | +++ b/tools/common.h 54 | @@ -76,8 +76,6 @@ 55 | djvu_programname(argv[0]); } while (0) 56 | #else 57 | # define DJVU_LOCALE do { \ 58 | - setlocale(LC_ALL,""); \ 59 | - setlocale(LC_NUMERIC,"C"); \ 60 | djvu_programname(argv[0]); } while (0) 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /thirdparty/srell/license.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** 3 | ** SRELL (std::regex-like library) version 3.018 4 | ** 5 | ** Copyright (c) 2012-2023, Nozomu Katoo. All rights reserved. 6 | ** 7 | ** Redistribution and use in source and binary forms, with or without 8 | ** modification, are permitted provided that the following conditions are 9 | ** met: 10 | ** 11 | ** 1. Redistributions of source code must retain the above copyright notice, 12 | ** this list of conditions and the following disclaimer. 13 | ** 14 | ** 2. Redistributions in binary form must reproduce the above copyright 15 | ** notice, this list of conditions and the following disclaimer in the 16 | ** documentation and/or other materials provided with the distribution. 17 | ** 18 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS 19 | ** IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | ** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | ** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | ** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | ** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | ** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | ** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ** 30 | ****************************************************************************** 31 | **/ 32 | 33 | -------------------------------------------------------------------------------- /thirdparty/glib/no_glibc_2.6_or_above_symbols.patch: -------------------------------------------------------------------------------- 1 | --- i/meson.build 2 | +++ w/meson.build 3 | @@ -709,7 +709,6 @@ functions = [ 4 | 'memalign', 5 | 'mmap', 6 | 'newlocale', 7 | - 'pipe2', 8 | 'poll', 9 | 'prlimit', 10 | 'readlink', 11 | @@ -945,14 +944,6 @@ else 12 | endif 13 | message('Checking whether to use statfs or statvfs .. ' + stat_func_to_use) 14 | 15 | -if host_system == 'linux' 16 | - if cc.has_function('mkostemp', 17 | - prefix: '''#define _GNU_SOURCE 18 | - #include ''') 19 | - glib_conf.set('HAVE_MKOSTEMP', 1) 20 | - endif 21 | -endif 22 | - 23 | osx_ldflags = [] 24 | glib_have_os_x_9_or_later = false 25 | glib_have_carbon = false 26 | @@ -1014,16 +1005,6 @@ if cc.compiles('''#include 27 | glib_conf.set('HAVE_FUTEX_TIME64', 1) 28 | endif 29 | 30 | -# Check for eventfd(2) 31 | -if cc.links('''#include 32 | - #include 33 | - int main (int argc, char ** argv) { 34 | - eventfd (0, EFD_CLOEXEC); 35 | - return 0; 36 | - }''', name : 'eventfd(2) system call') 37 | - glib_conf.set('HAVE_EVENTFD', 1) 38 | -endif 39 | - 40 | # Check for ppoll(2) 41 | if cc.links('''#define _GNU_SOURCE 42 | #include 43 | @@ -2113,9 +2094,6 @@ else 44 | if cc.has_header_symbol('pthread.h', 'pthread_getname_np', prefix : pthread_prefix) 45 | glib_conf.set('HAVE_PTHREAD_GETNAME_NP', 1) 46 | endif 47 | - if cc.has_header_symbol('pthread.h', 'pthread_getaffinity_np', prefix : pthread_prefix) 48 | - glib_conf.set('HAVE_PTHREAD_GETAFFINITY_NP', 1) 49 | - endif 50 | 51 | # Assume that pthread_setname_np is available in some form; same as configure 52 | if cc.links(pthread_prefix + ''' 53 | -------------------------------------------------------------------------------- /ffi-cdecl/sunxi_kobo_decl.c: -------------------------------------------------------------------------------- 1 | #include 2 | // specialized sunxi disp/eink headers 3 | #include "include/sunxi-kobo.h" 4 | 5 | #include "ffi-cdecl.h" 6 | 7 | cdecl_struct(area_info) 8 | cdecl_enum(eink_update_mode) 9 | cdecl_struct(disp_rectsz) 10 | cdecl_enum(disp_pixel_format) 11 | cdecl_enum(disp_color_space) 12 | cdecl_struct(disp_rect64) 13 | cdecl_enum(disp_buffer_flags) 14 | cdecl_enum(disp_scan_flags) 15 | cdecl_enum(disp_layer_mode) 16 | cdecl_struct(disp_rect) 17 | cdecl_enum(disp_3d_out_mode) 18 | cdecl_enum(disp_eotf) 19 | cdecl_enum(disp_atw_mode) 20 | cdecl_struct(disp_atw_info) 21 | cdecl_struct(disp_fb_info2) 22 | cdecl_struct(disp_layer_info2) 23 | cdecl_struct(disp_layer_config2) 24 | 25 | cdecl_const(DISP_EINK_UPDATE2) 26 | cdecl_const(DISP_EINK_WAIT_BEFORE_LCD_INT_COMPLETE) 27 | cdecl_const(DISP_EINK_SET_UPDATE_CONTROL) 28 | cdecl_const(DISP_EINK_WAIT_FRAME_SYNC_COMPLETE) 29 | cdecl_const(DISP_EINK_SET_NTX_HANDWRITE_ONOFF) 30 | cdecl_const(DISP_EINK_SET_WAIT_MODE_ONOFF) 31 | 32 | cdecl_type(sunxi_disp_raw_ioctl) 33 | cdecl_type(sunxi_disp_eink_update2) 34 | cdecl_type(sunxi_disp_eink_set_update_control) 35 | cdecl_type(sunxi_disp_eink_wait_frame_sync_complete) 36 | cdecl_type(sunxi_disp_eink_set_ntx_handwrite_onoff) 37 | cdecl_type(sunxi_disp_eink_set_wait_mode_onoff) 38 | 39 | cdecl_struct(disp_fb_info) 40 | cdecl_struct(disp_layer_info) 41 | cdecl_struct(disp_layer_config) 42 | cdecl_type(sunxi_disp_eink_update) 43 | cdecl_type(sunxi_disp_eink_set_temp) 44 | cdecl_type(sunxi_disp_eink_overlap_skip) 45 | cdecl_type(sunxi_disp_eink_set_gc_count) 46 | cdecl_struct(cfa_enable) 47 | cdecl_type(sunxi_disp_eink_set_bg_onoff) 48 | cdecl_type(sunxi_disp_layer_get_config2) 49 | cdecl_type(sunxi_disp_layer_get_config) 50 | cdecl_type(sunxi_disp_layer_generic_get) 51 | 52 | cdecl_type(sunxi_disp_eink_ioctl) 53 | -------------------------------------------------------------------------------- /thirdparty/czmq/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES 2 | cmake_tweaks.patch 3 | # Fix 2 bugs in prefix handling. 4 | fix_prefix_handling.patch 5 | ) 6 | if(ANDROID) 7 | list(APPEND PATCH_FILES android.patch) 8 | endif() 9 | 10 | # Pre-emptively remove `src/platform.h`: this is normaly done by 11 | # `CMakeLists.txt` at configure time, and wreaks havoc with `build.d` 12 | # generation. Since the later is done before configuring, a missing 13 | # `src/platform.h` would endlessly trigger a new czmq build. 14 | list(APPEND PATCH_CMD COMMAND rm src/platform.h) 15 | 16 | list(APPEND CMAKE_ARGS 17 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 18 | # Project options. 19 | -DCZMQ_BUILD_SHARED=$> 20 | -DCZMQ_BUILD_STATIC=$ 21 | -DENABLE_DRAFTS=FALSE 22 | # Disable some dependencies (which will automatically 23 | # disable the corresponding project optional features). 24 | -DCMAKE_DISABLE_FIND_PACKAGE_libcurl=TRUE 25 | -DCMAKE_DISABLE_FIND_PACKAGE_libmicrohttpd=TRUE 26 | -DCMAKE_DISABLE_FIND_PACKAGE_lz4=TRUE 27 | -DCMAKE_DISABLE_FIND_PACKAGE_nss=TRUE 28 | -DCMAKE_DISABLE_FIND_PACKAGE_systemd=TRUE 29 | -DCMAKE_DISABLE_FIND_PACKAGE_uuid=TRUE 30 | ) 31 | 32 | list(APPEND BUILD_CMD COMMAND ninja) 33 | 34 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 35 | 36 | if(NOT MONOLIBTIC) 37 | append_shared_lib_install_commands(INSTALL_CMD czmq VERSION 4) 38 | endif() 39 | 40 | external_project( 41 | DOWNLOAD URL 471e9ec120fc66a2fe2aae14359e3cfa 42 | https://github.com/zeromq/czmq/releases/download/v4.2.1/czmq-4.2.1.tar.gz 43 | PATCH_FILES ${PATCH_FILES} 44 | PATCH_COMMAND ${PATCH_CMD} 45 | CMAKE_ARGS ${CMAKE_ARGS} 46 | BUILD_COMMAND ${BUILD_CMD} 47 | INSTALL_COMMAND ${INSTALL_CMD} 48 | ) 49 | -------------------------------------------------------------------------------- /spec/unit/font_spec.lua: -------------------------------------------------------------------------------- 1 | require("ffi_wrapper") 2 | local ffi = require("ffi") 3 | 4 | describe("Low level font interfaces", function() 5 | it("FreeType and HarfBuzz FFI should work", function() 6 | assert.has_no.errors(function() 7 | -- HL wrappers are omitted deliberately - faster bisect in case those fail, but we don't. 8 | local ft = ffi.loadlib("freetype", "6") 9 | require("ffi/freetype_h") 10 | local hb = require("ffi/harfbuzz") 11 | 12 | -- This font is deliberately "odd" - raw ttf data - to test that both can see it the same 13 | local font = "spec/base/unit/data/testfont.ttf" 14 | local nglyphs = 15 15 | 16 | -- First try with HB 17 | local fontdata = io.open(font, "rb"):read("*a") 18 | local blob = hb.hb_blob_create(fontdata, #fontdata, hb.HB_MEMORY_MODE_READONLY, nil, nil) 19 | local face = hb.hb_face_create(blob, 0) 20 | hb.hb_blob_destroy(blob) 21 | assert.are.equals(hb.hb_face_get_glyph_count(face), nglyphs) 22 | hb.hb_face_destroy(face) 23 | 24 | -- Then with FT 25 | local ftlibp = ffi.new("FT_Library[1]") 26 | local facep = ffi.new("FT_Face[1]") 27 | ft.FT_Init_FreeType(ftlibp) 28 | ft.FT_New_Face(ftlibp[0], font, 0, facep) 29 | assert.are.equals(facep[0].num_glyphs, nglyphs) 30 | 31 | -- Try to turn the FT face into HB face 32 | face = hb.hb_ft_face_create_referenced(facep[0]) 33 | ft.FT_Done_Face(facep[0]) 34 | 35 | -- Check if it works 36 | assert.are.equals(hb.hb_face_get_glyph_count(face), nglyphs) 37 | hb.hb_face_destroy(face) 38 | --ft.FT_Done_FreeType(ftlibp[0]) 39 | end) 40 | end) 41 | end) 42 | 43 | -------------------------------------------------------------------------------- /ffi/mxcfb_cervantes_h.lua: -------------------------------------------------------------------------------- 1 | -- Automatically generated with ffi-cdecl. 2 | 3 | local ffi = require("ffi") 4 | 5 | ffi.cdef[[ 6 | static const int UPDATE_MODE_PARTIAL = 0; 7 | static const int UPDATE_MODE_FULL = 1; 8 | static const int TEMP_USE_AMBIENT = 4096; 9 | static const int WAVEFORM_MODE_AUTO = 257; 10 | static const int WAVEFORM_MODE_INIT = 0; 11 | static const int WAVEFORM_MODE_DU = 1; 12 | static const int WAVEFORM_MODE_GC16 = 2; 13 | static const int WAVEFORM_MODE_A2 = 4; 14 | static const int WAVEFORM_MODE_GL16 = 5; 15 | static const int WAVEFORM_MODE_GLR16 = 6; 16 | static const int WAVEFORM_MODE_GLD16 = 7; 17 | static const int EPDC_FLAG_ENABLE_INVERSION = 1; 18 | static const int EPDC_FLAG_FORCE_MONOCHROME = 2; 19 | static const int EPDC_FLAG_USE_ALT_BUFFER = 256; 20 | static const int EPDC_FLAG_USE_CMAP = 4; 21 | static const int EPDC_FLAG_TEST_COLLISION = 512; 22 | static const int EPDC_FLAG_GROUP_UPDATE = 1024; 23 | static const int EPDC_FLAG_USE_DITHERING_Y1 = 8192; 24 | static const int EPDC_FLAG_USE_DITHERING_Y4 = 16384; 25 | static const int EPDC_FLAG_USE_AAD = 4096; 26 | static const int EPDC_FLAG_USE_DITHERING_NTX_D8 = 1048576; 27 | struct mxcfb_rect { 28 | unsigned int top; 29 | unsigned int left; 30 | unsigned int width; 31 | unsigned int height; 32 | }; 33 | struct mxcfb_alt_buffer_data { 34 | void *virt_addr; 35 | unsigned int phys_addr; 36 | unsigned int width; 37 | unsigned int height; 38 | struct mxcfb_rect alt_update_region; 39 | }; 40 | struct mxcfb_update_data { 41 | struct mxcfb_rect update_region; 42 | unsigned int waveform_mode; 43 | unsigned int update_mode; 44 | unsigned int update_marker; 45 | int temp; 46 | unsigned int flags; 47 | struct mxcfb_alt_buffer_data alt_buffer_data; 48 | }; 49 | static const int MXCFB_SEND_UPDATE = 1078216238; 50 | static const int MXCFB_WAIT_FOR_UPDATE_COMPLETE = 1074021935; 51 | ]] 52 | -------------------------------------------------------------------------------- /thirdparty/djvulibre/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Never *ever* call setlocale, for any reason. 2 | # Most of our target platforms have custom/broken/incomplete locales, don't screw with it. 3 | # And this runs in our main thread, so this is Very Bad(TM). 4 | list(APPEND PATCH_FILES djvulibre-no-locale-mangling.patch) 5 | # Remove references to (build specific) install directory in binary. 6 | list(APPEND PATCH_FILES no_references_to_install_dir.patch) 7 | 8 | if(ANDROID) 9 | list(APPEND PATCH_FILES android.patch) 10 | endif() 11 | 12 | list(APPEND PATCH_CMD COMMAND env NOCONFIGURE=1 ./autogen.sh) 13 | 14 | # fix build error due to -Werror under Fedora 26 (and potentially other systems) 15 | string(APPEND CFLAGS " -Wno-error") 16 | # Fix build error when compiling with -std=gnu++17: ISO 17 | # C++17 does not allow 'register' storage class specifier. 18 | string(APPEND CXXFLAGS " -Wno-register -Wno-error=register") 19 | # Fix symbols visibility. 20 | string(APPEND CFLAGS " -fvisibility=hidden") 21 | string(APPEND CXXFLAGS " -fvisibility=hidden -fvisibility-inlines-hidden") 22 | 23 | list(APPEND CFG_CMD COMMAND env) 24 | append_autotools_vars(CFG_CMD) 25 | list(APPEND CFG_CMD 26 | ${SOURCE_DIR}/configure --host=${CHOST} --prefix=/ 27 | --disable-shared --enable-static 28 | --disable-desktopfiles 29 | --disable-largefile 30 | --disable-xmltools 31 | --with-jpeg=${STAGING_DIR} 32 | --without-tiff 33 | ) 34 | 35 | list(APPEND BUILD_CMD COMMAND make -C libdjvu) 36 | 37 | list(APPEND INSTALL_CMD COMMAND make -C libdjvu DESTDIR=${STAGING_DIR} install) 38 | 39 | external_project( 40 | DOWNLOAD GIT 6a1e5ba1c9ef81c205a4b270c3f121a1e106f4fc 41 | https://gitlab.com/koreader/djvulibre.git 42 | PATCH_FILES ${PATCH_FILES} 43 | PATCH_COMMAND ${PATCH_CMD} 44 | CONFIGURE_COMMAND ${CFG_CMD} 45 | BUILD_COMMAND ${BUILD_CMD} 46 | INSTALL_COMMAND ${INSTALL_CMD} 47 | ) 48 | -------------------------------------------------------------------------------- /input/inkview-compat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "inkview.h" 4 | 5 | #define COMPAT __attribute__((weak)) 6 | #define TICK_MS 20 7 | 8 | static int abc[3]; 9 | static pthread_t ivm_thread; 10 | static sem_t sem_notify, sem_poll; 11 | static iv_handler handler; 12 | static iv_mtinfo *gtcache; 13 | static int exiting; 14 | 15 | static void poll_timer() { 16 | SetWeakTimer("compat-poll", poll_timer, TICK_MS); // re-arm 17 | abc[0] = -1; // signals expiry 18 | sem_post(&sem_notify); 19 | sem_wait(&sem_poll); 20 | } 21 | 22 | static int ivm_proc(int a, int b, int c) { 23 | if (a == EVT_INIT) { 24 | SetWeakTimer("compat-poll", poll_timer, TICK_MS); 25 | sem_wait(&sem_poll); 26 | } 27 | abc[0] = a; 28 | abc[1] = b; 29 | abc[2] = c; 30 | if (a == EVT_EXIT) { 31 | exiting = 1; 32 | } else if (exiting) return 2; 33 | sem_post(&sem_notify); 34 | sem_wait(&sem_poll); 35 | return 0; 36 | } 37 | 38 | COMPAT void PrepareForLoop(iv_handler h) { 39 | handler = h; 40 | sem_init(&sem_notify, 0, 0);; 41 | sem_init(&sem_poll, 0, 0);; 42 | pthread_create(&ivm_thread, NULL, (void *)&InkViewMain, ivm_proc); 43 | } 44 | 45 | COMPAT void ProcessEventLoop() { 46 | sem_post(&sem_poll); 47 | sem_wait(&sem_notify); 48 | if (abc[0] != -1) 49 | handler(abc[0], abc[1], abc[2]); 50 | } 51 | 52 | COMPAT void ClearOnExit() { 53 | ClearTimer(poll_timer); 54 | if (!exiting) { 55 | LeaveInkViewMain(); 56 | exiting = 1; 57 | } 58 | sem_post(&sem_poll); 59 | sem_post(&sem_poll); 60 | pthread_join(ivm_thread, NULL); // until it escapes IVM 61 | sem_destroy(&sem_notify); 62 | sem_destroy(&sem_poll); 63 | } 64 | 65 | COMPAT iv_mtinfo *GetTouchInfoI(unsigned int i) { 66 | if (!i) gtcache = GetTouchInfo(); 67 | return gtcache + i; 68 | } 69 | 70 | -------------------------------------------------------------------------------- /spec/unit/qrencode_spec.lua: -------------------------------------------------------------------------------- 1 | require("ffi_wrapper") 2 | local qrencode = require("ffi/qrencode") 3 | 4 | describe("QRencode module", function() 5 | it("should match the defined result", function() 6 | local result = '2;2;2;2;2;2;2;-2;-2;-1;1;1;1;-2;2;2;2;2;2;2;2;2;-2;-2;-2;-2;-2;2;-2;-2;-1;-1;1;1;-2;2;-2;-2;' 7 | ..'-2;-2;-2;2;2;-2;2;2;2;-2;2;-2;-2;-1;1;-1;-1;-2;2;-2;2;2;2;-2;2;2;-2;2;2;2;-2;2;-2;2;1;1;1;-1;-2;2;-2;2;' 8 | ..'2;2;-2;2;2;-2;2;2;2;-2;2;-2;-2;1;-1;-1;-1;-2;2;-2;2;2;2;-2;2;2;-2;-2;-2;-2;-2;2;-2;-2;-1;-1;-1;1;-2;2;' 9 | ..'-2;-2;-2;-2;-2;2;2;2;2;2;2;2;2;-2;2;-2;2;-2;2;-2;2;2;2;2;2;2;2;-2;-2;-2;-2;-2;-2;-2;-2;-2;1;1;-1;-1;-2;' 10 | ..'-2;-2;-2;-2;-2;-2;-2;2;2;-2;2;2;2;2;-2;-2;1;1;-1;1;2;-2;-2;-2;2;-2;-2;-2;1;1;-1;-1;-1;1;-2;1;1;-1;-1;1;' 11 | ..'1;-1;1;1;-1;1;-1;1;-1;1;-1;1;-1;-1;-1;2;1;-1;-1;1;-1;1;-1;1;1;-1;-1;-1;-1;1;-1;-1;1;1;1;-1;-2;-1;1;-1;' 12 | ..'-1;-1;-1;1;1;-1;1;1;-1;1;1;1;-1;-1;1;-1;-1;2;1;-1;1;1;1;-1;1;-1;1;-1;-1;1;-1;-1;-2;-2;-2;-2;-2;-2;-2;-2;' 13 | ..'-2;-1;-1;-1;-1;1;-1;-1;1;-1;1;-1;1;2;2;2;2;2;2;2;-2;-2;1;1;1;-1;-1;1;1;1;-1;-1;1;-1;2;-2;-2;-2;-2;-2;2;' 14 | ..'-2;2;1;1;1;1;-1;-1;-1;-1;1;1;1;1;2;-2;2;2;2;-2;2;-2;2;-1;1;1;-1;1;1;-1;-1;-1;-1;-1;-1;2;-2;2;2;2;-2;2;' 15 | ..'-2;2;-1;1;1;1;1;-1;-1;1;1;-1;1;1;2;-2;2;2;2;-2;2;-2;-2;-1;1;-1;-1;-1;-1;-1;-1;-1;1;-1;1;2;-2;-2;-2;-2;' 16 | ..'-2;2;-2;2;1;-1;1;1;1;1;1;-1;1;-1;-1;1;2;2;2;2;2;2;2;-2;2;1;1;1;1;1;-1;-1;1;1;1;-1;-1;' 17 | local ok, tab = qrencode.qrcode('test') 18 | assert.are.same(ok, true) 19 | local ret = {} 20 | for _, col in ipairs(tab) do 21 | for _, lgn in ipairs(col) do 22 | table.insert(ret, lgn) 23 | table.insert(ret, ';') 24 | end 25 | end 26 | assert.are.same(table.concat(ret, ''), result) 27 | end) 28 | end) -------------------------------------------------------------------------------- /spec/unit/png_spec.lua: -------------------------------------------------------------------------------- 1 | local ffi = require("ffi") 2 | require("ffi_wrapper") 3 | local BB = require("ffi/blitbuffer") 4 | local Png = require("ffi/png") 5 | 6 | describe("Png module", function() 7 | it("should write bitmap to png file", function() 8 | local re, ok 9 | local fn = os.tmpname() 10 | local w, h = 40, 60 11 | local bb = BB.new(w, h, BB.TYPE_BBRGB32) 12 | bb:setPixel(0, 0, BB.ColorRGB32(128, 128, 128, 0)) 13 | bb:setPixel(20, 30, BB.ColorRGB32(10, 128, 205, 50)) 14 | bb:setPixel(40, 10, BB.ColorRGB32(120, 28, 25, 255)) 15 | 16 | local cdata = ffi.C.malloc(w * h * 4) 17 | local mem = ffi.cast("unsigned char*", cdata) 18 | for x = 0, w-1 do 19 | for y = 0, h-1 do 20 | local c = bb:getPixel(x, y):getColorRGB32() 21 | local offset = 4 * w * y + 4 * x 22 | mem[offset] = c.r 23 | mem[offset + 1] = c.g 24 | mem[offset + 2] = c.b 25 | mem[offset + 3] = c.alpha 26 | end 27 | end 28 | 29 | ok = Png.encodeToFile(fn, mem, w, h, 4) 30 | ffi.C.free(cdata) 31 | assert.are.same(ok, true) 32 | 33 | ok, re = Png.decodeFromFile(fn, 4) 34 | assert.are.same(ok, true) 35 | local bb2 = BB.new(re.width, re.height, BB.TYPE_BBRGB32, re.data) 36 | bb2:setAllocated(1) 37 | local c = bb2:getPixel(0, 0) 38 | assert.are.same({0x80, 0x80, 0x80, 0}, {c.r, c.g, c.b, c.alpha}) 39 | c = bb2:getPixel(20, 20) 40 | assert.are.same({0, 0, 0, 0}, {c.r, c.g, c.b, c.alpha}) 41 | c = bb2:getPixel(20, 30) 42 | assert.are.same({10, 128, 205, 50}, {c.r, c.g, c.b, c.alpha}) 43 | c = bb2:getPixel(40, 10) 44 | assert.are.same({120, 28, 25, 255}, {c.r, c.g, c.b, c.alpha}) 45 | os.remove(fn) 46 | end) 47 | end) 48 | -------------------------------------------------------------------------------- /thirdparty/libarchive/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND PATCH_FILES ignore_locale_and_use_utf8.patch) 2 | if(ANDROID) 3 | list(APPEND PATCH_FILES android.patch) 4 | list(APPEND PATCH_CMD COMMAND mv contrib/android/include/android_lf.h libarchive/) 5 | endif() 6 | 7 | list(APPEND CMAKE_ARGS 8 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 9 | -DBUILD_SHARED_LIBS=$> 10 | # Project options. 11 | -DENABLE_ACL=FALSE 12 | -DENABLE_BZip2=FALSE 13 | -DENABLE_CAT=FALSE 14 | -DENABLE_CNG=FALSE 15 | -DENABLE_CPIO=FALSE 16 | -DENABLE_EXPAT=FALSE 17 | -DENABLE_ICONV=FALSE 18 | -DENABLE_LIBB2=FALSE 19 | -DENABLE_LIBXML2=FALSE 20 | -DENABLE_LZ4=FALSE 21 | -DENABLE_LZMA=$ 22 | -DENABLE_OPENSSL=FALSE 23 | -DENABLE_PCRE2POSIX=FALSE 24 | -DENABLE_PCREPOSIX=FALSE 25 | -DENABLE_TAR=FALSE 26 | -DENABLE_TEST=FALSE 27 | -DENABLE_UNZIP=FALSE 28 | -DENABLE_WERROR=FALSE 29 | -DENABLE_XATTR=FALSE 30 | # Prevent md library fallback because OpenSSL is not used. 31 | -DLIBMD_FOUND=FALSE 32 | ) 33 | # Avoid pulling > GLIBC_2.4 symbols on crappy platforms. 34 | if(LEGACY OR POCKETBOOK) 35 | list(APPEND CMAKE_ARGS 36 | -DHAVE_FUTIMENS=FALSE 37 | -DHAVE_UTIMENSAT=FALSE 38 | ) 39 | endif() 40 | 41 | list(APPEND BUILD_CMD COMMAND ninja) 42 | 43 | list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) 44 | 45 | if(NOT MONOLIBTIC) 46 | append_shared_lib_install_commands(INSTALL_CMD archive VERSION 13) 47 | endif() 48 | 49 | external_project( 50 | DOWNLOAD URL 355bb47a72fad8417eb745754005fdb9 51 | https://github.com/libarchive/libarchive/releases/download/v3.8.4/libarchive-3.8.4.tar.xz 52 | CMAKE_ARGS ${CMAKE_ARGS} 53 | PATCH_FILES ${PATCH_FILES} 54 | PATCH_COMMAND ${PATCH_CMD} 55 | BUILD_COMMAND ${BUILD_CMD} 56 | INSTALL_COMMAND ${INSTALL_CMD} 57 | ) 58 | -------------------------------------------------------------------------------- /cmake/koreader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(koreader_targets) 2 | 3 | list(APPEND CMAKE_ARGS -DCMAKE_KOVARS=${CMAKE_KOVARS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) 4 | 5 | list(APPEND BUILD_CMD COMMAND ninja) 6 | 7 | external_project( 8 | BUILD_ALWAYS 9 | CMAKE_ARGS ${CMAKE_ARGS} 10 | BUILD_COMMAND ${BUILD_CMD} 11 | ) 12 | 13 | function(add_target_build_step NAME) 14 | cmake_parse_arguments("" "EXCLUDE_FROM_ALL" "" "DEPENDS" ${ARGN}) 15 | foreach(DEP IN LISTS _DEPENDS) 16 | if(NOT ${DEP} IN_LIST PROJECTS) 17 | message(FATAL_ERROR "trying to add ${PROJECT_NAME} step '${NAME}' with a dependency on undeclared project: ${DEP}") 18 | endif() 19 | endforeach() 20 | if(NOT _EXCLUDE_FROM_ALL AND _DEPENDS) 21 | add_dependencies(${PROJECT_NAME}-build ${_DEPENDS}) 22 | endif() 23 | set(COMMENT "Performing build step for '${NAME}'") 24 | add_custom_target(${NAME}-deps DEPENDS ${_DEPENDS}) 25 | add_custom_target( 26 | ${NAME} 27 | COMMENT ${COMMENT} 28 | COMMAND set -- ${PROJECT_NAME} ${COMMENT} 0 29 | COMMAND . ${KOENV} 30 | COMMAND ninja ${NAME} 31 | DEPENDS ${PROJECT_NAME}-configure ${NAME}-deps 32 | WORKING_DIRECTORY ${BINARY_DIR} 33 | USES_TERMINAL 34 | VERBATIM 35 | ) 36 | endfunction() 37 | 38 | function(add_targets) 39 | foreach(NAME IN LISTS KOREADER_TARGETS) 40 | if(${NAME}_EXCLUDE_FROM_ALL) 41 | set(EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL) 42 | else() 43 | set(EXCLUDE_FROM_ALL) 44 | endif() 45 | set(DEPENDS) 46 | foreach(DEP IN LISTS ${NAME}_DEPENDS) 47 | string(REGEX MATCH "^([^:]+)::([^:])+$" MATCHES ${DEP}) 48 | list(APPEND DEPENDS ${CMAKE_MATCH_1}) 49 | endforeach() 50 | add_target_build_step(${NAME} ${EXCLUDE_FROM_ALL} DEPENDS ${DEPENDS}) 51 | endforeach() 52 | endfunction() 53 | 54 | add_targets() 55 | --------------------------------------------------------------------------------