diff --git a/doc/10-如何编写recipe.md b/doc/10-如何编写recipe.md index af88c70..8dbf5ad 100644 --- a/doc/10-如何编写recipe.md +++ b/doc/10-如何编写recipe.md @@ -7,7 +7,7 @@ ! Contributors : Nul None ! | ! 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` 搜索上述三种前缀 diff --git a/src/framework/chef.c b/src/framework/chef.c index 9291ad5..82a768f 100644 --- a/src/framework/chef.c +++ b/src/framework/chef.c @@ -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); } diff --git a/src/framework/core.c b/src/framework/core.c index ddbb9b0..90ea5ad 100644 --- a/src/framework/core.c +++ b/src/framework/core.c @@ -11,7 +11,7 @@ * | Mikachu2333 * | * Created On : <2023-08-29> - * Last Modified : <2025-09-29> + * Last Modified : <2025-10-28> * * 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; @@ -1055,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; diff --git a/src/framework/chef-helper.c b/src/framework/helper.c similarity index 84% rename from src/framework/chef-helper.c rename to src/framework/helper.c index c513aa1..b84d292 100644 --- a/src/framework/chef-helper.c +++ b/src/framework/helper.c @@ -1,18 +1,18 @@ /** ------------------------------------------------------------ * SPDX-License-Identifier: GPL-3.0-or-later * ------------------------------------------------------------- - * File Name : chef-helper.c + * File Name : helper.c * File Authors : 曾奥然 * Contributors : Nul None * 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] == '/') diff --git a/src/recipe/lang/Ruby/Ruby.c b/src/recipe/lang/Ruby/Ruby.c index 81bd5a4..a7ab47d 100644 --- a/src/recipe/lang/Ruby/Ruby.c +++ b/src/recipe/lang/Ruby/Ruby.c @@ -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); diff --git a/src/recipe/os/BSD/NetBSD.c b/src/recipe/os/BSD/NetBSD.c index 6c4d03d..54d99fc 100644 --- a/src/recipe/os/BSD/NetBSD.c +++ b/src/recipe/os/BSD/NetBSD.c @@ -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);