添加 chef_verify_contributor() 以及 重写 chef_set_chef()

This commit is contained in:
Aoran Zeng 2025-08-21 16:48:07 +08:00
parent 404807e69b
commit 79cbceb683
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98

View File

@ -231,15 +231,33 @@ chef_set_authors (Target_t *target, size_t count, ...)
}
void
chef_set_chef (Target_t *target, char *name, char *email)
/**
* @brief `id`
*/
Contributor_t *
chef_verify_contributor (const char *id)
{
if (!target || !name || !email)
return;
xy_cant_be_null (id);
target->chef = xy_malloc0 (sizeof(Contributor_t));
target->chef->name = xy_strdup (name);
target->chef->email = xy_strdup (email);
Contributor_t *c = xy_map_get (ProgStatus.contributors, id);
if (!c)
{
char error[256];
snprintf (error, sizeof (error), "贡献者不存在: %s", id);
chsrc_panic (error);
}
return c;
}
void
chef_set_chef (Target_t *target, const char *id)
{
xy_cant_be_null (target);
Contributor_t *c = chef_verify_contributor (id);
target->chef = c;
}