Add mirror/source code

This commit is contained in:
Aoran Zeng 2023-09-03 16:42:17 +08:00
parent 152e061d9d
commit 9008701667
2 changed files with 32 additions and 24 deletions

13
chsrc.c
View File

@ -167,11 +167,12 @@ pl_ruby_setsrc (char* option)
return; return;
} }
const char* source_code = pl_ruby_sources[selected].mirror->code;
const char* source_name = pl_ruby_sources[selected].mirror->name; const char* source_name = pl_ruby_sources[selected].mirror->name;
const char* source_abbr = pl_ruby_sources[selected].mirror->abbr; const char* source_abbr = pl_ruby_sources[selected].mirror->abbr;
const char* source_url = pl_ruby_sources[selected].url; 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 命令换源"); xy_info("chsrc: 为 gem 命令换源");
system("gem source -r https://rubygems.org/"); system("gem source -r https://rubygems.org/");
@ -1014,10 +1015,13 @@ void
print_available_mirrors () print_available_mirrors ()
{ {
xy_info ("chsrc: 支持以下镜像站,荣耀均归属于这些站点,以及它们的开发/维护者们"); xy_info ("chsrc: 支持以下镜像站,荣耀均归属于这些站点,以及它们的开发/维护者们");
xy_warn ("chsrc: 下方code列可用于指定使用某镜像站请使用 chsrc set <target> <code>");
printf ("%-14s%-30s%-41s ", "code", "服务商缩写", "服务商URL"); puts("服务商名称");
puts ("-------------------------------------------------------------------------------------------------");
for (int i=0; i<xy_arylen(available_mirrors); i++) for (int i=0; i<xy_arylen(available_mirrors); i++)
{ {
mirror_info* mir = available_mirrors[i]; mirror_info* mir = available_mirrors[i];
printf ("%-18s%-41s ", mir->abbr, 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]; source_info src = sources[i];
const mirror_info* mir = src.mirror; 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); puts(mir->name);
} }
} }
@ -1165,6 +1169,9 @@ get_target (const char* input, int code)
} }
else if (Target_List_Source==code) { else if (Target_List_Source==code) {
xy_info (xy_strjoin(3,"chsrc: 对", input ,"支持以下镜像站,荣耀均归属于这些站点,以及它们的开发/维护者们")); xy_info (xy_strjoin(3,"chsrc: 对", input ,"支持以下镜像站,荣耀均归属于这些站点,以及它们的开发/维护者们"));
xy_warn (xy_strjoin(3, "chsrc: 下方code列可用于指定使用某源请使用 chsrc set ", input, " <code>"));
printf ("%-14s%-35s%-45s ", "code", "服务商缩写", "服务源URL"); puts("服务商名称");
puts ("--------------------------------------------------------------------------------------------------------");
print_supported_sources_for_target (target->sources); print_supported_sources_for_target (target->sources);
} }
else if (Target_Cesu_Source==code) { else if (Target_Cesu_Source==code) {

43
chsrc.h
View File

@ -12,6 +12,7 @@
#include "xy.h" #include "xy.h"
typedef struct { typedef struct {
const char* code; // 用于用户指定镜像站
const char* abbr; const char* abbr;
const char* name; const char* name;
const char* site; const char* site;
@ -21,38 +22,38 @@ typedef struct {
// 我们目前根据 https://github.com/mirrorz-org/oh-my-mirrorz 挑选速度前10位 // 我们目前根据 https://github.com/mirrorz-org/oh-my-mirrorz 挑选速度前10位
// //
mirror_info mirror_info
MirrorZ = {"MirrorZ", "MirrorZ校园网镜像站", "https://mirrors.cernet.edu.cn/"}, MirrorZ = {"mirrorz", "MirrorZ", "MirrorZ校园网镜像站", "https://mirrors.cernet.edu.cn/"},
Tuna = {"TUNA", "清华大学开源软件镜像站", "https://mirrors.tuna.tsinghua.edu.cn/"}, Tuna = {"tuna", "TUNA", "清华大学开源软件镜像站", "https://mirrors.tuna.tsinghua.edu.cn/"},
Sjtug_Zhiyuan = {"SJTUG-zhiyuan", "上海交通大学致远镜像站", "https://mirrors.sjtug.sjtu.edu.cn/"}, Sjtug_Zhiyuan = {"sjtu", "SJTUG-zhiyuan", "上海交通大学致远镜像站", "https://mirrors.sjtug.sjtu.edu.cn/"},
Zju = {"ZJU", "浙江大学开源软件镜像站", "https://mirrors.zju.edu.cn/"}, Zju = {"zju", "ZJU", "浙江大学开源软件镜像站", "https://mirrors.zju.edu.cn/"},
Lzuoss = {"LZUOSS", "兰州大学开源社区镜像站", "https://mirror.lzu.edu.cn/"}, Lzuoss = {"lzu", "LZUOSS", "兰州大学开源社区镜像站", "https://mirror.lzu.edu.cn/"},
Jlu = {"JLU", "吉林大学开源镜像站", "https://mirrors.jlu.edu.cn/"}, Jlu = {"jlu", "JLU", "吉林大学开源镜像站", "https://mirrors.jlu.edu.cn/"},
Bfsu = {"BFSU", "北京外国语大学开源软件镜像站","https://mirrors.bfsu.edu.cn/"}, Bfsu = {"bfsu", "BFSU", "北京外国语大学开源软件镜像站","https://mirrors.bfsu.edu.cn/"},
Pku = {"PKU", "北京大学开源镜像站", "https://mirrors.pku.edu.cn/"}, Pku = {"pku", "PKU", "北京大学开源镜像站", "https://mirrors.pku.edu.cn/"},
Bjtu = {"BJTU", "北京交通大学自由与开源软件镜像站", "https://mirror.bjtu.edu.cn/"}, Bjtu = {"bjtu", "BJTU", "北京交通大学自由与开源软件镜像站", "https://mirror.bjtu.edu.cn/"},
Sustech = {"SUSTech", "南方科技大学开源软件镜像站", "https://mirrors.sustech.edu.cn/"}, Sustech = {"sustech", "SUSTech", "南方科技大学开源软件镜像站", "https://mirrors.sustech.edu.cn/"},
Ustc = {"USTC", "中国科学技术大学开源镜像站", "https://mirrors.ustc.edu.cn/"}, Ustc = {"ustc", "USTC", "中国科学技术大学开源镜像站", "https://mirrors.ustc.edu.cn/"},
// 速度暂时处于10位以后但是目前可用的源 // 速度暂时处于10位以后但是目前可用的源
Nju = {"NJU", "南京大学开源镜像站", "https://mirrors.nju.edu.cn/"}, Nju = {"nju", "NJU", "南京大学开源镜像站", "https://mirrors.nju.edu.cn/"},
Cqu = {"CQU", "重庆大学开源软件镜像站", "https://mirrors.cqu.edu.cn/"}; Cqu = {"cqu", "CQU", "重庆大学开源软件镜像站", "https://mirrors.cqu.edu.cn/"};
// 大型公司 // 大型公司
// 注意,腾讯软件源中,有很多链接都已失效,请仔细检查 // 注意,腾讯软件源中,有很多链接都已失效,请仔细检查
mirror_info mirror_info
Ali = {"Ali OPSX", "阿里巴巴开源镜像站", "https://developer.aliyun.com/mirror/"}, Ali = {"ali", "Ali OPSX", "阿里巴巴开源镜像站", "https://developer.aliyun.com/mirror/"},
Tencent = {"Tencent", "腾讯软件源", "https://mirrors.tencent.com/"}, Tencent = {"tencent", "Tencent", "腾讯软件源", "https://mirrors.tencent.com/"},
Netease = {"Netease", "网易开源镜像站", "https://mirrors.163.com/"}, Netease = {"netease", "Netease", "网易开源镜像站", "https://mirrors.163.com/"},
Sohu = {"SOHU", "搜狐开源镜像站", "https://mirrors.sohu.com/"}; Sohu = {"sohu", "SOHU", "搜狐开源镜像站", "https://mirrors.sohu.com/"};
// 开源社区 // 开源社区
mirror_info mirror_info
RubyChina = {"RubyChina", "Ruby China 社区", "https://ruby-china.org/"}, RubyChina = {"rubychina", "RubyChina", "Ruby China 社区", "https://gems.ruby-china.com/"},
GoProxyCN = {"Goproxy.cn", "七牛云 Goproxy.cn", "https://www.qiniu.com/"}, GoProxyCN = {"goproxy.cn", "Goproxy.cn", "七牛云 Goproxy.cn", "https://goproxy.cn/"},
GoProxyIO = {"GOPROXY.IO", "GOPROXY.IO", "https://goproxy.io/"}, GoProxyIO = {"goproxy.io", "GOPROXY.IO", "GOPROXY.IO", "https://goproxy.io/"},
NugetOrg = {"NuGet Org", "Nuget Organization", "https://www.nuget.org/"}; NugetOrg = {"nuget.org", "NuGet Org", "Nuget Organization", "https://www.nuget.org/"};
mirror_info* mirror_info*