diff --git a/chsrc.c b/chsrc.c index 92551b4..de1f6ce 100644 --- a/chsrc.c +++ b/chsrc.c @@ -6,7 +6,7 @@ * * chsrc: * -* Change Source —— 换源命令行工具 +* Change Source —— 命令行换源工具 * -------------------------------------------------------------*/ #include "chsrc.h" @@ -672,6 +672,92 @@ print_help () } + +/** + * 遍历我们内置的targets列表,查询用户输入`input`是否与我们支持的某个target匹配 + * + * @param[out] target_func 如果匹配到,则返回内置targets列表中NULL的位置 + * + * @return 匹配到则返回true,未匹配到则返回false + */ +bool +iterate_targets_(const char const*** array, size_t size, const char* input, const char const*** target_func) +{ + int matched = 0; + + const char const** target = NULL; + int k = 0; + const char* alias = NULL; + + for (int i=0; i=2) - { - if (argv[2][0]=='-') { - option = argv[2]; - } else { - cmdarg = argv[2]; - } - } - - int matched = 0; - - for (int i=0; i