Use chef_ prefix

This commit is contained in:
Aoran Zeng 2025-07-14 14:02:17 +08:00
parent fac71e0dcb
commit 681ea40cee
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
4 changed files with 13 additions and 10 deletions

View File

@ -7,7 +7,7 @@
! Contributors : Nul None <nul@none.org>
! |
! Created On : <2024-08-19>
! Last Modified : <2025-03-06>
! Last Modified : <2025-07-14>
! ---------------------------------------------------------- -->
# Write A Recipe Even If You Don't Know C
@ -23,7 +23,7 @@
1. 本项目采用 `GPLv3+` 协议,是真正的**自由软件**,而非仅仅是开源软件
2. 代码规范灵活遵循 `GNU` 标准(若标准干扰了可维护性,则并不采纳)
3. 高度模块化,目录结构清晰易懂
4. 极小依赖,极易构建,只需要 `GCC``Clang` 即可编译
4. 极小依赖,极易构建,只需要 `GCC``Clang` 即可编译 (`make``just`可简化,但不是必需的)
5. 易于将 `shell` 脚本转换为等价的 `recipe`
6. 已有大量 `recipe` 可提供参考,并提供了 [recipe template] 供直接使用
7. 提供持续关注镜像站可用性的协作平台:
@ -83,6 +83,9 @@
1. `framework/core.c` 中以 `chsrc_` 开头的所有函数或宏
2. `xy.h` 中以 `xy_` 开头的所有函数或宏
3. `chec.h` 中以 `chef_` 开头的所有函数或宏
一个简单的方法是,在 VS Code 中按快捷键 `Ctrl-T` 搜索上述三种前缀
7. 在 `recipe/menu.c` 中添加用户可以使用的 `target` 别名

View File

@ -14,7 +14,7 @@
#pragma once
bool
is_url (const char *str)
chef_is_url (const char *str)
{
return (xy_str_start_with (str, "http://") || xy_str_start_with (str, "https://"));
}

View File

@ -451,7 +451,7 @@ chsrc_check_file (char *path)
int
query_provider_exist (Source_t *sources, size_t size, char *target, char *input)
{
if (is_url (input))
if (chef_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);
@ -706,7 +706,7 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
}
else if (!provider_skip && provider_speed_url)
{
if (is_url(provider_speed_url))
if (chef_is_url (provider_speed_url))
{
url = xy_strdup (provider_speed_url);
chsrc_debug ("m", xy_2strjoin ("使用镜像站整体测速链接: ", url));
@ -719,7 +719,7 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
if (dedicated_speed_url)
{
if (is_url(dedicated_speed_url))
if (chef_is_url (dedicated_speed_url))
{
url = xy_strdup (dedicated_speed_url);
has_dedicated_speed_url = true;
@ -843,7 +843,7 @@ sources_prepare_speedurl_with_postfix (Source_t sources[], int n, char *postfix)
if (src->url)
{
/* 为空时才修改 或者里面是脏数据 */
if (NULL==src->speed_measure_url || !is_url(src->speed_measure_url))
if (NULL==src->speed_measure_url || !chef_is_url (src->speed_measure_url))
src->speed_measure_url = xy_2strjoin (src->url, postfix);
}
}
@ -1010,7 +1010,7 @@ source_has_empty_url (Source_t *source)
{ \
source = for_what##_sources[ProgStatus.leader_selected_index]; \
} \
else if (is_url (option)) \
else if (chef_is_url (option)) \
{ \
Source_t __tmp = { &UserDefinedProvider, option }; \
source = __tmp; \
@ -1427,7 +1427,7 @@ chsrc_append_to_file (const char *str, const char *filename)
if (NULL==f)
{
char *msg = ENGLISH ? xy_2strjoin ("Unable to open file to write: ", file)
: xy_2strjoin ("无法打开文件以写入: ", file);
: xy_2strjoin ("无法打开文件以写入: ", file);
chsrc_error2 (msg);
exit (Exit_UserCause);
}

View File

@ -56,7 +56,7 @@ void
pl_ruby_remove_gem_source (const char *source)
{
char *cmd = NULL;
if (is_url (source))
if (chef_is_url (source))
{
cmd = xy_2strjoin ("gem sources -r ", source);
chsrc_run (cmd, RunOpt_Default);