@papyrus-sdk/engine-native 0.2.22-beta.2 → 0.2.22-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +1 -0
- package/android/src/main/cpp/CMakeLists.txt +137 -0
- package/android/src/main/cpp/PapyrusComicArchiveJni.cpp +68 -0
- package/android/src/main/cpp/PapyrusComicArchiveTest.cpp +55 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusComicArchiveNative.java +14 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusComicDocumentView.java +353 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusComicDocumentViewManager.java +32 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusComicPageLayout.java +17 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusNativeEngineModule.java +298 -34
- package/android/src/main/java/com/papyrus/engine/PapyrusNativeTextModel.java +195 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusPackage.java +3 -1
- package/android/src/main/java/com/papyrus/engine/PapyrusPdfViewerView.java +24 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusRenderMath.java +9 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusTextDocumentView.java +439 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusTextDocumentViewManager.java +43 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusTextStore.java +43 -0
- package/dist/index.d.mts +439 -3
- package/dist/index.d.ts +439 -3
- package/dist/index.js +412 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +404 -3
- package/dist/index.mjs.map +1 -1
- package/ios/PapyrusComicDocumentView.h +21 -0
- package/ios/PapyrusComicDocumentView.m +374 -0
- package/ios/PapyrusComicDocumentViewManager.m +23 -0
- package/ios/PapyrusEngineStore.m +4 -0
- package/ios/PapyrusNativeEngine.m +664 -0
- package/ios/PapyrusNativeEngine.podspec +26 -1
- package/ios/PapyrusPageRotationRegistry.h +29 -0
- package/ios/PapyrusPageRotationRegistry.m +179 -0
- package/ios/PapyrusPageView.m +38 -11
- package/ios/PapyrusPdfDocumentView.h +2 -0
- package/ios/PapyrusPdfDocumentView.m +116 -9
- package/ios/PapyrusPdfDocumentViewManager.m +2 -0
- package/ios/PapyrusPdfPageTheme.h +15 -0
- package/ios/PapyrusPdfPageTheme.m +218 -0
- package/ios/PapyrusTextDocumentView.h +27 -0
- package/ios/PapyrusTextDocumentView.m +299 -0
- package/ios/PapyrusTextDocumentViewManager.m +29 -0
- package/ios/PapyrusTextStore.h +13 -0
- package/ios/PapyrusTextStore.m +73 -0
- package/package.json +5 -3
- package/third_party_licenses/BLAKE2-NOTICE.txt +11 -0
- package/third_party_licenses/libarchive-COPYING +65 -0
- package/vendor/libarchive/PapyrusComicArchive.cpp +376 -0
- package/vendor/libarchive/PapyrusComicArchive.h +30 -0
- package/vendor/libarchive/README.papyrus.md +15 -0
- package/vendor/libarchive/android.h +192 -0
- package/vendor/libarchive/config/PapyrusArchiveConfig.h +65 -0
- package/vendor/libarchive/libarchive/CMakeLists.txt +293 -0
- package/vendor/libarchive/libarchive/android_lf.h +36 -0
- package/vendor/libarchive/libarchive/archive.h +1266 -0
- package/vendor/libarchive/libarchive/archive_acl.c +2025 -0
- package/vendor/libarchive/libarchive/archive_acl_private.h +85 -0
- package/vendor/libarchive/libarchive/archive_blake2.h +197 -0
- package/vendor/libarchive/libarchive/archive_blake2_impl.h +161 -0
- package/vendor/libarchive/libarchive/archive_blake2s_ref.c +369 -0
- package/vendor/libarchive/libarchive/archive_blake2sp_ref.c +361 -0
- package/vendor/libarchive/libarchive/archive_check_magic.c +183 -0
- package/vendor/libarchive/libarchive/archive_cmdline.c +211 -0
- package/vendor/libarchive/libarchive/archive_cmdline_private.h +45 -0
- package/vendor/libarchive/libarchive/archive_crc32.h +123 -0
- package/vendor/libarchive/libarchive/archive_cryptor.c +534 -0
- package/vendor/libarchive/libarchive/archive_cryptor_private.h +199 -0
- package/vendor/libarchive/libarchive/archive_digest.c +1584 -0
- package/vendor/libarchive/libarchive/archive_digest_private.h +431 -0
- package/vendor/libarchive/libarchive/archive_disk_acl_darwin.c +558 -0
- package/vendor/libarchive/libarchive/archive_disk_acl_freebsd.c +712 -0
- package/vendor/libarchive/libarchive/archive_disk_acl_linux.c +760 -0
- package/vendor/libarchive/libarchive/archive_disk_acl_sunos.c +824 -0
- package/vendor/libarchive/libarchive/archive_endian.h +234 -0
- package/vendor/libarchive/libarchive/archive_entry.3 +147 -0
- package/vendor/libarchive/libarchive/archive_entry.c +2297 -0
- package/vendor/libarchive/libarchive/archive_entry.h +763 -0
- package/vendor/libarchive/libarchive/archive_entry_acl.3 +458 -0
- package/vendor/libarchive/libarchive/archive_entry_copy_bhfi.c +55 -0
- package/vendor/libarchive/libarchive/archive_entry_copy_stat.c +82 -0
- package/vendor/libarchive/libarchive/archive_entry_link_resolver.c +472 -0
- package/vendor/libarchive/libarchive/archive_entry_linkify.3 +224 -0
- package/vendor/libarchive/libarchive/archive_entry_locale.h +90 -0
- package/vendor/libarchive/libarchive/archive_entry_misc.3 +63 -0
- package/vendor/libarchive/libarchive/archive_entry_paths.3 +153 -0
- package/vendor/libarchive/libarchive/archive_entry_perms.3 +210 -0
- package/vendor/libarchive/libarchive/archive_entry_private.h +205 -0
- package/vendor/libarchive/libarchive/archive_entry_sparse.c +156 -0
- package/vendor/libarchive/libarchive/archive_entry_stat.3 +274 -0
- package/vendor/libarchive/libarchive/archive_entry_stat.c +121 -0
- package/vendor/libarchive/libarchive/archive_entry_strmode.c +69 -0
- package/vendor/libarchive/libarchive/archive_entry_time.3 +127 -0
- package/vendor/libarchive/libarchive/archive_entry_xattr.c +155 -0
- package/vendor/libarchive/libarchive/archive_hmac.c +345 -0
- package/vendor/libarchive/libarchive/archive_hmac_private.h +119 -0
- package/vendor/libarchive/libarchive/archive_integer.h +267 -0
- package/vendor/libarchive/libarchive/archive_match.c +1869 -0
- package/vendor/libarchive/libarchive/archive_openssl_evp_private.h +54 -0
- package/vendor/libarchive/libarchive/archive_openssl_hmac_private.h +54 -0
- package/vendor/libarchive/libarchive/archive_options.c +219 -0
- package/vendor/libarchive/libarchive/archive_options_private.h +49 -0
- package/vendor/libarchive/libarchive/archive_pack_dev.c +330 -0
- package/vendor/libarchive/libarchive/archive_pack_dev.h +49 -0
- package/vendor/libarchive/libarchive/archive_parse_date.c +1173 -0
- package/vendor/libarchive/libarchive/archive_pathmatch.c +480 -0
- package/vendor/libarchive/libarchive/archive_pathmatch.h +50 -0
- package/vendor/libarchive/libarchive/archive_platform.h +213 -0
- package/vendor/libarchive/libarchive/archive_platform_acl.h +53 -0
- package/vendor/libarchive/libarchive/archive_platform_stat.h +45 -0
- package/vendor/libarchive/libarchive/archive_platform_xattr.h +45 -0
- package/vendor/libarchive/libarchive/archive_ppmd7.c +1173 -0
- package/vendor/libarchive/libarchive/archive_ppmd7_private.h +119 -0
- package/vendor/libarchive/libarchive/archive_ppmd8.c +1293 -0
- package/vendor/libarchive/libarchive/archive_ppmd8_private.h +123 -0
- package/vendor/libarchive/libarchive/archive_ppmd_private.h +159 -0
- package/vendor/libarchive/libarchive/archive_private.h +209 -0
- package/vendor/libarchive/libarchive/archive_random.c +274 -0
- package/vendor/libarchive/libarchive/archive_random_private.h +36 -0
- package/vendor/libarchive/libarchive/archive_rb.c +709 -0
- package/vendor/libarchive/libarchive/archive_rb.h +113 -0
- package/vendor/libarchive/libarchive/archive_read.3 +250 -0
- package/vendor/libarchive/libarchive/archive_read.c +1814 -0
- package/vendor/libarchive/libarchive/archive_read_add_passphrase.3 +72 -0
- package/vendor/libarchive/libarchive/archive_read_add_passphrase.c +189 -0
- package/vendor/libarchive/libarchive/archive_read_append_filter.c +209 -0
- package/vendor/libarchive/libarchive/archive_read_data.3 +128 -0
- package/vendor/libarchive/libarchive/archive_read_data_into_fd.c +207 -0
- package/vendor/libarchive/libarchive/archive_read_disk.3 +422 -0
- package/vendor/libarchive/libarchive/archive_read_disk_entry_from_file.c +1086 -0
- package/vendor/libarchive/libarchive/archive_read_disk_posix.c +2639 -0
- package/vendor/libarchive/libarchive/archive_read_disk_private.h +97 -0
- package/vendor/libarchive/libarchive/archive_read_disk_set_standard_lookup.c +315 -0
- package/vendor/libarchive/libarchive/archive_read_disk_windows.c +2603 -0
- package/vendor/libarchive/libarchive/archive_read_extract.3 +135 -0
- package/vendor/libarchive/libarchive/archive_read_extract.c +59 -0
- package/vendor/libarchive/libarchive/archive_read_extract2.c +154 -0
- package/vendor/libarchive/libarchive/archive_read_filter.3 +163 -0
- package/vendor/libarchive/libarchive/archive_read_format.3 +190 -0
- package/vendor/libarchive/libarchive/archive_read_free.3 +91 -0
- package/vendor/libarchive/libarchive/archive_read_header.3 +89 -0
- package/vendor/libarchive/libarchive/archive_read_new.3 +57 -0
- package/vendor/libarchive/libarchive/archive_read_open.3 +247 -0
- package/vendor/libarchive/libarchive/archive_read_open_fd.c +236 -0
- package/vendor/libarchive/libarchive/archive_read_open_file.c +257 -0
- package/vendor/libarchive/libarchive/archive_read_open_filename.c +652 -0
- package/vendor/libarchive/libarchive/archive_read_open_memory.c +188 -0
- package/vendor/libarchive/libarchive/archive_read_private.h +274 -0
- package/vendor/libarchive/libarchive/archive_read_set_format.c +116 -0
- package/vendor/libarchive/libarchive/archive_read_set_options.3 +290 -0
- package/vendor/libarchive/libarchive/archive_read_set_options.c +132 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_all.c +84 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_by_code.c +68 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_bzip2.c +360 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_compress.c +457 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_grzip.c +108 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_gzip.c +538 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_lrzip.c +119 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_lz4.c +829 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_lzop.c +493 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_none.c +51 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_program.c +497 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_rpm.c +249 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_uu.c +739 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_xz.c +792 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_zstd.c +356 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_7zip.c +4650 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_all.c +88 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_ar.c +597 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_by_code.c +76 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_cab.c +3410 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_cpio.c +1152 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_empty.c +95 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_iso9660.c +3516 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_lha.c +2931 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_mtree.c +2113 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_rar.c +3932 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_rar5.c +4501 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_raw.c +194 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_tar.c +3785 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_warc.c +875 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_xar.c +3770 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_zip.c +4710 -0
- package/vendor/libarchive/libarchive/archive_string.c +4391 -0
- package/vendor/libarchive/libarchive/archive_string.h +244 -0
- package/vendor/libarchive/libarchive/archive_string_composition.h +2289 -0
- package/vendor/libarchive/libarchive/archive_string_sprintf.c +200 -0
- package/vendor/libarchive/libarchive/archive_time.c +168 -0
- package/vendor/libarchive/libarchive/archive_time_private.h +47 -0
- package/vendor/libarchive/libarchive/archive_util.3 +239 -0
- package/vendor/libarchive/libarchive/archive_util.c +668 -0
- package/vendor/libarchive/libarchive/archive_version_details.c +516 -0
- package/vendor/libarchive/libarchive/archive_virtual.c +162 -0
- package/vendor/libarchive/libarchive/archive_windows.c +1035 -0
- package/vendor/libarchive/libarchive/archive_windows.h +332 -0
- package/vendor/libarchive/libarchive/archive_write.3 +266 -0
- package/vendor/libarchive/libarchive/archive_write.c +896 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter.c +71 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_b64encode.c +329 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_by_name.c +76 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_bzip2.c +411 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_compress.c +459 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_grzip.c +143 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_gzip.c +493 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_lrzip.c +214 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_lz4.c +710 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_lzop.c +500 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_none.c +42 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_program.c +398 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_uuencode.c +320 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_xz.c +547 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_zstd.c +608 -0
- package/vendor/libarchive/libarchive/archive_write_blocksize.3 +112 -0
- package/vendor/libarchive/libarchive/archive_write_data.3 +88 -0
- package/vendor/libarchive/libarchive/archive_write_disk.3 +360 -0
- package/vendor/libarchive/libarchive/archive_write_disk_posix.c +4789 -0
- package/vendor/libarchive/libarchive/archive_write_disk_private.h +43 -0
- package/vendor/libarchive/libarchive/archive_write_disk_set_standard_lookup.c +265 -0
- package/vendor/libarchive/libarchive/archive_write_disk_windows.c +2952 -0
- package/vendor/libarchive/libarchive/archive_write_filter.3 +140 -0
- package/vendor/libarchive/libarchive/archive_write_finish_entry.3 +77 -0
- package/vendor/libarchive/libarchive/archive_write_format.3 +187 -0
- package/vendor/libarchive/libarchive/archive_write_free.3 +94 -0
- package/vendor/libarchive/libarchive/archive_write_header.3 +71 -0
- package/vendor/libarchive/libarchive/archive_write_new.3 +56 -0
- package/vendor/libarchive/libarchive/archive_write_open.3 +270 -0
- package/vendor/libarchive/libarchive/archive_write_open_fd.c +141 -0
- package/vendor/libarchive/libarchive/archive_write_open_file.c +102 -0
- package/vendor/libarchive/libarchive/archive_write_open_filename.c +272 -0
- package/vendor/libarchive/libarchive/archive_write_open_memory.c +110 -0
- package/vendor/libarchive/libarchive/archive_write_private.h +166 -0
- package/vendor/libarchive/libarchive/archive_write_set_format.c +124 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_7zip.c +2571 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_ar.c +540 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_by_name.c +93 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_cpio.c +11 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_cpio_binary.c +618 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_cpio_newc.c +457 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_cpio_odc.c +508 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_filter_by_ext.c +141 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_gnutar.c +790 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_iso9660.c +8216 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_mtree.c +2307 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_pax.c +2249 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_private.h +40 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_raw.c +123 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_shar.c +650 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_ustar.c +768 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_v7tar.c +648 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_warc.c +491 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_xar.c +3799 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_zip.c +2548 -0
- package/vendor/libarchive/libarchive/archive_write_set_options.3 +779 -0
- package/vendor/libarchive/libarchive/archive_write_set_options.c +129 -0
- package/vendor/libarchive/libarchive/archive_write_set_passphrase.3 +72 -0
- package/vendor/libarchive/libarchive/archive_write_set_passphrase.c +95 -0
- package/vendor/libarchive/libarchive/archive_xxhash.h +48 -0
- package/vendor/libarchive/libarchive/config_freebsd.h +275 -0
- package/vendor/libarchive/libarchive/cpio.5 +389 -0
- package/vendor/libarchive/libarchive/filter_fork.h +44 -0
- package/vendor/libarchive/libarchive/filter_fork_posix.c +269 -0
- package/vendor/libarchive/libarchive/filter_fork_windows.c +270 -0
- package/vendor/libarchive/libarchive/libarchive-formats.5 +478 -0
- package/vendor/libarchive/libarchive/libarchive.3 +297 -0
- package/vendor/libarchive/libarchive/libarchive_changes.3 +339 -0
- package/vendor/libarchive/libarchive/libarchive_internals.3 +363 -0
- package/vendor/libarchive/libarchive/module.modulemap +34 -0
- package/vendor/libarchive/libarchive/mtree.5 +323 -0
- package/vendor/libarchive/libarchive/tar.5 +947 -0
- package/vendor/libarchive/libarchive/xxhash.c +531 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
BLAKE2 reference source notice
|
|
2
|
+
|
|
3
|
+
The BLAKE2 reference source files included in the libarchive subset are
|
|
4
|
+
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. They may be used under the
|
|
5
|
+
terms of CC0 1.0 Universal, the OpenSSL License, or Apache License 2.0, at the
|
|
6
|
+
user's option. The source files retain this notice. The license texts are
|
|
7
|
+
available from:
|
|
8
|
+
|
|
9
|
+
CC0 1.0 Universal: https://creativecommons.org/publicdomain/zero/1.0/legalcode
|
|
10
|
+
OpenSSL License: https://www.openssl.org/source/license.html
|
|
11
|
+
Apache License 2.0: https://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
The libarchive distribution as a whole is Copyright by Tim Kientzle
|
|
2
|
+
and is subject to the copyright notice reproduced at the bottom of
|
|
3
|
+
this file.
|
|
4
|
+
|
|
5
|
+
Each individual file in this distribution should have a clear
|
|
6
|
+
copyright/licensing statement at the beginning of the file. If any do
|
|
7
|
+
not, please let me know and I will rectify it. The following is
|
|
8
|
+
intended to summarize the copyright status of the individual files;
|
|
9
|
+
the actual statements in the files are controlling.
|
|
10
|
+
|
|
11
|
+
* Except as listed below, all C sources (including .c and .h files)
|
|
12
|
+
and documentation files are subject to the copyright notice reproduced
|
|
13
|
+
at the bottom of this file.
|
|
14
|
+
|
|
15
|
+
* The following source files are also subject in whole or in part to
|
|
16
|
+
a 3-clause UC Regents copyright; please read the individual source
|
|
17
|
+
files for details:
|
|
18
|
+
libarchive/archive_read_support_filter_compress.c
|
|
19
|
+
libarchive/archive_write_add_filter_compress.c
|
|
20
|
+
libarchive/mtree.5
|
|
21
|
+
|
|
22
|
+
* The following source files are in the public domain:
|
|
23
|
+
libarchive/archive_parse_date.c
|
|
24
|
+
|
|
25
|
+
* The following source files are triple-licensed with the ability to choose
|
|
26
|
+
from CC0 1.0 Universal, OpenSSL or Apache 2.0 licenses:
|
|
27
|
+
libarchive/archive_blake2.h
|
|
28
|
+
libarchive/archive_blake2_impl.h
|
|
29
|
+
libarchive/archive_blake2s_ref.c
|
|
30
|
+
libarchive/archive_blake2sp_ref.c
|
|
31
|
+
|
|
32
|
+
* The build files---including Makefiles, configure scripts,
|
|
33
|
+
and auxiliary scripts used as part of the compile process---have
|
|
34
|
+
widely varying licensing terms. Please check individual files before
|
|
35
|
+
distributing them to see if those restrictions apply to you.
|
|
36
|
+
|
|
37
|
+
I intend for all new source code to use the license below and hope over
|
|
38
|
+
time to replace code with other licenses with new implementations that
|
|
39
|
+
do use the license below. The varying licensing of the build scripts
|
|
40
|
+
seems to be an unavoidable mess.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
Copyright (c) 2003-2018 <author(s)>
|
|
44
|
+
All rights reserved.
|
|
45
|
+
|
|
46
|
+
Redistribution and use in source and binary forms, with or without
|
|
47
|
+
modification, are permitted provided that the following conditions
|
|
48
|
+
are met:
|
|
49
|
+
1. Redistributions of source code must retain the above copyright
|
|
50
|
+
notice, this list of conditions and the following disclaimer
|
|
51
|
+
in this position and unchanged.
|
|
52
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
53
|
+
notice, this list of conditions and the following disclaimer in the
|
|
54
|
+
documentation and/or other materials provided with the distribution.
|
|
55
|
+
|
|
56
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
57
|
+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
58
|
+
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
59
|
+
IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
60
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
61
|
+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
62
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
63
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
64
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
65
|
+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
#include "PapyrusComicArchive.h"
|
|
2
|
+
|
|
3
|
+
#include <archive.h>
|
|
4
|
+
#include <archive_entry.h>
|
|
5
|
+
|
|
6
|
+
#include <algorithm>
|
|
7
|
+
#include <cctype>
|
|
8
|
+
#include <chrono>
|
|
9
|
+
#include <cstdint>
|
|
10
|
+
#include <filesystem>
|
|
11
|
+
#include <fstream>
|
|
12
|
+
#include <functional>
|
|
13
|
+
#include <limits>
|
|
14
|
+
#include <memory>
|
|
15
|
+
#include <mutex>
|
|
16
|
+
#include <string>
|
|
17
|
+
#include <unordered_map>
|
|
18
|
+
#include <vector>
|
|
19
|
+
|
|
20
|
+
namespace fs = std::filesystem;
|
|
21
|
+
|
|
22
|
+
namespace {
|
|
23
|
+
constexpr std::uint64_t kMaximumEntryBytes = 64ULL * 1024ULL * 1024ULL;
|
|
24
|
+
// Reserve 16 MiB for downsampled thumbnails; page files plus thumbnails stay within 96 MiB.
|
|
25
|
+
constexpr std::uint64_t kMaximumExtractedPageCacheBytes = 80ULL * 1024ULL * 1024ULL;
|
|
26
|
+
constexpr std::size_t kMaximumEntries = 50000;
|
|
27
|
+
constexpr std::size_t kMaximumArchiveEntries = 200000;
|
|
28
|
+
constexpr std::size_t kIoBlockSize = 64 * 1024;
|
|
29
|
+
|
|
30
|
+
struct ComicPage {
|
|
31
|
+
std::string name;
|
|
32
|
+
std::string normalized_name;
|
|
33
|
+
std::uint64_t declared_size = 0;
|
|
34
|
+
std::size_t archive_ordinal = 0;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
struct ComicDocument {
|
|
38
|
+
std::string engine_id;
|
|
39
|
+
int generation = 0;
|
|
40
|
+
fs::path archive_path;
|
|
41
|
+
fs::path cache_dir;
|
|
42
|
+
std::vector<ComicPage> pages;
|
|
43
|
+
std::mutex lock;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
std::mutex g_documents_lock;
|
|
47
|
+
std::mutex g_cache_lock;
|
|
48
|
+
std::unordered_map<std::string, std::shared_ptr<ComicDocument>> g_documents;
|
|
49
|
+
|
|
50
|
+
std::string key_for(const char *engine_id, int generation) {
|
|
51
|
+
return std::string(engine_id ? engine_id : "") + ":" + std::to_string(generation);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
void write_error(char *buffer, std::size_t size, const std::string &message) {
|
|
55
|
+
if (!buffer || size == 0) return;
|
|
56
|
+
const std::size_t length = std::min(size - 1, message.size());
|
|
57
|
+
std::copy(message.begin(), message.begin() + length, buffer);
|
|
58
|
+
buffer[length] = '\0';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
std::string normalize_path(std::string path) {
|
|
62
|
+
std::replace(path.begin(), path.end(), '\\', '/');
|
|
63
|
+
return path;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
bool is_supported_image(const std::string &path) {
|
|
67
|
+
const std::string normalized = normalize_path(path);
|
|
68
|
+
const std::size_t slash = normalized.find_last_of('/');
|
|
69
|
+
const std::string name = normalized.substr(slash == std::string::npos ? 0 : slash + 1);
|
|
70
|
+
if (name.empty() || name[0] == '.') return false;
|
|
71
|
+
|
|
72
|
+
std::size_t start = 0;
|
|
73
|
+
while (start < normalized.size()) {
|
|
74
|
+
const std::size_t end = normalized.find('/', start);
|
|
75
|
+
const std::string part = normalized.substr(start, end == std::string::npos ? std::string::npos : end - start);
|
|
76
|
+
std::string lower_part = part;
|
|
77
|
+
std::transform(lower_part.begin(), lower_part.end(), lower_part.begin(), [](unsigned char c) { return static_cast<char>(std::tolower(c)); });
|
|
78
|
+
if (part.empty() || part[0] == '.' || lower_part == "__macosx") return false;
|
|
79
|
+
if (end == std::string::npos) break;
|
|
80
|
+
start = end + 1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const std::size_t dot = name.find_last_of('.');
|
|
84
|
+
if (dot == std::string::npos || dot + 1 >= name.size()) return false;
|
|
85
|
+
std::string extension = name.substr(dot + 1);
|
|
86
|
+
std::transform(extension.begin(), extension.end(), extension.begin(), [](unsigned char c) { return static_cast<char>(std::tolower(c)); });
|
|
87
|
+
const bool common_image = extension == "jpg" || extension == "jpeg" || extension == "png" || extension == "gif";
|
|
88
|
+
#if defined(__APPLE__)
|
|
89
|
+
return common_image;
|
|
90
|
+
#else
|
|
91
|
+
return common_image || extension == "webp";
|
|
92
|
+
#endif
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
int compare_digit_runs(const std::string &a, std::size_t &i, const std::string &b, std::size_t &j) {
|
|
96
|
+
const std::size_t start_a = i;
|
|
97
|
+
const std::size_t start_b = j;
|
|
98
|
+
while (i < a.size() && a[i] == '0') ++i;
|
|
99
|
+
while (j < b.size() && b[j] == '0') ++j;
|
|
100
|
+
const std::size_t significant_a = i;
|
|
101
|
+
const std::size_t significant_b = j;
|
|
102
|
+
while (i < a.size() && std::isdigit(static_cast<unsigned char>(a[i]))) ++i;
|
|
103
|
+
while (j < b.size() && std::isdigit(static_cast<unsigned char>(b[j]))) ++j;
|
|
104
|
+
const std::size_t length_a = i - significant_a;
|
|
105
|
+
const std::size_t length_b = j - significant_b;
|
|
106
|
+
if (length_a != length_b) return length_a < length_b ? -1 : 1;
|
|
107
|
+
const int number_compare = a.compare(significant_a, length_a, b, significant_b, length_b);
|
|
108
|
+
if (number_compare != 0) return number_compare < 0 ? -1 : 1;
|
|
109
|
+
const std::size_t width_a = i - start_a;
|
|
110
|
+
const std::size_t width_b = j - start_b;
|
|
111
|
+
return width_a == width_b ? 0 : (width_a < width_b ? -1 : 1);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
bool natural_less(const ComicPage &left, const ComicPage &right) {
|
|
115
|
+
const std::string &a = left.normalized_name;
|
|
116
|
+
const std::string &b = right.normalized_name;
|
|
117
|
+
std::size_t i = 0, j = 0;
|
|
118
|
+
while (i < a.size() && j < b.size()) {
|
|
119
|
+
const unsigned char ca = static_cast<unsigned char>(a[i]);
|
|
120
|
+
const unsigned char cb = static_cast<unsigned char>(b[j]);
|
|
121
|
+
if (std::isdigit(ca) && std::isdigit(cb)) {
|
|
122
|
+
const int comparison = compare_digit_runs(a, i, b, j);
|
|
123
|
+
if (comparison != 0) return comparison < 0;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const unsigned char lower_a = static_cast<unsigned char>(std::tolower(ca));
|
|
127
|
+
const unsigned char lower_b = static_cast<unsigned char>(std::tolower(cb));
|
|
128
|
+
if (lower_a != lower_b) return lower_a < lower_b;
|
|
129
|
+
++i;
|
|
130
|
+
++j;
|
|
131
|
+
}
|
|
132
|
+
if (a.size() != b.size()) return a.size() < b.size();
|
|
133
|
+
return left.name < right.name;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
struct ArchiveDeleter {
|
|
137
|
+
void operator()(archive *reader) const { if (reader) archive_read_free(reader); }
|
|
138
|
+
};
|
|
139
|
+
using Reader = std::unique_ptr<archive, ArchiveDeleter>;
|
|
140
|
+
|
|
141
|
+
Reader new_reader(std::string &error) {
|
|
142
|
+
Reader reader(archive_read_new());
|
|
143
|
+
if (!reader) {
|
|
144
|
+
error = "Unable to allocate archive reader";
|
|
145
|
+
return nullptr;
|
|
146
|
+
}
|
|
147
|
+
archive_read_support_filter_none(reader.get());
|
|
148
|
+
archive_read_support_format_zip(reader.get());
|
|
149
|
+
archive_read_support_format_rar(reader.get());
|
|
150
|
+
archive_read_support_format_rar5(reader.get());
|
|
151
|
+
return reader;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
std::shared_ptr<ComicDocument> find_document(const char *engine_id, int generation) {
|
|
155
|
+
std::lock_guard<std::mutex> guard(g_documents_lock);
|
|
156
|
+
const auto found = g_documents.find(key_for(engine_id, generation));
|
|
157
|
+
return found == g_documents.end() ? nullptr : found->second;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
void prune_disk_cache(const fs::path &directory, const fs::path &preserve) {
|
|
161
|
+
std::lock_guard<std::mutex> cache_guard(g_cache_lock);
|
|
162
|
+
std::error_code error;
|
|
163
|
+
if (!fs::exists(directory, error)) return;
|
|
164
|
+
struct CacheFile { fs::path path; std::uint64_t size; fs::file_time_type time; };
|
|
165
|
+
std::vector<CacheFile> files;
|
|
166
|
+
std::uint64_t total = 0;
|
|
167
|
+
for (const auto &item : fs::directory_iterator(directory, error)) {
|
|
168
|
+
if (error || !item.is_regular_file()) continue;
|
|
169
|
+
const std::string name = item.path().filename().string();
|
|
170
|
+
if (name.find("papyrus-comic-page-") != 0) continue;
|
|
171
|
+
const std::uint64_t size = item.file_size(error);
|
|
172
|
+
if (error) { error.clear(); continue; }
|
|
173
|
+
total += size;
|
|
174
|
+
files.push_back({item.path(), size, item.last_write_time(error)});
|
|
175
|
+
if (error) error.clear();
|
|
176
|
+
}
|
|
177
|
+
std::sort(files.begin(), files.end(), [](const CacheFile &a, const CacheFile &b) { return a.time < b.time; });
|
|
178
|
+
for (const auto &file : files) {
|
|
179
|
+
if (total <= kMaximumExtractedPageCacheBytes) break;
|
|
180
|
+
if (file.path == preserve) continue;
|
|
181
|
+
if (fs::remove(file.path, error)) total -= file.size;
|
|
182
|
+
error.clear();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
} // namespace
|
|
186
|
+
|
|
187
|
+
extern "C" int papyrus_comic_open(const char *engine_id,
|
|
188
|
+
int generation,
|
|
189
|
+
const char *archive_path,
|
|
190
|
+
const char *cache_dir,
|
|
191
|
+
int *page_count,
|
|
192
|
+
char *error_buffer,
|
|
193
|
+
size_t error_buffer_size) {
|
|
194
|
+
if (!engine_id || !*engine_id || !archive_path || !cache_dir) {
|
|
195
|
+
write_error(error_buffer, error_buffer_size, "Missing comic archive identity or path");
|
|
196
|
+
return 0;
|
|
197
|
+
}
|
|
198
|
+
auto document = std::make_shared<ComicDocument>();
|
|
199
|
+
document->engine_id = engine_id;
|
|
200
|
+
document->generation = generation;
|
|
201
|
+
document->archive_path = archive_path;
|
|
202
|
+
document->cache_dir = cache_dir;
|
|
203
|
+
|
|
204
|
+
std::string message;
|
|
205
|
+
Reader reader = new_reader(message);
|
|
206
|
+
if (!reader || archive_read_open_filename(reader.get(), archive_path, kIoBlockSize) != ARCHIVE_OK) {
|
|
207
|
+
write_error(error_buffer, error_buffer_size, reader ? archive_error_string(reader.get()) : message);
|
|
208
|
+
return 0;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
archive_entry *entry = nullptr;
|
|
212
|
+
std::size_t ordinal = 0;
|
|
213
|
+
for (;;) {
|
|
214
|
+
const int status = archive_read_next_header(reader.get(), &entry);
|
|
215
|
+
if (status == ARCHIVE_EOF) break;
|
|
216
|
+
if (status != ARCHIVE_OK && status != ARCHIVE_WARN) {
|
|
217
|
+
const char *archive_error = archive_error_string(reader.get());
|
|
218
|
+
write_error(error_buffer, error_buffer_size, archive_error ? archive_error : "Corrupt comic archive");
|
|
219
|
+
return 0;
|
|
220
|
+
}
|
|
221
|
+
const char *raw_name = archive_entry_pathname_utf8(entry);
|
|
222
|
+
if (!raw_name) raw_name = archive_entry_pathname(entry);
|
|
223
|
+
const std::string name = raw_name ? normalize_path(raw_name) : std::string();
|
|
224
|
+
const la_int64_t declared_size = archive_entry_size(entry);
|
|
225
|
+
if (archive_entry_filetype(entry) == AE_IFREG && !archive_entry_symlink(entry) &&
|
|
226
|
+
!archive_entry_hardlink(entry) && is_supported_image(name) &&
|
|
227
|
+
declared_size >= 0 && static_cast<std::uint64_t>(declared_size) <= kMaximumEntryBytes) {
|
|
228
|
+
document->pages.push_back({name, name, static_cast<std::uint64_t>(declared_size), ordinal});
|
|
229
|
+
if (document->pages.size() > kMaximumEntries) {
|
|
230
|
+
write_error(error_buffer, error_buffer_size, "Comic archive has too many page entries");
|
|
231
|
+
return 0;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
archive_read_data_skip(reader.get());
|
|
235
|
+
++ordinal;
|
|
236
|
+
if (ordinal > kMaximumArchiveEntries) {
|
|
237
|
+
write_error(error_buffer, error_buffer_size, "Comic archive has too many entries");
|
|
238
|
+
return 0;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (document->pages.empty()) {
|
|
242
|
+
write_error(error_buffer, error_buffer_size, "Comic archive contains no supported image pages");
|
|
243
|
+
return 0;
|
|
244
|
+
}
|
|
245
|
+
std::stable_sort(document->pages.begin(), document->pages.end(), natural_less);
|
|
246
|
+
std::error_code error;
|
|
247
|
+
fs::create_directories(document->cache_dir, error);
|
|
248
|
+
if (error) {
|
|
249
|
+
write_error(error_buffer, error_buffer_size, "Unable to create comic page cache");
|
|
250
|
+
return 0;
|
|
251
|
+
}
|
|
252
|
+
{
|
|
253
|
+
std::lock_guard<std::mutex> guard(g_documents_lock);
|
|
254
|
+
const std::string key = key_for(engine_id, generation);
|
|
255
|
+
g_documents[key] = document;
|
|
256
|
+
}
|
|
257
|
+
if (page_count) *page_count = static_cast<int>(document->pages.size());
|
|
258
|
+
return 1;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
extern "C" int papyrus_comic_extract_page(const char *engine_id,
|
|
262
|
+
int generation,
|
|
263
|
+
int page_index,
|
|
264
|
+
char *output_path,
|
|
265
|
+
size_t output_path_size,
|
|
266
|
+
char *error_buffer,
|
|
267
|
+
size_t error_buffer_size) {
|
|
268
|
+
auto document = find_document(engine_id, generation);
|
|
269
|
+
if (!document || page_index < 0 || static_cast<std::size_t>(page_index) >= document->pages.size()) {
|
|
270
|
+
write_error(error_buffer, error_buffer_size, "Comic page is unavailable");
|
|
271
|
+
return 0;
|
|
272
|
+
}
|
|
273
|
+
std::lock_guard<std::mutex> guard(document->lock);
|
|
274
|
+
const ComicPage &page = document->pages[static_cast<std::size_t>(page_index)];
|
|
275
|
+
std::string extension = fs::path(page.name).extension().string();
|
|
276
|
+
std::string filename = "papyrus-comic-page-" + std::to_string(std::hash<std::string>{}(document->engine_id)) +
|
|
277
|
+
"-" + std::to_string(generation) + "-" + std::to_string(page_index) + extension;
|
|
278
|
+
fs::path destination = document->cache_dir / filename;
|
|
279
|
+
std::error_code filesystem_error;
|
|
280
|
+
if (fs::is_regular_file(destination, filesystem_error) && fs::file_size(destination, filesystem_error) <= kMaximumEntryBytes) {
|
|
281
|
+
fs::last_write_time(destination, fs::file_time_type::clock::now(), filesystem_error);
|
|
282
|
+
const std::string value = destination.string();
|
|
283
|
+
if (output_path && value.size() + 1 <= output_path_size) {
|
|
284
|
+
std::copy(value.begin(), value.end(), output_path);
|
|
285
|
+
output_path[value.size()] = '\0';
|
|
286
|
+
return 1;
|
|
287
|
+
}
|
|
288
|
+
write_error(error_buffer, error_buffer_size, "Output path buffer is too small");
|
|
289
|
+
return 0;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
std::string message;
|
|
293
|
+
Reader reader = new_reader(message);
|
|
294
|
+
if (!reader || archive_read_open_filename(reader.get(), document->archive_path.string().c_str(), kIoBlockSize) != ARCHIVE_OK) {
|
|
295
|
+
write_error(error_buffer, error_buffer_size, reader ? archive_error_string(reader.get()) : message);
|
|
296
|
+
return 0;
|
|
297
|
+
}
|
|
298
|
+
archive_entry *entry = nullptr;
|
|
299
|
+
std::size_t ordinal = 0;
|
|
300
|
+
while (ordinal <= page.archive_ordinal) {
|
|
301
|
+
const int status = archive_read_next_header(reader.get(), &entry);
|
|
302
|
+
if (status != ARCHIVE_OK && status != ARCHIVE_WARN) {
|
|
303
|
+
const char *archive_error = archive_error_string(reader.get());
|
|
304
|
+
write_error(error_buffer, error_buffer_size, archive_error ? archive_error : "Unable to read comic page entry");
|
|
305
|
+
return 0;
|
|
306
|
+
}
|
|
307
|
+
if (ordinal < page.archive_ordinal) {
|
|
308
|
+
archive_read_data_skip(reader.get());
|
|
309
|
+
++ordinal;
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
if (archive_entry_is_encrypted(entry) == 1) {
|
|
313
|
+
write_error(error_buffer, error_buffer_size, "Encrypted comic pages are not supported");
|
|
314
|
+
return 0;
|
|
315
|
+
}
|
|
316
|
+
std::ofstream output(destination, std::ios::binary | std::ios::trunc);
|
|
317
|
+
if (!output) {
|
|
318
|
+
write_error(error_buffer, error_buffer_size, "Unable to create comic page cache file");
|
|
319
|
+
return 0;
|
|
320
|
+
}
|
|
321
|
+
char buffer[kIoBlockSize];
|
|
322
|
+
std::uint64_t total = 0;
|
|
323
|
+
for (;;) {
|
|
324
|
+
const la_ssize_t count = archive_read_data(reader.get(), buffer, sizeof(buffer));
|
|
325
|
+
if (count == 0) break;
|
|
326
|
+
if (count < 0) {
|
|
327
|
+
output.close();
|
|
328
|
+
fs::remove(destination, filesystem_error);
|
|
329
|
+
const char *archive_error = archive_error_string(reader.get());
|
|
330
|
+
write_error(error_buffer, error_buffer_size, archive_error ? archive_error : "Unable to extract comic page");
|
|
331
|
+
return 0;
|
|
332
|
+
}
|
|
333
|
+
total += static_cast<std::uint64_t>(count);
|
|
334
|
+
if (total > kMaximumEntryBytes) {
|
|
335
|
+
output.close();
|
|
336
|
+
fs::remove(destination, filesystem_error);
|
|
337
|
+
write_error(error_buffer, error_buffer_size, "Comic page exceeds the 64 MiB size limit");
|
|
338
|
+
return 0;
|
|
339
|
+
}
|
|
340
|
+
output.write(buffer, count);
|
|
341
|
+
if (!output) {
|
|
342
|
+
output.close();
|
|
343
|
+
fs::remove(destination, filesystem_error);
|
|
344
|
+
write_error(error_buffer, error_buffer_size, "Failed while caching comic page");
|
|
345
|
+
return 0;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
output.close();
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
prune_disk_cache(document->cache_dir, destination);
|
|
353
|
+
const std::string value = destination.string();
|
|
354
|
+
if (!output_path || value.size() + 1 > output_path_size) {
|
|
355
|
+
write_error(error_buffer, error_buffer_size, "Output path buffer is too small");
|
|
356
|
+
return 0;
|
|
357
|
+
}
|
|
358
|
+
std::copy(value.begin(), value.end(), output_path);
|
|
359
|
+
output_path[value.size()] = '\0';
|
|
360
|
+
return 1;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
extern "C" void papyrus_comic_close(const char *engine_id, int generation) {
|
|
364
|
+
if (!engine_id) return;
|
|
365
|
+
std::lock_guard<std::mutex> guard(g_documents_lock);
|
|
366
|
+
g_documents.erase(key_for(engine_id, generation));
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
extern "C" void papyrus_comic_close_engine(const char *engine_id) {
|
|
370
|
+
if (!engine_id) return;
|
|
371
|
+
std::lock_guard<std::mutex> guard(g_documents_lock);
|
|
372
|
+
for (auto iterator = g_documents.begin(); iterator != g_documents.end();) {
|
|
373
|
+
if (iterator->second->engine_id == engine_id) iterator = g_documents.erase(iterator);
|
|
374
|
+
else ++iterator;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <stddef.h>
|
|
4
|
+
|
|
5
|
+
#ifdef __cplusplus
|
|
6
|
+
extern "C" {
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
int papyrus_comic_open(const char *engine_id,
|
|
10
|
+
int generation,
|
|
11
|
+
const char *archive_path,
|
|
12
|
+
const char *cache_dir,
|
|
13
|
+
int *page_count,
|
|
14
|
+
char *error_buffer,
|
|
15
|
+
size_t error_buffer_size);
|
|
16
|
+
|
|
17
|
+
int papyrus_comic_extract_page(const char *engine_id,
|
|
18
|
+
int generation,
|
|
19
|
+
int page_index,
|
|
20
|
+
char *output_path,
|
|
21
|
+
size_t output_path_size,
|
|
22
|
+
char *error_buffer,
|
|
23
|
+
size_t error_buffer_size);
|
|
24
|
+
|
|
25
|
+
void papyrus_comic_close(const char *engine_id, int generation);
|
|
26
|
+
void papyrus_comic_close_engine(const char *engine_id);
|
|
27
|
+
|
|
28
|
+
#ifdef __cplusplus
|
|
29
|
+
}
|
|
30
|
+
#endif
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Vendored libarchive subset
|
|
2
|
+
|
|
3
|
+
This source snapshot is libarchive **v3.8.9**, pinned to upstream commit
|
|
4
|
+
`27cbc7827172698143e440801fc0ba39ccb4f1f5` from
|
|
5
|
+
`https://github.com/libarchive/libarchive`.
|
|
6
|
+
|
|
7
|
+
Papyrus compiles only the read-side source subset listed in both
|
|
8
|
+
`android/src/main/cpp/CMakeLists.txt` and `ios/PapyrusNativeEngine.podspec`.
|
|
9
|
+
The public C++ adapter in this directory filters comic archive entries,
|
|
10
|
+
orders them naturally, and extracts one selected image at a time to a bounded
|
|
11
|
+
cache. It does not write or modify archives.
|
|
12
|
+
|
|
13
|
+
The libarchive files retain their upstream notices. BLAKE2 reference source
|
|
14
|
+
files also carry the separate permissive notice in
|
|
15
|
+
`third_party_licenses/BLAKE2-NOTICE.txt`.
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/*-
|
|
2
|
+
* Copyright (c) 2014 Trevor Drake
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
|
6
|
+
* modification, are permitted provided that the following conditions
|
|
7
|
+
* are met:
|
|
8
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
9
|
+
* notice, this list of conditions and the following disclaimer.
|
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
11
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
12
|
+
* documentation and/or other materials provided with the distribution.
|
|
13
|
+
*
|
|
14
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
15
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
16
|
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
17
|
+
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
18
|
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
19
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
20
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
21
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
22
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
23
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
#ifndef ARCHIVE_PLATFORM_H_ANDROID_INCLUDED
|
|
27
|
+
#define ARCHIVE_PLATFORM_H_ANDROID_INCLUDED
|
|
28
|
+
|
|
29
|
+
#define __LIBARCHIVE_CONFIG_H_INCLUDED 1
|
|
30
|
+
|
|
31
|
+
#include <android/api-level.h>
|
|
32
|
+
#ifdef __ANDROID_API__
|
|
33
|
+
#if __ANDROID_API__ > 20
|
|
34
|
+
#define HAVE_FSTATVFS 1
|
|
35
|
+
#define HAVE_STATVFS 1
|
|
36
|
+
#define HAVE_TIMEGM 1
|
|
37
|
+
#define HAVE_SYS_XATTR_H 1
|
|
38
|
+
#define HAVE_LINUX_FIEMAP_H 1
|
|
39
|
+
#define HAVE_SYS_STATVFS_H 1
|
|
40
|
+
#endif
|
|
41
|
+
#endif
|
|
42
|
+
|
|
43
|
+
#define HAVE_CHOWN 1
|
|
44
|
+
#define HAVE_CHROOT 1
|
|
45
|
+
#define HAVE_CLOSEFROM 0
|
|
46
|
+
#define HAVE_CLOSE_RANGE 0
|
|
47
|
+
#define HAVE_CTIME_R 1
|
|
48
|
+
#define HAVE_CTYPE_H 1
|
|
49
|
+
#define HAVE_DECL_EXTATTR_NAMESPACE_USER 0
|
|
50
|
+
#define HAVE_DECL_INTMAX_MIN 1
|
|
51
|
+
#define HAVE_DECL_INTMAX_MAX 1
|
|
52
|
+
#define HAVE_DECL_INT64_MAX 1
|
|
53
|
+
#define HAVE_DECL_INT64_MIN 1
|
|
54
|
+
#define HAVE_DECL_SIZE_MAX 1
|
|
55
|
+
#define HAVE_DECL_SSIZE_MAX 1
|
|
56
|
+
#define HAVE_DECL_STRERROR_R 1
|
|
57
|
+
#define HAVE_DECL_UINTMAX_MAX 1
|
|
58
|
+
#define HAVE_DECL_UINT32_MAX 1
|
|
59
|
+
#define HAVE_DECL_UINT64_MAX 1
|
|
60
|
+
#define HAVE_DECL_INT32_MAX 1
|
|
61
|
+
#define HAVE_DECL_INT32_MIN 1
|
|
62
|
+
#define HAVE_DIRENT_H 1
|
|
63
|
+
#define HAVE_DIRFD 1
|
|
64
|
+
#define HAVE_DLFCN_H 1
|
|
65
|
+
#define HAVE_EILSEQ 1
|
|
66
|
+
#define HAVE_ERRNO_H 1
|
|
67
|
+
#define HAVE_FCHDIR 1
|
|
68
|
+
#define HAVE_FCHMOD 1
|
|
69
|
+
#define HAVE_FCHOWN 1
|
|
70
|
+
#define HAVE_FCNTL 1
|
|
71
|
+
#define HAVE_FCNTL_H 1
|
|
72
|
+
#define HAVE_FDOPENDIR 1
|
|
73
|
+
#define HAVE_FGETXATTR 1
|
|
74
|
+
#define HAVE_FLISTXATTR 1
|
|
75
|
+
#define HAVE_FORK 1
|
|
76
|
+
#define HAVE_FSEEKO 1
|
|
77
|
+
#define HAVE_FSETXATTR 1
|
|
78
|
+
#define HAVE_FSTAT 1
|
|
79
|
+
#define HAVE_FSTATAT 1
|
|
80
|
+
#define HAVE_FSTATFS 1
|
|
81
|
+
#define HAVE_FTRUNCATE 1
|
|
82
|
+
#define HAVE_GETEUID 1
|
|
83
|
+
#define HAVE_GETPID 1
|
|
84
|
+
#define HAVE_GETPWNAM_R 1
|
|
85
|
+
#define HAVE_GETPWUID_R 1
|
|
86
|
+
#define HAVE_GETXATTR 1
|
|
87
|
+
#define HAVE_GMTIME_R 1
|
|
88
|
+
#define HAVE_GRP_H 1
|
|
89
|
+
#define HAVE_INTMAX_T 1
|
|
90
|
+
#define HAVE_INTTYPES_H 1
|
|
91
|
+
#define HAVE_LCHOWN 1
|
|
92
|
+
#define HAVE_LGETXATTR 1
|
|
93
|
+
#define HAVE_LIBLZMA 1
|
|
94
|
+
#define HAVE_LIBZ 1
|
|
95
|
+
#define HAVE_LIMITS_H 1
|
|
96
|
+
#define HAVE_LINK 1
|
|
97
|
+
#define HAVE_LINUX_FS_H 1
|
|
98
|
+
#define HAVE_LINUX_MAGIC_H 1
|
|
99
|
+
#define HAVE_LINUX_TYPES_H 1
|
|
100
|
+
#define HAVE_LISTXATTR 1
|
|
101
|
+
#define HAVE_LLISTXATTR 1
|
|
102
|
+
#define HAVE_LOCALE_H 1
|
|
103
|
+
#define HAVE_LOCALTIME_R 1
|
|
104
|
+
#define HAVE_LONG_LONG_INT 1
|
|
105
|
+
#define HAVE_LSETXATTR 1
|
|
106
|
+
#define HAVE_LSTAT 1
|
|
107
|
+
#define HAVE_MBRTOWC 1
|
|
108
|
+
#define HAVE_MEMMOVE 1
|
|
109
|
+
#define HAVE_MEMORY_H 1
|
|
110
|
+
#define HAVE_MEMSET 1
|
|
111
|
+
#define HAVE_MKDIR 1
|
|
112
|
+
#define HAVE_MKFIFO 1
|
|
113
|
+
#define HAVE_MKNOD 1
|
|
114
|
+
#define HAVE_MKSTEMP 1
|
|
115
|
+
#define HAVE_OPENAT 1
|
|
116
|
+
#define HAVE_PATHS_H 1
|
|
117
|
+
#define HAVE_PIPE 1
|
|
118
|
+
#define HAVE_POLL 1
|
|
119
|
+
#define HAVE_POLL_H 1
|
|
120
|
+
#define HAVE_PTHREAD_H 1
|
|
121
|
+
#define HAVE_PWD_H 1
|
|
122
|
+
#define HAVE_READDIR_R 1
|
|
123
|
+
#define HAVE_READLINK 1
|
|
124
|
+
#define HAVE_READLINKAT 1
|
|
125
|
+
#define HAVE_REGEX_H 1
|
|
126
|
+
#define HAVE_SELECT 1
|
|
127
|
+
#define HAVE_SETENV 1
|
|
128
|
+
#define HAVE_SETLOCALE 1
|
|
129
|
+
#define HAVE_SIGACTION 1
|
|
130
|
+
#define HAVE_SIGNAL_H 1
|
|
131
|
+
#define HAVE_STATFS 1
|
|
132
|
+
#define HAVE_STDARG_H 1
|
|
133
|
+
#define HAVE_STDINT_H 1
|
|
134
|
+
#define HAVE_STDLIB_H 1
|
|
135
|
+
#define HAVE_STRCHR 1
|
|
136
|
+
#define HAVE_STRDUP 1
|
|
137
|
+
#define HAVE_STRERROR 1
|
|
138
|
+
#define HAVE_STRERROR_R 1
|
|
139
|
+
#define HAVE_STRFTIME 1
|
|
140
|
+
#define HAVE_STRINGS_H 1
|
|
141
|
+
#define HAVE_STRING_H 1
|
|
142
|
+
#define HAVE_STRRCHR 1
|
|
143
|
+
#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
|
|
144
|
+
#define HAVE_STRUCT_STAT_ST_MTIME_NSEC 0
|
|
145
|
+
#define HAVE_STRUCT_TM_TM_GMTOFF 1
|
|
146
|
+
#define HAVE_SYMLINK 1
|
|
147
|
+
#define HAVE_SYS_CDEFS_H 1
|
|
148
|
+
#define HAVE_SYS_IOCTL_H 1
|
|
149
|
+
#define HAVE_SYS_MOUNT_H 1
|
|
150
|
+
#define HAVE_SYS_PARAM_H 1
|
|
151
|
+
#define HAVE_SYS_POLL_H 1
|
|
152
|
+
#define HAVE_SYS_SELECT_H 1
|
|
153
|
+
#define HAVE_SYS_STATFS_H 1
|
|
154
|
+
#define HAVE_SYS_STAT_H 1
|
|
155
|
+
#define HAVE_SYS_TIME_H 1
|
|
156
|
+
#define HAVE_SYS_TYPES_H 1
|
|
157
|
+
#define HAVE_SYS_UTSNAME_H 1
|
|
158
|
+
#define HAVE_SYS_VFS_H 1
|
|
159
|
+
#define HAVE_SYS_WAIT_H 1
|
|
160
|
+
#define HAVE_TCGETATTR 1
|
|
161
|
+
#define HAVE_TCSETATTR 1
|
|
162
|
+
#define HAVE_TIME_H 1
|
|
163
|
+
#define HAVE_TZSET 1
|
|
164
|
+
#define HAVE_UINTMAX_T 1
|
|
165
|
+
#define HAVE_UNISTD_H 1
|
|
166
|
+
#define HAVE_UNSETENV 1
|
|
167
|
+
#define HAVE_UNSIGNED_LONG_LONG 1
|
|
168
|
+
#define HAVE_UNSIGNED_LONG_LONG_INT 1
|
|
169
|
+
#define HAVE_UTIME 1
|
|
170
|
+
#define HAVE_UTIMENSAT 1
|
|
171
|
+
#define HAVE_UTIMES 1
|
|
172
|
+
#define HAVE_UTIME_H 1
|
|
173
|
+
#define HAVE_VFORK 1
|
|
174
|
+
#define HAVE_VPRINTF 1
|
|
175
|
+
#define HAVE_WCHAR_H 1
|
|
176
|
+
#define HAVE_WCHAR_T 1
|
|
177
|
+
#define HAVE_WCRTOMB 1
|
|
178
|
+
#define HAVE_WCSCMP 1
|
|
179
|
+
#define HAVE_WCSCPY 1
|
|
180
|
+
#define HAVE_WCSLEN 1
|
|
181
|
+
#define HAVE_WCTOMB 1
|
|
182
|
+
#define HAVE_WCTYPE_H 1
|
|
183
|
+
#define HAVE_WMEMCMP 1
|
|
184
|
+
#define HAVE_WMEMCPY 1
|
|
185
|
+
#define HAVE_ARC4RANDOM_BUF 1
|
|
186
|
+
#define HAVE_ZLIB_H 1
|
|
187
|
+
#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
|
|
188
|
+
#define SIZEOF_WCHAR_T 4
|
|
189
|
+
#define STDC_HEADERS 1
|
|
190
|
+
#define STRERROR_R_CHAR_P 1
|
|
191
|
+
#define HAVE_SYS_TIME_H 1
|
|
192
|
+
#endif
|