Compare commits

..

67 Commits
v0.2.3 ... main

Author SHA1 Message Date
Aoran Zeng 3816263878
CI deprecated `macos-13`
Some checks failed
Publish 'chsrc-git' to AUR / publish (push) Has been cancelled
2025-12-18 14:10:15 +08:00
Aoran Zeng 3657c9f7dd
Prerelease `0.2.3.4` 2025-12-18 14:01:49 +08:00
happygame f5c78c5a04 Fix: 修复 Mac 上 `uv` 换源 #323 2025-12-18 13:56:12 +08:00
dependabot[bot] db9449993b Bump actions/download-artifact from 6 to 7
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 6 to 7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-16 21:20:15 +08:00
dependabot[bot] 6613c676cc Bump actions/upload-artifact from 5 to 6
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-16 21:19:48 +08:00
dependabot[bot] b8ff421a8a Bump actions/checkout from 5 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-25 10:50:06 +08:00
Aoran Zeng 7e6c90319d
Prerelease `0.2.3.3`
Some checks failed
Publish 'chsrc-git' to AUR / publish (push) Has been cancelled
2025-11-09 13:05:48 +08:00
Aoran Zeng 9a6f39216c
Fix `Debian` recipe: 多余的 `/`
[GitHub #319]
2025-11-09 12:58:30 +08:00
Aoran Zeng 55aef454e9
Prerelease `0.2.3.2`
Some checks failed
Publish 'chsrc-git' to AUR / publish (push) Has been cancelled
2025-10-30 20:21:12 +08:00
Aoran Zeng 64581bb718
Update `lefthook.yml` 2025-10-30 20:20:21 +08:00
Aoran Zeng 46e2cb8d43
Add missing `\n` for `Arch`
[GitHub #317]
2025-10-30 20:19:36 +08:00
Aoran Zeng c22fae679e
Rewrite `chsrc_prepend_to_file()`
[GitHub #317]
2025-10-30 20:18:08 +08:00
Aoran Zeng 6a527dba00
Fix deb building in CI
Some checks failed
Publish 'chsrc-git' to AUR / publish (push) Has been cancelled
2025-10-29 13:28:56 +08:00
Aoran Zeng dafbb302bb
Fix `cli.pl` 2025-10-29 13:25:27 +08:00
Aoran Zeng 6e03939f45
Update doc 2025-10-29 12:41:07 +08:00
Aoran Zeng 1264b4192f
Fix deb building in CI 2025-10-29 11:35:38 +08:00
Aoran Zeng 332186224f
Prerelease `v0.2.3.1`
Some checks are pending
Publish 'chsrc-git' to AUR / publish (push) Waiting to run
2025-10-28 22:34:40 +08:00
Aoran Zeng fed349827c
Rename to helper.c 2025-10-28 22:29:57 +08:00
Aoran Zeng fd309e7300
Update `lefthook.yml` 2025-10-28 20:21:28 +08:00
Aoran Zeng 4a13358c8b
Use internal warn for xy.h 2025-10-28 20:10:04 +08:00
Aoran Zeng 8833eb99c1
Update lefthook.yml 2025-10-28 20:00:34 +08:00
Aoran Zeng 6af042ca9f
Update lefthook.yml 2025-10-28 19:38:07 +08:00
Aoran Zeng 0c3405803a
Update lefthook.yml 2025-10-28 19:30:55 +08:00
Aoran Zeng cbf22a7f29
Add lefthook.yml 2025-10-28 19:01:21 +08:00
Aoran Zeng 37710884a8
Add `xy.os_family` 2025-10-28 14:55:17 +08:00
Aoran Zeng 066ac191a6
Refactor `xy_ptr_replace()` 2025-10-28 13:44:42 +08:00
dependabot[bot] 985a6344b3 Bump actions/upload-artifact from 4 to 5
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-28 13:11:33 +08:00
dependabot[bot] 8e392b04b8 Bump actions/download-artifact from 5 to 6
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-28 13:10:45 +08:00
曾奥然 6060b325be
Merge pull request #300 from Mikachu2333/fix/free_hwnd
处理 `xy.h` 内存以及部分资源未释放的问题
2025-10-28 13:10:03 +08:00
曾奥然 d84bdba08a
Merge branch 'dev' into fix/free_hwnd 2025-10-28 13:09:06 +08:00
Aoran Zeng c6897bd73e
Remove `free()` in recipes 2025-10-27 22:11:34 +08:00
Aoran Zeng 1058d3310b
Rename option controlling API to `deny` 2025-10-27 22:05:17 +08:00
Aoran Zeng 28d8e4ad0c
Only use `$(OS)` to ensure MSYS2
Some checks failed
Publish 'chsrc-git' to AUR / publish (push) Has been cancelled
2025-10-15 18:33:21 +08:00
Aoran Zeng 8ebe5812ed
Redefine Windows resource script macro 2025-10-15 18:21:41 +08:00
Aoran Zeng 19d09e537a
Rename directory from `res` to `resource` 2025-10-15 18:10:19 +08:00
Aoran Zeng ebc9e167f2
Refactor Windows resource compiling 2025-10-15 18:09:50 +08:00
曾奥然 e030c8095e
Merge pull request #307 from Mikachu2333/feat/win_rc_support
为win的exe文件增添附加的属性,便于区分版本
2025-10-15 17:10:18 +08:00
Aoran Zeng f926834384
避免API使用消极用语 2025-10-15 17:02:43 +08:00
Mikachu2333 6af3e51566
修复Android系统检测 (#313) 2025-10-15 16:51:04 +08:00
Mikachu2333 990b8d0df3 refactor(lib): 重命名字符串替换函数、优化空指针处理 2025-10-15 15:05:48 +08:00
Mikachu2333 1ac8b892e2 style(lib): 调整函数参数括号前空格 2025-10-15 15:05:48 +08:00
Mikachu2333 c44377f2d9 build(lib): 更新版本号和最后修改日期 2025-10-15 15:05:48 +08:00
Mikachu2333 16602d0e7f refactor(lib): 重命名字符串替换函数
将函数名从 `xy_str_swap` 更改为 `xy_str_replace`,以更准确地反映其实际功能。
该函数并非简单交换两个字符串,而是用新字符串替换旧字符串的内容。

此更改涉及多个文件中的调用点,包括路径处理和文件读取相关的逻辑。
2025-10-15 15:05:48 +08:00
Mikachu2333 6f312a66c0 fix(lib): 优化字符串前缀删除逻辑并修复内存泄漏
重构 `xy_str_delete_prefix` 函数以避免不必要的内存分配和释放,
直接使用原字符串进行处理。同时修复 `xy_dir_exist` 函数中 system
调用后未释放临时命令字符串的内存泄漏问题。
2025-10-15 15:05:48 +08:00
Mikachu2333 948d55185f 修复 xy_normalize_path 内存泄漏问题 2025-10-15 15:05:48 +08:00
Mikachu2333 41783b8531 修复 xy_str_strip 误释放的问题 2025-10-15 15:05:48 +08:00
Mikachu2333 5588beb542 修复 xy_str_delete_prefix 误释放的问题 2025-10-15 15:05:48 +08:00
Mikachu2333 547931c4e4 修复 xy_detect_os 内存泄露 2025-10-15 15:05:48 +08:00
Mikachu2333 e64778911a 修复 xy_parent_dir 内存泄露 2025-10-15 15:05:48 +08:00
Mikachu2333 2a9d13bfc8 修复 xy_normalize_path 内存泄露 2025-10-15 15:05:48 +08:00
Mikachu2333 a3600bf05f 修复 xy_dir_exist 的内存泄露 2025-10-15 15:05:47 +08:00
Mikachu2333 437729a5cf 改进 xy_file_exist 的变量命名,修复内存泄露 2025-10-15 15:05:47 +08:00
Mikachu2333 b2a844b676 修复 xy_file_to_str 的内存泄露 2025-10-15 15:05:47 +08:00
Mikachu2333 5771a308a6 xy.h + `xy_str_swap` 帮助释放内存 2025-10-15 15:05:47 +08:00
Mikachu2333 0b4215f257 修复 core.c 中未手动释放的内存 2025-10-15 15:05:47 +08:00
Mikachu2333 cfe850382d revert(Makefile): 彻底回退,未保留任何更改 2025-10-15 14:55:13 +08:00
Mikachu2333 717b0f96b8 feat(build): 增强Windows支持,动态检测目标机器类型 2025-10-15 14:55:13 +08:00
Mikachu2333 91692d6215 build(Makefile): 更新编译配置以包含新的头文件路径 2025-10-15 14:55:13 +08:00
Mikachu2333 6aac016c02 refactor(include): 更新头文件引用路径 2025-10-15 14:55:13 +08:00
Mikachu2333 1829f6e622 feat(chsrc): 移除一处无用的宏定义,删除文档过时内容 2025-10-15 14:55:13 +08:00
Mikachu2333 b84f2f9edd feat(build): 支持编译资源文件
修复just
修复makefile
2025-10-15 14:55:13 +08:00
Mikachu2333 de75aaa62b docs(chsrc): 更新文档贡献者信息 2025-10-15 14:55:13 +08:00
Mikachu2333 a5e358fc4a feat(logo): 添加项目图标文件
svg为矢量图,因无损所以可作为备份
2025-10-15 14:55:12 +08:00
Mikachu2333 9666b769a1 build(.gitignore): 添加 .res 文件到忽略列表 2025-10-15 14:55:12 +08:00
dependabot[bot] 730d18a8a9
Bump peter-evans/create-or-update-comment from 4 to 5 (#314)
Bumps [peter-evans/create-or-update-comment](https://github.com/peter-evans/create-or-update-comment) from 4 to 5.
- [Release notes](https://github.com/peter-evans/create-or-update-comment/releases)
- [Commits](https://github.com/peter-evans/create-or-update-comment/compare/v4...v5)

---
updated-dependencies:
- dependency-name: peter-evans/create-or-update-comment
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-15 13:00:57 +08:00
Mikachu2333 d6c2111868
更新 `Perl` recipe (#304) 2025-10-11 19:27:58 +08:00
dependabot[bot] 9dfffbb8f2 Bump peter-evans/create-or-update-comment from 4 to 5
Bumps [peter-evans/create-or-update-comment](https://github.com/peter-evans/create-or-update-comment) from 4 to 5.
- [Release notes](https://github.com/peter-evans/create-or-update-comment/releases)
- [Commits](https://github.com/peter-evans/create-or-update-comment/compare/v4...v5)

---
updated-dependencies:
- dependency-name: peter-evans/create-or-update-comment
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-07 09:42:49 +08:00
97 changed files with 594 additions and 376 deletions

4
.github/READIT.md vendored
View File

@ -3,8 +3,8 @@
! -------------------------------------------------------------
! Doc Type : Markdown
! Doc Name : (Overview .github) READIT.md
! Doc Authors : Aoran Zeng <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! Doc Authors : 曾奥然 <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! |
! Created On : <2025-06-20>
! Last Modified : <2025-06-20>

View File

@ -49,10 +49,10 @@ jobs:
echo "Event 名: ${{ github.event_name }}"
# 2025-10-06 移除点赞的步骤
# 因原 peter-evans/create-or-update-comment@v4 已不再支持空body而如果使用 Github Token 之类又过于大材小用因此移除
# 因原 peter-evans/create-or-update-comment@v5 已不再支持空body而如果使用 Github Token 之类又过于大材小用因此移除
- name: 添加评论欢迎 PRer
uses: peter-evans/create-or-update-comment@v4
uses: peter-evans/create-or-update-comment@v5
with:
issue-number: ${{ github.event.pull_request.number }}
body: |

View File

@ -34,7 +34,7 @@ jobs:
steps:
- name: 检出代码
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: 测试构建情况
run: |
@ -51,7 +51,7 @@ jobs:
steps:
- name: 检出代码
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: 创建测试文件
shell: powershell

View File

@ -20,7 +20,7 @@ jobs:
steps:
- name: 检出代码
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: 构建
run: |

View File

@ -24,7 +24,7 @@ jobs:
steps:
- name: 检出代码
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: 安装 GCC
uses: msys2/setup-msys2@v2

View File

@ -4,7 +4,7 @@
# Contributors : Nul None <nul@none.org>
# |
# Created On : <2023-09-15>
# Last Modified : <2025-09-12>
# Last Modified : <2025-12-18>
#
# Build chsrc on macOS and upload it to GitHub: the 'pre' release
# ---------------------------------------------------------------
@ -20,7 +20,7 @@ jobs:
steps:
- name: 检出代码
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: 检查编译器版本
run: |
@ -48,11 +48,13 @@ jobs:
on-x64:
runs-on: macos-13 # macos-14 is AArch64(ARMv8-A)
# macos-13 是 x64macos-14 是 AArch64(ARMv8-A)
# 但是 macos-13 已经于 2025-12-04 下线
runs-on: macos-15-intel
steps:
- name: 检出代码
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: 检查编译器版本
run: |

View File

@ -4,7 +4,7 @@
# Contributors : 曾奥然 <ccmywish@qq.com>
# |
# Created On : <2025-06-10>
# Last Modified : <2025-06-16>
# Last Modified : <2025-10-29>
#
# Build and publish deb packages
# ---------------------------------------------------------------
@ -30,7 +30,7 @@ jobs:
steps:
- name: 检出代码
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
ref: gh-build
@ -44,7 +44,7 @@ jobs:
elif [ "${{ github.event_name }}" = "push" ];then
# 从源代码中提取版本号
version=$(sed -E -n 's/^#define Chsrc_Version +"([0-9]+\.[0-9]+\.[0-9]+).*"/\1/p' ./src/chsrc-main.c)
version=$(sed -E -n 's/^#define Chsrc_Version +"([0-9]+\.[0-9]+\.[0-9]+).*"/\1/p' ./src/framework/version.h)
else
version="${{ github.event.inputs.version }}"
@ -73,7 +73,7 @@ jobs:
* Release version $version
-- Aoran Zeng <ccmywish@qq.com> $(date -R)
-- 曾奥然 <ccmywish@qq.com> $(date -R)
EOF
@ -121,7 +121,7 @@ jobs:
bash pkg/deb/deb-installation-test.sh
- name: 上传deb包到artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v6
with:
name: chsrc-deb-files
path: dist/chsrc_*.deb
@ -154,7 +154,7 @@ jobs:
steps:
- name: Download all artifacts
uses: actions/download-artifact@v5
uses: actions/download-artifact@v7
with:
pattern: chsrc-deb-files
merge-multiple: true
@ -172,7 +172,7 @@ jobs:
dpkg-scanpackages . /dev/null > Packages
- name: Upload repository metadata
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v6
with:
name: debian-repository-metadata
path: debs/Packages*

2
.gitignore vendored
View File

@ -22,7 +22,7 @@
*.dll
*.out
*.exe
*.res
##############################

4
.vscode/README.md vendored
View File

@ -3,8 +3,8 @@
! -------------------------------------------------------------
! Doc Type : Markdown
! Doc Name : (for VS Code users) README.md
! Doc Authors : Aoran Zeng <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! Doc Authors : 曾奥然 <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! |
! Created On : <2025-06-18>
! Last Modified : <2025-06-20>

View File

@ -2,13 +2,13 @@
# --------------------------------------------------------------
# SPDX-License-Identifier: GPL-3.0-or-later
# --------------------------------------------------------------
# Build File : Makefile
# File Authors : Aoran Zeng <ccmywish@qq.com>
# Contributors : Yangmoooo <yangmoooo@outlook.com>
# Build File : Makefile
# File Authors : 曾奥然 <ccmywish@qq.com>
# Contributors : Yangmoooo <yangmoooo@outlook.com>
# | sanchuanhehe <wyihe5520@gmail.com>
# |
# Created On : <2023-08-28>
# Last Modified : <2025-07-22>
# Last Modified : <2025-10-15>
#
# 请阅读 ./doc/01-开发与构建.md 来使用
# --------------------------------------------------------------
@ -26,10 +26,12 @@ ifeq ($(shell uname), Darwin)
On-macOS = 1
endif
# 只有Windows会定义$(OS)变量
# 只有 MSYS2 会定义 $(OS) 变量
ifeq ($(OS), Windows_NT)
On-Windows = 1
endif
# 注意, 原生 Windows 会定义 $(ComSpec) 变量,且区分大小写
# 但是 MSYS2 并不会定义
#=====================================
@ -196,6 +198,7 @@ test-cli: $(DevMode-Target-Name)
clean:
-@rm *.exe 2>/dev/null
-@rm *.res 2>/dev/null
-@rm xy 2>/dev/null
-@rm fw 2>/dev/null
-@rm README.md.bak* 2>/dev/null

View File

@ -3,8 +3,8 @@
! -------------------------------------------------------------
! Doc Type : Markdown
! Doc Name : (chsrc-bootstrap Introduction.md)
! Doc Authors : Aoran Zeng <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! Doc Authors : 曾奥然 <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! |
! Created On : <2025-07-12>
! Last Modified : <2025-07-22>

View File

@ -3,11 +3,11 @@
! -------------------------------------------------------------
! Doc Type : Markdown
! Doc Name : 01-开发与构建.md
! Doc Authors : 曾奥然 <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! Doc Authors : 曾奥然 <ccmywish@qq.com>
! Contributors : Mikachu2333 <mikachu.23333@zohomail.com>
! |
! Created On : <2024-12-27>
! Last Modified : <2025-08-22>
! Last Modified : <2025-10-11>
! ---------------------------------------------------------- -->
# 开发 chsrc

View File

@ -7,7 +7,7 @@
! Contributors : Nul None <nul@none.org>
! |
! Created On : <2024-08-19>
! Last Modified : <2025-08-22>
! Last Modified : <2025-10-28>
! ---------------------------------------------------------- -->
# Write A Recipe Even If You Don't Know C
@ -89,7 +89,8 @@
1. `framework/core.c` 中以 `chsrc_` 开头的所有函数或宏
2. `xy.h` 中以 `xy_` 开头的所有函数或宏
3. `chec.c` `chef-helper.c` 中以 `chef_` 开头的所有函数或宏
3. `chec.c` 中以 `chef_` 开头的所有函数或宏
4. `helper.c` 中以 `hp_` 开头的所有函数或宏
一个简单的方法是,在 VS Code 中按快捷键 `Ctrl-T` 搜索上述三种前缀

View File

@ -2,14 +2,14 @@
.\" SPDX-License-Identifier: GFDL-1.3-or-later
.\" --------------------------------------------------------------
.\" Doc Type : Man Page
.\" Doc Authors : Aoran Zeng <ccmywish@qq.com>
.\" Contributors : Nul None <nul@none.org>
.\" Doc Authors : 曾奥然 <ccmywish@qq.com>
.\" Contributors : Nul None <nul@none.org>
.\" |
.\" Created On : <2024-08-21>
.\" Last Modified : <2025-08-11>
.\" --------------------------------------------------------------
.\" Last Modified : <2025-10-29>
.\" ----------------------------------------------------------------
.TH chsrc 1 "2025-08-11" "v0.2.2.3" "RubyMetric chsrc"
.TH chsrc 1 "2025-10-29" "v0.2.3.1" "RubyMetric chsrc"
.SH NAME
chsrc - Change Source for every software on every platform from the command line

View File

@ -2,29 +2,29 @@
@c SPDX-License-Identifier: GFDL-1.3-or-later
@c --------------------------------------------------------------
@c Doc Type : Texinfo
@c Doc Authors : Aoran Zeng <ccmywish@qq.com>
@c Contributors : Nul None <nul@none.org>
@c Doc Authors : 曾奥然 <ccmywish@qq.com>
@c Contributors : Nul None <nul@none.org>
@c |
@c Created On : <2024-08-22>
@c Last Modified : <2025-08-11>
@c Last Modified : <2025-10-29>
@c --------------------------------------------------------------
\input texinfo
@setfilename chsrc.info
@settitle chsrc
@set Chsrc_Version v0.2.2.3
@set Doc_Publish_Date 2025-08-11
@set Chsrc_Version v0.2.3.1
@set Doc_Publish_Date 2025-10-29
@copying
@comment 这是软件copyright不是文档copyright因此不放在titlepage
Copyright @copyright{} 2025 Aoran Zeng, Heng Guo
Copyright @copyright{} 2025 曾奥然, 郭恒
@end copying
@titlepage
@title chsrc printed manual
@subtitle Change Source everywhere for every software!
@author Aoran Zeng
@author 曾奥然
@c @insertcopying
For chsrc @value{Chsrc_Version}
@page

9
doc/image/chsrc.svg Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 500 500" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g>
<path d="M13.392,207.176L130.909,79.868L369.203,79.868L486.608,207.055L486.608,210.821L255.801,459.814L244.311,459.814L13.392,210.7L13.392,207.176ZM250.056,118.434C186.007,118.434 134.008,170.433 134.008,234.482C134.008,298.53 186.007,350.53 250.056,350.53C314.104,350.53 366.104,298.53 366.104,234.482C366.104,170.433 314.104,118.434 250.056,118.434Z" style="fill:#a52019;"/>
<path d="M189.09,222.379C183.346,222.379 178.683,217.716 178.683,211.972C178.683,209.1 179.849,206.498 181.733,204.614L204.205,182.142C204.253,182.092 204.302,182.042 204.351,181.993C208.413,177.931 215.007,177.931 219.069,181.993C223.131,186.055 223.131,192.649 219.069,196.711C219.02,196.76 218.97,196.808 218.921,196.856L214.212,201.565L312.183,201.565C317.927,201.565 322.59,206.228 322.59,211.972C322.59,217.716 317.927,222.379 312.183,222.379L189.09,222.379Z" style="fill:#a52019;"/>
<path d="M311.547,245.378C317.29,245.378 321.954,250.042 321.954,255.785C321.954,258.657 320.788,261.259 318.904,263.143L296.431,285.616C296.383,285.665 296.335,285.715 296.286,285.764C292.224,289.826 285.629,289.826 281.568,285.764C277.506,281.703 277.506,275.108 281.568,271.046C281.617,270.997 281.666,270.949 281.716,270.901L286.424,266.193L188.453,266.193C182.71,266.193 178.046,261.529 178.046,255.785C178.046,250.042 182.71,245.378 188.453,245.378L311.547,245.378Z" style="fill:#a52019;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -2,12 +2,12 @@
# --------------------------------------------------------------
# SPDX-License-Identifier: GPL-3.0-or-later
# --------------------------------------------------------------
# Build File : justfile
# File Authors : Aoran Zeng <ccmywish@qq.com>
# Contributors : Nul None <nul@none.org>
# |
# Build File : justfile
# File Authors : 曾奥然 <ccmywish@qq.com>
# Contributors : Mikachu2333 <mikachu.23333@zohomail.com>
# |
# Created On : <2025-06-18>
# Last Modified : <2025-07-21>
# Last Modified : <2025-10-15>
#
# 该文件主要用于在原生Windows上执行项目的基本任务而不借助于
# GNU make 以及相应的 MSYS2、Cygwin 环境
@ -104,9 +104,9 @@ alias c := clean
default: build-in-dev-mode
build-in-dev-mode:
@echo Starting: Build in DEV mode: '{{CC}}' {{CFLAGS_dev_mode_prompt}} -o {{DevMode-Target-Name}}
@{{CC}} src/chsrc-main.c {{CFLAGS_dev_mode}} -o {{DevMode-Target-Name}}
@echo Finished: Build in DEV mode
@echo Starting: Build in DEV mode: '{{CC}}' {{CFLAGS_dev_mode_prompt}} -o {{DevMode-Target-Name}}
@{{CC}} src/chsrc-main.c {{CFLAGS_dev_mode}} -o {{DevMode-Target-Name}}
@echo Finished: Build in DEV mode
build-in-debug-mode:
@echo Starting: Build in DEBUG mode: '{{CC}}' {{CFLAGS_debug_mode_prompt}} -o {{DebugMode-Target-Name}}
@ -114,9 +114,17 @@ build-in-debug-mode:
@echo Finished: Build in DEBUG mode
build-in-release-mode:
@echo Starting: Build in RELEASE mode: '{{CC}}' {{CFLAGS_release_mode_prompt}} -o {{ReleaseMode-Target-Name}}
@{{CC}} src/chsrc-main.c {{CFLAGS_release_mode}} -o {{ReleaseMode-Target-Name}}
@echo Finished: Build in RELEASE mode
@echo Starting: Build in RELEASE mode: '{{CC}}' {{CFLAGS_release_mode_prompt}} -o {{ReleaseMode-Target-Name}}
@{{ if os() == 'windows' { \
'(if exist chsrc.res del chsrc.res)' + \
' & windres src/resource/chsrc.rc -O coff -o chsrc.res' \
} else { '' } }}
@{{ if os() == 'windows' { \
CC + ' src/chsrc-main.c chsrc.res ' + CFLAGS_release_mode + ' -o ' + ReleaseMode-Target-Name \
} else { \
CC + ' src/chsrc-main.c ' + CFLAGS_release_mode + ' -o ' + ReleaseMode-Target-Name \
} }}
@echo Finished: Build in RELEASE mode
debug: build-in-debug-mode
@{{DEBUGGER}} {{DebugMode-Target-Name}}
@ -140,6 +148,7 @@ test-cli:
clean:
-@{{BIN_rm}} *.exe
-@{{BIN_rm}} *.res
-@{{BIN_rm}} xy
-@{{BIN_rm}} fw
-@{{BIN_rm}} chsrc

53
lefthook.yml Normal file
View File

@ -0,0 +1,53 @@
# ---------------------------------------------------------------
# Lefthook File : lefthook.yml
# File Authors : 曾奥然 <ccmywish@qq.com>
# Contributors : Nul None <nul@none.org>
# |
# Created On : <2025-10-28>
# Last Modified : <2025-10-30>
# ---------------------------------------------------------------
min_version: 2.0.1
pre-commit:
only:
- ref: dev
parallel: false
jobs:
- name: 试运行 DEBUG mode
# 触发所有 _prelude() 函数检查
run: |
just build-in-debug-mode
./chsrc-debug get pip
glob: "*.{c,h}"
exclude: test/*
- name: 测试 xy.h
run: just test-xy
glob:
- lib/xy.h
- test/xy.c
- name: 测试 framework
run: just test-fw
glob:
- "src/framework/*.{c,h}"
- src/chsrc-main.c
- test/fw.c
post-merge:
only:
- ref: main
jobs:
- name: 测试编译 DEV mode
run: just build-in-dev-mode
pre-push:
only:
- ref: gh-build
jobs:
- name: 测试编译 RELEASE mode
run: just build-in-release-mode
- name: 测试运行
run: just test-cli

264
lib/xy.h
View File

@ -9,7 +9,7 @@
* | BingChunMoLi <bingchunmoli@bingchunmoli.com>
* |
* Created On : <2023-08-28>
* Last Modified : <2025-10-06>
* Last Modified : <2025-10-28>
*
*
* xy:
@ -23,7 +23,7 @@
#ifndef XY_H
#define XY_H
#define _XY_Version "v0.2.1.0-2025/10/06"
#define _XY_Version "v0.2.2.0-2025/10/28"
#define _XY_Maintain_URL "https://github.com/RubyMetric/chsrc/blob/dev/lib/xy.h"
#define _XY_Maintain_URL2 "https://gitee.com/RubyMetric/chsrc/blob/dev/lib/xy.h"
@ -72,6 +72,8 @@ struct
bool on_bsd;
bool on_android;
/* @flavor 同 just 中的 os_family(),只区分 windows, unix */
char *os_family;
char *os_devnull;
}
xy =
@ -88,6 +90,7 @@ xy =
.on_bsd = false,
.on_android = false,
.os_family = NULL,
.os_devnull = NULL
};
@ -122,17 +125,31 @@ xy =
#define assert_str(a, b) assert (xy_streql ((a), (b)))
#define xy_panic(reason) assert(!reason)
#define xy_throw(reason) assert(!reason)
// @flavor Perl, PHP, Raku
#define die xy_panic
/**
* @depreacated
*
* @flavor Perl, PHP, Raku
*/
// #define die xy_throw
#define xy_unsupported() xy_panic("Unsuppoted")
#define xy_unimplemented() xy_panic("Unimplemented temporarily")
#define xy_unreached() xy_panic("This code shouldn't be reached")
#define xy_cant_be_null(p) if(!p) xy_panic("This pointer can't be null")
/**
* @depreacated
*/
// #define xy_panic xy_throw
#define xy_unsupported() xy_throw("Unsuppoted")
#define xy_unimplemented() xy_throw("Unimplemented temporarily")
#define xy_unreached() xy_throw("This code shouldn't be reached")
#define xy_cant_be_null(p) if(!p) xy_throw("This pointer can't be null")
static inline void
_xy_internal_warn (char *str)
{
fprintf (stderr, "[xy.h] %s\n", str);
}
static void _xy_print_int (int n) {printf ("%d", n);}
static void _xy_print_long (long n) {printf ("%ld", n);}
@ -164,7 +181,7 @@ static void _xy_println_const_str (const char *str) {printf ("%s\n", str);}
bool: _xy_print_bool, \
char *: _xy_print_str, \
const char *: _xy_print_const_str, \
default: xy_panic("Unsupported type for print()!") \
default: xy_throw("Unsupported type for print()!") \
)(x)
/**
@ -179,7 +196,7 @@ static void _xy_println_const_str (const char *str) {printf ("%s\n", str);}
bool: _xy_println_bool, \
char *: _xy_println_str, \
const char *: _xy_println_const_str, \
default: xy_panic("Unsupported type for println()/say()!") \
default: xy_throw("Unsupported type for println()/say()!") \
)(x)
/* @flavor Raku, Perl */
#define say println
@ -204,12 +221,31 @@ xy_malloc0 (size_t size)
}
/**
* @brief
*
* @param pptr
* *pptr NULL
* @param new_mem
*/
static inline void
xy_ptr_replace (char **pptr, char *new_mem)
{
xy_cant_be_null (pptr);
if (*pptr)
free (*pptr);
*pptr = new_mem;
}
/******************************************************
* String
******************************************************/
/**
* @brief str pat replace
* @brief str pat replace
*
* @flavor Ruby: String#gsub
*
@ -344,7 +380,7 @@ xy_strcat (unsigned int count, ...)
}
if (NULL == ret)
{
fprintf (stderr, "xy.h: No availble memory!");
_xy_internal_warn ("xy_strcat(): No availble memory to allocate!");
return NULL;
}
strcpy (cur, str);
@ -370,7 +406,7 @@ xy_strdup (const char *str)
{
if (!str)
{
fprintf (stderr, "xy.h: xy_strdup() called with NULL!\n");
_xy_internal_warn ("xy_strdup(): called with NULL!");
return NULL;
}
@ -470,15 +506,15 @@ xy_streql (const char *str1, const char *str2)
}
static bool
xy_streql_ic(const char *str1, const char *str2)
xy_streql_ic (const char *str1, const char *str2)
{
if (NULL == str1 || NULL == str2)
{
return false;
}
size_t len1 = strlen(str1);
size_t len2 = strlen(str2);
size_t len1 = strlen (str1);
size_t len2 = strlen (str2);
if (len1 != len2)
{
return false;
@ -486,7 +522,7 @@ xy_streql_ic(const char *str1, const char *str2)
for (size_t i = 0; i < len1; i++)
{
if (tolower(str1[i]) != tolower(str2[i]))
if (tolower (str1[i]) != tolower (str2[i]))
{
return false;
}
@ -560,14 +596,16 @@ xy_str_start_with (const char *str, const char *prefix)
static char *
xy_str_delete_prefix (const char *str, const char *prefix)
{
char *new = xy_strdup (str);
bool yes = xy_str_start_with (str, prefix);
if (!yes)
return new;
size_t len = strlen (prefix);
char *cur = new + len;
return cur;
{
return xy_strdup (str);
}
else
{
size_t len = strlen (prefix);
return xy_strdup (str + len);
}
}
/**
@ -594,23 +632,24 @@ xy_str_delete_suffix (const char *str, const char *suffix)
static char *
xy_str_strip (const char *str)
{
char *new = xy_strdup (str);
xy_cant_be_null (str);
while (strchr ("\n\r\v\t\f ", new[0]))
{
new += 1;
}
const char *start = str;
while (*start && strchr ("\n\r\v\t\f ", *start))
start++;
size_t len = strlen (new);
if ('\0' == *start)
return xy_strdup ("");
char *last = new + len - 1;
const char *end = start + strlen (start) - 1;
while (end >= start && strchr ("\n\r\v\t\f ", *end))
end--;
while (strchr ("\n\r\v\t\f ", *last))
{
*last = '\0';
last -= 1;
}
return new;
size_t len = (size_t) (end - start + 1);
char *ret = xy_malloc0 (len + 1);
memcpy (ret, start, len);
ret[len] = '\0';
return ret;
}
typedef struct
@ -724,7 +763,7 @@ xy_file_read (const char *path)
buf[read_bytes] = '\0';
char *formatted_str = xy_str_gsub (buf, "\r\n", "\n");
formatted_str = xy_str_gsub (formatted_str, "\r", "\n");
xy_ptr_replace (&formatted_str, xy_str_gsub (formatted_str, "\r", "\n"));
free (buf);
@ -929,7 +968,7 @@ xy_run_iter_lines (const char *cmd, unsigned long n, bool (*func) (const char
FILE *stream = popen (cmd, "r");
if (stream == NULL)
{
fprintf (stderr, "xy: 命令执行失败\n");
_xy_internal_warn ("xy_run_iter_lines(): popen() failed");
return NULL;
}
@ -994,7 +1033,7 @@ xy_run_get_stdout (const char *cmd, char **output)
FILE *stream = popen (cmd, "r");
if (stream == NULL)
{
fprintf (stderr, "xy: 命令执行失败\n");
_xy_internal_warn ("xy_run_get_stdout(): popen() failed");
return -1;
}
@ -1020,21 +1059,6 @@ xy_run_get_stdout (const char *cmd, char **output)
}
/**
* @flavor just os_family() windows, unix
*
* @return "windows" "unix"
*/
#define xy_os_family _xy_os_family ()
static char *
_xy_os_family ()
{
if (xy.on_windows)
return "windows";
else
return "unix";
}
/**
* @brief os family
@ -1143,13 +1167,19 @@ _xy_win_powershellv5_profile ()
static bool
xy_file_exist (const char *path)
{
const char *new_path = path;
char *expanded_path = NULL;
const char *check_path = path;
if (xy_str_start_with (path, "~"))
{
new_path = xy_2strcat (xy_os_home, path + 1);
expanded_path = xy_2strcat (xy_os_home, path + 1);
check_path = expanded_path;
}
// 0 即 F_OK
return (0==access (new_path, 0)) ? true : false;
bool result = (0 == access (check_path, 0)) ? true : false;
if (expanded_path) free (expanded_path);
return result;
}
/**
@ -1159,12 +1189,14 @@ xy_file_exist (const char *path)
static bool
xy_dir_exist (const char *path)
{
char *allocated_dir = NULL;
const char *dir = path;
if (xy.on_windows)
{
if (xy_str_start_with (path, "~"))
{
dir = xy_2strcat (xy_os_home, path + 1);
allocated_dir = xy_2strcat (xy_os_home, path + 1);
dir = allocated_dir;
}
}
@ -1174,29 +1206,32 @@ xy_dir_exist (const char *path)
// 也可以用 opendir() #include <dirent.h>
DWORD attr = GetFileAttributesA (dir);
bool result = false;
if (attr == INVALID_FILE_ATTRIBUTES)
{
// Q: 我们应该报错吗?
return false;
result = false;
}
else if (attr & FILE_ATTRIBUTE_DIRECTORY)
{
return true;
result = true;
}
else
{
return false;
result = false;
}
if (allocated_dir) free (allocated_dir);
return result;
#endif
}
else
{
int status = system (xy_2strcat ("test -d ", dir));
if (0==status)
return true;
else
return false;
char *tmp_cmd = xy_2strcat ("test -d ", dir);
int status = system (tmp_cmd);
free (tmp_cmd);
bool result = (0==status);
if (allocated_dir) free (allocated_dir);
return result;
}
return false;
@ -1219,13 +1254,17 @@ xy_normalize_path (const char *path)
if (xy_str_start_with (new, "~"))
{
new = xy_2strcat (xy_os_home, xy_str_delete_prefix (new, "~"));
char *tmp = xy_str_delete_prefix (new, "~");
char *joined = xy_2strcat (xy_os_home, tmp);
free (tmp);
xy_ptr_replace (&new, joined);
}
if (xy.on_windows)
return xy_str_gsub (new, "/", "\\");
else
return new;
{
xy_ptr_replace (&new, xy_str_gsub (new, "/", "\\"));
}
return new;
}
@ -1242,10 +1281,10 @@ xy_parent_dir (const char *path)
char *dir = xy_normalize_path (path);
/* 不管是否为Windows全部统一使用 / 作为路径分隔符,方便后续处理 */
dir = xy_str_gsub (dir, "\\", "/");
xy_ptr_replace (&dir, xy_str_gsub (dir, "\\", "/"));
if (xy_str_end_with (dir, "/"))
dir = xy_str_delete_suffix (dir, "/");
xy_ptr_replace (&dir, xy_str_delete_suffix (dir, "/"));
char *last = NULL;
@ -1259,17 +1298,24 @@ xy_parent_dir (const char *path)
/* Windows上重新使用 \ 作为路径分隔符 */
if (xy.on_windows)
return xy_str_gsub (dir, "/", "\\");
else
return dir;
{
xy_ptr_replace (&dir, xy_str_gsub (dir, "/", "\\"));
}
return dir;
}
/**
* @internal xy_init ()
*/
void
xy_detect_os ()
_xy_detect_os ()
{
// C:
/**
* Windows
*
* SystemDrive C:
*/
char *drive = getenv ("SystemDrive");
if (drive)
{
@ -1279,25 +1325,39 @@ xy_detect_os ()
if (d)
{
xy.on_windows = true;
xy.os_family = "windows";
closedir (d);
return;
}
}
/* 判断 Linux */
FILE *fp = fopen ("/proc/version", "r");
if (fp)
{
char buf[256] = {0};
fread (buf, 1, sizeof(buf) - 1, fp);
fread (buf, 1, sizeof (buf) - 1, fp);
fclose (fp);
if (strstr (buf, "Android"))
{
xy.on_android = true;
return;
}
else if (strstr (buf, "Linux"))
if (strstr (buf, "Linux"))
{
xy.on_linux = true;
xy.os_family = "unix";
return;
}
}
/**
* Android
*
* @consult https://android.googlesource.com/platform/system/core/+/refs/heads/main/rootdir/init.environ.rc.in
*/
char *android_env = getenv ("ANDROID_ROOT");
if (android_env)
{
if (xy_str_find (android_env, "/system").found)
{
xy.on_android = true;
xy.os_family = "unix";
return;
}
}
@ -1311,32 +1371,40 @@ xy_detect_os ()
if (d)
{
xy.on_macos = true;
xy.os_family = "unix";
closedir (d);
return;
}
}
/* 最后判断 BSD */
fp = popen ("uname -s", "r");
if (!fp)
if (fp)
{
if (opendir ("/etc/rc.d"))
char buf[256];
fgets (buf, sizeof (buf), fp);
pclose (fp);
if (strstr (buf, "BSD") != NULL)
{
closedir (d);
xy.on_bsd = true;
xy.os_family = "unix";
return;
}
}
else
{
char buf[256];
fgets (buf, sizeof (buf), fp);
pclose (fp);
if (strstr (buf, "BSD") != NULL)
xy.on_bsd = true;
DIR *bsd_dir = opendir ("/etc/rc.d");
if (bsd_dir)
{
closedir (bsd_dir);
xy.on_bsd = true;
xy.os_family = "unix";
return;
}
}
if (!(xy.on_windows || xy.on_linux || xy.on_android || xy.on_macos || xy.on_bsd))
xy_panic ("Unknown operating system");
xy_throw ("Unknown operating system");
}
@ -1355,7 +1423,7 @@ xy_use_utf8 ()
void
xy_init ()
{
xy_detect_os ();
_xy_detect_os ();
if (xy.on_windows)
xy.os_devnull = "nul";
@ -1445,7 +1513,7 @@ xy_seq_at (XySeq_t *seq, int n)
{
xy_cant_be_null (seq);
if (0 == n) xy_panic ("The index must begin from 1, not 0");
if (0 == n) xy_throw ("The index must begin from 1, not 0");
if (1 == n) return seq->first_item ? seq->first_item->data : NULL;

View File

@ -3,8 +3,8 @@
! -------------------------------------------------------------
! Doc Type : Markdown
! Doc Name : README.md
! Doc Authors : Aoran Zeng <ccmywish@qq.com>
! Contributors : Nil Null <nil@null.org>
! Doc Authors : 曾奥然 <ccmywish@qq.com>
! Contributors : Nil Null <nil@null.org>
! |
! Created On : <2025-06-15>
! Last Modified : <2025-06-16>

View File

@ -4,7 +4,7 @@
! Doc Type : Markdown
! Doc Name : BUILD.md
! Doc Authors : sanchuanhehe <wyihe5520@gmail.com>
! Contributors : Aoran Zeng <ccmywish@qq.com>
! Contributors : 曾奥然 <ccmywish@qq.com>
! |
! Created On : <2025-06-14>
! Last Modified : <2025-06-16>

View File

@ -4,7 +4,7 @@
! Doc Type : Markdown
! Doc Name : CI.md
! Doc Authors : sanchuanhehe <wyihe5520@gmail.com>
! Contributors : Aoran Zeng <ccmywish@qq.com>
! Contributors : 曾奥然 <ccmywish@qq.com>
! |
! Created On : <2025-06-14>
! Last Modified : <2025-06-16>

View File

@ -4,7 +4,7 @@
# --------------------------------------------------------------
# Build File : Makefile
# File Authors : sanchuanhehe <wyihe5520@gmail.com>
# Contributors : Aoran Zeng <ccmywish@qq.com>
# Contributors : 曾奥然 <ccmywish@qq.com>
# |
# Created On : <2025-06-14>
# Last Modified : <2025-06-16>

View File

@ -4,8 +4,8 @@
! Doc Type : Markdown
! Doc Name : README.md
! Doc Authors : sanchuanhehe <wyihe5520@gmail.com>
! | Aoran Zeng <ccmywish@qq.com>
! Contributors : Nil Null <nil@null.org>
! | 曾奥然 <ccmywish@qq.com>
! Contributors : Nil Null <nil@null.org>
! |
! Created On : <2025-06-14>
! Last Modified : <2025-06-16>

View File

@ -4,7 +4,7 @@
# --------------------------------------------------------------
# Test File : deb-installation-test.sh
# File Authors : sanchuanhehe <wyihe5520@gmail.com>
# Contributors : Aoran Zeng <ccmywish@qq.com>
# Contributors : 曾奥然 <ccmywish@qq.com>
# |
# Created On : <2025-06-14>
# Last Modified : <2025-06-16>

View File

@ -1,8 +1,15 @@
chsrc (0.2.3-1) unstable; urgency=medium
* v0.2.3 已发布
-- 曾奥然 <ccmywish@qq.com> Wed, 29 Oct 2025 11:29:05 +0800
chsrc (0.1.9-1) unstable; urgency=medium
* v0.1.9 已发布
-- Aoran Zeng <ccmywish@qq.com> Sun, 15 Jun 2025 13:32:50 +0800
-- 曾奥然 <ccmywish@qq.com> Sun, 15 Jun 2025 13:32:50 +0800
chsrc (0.0.1-1) unstable; urgency=medium

View File

@ -1,17 +1,17 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: chsrc
Upstream-Contact: Aoran Zeng <ccmywish@qq.com>
Upstream-Contact: 曾奥然 <ccmywish@qq.com>
Source: https://github.com/RubyMetric/chsrc
Files: *
Copyright: 2023-2025 Aoran Zeng <ccmywish@qq.com>
2023-2025 Heng Guo <2085471348@qq.com>
Copyright: 2023-2025 曾奥然 <ccmywish@qq.com>
2023-2025 郭恒 <2085471348@qq.com>
License: GPL-3+
Comment: The authors' names are indicated in each source code file's header.
Files: lib/xy.h
Copyright: 2023-2025 Aoran Zeng <ccmywish@qq.com>
2023-2025 Heng Guo <2085471348@qq.com>
Copyright: 2023-2025 曾奥然 <ccmywish@qq.com>
2023-2025 郭恒 <2085471348@qq.com>
License: MIT
Files: pkg/deb/debian/*

View File

@ -5,7 +5,7 @@
# deb File : postinst
# File Authors : sanchuanhehe <wyihe5520@gmail.com>
# Contributors : Nil Null <nil@null.org>
# |
# |
# Created On : <2025-06-14>
# Last Modified : <2025-06-16>
#

View File

@ -5,7 +5,7 @@
# deb File : prerm
# File Authors : sanchuanhehe <wyihe5520@gmail.com>
# Contributors : Nil Null <nil@null.org>
# |
# |
# Created On : <2025-06-14>
# Last Modified : <2025-06-16>
#

View File

@ -4,8 +4,8 @@
# --------------------------------------------------------------
# Build File : rules
# File Authors : sanchuanhehe <wyihe5520@gmail.com>
# | Aoran Zeng <ccmywish@qq.com>
# Contributors : Nil Null <nil@null.org>
# | 曾奥然 <ccmywish@qq.com>
# Contributors : Nil Null <nil@null.org>
# |
# Created On : <2025-06-14>
# Last Modified : <2025-06-20>

View File

@ -30,11 +30,10 @@
*
* ------------------------------------------------------------*/
#define Chsrc_Version "0.2.3"
#define Chsrc_Release_Date "2025/10/06"
#define Chsrc_Maintain_URL "https://github.com/RubyMetric/chsrc"
#define Chsrc_Maintain_URL2 "https://gitee.com/RubyMetric/chsrc"
#include "framework/version.h"
#include "framework/core.c"
#include "framework/chef.c"
@ -456,7 +455,8 @@ cli_print_version ()
{
char *version_string = "v" Chsrc_Version " (" Chsrc_Release_Date ")";
char *str = xy_str_gsub (RAWSTR_chsrc_for_v, "@ver@", version_string);
char *str = xy_str_gsub (CHINESE ? RAWSTR_chsrc_for_v_CHINESE : RAWSTR_chsrc_for_v_ENGLISH,
"@ver@", version_string);
println (str);
}

View File

@ -5,7 +5,7 @@
* File Authors : <ccmywish@qq.com>
* Contributors : BingChunMoLi <bingchunmoli@bingchunmoli.com>
* Created On : <2025-08-09>
* Last Modified : <2025-08-27>
* Last Modified : <2025-10-27>
*
* chef DSL: for chefs (recipe makers) to define a target
* ------------------------------------------------------------*/
@ -137,7 +137,7 @@ chef_set_sources_speed_measure_url_with_func (
if (src->url)
{
/* 为空时才修改 或者里面是脏数据 */
if (NULL==src->speed_measure_url || !chef_is_url (src->speed_measure_url))
if (NULL==src->speed_measure_url || !hp_is_url (src->speed_measure_url))
{
src->speed_measure_url = func (src->url, user_data);
}
@ -186,7 +186,7 @@ chef_allow_english (Target_t *target)
}
void
chef_forbid_english (Target_t *target)
chef_deny_english (Target_t *target)
{
xy_cant_be_null (target);
target->can_english = false;
@ -226,7 +226,7 @@ chef_allow_user_define (Target_t *target)
}
void
chef_forbid_user_define (Target_t *target)
chef_deny_user_define (Target_t *target)
{
xy_cant_be_null (target);

View File

@ -11,7 +11,7 @@
* | Mikachu2333 <mikachu.23333@zohomail.com>
* |
* Created On : <2023-08-29>
* Last Modified : <2025-09-29>
* Last Modified : <2025-10-30>
*
* chsrc framework
* ------------------------------------------------------------*/
@ -27,7 +27,7 @@
#include "xy.h"
#include "struct.h"
#include "mirror.c"
#include "chef-helper.c"
#include "helper.c"
#define App_Name "chsrc"
@ -511,7 +511,7 @@ chsrc_check_file (char *path)
int
query_mirror_exist (Source_t *sources, size_t size, char *target_name, char *input)
{
if (chef_is_url (input))
if (hp_is_url (input))
{
char *msg = ENGLISH ? "Using user-defined sources for this software is not supported at this time, please contact the developers to ask why or request support" : "暂不支持对该软件使用用户自定义源,请联系开发者询问原因或请求支持";
chsrc_error (msg);
@ -764,7 +764,7 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
}
else if (!provider_skip && provider_speed_url)
{
if (chef_is_url (provider_speed_url))
if (hp_is_url (provider_speed_url))
{
url = xy_strdup (provider_speed_url);
chsrc_debug ("m", xy_2strcat ("使用镜像站整体测速链接: ", url));
@ -777,7 +777,7 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
if (dedicated_speed_url)
{
if (chef_is_url (dedicated_speed_url))
if (hp_is_url (dedicated_speed_url))
{
url = xy_strdup (dedicated_speed_url);
has_dedicated_speed_url = true;
@ -863,6 +863,9 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
char *curl_result = measure_speed_for_url (url);
double speed = parse_and_say_curl_result (curl_result);
speed_records[i] = speed;
/* 释放 url 内存 */
if (url) free (url);
}
else
{
@ -1052,7 +1055,7 @@ chsrc_yield_source (Target_t *t, char *option)
{
source = t->sources[ProgStatus.leader_selected_index];
}
else if (chef_is_url (option))
else if (hp_is_url (option))
{
Source_t tmp = { &UserDefinedProvider, option };
source = tmp;
@ -1519,6 +1522,7 @@ chsrc_run_as_bash_file (const char *script_content)
char *cmd = xy_2strcat ("bash ", tmpfile);
chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure);
remove (tmpfile);
free (tmpfile); /* 释放 tmpfile 路径内存 */
}
@ -1539,6 +1543,7 @@ chsrc_run_as_sh_file (const char *script_content)
char *cmd = xy_2strcat ("sh ", tmpfile);
chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure);
remove (tmpfile);
free (tmpfile);
}
@ -1558,6 +1563,7 @@ chsrc_run_as_pwsh_file (const char *script_content)
char *cmd = xy_2strcat ("pwsh ", tmpfile);
chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure);
remove (tmpfile);
free (tmpfile);
}
@ -1745,7 +1751,7 @@ log_anyway:
}
/**
* @note `str`
* @note `str` `str`
*/
static void
chsrc_prepend_to_file (const char *str, const char *filename)
@ -1756,67 +1762,21 @@ chsrc_prepend_to_file (const char *str, const char *filename)
}
char *file = xy_normalize_path (filename);
char *dir = xy_parent_dir (file);
chsrc_ensure_dir (dir);
char *tmpfile_path = NULL;
FILE *output = chsrc_make_tmpfile ("prepend", ".txt", false, &tmpfile_path);
char *file_content = xy_file_read (file);
char *content = xy_2strcat (str, file_content);
if (!output)
FILE *f = fopen (file, "w");
if (f)
{
char *msg = ENGLISH ? xy_2strcat ("Create temp file before Write prepend failed ", file)
: xy_2strcat ("尝试在文件开头写入时创建临时文件失败:", file);
chsrc_error2 (msg);
exit (Exit_ExternalError);
fwrite (content, 1, strlen (content), f);
fclose (f);
}
/* 先写入要插入的内容 */
fprintf (output, "%s", str);
/* 如果原文件存在,复制其内容到临时文件 */
FILE *input = fopen (file, "r");
if (input)
else
{
fseek (input, 0, SEEK_END);
long file_size = ftell (input);
fseek (input, 0, SEEK_SET);
if (file_size > 0)
{
char *buffer = malloc (file_size);
if (buffer == NULL)
{
fclose (input);
fclose (output);
remove (tmpfile_path);
char *msg = ENGLISH ? "Memory allocation failed" : "内存分配失败";
chsrc_error2 (msg);
exit (Exit_ExternalError);
}
size_t bytes = fread (buffer, 1, file_size, input);
if (bytes > 0)
{
fwrite (buffer, 1, bytes, output);
}
free (buffer);
}
fclose (input);
}
fclose (output);
/* 删除原文件(如果存在) */
remove (file);
/* 将临时文件重命名为目标文件 */
if (rename (tmpfile_path, file) != 0)
{
unlink (tmpfile_path);
char *msg = ENGLISH ? xy_2strcat ("Write prepend failed to ", file)
: xy_2strcat ("在文件开头写入失败: ", file);
chsrc_error2 (msg);
exit (Exit_ExternalError);
chsrc_error2 ("文件打开失败");
exit (Exit_UserCause);
}
log_anyway:
@ -1849,6 +1809,7 @@ chsrc_overwrite_file (const char *str, const char *filename)
size_t ret = fwrite (str, len, 1, f);
if (ret != 1)
{
fclose (f);
char *msg = ENGLISH ? xy_2strcat ("Write failed to ", file)
: xy_2strcat ("写入文件失败: ", file);
chsrc_error2 (msg);

View File

@ -1,18 +1,18 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Name : chef-helper.c
* File Name : helper.c
* File Authors : <ccmywish@qq.com>
* Contributors : Nul None <nul@none.org>
* Created On : <2025-07-14>
* Last Modified : <2025-08-20>
* Last Modified : <2025-10-28>
*
* For chefs (recipe makers) and sometimes framewoker
* to do some work not releated to OS operations
* ------------------------------------------------------------*/
bool
chef_is_url (const char *str)
hp_is_url (const char *str)
{
return (xy_str_start_with (str, "http://") || xy_str_start_with (str, "https://"));
}
@ -21,7 +21,7 @@ chef_is_url (const char *str)
* @return
*/
char *
chef_remove_trailing_slash (char *str)
hp_remove_trailing_slash (char *str)
{
char *newstr = xy_strdup (str);
size_t len = strlen (newstr);
@ -34,7 +34,7 @@ chef_remove_trailing_slash (char *str)
* @return
*/
char *
chef_ensure_trailing_slash (char *str)
hp_ensure_trailing_slash (char *str)
{
size_t len = strlen (str);
if (len == 0 || str[len - 1] == '/')

View File

@ -10,7 +10,7 @@
* | BingChunMoLi <bingchunmoli@bingchunmoli.com>
* |
* Created On : <2023-08-29>
* Last Modified : <2025-08-27>
* Last Modified : <2025-10-07>
*
*
* ------------------------------------------------------------*/

23
src/framework/version.h Normal file
View File

@ -0,0 +1,23 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Name : version.h
* File Authors : <ccmywish@qq.com>
* | Mikachu2333 <mikachu.23333@zohomail.com>
* Contributors : Nil Null <nil@null.org>
* |
* Created On : <2025-10-10>
* Last Modified : <See 'Chsrc_Release_Date'>
*
*
* ------------------------------------------------------------*/
#define Chsrc_Version "0.2.3.4"
// 以下四个宏仅用于 resource/chsrc.rc
#define Chsrc_Version_Major 0
#define Chsrc_Version_Minor 2
#define Chsrc_Version_Patch 3
#define Chsrc_Version_Pre 4
#define Chsrc_Release_Date "2025/12/18"

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@
! Config Authors: 曾奥然 <ccmywish@qq.com>
! Contributors : Nil Null <nil@null.org>
! Created On : <2025-07-22>
! Last Modified : <2025-08-22>
! Last Modified : <2025-10-29>
! ---------------------------------------------------------- -->
# [rawstr4c] input for chsrc
@ -132,16 +132,36 @@ MAINTAIN:
## for `chsrc -v`
- name = `for__v`
- name = `for__v_CHINESE`
```
chsrc @ver@
Copyright (C) 2025 Aoran Zeng, Heng Guo
Copyright (C) 2023-2025 曾奥然, 郭恒
许可证 GPLv3+GNU GPL 第 3 版或更高版本 <https://gnu.org/licenses/gpl.html>
这是自由软件:您可以自由修改和分发它。
在法律允许的最大范围内,本软件按'原样'提供,不作任何明示或暗示的保证。
由作者曾奥然、郭恒协作者Mikachu2333、Happy Game 以及各位贡献者开发。(详见 chsrc-main.c, 或 `chsrc ls <target>`)
```
<br>
## for `chsrc -v -en`
- name = `for__v_ENGLISH`
```
chsrc @ver@
Copyright (C) 2023-2025 Aoran Zeng, Heng Guo
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Aoran Zeng, Heng Guo and contributors. (See chsrc-main.c)
Written by authors: Aoran Zeng, Heng Guo, collaborators: Mikachu2333, Happy Game, and contributors. (See chsrc-main.c, or `chsrc ls <target>`)
```
<br>

View File

@ -18,7 +18,7 @@ pl_clojure_prelude ()
chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_forbid_english(this);
chef_deny_english(this);
chef_allow_user_define(this);
def_sources_begin()

View File

@ -32,7 +32,7 @@ pl_go_prelude ()
chef_set_sauciers (this, 2, "@czyt", "@techoc");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_deny_english(this);
chef_allow_user_define(this);

View File

@ -18,7 +18,7 @@ pl_haskell_prelude ()
chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_deny_english(this);
chef_allow_user_define(this);
def_sources_begin()

View File

@ -18,7 +18,7 @@ pl_java_prelude ()
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_deny_english(this);
chef_allow_user_define(this);
// 阿里巴巴开源镜像站需要修改为此才能测速

View File

@ -25,7 +25,7 @@ pl_lua_prelude ()
chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_deny_english(this);
chef_allow_user_define(this);
def_sources_begin()

View File

@ -18,8 +18,8 @@ pl_nuget_prelude ()
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
def_sources_begin()
{&UpstreamProvider, "https://www.nuget.org/api/v3/", DelegateToUpstream},

View File

@ -18,7 +18,7 @@ pl_ocaml_prelude ()
chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_deny_english(this);
chef_allow_user_define(this);
def_sources_begin()

View File

@ -18,7 +18,7 @@ pl_php_prelude ()
chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_forbid_english(this);
chef_deny_english(this);
chef_allow_user_define(this);
def_sources_begin()

View File

@ -10,26 +10,36 @@ pl_perl_prelude ()
chef_prep_this (pl_perl, gs);
chef_set_created_on (this, "2023-09-31");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-08-21");
chef_set_last_updated (this, "2025-10-07");
chef_set_sources_last_updated (this, "2025-10-07");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@hezonglun");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 2, "@hezonglun", "@Mikachu2333");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_allow_user_define(this);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english (this);
chef_allow_user_define (this);
def_sources_begin()
{&UpstreamProvider, "https://www.cpan.org/", DelegateToUpstream},
{&Bfsu, "https://mirrors.bfsu.edu.cn/CPAN/", DelegateToMirror},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/CPAN/", DelegateToMirror},
{&Bjtu, "https://mirror.bjtu.edu.cn/cpan/", DelegateToMirror},
{&Hust, "https://mirrors.hust.edu.cn/CPAN/", DelegateToMirror},
{&Ali, "https://mirrors.aliyun.com/CPAN/", DelegateToMirror},
{&Lzuoss, "https://mirror.lzu.edu.cn/CPAN/", DelegateToMirror}
{&UpstreamProvider, "https://www.cpan.org/", FeedByPrelude},
{&MirrorZ, "https://mirrors.cernet.edu.cn/CPAN/", FeedByPrelude},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/CPAN/", FeedByPrelude},
{&Bfsu, "https://mirrors.bfsu.edu.cn/CPAN/", FeedByPrelude},
{&Cqu, "https://mirrors.cqu.edu.cn/CPAN/", FeedByPrelude},
{&Bjtu, "https://mirror.bjtu.edu.cn/cpan/", FeedByPrelude},
{&Nju, "https://mirrors.nju.edu.cn/CPAN/", FeedByPrelude},
{&Nyist, "https://mirror.nyist.edu.cn/CPAN/", FeedByPrelude},
{&Ustc, "https://mirrors.ustc.edu.cn/CPAN/", FeedByPrelude},
{&Sjtug_Siyuan, "https://mirror.sjtu.edu.cn/cpan/", FeedByPrelude},
{&Iscas, "https://mirror.iscas.ac.cn/CPAN/", FeedByPrelude},
{&Zju, "https://mirrors.zju.edu.cn/CPAN/", FeedByPrelude},
{&Lzuoss, "https://mirrors.lzu.edu.cn/CPAN/", FeedByPrelude},
{&Hust, "https://mirrors.hust.edu.cn/CPAN/", FeedByPrelude},
{&Ali, "https://mirrors.aliyun.com/CPAN/", FeedByPrelude}
def_sources_end()
chef_set_sources_speed_measure_url_with_postfix (this, "authors/id/D/DB/DBAURAIN/Bio-MUST-Apps-FortyTwo-0.213470.tar.gz");
}

View File

@ -8,7 +8,7 @@ char RAWSTR_pl_python_uv_config_source_content[] = "\x5b\x5b\x69\x6e\x64\x65\x78
char RAWSTR_pl_python_get_uv_config[] = "\x67\x72\x65\x70\x20\x2d\x41\x20\x32\x20\x27\x69\x6e\x64\x65\x78\x27\x20\x40\x66\x40\x20\x7c\x20\x73\x65\x64\x20\x2d\x6e\x20\x27\x73\x2f\x5e\x75\x72\x6c\x20\x3d\x20\x22\x5c\x28\x2e\x2a\x5c\x29\x22\x2f\x5c\x31\x2f\x70\x27";
char RAWSTR_pl_python_set_uv_config[] = "\x40\x73\x65\x64\x40\x20\x27\x2f\x5e\x5c\x5b\x5c\x5b\x69\x6e\x64\x65\x78\x5c\x5d\x5c\x5d\x24\x2f\x2c\x2f\x5e\x64\x65\x66\x61\x75\x6c\x74\x20\x3d\x20\x74\x72\x75\x65\x24\x2f\x7b\x73\x7c\x5e\x75\x72\x6c\x20\x3d\x20\x22\x2e\x2a\x22\x24\x7c\x75\x72\x6c\x20\x3d\x20\x22\x40\x75\x72\x6c\x40\x22\x7c\x7d\x27\x20\x40\x66\x40";
char RAWSTR_pl_python_set_uv_config[] = "\x40\x73\x65\x64\x40\x20\x27\x2f\x5e\x5c\x5b\x5c\x5b\x69\x6e\x64\x65\x78\x5c\x5d\x5c\x5d\x24\x2f\x2c\x2f\x5e\x64\x65\x66\x61\x75\x6c\x74\x20\x3d\x20\x74\x72\x75\x65\x24\x2f\x7b\x73\x7c\x5e\x75\x72\x6c\x20\x3d\x20\x22\x2e\x2a\x22\x24\x7c\x75\x72\x6c\x20\x3d\x20\x22\x40\x75\x72\x6c\x40\x22\x7c\x3b\x7d\x27\x20\x40\x66\x40";
char RAWSTR_pl_python_test_uv_if_set_source[] = "\x67\x72\x65\x70\x20\x2d\x71\x20\x27\x5e\x5c\x5b\x5c\x5b\x69\x6e\x64\x65\x78\x5d\x5d\x24\x27\x20\x40\x66\x40";

View File

@ -6,7 +6,7 @@
! | happy game <happygame1024@gmail.com>
! Contributors : Nil Null <nil@null.org>
! Created On : <2025-07-14>
! Last Modified : <2025-08-09>
! Last Modified : <2025-12-17>
! ---------------------------------------------------------- -->
# rawstr4c input for Python
@ -42,7 +42,7 @@ grep -A 2 'index' @f@ | sed -n 's/^url = "\(.*\)"/\1/p'
### Set uv config
```sh
@sed@ '/^\[\[index\]\]$/,/^default = true$/{s|^url = ".*"$|url = "@url@"|}' @f@
@sed@ '/^\[\[index\]\]$/,/^default = true$/{s|^url = ".*"$|url = "@url@"|;}' @f@
```

View File

@ -10,7 +10,7 @@ pl_python_uv_prelude (void)
chef_prep_this (pl_python_uv, gsr);
chef_set_created_on (this, "2024-12-11");
chef_set_last_updated (this, "2025-08-09");
chef_set_last_updated (this, "2025-12-17");
chef_set_sources_last_updated (this, "2025-08-09");
chef_set_chef (this, NULL);

View File

@ -18,7 +18,7 @@ pl_r_prelude ()
chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_deny_english(this);
chef_allow_user_define(this);
// 以下注释的是不含有bioconductor的镜像站我们在换cran的同时也直接帮助用户换bioconductor

View File

@ -54,7 +54,7 @@ bool
pl_ruby_remove_gem_source (const char *source)
{
char *cmd = NULL;
if (chef_is_url (source))
if (hp_is_url (source))
{
cmd = xy_2strcat ("gem sources -r ", source);
chsrc_run (cmd, RunOpt_Default);

View File

@ -18,7 +18,7 @@ pl_rust_cargo_prelude (void)
chef_set_sauciers (this, 1, "@happy-game");
chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_forbid_english (this);
chef_deny_english (this);
chef_allow_user_define (this);
@ -75,7 +75,6 @@ pl_rust_cargo_getsrc (char *option)
char *raw_content = xy_file_read (cargo_config_file);
char *formatted_content = xy_str_gsub (raw_content, " ", "");
formatted_content = xy_str_gsub (formatted_content, "'", "\"");
free (raw_content);
XyStrFindResult_t result_has_mirror = xy_str_find (formatted_content, "replace-with");
if (result_has_mirror.found)
@ -112,7 +111,6 @@ pl_write_rust_config (const char *path, const char *url)
char *content = RAWSTR_pl_rust_cargo_config;
content = xy_str_gsub (content, "@url@", url);
chsrc_overwrite_file (content, path);
free (content);
}
/**
@ -172,7 +170,6 @@ pl_rust_cargo_setsrc (char *option)
char *final_content = xy_str_gsub (raw_content, mirror_url, xy_2strcat ("sparse+", source.url));
chsrc_overwrite_file (final_content, cargo_config_file);
free (final_content);
goto finish;
}

View File

@ -21,7 +21,7 @@ pl_rust_rustup_prelude (void)
chef_set_sauciers (this, 2, "@Yangmoooo", "@Mikachu2333");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english (this);
chef_deny_english (this);
chef_allow_user_define(this);
def_sources_begin()

View File

@ -18,8 +18,8 @@ os_armbian_prelude ()
chef_set_sauciers (this, 2, "@ccmywish", "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);

View File

@ -10,7 +10,7 @@ os_debian_prelude ()
chef_prep_this (os_debian, gsr);
chef_set_created_on (this, "2023-09-02");
chef_set_last_updated (this, "2025-09-12");
chef_set_last_updated (this, "2025-11-09");
chef_set_sources_last_updated (this, "2025-07-11");
chef_set_chef (this, NULL);
@ -18,14 +18,14 @@ os_debian_prelude ()
chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);
def_sources_begin()
{&UpstreamProvider, "http://deb.debian.org/debian", FeedByPrelude},
{&MirrorZ, "https://mirrors.cernet.edu.cn/debian/", FeedByPrelude},
{&MirrorZ, "https://mirrors.cernet.edu.cn/debian", FeedByPrelude},
{&Ali, "https://mirrors.aliyun.com/debian", FeedByPrelude},
{&Volcengine, "https://mirrors.volces.com/debian", FeedByPrelude},
{&Bfsu, "https://mirrors.bfsu.edu.cn/debian", FeedByPrelude},

View File

@ -18,8 +18,8 @@ os_kali_prelude ()
chef_set_sauciers (this, 2, "@Yangmoooo", "@happy-game");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_linuxlite_prelude ()
chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_linuxmint_prelude ()
chef_set_sauciers (this, 1, "@happy-game");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
/* @note 实际上镜像站里的内容和Ubuntu的不太一样 */

View File

@ -18,8 +18,8 @@ os_ros_prelude ()
chef_set_sauciers (this, 2, "@ccmywish", "@zouri");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, "该换源方案中URL存在拼凑因此不能手动使用某URL来换源", "In this switching method, URLs are constructed, so manual URL specification is not supported");

View File

@ -20,8 +20,8 @@ os_raspberrypi_prelude ()
chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_termux_prelude ()
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, "该 recipe 存在对应的 bootstrapper", "This recipe has a corresponding bootstrapper");

View File

@ -20,8 +20,8 @@ os_trisquel_prelude ()
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);

View File

@ -19,8 +19,8 @@ os_ubuntu_prelude ()
chef_set_sauciers (this, 1, "@XUANJI233");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_deepin_prelude ()
chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);

View File

@ -21,8 +21,8 @@ os_openkylin_prelude ()
chef_set_sauciers (this, 1, "@ccmywish");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);

View File

@ -19,7 +19,7 @@ os_alpine_prelude ()
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_allow_english(this);
chef_forbid_user_define(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_freebsd_prelude ()
chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
// 2023-09-24: 以下三个USTC, NJU, Netease 均维护了 freebsd-pkg freebsd-ports

View File

@ -19,8 +19,8 @@ os_netbsd_prelude ()
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
def_sources_begin()
{&UpstreamProvider, "http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/", DelegateToUpstream},
@ -66,7 +66,7 @@ os_netbsd_setsrc (char *option)
char *vercmd = "cat /etc/os-release | grep \"VERSION=\" | grep -Po \"[8-9].[0-9]+\"";
char *version = xy_run (vercmd, 0);
char *url = xy_strcat (5, chef_ensure_trailing_slash (source.url), arch, "/", version, "/All");
char *url = xy_strcat (5, hp_ensure_trailing_slash (source.url), arch, "/", version, "/All");
chsrc_overwrite_file (url, "/usr/pkg/etc/pkgin/repositories.conf");
chsrc_conclude (&source);

View File

@ -18,8 +18,8 @@ os_openbsd_prelude ()
chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
def_sources_begin()
{&UpstreamProvider, "https://cdn.openbsd.org/pub/OpenBSD/", DelegateToUpstream},

View File

@ -19,7 +19,7 @@ os_gentoo_prelude ()
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_allow_english(this);
chef_forbid_user_define(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);

View File

@ -19,7 +19,7 @@ os_solus_prelude ()
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_deny_english(this);
chef_allow_user_define(this);
chef_set_note(this, NULL, NULL);

View File

@ -18,7 +18,7 @@ os_voidlinux_prelude ()
chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_deny_english(this);
chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_almalinux_prelude ()
chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_anolis_prelude ()
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_fedora_prelude ()
chef_set_sauciers (this, 1, "@ccmywish");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_rockylinux_prelude ()
chef_set_sauciers (this, 1, "@happy-game");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
def_sources_begin()
{&UpstreamProvider, "https://dl.rockylinux.org", DelegateToUpstream},

View File

@ -18,8 +18,8 @@ os_openeuler_prelude ()
chef_set_sauciers (this, 3, "@ccmywish", "@Yangmoooo", "@happy-game");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_opensuse_prelude ()
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);

View File

@ -13,7 +13,7 @@ os_arch_prelude ()
chef_prep_this (os_arch, gs);
chef_set_created_on (this, "2023-09-05");
chef_set_last_updated (this, "2025-08-10");
chef_set_last_updated (this, "2025-10-30");
chef_set_sources_last_updated (this, "2025-06-20");
chef_set_chef (this, "@happy-game");
@ -21,8 +21,8 @@ os_arch_prelude ()
chef_set_sauciers (this, 2, "@happy-game", "@Young-Lord");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note (this,
"可额外使用 chsrc set archlinuxcn 来更换 Arch Linux CN Repository 源",
@ -78,12 +78,12 @@ os_arch_setsrc (char *option)
if (strncmp(arch, "x86_64", 6)==0)
{
is_x86 = true;
to_write = xy_strcat (3, "Server = ", source.url, "/$repo/os/$arch");
to_write = xy_strcat (3, "Server = ", source.url, "/$repo/os/$arch\n");
}
else
{
is_x86 = false;
to_write = xy_strcat (3, "Server = ", source.url, "arm/$arch/$repo");
to_write = xy_strcat (3, "Server = ", source.url, "arm/$arch/$repo\n");
}
/* 配置文件中,越前面的优先级越高 */
@ -124,8 +124,8 @@ os_archlinuxcn_prelude ()
chef_set_sauciers (this, 2, "@happy-game", "@Young-Lord");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note (this,
"可额外使用 chsrc set arch 来更换 Arch Linux 源",

View File

@ -18,8 +18,8 @@ os_msys2_prelude ()
chef_set_sauciers (this, 2, "@ccmywish", "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
def_sources_begin()
{&UpstreamProvider, "https://mirror.msys2.org/", DelegateToUpstream},

View File

@ -17,8 +17,8 @@ os_manjaro_prelude ()
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
def_sources_begin()
{&UpstreamProvider, NULL, DelegateToUpstream}

View File

@ -73,10 +73,10 @@ void
chef_allow_local_mode (this, PartiallyCan, "具体说明是否支持项目级换源...", "Tell users the local mode support");
// chef_allow_english(this); // 项目是否支持英文
chef_forbid_english(this);
chef_deny_english(this);
// chef_allow_user_define(this); // 是否支持用户自定义镜像源
chef_forbid_user_define(this);
chef_deny_user_define(this);
chef_set_note ("中文备注说明...", "English note...");

View File

@ -20,8 +20,8 @@ wr_anaconda_prelude ()
chef_set_sauciers (this, 2, "@Yangmoooo", "@xyx1926885268");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
def_sources_begin()
{&UpstreamProvider, "https://repo.anaconda.com", DelegateToUpstream},

View File

@ -19,7 +19,7 @@ wr_cocoapods_prelude ()
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_deny_english(this);
chef_allow_user_define(this);
def_sources_begin()

View File

@ -35,7 +35,7 @@ wr_docker_prelude ()
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_deny_english(this);
chef_allow_user_define(this);
def_sources_begin()

View File

@ -25,8 +25,8 @@ wr_emacs_prelude ()
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note (this, "Emacs用户往往只需要一次性换源只会极少次调用 chsrc我们只给用户提供文档",
"Emacs users typically only need to switch sources once and rarely call chsrc, so we only provide documentation to users");

View File

@ -18,7 +18,7 @@ wr_flatpak_prelude ()
chef_set_sauciers (this, 1, "@jialinlvcn");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_deny_english(this);
chef_allow_user_define(this);
chef_set_note (this, "对Flathub目标进行测速的文件非常小测速效果严重失真若你知道可供测速的URL欢迎参与贡献: chsrc issue",

View File

@ -18,8 +18,8 @@ wr_guix_prelude ()
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note (this, "目前只有一个源, guixcn 的源不知道是否可用",
"Currently only one source available, guixcn source availability unknown");

View File

@ -21,7 +21,7 @@ wr_homebrew_prelude ()
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_allow_english(this);
chef_forbid_user_define(this);
chef_deny_user_define(this);
chef_set_note (this, "该换源通过写入环境变量实现若多次换源请手动清理profile文件",
"This source switching is implemented by writing environment variables. If switching sources multiple times, please manually clean the profile file");

View File

@ -18,8 +18,8 @@ wr_nix_prelude ()
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_forbid_user_define(this);
chef_deny_english(this);
chef_deny_user_define(this);
def_sources_begin()
{&UpstreamProvider, "https://channels.nixos.org/", DelegateToUpstream},

View File

@ -20,7 +20,7 @@ wr_tex_prelude ()
chef_set_sauciers (this, 1, "@Mikachu2333");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
chef_deny_english(this);
chef_allow_user_define(this);
def_sources_begin()

View File

@ -17,7 +17,7 @@ wr_winget_prelude ()
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@Mikachu2333");
chef_forbid_english(this);
chef_deny_english(this);
chef_allow_user_define(this);
def_sources_begin()

48
src/resource/chsrc.rc Normal file
View File

@ -0,0 +1,48 @@
// chsrc.rc - Windows Resource Script
// SPDX-License-Identifier: GPL-3.0-or-later
#include <windows.h>
#include "../framework/version.h"
// 图标资源
IDI_ICON1 ICON DISCARDABLE "logo.ico"
// 版本信息
VS_VERSION_INFO VERSIONINFO
FILEVERSION Chsrc_Version_Major,Chsrc_Version_Minor,Chsrc_Version_Patch,Chsrc_Version_Pre
// 经实验,该值会被下面的 ProductVersion 替换
// PRODUCTVERSION Chsrc_Version_Major,Chsrc_Version_Minor,Chsrc_Version_Patch,Chsrc_Version_Pre
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "RubyMetric"
VALUE "FileDescription", "Change Source everywhere for every software"
// 经实验,该值会被上面的 FILEVERSION 替换
// VALUE "FileVersion", Chsrc_Version
VALUE "InternalName", "chsrc"
VALUE "LegalCopyright", "Copyright (c) 2023-2025 RubyMetric"
VALUE "OriginalFilename", "chsrc.exe"
VALUE "ProductName", "chsrc"
VALUE "ProductVersion", Chsrc_Version
VALUE "Comments", "Released on " Chsrc_Release_Date " (GPLv3+)"
VALUE "LegalTrademarks", "RubyMetric"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0804, 1200, 0x0409, 1200 // 简体中文和英语
END
END

BIN
src/resource/logo.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

@ -2,11 +2,11 @@
# ---------------------------------------------------------------
# Test File : cli.pl
# Test Authors : 曾奥然 <ccmywish@qq.com>
# Contributors : Nil Null <nil@null.org>
# Contributors : Nil Null <nil@null.org>
# Created On : <2024-06-05>
# Last Modified : <2025-09-27>
# Last Modified : <2025-10-29>
#
# 测试 chsrc 可执行文件
# 测试 chsrc 可执行文件
# ---------------------------------------------------------------
=encoding utf8
@ -62,11 +62,16 @@ use open qw(:std :encoding(UTF-8));
my $CHSRC = ($^O eq 'MSWin32') ? '.\chsrc' : './chsrc';
my $version_str_cn = qr|chsrc .*\n\nCopyright .*\n许可证 GPLv3\+GNU GPL 第 3 版或更高版本|;
like `$CHSRC -v`, $version_str_cn, 'chsrc -v';
like `$CHSRC --version`, $version_str_cn, 'chsrc --version';
like `$CHSRC version`, $version_str_cn, 'chsrc version';
my $version_str = qr|chsrc .*\nCopyright .*\nLicense GPLv3\+: GNU GPL version 3 or later|;
like `$CHSRC -v`, $version_str, 'chsrc -v';
like `$CHSRC --version`, $version_str, 'chsrc --version';
like `$CHSRC version`, $version_str, 'chsrc version';
my $version_str_en = qr|chsrc .*\n\nCopyright .*\nLicense GPLv3\+: GNU GPL version 3 or later|;
like `$CHSRC -v -en`, $version_str_en, 'chsrc -v -en';
like `$CHSRC -en -v`, $version_str_en, 'chsrc -en -v';
like `$CHSRC --version -en`, $version_str_en, 'chsrc --version -en';
like `$CHSRC version -en`, $version_str_en, 'chsrc version -en';
my $help_str = qr/^ (help|list|get|set|reset)/m;
like `$CHSRC -h`, $help_str, 'chsrc -h';

View File

@ -3,9 +3,9 @@
! -------------------------------------------------------------
! Doc Type : Markdown
! Doc Name : (Tools Introduction).md
! Doc Authors : Aoran Zeng <ccmywish@qq.com>
! | xuan <wick.dynex@qq.com>
! Contributors : ChatGPT <https://chatgpt.com>
! Doc Authors : 曾奥然 <ccmywish@qq.com>
! | xuan <wick.dynex@qq.com>
! Contributors : ChatGPT <https://chatgpt.com>
! |
! Created On : <2024-10-25>
! Last Modified : <2025-07-21>