feat: M6.10–M6.19 批量收编 + M6.19 推卡验收
- M7 launcher 重写 5 期(虚拟化宫格/meow_theme 单一权威/横幅动画/自定义 PIN 键盘) - OOM 通用化(cachegov 上收 SDK)、自动切歌根治、meowpanel jv_free 泄漏修复、Hello 滚动卡顿修复 - ncm 歌词 UI / 媒体通知封面 / 封面分辨率 640 - 5 bug 修复:ncm 后台化 UI 叠层+点击穿透、再进 ncm 桌面叠层、播放页新旧 UI 叠层抢刷脏区(meow_ui_gfx 恢复边沿整帧重画)、PIN 亮屏亮度跳(keys.c meow_panel_on 按 settings_brightness_clamped 恢复)、通知中心封面显歌单封面(cover.c save_cover_raw 加 is_song + 命中块守卫) - 四 App 统一重链新 meow_ui.a 51caee4a;M6.19=0.8.19 固件 2d2331f2 推卡自刷验收全绿
This commit is contained in:
1 parent
c2ee7626a4
commit
3d70a3dd2c
176 files changed
+15507
-597
No files matched your search
@@ -1,6 +1,7 @@
|
||||
# os.meow.reader 构建产物(不入仓)
|
||||
/vendor/
|
||||
/reader
|
||||
/os.meow.reader.mpk
|
||||
/test/test_reader_core_host
|
||||
/test/loaders_smoke_host
|
||||
/test/rdft_smoke_mipsel
|
||||
|
||||
@@ -1,10 +1,30 @@
|
||||
os.meow.reader (patch_v2/reader_app) — Third-Party NOTICES
|
||||
==========================================================
|
||||
|
||||
This application statically links and/or bundles the following
|
||||
third-party components. Their copyrights and licenses are reproduced
|
||||
below. The build script (build_reader.sh) fetches the exact pinned
|
||||
versions, so the binaries can be rebuilt / re-linked from source.
|
||||
This application (os.meow.reader) statically links and/or bundles the
|
||||
following third-party components. Their copyrights and licenses are
|
||||
reproduced below. The build script (build_reader.sh) fetches the exact
|
||||
pinned versions, so the binaries can be rebuilt / re-linked from source.
|
||||
|
||||
License ownership
|
||||
-----------------
|
||||
The reader application's own source code is licensed under the Apache
|
||||
License 2.0 (part of the MeowOS project; see the top-level repository
|
||||
LICENSE). The third-party components listed below retain their own
|
||||
licenses — in particular libmobi is LGPL-3.0 and stays under LGPL-3.0
|
||||
even though it is statically linked into the binary. Under LGPL-3.0
|
||||
section 1 the Apache-2.0 application is not thereby required to be
|
||||
re-licensed under the GPL.
|
||||
|
||||
Source availability
|
||||
-------------------
|
||||
The reader source (this application), build_reader.sh, and the top-level
|
||||
MeowOS repository are publicly pullable at:
|
||||
https://git.yeij.top/AskaEth/MeowOS-For-R3P2.git
|
||||
(admin push: ssh://git@git.yeij.top:2222/AskaEth/MeowOS-For-R3P2.git)
|
||||
The libmobi source tree at the locked commit remains available from the
|
||||
upstream project and is re-fetched by build_reader.sh; a relink how-to
|
||||
is in README_LGPL_RELINK.md in the reader_app directory.
|
||||
|
||||
--------------------------------------------------------------------
|
||||
1. libmobi — Copyright (c) 2014-2024 Bartek Fabiszewski
|
||||
@@ -26,6 +46,11 @@ versions, so the binaries can be rebuilt / re-linked from source.
|
||||
upstream repo at the commit above); the build script retrieves
|
||||
exactly that commit.
|
||||
|
||||
Full license texts (shipped with the package in resources/licenses/):
|
||||
- GNU GPL version 3: resources/licenses/GPL-3.0.txt
|
||||
- GNU LGPL version 3: resources/licenses/LGPL-3.0.txt
|
||||
Both full texts are also reproduced below.
|
||||
|
||||
Full license text (GNU LGPL v3):
|
||||
--------------------------------------------------------------------
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
# README_LGPL_RELINK — 如何替换 libmobi 并重新链接阅读器(LGPL-3.0 relink)
|
||||
|
||||
`os.meow.reader` 静态链接 **libmobi**(LGPL-3.0)。LGPL-3.0 §4(d) 要求以「允许用户在替换 libmobi 后重链」的方式提供源码(§4(d)(0))。本文件给出完整重链步骤:获取工具链 → 替换 libmobi 源码 → 重链 → 装回设备。**本操作可自行修改 libmobi 并重编,不触犯任何许可证限制;修改 libmobi 部分的衍生成果仍受 LGPL-3.0 约束(但不会被强制整体 GPL)。**
|
||||
|
||||
## 0) 相关文件与源码位置
|
||||
|
||||
| 内容 | 位置 |
|
||||
|---|---|
|
||||
| 阅读器自有源码 | 主仓:`https://git.yeij.top/AskaEth/MeowOS-For-R3P2.git`(`patch_v2/reader_app/`,Apache-2.0) |
|
||||
| libmobi 源码(锁定 commit) | `https://github.com/bfabiszewski/libmobi`,commit `906274205c11944b628da1c553b255acb1af7c55`(2024-10-29);`build_reader.sh` 的 `LM_URL` 即指向该 SHA |
|
||||
| 重链构建脚本 | `patch_v2/reader_app/build_reader.sh`(可复现构建 + qemu-mipsel 冒烟) |
|
||||
| 合规材料(随 .mpk 分发) | `patch_v2/reader_app/resources/licenses/`(`NOTICE` + `GPL-3.0.txt` + `LGPL-3.0.txt`) |
|
||||
|
||||
> 主仓公开性:`git ls-remote https://git.yeij.top/AskaEth/MeowOS-For-R3P2.git` 可匿名读到 HEAD,即公开可克隆(见 NOTICE「Source availability」)。若看不到,说明镜像/网络受限,请从维护者获取。
|
||||
|
||||
## 1) 获取 mipsel 交叉工具链(两种方式)
|
||||
|
||||
阅读器是 **mipsel / musl 静态软浮点 (sf)** 目标。构建用的是本地 `.tools/`(gitignored,不入仓),接收者需自行准备等价工具链:
|
||||
|
||||
- **方式 A(推荐,zig 单文件)**:下载 zig(`zig cc` 支持 `-target mipsel-linux-musl`,静态软浮点)。本项目用 `zig-mipsel-cc` 封装,等价于:
|
||||
```sh
|
||||
# 示例:zig-0.12+;把 zig 解压后设 ZIG 路径
|
||||
# zig cc -target mipsel-linux-musl -static ...
|
||||
```
|
||||
- **方式 B(musl 交叉编译套件)**:安装 `mipsel-linux-muslsf-cross`(如 musl.cc 发布的 `mipsel-linux-muslsf-cross`),得到:
|
||||
```
|
||||
$ROOT/.tools/mipsel-linux-muslsf-cross/mipsel-linux-muslsf # sysroot/lib等
|
||||
```
|
||||
`$ROOT = $HOME/Project/R3ProII`(build_reader.sh 内 `ROOT` 变量,可改)。
|
||||
|
||||
若本地已有 `.tools/`,重链无需再装。
|
||||
|
||||
## 2) 替换 libmobi 源码
|
||||
|
||||
```sh
|
||||
cd "$HOME/Project/R3ProII/patch_v2/reader_app"
|
||||
# 拉取你想要的 libmobi(或用 build_reader.sh 自动拉锁定 commit)
|
||||
# 用锁定 commit 拉取:
|
||||
curl -fsSL -o /tmp/lm.tgz \
|
||||
"https://codeload.github.com/bfabiszewski/libmobi/tar.gz/906274205c11944b628da1c553b255acb1af7c55"
|
||||
rm -rf vendor/libmobi && mkdir -p /tmp/lm_m && tar xzf /tmp/lm.tgz -C /tmp/lm_m --strip-components=1
|
||||
mkdir -p vendor/libmobi && cp -r /tmp/lm_m/src vendor/libmobi/src && cp /tmp/lm_m/COPYING vendor/libmobi/COPYING
|
||||
# 然后在此处对 vendor/libmobi/src/*.c 做你的修改
|
||||
```
|
||||
|
||||
## 3) 强制重编 libmobi 目标文件 + 重链
|
||||
|
||||
`build_reader.sh` 对 `vendor/libmobi/src/*.c` 有「已存在 .o 跳过」缓存(`vendor/build/lm_*.o`),替换源码后**必须清掉**旧目标文件再重跑,否则不会重编 libmobi:
|
||||
|
||||
```sh
|
||||
rm -f vendor/build/lm_*.o
|
||||
./build_reader.sh # 全量:编 libmobi/miniz/stb/freetype + 链接 reader + qemu-mipsel 冒烟
|
||||
```
|
||||
|
||||
- 产物:`./reader`(mipsel 静态 ELF)。
|
||||
- 需要 `qemu-mipsel`(跑冒烟单测);宿主 core/loader 单测用 `gcc`。
|
||||
- 若只想重链不跑测试,可手动执行 `build_reader.sh` 第 7 步的链接命令(见脚本注释),但建议跑全套以保正确。
|
||||
|
||||
## 4) 装回设备(两种方式)
|
||||
|
||||
- **方式 A(宽松,最直接;启动路径不验签)**:launcher 重扫 `MeowAPPs/` 后直接运行二进制,故把重链后的 `reader` 直接放到应用目录即可,**不触发安装期签名门**:
|
||||
```sh
|
||||
scp ./reader root@<设备IP>:/usr/data/mnt/sd_0/MeowAPPs/os.meow.reader/reader
|
||||
ssh root@<设备IP> 'chmod 755 /usr/data/mnt/sd_0/MeowAPPs/os.meow.reader/reader'
|
||||
# 若在跑,重开阅读器;MeowAPPs 热更即生效
|
||||
```
|
||||
- **方式 B(走官方 .mpk + 签名 + nyai 安装)**:`os.meow.*` 包无签会被 `nyai`/launcher 拒装,故需用 `.keys/signing.key` 签名(仅维护者持有私钥)。接收者的本地重链一般走方式 A。
|
||||
```sh
|
||||
./pack_reader_mpk.sh # 产 os.meow.reader.mpk(含 resources/licenses/)
|
||||
../meow_sign/meow_sign sign os.meow.reader.mpk "$HOME/Project/R3ProII/.keys/signing.key"
|
||||
scp os.meow.reader.mpk root@<设备IP>:/data/
|
||||
ssh root@<设备IP> 'nyai install /data/os.meow.reader.mpk'
|
||||
```
|
||||
|
||||
## 5) 修改自由度说明(LGPL 敏感点)
|
||||
|
||||
- 安装期签名校验只针对**未签名/无有效签**的 `.mpk` 安装;**启动路径**是 launcher 直接运行 `MeowAPPs/<pkg>/` 下的二进制(`README.md:259` 热更语义),对重链后的二进制**不做运行时验签**,改造自由度未被结构性封死。
|
||||
- 重链产物请**保留 `resources/licenses/` 随包**(含 GPL-3.0 + LGPL-3.0 全文 + NOTICE),并保留 libmobi 版权声明。
|
||||
- 你对 libmobi 的修改形成衍生作品:其自身仍按 LGPL-3.0 提供;把修改后的 libmobi 重新分发时应随附相应源码(按 LGPL §4 履行,本仓库的重链脚本 + 锁定的 `LM_URL` 即可复现)。
|
||||
|
||||
## 6) 校验
|
||||
|
||||
- `file ./reader` 应显示 `ELF 32-bit LSB executable, MIPS, ... statically linked, ... soft-float`。
|
||||
- `tar tzvf os.meow.reader.mpk` 应含 `resources/licenses/{NOTICE,GPL-3.0.txt,LGPL-3.0.txt}`。
|
||||
- 真机打开一本 MOBI 确认可读。
|
||||
@@ -34,6 +34,15 @@ static void app_on_tick(void)
|
||||
if (reader_is_active()) { reader_on_tick(now); return; }
|
||||
}
|
||||
|
||||
static void app_on_touch_down(int x, int y)
|
||||
{
|
||||
if (reader_is_active()) { reader_on_touch_down(x, y); return; }
|
||||
}
|
||||
static void app_on_touch_move(int x, int y)
|
||||
{
|
||||
if (reader_is_active()) { reader_on_touch_move(x, y); return; }
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
meow_log(MEOW_LOG_INFO, "start");
|
||||
@@ -48,7 +57,7 @@ int main(void)
|
||||
meow_view_page_push(ACT_SHELF);
|
||||
|
||||
meow_ui_events ev = { app_on_key, app_on_tap, app_on_swipe, app_on_tick,
|
||||
NULL, NULL, NULL };
|
||||
NULL, app_on_touch_down, app_on_touch_move };
|
||||
meow_ui_run(&ev);
|
||||
|
||||
meow_view_free(g_reader_view);
|
||||
|
||||
@@ -24,7 +24,8 @@ struct rd_book {
|
||||
char path[400];
|
||||
char font[400];
|
||||
char base[256];
|
||||
const char *encname;
|
||||
const char *encname; /* TXT 有效编码可读名(含覆盖后);非 TXT = "" */
|
||||
rd_enc_t enc; /* TXT 有效编码;非 TXT = RD_ENC_UTF8 */
|
||||
rdft *ft;
|
||||
rd_src *src;
|
||||
rd_fmt_t fmt;
|
||||
@@ -44,21 +45,22 @@ struct rd_book {
|
||||
int seg_cache_idx;
|
||||
};
|
||||
|
||||
static const char *fmt_encname(rd_fmt_t f, const char *path)
|
||||
/* 编码枚举 → 可读名(R3:Big5 正确解码后名实相符)。 */
|
||||
static const char *enc_to_name(rd_enc_t enc)
|
||||
{
|
||||
if (f == RD_FMT_TXT) {
|
||||
rdtxt_info info;
|
||||
if (rdtxt_probe(path, &info) == 0) {
|
||||
switch (info.enc) {
|
||||
case RD_ENC_UTF8: return "UTF-8";
|
||||
case RD_ENC_UTF16LE: return "UTF-16LE";
|
||||
case RD_ENC_UTF16BE: return "UTF-16BE";
|
||||
case RD_ENC_GB18030: return "GB18030";
|
||||
case RD_ENC_BIG5: return "Big5(按GB18030)";
|
||||
case RD_ENC_ASCII: return "ASCII";
|
||||
}
|
||||
}
|
||||
switch (enc) {
|
||||
case RD_ENC_UTF8: return "UTF-8";
|
||||
case RD_ENC_UTF16LE: return "UTF-16LE";
|
||||
case RD_ENC_UTF16BE: return "UTF-16BE";
|
||||
case RD_ENC_GB18030: return "GB18030";
|
||||
case RD_ENC_BIG5: return "Big5";
|
||||
case RD_ENC_ASCII: return "ASCII";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
static const char *fmt_encname(rd_fmt_t f, rd_enc_t enc)
|
||||
{
|
||||
if (f == RD_FMT_TXT) return enc_to_name(enc);
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -169,7 +171,10 @@ int rd_book_open(rd_book **b, const char *path, const char *font_path,
|
||||
|
||||
if (rd_src_open(&x->src, path) != 0) goto close;
|
||||
x->fmt = rd_src_fmt(x->src);
|
||||
x->encname = fmt_encname(x->fmt, path);
|
||||
x->enc = RD_ENC_UTF8;
|
||||
rd_enc_t tmp_enc = RD_ENC_UTF8;
|
||||
if (rd_src_txt_enc(x->src, &tmp_enc) == 0) x->enc = tmp_enc;
|
||||
x->encname = fmt_encname(x->fmt, x->enc);
|
||||
x->is_img = (x->fmt == RD_FMT_CBZ);
|
||||
|
||||
if (!x->is_img) {
|
||||
@@ -210,6 +215,7 @@ int rd_book_font(rd_book *b) { return b ? b->fs : 0; }
|
||||
int rd_book_ls(rd_book *b) { return b ? b->ls : 0; }
|
||||
int rd_book_is_image(rd_book *b) { return b ? b->is_img : 0; }
|
||||
const char *rd_book_encname(const rd_book *b) { return b ? (b->encname ? b->encname : "") : ""; }
|
||||
rd_enc_t rd_book_enc_get(const rd_book *b) { return b ? b->enc : RD_ENC_UTF8; }
|
||||
|
||||
void rd_book_geom(rd_book *b, int *fs, int *ls, int *pw, int *ph, int *mx, int *my, int *top)
|
||||
{
|
||||
@@ -225,6 +231,28 @@ void rd_book_geom(rd_book *b, int *fs, int *ls, int *pw, int *ph, int *mx, int *
|
||||
const char *rd_book_basename(const rd_book *b) { return b ? b->base : ""; }
|
||||
const char *rd_book_path(const rd_book *b) { return b ? b->path : ""; }
|
||||
|
||||
/* R3:TXT 编码切换——重开 src(带覆盖编码)、重建页索引、回锚当前页。非 TXT/CBZ 返回 -1。
|
||||
* 事务式:先开新 src 成功才换(失败保留旧 src,书仍可用,返回负值)。 */
|
||||
int rd_book_set_enc(rd_book *b, rd_enc_t enc)
|
||||
{
|
||||
if (!b || b->is_img || b->fmt != RD_FMT_TXT) return -1;
|
||||
if (enc == b->enc) return b->cur; /* 同编码,无需重建 */
|
||||
int seg; int32_t ch;
|
||||
rd_book_anchor(b, &seg, &ch);
|
||||
|
||||
rd_src *ns = NULL;
|
||||
if (rd_src_open_with_enc(&ns, b->path, &enc) != 0) return -2; /* 旧 src 未动 */
|
||||
rd_src_free(b->src); b->src = ns; /* 换新 */
|
||||
b->enc = enc;
|
||||
b->encname = fmt_encname(b->fmt, b->enc);
|
||||
|
||||
/* 重建索引(复用现值 fs/ls/content_*),再回锚 */
|
||||
free(b->segs); free(b->pages); b->segs = NULL; b->pages = NULL;
|
||||
b->nsegs = b->npages = 0;
|
||||
if (build_index(b) != 0) return -3; /* 新 src 有效但索引空 → 渲染返回 -1,安全降级 */
|
||||
return rd_book_jump_to_anchor(b, seg, ch, b->fs, b->ls);
|
||||
}
|
||||
|
||||
void rd_book_anchor(rd_book *b, int *seg, int32_t *ch)
|
||||
{
|
||||
if (!b || b->npages <= 0) { if (seg) *seg = 0; if (ch) *ch = 0; return; }
|
||||
@@ -243,6 +271,15 @@ int rd_book_turn(rd_book *b, int delta)
|
||||
return np;
|
||||
}
|
||||
|
||||
int rd_book_set_page(rd_book *b, int page)
|
||||
{
|
||||
if (!b || b->npages <= 0) return 0;
|
||||
if (page < 0) page = 0;
|
||||
if (page >= b->npages) page = b->npages - 1;
|
||||
b->cur = page;
|
||||
return page;
|
||||
}
|
||||
|
||||
/* ---- 文本页渲染(FreeType 字形 → 全屏 565) ---- */
|
||||
static int render_text_page(rd_book *b, int page_no, uint16_t *out, int pitch, uint16_t bg565, uint16_t fg565)
|
||||
{
|
||||
|
||||
@@ -35,6 +35,7 @@ void rd_book_close(rd_book *b);
|
||||
int rd_book_pages(rd_book *b);
|
||||
int rd_book_current(rd_book *b); /* 当前页 */
|
||||
int rd_book_turn(rd_book *b, int delta); /* +1/-1;clamp 到 [0,npages-1] */
|
||||
int rd_book_set_page(rd_book *b, int page); /* 跳到绝对页;clamp;返回实际页(段刮擦用) */
|
||||
int rd_book_is_image(rd_book *b); /* 1=CBZ 图片页书 */
|
||||
|
||||
/* 目录:0=无;i 项标题写到 title,目标段/字符偏移填 *seg 与 *ch。 */
|
||||
@@ -56,8 +57,13 @@ int rd_book_render_text(rd_book *b, int page_no, rd_book_line_fn fn, void *ctx)
|
||||
/* 书名/信息(章节名:TXT 无章节=文件名;enc 可读名)。调用方 strcpy 到自己的缓冲。 */
|
||||
const char *rd_book_basename(const rd_book *b); /* 文件名(路径尾分量) */
|
||||
const char *rd_book_encname(const rd_book *b);
|
||||
rd_enc_t rd_book_enc_get(const rd_book *b); /* TXT 有效编码(非 TXT = RD_ENC_UTF8) */
|
||||
const char *rd_book_path(const rd_book *b); /* 原始路径 */
|
||||
|
||||
/* R3:TXT 编码切换:重开 src(覆盖编码)+ 重建索引 + 回锚。返回目标页;非 TXT/CBZ 或失败负值。
|
||||
* 用于「编码」菜单(Big5 繁体书手动选定)。 */
|
||||
int rd_book_set_enc(rd_book *b, rd_enc_t enc);
|
||||
|
||||
/* 字体/几何 */
|
||||
int rd_book_font(rd_book *b); /* 当前字号 */
|
||||
int rd_book_ls(rd_book *b); /* 行距% */
|
||||
|
||||
@@ -68,18 +68,19 @@ int rdprog_load(const char *book_path, rdprog *p)
|
||||
FILE *f = fopen(path, "rb");
|
||||
if (!f) return 0;
|
||||
char line[256];
|
||||
int seg = 0, fs = 0, ls = 0; int32_t ch = 0; uint64_t ts = 0; int v = 0, found = 0;
|
||||
int seg = 0, fs = 0, ls = 0, enc = -1; int32_t ch = 0; uint64_t ts = 0; int v = 0, found = 0;
|
||||
while (fgets(line, sizeof line, f)) {
|
||||
if (sscanf(line, "v=%d", &v) == 1) { if (v == 1) found = 1; }
|
||||
else if (sscanf(line, "seg=%d", &seg) == 1) { /* no-op */ }
|
||||
else if (sscanf(line, "ch=%d", &ch) == 1) { /* no-op */ }
|
||||
else if (sscanf(line, "fs=%d", &fs) == 1) { /* no-op */ }
|
||||
else if (sscanf(line, "ls=%d", &ls) == 1) { /* no-op */ }
|
||||
else if (sscanf(line, "enc=%d", &enc) == 1) { /* no-op(旧档无此键→enc=-1 自动) */ }
|
||||
else if (sscanf(line, "ts=%llu", (unsigned long long *)&ts) == 1) { /* no-op */ }
|
||||
}
|
||||
fclose(f);
|
||||
if (!found) return 0;
|
||||
p->valid = 1; p->seg = seg; p->ch = ch; p->fs = fs; p->ls = ls; p->ts = ts;
|
||||
p->valid = 1; p->seg = seg; p->ch = ch; p->fs = fs; p->ls = ls; p->enc = enc; p->ts = ts;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -96,6 +97,7 @@ int rdprog_save(const char *book_path, const rdprog *p)
|
||||
fprintf(f, "ch=%d\n", (int)p->ch);
|
||||
fprintf(f, "fs=%d\n", p->fs);
|
||||
fprintf(f, "ls=%d\n", p->ls);
|
||||
fprintf(f, "enc=%d\n", p->enc);
|
||||
fprintf(f, "ts=%llu\n", (unsigned long long)p->ts);
|
||||
fclose(f);
|
||||
return 0;
|
||||
|
||||
@@ -21,6 +21,7 @@ typedef struct rdprog {
|
||||
int32_t ch;
|
||||
int fs;
|
||||
int ls;
|
||||
int enc; /* R3:显式文本编码(rd_enc_t);-1=自动(未手动选) */
|
||||
uint64_t ts; /* 最近阅读 unix 秒 */
|
||||
} rdprog;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#define RD_MENU_H 64
|
||||
#define RD_MENU_BTN 6
|
||||
#define RD_MENU_BTN 7
|
||||
|
||||
static rd_book *g_book;
|
||||
static int g_reader_active;
|
||||
@@ -34,12 +34,47 @@ static int g_dir_top, g_dir_row_h; /* 目录列表几何(rdsrc 目录项
|
||||
static char g_font_path[400];
|
||||
static int g_notice_ms;
|
||||
|
||||
/* ---- R3 翻页动画(轻量水平滑入) ---- */
|
||||
static meow_anim *g_anim; /* 活动翻页动画;NULL=无 */
|
||||
static uint16_t *g_anim_old; /* 动画「滑出」页位图(切页前快照) */
|
||||
static int g_anim_dir; /* 1=下一页(旧左移/新右入);-1=上一页(旧右移/新左入) */
|
||||
|
||||
/* ---- R3 段刮擦(右缘拖动快速定位 + 预览) ---- */
|
||||
#define RD_SCRUB_W 26 /* 右缘刮擦条宽度 */
|
||||
static int g_scrub; /* 1=刮擦中 */
|
||||
static int g_scrub_page; /* 刮擦目标页(实时预览用) */
|
||||
|
||||
/* ---- R3 编码切换(TXT;Big5 繁体书手动选定) ---- */
|
||||
static int g_enc_idx; /* g_enc_cycle[] 下标(当前有效编码) */
|
||||
|
||||
static uint32_t g_page_bg, g_page_fg; /* 正文页底/字色(24bit) */
|
||||
static char g_chapter[128]; /* 顶栏章节名(TXT 无章节=文件名) */
|
||||
|
||||
#define RD_READER_DEFAULT_FS 20
|
||||
#define RD_READER_DEFAULT_LS 130
|
||||
|
||||
/* R3:编码循环(显式编码;Auto 由打开时探测决定,不在此列)。
|
||||
* -1 哨兵不用;TXT 初始 = 打开探测结果(GB18030 兜底)。 */
|
||||
static const rd_enc_t g_enc_cycle[] = { RD_ENC_GB18030, RD_ENC_BIG5, RD_ENC_UTF8,
|
||||
RD_ENC_UTF16LE, RD_ENC_UTF16BE };
|
||||
#define RD_ENC_CYCLE_N ((int)(sizeof g_enc_cycle / sizeof g_enc_cycle[0]))
|
||||
static const char *enc_cycle_name(int idx)
|
||||
{
|
||||
switch (g_enc_cycle[idx]) {
|
||||
case RD_ENC_GB18030: return "GB18030";
|
||||
case RD_ENC_BIG5: return "Big5";
|
||||
case RD_ENC_UTF8: return "UTF-8";
|
||||
case RD_ENC_UTF16LE: return "UTF-16LE";
|
||||
case RD_ENC_UTF16BE: return "UTF-16BE";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
static int enc_to_cycle_idx(rd_enc_t e)
|
||||
{
|
||||
for (int i = 0; i < RD_ENC_CYCLE_N; i++) if (g_enc_cycle[i] == e) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* 前向声明(reader_reflow* 依赖 reader_refill/redraw,定义在后) */
|
||||
static void reader_redraw(void);
|
||||
static int reader_refill_page(void);
|
||||
@@ -96,6 +131,7 @@ static void chapter_name(void)
|
||||
static void reader_reflow(void)
|
||||
{
|
||||
if (!g_book) return;
|
||||
if (g_anim) { meow_anim_cancel(g_anim); g_anim = NULL; } /* 重排/雷字号时终止翻页动画 */
|
||||
int seg = 0; int32_t ch = 0;
|
||||
rd_book_anchor(g_book, &seg, &ch); /* 记录当前锚,重排后回锚 */
|
||||
rd_book_jump_to_anchor(g_book, seg, ch, g_fs, g_ls);
|
||||
@@ -110,7 +146,9 @@ static void reader_reflow_persist(void)
|
||||
int seg = 0; int32_t ch = 0;
|
||||
rd_book_anchor(g_book, &seg, &ch);
|
||||
rdprog p;
|
||||
p.valid = 1; p.seg = seg; p.ch = ch; p.fs = g_fs; p.ls = g_ls; p.ts = (uint64_t)time(NULL);
|
||||
p.valid = 1; p.seg = seg; p.ch = ch; p.fs = g_fs; p.ls = g_ls;
|
||||
p.enc = (g_book && !rd_book_is_image(g_book)) ? (int)g_enc_cycle[g_enc_idx] : -1;
|
||||
p.ts = (uint64_t)time(NULL);
|
||||
rdprog_save(rd_book_path(g_book), &p);
|
||||
}
|
||||
|
||||
@@ -121,6 +159,67 @@ static void reader_draw_line_atlas(int x, int y, const char *utf8, int len, void
|
||||
meow_ui_text(x, y, utf8, (g_fs <= 20) ? 20 : 28, g_page_fg);
|
||||
}
|
||||
|
||||
/* 正文内容区几何:y0=top(顶栏下沿),y1=ph-my(下边距)。 */
|
||||
static int rect_y0(void) { return g_top; }
|
||||
static int rect_y1(void) { return g_ph - g_my; }
|
||||
|
||||
/* 把一页位图的行区间 [y0,y1) 以水平偏移 dx 拷到 back_buf(裁剪到屏幕)。动画/局部重绘共用。 */
|
||||
static void blit_rows(uint16_t *src, int dx, int y0, int y1)
|
||||
{
|
||||
unsigned char *bb = meow_ui_back_buf();
|
||||
int pitch = meow_ui_back_buf_pitch();
|
||||
int bpp = meow_ui_back_buf_bpp();
|
||||
if (!bb || pitch <= 0 || bpp != 16) return;
|
||||
int sx0 = dx < 0 ? -dx : 0;
|
||||
int dx0 = dx > 0 ? dx : 0;
|
||||
int w = g_pw - (dx < 0 ? -dx : dx);
|
||||
if (w <= 0) return;
|
||||
for (int y = y0; y < y1; y++) {
|
||||
if (y < 0 || y >= g_ph) continue;
|
||||
memcpy(bb + (size_t)y * pitch + (size_t)dx0 * 2,
|
||||
src + (size_t)y * g_pw + sx0, (size_t)w * 2);
|
||||
}
|
||||
}
|
||||
/* 子矩形直拷(同屏幕坐标):用于右缘刮擦条区恢复/局部重绘。 */
|
||||
static void blit_sub(uint16_t *src, int sx, int sy, int w, int h)
|
||||
{
|
||||
unsigned char *bb = meow_ui_back_buf();
|
||||
int pitch = meow_ui_back_buf_pitch();
|
||||
int bpp = meow_ui_back_buf_bpp();
|
||||
if (!bb || pitch <= 0 || bpp != 16) return;
|
||||
for (int y = sy; y < sy + h; y++) {
|
||||
if (y < 0 || y >= g_ph) continue;
|
||||
memcpy(bb + (size_t)y * pitch + (size_t)sx * 2, src + (size_t)y * g_pw + sx, (size_t)w * 2);
|
||||
}
|
||||
}
|
||||
|
||||
/* R3 右缘刮擦指示条:轨道 + 拇指(当前/目标位置)+ 刮擦中预览框。render_cb 调用。 */
|
||||
static void reader_draw_scrub(const meow_theme *th)
|
||||
{
|
||||
int np = g_book ? rd_book_pages(g_book) : 0;
|
||||
if (np <= 0) return;
|
||||
int y0 = rect_y0(), y1 = rect_y1(), h = y1 - y0;
|
||||
if (h <= 0) return;
|
||||
int page = g_scrub ? g_scrub_page : rd_book_current(g_book);
|
||||
if (page < 0) page = 0;
|
||||
if (page >= np) page = np - 1;
|
||||
int x = g_pw - 10;
|
||||
meow_ui_fill_rect(x - 1, y0, 3, h, th->dim); /* 轨道 */
|
||||
int denom = np > 1 ? (np - 1) : 1;
|
||||
int ty = y0 + (int)((long long)h * (np > 1 ? page : 0) / denom);
|
||||
meow_ui_fill_rect(x - 3, ty - 4, 7, 8, th->primary); /* 拇指 */
|
||||
if (g_scrub) {
|
||||
char pv[24]; snprintf(pv, sizeof pv, "%d/%d", page + 1, np);
|
||||
int bw = 58, bh = 22;
|
||||
int px = x - bw - 6;
|
||||
int py = ty - bh / 2;
|
||||
if (py < y0) py = y0;
|
||||
if (py + bh > y1) py = y1 - bh;
|
||||
meow_ui_fill_rect(px, py, bw, bh, th->surfaceContainer);
|
||||
meow_ui_text_center(px + bw / 2, py + (bh - 20) / 2, pv, 16, th->fg);
|
||||
}
|
||||
}
|
||||
|
||||
static void reader_canvas_render(meow_widget *w, const meow_theme *th, void *ctx)
|
||||
{
|
||||
(void)w; (void)ctx;
|
||||
@@ -129,36 +228,39 @@ static void reader_canvas_render(meow_widget *w, const meow_theme *th, void *ctx
|
||||
int page = rd_book_current(g_book);
|
||||
if ((g_has_font || rd_book_is_image(g_book)) && g_page_buf[RD_PAGE_SLOT_CUR]) {
|
||||
/* 翻页 blit:行拷贝当前页位图 → back_buf(局部脏区由 flush_region 上屏) */
|
||||
unsigned char *bb = meow_ui_back_buf();
|
||||
int pitch = meow_ui_back_buf_pitch();
|
||||
int bpp = meow_ui_back_buf_bpp();
|
||||
uint16_t *src = g_page_buf[RD_PAGE_SLOT_CUR];
|
||||
if (bb && pitch > 0 && bpp == 16) {
|
||||
for (int y = 0; y < g_ph; y++)
|
||||
memcpy(bb + (size_t)y * pitch, src + (size_t)y * g_pw, (size_t)g_pw * 2);
|
||||
}
|
||||
blit_rows(g_page_buf[RD_PAGE_SLOT_CUR], 0, 0, g_ph);
|
||||
} else {
|
||||
rd_book_render_text(g_book, page, reader_draw_line_atlas, NULL);
|
||||
}
|
||||
}
|
||||
/* 顶栏:进度% + 章节名(避开系统状态栏) */
|
||||
/* 顶栏:章节名 + 页 n/N + 进度% + (TXT)编码 */
|
||||
int sbh = meow_ui_statusbar_height();
|
||||
int pages = rd_book_pages(g_book);
|
||||
int page = rd_book_current(g_book);
|
||||
char pct[16];
|
||||
int pages = g_book ? rd_book_pages(g_book) : 0;
|
||||
int page = g_book ? rd_book_current(g_book) : 0;
|
||||
char right[40];
|
||||
int p = pages > 0 ? (page * 100 / pages) : 0;
|
||||
snprintf(pct, sizeof pct, "%d%%", p);
|
||||
if (pages > 0) snprintf(right, sizeof right, "%d/%d %d%%", page + 1, pages, p);
|
||||
else snprintf(right, sizeof right, "%d%%", p);
|
||||
meow_ui_fill_rect(0, sbh, g_pw, (g_top - 4 - sbh), g_page_bg);
|
||||
meow_ui_text(16, sbh + 4, g_chapter[0] ? g_chapter : "阅读", 20, th->fg);
|
||||
meow_ui_text_right(g_pw - 16, sbh + 4, pct, 20, th->fg);
|
||||
meow_ui_text_right(g_pw - 16, sbh + 4, right, 20, th->fg);
|
||||
meow_ui_draw_rect(0, g_top - 5, g_pw, 1, th->outline);
|
||||
|
||||
/* R3 刮擦指示条(非目录覆盖时显示;菜单为底部条,与右缘条并存即可) */
|
||||
if (g_book && !g_dir_open) reader_draw_scrub(th);
|
||||
|
||||
if (g_menu_open) {
|
||||
int y = g_ph - RD_MENU_H;
|
||||
meow_ui_fill_rect_alpha(0, y, g_pw, RD_MENU_H, 0x000000, 160);
|
||||
/* 6 按钮:返回 | 目录 | 字− | 字+ | 距− | 距+ */
|
||||
/* 当前编码提示(菜单上方淡条;仅文本类书有意义) */
|
||||
if (g_book && !rd_book_is_image(g_book)) {
|
||||
char en[64]; snprintf(en, sizeof en, "编码:%s", enc_cycle_name(g_enc_idx));
|
||||
meow_ui_fill_rect_alpha(0, y - 26, g_pw, 24, 0x000000, 130);
|
||||
meow_ui_text_right(g_pw - 16, y - 22, en, 16, th->dim);
|
||||
}
|
||||
/* 7 按钮:返回 | 目录 | 字− | 字+ | 距− | 距+ | 编码 */
|
||||
int bw = g_pw / RD_MENU_BTN;
|
||||
const char *labels[RD_MENU_BTN] = { "返回", "目录", "字-", "字+", "距-", "距+" };
|
||||
const char *labels[RD_MENU_BTN] = { "返回", "目录", "字-", "字+", "距-", "距+", "编码" };
|
||||
for (int i = 0; i < RD_MENU_BTN; i++) {
|
||||
int bx = i * bw;
|
||||
meow_ui_fill_rect(bx + 4, y + 12, bw - 8, RD_MENU_H - 24, th->surfaceContainer);
|
||||
@@ -203,6 +305,7 @@ static void reader_redraw(void)
|
||||
static void reader_free_page_bufs(void)
|
||||
{
|
||||
for (int i = 0; i < RD_PAGE_CACHE; i++) { free(g_page_buf[i]); g_page_buf[i] = NULL; }
|
||||
if (g_anim_old) { free(g_anim_old); g_anim_old = NULL; }
|
||||
}
|
||||
|
||||
/* 渲染当前页 + 前后各一页到 3 槽缓存(对齐设计「当前±前±后」;动画档为 无/滑动/淡入 R1 默认无)。 */
|
||||
@@ -225,6 +328,104 @@ static int reader_refill_page(void)
|
||||
return 0; /* 兜底路径:render_text 直绘 */
|
||||
}
|
||||
|
||||
/* ---------- R3 翻页动画(重载页位图,轻量水平滑动,仅内容区分帧) ---------- */
|
||||
static void reader_anim_update(meow_anim *a, float v, void *ctx)
|
||||
{
|
||||
(void)a; (void)ctx;
|
||||
if (!g_book || !g_anim_old || !g_page_buf[RD_PAGE_SLOT_CUR]) return;
|
||||
int off = (int)(v * g_pw);
|
||||
int y0 = rect_y0(), y1 = rect_y1();
|
||||
meow_ui_fill_rect(0, y0, g_pw, y1 - y0, g_page_bg); /* 内容区清底色 */
|
||||
int old_x, new_x;
|
||||
if (g_anim_dir == 1) { old_x = -off; new_x = g_pw - off; } /* 下一页:旧左移/新右入 */
|
||||
else { old_x = off; new_x = off - g_pw; } /* 上一页:旧右移/新左入 */
|
||||
blit_rows(g_anim_old, old_x, y0, y1);
|
||||
blit_rows(g_page_buf[RD_PAGE_SLOT_CUR], new_x, y0, y1);
|
||||
meow_ui_flush_region(0, y0, g_pw, y1 - y0);
|
||||
}
|
||||
static void reader_anim_done(meow_anim *a, int canceled, void *ctx)
|
||||
{
|
||||
(void)a; (void)ctx;
|
||||
g_anim = NULL;
|
||||
if (!canceled) { reader_redraw(); reader_reflow_persist(); } /* 顶栏 n/N+% 更新 + 进度保存 */
|
||||
}
|
||||
static void reader_turn_animated(int dir)
|
||||
{
|
||||
if (!g_book) return;
|
||||
if (g_anim) { meow_anim_cancel(g_anim); g_anim = NULL; } /* 取消进行中动画,重开 */
|
||||
/* 无页位图(atlas 兜底):瞬切 */
|
||||
if (!(g_has_font || rd_book_is_image(g_book)) || !g_page_buf[RD_PAGE_SLOT_CUR]) {
|
||||
rd_book_turn(g_book, dir);
|
||||
reader_refill_page(); reader_redraw(); reader_reflow_persist();
|
||||
return;
|
||||
}
|
||||
if (!g_anim_old) g_anim_old = (uint16_t *)malloc((size_t)g_pw * g_ph * 2);
|
||||
if (!g_anim_old) { rd_book_turn(g_book, dir); reader_refill_page(); reader_redraw(); return; }
|
||||
memcpy(g_anim_old, g_page_buf[RD_PAGE_SLOT_CUR], (size_t)g_pw * g_ph * 2);
|
||||
rd_book_turn(g_book, dir);
|
||||
reader_refill_page();
|
||||
g_anim_dir = dir;
|
||||
meow_anim_desc d = { 0.0f, 1.0f, 140, MEOW_EASE_OUT, reader_anim_update, reader_anim_done, NULL };
|
||||
g_anim = meow_anim_start(&d);
|
||||
if (!g_anim) reader_redraw(); /* 池满等:瞬时落定 */
|
||||
}
|
||||
|
||||
/* ---------- R3 段刮擦(右缘拖动快速定位 + 预览) ---------- */
|
||||
static int scrub_page_for_y(int y)
|
||||
{
|
||||
int y0 = rect_y0(), y1 = rect_y1(), h = y1 - y0;
|
||||
int np = g_book ? rd_book_pages(g_book) : 0;
|
||||
if (h <= 0 || np <= 0) return g_book ? rd_book_current(g_book) : 0;
|
||||
int cy = y - y0; if (cy < 0) cy = 0; if (cy > h) cy = h;
|
||||
return (int)((long long)cy * (np - 1) / h);
|
||||
}
|
||||
static void reader_scrub_jump(int page)
|
||||
{
|
||||
if (!g_book) return;
|
||||
int np = rd_book_pages(g_book);
|
||||
if (np <= 0) return;
|
||||
rd_book_set_page(g_book, page);
|
||||
reader_refill_page();
|
||||
reader_redraw(); /* 整页落定:正文 + 顶栏 + 刮擦条 */
|
||||
reader_reflow_persist();
|
||||
}
|
||||
/* 拖动中局部重绘(不动正文页,仅顶栏 n/N + 右缘条/预览)。内容页保持(预览语义)。 */
|
||||
static void reader_scrub_preview(int page)
|
||||
{
|
||||
g_scrub_page = page;
|
||||
if (!g_book) return;
|
||||
const meow_theme *th = meow_theme_get();
|
||||
int sbh = meow_ui_statusbar_height();
|
||||
int pages = rd_book_pages(g_book);
|
||||
int y0 = rect_y0(), y1 = rect_y1();
|
||||
char right[40];
|
||||
int p = pages > 0 ? (g_scrub_page * 100 / pages) : 0;
|
||||
if (pages > 0) snprintf(right, sizeof right, "%d/%d %d%%", g_scrub_page + 1, pages, p);
|
||||
else snprintf(right, sizeof right, "%d%%", p);
|
||||
/* 顶栏重画 */
|
||||
meow_ui_fill_rect(0, sbh, g_pw, (g_top - 4 - sbh), g_page_bg);
|
||||
meow_ui_text(16, sbh + 4, g_chapter[0] ? g_chapter : "阅读", 20, th->fg);
|
||||
meow_ui_text_right(g_pw - 16, sbh + 4, right, 20, th->fg);
|
||||
meow_ui_draw_rect(0, g_top - 5, g_pw, 1, th->outline);
|
||||
/* 右缘条区清残留(恢复页面内容)再画条 + 预览框;无页位图(字库兜底)则跳过恢复 */
|
||||
if (g_page_buf[RD_PAGE_SLOT_CUR]) blit_sub(g_page_buf[RD_PAGE_SLOT_CUR], g_pw - 120, y0, 120, y1 - y0);
|
||||
reader_draw_scrub(th);
|
||||
meow_ui_flush_region(0, sbh, g_pw, g_top - sbh);
|
||||
meow_ui_flush_region(g_pw - 120, y0, 120, y1 - y0);
|
||||
}
|
||||
static void reader_scrub_begin(int x, int y)
|
||||
{
|
||||
(void)x;
|
||||
if (!g_book || g_menu_open || g_dir_open) return;
|
||||
if (g_pw - x > RD_SCRUB_W) return;
|
||||
if (y < rect_y0() || y >= rect_y1()) return;
|
||||
int np = rd_book_pages(g_book);
|
||||
if (np <= 1) return;
|
||||
g_scrub = 1;
|
||||
if (g_anim) { meow_anim_cancel(g_anim); g_anim = NULL; }
|
||||
reader_scrub_preview(scrub_page_for_y(y));
|
||||
}
|
||||
|
||||
/* ---------- 打开 ---------- */
|
||||
void reader_open(const char *path)
|
||||
{
|
||||
@@ -263,8 +464,27 @@ void reader_open(const char *path)
|
||||
for (int i = 0; i < RD_PAGE_CACHE; i++)
|
||||
g_page_buf[i] = (uint16_t *)malloc((size_t)g_pw * (size_t)g_ph * 2);
|
||||
if (!g_page_buf[RD_PAGE_SLOT_CUR]) { reader_free_page_bufs(); g_has_font = 0; }
|
||||
else g_anim_old = (uint16_t *)malloc((size_t)g_pw * (size_t)g_ph * 2); /* 动画快照位图 */
|
||||
}
|
||||
|
||||
/* 复位动画/刮擦状态(跨书) */
|
||||
if (g_anim) { meow_anim_cancel(g_anim); g_anim = NULL; }
|
||||
g_scrub = 0; g_menu_open = 0; g_dir_open = 0;
|
||||
|
||||
/* 编码:初始 = 打开探测结果;进度里的显式编码(Big5 用户选定)优先重开 */
|
||||
if (g_book && !rd_book_is_image(g_book)) {
|
||||
int idx = enc_to_cycle_idx(rd_book_enc_get(g_book));
|
||||
g_enc_idx = idx >= 0 ? idx : 0;
|
||||
if (hasprog && prog.enc >= 0) {
|
||||
int pi = enc_to_cycle_idx((rd_enc_t)prog.enc);
|
||||
if (pi >= 0) {
|
||||
if (g_enc_cycle[pi] != rd_book_enc_get(g_book)) {
|
||||
if (rd_book_set_enc(g_book, g_enc_cycle[pi]) == 0) { g_enc_idx = pi; chapter_name(); }
|
||||
} else g_enc_idx = pi;
|
||||
}
|
||||
}
|
||||
} else g_enc_idx = 0;
|
||||
|
||||
/* 续读:进度锚(段,字符偏移)→ 跳页 */
|
||||
if (hasprog && g_book) {
|
||||
rd_book_jump_to_anchor(g_book, prog.seg, prog.ch, g_fs, g_ls);
|
||||
@@ -272,7 +492,6 @@ void reader_open(const char *path)
|
||||
|
||||
reader_refill_page();
|
||||
|
||||
g_menu_open = 0; g_dir_open = 0;
|
||||
if (g_reader_active) reader_redraw();
|
||||
}
|
||||
|
||||
@@ -294,10 +513,11 @@ static void reader_on_leave(meow_view *v, void *ctx)
|
||||
static void reader_on_destroy(meow_view *v, void *ctx)
|
||||
{
|
||||
(void)v; (void)ctx;
|
||||
if (g_anim) { meow_anim_cancel(g_anim); g_anim = NULL; }
|
||||
if (g_book) rd_book_close(g_book);
|
||||
g_book = NULL;
|
||||
reader_free_page_bufs();
|
||||
g_menu_open = 0; g_dir_open = 0; g_reader_active = 0;
|
||||
g_menu_open = 0; g_dir_open = 0; g_scrub = 0; g_reader_active = 0;
|
||||
}
|
||||
|
||||
meow_view *reader_view_create(void)
|
||||
@@ -314,7 +534,13 @@ int reader_is_active(void) { return g_reader_active; }
|
||||
|
||||
void reader_on_tap(int x, int y)
|
||||
{
|
||||
(void)x;
|
||||
if (!g_book) { return; }
|
||||
if (g_scrub) { /* 刮擦抬手 → 跳到目标页收尾 */
|
||||
g_scrub = 0;
|
||||
reader_scrub_jump(g_scrub_page);
|
||||
return;
|
||||
}
|
||||
if (g_dir_open) {
|
||||
/* 目录覆盖层:点条目跳转,点空白关闭 */
|
||||
int n = rd_book_toc_n(g_book);
|
||||
@@ -359,6 +585,18 @@ void reader_on_tap(int x, int y)
|
||||
case 3: if (g_fs < 40) { g_fs += 2; reader_reflow(); } break;
|
||||
case 4: if (g_ls > 100) { g_ls -= 5; reader_reflow(); } break;
|
||||
case 5: if (g_ls < 200) { g_ls += 5; reader_reflow(); } break;
|
||||
case 6: /* 编码切换(TXT/Big5 繁体书) */
|
||||
if (g_book && !rd_book_is_image(g_book)) {
|
||||
int ni = (g_enc_idx + 1) % RD_ENC_CYCLE_N;
|
||||
if (rd_book_set_enc(g_book, g_enc_cycle[ni]) == 0) {
|
||||
g_enc_idx = ni;
|
||||
chapter_name();
|
||||
reader_refill_page();
|
||||
reader_redraw();
|
||||
reader_reflow_persist();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (y >= y0) return;
|
||||
}
|
||||
@@ -367,20 +605,27 @@ void reader_on_tap(int x, int y)
|
||||
return;
|
||||
}
|
||||
/* 三栏:左 1/3 上一页、右 1/3 下一页、中央唤菜单 */
|
||||
if (x < g_pw / 3) { rd_book_turn(g_book, -1); reader_refill_page(); reader_redraw(); }
|
||||
else if (x > g_pw * 2 / 3) { rd_book_turn(g_book, 1); reader_refill_page(); reader_redraw(); }
|
||||
else { g_menu_open = 1; reader_redraw(); }
|
||||
if (x < g_pw / 3) { reader_turn_animated(-1); }
|
||||
else if (x > g_pw * 2 / 3) { reader_turn_animated(1); }
|
||||
else { if (g_anim) { meow_anim_cancel(g_anim); g_anim = NULL; } g_menu_open = 1; reader_redraw(); }
|
||||
}
|
||||
|
||||
void reader_on_swipe(int dir, int dx, int dy)
|
||||
{
|
||||
(void)dx; (void)dy;
|
||||
if (!g_book) return;
|
||||
if (g_scrub) g_scrub = 0; /* 刮擦中被滑走 → 退出刮擦 */
|
||||
if (g_menu_open) { g_menu_open = 0; reader_redraw(); return; }
|
||||
if (dir == MEOW_SWIPE_LEFT) { rd_book_turn(g_book, 1); }
|
||||
else if (dir == MEOW_SWIPE_RIGHT) { rd_book_turn(g_book, -1); }
|
||||
else return;
|
||||
reader_refill_page(); reader_redraw();
|
||||
if (dir == MEOW_SWIPE_LEFT) reader_turn_animated(1);
|
||||
else if (dir == MEOW_SWIPE_RIGHT) reader_turn_animated(-1);
|
||||
}
|
||||
|
||||
/* ---- R3 段刮擦触控(app.c on_touch_down/on_touch_move 路由) ---- */
|
||||
void reader_on_touch_down(int x, int y) { reader_scrub_begin(x, y); }
|
||||
void reader_on_touch_move(int x, int y)
|
||||
{
|
||||
(void)x;
|
||||
if (g_scrub && g_book) reader_scrub_preview(scrub_page_for_y(y));
|
||||
}
|
||||
|
||||
void reader_on_tick(uint64_t now)
|
||||
|
||||
@@ -25,7 +25,10 @@ mkdir -p "$OBJ"
|
||||
|
||||
# ---------- 1) vendor 拉取/对齐 ----------
|
||||
FT_VER="2.14.3"; MINIZ_URL="https://codeload.github.com/richgel999/miniz/tar.gz/refs/heads/master"
|
||||
LM_URL="https://codeload.github.com/bfabiszewski/libmobi/tar.gz/refs/heads/master"
|
||||
# libmobi 版本锁定:见 NOTICE「Locked version (commit)」。LGPL-3.0 §4(d) 要求「已分发二进制
|
||||
# 对应的 libmobi 源码」与公开源码一致可复现,故不用 refs/heads/master(移动分支),改锁到精确
|
||||
# commit SHA(2024-10-29 的 9062742...,与上级代理 agent-332 复验/NOTICE 声明一致,已验证可拉取)。
|
||||
LM_URL="https://codeload.github.com/bfabiszewski/libmobi/tar.gz/906274205c11944b628da1c553b255acb1af7c55"
|
||||
mkdir -p "$VENDOR"
|
||||
fetch_freetype() {
|
||||
if [ -n "$FREETYPE_SRC" ] && [ -f "$FREETYPE_SRC/CMakeLists.txt" ]; then cp -r "$FREETYPE_SRC" vendor/freetype-src;
|
||||
@@ -45,6 +48,8 @@ fetch_miniz() {
|
||||
[ -f "$VENDOR/miniz/miniz.c" ] || { echo "miniz 不可用"; exit 1; }
|
||||
}
|
||||
fetch_libmobi() {
|
||||
# 若 vendor/libmobi 来自旧版(LM_URL 改 pin 前抓的 master),请先删 vendor/libmobi 再重跑,
|
||||
# 以确保取到下方锁定的 commit。此处仅在其缺失时拉取。
|
||||
if [ ! -f "$VENDOR/libmobi/src/mobi.h" ]; then
|
||||
( cd /tmp && curl -fsSL -o lm.tgz "$LM_URL" && mkdir -p lm_m && tar xzf lm.tgz -C lm_m --strip-components=1 \
|
||||
&& mkdir -p "$VENDOR/libmobi" && cp -r lm_m/src "$VENDOR/libmobi/src" && cp lm_m/COPYING "$VENDOR/libmobi/COPYING" )
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,7 @@
|
||||
/* rdenc.c — 文本编码检测 + GB18030→UTF-8 + UTF-8 工具(实现见 rdenc.h)。 */
|
||||
/* rdenc.c — 文本编码检测 + GB18030/Big5→UTF-8 + UTF-8 工具(实现见 rdenc.h)。 */
|
||||
#include "rdenc.h"
|
||||
#include "gb18030_table.h"
|
||||
#include "big5_table.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -39,6 +40,14 @@ static inline int gb_trail_ok(unsigned b)
|
||||
{
|
||||
return (b >= 0x40 && b <= 0x7E) || (b >= 0x80 && b <= 0xFE);
|
||||
}
|
||||
static inline int gb_trail_q(unsigned b)
|
||||
{
|
||||
return gb_trail_ok(b);
|
||||
}
|
||||
static inline int big5_trail_q(unsigned b)
|
||||
{
|
||||
return (b >= 0x40 && b <= 0x7E) || (b >= 0xA1 && b <= 0xFE);
|
||||
}
|
||||
static inline int gb_col(unsigned b)
|
||||
{
|
||||
/* 列 = b - 0x40 - (b >= 0x80);b 已在合法范围(不含 0x7F) */
|
||||
@@ -128,16 +137,45 @@ int rd_gb18030_to_utf8(const uint8_t *in, size_t inlen, uint8_t *out, size_t out
|
||||
return RD_ENC_OK;
|
||||
}
|
||||
|
||||
/* ================= 编码检测 ================= */
|
||||
static inline int gb_trail_q(unsigned b)
|
||||
/* ================= Big5 双字节 → UTF-8 ================= */
|
||||
int rd_big5_to_utf8(const uint8_t *in, size_t inlen, uint8_t *out, size_t outcap, size_t *outlen)
|
||||
{
|
||||
return (b >= 0x40 && b <= 0x7E) || (b >= 0x80 && b <= 0xFE);
|
||||
}
|
||||
static inline int big5_trail_q(unsigned b)
|
||||
{
|
||||
return (b >= 0x40 && b <= 0x7E) || (b >= 0xA1 && b <= 0xFE);
|
||||
if (!in || !outlen) return RD_ENC_ERR_INVAL;
|
||||
if (!out && outcap) return RD_ENC_ERR_INVAL;
|
||||
size_t o = 0;
|
||||
size_t i = 0;
|
||||
while (i < inlen) {
|
||||
uint8_t b = in[i];
|
||||
if (b < 0x80) {
|
||||
if (o + 1 > outcap) { *outlen = o + 1; return RD_ENC_ERR_BUFSZ; }
|
||||
out[o++] = b; i++; continue;
|
||||
}
|
||||
if (b >= 0x81 && b <= 0xFE && i + 1 < inlen) {
|
||||
uint8_t t = in[i + 1];
|
||||
if (big5_trail_q(t)) {
|
||||
uint32_t cp = big5_2byte[b - RD_B5_LEAD0][gb_col(t)];
|
||||
uint8_t tmp[4];
|
||||
int n;
|
||||
if (cp == 0) { cp = 0xFFFD; }
|
||||
n = enc_utf8(cp, tmp);
|
||||
if (o + (size_t)n > outcap) { *outlen = o + (size_t)n; return RD_ENC_ERR_BUFSZ; }
|
||||
memcpy(out + o, tmp, (size_t)n); o += (size_t)n;
|
||||
i += 2; continue;
|
||||
}
|
||||
}
|
||||
/* 非法首字节 / 尾字节不成对 → U+FFFD */
|
||||
{
|
||||
uint8_t tmp[4]; int n = enc_utf8(0xFFFD, tmp);
|
||||
if (o + (size_t)n > outcap) { *outlen = o + (size_t)n; return RD_ENC_ERR_BUFSZ; }
|
||||
memcpy(out + o, tmp, (size_t)n); o += (size_t)n;
|
||||
i++; continue;
|
||||
}
|
||||
}
|
||||
*outlen = o;
|
||||
return RD_ENC_OK;
|
||||
}
|
||||
|
||||
/* ================= 编码检测 ================= */
|
||||
rd_enc_t rd_enc_detect(const uint8_t *buf, size_t len, rd_enc_stats *st)
|
||||
{
|
||||
if (st) { st->gb_pairs = st->big5_pairs = st->stray = 0; }
|
||||
@@ -156,33 +194,27 @@ rd_enc_t rd_enc_detect(const uint8_t *buf, size_t len, rd_enc_stats *st)
|
||||
return ascii ? RD_ENC_ASCII : RD_ENC_UTF8;
|
||||
}
|
||||
|
||||
/* 3) 双字节区段统计(GB18030 兼容 GBK;Big5 尾字节不同)。
|
||||
* GB 有效 = 码表 gb_2byte 查到非 0(GBK/GB18030 已映射码位);
|
||||
* Big5 专属 = 结构上 Big5 合法、但对 GB 码表无效(Big5 独有码位)。
|
||||
* 二者比较更可靠(结构上每个 GBK 双字节对也是合法 Big5 结构,无法区分)。 */
|
||||
long gb = 0, big5 = 0, stray = 0;
|
||||
/* 3) 双字节区段统计(GB18030 兼容 GBK)。
|
||||
* GB 有效 = 码表 gb_2byte 查到非 0(GBK/GB18030 已映射码位);stray = 无法成对字节。
|
||||
* R3 注:Big5 双字节区间是 GB18030 双字节区间的**严格子集**(Big5 尾字节
|
||||
* 0x40..0x7E|0xA1..0xFE ⊂ GB 尾字节 0x40..0x7E|0x80..0xFE;常见 GBK 简体字尾字节大量
|
||||
* 落在 0xA1..0xFE 与 Big5 重叠),故字节结构**无法可靠区分 Big5 与 GB18030**——盲判必然
|
||||
* 误伤(误把 GBK 判成 Big5 或反之)。自动检测统一兜底 GB18030(简体最常见、误伤代价
|
||||
* 最小);Big5 书由 UI 提供「编码切换」显式选中(对应正确解码走 rd_big5_to_utf8)。 */
|
||||
long gb = 0, stray = 0;
|
||||
for (size_t i = 0; i < len; ) {
|
||||
uint8_t b = buf[i];
|
||||
if (b < 0x80) { i++; continue; }
|
||||
if (b >= 0x81 && b <= 0xFE && i + 1 < len) {
|
||||
uint8_t t = buf[i + 1];
|
||||
int gb_ok = gb_trail_q(t) &&
|
||||
gb_2byte[b - RD_GB_LEAD0][gb_col(t)] != 0;
|
||||
int b5_ok = big5_trail_q(t);
|
||||
if (gb_ok) gb++;
|
||||
if (b5_ok && !gb_ok) big5++; /* Big5 专属:GB 码表无效 */
|
||||
if (gb_trail_q(t) && gb_2byte[b - RD_GB_LEAD0][gb_col(t)] != 0) gb++;
|
||||
i += 2; continue;
|
||||
}
|
||||
stray++; i++;
|
||||
}
|
||||
if (st) { st->gb_pairs = gb; st->big5_pairs = big5; st->stray = stray; }
|
||||
if (st) { st->gb_pairs = gb; st->big5_pairs = 0; st->stray = stray; }
|
||||
|
||||
/* 阈值(经验值):双字节对太少 → 乱码/不确定 → 兜底 GB18030(最常见中文编码)。
|
||||
* 注(READER_ENGINE_NOTES §3.5 风险):Big5 与 GB18030 双字节区大量重叠,码表有效性
|
||||
* 无法可靠区分(简体 GB2312 文本 trail 0xA1-0xFE 恰是 Big5 trail 区)。R1 双字节一律
|
||||
* 按 GB18030 兜底;Big5 经此检测也按 GB18030 试(v1 不转),真实区分需用户手动切编码
|
||||
* (列 R2)。 */
|
||||
if (gb + big5 < (long)(len / 5)) return RD_ENC_GB18030;
|
||||
if (gb < (long)(len / 5)) return RD_ENC_GB18030; /* 双字节对太少 → 不确定 → GB18030 */
|
||||
return RD_ENC_GB18030;
|
||||
}
|
||||
|
||||
@@ -231,7 +263,8 @@ int rd_to_utf8(rd_enc_t enc, const uint8_t *in, size_t inlen, uint8_t *out, size
|
||||
memcpy(out, in + off, inlen - off); *outlen = inlen - off;
|
||||
return RD_ENC_OK;
|
||||
}
|
||||
/* GB18030 / Big5(v1 按 GB18030 试) */
|
||||
if (enc == RD_ENC_BIG5) return rd_big5_to_utf8(in, inlen, out, outcap, outlen);
|
||||
/* GB18030 兜底 */
|
||||
return rd_gb18030_to_utf8(in, inlen, out, outcap, outlen);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
/* rdenc.h — 阅读器文本编码检测 + GB18030→UTF-8 解码 + UTF-8 工具(纯 C,宿主可测)。
|
||||
/* rdenc.h — 阅读器文本编码检测 + GB18030/Big5→UTF-8 解码 + UTF-8 工具(纯 C,宿主可测)。
|
||||
*
|
||||
* 对齐 devdocs/plan/READER_ENGINE_NOTES.md §3(zLibrary 轻量化:BOM + 严格 UTF-8 + 双字节区段统计,
|
||||
* 不抄 N-gram 马尔可夫):
|
||||
* - BOM 优先:FE FF=UTF-16BE、FF FE=UTF-16LE、EF BB BF=UTF-8;
|
||||
* - 无 BOM → 严格 UTF-8 校验(合法即 UTF-8;ASCII 属 UTF-8 子集);
|
||||
* - 非 UTF-8 → GB18030(GBK 超集) / Big5 双字节区段统计(阈值经验值,见 READER_ENGINE_NOTES §3.3);
|
||||
* - **R1 只做 GB18030→UTF-8 双字节映射**(uint16[126][190] 码表),4 字节扩展段 → U+FFFD;
|
||||
* Big5 检测出来也按 GB18030 试(v1 不转 Big5,正文会乱但可读,注明)。
|
||||
* - 非 UTF-8 → GB18030(GBK 超集) 双字节映射(uint16[126][190] 码表);4 字节扩展段 → U+FFFD。
|
||||
*
|
||||
* 无 SDK 依赖;`#include "gb18030_table.h"`(生成物,见 tools/gen_gb18030_table.py)。
|
||||
* **Big5(R3)**:Big5 双字节区间是 GB18030 双字节区间的**严格子集**(Big5 尾字节
|
||||
* 0x40..0x7E|0xA1..0xFE ⊂ GB 尾字节 0x40..0x7E|0x80..0xFE,且常用 GBK 简体字尾字节
|
||||
* 大量落在 0xA1..0xFE 与 Big5 重叠),故**字节结构无法自动区分 Big5 与 GB18030**——
|
||||
* 盲判必然误伤。R3 方案:解码器支持 RD_ENC_BIG5(big5_2byte 码表),由 UI 提供编码
|
||||
* 切换(Auto→GB18030/Big5/UTF-8/UTF-16LE/BE),用户对繁体乱码书手动选 Big5 即正确
|
||||
* 渲染;自动检测默认 GB18030(简体最常见,误伤代价最小)。详见 READER_ENGINE_NOTES §3.5。
|
||||
*
|
||||
* 无 SDK 依赖;`#include "gb18030_table.h"` 与 `"big5_table.h"`(生成物,见 tools/)。
|
||||
*/
|
||||
#ifndef RDENC_H
|
||||
#define RDENC_H
|
||||
@@ -26,7 +31,7 @@ typedef enum {
|
||||
RD_ENC_UTF16LE,
|
||||
RD_ENC_UTF16BE,
|
||||
RD_ENC_GB18030, /* GBK 超集(解码器按 2 字节码表) */
|
||||
RD_ENC_BIG5, /* v1 检测但按 GB18030 解码 */
|
||||
RD_ENC_BIG5, /* Big5 → UTF-8(R3:big5_2byte 码表;需显式选中,不自动检测) */
|
||||
} rd_enc_t;
|
||||
|
||||
/* 检测统计(诊断 + 阈值用;值可为 0)。 */
|
||||
@@ -49,6 +54,9 @@ int rd_utf8_validate(const uint8_t *buf, size_t len);
|
||||
#define RD_ENC_ERR_BUFSZ -2 /* out 不足;*outlen 已填所需 */
|
||||
int rd_gb18030_to_utf8(const uint8_t *in, size_t inlen, uint8_t *out, size_t outcap, size_t *outlen);
|
||||
|
||||
/* Big5 双字节 → UTF-8(与 GB 版同构;Big5 非法双字节 → U+FFFD)。成功 0;输出不足 RD_ENC_ERR_BUFSZ。 */
|
||||
int rd_big5_to_utf8(const uint8_t *in, size_t inlen, uint8_t *out, size_t outcap, size_t *outlen);
|
||||
|
||||
/* UTF-8 → 码点数组(布局用;malloc 分配 *cps,调用方 free)。成功 0。 *n = 码点数。
|
||||
* 非法序列按一个 U+FFFD 收(宽松);len 为输入字节长。 */
|
||||
#define RD_UTF8_ERR_INVAL -1
|
||||
@@ -59,7 +67,7 @@ int rd_utf8_to_cp(const uint8_t *utf8, size_t len, uint32_t **cps, size_t *n);
|
||||
int rd_cp_to_utf8(uint32_t cp, uint8_t out[4]);
|
||||
|
||||
/* 通用:任意检测编码 → UTF-8(rdenc 已知的各编码)。UTF-16LE/BE 走简易 BOM 对齐 + 码点转换;
|
||||
* Big5 v1 按 GB18030 双字节表转(会乱但可读,注明)。返回码同 rd_gb18030_to_utf8。 */
|
||||
* Big5 走 rd_big5_to_utf8。返回码同 rd_gb18030_to_utf8。 */
|
||||
int rd_to_utf8(rd_enc_t enc, const uint8_t *in, size_t inlen, uint8_t *out, size_t outcap, size_t *outlen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -40,6 +40,8 @@ static int txt_open(rd_src *s)
|
||||
if (!m) return -6;
|
||||
s->impl = m;
|
||||
if (rdtxt_probe(s->path, &m->info) != 0) { txt_free(s); return -1; }
|
||||
/* R3:显式编码覆盖(Big5 书)——探测只取 file_size/path,编码改用覆盖值 */
|
||||
if (s->enc_override_set) m->info.enc = s->enc_override;
|
||||
/* 建段表:一次扫描(off,len) */
|
||||
rdtxt_reader *r = NULL;
|
||||
if (rdtxt_reader_open(s->path, &m->info, &r) != 0) { txt_free(s); return -2; }
|
||||
@@ -105,7 +107,7 @@ static int is_ext(const char *path, const char *ext)
|
||||
return strcasecmp(path + pl - el, ext) == 0; /* ext 含点(如 ".cbz") */
|
||||
}
|
||||
|
||||
int rd_src_open(rd_src **out, const char *path)
|
||||
static int src_open_common(rd_src **out, const char *path, const rd_enc_t *enc)
|
||||
{
|
||||
if (!out || !path) return -1;
|
||||
/* 读前 64 字节做 magic 探测 */
|
||||
@@ -127,6 +129,7 @@ int rd_src_open(rd_src **out, const char *path)
|
||||
if (strlen(path) >= sizeof s->path) { free(s); return -2; }
|
||||
strcpy(s->path, path);
|
||||
s->fmt = pick->fmt;
|
||||
if (enc) { s->enc_override = *enc; s->enc_override_set = 1; }
|
||||
int rc = pick->open(s);
|
||||
if (rc != 0) { s->vt = NULL; s->impl = NULL; rd_src_free(s); return rc; }
|
||||
s->vt = pick->vt;
|
||||
@@ -134,6 +137,16 @@ int rd_src_open(rd_src **out, const char *path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rd_src_open(rd_src **out, const char *path)
|
||||
{
|
||||
return src_open_common(out, path, NULL);
|
||||
}
|
||||
|
||||
int rd_src_open_with_enc(rd_src **out, const char *path, const rd_enc_t *enc)
|
||||
{
|
||||
return src_open_common(out, path, enc);
|
||||
}
|
||||
|
||||
void rd_src_free(rd_src *s)
|
||||
{
|
||||
if (!s) return;
|
||||
@@ -141,6 +154,14 @@ void rd_src_free(rd_src *s)
|
||||
free(s);
|
||||
}
|
||||
rd_fmt_t rd_src_fmt(const rd_src *s) { return s ? s->fmt : RD_FMT_TXT; }
|
||||
int rd_src_txt_enc(const rd_src *s, rd_enc_t *out)
|
||||
{
|
||||
if (!s || s->fmt != RD_FMT_TXT || !out) return -1;
|
||||
txt_impl *m = (txt_impl *)s->impl;
|
||||
if (!m) return -1;
|
||||
*out = m->info.enc;
|
||||
return 0;
|
||||
}
|
||||
const char *rd_src_title(const rd_src *s) { return (s && s->title[0]) ? s->title : (s ? s->path : ""); }
|
||||
const char *rd_src_author(const rd_src *s) { return (s && s->author[0]) ? s->author : "佚名"; }
|
||||
const char *rd_src_cover(const rd_src *s) { return (s && s->cover[0]) ? s->cover : NULL; }
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#ifndef RDSRC_H
|
||||
#define RDSRC_H
|
||||
|
||||
#include "rdenc.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -38,9 +39,15 @@ typedef struct rd_toc_entry {
|
||||
|
||||
/* 打开(按扩展名/magic 探测格式)。0=成功;负值=不支持/打不开。 */
|
||||
int rd_src_open(rd_src **out, const char *path);
|
||||
|
||||
/* 同 rd_src_open,但用 *enc 显式覆盖文本编码(TXT;ENC 为 NULL=自动探测)。
|
||||
* 非 TXT 格式忽略覆盖。R3 编码切换用(Big5 书显式选中)。 */
|
||||
int rd_src_open_with_enc(rd_src **out, const char *path, const rd_enc_t *enc);
|
||||
void rd_src_free(rd_src *s);
|
||||
|
||||
rd_fmt_t rd_src_fmt(const rd_src *s);
|
||||
/* TXT 有效文本编码(含覆盖);*out 填 rd_enc_t。非 TXT 返回 -1(XML/结构化固定 UTF-8 内部码)。 */
|
||||
int rd_src_txt_enc(const rd_src *s, rd_enc_t *out);
|
||||
const char *rd_src_title(const rd_src *s);
|
||||
const char *rd_src_author(const rd_src *s);
|
||||
const char *rd_src_cover(const rd_src *s); /* 封面 ref;无则 NULL */
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#define RDSRC_INT_H
|
||||
|
||||
#include "rdsrc.h"
|
||||
#include "rdenc.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -29,6 +30,10 @@ struct rd_src {
|
||||
char author[160];
|
||||
char cover[320];
|
||||
void *impl;
|
||||
/* R3:文本编码显式覆盖(rd_src_open_with_enc)。enc_override_set=1 时 TXT loader 用该编码;
|
||||
* 非 TXT 格式(XML/结构化)固定 UTF-8 内部编码,忽略覆盖。 */
|
||||
rd_enc_t enc_override;
|
||||
int enc_override_set;
|
||||
};
|
||||
|
||||
/* 注册一个格式(供 rdsrc.c 调度)。 */
|
||||
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
# pack_reader_mpk.sh — 把 os.meow.reader 打成 .mpk(tar.gz),并把 LGPL 合规材料并入包内。
|
||||
# .mpk = app.json + reader 二进制 + icon.png + resources/licenses/{NOTICE,GPL-3.0.txt,LGPL-3.0.txt}
|
||||
# (不含 data/cache;符合 APPS.md §3 与 mips-repo/mpk/README.md 的 .mpk 规范)
|
||||
#
|
||||
# 合规目的:让「接收者随包拿到」NOTICE + GPL-3.0 全文 + LGPL-3.0 全文,
|
||||
# 满足 LGPL-3.0 §4(a)(显著通知)与 §4(b)(随 Combined Work 附 GPL + LGPL 两份文本)。
|
||||
#
|
||||
# 用法:
|
||||
# ./build_reader.sh # 先编出 reader 二进制(本脚本不重编)
|
||||
# ./pack_reader_mpk.sh # → ./os.meow.reader.mpk(未签名)
|
||||
# 签名(可选,正式分发:install 期验签,os.meow.* 无签拒装):
|
||||
# ../meow_sign/meow_sign sign os.meow.reader.mpk "$HOME/Project/R3ProII/.keys/signing.key"
|
||||
#
|
||||
# 只做打包/sign 提示,不改阅读器功能逻辑。
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
PKG="os.meow.reader"
|
||||
MPK="$PKG.mpk"
|
||||
|
||||
[ -f "reader" ] || { echo "找不到 ./reader —— 请先运行 ./build_reader.sh 编出二进制"; exit 1; }
|
||||
[ -f "app.json" ] || { echo "找不到 ./app.json"; exit 1; }
|
||||
[ -f "resources/licenses/NOTICE" ] || { echo "找不到 resources/licenses/NOTICE(合规材料缺失)"; exit 1; }
|
||||
|
||||
STAGE="$(mktemp -d)"
|
||||
trap 'rm -rf "$STAGE"' EXIT
|
||||
|
||||
# 组装 MeowAPPs/<pkg>/ 布局(.mpk 内相对路径,顶层不含包名目录)
|
||||
cp app.json "$STAGE/"
|
||||
cp icon.png "$STAGE/" 2>/dev/null || true
|
||||
cp reader "$STAGE/"
|
||||
mkdir -p "$STAGE/resources/licenses"
|
||||
cp resources/licenses/NOTICE resources/licenses/GPL-3.0.txt resources/licenses/LGPL-3.0.txt \
|
||||
"$STAGE/resources/licenses/"
|
||||
|
||||
# busybox tar + gzip(与 launcher/nyai 同管道语义);-cz 直接出 .
|
||||
tar czf "$MPK" -C "$STAGE" app.json reader icon.png resources
|
||||
|
||||
echo "== packed $MPK =="
|
||||
tar tzvf "$MPK"
|
||||
echo "md5: $(md5sum "$MPK" | cut -d' ' -f1)"
|
||||
echo
|
||||
echo "含合规材料:resources/licenses/NOTICE + GPL-3.0.txt + LGPL-3.0.txt"
|
||||
echo "未签名。正式分发前 run:"
|
||||
echo " ../meow_sign/meow_sign sign $MPK \"\$HOME/Project/R3ProII/.keys/signing.key\""
|
||||
@@ -24,6 +24,8 @@ int reader_is_active(void);
|
||||
void reader_on_tap(int x, int y);
|
||||
void reader_on_swipe(int dir, int dx, int dy);
|
||||
void reader_on_tick(uint64_t now);
|
||||
void reader_on_touch_down(int x, int y); /* R3 段刮擦:右缘拖动快速定位 */
|
||||
void reader_on_touch_move(int x, int y);
|
||||
|
||||
/* 打开一本书(书架调;成功进入阅读页)。path=TXT 完整路径。 */
|
||||
void reader_open(const char *path);
|
||||
|
||||
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
@@ -0,0 +1,234 @@
|
||||
os.meow.reader (patch_v2/reader_app) — Third-Party NOTICES
|
||||
==========================================================
|
||||
|
||||
This application (os.meow.reader) statically links and/or bundles the
|
||||
following third-party components. Their copyrights and licenses are
|
||||
reproduced below. The build script (build_reader.sh) fetches the exact
|
||||
pinned versions, so the binaries can be rebuilt / re-linked from source.
|
||||
|
||||
License ownership
|
||||
-----------------
|
||||
The reader application's own source code is licensed under the Apache
|
||||
License 2.0 (part of the MeowOS project; see the top-level repository
|
||||
LICENSE). The third-party components listed below retain their own
|
||||
licenses — in particular libmobi is LGPL-3.0 and stays under LGPL-3.0
|
||||
even though it is statically linked into the binary. Under LGPL-3.0
|
||||
section 1 the Apache-2.0 application is not thereby required to be
|
||||
re-licensed under the GPL.
|
||||
|
||||
Source availability
|
||||
-------------------
|
||||
The reader source (this application), build_reader.sh, and the top-level
|
||||
MeowOS repository are publicly pullable at:
|
||||
https://git.yeij.top/AskaEth/MeowOS-For-R3P2.git
|
||||
(admin push: ssh://git@git.yeij.top:2222/AskaEth/MeowOS-For-R3P2.git)
|
||||
The libmobi source tree at the locked commit remains available from the
|
||||
upstream project and is re-fetched by build_reader.sh; a relink how-to
|
||||
is in README_LGPL_RELINK.md in the reader_app directory.
|
||||
|
||||
--------------------------------------------------------------------
|
||||
1. libmobi — Copyright (c) 2014-2024 Bartek Fabiszewski
|
||||
project: https://github.com/bfabiszewski/libmobi
|
||||
license: GNU LESSER GENERAL PUBLIC LICENSE, Version 3
|
||||
(or, at your option, any later version)
|
||||
|
||||
Locked version (commit):
|
||||
906274205c11944b628da1c553b255acb1af7c55 (2024-10-29)
|
||||
Upstream source and relink instructions:
|
||||
https://github.com/bfabiszewski/libmobi
|
||||
|
||||
libmobi is linked statically into the reader binary (LGPL-3.0
|
||||
§4 relink requirement). This NOTICE, the version lock above, and
|
||||
the publicly reproducible build (build_reader.sh) that fetches and
|
||||
recompiles libmobi satisfy the obligation to provide the
|
||||
corresponding source and the ability to re-link. The libmobi
|
||||
sources are NOT committed to this repository (they live in the
|
||||
upstream repo at the commit above); the build script retrieves
|
||||
exactly that commit.
|
||||
|
||||
Full license texts (shipped with the package in resources/licenses/):
|
||||
- GNU GPL version 3: resources/licenses/GPL-3.0.txt
|
||||
- GNU LGPL version 3: resources/licenses/LGPL-3.0.txt
|
||||
Both full texts are also reproduced below.
|
||||
|
||||
Full license text (GNU LGPL v3):
|
||||
--------------------------------------------------------------------
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
|
||||
--------------------------------------------------------------------
|
||||
2. miniz — Copyright (c) 2013-2014 RAD Game Tools and Valve Software
|
||||
Copyright (c) 2010-2014 Rich Geldreich and Tenacious
|
||||
Software LLC
|
||||
license: zlib license (MIT-style, permissive)
|
||||
project: https://github.com/richgel999/miniz
|
||||
Used for ZIP container reading (EPUB/CBZ) and inflate.
|
||||
|
||||
--------------------------------------------------------------------
|
||||
3. stb_image — Public domain / MIT (Sean Barrett et al., v2.30)
|
||||
project: https://github.com/nothings/stb
|
||||
Used for image decode + downsample (CBZ pages, covers).
|
||||
|
||||
@@ -266,10 +266,66 @@ static void t10(void)
|
||||
remove(path);
|
||||
}
|
||||
|
||||
/* t11 — Big5→UTF-8 解码金标准(R3:big5_2byte 码表;对照 python `big5` codec)。 */
|
||||
static void t11(void)
|
||||
{
|
||||
/* "你好世界" Big5 = a741 a66e a540 acc9 → UTF-8 你好世界 */
|
||||
const uint8_t in_nihao[] = { 0xA7, 0x41, 0xA6, 0x6E, 0xA5, 0x40, 0xAC, 0xC9 };
|
||||
const uint8_t ex_nihao[] = "\xE4\xBD\xA0\xE5\xA5\xBD\xE4\xB8\x96\xE7\x95\x8C";
|
||||
uint8_t out[256]; size_t olen = 0;
|
||||
int rc = rd_big5_to_utf8(in_nihao, sizeof in_nihao, out, sizeof out, &olen);
|
||||
CHECK(rc == RD_ENC_OK, "big5 decode ok");
|
||||
CHECK(olen == sizeof ex_nihao - 1 && memcmp(out, ex_nihao, olen) == 0, "big5 golden 你好世界");
|
||||
/* 经通用 rd_to_utf8(RD_ENC_BIG5) 路径 */
|
||||
memset(out, 0, sizeof out); olen = 0;
|
||||
CHECK(rd_to_utf8(RD_ENC_BIG5, in_nihao, sizeof in_nihao, out, sizeof out, &olen) == RD_ENC_OK &&
|
||||
olen == sizeof ex_nihao - 1 && memcmp(out, ex_nihao, olen) == 0, "rd_to_utf8 big5");
|
||||
|
||||
/* 繁体长句(python 生成金标准) */
|
||||
const uint8_t in_tr[] = { 0xB3,0x6F,0xAC,0x4F,0xC1,0x63,0xC5,0xE9,0xA4,0xA4,0xA4,0xE5,0xB4,0xFA,
|
||||
0xB8,0xD5,0xA1,0x41,0xA5,0xCE,0xA9,0xF3,0xBD,0x73,0xBD,0x58,0xC0,0xCB,
|
||||
0xB4,0xFA,0xA1,0x43 };
|
||||
const uint8_t ex_tr[] = "\xE9\x80\x99\xE6\x98\xAF\xE7\xB9\x81\xE9\xAB\x94\xE4\xB8\xAD\xE6\x96\x87"
|
||||
"\xE6\xB8\xAC\xE8\xA9\xA6\xEF\xBC\x8C\xE7\x94\xA8\xE6\x96\xBC\xE7\xB7\xA8"
|
||||
"\xE7\xA2\xBC\xE6\xAA\xA2\xE6\xB8\xAC\xE3\x80\x82";
|
||||
memset(out, 0, sizeof out); olen = 0;
|
||||
CHECK(rd_big5_to_utf8(in_tr, sizeof in_tr, out, sizeof out, &olen) == RD_ENC_OK, "big5 trad decode");
|
||||
CHECK(olen == sizeof ex_tr - 1 && memcmp(out, ex_tr, olen) == 0, "big5 golden trad");
|
||||
|
||||
/* 非法 Big5 双字节(trail 0x80..0xA0 非 Big5 尾节区)→ U+FFFD,不崩溃 */
|
||||
const uint8_t in_bad[] = { 0xA7, 0x80, 'X' }; /* a7 + trail 0x80(Big5 非法)+ 孤立 0x80 */
|
||||
memset(out, 0, sizeof out); olen = 0;
|
||||
CHECK(rd_big5_to_utf8(in_bad, sizeof in_bad, out, sizeof out, &olen) == RD_ENC_OK, "big5 bad decode");
|
||||
const uint8_t ex_bad[] = { 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBD, 'X' }; /* FFFD(0xA7) FFFD(0x80) X */
|
||||
CHECK(olen == sizeof ex_bad && memcmp(out, ex_bad, olen) == 0, "big5 bad → FFFD");
|
||||
}
|
||||
|
||||
/* t12 — Big5 文件经 rdtxt 段读(info.enc 显式 Big5,模拟 UI 编码切换)。 */
|
||||
static void t12(void)
|
||||
{
|
||||
const char *path = "/tmp/rdtxt_big5.txt";
|
||||
FILE *f = fopen(path, "wb");
|
||||
const uint8_t b5[] = { 0xA7,0x41,0xA6,0x6E, 0x0A, 0xA5,0x40,0xAC,0xC9, 0x0A }; /* 你好\n世界\n */
|
||||
fwrite(b5, 1, sizeof b5, f);
|
||||
fclose(f);
|
||||
rdtxt_info info;
|
||||
CHECK(rdtxt_probe(path, &info) == 0, "big5 probe");
|
||||
info.enc = RD_ENC_BIG5; /* 手动指定 Big5(auto 会判 GB18030) */
|
||||
rdtxt_reader *r = NULL;
|
||||
CHECK(rdtxt_reader_open(path, &info, &r) == 0, "big5 open");
|
||||
uint8_t buf[RDTXT_SEG_UTF8_MAX + 8];
|
||||
size_t ul = 0, off = 0, flen = 0, total = 0;
|
||||
while (rdtxt_reader_next(r, buf, sizeof buf, &ul, &off, &flen) == 0) total += ul;
|
||||
rdtxt_reader_free(r);
|
||||
/* 整文件为一段(< 48K 分段阈值):"你好\n世界\n" = 6+1+6+1 = 14 字节 */
|
||||
CHECK(total == 14, "big5 segments sum");
|
||||
remove(path);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
t1(); t2(); t3(); t4(); t5();
|
||||
t6(); t7(); t8(); t9(); t10();
|
||||
t6(); t7(); t8(); t9(); t10(); t11(); t12();
|
||||
printf("test_reader_core: %d pass, %d fail\n", g_pass, g_fail);
|
||||
return g_fail ? 1 : 0;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python3
|
||||
"""gen_big5_table.py — 生成 Big5 双字节 → Unicode BMP 码位表(源码生成物,入仓)。
|
||||
|
||||
输出:core/big5_table.h 的 `static const uint16_t big5_2byte[126][190]`。
|
||||
|
||||
为什么这样生成(对齐 devdocs/plan/READER_ENGINE_NOTES.md §3.4 的 GB 表做法):
|
||||
- 用 Python 内置 `big5` codec 枚举 2 字节码位(CP950/Big5 全映射)。
|
||||
- 表大小 = 126 引导字节(0x81..0xFE)× 190 尾字节 = 23,940 项 × 2B = 47,880 B。
|
||||
- 0 值 = 该 (lead,trail) 不是合法 Big5 双字节(含 trail 0x80..0xA0 区——Big5 尾字节
|
||||
只取 0x40..0x7E | 0xA1..0xFE);解码器查表得码位,命中 0 → U+FFFD。
|
||||
- 列布局与 GB 表完全一致(idx(b) = b-0x40-(b>=0x80),跳过 0x7F),故解码器可复用同一
|
||||
trail 列索引函数。
|
||||
- 说明(README/编码检测局限):Big5 的双字节区间是 GB18030 双字节区间的**严格子集**,
|
||||
字节结构无法区分二者;本表用于 Big5 **显式选中时正确解码**,不用于自动检测(见 rdenc.h)。
|
||||
|
||||
用法:`python3 tools/gen_big5_table.py > core/big5_table.h`
|
||||
(可用 env BIG5_TABLE_H 覆写输出路径。)
|
||||
"""
|
||||
import sys
|
||||
|
||||
LEADS = list(range(0x81, 0xFF)) # 0x81..0xFE → 126 个
|
||||
TRAILS = list(range(0x40, 0x7F)) + list(range(0x80, 0xFF)) # 0x40..0x7E,0x80..0xFE → 190 个
|
||||
|
||||
INDEX_OF = {b: i for i, b in enumerate(TRAILS)} # 尾字节 → 列号
|
||||
|
||||
def build():
|
||||
g = [0] * (len(LEADS) * len(TRAILS))
|
||||
for k, lead in enumerate(LEADS):
|
||||
for j, tr in enumerate(TRAILS):
|
||||
try:
|
||||
s = bytes([lead, tr]).decode('big5')
|
||||
if len(s) == 1 and ord(s) <= 0xFFFF:
|
||||
g[k * len(TRAILS) + j] = ord(s)
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
return g
|
||||
|
||||
def emit(g):
|
||||
rows, cols = len(LEADS), len(TRAILS)
|
||||
out = sys.stdout
|
||||
out.write("/* big5_table.h — Big5 双字节 → Unicode BMP 码位表(生成物,勿手改;\n")
|
||||
out.write(" * 由 tools/gen_big5_table.py 用 python3 `big5` codec 生成)。\n")
|
||||
out.write(" * 布局:big5_2byte[lead-0x81][trail_col];列号 idx(b)= b-0x40-(b>=0x80);\n")
|
||||
out.write(" * 值 0 = 非法 Big5 双字节(如 trail 0x80..0xA0);解码器输出 U+FFFD。*/\n")
|
||||
out.write("#ifndef RD_BIG5_TABLE_H\n#define RD_BIG5_TABLE_H\n\n")
|
||||
out.write("#include <stdint.h>\n\n")
|
||||
out.write("#define RD_B5_LEADS %d\n" % rows)
|
||||
out.write("#define RD_B5_TRAILS %d\n" % cols)
|
||||
out.write("#define RD_B5_LEAD0 0x81\n")
|
||||
out.write("#define RD_B5_TRAIL0 0x40\n\n")
|
||||
out.write("/* big5_2byte[126][190]:rdbig5_lookup(lead, trail) 返回 BMP 码位或 0。 */\n")
|
||||
out.write("static const uint16_t big5_2byte[%d][%d] = {\n" % (rows, cols))
|
||||
for k in range(rows):
|
||||
out.write(" {")
|
||||
for j in range(cols):
|
||||
v = g[k * cols + j]
|
||||
if j % 8 == 0:
|
||||
out.write("\n " if j else "")
|
||||
out.write("0x%04X,%s" % (v, "" if j == cols - 1 else ""))
|
||||
out.write("\n }%s\n" % ("," if k != rows - 1 else ""))
|
||||
out.write("};\n\n#endif /* RD_BIG5_TABLE_H */\n")
|
||||
|
||||
if __name__ == '__main__':
|
||||
emit(build())
|
||||
Reference in new issue
Block a user