diff options
-rw-r--r-- | include/usbg/usbg_internal.h | 3 | ||||
-rw-r--r-- | src/usbg.c | 14 |
2 files changed, 17 insertions, 0 deletions
diff --git a/include/usbg/usbg_internal.h b/include/usbg/usbg_internal.h index 793319c..30098c9 100644 --- a/include/usbg/usbg_internal.h +++ b/include/usbg/usbg_internal.h @@ -74,6 +74,8 @@ struct usbg_config int id; }; +typedef int (*usbg_rm_function_callback)(usbg_function *, int); + struct usbg_function { TAILQ_ENTRY(usbg_function) fnode; @@ -85,6 +87,7 @@ struct usbg_function /* Only for internal library usage */ char *label; usbg_function_type type; + usbg_rm_function_callback rm_callback; }; struct usbg_binding @@ -725,6 +725,13 @@ static usbg_function *usbg_allocate_function(const char *path, f->parent = parent; f->type = type; + /* only composed funcitons (with subdirs) require this callback */ + switch (usbg_lookup_function_attrs_type(type)) { + default: + f->rm_callback = NULL; + break; + } + if (!(f->path)) { free(f->name); free(f->path); @@ -1642,12 +1649,19 @@ int usbg_rm_function(usbg_function *f, int opts) } /* TAILQ_FOREACH */ } + if (f->rm_callback) { + ret = f->rm_callback(f, opts); + if (ret != USBG_SUCCESS) + goto out; + } + ret = usbg_rm_dir(f->path, f->name); if (ret == USBG_SUCCESS) { TAILQ_REMOVE(&(g->functions), f, fnode); usbg_free_function(f); } +out: return ret; } |