Restructured error,debug anf log API

Renamed functions clicon->clixon, replaced global variables w access functions
Unified clicon_netconf_error with clixon_err()
This commit is contained in:
Olof hagsand 2023-11-13 10:12:52 +01:00
parent 261469be16
commit 24a4991ec8
199 changed files with 4668 additions and 4158 deletions

View file

@ -62,7 +62,7 @@
* @retval -1 Error
*/
typedef int (*clicon_rpc_cb)(
clicon_handle h,
clixon_handle h,
cxobj *xn,
cbuf *cbret,
void *arg,
@ -84,7 +84,7 @@ typedef int (*clicon_rpc_cb)(
* @retval -1 Error
*/
typedef int (*clicon_upgrade_cb)(
clicon_handle h,
clixon_handle h,
cxobj *xn,
char *ns,
uint16_t op,
@ -121,19 +121,19 @@ typedef enum clixon_auth_type clixon_auth_type_t;
* this callback is called *before* privileges are dropped.
* @param[in] h Clixon handle
*/
typedef int (plgstart_t)(clicon_handle); /* Plugin start */
typedef int (plgstart_t)(clixon_handle); /* Plugin start */
/* Called just before or after a server has "daemonized", ie put in background.
* Backend: If daemon privileges are dropped this callback is called *before* privileges are dropped.
* If daemon is started in foreground (-F): pre-daemon is not called, but daemon called
* @param[in] h Clixon handle
*/
typedef int (plgdaemon_t)(clicon_handle); /* Plugin pre/post daemonized */
typedef int (plgdaemon_t)(clixon_handle); /* Plugin pre/post daemonized */
/* Called just before plugin unloaded.
* @param[in] h Clixon handle
*/
typedef int (plgexit_t)(clicon_handle); /* Plugin exit */
typedef int (plgexit_t)(clixon_handle); /* Plugin exit */
/* For yang extension/unknown handling.
* Called at parsing of yang module containing an unknown statement of an extension.
@ -147,7 +147,7 @@ typedef int (plgexit_t)(clicon_handle); /* Plugin exit */
* @retval 0 OK, all callbacks executed OK
* @retval -1 Error in one callback
*/
typedef int (plgextension_t)(clicon_handle h, yang_stmt *yext, yang_stmt *ys);
typedef int (plgextension_t)(clixon_handle h, yang_stmt *yext, yang_stmt *ys);
/*! Called by restconf on each incoming request to check credentials and return username
*/
@ -188,7 +188,7 @@ typedef int (plgextension_t)(clicon_handle h, yang_stmt *yext, yang_stmt *ys);
*
* @note user should be freed by caller
*/
typedef int (plgauth_t)(clicon_handle h, void *req, clixon_auth_type_t auth_type, char **authp);
typedef int (plgauth_t)(clixon_handle h, void *req, clixon_auth_type_t auth_type, char **authp);
/*! Reset system status
*
@ -204,7 +204,7 @@ typedef int (plgauth_t)(clicon_handle h, void *req, clixon_auth_type_t auth_type
* @retval 0 OK
* @retval -1 Fatal error
*/
typedef int (plgreset_t)(clicon_handle h, const char *db);
typedef int (plgreset_t)(clixon_handle h, const char *db);
/* Provide state data from plugin
*
@ -225,7 +225,7 @@ typedef int (plgreset_t)(clicon_handle h, const char *db);
* @note The system does not validate the xml, unless CLICON_VALIDATE_STATE_XML is set
* @see clixon_pagination_cb_register for special paginated state data callback
*/
typedef int (plgstatedata_t)(clicon_handle h, cvec *nsc, char *xpath, cxobj *xtop);
typedef int (plgstatedata_t)(clixon_handle h, cvec *nsc, char *xpath, cxobj *xtop);
/*! Pagination-data type
*
@ -243,7 +243,7 @@ typedef void *pagination_data;
* @retval 0 OK
* @retval -1 Fatal error
*/
typedef int (plglockdb_t)(clicon_handle h, char *db, int lock, int id);
typedef int (plglockdb_t)(clixon_handle h, char *db, int lock, int id);
/*! Transaction-data type
*
@ -252,7 +252,7 @@ typedef int (plglockdb_t)(clicon_handle h, char *db, int lock, int id);
typedef void *transaction_data;
/* Transaction callback */
typedef int (trans_cb_t)(clicon_handle h, transaction_data td);
typedef int (trans_cb_t)(clixon_handle h, transaction_data td);
/*! Hook to override default prompt with explicit function
*
@ -261,7 +261,7 @@ typedef int (trans_cb_t)(clicon_handle h, transaction_data td);
* @param[in] mode Cligen syntax mode
* @retval prompt Prompt to prepend all CLigen command lines
*/
typedef char *(cli_prompthook_t)(clicon_handle, char *mode);
typedef char *(cli_prompthook_t)(clixon_handle, char *mode);
/*! General-purpose datastore upgrade callback called once on startupo
*
@ -274,7 +274,7 @@ typedef char *(cli_prompthook_t)(clicon_handle, char *mode);
* @retval 0 OK
* @retval -1 Error
*/
typedef int (datastore_upgrade_t)(clicon_handle h, const char *db, cxobj *xt, modstate_diff_t *msd);
typedef int (datastore_upgrade_t)(clixon_handle h, const char *db, cxobj *xt, modstate_diff_t *msd);
/*! YANG schema mount
*
@ -298,7 +298,7 @@ typedef int (datastore_upgrade_t)(clicon_handle h, const char *db, cxobj *xt, mo
* at proper parse-time, but this is not visible in the yanglib return
* @see RFC 8528 (schema-mount) and RFC 8525 (yang-lib)
*/
typedef int (yang_mount_t)(clicon_handle h, cxobj *xt, int *config,
typedef int (yang_mount_t)(clixon_handle h, cxobj *xt, int *config,
validate_level *vl, cxobj **yanglib);
/*! YANG module patch
@ -312,7 +312,7 @@ typedef int (yang_mount_t)(clicon_handle h, cxobj *xt, int *config,
* @retval 0 OK
* @retval -1 Error
*/
typedef int (yang_patch_t)(clicon_handle h, yang_stmt *ymod);
typedef int (yang_patch_t)(clixon_handle h, yang_stmt *ymod);
/*! Callback to customize Netconf error message
*
@ -322,7 +322,7 @@ typedef int (yang_patch_t)(clicon_handle h, yang_stmt *ymod);
* @retval 0 OK, with cberr set
* @retval -1 Error
*/
typedef int (netconf_errmsg_t)(clicon_handle, cxobj *xerr, cbuf *cberr);
typedef int (netconf_errmsg_t)(clixon_handle, cxobj *xerr, cbuf *cberr);
/*! Callback for printing version output and exit
*
@ -335,7 +335,7 @@ typedef int (netconf_errmsg_t)(clicon_handle, cxobj *xerr, cbuf *cberr);
* @retval 0 OK
* @retval -1 Error
*/
typedef int (plgversion_t)(clicon_handle, FILE*);
typedef int (plgversion_t)(clixon_handle, FILE*);
/*! Startup status for use in startup-callback
*
@ -355,7 +355,7 @@ enum startup_status{
* Note: Implicit init function
*/
struct clixon_plugin_api;
typedef struct clixon_plugin_api* (plginit_t)(clicon_handle); /* Clixon plugin Init */
typedef struct clixon_plugin_api* (plginit_t)(clixon_handle); /* Clixon plugin Init */
struct clixon_plugin_api{
/*--- Common fields. ---*/
@ -464,62 +464,62 @@ typedef struct {
* @retval NULL Failure (if clixon_err() called), module disabled otherwise.
* @see CLIXON_PLUGIN_INIT default symbol
*/
clixon_plugin_api *clixon_plugin_init(clicon_handle h);
clixon_plugin_api *clixon_plugin_init(clixon_handle h);
clixon_plugin_api *clixon_plugin_api_get(clixon_plugin_t *cp);
char *clixon_plugin_name_get(clixon_plugin_t *cp);
plghndl_t clixon_plugin_handle_get(clixon_plugin_t *cp);
clixon_plugin_t *clixon_plugin_each(clicon_handle h, clixon_plugin_t *cpprev);
clixon_plugin_t *clixon_plugin_each(clixon_handle h, clixon_plugin_t *cpprev);
clixon_plugin_t *clixon_plugin_each_revert(clicon_handle h, clixon_plugin_t *cpprev, int nr);
clixon_plugin_t *clixon_plugin_each_revert(clixon_handle h, clixon_plugin_t *cpprev, int nr);
clixon_plugin_t *clixon_plugin_find(clicon_handle h, const char *name);
clixon_plugin_t *clixon_plugin_find(clixon_handle h, const char *name);
int clixon_plugins_load(clicon_handle h, const char *function, const char *dir, const char *regexp);
int clixon_plugins_load(clixon_handle h, const char *function, const char *dir, const char *regexp);
int clixon_pseudo_plugin(clicon_handle h, const char *name, clixon_plugin_t **cpp);
int clixon_pseudo_plugin(clixon_handle h, const char *name, clixon_plugin_t **cpp);
int plugin_context_check(clicon_handle h, void **wh, const char *name, const char *fn);
int plugin_context_check(clixon_handle h, void **wh, const char *name, const char *fn);
int clixon_plugin_start_one(clixon_plugin_t *cp, clicon_handle h);
int clixon_plugin_start_all(clicon_handle h);
int clixon_plugin_start_one(clixon_plugin_t *cp, clixon_handle h);
int clixon_plugin_start_all(clixon_handle h);
int clixon_plugin_auth_all(clicon_handle h, void *req, clixon_auth_type_t auth_type, char **authp);
int clixon_plugin_auth_all(clixon_handle h, void *req, clixon_auth_type_t auth_type, char **authp);
int clixon_plugin_extension_one(clixon_plugin_t *cp, clicon_handle h, yang_stmt *yext, yang_stmt *ys);
int clixon_plugin_extension_all(clicon_handle h, yang_stmt *yext, yang_stmt *ys);
int clixon_plugin_extension_one(clixon_plugin_t *cp, clixon_handle h, yang_stmt *yext, yang_stmt *ys);
int clixon_plugin_extension_all(clixon_handle h, yang_stmt *yext, yang_stmt *ys);
int clixon_plugin_datastore_upgrade_one(clixon_plugin_t *cp, clicon_handle h, const char *db, cxobj *xt, modstate_diff_t *msd);
int clixon_plugin_datastore_upgrade_all(clicon_handle h, const char *db, cxobj *xt, modstate_diff_t *msd);
int clixon_plugin_datastore_upgrade_one(clixon_plugin_t *cp, clixon_handle h, const char *db, cxobj *xt, modstate_diff_t *msd);
int clixon_plugin_datastore_upgrade_all(clixon_handle h, const char *db, cxobj *xt, modstate_diff_t *msd);
int clixon_plugin_yang_mount_one(clixon_plugin_t *cp, clicon_handle h, cxobj *xt, int *config, validate_level *vl, cxobj **yanglib);
int clixon_plugin_yang_mount_all(clicon_handle h, cxobj *xt, int *config, validate_level *vl, cxobj **yanglib);
int clixon_plugin_yang_mount_one(clixon_plugin_t *cp, clixon_handle h, cxobj *xt, int *config, validate_level *vl, cxobj **yanglib);
int clixon_plugin_yang_mount_all(clixon_handle h, cxobj *xt, int *config, validate_level *vl, cxobj **yanglib);
int clixon_plugin_yang_patch_one(clixon_plugin_t *cp, clicon_handle h, yang_stmt *ymod);
int clixon_plugin_yang_patch_all(clicon_handle h, yang_stmt *ymod);
int clixon_plugin_yang_patch_one(clixon_plugin_t *cp, clixon_handle h, yang_stmt *ymod);
int clixon_plugin_yang_patch_all(clixon_handle h, yang_stmt *ymod);
int clixon_plugin_netconf_errmsg_one(clixon_plugin_t *cp, clicon_handle h, cxobj *xerr, cbuf *cberr);
int clixon_plugin_netconf_errmsg_all(clicon_handle h, cxobj *xerr, cbuf *cberr);
int clixon_plugin_netconf_errmsg_one(clixon_plugin_t *cp, clixon_handle h, cxobj *xerr, cbuf *cberr);
int clixon_plugin_netconf_errmsg_all(clixon_handle h, cxobj *xerr, cbuf *cberr);
int clixon_plugin_version_one(clixon_plugin_t *cp, clicon_handle h, FILE *f);
int clixon_plugin_version_all(clicon_handle h, FILE *f);
int clixon_plugin_version_one(clixon_plugin_t *cp, clixon_handle h, FILE *f);
int clixon_plugin_version_all(clixon_handle h, FILE *f);
/* rpc callback API */
int rpc_callback_register(clicon_handle h, clicon_rpc_cb cb, void *arg, const char *ns, const char *name);
int rpc_callback_call(clicon_handle h, cxobj *xe, void *arg, int *nrp, cbuf *cbret);
int rpc_callback_register(clixon_handle h, clicon_rpc_cb cb, void *arg, const char *ns, const char *name);
int rpc_callback_call(clixon_handle h, cxobj *xe, void *arg, int *nrp, cbuf *cbret);
/* action callback API */
int action_callback_register(clicon_handle h, yang_stmt *ya, clicon_rpc_cb cb, void *arg);
int action_callback_call(clicon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg);
int action_callback_register(clixon_handle h, yang_stmt *ya, clicon_rpc_cb cb, void *arg);
int action_callback_call(clixon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg);
/* upgrade callback API */
int upgrade_callback_reg_fn(clicon_handle h, clicon_upgrade_cb cb, const char *strfn, const char *ns, void *arg);
int upgrade_callback_call(clicon_handle h, cxobj *xt, char *ns, uint16_t op, uint32_t from, uint32_t to, cbuf *cbret);
int upgrade_callback_reg_fn(clixon_handle h, clicon_upgrade_cb cb, const char *strfn, const char *ns, void *arg);
int upgrade_callback_call(clixon_handle h, cxobj *xt, char *ns, uint16_t op, uint32_t from, uint32_t to, cbuf *cbret);
const int clixon_auth_type_str2int(char *auth_type);
const char *clixon_auth_type_int2str(clixon_auth_type_t auth_type);
int clixon_plugin_module_init(clicon_handle h);
int clixon_plugin_module_exit(clicon_handle h);
int clixon_plugin_module_init(clixon_handle h);
int clixon_plugin_module_exit(clixon_handle h);
#endif /* _CLIXON_PLUGIN_H_ */