diff --git a/include/chsrc.h b/include/chsrc.h index c5929d2..cd58e80 100644 --- a/include/chsrc.h +++ b/include/chsrc.h @@ -276,8 +276,11 @@ query_mirror_exist (SourceInfo *sources, size_t size, char *target, char *input) if (2==size) { char *msg1 = CliOpt_InEnglish ? " is " : " 是 "; - char *msg2 = CliOpt_InEnglish ? " the only mirror site available currently, thanks for their generous support" : " 目前唯一可用镜像站,感谢他们的慷慨支持"; - chsrc_succ (xy_strjoin (4, sources[1].mirror->name, msg1, target, msg2)); + char *msg2 = CliOpt_InEnglish ? " the only mirror site available currently, thanks for their generous support" + : " 目前唯一可用镜像站,感谢他们的慷慨支持"; + const char *name = CliOpt_InEnglish ? sources[1].mirror->abbr + : sources[1].mirror->name; + chsrc_succ (xy_strjoin (4, name, msg1, target, msg2)); } if (xy_streql ("reset", input)) @@ -498,15 +501,19 @@ auto_select_ (SourceInfo *sources, size_t size, const char *target_name) if (only_one) { - char *is = CliOpt_InEnglish ? " is " : " 是 "; - char *msg = CliOpt_InEnglish ? "the ONLY mirror available currently, thanks for their generous support" : \ - " 目前唯一可用镜像站,感谢他们的慷慨支持"; - chsrc_succ (xy_strjoin (4, sources[fast_idx].mirror->name, is, target_name, msg)); + char *is = CliOpt_InEnglish ? " is " : " 是 "; + char *msg = CliOpt_InEnglish ? "the ONLY mirror available currently, thanks for their generous support" + : " 目前唯一可用镜像站,感谢他们的慷慨支持"; + const char *name = CliOpt_InEnglish ? sources[fast_idx].mirror->abbr + : sources[fast_idx].mirror->name; + chsrc_succ (xy_strjoin (4, name, is, target_name, msg)); } else { char *msg = CliOpt_InEnglish ? "FASTEST mirror site: " : "最快镜像站: "; - say (xy_2strjoin (msg, green (sources[fast_idx].mirror->name))); + const char *name = CliOpt_InEnglish ? sources[fast_idx].mirror->abbr + : sources[fast_idx].mirror->name; + say (xy_2strjoin (msg, green(name))); } @@ -632,6 +639,8 @@ confirm_source (SourceInfo *source) #define MSG_EN_STILL "Still need to operate manually according to the above prompts. " #define MSG_CN_STILL "仍需按上述提示手工操作" +#define thank_mirror(msg) chsrc_log(xy_2strjoin(msg,purple(CliOpt_InEnglish?source->mirror->abbr:source->mirror->name))) + /** * @param source 可为NULL * @param last_word 5种选择:ChsrcTypeAuto | ChsrcTypeReset | ChsrcTypeSemiAuto | ChsrcTypeManual | ChsrcTypeUntested @@ -656,7 +665,7 @@ chsrc_conclude (SourceInfo *source, const char *last_word) { char *msg = CliOpt_InEnglish ? MSG_EN_FULLY_AUTO MSG_EN_THANKS \ : MSG_CN_FULLY_AUTO ", " MSG_CN_THANKS; - chsrc_log (xy_2strjoin (msg, purple (source->mirror->name))); + thank_mirror (msg); } } else @@ -685,7 +694,7 @@ chsrc_conclude (SourceInfo *source, const char *last_word) { char *msg = CliOpt_InEnglish ? MSG_EN_SEMI_AUTO MSG_EN_STILL MSG_EN_THANKS \ : MSG_CN_SEMI_AUTO ", " MSG_CN_STILL "。" MSG_CN_THANKS; - chsrc_log (xy_2strjoin (msg, purple (source->mirror->name))); + thank_mirror (msg); } } else @@ -712,7 +721,7 @@ chsrc_conclude (SourceInfo *source, const char *last_word) { char *msg = CliOpt_InEnglish ? MSG_EN_CONSTRAINT MSG_EN_THANKS \ : MSG_CN_CONSTRAINT ", " MSG_CN_THANKS; - chsrc_log (xy_2strjoin (msg, purple (source->mirror->name))); + thank_mirror (msg); } } else @@ -735,7 +744,7 @@ chsrc_conclude (SourceInfo *source, const char *last_word) else { char *msg = CliOpt_InEnglish ? MSG_EN_THANKS : MSG_CN_THANKS; - chsrc_log (xy_2strjoin (msg, purple (source->mirror->name))); + thank_mirror (msg); } } else diff --git a/include/source.h b/include/source.h index 6157735..3ffcf90 100644 --- a/include/source.h +++ b/include/source.h @@ -6,15 +6,15 @@ * Contributors : Shengwei Chen <414685209@qq.com> * | * Created on : <2023-08-29> - * Last modified : <2024-08-22> + * Last modified : <2024-08-23> * * 镜像站与换源信息 * ------------------------------------------------------------*/ typedef struct MirrorSite_t { const char *code; // 用于用户指定镜像站 - const char *abbr; - const char *name; + const char *abbr; // 需要使用镜像站的英文名时,用这个代替,因为大部分镜像站没有提供正式的英文名 + const char *name; // 镜像站中文名 const char *site; const char *__bigfile_url; // 用于对该镜像站测速 } MirrorSite; @@ -32,7 +32,7 @@ typedef struct MirrorSite_t { * 我们目前根据 https://github.com/mirrorz-org/oh-my-mirrorz 挑选速度前10位 */ MirrorSite -MirrorZ = {"mirrorz", "MirrorZ", "MirrorZ 校园网镜像站", "https://mirrors.cernet.edu.cn/", NULL}, +MirrorZ = {"mirrorz", "MirrorZ", "MirrorZ 校园网镜像站", "https://mirrors.cernet.edu.cn/", NULL}, Tuna = {"tuna", "TUNA", "清华大学开源软件镜像站", "https://mirrors.tuna.tsinghua.edu.cn/", "https://mirrors.tuna.tsinghua.edu.cn/speedtest/1000mb.bin"}, diff --git a/src/chsrc.c b/src/chsrc.c index 488aea0..2567b5f 100644 --- a/src/chsrc.c +++ b/src/chsrc.c @@ -595,9 +595,6 @@ main (int argc, char const *argv[]) else if (xy_streql (argv[i], "-dry")) { CliOpt_DryRun = true; - char *msg = CliOpt_InEnglish ? "** Enable [Dry Run] mode. Simulate the source changing process (skipping speed measurement). Commands only print but don't run **\n" - : "**开启Dry Run模式,模拟换源过程(跳过测速),命令仅打印并不运行**\n"; - chsrc_log (bdyellow(msg)); } else if (xy_streql (argv[i], "-no-color") || xy_streql (argv[i], "-no-colour")) { @@ -623,6 +620,10 @@ main (int argc, char const *argv[]) bool matched = false; + char *dry_msg = CliOpt_InEnglish ? "** Enable [Dry Run] mode. Simulate the source changing process (skipping speed measurement). Commands only print but don't run **\n" + : "**开启Dry Run模式,模拟换源过程(跳过测速),命令仅打印并不运行**\n"; + chsrc_log (bdyellow(dry_msg)); + /* chsrc help */ if (xy_streql (command, "h") || xy_streql (command, "-h")