diff --git a/chsrc.c b/chsrc.c index fafb809..4447a01 100644 --- a/chsrc.c +++ b/chsrc.c @@ -1,3 +1,14 @@ +/* -------------------------------------------------------------- +* File : chsrc.c +* Authors : Aoran Zeng +* Created on : <2023-08-28> +* Last modified : <2023-08-29> +* +* chsrc: +* +* Change Source —— 换源命令行工具 +* -------------------------------------------------------------*/ + #include #include "helper.h" @@ -76,9 +87,9 @@ pl_chsrc_ruby (char* source_name) free(cmd); } -#define arg(func) (const char const*)func +#define cmdfunc(func) (const char const*)func static const char const -*pl_ruby[] = {"gem", "ruby", "rb", NULL, arg(pl_chsrc_ruby)}, +*pl_ruby[] = {"gem", "ruby", "rb", NULL, cmdfunc(pl_chsrc_ruby)}, *pl_python[] = {"pip", "python", "py", NULL}, *pl_nodejs[] = {"npm", "node", "nodejs", "js", NULL}, *pl_perl[] = {"perl", "cpan", NULL}, @@ -101,20 +112,20 @@ static const char const static const char const* usage[] = { "chsrc: Change Source " Chsrc_Version " by RubyMetric\n", - "Usage:\n" - " chsrc [source]\n", + "使用:\n" + " chsrc <要换源的对象> [所换源名称]\n", - "Options:\n" - " -h Print this help\n", + "选项:\n" + " -h 打印该帮助\n", - "Supported:\n" + "支持:\n" }; void -call_cmd (void* cmdptr, char* arg) +call_cmd (void* cmdptr, const char* arg) { - void (*cmd_func)(char*) = cmdptr; + void (*cmd_func)(const char*) = cmdptr; if (NULL==arg) { puts("chsrc: Use the default"); } @@ -123,7 +134,7 @@ call_cmd (void* cmdptr, char* arg) int -print_help() +print_help () { for (int i=0; i=2) { diff --git a/helper.h b/helper.h index add3d95..0c09a8f 100644 --- a/helper.h +++ b/helper.h @@ -2,7 +2,7 @@ * File : helper.h * Authors : Aoran Zeng * Created on : <2023-08-28> -* Last modified : <2023-08-28> +* Last modified : <2023-08-29> * * helper: * @@ -15,7 +15,7 @@ #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) char* -xy_strjoin(const char* str1, const char* str2) +xy_strjoin (const char* str1, const char* str2) { size_t len = strlen(str1) + strlen(str2) + 1; char* ret = malloc(len);