modules: implement description()

This commit is contained in:
Daniel Eklöf 2021-06-20 21:15:24 +02:00
parent 97d5570daf
commit ed2b8c4874
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
14 changed files with 116 additions and 0 deletions

View file

@ -56,6 +56,19 @@ destroy(struct module *mod)
module_default_destroy(mod);
}
static const char *
description(struct module *mod)
{
static char desc[32];
struct private *m = mod->private;
char *path = strdup(m->path);
snprintf(desc, sizeof(desc), "script(%s)", basename(path));
free(path);
return desc;
}
static struct exposable *
content(struct module *mod)
{
@ -569,6 +582,7 @@ script_new(const char *path, size_t argc, const char *const argv[static argc],
mod->run = &run;
mod->destroy = &destroy;
mod->content = &content;
mod->description = &description;
return mod;
}