Yield source

This commit is contained in:
Aoran Zeng
2024-06-13 23:43:31 +08:00
parent 419168fcf7
commit 92b3446531
2 changed files with 24 additions and 0 deletions

View File

@@ -346,6 +346,27 @@ source_has_empty_url (SourceInfo *source)
return source->url == NULL;
}
/**
* 用户*只可能*通过下面三种方式来换源,无论哪一种都会返回一个 SourceInfo 出来
*
* 1. 用户指定 MirrorCode
* 2. 用户什么都没指定 (将测速选择最快镜像)
* 3. 用户给了一个 URL
*
* @dependency 变量 option
* @dependency 变量 source
*/
#define chsrc_yield_source(for_what) \
if (is_url (option)) \
{ \
SourceInfo __tmp = { &UserDefine, option }; \
source = __tmp; \
} \
else \
{ \
int __index = use_specific_mirror_or_auto_select (option, for_what); \
source = pl_ruby_sources[__index]; \
}