Keep unexposed functions inner

This commit is contained in:
Aoran Zeng 2024-08-19 11:42:31 +08:00
parent 4e349aa583
commit 51d08a5746
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
2 changed files with 33 additions and 33 deletions

View File

@ -84,7 +84,7 @@ chsrc_note2 (const char* str)
* @translation Done * @translation Done
*/ */
void void
chsrc_log_check_result (const char *check_what, const char *check_type, bool exist) log_check_result (const char *check_what, const char *check_type, bool exist)
{ {
char *chk_msg = NULL; char *chk_msg = NULL;
char *not_exist_msg = NULL; char *not_exist_msg = NULL;
@ -121,7 +121,7 @@ chsrc_log_check_result (const char *check_what, const char *check_type, bool exi
* @translation Done * @translation Done
*/ */
void void
chsrc_log_cmd_result (bool result, int ret_code) log_cmd_result (bool result, int ret_code)
{ {
char *run_msg = NULL; char *run_msg = NULL;
char *succ_msg = NULL; char *succ_msg = NULL;
@ -185,12 +185,12 @@ query_program_exist (char *check_cmd, char *prog_name)
if (0 != ret) if (0 != ret)
{ {
// xy_warn (xy_strjoin(4, "× 命令 ", progname, " 不存在,", buf)); // xy_warn (xy_strjoin(4, "× 命令 ", progname, " 不存在,", buf));
chsrc_log_check_result (prog_name, msg, false); log_check_result (prog_name, msg, false);
return false; return false;
} }
else else
{ {
chsrc_log_check_result (prog_name, msg, true); log_check_result (prog_name, msg, true);
return true; return true;
} }
} }
@ -232,12 +232,12 @@ chsrc_check_file (char *path)
{ {
if (xy_file_exist (path)) if (xy_file_exist (path))
{ {
chsrc_log_check_result (path, "文件", true); log_check_result (path, "文件", true);
return true; return true;
} }
else else
{ {
chsrc_log_check_result (path, "文件", false); log_check_result (path, "文件", false);
return false; return false;
} }
} }
@ -340,7 +340,7 @@ to_human_readable_speed (double speed)
* @return -1 * @return -1
*/ */
double double
test_speed_url (const char *url) measure_speed (const char *url)
{ {
char *time_sec = "6"; char *time_sec = "6";
@ -471,7 +471,7 @@ auto_select_ (SourceInfo *sources, size_t size, const char *target_name)
printf ("%s", xy_strjoin (3, test_msg, src.mirror->site , " ... ")); printf ("%s", xy_strjoin (3, test_msg, src.mirror->site , " ... "));
fflush (stdout); fflush (stdout);
speed = test_speed_url (url); speed = measure_speed (url);
} }
speeds[i] = speed; speeds[i] = speed;
} }
@ -781,12 +781,12 @@ chsrc_run (const char *cmd, int run_option)
{ {
if (! (RunOpt_Dont_Notify_On_Success & run_option)) if (! (RunOpt_Dont_Notify_On_Success & run_option))
{ {
chsrc_log_cmd_result (true, status); log_cmd_result (true, status);
} }
} }
else else
{ {
chsrc_log_cmd_result (false, status); log_cmd_result (false, status);
if (! (run_option & RunOpt_Dont_Abort_On_Failure)) if (! (run_option & RunOpt_Dont_Abort_On_Failure))
{ {
chsrc_error ("关键错误,强制结束"); chsrc_error ("关键错误,强制结束");

View File

@ -134,13 +134,13 @@ cli_print_available_mirrors ()
{ {
chsrc_info ("支持以下镜像站"); chsrc_info ("支持以下镜像站");
chsrc_info ("下方 code 列,可用于指定使用某镜像站,请使用 chsrc set <target> <code>\n"); chsrc_info ("下方 code 列,可用于指定使用某镜像站,请使用 chsrc set <target> <code>\n");
printf (" %-13s%-35s%-38s", "code", "镜像站简写", "镜像站URL"); puts ("镜像站名称"); printf (" %-13s%-35s%-38s", "code", "镜像站简写", "镜像站URL"); say ("镜像站名称");
puts ("------- ----------- ------------------------------------- ---------------------"); say ("------- ----------- ------------------------------------- ---------------------");
// puts ("-------------------------------------------------------------------------------------------------"); // say ("-------------------------------------------------------------------------------------------------");
for (int i = 0; i < xy_arylen (available_mirrors); i++) for (int i = 0; i < xy_arylen (available_mirrors); i++)
{ {
MirrorSite* mir = available_mirrors[i]; MirrorSite* mir = available_mirrors[i];
printf ("%-14s%-18s%-41s ", mir->code, mir->abbr, mir->site); puts (mir->name); printf ("%-14s%-18s%-41s ", mir->code, mir->abbr, mir->site); say (mir->name);
} }
} }
@ -165,15 +165,15 @@ cli_print_supported_targets_ (const char ***array, size_t size)
void void
cli_print_supported_targets () cli_print_supported_targets ()
{ {
chsrc_info ("支持对以下目标换源 (同一行表示这几个命令兼容)"); puts(""); chsrc_info ("支持对以下目标换源 (同一行表示这几个命令兼容)"); br();
puts (xy_str_to_blue ("编程语言开发")); say (to_blue ("编程语言开发"));
puts ("-------------------------"); say ("-------------------------");
cli_print_supported_targets_ (pl_packagers, xy_arylen(pl_packagers)); cli_print_supported_targets_ (pl_packagers, xy_arylen(pl_packagers));
puts (xy_str_to_blue ("操作系统")); say (to_blue ("操作系统"));
puts ("-------------------------"); say ("-------------------------");
cli_print_supported_targets_ (os_systems, xy_arylen(os_systems)); cli_print_supported_targets_ (os_systems, xy_arylen(os_systems));
puts (xy_str_to_blue ("软件")); say (to_blue ("软件"));
puts ("-------------------------"); say ("-------------------------");
cli_print_supported_targets_ (wr_softwares, xy_arylen(wr_softwares)); cli_print_supported_targets_ (wr_softwares, xy_arylen(wr_softwares));
} }
@ -188,14 +188,14 @@ void
cli_print_supported_os () cli_print_supported_os ()
{ {
chsrc_info ("支持对以下操作系统换源 (同一行表示这几个命令兼容)"); chsrc_info ("支持对以下操作系统换源 (同一行表示这几个命令兼容)");
cli_print_supported_targets_ (os_systems, xy_arylen(os_systems)); cli_print_supported_targets_ (os_systems, xy_arylen(os_systems));
} }
void void
cli_print_supported_wr () cli_print_supported_wr ()
{ {
chsrc_info ("支持对以下软件换源 (同一行表示这几个命令兼容)"); chsrc_info ("支持对以下软件换源 (同一行表示这几个命令兼容)");
cli_print_supported_targets_ (wr_softwares, xy_arylen(wr_softwares)); cli_print_supported_targets_ (wr_softwares, xy_arylen(wr_softwares));
} }
@ -215,7 +215,7 @@ cli_print_target_available_sources (SourceInfo sources[], size_t size)
src.url = "Please help to add the upstream url!"; src.url = "Please help to add the upstream url!";
} }
printf ("%-14s%-18s%-50s ", mir->code, mir->abbr, src.url); printf ("%-14s%-18s%-50s ", mir->code, mir->abbr, src.url);
puts (mir->name); say (mir->name);
} }
} }
@ -226,15 +226,15 @@ cli_print_target_features (FeatInfo f, const char *input_target_name)
char *get_msg = xy_2strjoin (" Get: 查看当前源状态 | chsrc get ", input_target_name); char *get_msg = xy_2strjoin (" Get: 查看当前源状态 | chsrc get ", input_target_name);
if (f.can_get) printf (" %s%s\n", to_boldgreen(YesMark), to_purple(get_msg)); if (f.can_get) printf (" %s%s\n", to_boldgreen(YesMark), to_purple(get_msg));
else printf (" %s%s\n", to_boldred(NoMark), get_msg);puts(""); else printf (" %s%s\n", to_boldred(NoMark), get_msg);br();
char *reset_msg = xy_2strjoin (" Reset: 重置回默认源 | chsrc reset ", input_target_name); char *reset_msg = xy_2strjoin (" Reset: 重置回默认源 | chsrc reset ", input_target_name);
if (f.can_reset) printf (" %s%s\n", to_boldgreen(YesMark), to_purple(reset_msg)); if (f.can_reset) printf (" %s%s\n", to_boldgreen(YesMark), to_purple(reset_msg));
else printf (" %s%s\n", to_boldred(NoMark), reset_msg);puts(""); else printf (" %s%s\n", to_boldred(NoMark), reset_msg);br();
char *user_define_msg = xy_strjoin (4, " UserDefine: 用户自定义换源URL | chsrc set ", input_target_name, " https://user-define-url.org/", input_target_name); char *user_define_msg = xy_strjoin (4, " UserDefine: 用户自定义换源URL | chsrc set ", input_target_name, " https://user-define-url.org/", input_target_name);
if (f.can_user_define) printf (" %s%s\n", to_boldgreen(YesMark), to_purple(user_define_msg)); if (f.can_user_define) printf (" %s%s\n", to_boldgreen(YesMark), to_purple(user_define_msg));
else printf (" %s%s\n", to_boldred(NoMark), user_define_msg);puts(""); else printf (" %s%s\n", to_boldred(NoMark), user_define_msg);br();
char *locally_msg = xy_2strjoin (" Locally: 仅对本项目换源 | chsrc set -local ", input_target_name); char *locally_msg = xy_2strjoin (" Locally: 仅对本项目换源 | chsrc set -local ", input_target_name);
@ -242,13 +242,13 @@ cli_print_target_features (FeatInfo f, const char *input_target_name)
switch (f.stcan_locally) switch (f.stcan_locally)
{ {
case CanNotFully: case CanNotFully:
printf (" %s%s\n", to_boldred(NoMark), locally_msg);puts(""); printf (" %s%s\n", to_boldred(NoMark), locally_msg);br();
break; break;
case CanFully: case CanFully:
printf (" %s%s\n", to_boldgreen(YesMark), to_purple(locally_msg));puts(""); printf (" %s%s\n", to_boldgreen(YesMark), to_purple(locally_msg));br();
break; break;
case CanSemi: case CanSemi:
printf (" %s%s\n\n %s\n", to_boldgreen(SemiYesMark), to_purple(locally_msg), f.locally);puts(""); printf (" %s%s\n\n %s\n", to_boldgreen(SemiYesMark), to_purple(locally_msg), f.locally);br();
break; break;
default: default:
xy_unreach; xy_unreach;
@ -294,7 +294,7 @@ cli_print_help ()
void void
cli_print_issues () cli_print_issues ()
{ {
puts ( say (
"chsrc issues: Gitee和GitHub两边同时接受issue\n\n" "chsrc issues: Gitee和GitHub两边同时接受issue\n\n"
"- https://gitee.com/RubyMetric/chsrc/issues\n" "- https://gitee.com/RubyMetric/chsrc/issues\n"
"- https://github.com/RubyMetric/chsrc/issues\n" "- https://github.com/RubyMetric/chsrc/issues\n"
@ -409,8 +409,8 @@ get_target (const char *input, TargetOp code, char *option)
say (to_boldblue(xy_strjoin (3, "指定使用某源,请使用 chsrc set ", input, " <code>\n"))); say (to_boldblue(xy_strjoin (3, "指定使用某源,请使用 chsrc set ", input, " <code>\n")));
say (to_boldgreen("Available Sources: \n")); say (to_boldgreen("Available Sources: \n"));
// chsrc_info (xy_strjoin (3, "下方 code 列,可用于指定使用某源,请使用 chsrc set ", input, " <code>\n")); // chsrc_info (xy_strjoin (3, "下方 code 列,可用于指定使用某源,请使用 chsrc set ", input, " <code>\n"));
printf (" %-14s%-35s%-43s ", "code", "镜像站简写", "换源URL"); puts ("镜像站名称"); printf (" %-14s%-35s%-43s ", "code", "镜像站简写", "换源URL"); say ("镜像站名称");
puts ("--------- -------------- ----------------------------------------------- ---------------------"); say ("--------- -------------- ----------------------------------------------- ---------------------");
cli_print_target_available_sources (target->sources, target->sources_n); cli_print_target_available_sources (target->sources, target->sources_n);
if (target->featfn) if (target->featfn)
{ {