From 906aef50a50529cd44715455dc5b7dd1ee20fcbf Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Sat, 2 Sep 2023 19:07:30 +0800 Subject: [PATCH] Add `_sources_n` --- chsrc.c | 63 ++++++++++++++++++++++++++++++++++++++++++--------------- chsrc.h | 22 +++++++++++++++++++- 2 files changed, 68 insertions(+), 17 deletions(-) diff --git a/chsrc.c b/chsrc.c index cc7b004..1c79ff1 100644 --- a/chsrc.c +++ b/chsrc.c @@ -2,7 +2,7 @@ * File : chsrc.c * Authors : Aoran Zeng * Created on : <2023-08-28> -* Last modified : <2023-09-01> +* Last modified : <2023-09-02> * * chsrc: * @@ -293,6 +293,48 @@ pl_ruby_getsrc (char* option) } +int +dblary_maxidx(double* array, int size) +{ + double maxval = array[0]; + double maxidx = 0; + + for (int i=1; imaxval) { + maxval = array[i]; + maxidx = i; + } + } + return maxidx; +} + + +/** + * @maintainer ccmywish + * + * 我们测 https://mirrors.bfsu.edu.cn/rubygems/gems/nokogiri-1.15.0-java.gem 大小为9.9MB + */ +void +pl_ruby_cesu (char* option) +{ + char* url = ""; + + size_t size = pl_ruby_sources_n; + source_info* sources = pl_ruby_sources; + double speeds[size]; + for (int i=0;iname)); +} + + /** * Go换源 @@ -626,19 +668,8 @@ os_debian_setsrc (char* option) } -/************************************** Target Matrix ****************************************/ - -typedef struct { - void (*setfn)(char* option); - void (*getfn)(char* option); - void (*cesufn)(char* option); - source_info* sources; - size_t sources_count; -} target_info; - -#define def_target_info(t, n) target_info t##_target = {t##_setsrc, t##_getsrc, t##_cesu, t##_sources, n}; - -def_target_info(pl_ruby, 5) +/************************************** Begin Target Matrix ****************************************/ +def_target_info(pl_ruby); target_info pl_python_target = {pl_python_setsrc, NULL, NULL, pl_python_sources, 5}, @@ -700,7 +731,7 @@ static const char const wr_anaconda, wr_emacs, wr_tex }; #undef targetinfo - +/************************************** End Target Matrix ****************************************/ static const char const* @@ -810,7 +841,7 @@ print_help () /** * 遍历我们内置的targets列表,查询用户输入`input`是否与我们支持的某个target匹配 * - * @param[out] target_func 如果匹配到,则返回内置targets列表中NULL的位置 + * @param[out] target_func 如果匹配到,则返回内置targets列表中最后的target_info信息 * * @return 匹配到则返回true,未匹配到则返回false */ diff --git a/chsrc.h b/chsrc.h index e43562d..285ed05 100644 --- a/chsrc.h +++ b/chsrc.h @@ -2,7 +2,7 @@ * File : chsrc.h * Authors : Aoran Zeng * Created on : <2023-08-29> -* Last modified : <2023-09-01> +* Last modified : <2023-09-02> * * chsrc: * @@ -272,3 +272,23 @@ os_debian_sources[] = { /* 函数签名 */ bool does_the_program_exist (char* check_cmd, char* progname); + + + +#define def_target_sources_n(t) const size_t t##_sources_n = xy_arylen(pl_ruby_sources) +def_target_sources_n(pl_ruby); def_target_sources_n(pl_python); def_target_sources_n(pl_nodejs); +def_target_sources_n(pl_perl); def_target_sources_n(pl_php); def_target_sources_n(pl_go); +def_target_sources_n(pl_rust); def_target_sources_n(pl_java); def_target_sources_n(pl_r); +def_target_sources_n(pl_julia); +def_target_sources_n(os_ubuntu); def_target_sources_n(os_debian); + +/* Target Info */ +typedef struct { + void (*setfn)(char* option); + void (*getfn)(char* option); + void (*cesufn)(char* option); + source_info* sources; + size_t sources_n; +} target_info; + +#define def_target_info(t) target_info t##_target = {t##_setsrc, t##_getsrc, t##_cesu, t##_sources, t##_sources_n}