Correct API name typo and deprecate old APIs

This commit is contained in:
Amin Ben Romdhane 2025-10-15 10:44:01 +00:00 committed by IOPSYS Dev
parent 1596a6a8c1
commit 69134df069
No known key found for this signature in database
4 changed files with 24 additions and 9 deletions

View file

@ -71,8 +71,7 @@ int main(int argc, char **argv)
bbfdm_ubus_set_log_level(log_level); bbfdm_ubus_set_log_level(log_level);
bbfdm_ubus_load_data_model(NULL); bbfdm_ubus_load_data_model(NULL);
err = bbfdm_ubus_register_init(&bbfdm_ctx);
err = bbfdm_ubus_regiter_init(&bbfdm_ctx);
if (err != 0) if (err != 0)
goto exit; goto exit;
@ -87,7 +86,7 @@ int main(int argc, char **argv)
exit: exit:
if (err != -5) // Error code is not -5, indicating that ubus_ctx is connected, proceed with shutdown if (err != -5) // Error code is not -5, indicating that ubus_ctx is connected, proceed with shutdown
bbfdm_ubus_regiter_free(&bbfdm_ctx); bbfdm_ubus_register_free(&bbfdm_ctx);
closelog(); closelog();

View file

@ -13,12 +13,12 @@ The `libbbfdm-ubus` library can be used by:
The following APIs are provided by `libbbfdm-ubus` to expose the data model over ubus: The following APIs are provided by `libbbfdm-ubus` to expose the data model over ubus:
### bbfdm_ubus_regiter_init ### bbfdm_ubus_register_init
This method initializes the `bbfdm_context` structure object and registers ubus data model methods. This method initializes the `bbfdm_context` structure object and registers ubus data model methods.
```c ```c
int bbfdm_ubus_regiter_init(struct bbfdm_context *bbfdm_ctx) int bbfdm_ubus_register_init(struct bbfdm_context *bbfdm_ctx)
Inputs: Inputs:
struct bbfdm_context *bbfdm_ctx struct bbfdm_context *bbfdm_ctx
@ -29,12 +29,12 @@ Returns:
Returns 0 on success, or an error code if the registration fails. Returns 0 on success, or an error code if the registration fails.
``` ```
### bbfdm_ubus_regiter_free ### bbfdm_ubus_register_free
This method frees the `bbfdm_context` structure object. This method frees the `bbfdm_context` structure object.
```c ```c
int bbfdm_ubus_regiter_free(struct bbfdm_context *bbfdm_ctx) int bbfdm_ubus_register_free(struct bbfdm_context *bbfdm_ctx)
Inputs: Inputs:
struct bbfdm_context *bbfdm_ctx struct bbfdm_context *bbfdm_ctx

View file

@ -1010,7 +1010,7 @@ static void register_bbfdm_apply_event(struct bbfdm_context *bbfdm_ctx)
ubus_register_event_handler(&bbfdm_ctx->ubus_ctx, &bbfdm_ctx->apply_event, "bbfdm.apply"); ubus_register_event_handler(&bbfdm_ctx->ubus_ctx, &bbfdm_ctx->apply_event, "bbfdm.apply");
} }
int bbfdm_ubus_regiter_init(struct bbfdm_context *bbfdm_ctx) int bbfdm_ubus_register_init(struct bbfdm_context *bbfdm_ctx)
{ {
int err = 0; int err = 0;
@ -1058,7 +1058,7 @@ int bbfdm_ubus_regiter_init(struct bbfdm_context *bbfdm_ctx)
return register_events_to_ubus(&bbfdm_ctx->ubus_ctx, &bbfdm_ctx->event_handlers); return register_events_to_ubus(&bbfdm_ctx->ubus_ctx, &bbfdm_ctx->event_handlers);
} }
int bbfdm_ubus_regiter_free(struct bbfdm_context *bbfdm_ctx) int bbfdm_ubus_register_free(struct bbfdm_context *bbfdm_ctx)
{ {
free_apply_handlers(&bbfdm_ctx->config); free_apply_handlers(&bbfdm_ctx->config);
free_changed_uci(bbfdm_ctx); free_changed_uci(bbfdm_ctx);
@ -1071,6 +1071,16 @@ int bbfdm_ubus_regiter_free(struct bbfdm_context *bbfdm_ctx)
return 0; return 0;
} }
int bbfdm_ubus_regiter_init(struct bbfdm_context *bbfdm_ctx)
{
return bbfdm_ubus_register_init(bbfdm_ctx);
}
int bbfdm_ubus_regiter_free(struct bbfdm_context *bbfdm_ctx)
{
return bbfdm_ubus_register_free(bbfdm_ctx);
}
void bbfdm_ubus_set_service_name(struct bbfdm_context *bbfdm_ctx, const char *srv_name) void bbfdm_ubus_set_service_name(struct bbfdm_context *bbfdm_ctx, const char *srv_name)
{ {
strncpyt(bbfdm_ctx->config.service_name, srv_name, sizeof(bbfdm_ctx->config.service_name)); strncpyt(bbfdm_ctx->config.service_name, srv_name, sizeof(bbfdm_ctx->config.service_name));

View file

@ -47,7 +47,13 @@ typedef struct bbfdm_data {
struct blob_buf bb; struct blob_buf bb;
} bbfdm_data_t; } bbfdm_data_t;
int bbfdm_ubus_register_init(struct bbfdm_context *bbfdm_ctx);
int bbfdm_ubus_register_free(struct bbfdm_context *bbfdm_ctx);
__attribute__((deprecated("Use bbfdm_ubus_register_init() instead of bbfdm_ubus_regiter_init()")))
int bbfdm_ubus_regiter_init(struct bbfdm_context *bbfdm_ctx); int bbfdm_ubus_regiter_init(struct bbfdm_context *bbfdm_ctx);
__attribute__((deprecated("Use bbfdm_ubus_register_free() instead of bbfdm_ubus_regiter_free()")))
int bbfdm_ubus_regiter_free(struct bbfdm_context *bbfdm_ctx); int bbfdm_ubus_regiter_free(struct bbfdm_context *bbfdm_ctx);
int bbfdm_print_data_model_schema(struct bbfdm_context *bbfdm_ctx, const enum bbfdm_type_enum type); int bbfdm_print_data_model_schema(struct bbfdm_context *bbfdm_ctx, const enum bbfdm_type_enum type);