删除 authors 字段,将其由 cooks 代替

This commit is contained in:
Aoran Zeng 2025-08-21 17:16:33 +08:00
parent 79cbceb683
commit c609a10988
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
2 changed files with 54 additions and 87 deletions

View File

@ -75,8 +75,11 @@ chef_set_sources_speed_measure_url_with_func (
char *(*func)(const char *url, const char *user_data),
char *user_data)
{
xy_cant_be_null (target);
Source_t *sources = target->sources;
int n = target->sources_n;
for (int i=0; i<n; i++)
{
Source_t *src = &sources[i];
@ -106,18 +109,14 @@ chef_set_sources_speed_measure_url_with_postfix (Target_t *target, char *postfix
void
chef_allow_english (Target_t *target)
{
if (!target)
return;
xy_cant_be_null (target);
target->can_english = true;
}
void
chef_forbid_english (Target_t *target)
{
if (!target)
return;
xy_cant_be_null (target);
target->can_english = false;
}
@ -125,8 +124,7 @@ chef_forbid_english (Target_t *target)
void
chef_allow_local_mode (Target_t *target, Capability_t cap, const char *explain_zh, const char *explain_en)
{
if (!target)
return;
xy_cant_be_null (target);
target->cap_local = cap;
@ -149,8 +147,7 @@ chef_allow_local_mode (Target_t *target, Capability_t cap, const char *explain_z
void
chef_allow_user_define (Target_t *target)
{
if (!target)
return;
xy_cant_be_null (target);
target->can_user_define = true;
target->can_user_define_explain = NULL;
@ -159,8 +156,7 @@ chef_allow_user_define (Target_t *target)
void
chef_forbid_user_define (Target_t *target)
{
if (!target)
return;
xy_cant_be_null (target);
target->can_user_define = false;
@ -173,63 +169,15 @@ chef_forbid_user_define (Target_t *target)
void
chef_set_note (Target_t *target, const char *note_zh, const char *note_en)
{
if (!target)
return;
xy_cant_be_null (target);
const char *msg = CHINESE ? note_zh : note_en;
if (msg)
target->note = xy_strdup(msg);
target->note = xy_strdup (msg);
}
void
chef_set_contributors (Target_t *target, uint32_t count, ...)
{
if (!target || count==0)
return;
target->contributors_n = count;
target->contributors = xy_malloc0 (count * sizeof(Contributor_t));
va_list args;
va_start(args, count);
for (uint32_t i = 0; i < count; i++)
{
char *name = va_arg(args, char*);
char *email = va_arg(args, char*);
target->contributors[i].name = xy_strdup (name);
target->contributors[i].email = xy_strdup (email);
}
}
void
chef_set_authors (Target_t *target, size_t count, ...)
{
if (!target || count == 0)
return;
va_list args;
va_start(args, count);
target->authors = xy_malloc0 (count * sizeof(Contributor_t));
target->authors_n = count;
for (size_t i = 0; i < count; i++)
{
char *name = va_arg(args, char*);
char *email = va_arg(args, char*);
target->authors[i].name = xy_strdup(name);
target->authors[i].email = xy_strdup(email);
}
va_end(args);
}
/**
* @brief `id`
@ -264,8 +212,7 @@ chef_set_chef (Target_t *target, const char *id)
void
chef_set_cooks (Target_t *target, size_t count, ...)
{
if (!target)
return;
xy_cant_be_null (target);
if (count == 0)
{
@ -275,29 +222,52 @@ chef_set_cooks (Target_t *target, size_t count, ...)
}
va_list args;
va_start(args, count);
va_start (args, count);
target->cooks = xy_malloc0 (count * sizeof(Contributor_t));
target->cooks = xy_malloc0 (count * sizeof (Contributor_t*));
target->cooks_n = count;
for (size_t i = 0; i < count; i++)
{
char *name = va_arg(args, char*);
char *email = va_arg(args, char*);
target->cooks[i].name = xy_strdup(name);
target->cooks[i].email = xy_strdup(email);
char *id = va_arg (args, char*);
target->cooks[i] = chef_verify_contributor (id);
}
va_end(args);
va_end (args);
}
void
chef_set_contributors (Target_t *target, uint32_t count, ...)
{
xy_cant_be_null (target);
if (count == 0)
{
target->contributors = NULL;
target->contributors_n = 0;
return;
}
va_list args;
va_start (args, count);
target->contributors = xy_malloc0 (count * sizeof (Contributor_t*));
target->contributors_n = count;
for (uint32_t i = 0; i < count; i++)
{
char *id = va_arg (args, char*);
target->contributors[i] = chef_verify_contributor (id);
}
}
void
chef_set_created_on (Target_t *target, char *date)
{
if (!target)
return;
xy_cant_be_null (target);
xy_cant_be_null (date);
target->created_on = xy_strdup (date);
}
@ -306,8 +276,8 @@ chef_set_created_on (Target_t *target, char *date)
void
chef_set_last_updated (Target_t *target, char *date)
{
if (!target)
return;
xy_cant_be_null (target);
xy_cant_be_null (date);
target->last_updated = xy_strdup (date);
}
@ -316,8 +286,8 @@ chef_set_last_updated (Target_t *target, char *date)
void
chef_set_sources_last_updated (Target_t *target, char *date)
{
if (!target)
return;
xy_cant_be_null (target);
xy_cant_be_null (date);
target->sources_last_updated = xy_strdup (date);
}

View File

@ -142,20 +142,17 @@ typedef struct Target_t
char *note; /* 备注 */
/* Recipe maintain info */
/* recipe 维护信息 */
char *created_on;
char *last_updated;
char *sources_last_updated;
Contributor_t *authors;
size_t authors_n;
Contributor_t *chef; /* 该 recipe 的负责人 */
Contributor_t **cooks; /* 该 recipe 的核心作者 */
size_t cooks_n;
Contributor_t *contributors;
size_t contributors_n;
Contributor_t *chef; /* Chef 仅有一个 */
Contributor_t *cooks; /* Cook 可以有多个 */
size_t cooks_n;
Contributor_t **contributors; /* 该 recipe 的所有贡献者(除核心作者外的其他人) */
size_t contributors_n;
}
Target_t;