From 9008701667329bee039cd308b439b37a203c2fb7 Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Sun, 3 Sep 2023 16:42:17 +0800 Subject: [PATCH] Add mirror/source code --- chsrc.c | 13 ++++++++++--- chsrc.h | 43 ++++++++++++++++++++++--------------------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/chsrc.c b/chsrc.c index 2c378f3..d5536d0 100644 --- a/chsrc.c +++ b/chsrc.c @@ -167,11 +167,12 @@ pl_ruby_setsrc (char* option) return; } + const char* source_code = pl_ruby_sources[selected].mirror->code; const char* source_name = pl_ruby_sources[selected].mirror->name; const char* source_abbr = pl_ruby_sources[selected].mirror->abbr; const char* source_url = pl_ruby_sources[selected].url; - xy_info (xy_2strjoin("chsrc: 选中镜像站:", source_abbr)); + xy_info (xy_strjoin(5, "chsrc: 选中镜像站:", source_abbr, " (", source_code, ")")); xy_info("chsrc: 为 gem 命令换源"); system("gem source -r https://rubygems.org/"); @@ -1014,10 +1015,13 @@ void print_available_mirrors () { xy_info ("chsrc: 支持以下镜像站,荣耀均归属于这些站点,以及它们的开发/维护者们"); + xy_warn ("chsrc: 下方code列,可用于指定使用某镜像站,请使用 chsrc set "); + printf ("%-14s%-30s%-41s ", "code", "服务商缩写", "服务商URL"); puts("服务商名称"); + puts ("-------------------------------------------------------------------------------------------------"); for (int i=0; iabbr, mir->site); puts(mir->name); + printf ("%-14s%-18s%-41s ", mir->code, mir->abbr, mir->site); puts(mir->name); } } @@ -1064,7 +1068,7 @@ print_supported_sources_for_target (source_info sources[]) { source_info src = sources[i]; const mirror_info* mir = src.mirror; - printf ("%-18s%-50s ", mir->abbr, src.url); + printf ("%-14s%-18s%-50s ",mir->code, mir->abbr, src.url); puts(mir->name); } } @@ -1165,6 +1169,9 @@ get_target (const char* input, int code) } else if (Target_List_Source==code) { xy_info (xy_strjoin(3,"chsrc: 对", input ,"支持以下镜像站,荣耀均归属于这些站点,以及它们的开发/维护者们")); + xy_warn (xy_strjoin(3, "chsrc: 下方code列,可用于指定使用某源,请使用 chsrc set ", input, " ")); + printf ("%-14s%-35s%-45s ", "code", "服务商缩写", "服务源URL"); puts("服务商名称"); + puts ("--------------------------------------------------------------------------------------------------------"); print_supported_sources_for_target (target->sources); } else if (Target_Cesu_Source==code) { diff --git a/chsrc.h b/chsrc.h index 0f2de56..b0e04a2 100644 --- a/chsrc.h +++ b/chsrc.h @@ -12,6 +12,7 @@ #include "xy.h" typedef struct { + const char* code; // 用于用户指定镜像站 const char* abbr; const char* name; const char* site; @@ -21,38 +22,38 @@ typedef struct { // 我们目前根据 https://github.com/mirrorz-org/oh-my-mirrorz 挑选速度前10位 // mirror_info - MirrorZ = {"MirrorZ", "MirrorZ校园网镜像站", "https://mirrors.cernet.edu.cn/"}, - Tuna = {"TUNA", "清华大学开源软件镜像站", "https://mirrors.tuna.tsinghua.edu.cn/"}, - Sjtug_Zhiyuan = {"SJTUG-zhiyuan", "上海交通大学致远镜像站", "https://mirrors.sjtug.sjtu.edu.cn/"}, - Zju = {"ZJU", "浙江大学开源软件镜像站", "https://mirrors.zju.edu.cn/"}, - Lzuoss = {"LZUOSS", "兰州大学开源社区镜像站", "https://mirror.lzu.edu.cn/"}, - Jlu = {"JLU", "吉林大学开源镜像站", "https://mirrors.jlu.edu.cn/"}, - Bfsu = {"BFSU", "北京外国语大学开源软件镜像站","https://mirrors.bfsu.edu.cn/"}, - Pku = {"PKU", "北京大学开源镜像站", "https://mirrors.pku.edu.cn/"}, - Bjtu = {"BJTU", "北京交通大学自由与开源软件镜像站", "https://mirror.bjtu.edu.cn/"}, - Sustech = {"SUSTech", "南方科技大学开源软件镜像站", "https://mirrors.sustech.edu.cn/"}, - Ustc = {"USTC", "中国科学技术大学开源镜像站", "https://mirrors.ustc.edu.cn/"}, + MirrorZ = {"mirrorz", "MirrorZ", "MirrorZ校园网镜像站", "https://mirrors.cernet.edu.cn/"}, + Tuna = {"tuna", "TUNA", "清华大学开源软件镜像站", "https://mirrors.tuna.tsinghua.edu.cn/"}, + Sjtug_Zhiyuan = {"sjtu", "SJTUG-zhiyuan", "上海交通大学致远镜像站", "https://mirrors.sjtug.sjtu.edu.cn/"}, + Zju = {"zju", "ZJU", "浙江大学开源软件镜像站", "https://mirrors.zju.edu.cn/"}, + Lzuoss = {"lzu", "LZUOSS", "兰州大学开源社区镜像站", "https://mirror.lzu.edu.cn/"}, + Jlu = {"jlu", "JLU", "吉林大学开源镜像站", "https://mirrors.jlu.edu.cn/"}, + Bfsu = {"bfsu", "BFSU", "北京外国语大学开源软件镜像站","https://mirrors.bfsu.edu.cn/"}, + Pku = {"pku", "PKU", "北京大学开源镜像站", "https://mirrors.pku.edu.cn/"}, + Bjtu = {"bjtu", "BJTU", "北京交通大学自由与开源软件镜像站", "https://mirror.bjtu.edu.cn/"}, + Sustech = {"sustech", "SUSTech", "南方科技大学开源软件镜像站", "https://mirrors.sustech.edu.cn/"}, + Ustc = {"ustc", "USTC", "中国科学技术大学开源镜像站", "https://mirrors.ustc.edu.cn/"}, // 速度暂时处于10位以后,但是目前可用的源 - Nju = {"NJU", "南京大学开源镜像站", "https://mirrors.nju.edu.cn/"}, - Cqu = {"CQU", "重庆大学开源软件镜像站", "https://mirrors.cqu.edu.cn/"}; + Nju = {"nju", "NJU", "南京大学开源镜像站", "https://mirrors.nju.edu.cn/"}, + Cqu = {"cqu", "CQU", "重庆大学开源软件镜像站", "https://mirrors.cqu.edu.cn/"}; // 大型公司 // 注意,腾讯软件源中,有很多链接都已失效,请仔细检查 mirror_info - Ali = {"Ali OPSX", "阿里巴巴开源镜像站", "https://developer.aliyun.com/mirror/"}, - Tencent = {"Tencent", "腾讯软件源", "https://mirrors.tencent.com/"}, - Netease = {"Netease", "网易开源镜像站", "https://mirrors.163.com/"}, - Sohu = {"SOHU", "搜狐开源镜像站", "https://mirrors.sohu.com/"}; + Ali = {"ali", "Ali OPSX", "阿里巴巴开源镜像站", "https://developer.aliyun.com/mirror/"}, + Tencent = {"tencent", "Tencent", "腾讯软件源", "https://mirrors.tencent.com/"}, + Netease = {"netease", "Netease", "网易开源镜像站", "https://mirrors.163.com/"}, + Sohu = {"sohu", "SOHU", "搜狐开源镜像站", "https://mirrors.sohu.com/"}; // 开源社区 mirror_info - RubyChina = {"RubyChina", "Ruby China 社区", "https://ruby-china.org/"}, - GoProxyCN = {"Goproxy.cn", "七牛云 Goproxy.cn", "https://www.qiniu.com/"}, - GoProxyIO = {"GOPROXY.IO", "GOPROXY.IO", "https://goproxy.io/"}, - NugetOrg = {"NuGet Org", "Nuget Organization", "https://www.nuget.org/"}; + RubyChina = {"rubychina", "RubyChina", "Ruby China 社区", "https://gems.ruby-china.com/"}, + GoProxyCN = {"goproxy.cn", "Goproxy.cn", "七牛云 Goproxy.cn", "https://goproxy.cn/"}, + GoProxyIO = {"goproxy.io", "GOPROXY.IO", "GOPROXY.IO", "https://goproxy.io/"}, + NugetOrg = {"nuget.org", "NuGet Org", "Nuget Organization", "https://www.nuget.org/"}; mirror_info*