Skip to content

Commit fed3498

Browse files
committed
Rename to helper.c
1 parent fd309e7 commit fed3498

File tree

6 files changed

+17
-16
lines changed

6 files changed

+17
-16
lines changed

doc/10-如何编写recipe.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
! Contributors : Nul None <nul@none.org>
88
! |
99
! Created On : <2024-08-19>
10-
! Last Modified : <2025-08-22>
10+
! Last Modified : <2025-10-28>
1111
! ---------------------------------------------------------- -->
1212

1313
# Write A Recipe Even If You Don't Know C
@@ -89,7 +89,8 @@
8989

9090
1. `framework/core.c` 中以 `chsrc_` 开头的所有函数或宏
9191
2. `xy.h` 中以 `xy_` 开头的所有函数或宏
92-
3. `chec.c` `chef-helper.c` 中以 `chef_` 开头的所有函数或宏
92+
3. `chec.c` 中以 `chef_` 开头的所有函数或宏
93+
4. `helper.c` 中以 `hp_` 开头的所有函数或宏
9394

9495
一个简单的方法是,在 VS Code 中按快捷键 `Ctrl-T` 搜索上述三种前缀
9596

src/framework/chef.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ chef_set_sources_speed_measure_url_with_func (
137137
if (src->url)
138138
{
139139
/* 为空时才修改 或者里面是脏数据 */
140-
if (NULL==src->speed_measure_url || !chef_is_url (src->speed_measure_url))
140+
if (NULL==src->speed_measure_url || !hp_is_url (src->speed_measure_url))
141141
{
142142
src->speed_measure_url = func (src->url, user_data);
143143
}

src/framework/core.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* | Mikachu2333 <mikachu.23333@zohomail.com>
1212
* |
1313
* Created On : <2023-08-29>
14-
* Last Modified : <2025-09-29>
14+
* Last Modified : <2025-10-28>
1515
*
1616
* chsrc framework
1717
* ------------------------------------------------------------*/
@@ -27,7 +27,7 @@
2727
#include "xy.h"
2828
#include "struct.h"
2929
#include "mirror.c"
30-
#include "chef-helper.c"
30+
#include "helper.c"
3131

3232
#define App_Name "chsrc"
3333

@@ -511,7 +511,7 @@ chsrc_check_file (char *path)
511511
int
512512
query_mirror_exist (Source_t *sources, size_t size, char *target_name, char *input)
513513
{
514-
if (chef_is_url (input))
514+
if (hp_is_url (input))
515515
{
516516
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" : "暂不支持对该软件使用用户自定义源,请联系开发者询问原因或请求支持";
517517
chsrc_error (msg);
@@ -764,7 +764,7 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
764764
}
765765
else if (!provider_skip && provider_speed_url)
766766
{
767-
if (chef_is_url (provider_speed_url))
767+
if (hp_is_url (provider_speed_url))
768768
{
769769
url = xy_strdup (provider_speed_url);
770770
chsrc_debug ("m", xy_2strcat ("使用镜像站整体测速链接: ", url));
@@ -777,7 +777,7 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
777777

778778
if (dedicated_speed_url)
779779
{
780-
if (chef_is_url (dedicated_speed_url))
780+
if (hp_is_url (dedicated_speed_url))
781781
{
782782
url = xy_strdup (dedicated_speed_url);
783783
has_dedicated_speed_url = true;
@@ -1055,7 +1055,7 @@ chsrc_yield_source (Target_t *t, char *option)
10551055
{
10561056
source = t->sources[ProgStatus.leader_selected_index];
10571057
}
1058-
else if (chef_is_url (option))
1058+
else if (hp_is_url (option))
10591059
{
10601060
Source_t tmp = { &UserDefinedProvider, option };
10611061
source = tmp;
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/** ------------------------------------------------------------
22
* SPDX-License-Identifier: GPL-3.0-or-later
33
* -------------------------------------------------------------
4-
* File Name : chef-helper.c
4+
* File Name : helper.c
55
* File Authors : 曾奥然 <ccmywish@qq.com>
66
* Contributors : Nul None <nul@none.org>
77
* Created On : <2025-07-14>
8-
* Last Modified : <2025-08-20>
8+
* Last Modified : <2025-10-28>
99
*
1010
* For chefs (recipe makers) and sometimes framewoker
1111
* to do some work not releated to OS operations
1212
* ------------------------------------------------------------*/
1313

1414
bool
15-
chef_is_url (const char *str)
15+
hp_is_url (const char *str)
1616
{
1717
return (xy_str_start_with (str, "http://") || xy_str_start_with (str, "https://"));
1818
}
@@ -21,7 +21,7 @@ chef_is_url (const char *str)
2121
* @return 一律返回新字符串
2222
*/
2323
char *
24-
chef_remove_trailing_slash (char *str)
24+
hp_remove_trailing_slash (char *str)
2525
{
2626
char *newstr = xy_strdup (str);
2727
size_t len = strlen (newstr);
@@ -34,7 +34,7 @@ chef_remove_trailing_slash (char *str)
3434
* @return 一律返回新字符串
3535
*/
3636
char *
37-
chef_ensure_trailing_slash (char *str)
37+
hp_ensure_trailing_slash (char *str)
3838
{
3939
size_t len = strlen (str);
4040
if (len == 0 || str[len - 1] == '/')

src/recipe/lang/Ruby/Ruby.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ bool
5454
pl_ruby_remove_gem_source (const char *source)
5555
{
5656
char *cmd = NULL;
57-
if (chef_is_url (source))
57+
if (hp_is_url (source))
5858
{
5959
cmd = xy_2strcat ("gem sources -r ", source);
6060
chsrc_run (cmd, RunOpt_Default);

src/recipe/os/BSD/NetBSD.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ os_netbsd_setsrc (char *option)
6666
char *vercmd = "cat /etc/os-release | grep \"VERSION=\" | grep -Po \"[8-9].[0-9]+\"";
6767
char *version = xy_run (vercmd, 0);
6868

69-
char *url = xy_strcat (5, chef_ensure_trailing_slash (source.url), arch, "/", version, "/All");
69+
char *url = xy_strcat (5, hp_ensure_trailing_slash (source.url), arch, "/", version, "/All");
7070
chsrc_overwrite_file (url, "/usr/pkg/etc/pkgin/repositories.conf");
7171

7272
chsrc_conclude (&source);

0 commit comments

Comments
 (0)