update controller code

This commit is contained in:
Rongsong Shen 2025-11-05 16:58:57 +08:00
parent 2836d196da
commit 41f56fa6ed
54 changed files with 9688 additions and 214 deletions

View file

@ -65,7 +65,7 @@ int xce_add_hook(hooksys_t* s,
int xce_run_hooks(hooksys_t* s,
int type,
int situation,
int detail,
int detail,
...)
{
xlist_t* l;
@ -84,17 +84,17 @@ int xce_run_hooks(hooksys_t* s,
for (i = 0; i < l->count; i++) {
hook_item_t* it = l->data[i];
va_list ap;
va_list ap;
if (it == NULL) {
continue;
}
va_start(ap, detail);
va_start(ap, detail);
rc = (*(it->fn))(type, situation, detail,
it->data, ap);
va_end(ap);
va_end(ap);
if ((situation == HOOK_BEFORE_EVENT) && (rc < 0)) {
break;
}
@ -103,10 +103,11 @@ int xce_run_hooks(hooksys_t* s,
return rc;
}
static int free_hook_item(void *data1,
void *data2) {
static int free_hook_item(void* data1,
void* data2)
{
if (data1 == NULL) {
return -EINVAL;
return -EINVAL;
}
free(data1);
@ -126,9 +127,9 @@ void xce_hook_fini(hooksys_t* s)
}
for (i = 0; i < s->maxtypes; i++) {
xlist_iter(&(s->hooks[i]),
(xlist_iter_fn_t)free_hook_item,
NULL);
xlist_iter(&(s->hooks[i]),
(xlist_iter_fn_t)free_hook_item,
NULL);
xlist_fini(&(s->hooks[i]));
}