Hide plugin check handler struct with a handler
This commit is contained in:
parent
764e9c628c
commit
c93348d8d5
5 changed files with 163 additions and 125 deletions
|
|
@ -931,21 +931,20 @@ from_client_restart_one(clicon_handle h,
|
||||||
yang_stmt *yspec;
|
yang_stmt *yspec;
|
||||||
int i;
|
int i;
|
||||||
cxobj *xn;
|
cxobj *xn;
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
yspec = clicon_dbspec_yang(h);
|
yspec = clicon_dbspec_yang(h);
|
||||||
if (xmldb_db_reset(h, db) < 0)
|
if (xmldb_db_reset(h, db) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* Application may define extra xml in its reset function*/
|
/* Application may define extra xml in its reset function*/
|
||||||
if ((resetfn = clixon_plugin_api_get(cp)->ca_reset) != NULL){
|
if ((resetfn = clixon_plugin_api_get(cp)->ca_reset) != NULL){
|
||||||
plugin_context_t pc = {0,};
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if ((retval = resetfn(h, db)) < 0) {
|
if ((retval = resetfn(h, db)) < 0) {
|
||||||
clicon_debug(1, "plugin_start() failed");
|
clicon_debug(1, "plugin_start() failed");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
if (plugin_context_check(pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
/* 1. Start transaction */
|
/* 1. Start transaction */
|
||||||
|
|
@ -1027,6 +1026,8 @@ from_client_restart_one(clicon_handle h,
|
||||||
goto fail;
|
goto fail;
|
||||||
retval = 1;
|
retval = 1;
|
||||||
done:
|
done:
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
if (td){
|
if (td){
|
||||||
xmldb_get0_free(h, &td->td_target);
|
xmldb_get0_free(h, &td->td_target);
|
||||||
transaction_free(td);
|
transaction_free(td);
|
||||||
|
|
|
||||||
|
|
@ -80,11 +80,10 @@ clixon_plugin_reset_one(clixon_plugin_t *cp,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
plgreset_t *fn; /* callback */
|
plgreset_t *fn; /* callback */
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
if ((fn = clixon_plugin_api_get(cp)->ca_reset) != NULL){
|
if ((fn = clixon_plugin_api_get(cp)->ca_reset) != NULL){
|
||||||
plugin_context_t pc = {0,};
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (fn(h, db) < 0) {
|
if (fn(h, db) < 0) {
|
||||||
if (clicon_errno < 0)
|
if (clicon_errno < 0)
|
||||||
|
|
@ -92,11 +91,13 @@ clixon_plugin_reset_one(clixon_plugin_t *cp,
|
||||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
if (plugin_context_check(pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,12 +138,12 @@ clixon_plugin_pre_daemon_one(clixon_plugin_t *cp,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
plgdaemon_t *fn; /* Daemonize plugin callback function */
|
plgdaemon_t *fn; /* Daemonize plugin callback function */
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
if ((fn = clixon_plugin_api_get(cp)->ca_pre_daemon) != NULL){
|
if ((fn = clixon_plugin_api_get(cp)->ca_pre_daemon) != NULL){
|
||||||
plugin_context_t pc = {0,};
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (fn(h) < 0) {
|
if (fn(h) < 0) {
|
||||||
if (clicon_errno < 0)
|
if (clicon_errno < 0)
|
||||||
clicon_log(LOG_WARNING, "%s: Internal error: Pre-daemon callback in plugin:\
|
clicon_log(LOG_WARNING, "%s: Internal error: Pre-daemon callback in plugin:\
|
||||||
|
|
@ -150,11 +151,13 @@ clixon_plugin_pre_daemon_one(clixon_plugin_t *cp,
|
||||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
if (plugin_context_check(pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,11 +199,10 @@ clixon_plugin_daemon_one(clixon_plugin_t *cp,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
plgdaemon_t *fn; /* Daemonize plugin callback function */
|
plgdaemon_t *fn; /* Daemonize plugin callback function */
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
if ((fn = clixon_plugin_api_get(cp)->ca_daemon) != NULL){
|
if ((fn = clixon_plugin_api_get(cp)->ca_daemon) != NULL){
|
||||||
plugin_context_t pc = {0,};
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (fn(h) < 0) {
|
if (fn(h) < 0) {
|
||||||
if (clicon_errno < 0)
|
if (clicon_errno < 0)
|
||||||
|
|
@ -208,11 +210,13 @@ clixon_plugin_daemon_one(clixon_plugin_t *cp,
|
||||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
if (plugin_context_check(pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -279,13 +283,12 @@ clixon_plugin_statedata_one(clixon_plugin_t *cp,
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
plgstatedata_t *fn; /* Plugin statedata fn */
|
plgstatedata_t *fn; /* Plugin statedata fn */
|
||||||
cxobj *x = NULL;
|
cxobj *x = NULL;
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
if ((fn = clixon_plugin_api_get(cp)->ca_statedata) != NULL){
|
if ((fn = clixon_plugin_api_get(cp)->ca_statedata) != NULL){
|
||||||
if ((x = xml_new(DATASTORE_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL)
|
if ((x = xml_new(DATASTORE_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
plugin_context_t pc = {0,};
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (fn(h, nsc, xpath, x) < 0){
|
if (fn(h, nsc, xpath, x) < 0){
|
||||||
if (clicon_errno < 0)
|
if (clicon_errno < 0)
|
||||||
|
|
@ -293,13 +296,15 @@ clixon_plugin_statedata_one(clixon_plugin_t *cp,
|
||||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||||
goto fail; /* Dont quit here on user callbacks */
|
goto fail; /* Dont quit here on user callbacks */
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
if (plugin_context_check(pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (xp && x)
|
if (xp && x)
|
||||||
*xp = x;
|
*xp = x;
|
||||||
retval = 1;
|
retval = 1;
|
||||||
done:
|
done:
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
return retval;
|
return retval;
|
||||||
fail:
|
fail:
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
@ -432,19 +437,20 @@ clixon_plugin_lockdb_one(clixon_plugin_t *cp,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
plglockdb_t *fn; /* Plugin statedata fn */
|
plglockdb_t *fn; /* Plugin statedata fn */
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
if ((fn = clixon_plugin_api_get(cp)->ca_lockdb) != NULL){
|
if ((fn = clixon_plugin_api_get(cp)->ca_lockdb) != NULL){
|
||||||
plugin_context_t pc = {0,};
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (fn(h, db, lock, id) < 0)
|
if (fn(h, db, lock, id) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (plugin_context_check(&pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
if (plugin_context_check(pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -607,11 +613,10 @@ plugin_transaction_begin_one(clixon_plugin_t *cp,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
trans_cb_t *fn;
|
trans_cb_t *fn;
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
if ((fn = clixon_plugin_api_get(cp)->ca_trans_begin) != NULL){
|
if ((fn = clixon_plugin_api_get(cp)->ca_trans_begin) != NULL){
|
||||||
plugin_context_t pc = {0,};
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (fn(h, (transaction_data)td) < 0){
|
if (fn(h, (transaction_data)td) < 0){
|
||||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||||
|
|
@ -619,11 +624,13 @@ plugin_transaction_begin_one(clixon_plugin_t *cp,
|
||||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
if (plugin_context_check(pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -666,11 +673,10 @@ plugin_transaction_validate_one(clixon_plugin_t *cp,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
trans_cb_t *fn;
|
trans_cb_t *fn;
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
if ((fn = clixon_plugin_api_get(cp)->ca_trans_validate) != NULL){
|
if ((fn = clixon_plugin_api_get(cp)->ca_trans_validate) != NULL){
|
||||||
plugin_context_t pc = {0,};
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (fn(h, (transaction_data)td) < 0){
|
if (fn(h, (transaction_data)td) < 0){
|
||||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||||
|
|
@ -678,11 +684,13 @@ plugin_transaction_validate_one(clixon_plugin_t *cp,
|
||||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
if (plugin_context_check(pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -723,11 +731,10 @@ plugin_transaction_complete_one(clixon_plugin_t *cp,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
trans_cb_t *fn;
|
trans_cb_t *fn;
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
if ((fn = clixon_plugin_api_get(cp)->ca_trans_complete) != NULL){
|
if ((fn = clixon_plugin_api_get(cp)->ca_trans_complete) != NULL){
|
||||||
plugin_context_t pc = {0,};
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (fn(h, (transaction_data)td) < 0){
|
if (fn(h, (transaction_data)td) < 0){
|
||||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||||
|
|
@ -735,11 +742,13 @@ plugin_transaction_complete_one(clixon_plugin_t *cp,
|
||||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
if (plugin_context_check(pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -812,11 +821,10 @@ plugin_transaction_commit_one(clixon_plugin_t *cp,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
trans_cb_t *fn;
|
trans_cb_t *fn;
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
if ((fn = clixon_plugin_api_get(cp)->ca_trans_commit) != NULL){
|
if ((fn = clixon_plugin_api_get(cp)->ca_trans_commit) != NULL){
|
||||||
plugin_context_t pc = {0,};
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (fn(h, (transaction_data)td) < 0){
|
if (fn(h, (transaction_data)td) < 0){
|
||||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||||
|
|
@ -824,11 +832,13 @@ plugin_transaction_commit_one(clixon_plugin_t *cp,
|
||||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
if (plugin_context_check(pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -877,11 +887,10 @@ plugin_transaction_commit_done_one(clixon_plugin_t *cp,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
trans_cb_t *fn;
|
trans_cb_t *fn;
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
if ((fn = clixon_plugin_api_get(cp)->ca_trans_commit_done) != NULL){
|
if ((fn = clixon_plugin_api_get(cp)->ca_trans_commit_done) != NULL){
|
||||||
plugin_context_t pc = {0,};
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (fn(h, (transaction_data)td) < 0){
|
if (fn(h, (transaction_data)td) < 0){
|
||||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||||
|
|
@ -889,11 +898,13 @@ plugin_transaction_commit_done_one(clixon_plugin_t *cp,
|
||||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
if (plugin_context_check(pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -934,11 +945,10 @@ plugin_transaction_end_one(clixon_plugin_t *cp,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
trans_cb_t *fn;
|
trans_cb_t *fn;
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
if ((fn = clixon_plugin_api_get(cp)->ca_trans_end) != NULL){
|
if ((fn = clixon_plugin_api_get(cp)->ca_trans_end) != NULL){
|
||||||
plugin_context_t pc = {0,};
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (fn(h, (transaction_data)td) < 0){
|
if (fn(h, (transaction_data)td) < 0){
|
||||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||||
|
|
@ -946,11 +956,13 @@ plugin_transaction_end_one(clixon_plugin_t *cp,
|
||||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
if (plugin_context_check(pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -984,11 +996,10 @@ plugin_transaction_abort_one(clixon_plugin_t *cp,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
trans_cb_t *fn;
|
trans_cb_t *fn;
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
if ((fn = clixon_plugin_api_get(cp)->ca_trans_abort) != NULL){
|
if ((fn = clixon_plugin_api_get(cp)->ca_trans_abort) != NULL){
|
||||||
plugin_context_t pc = {0,};
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (fn(h, (transaction_data)td) < 0){
|
if (fn(h, (transaction_data)td) < 0){
|
||||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||||
|
|
@ -996,11 +1007,13 @@ plugin_transaction_abort_one(clixon_plugin_t *cp,
|
||||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
if (plugin_context_check(pc, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -533,16 +533,16 @@ cligen_clixon_eval(cligen_handle h,
|
||||||
struct cg_callback *cc;
|
struct cg_callback *cc;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
cvec *argv;
|
cvec *argv;
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
if (h)
|
if (h)
|
||||||
cligen_co_match_set(h, co);
|
cligen_co_match_set(h, co);
|
||||||
for (cc = co->co_callbacks; cc; cc=cc->cc_next){
|
for (cc = co->co_callbacks; cc; cc=cc->cc_next){
|
||||||
/* Vector cvec argument to callback */
|
/* Vector cvec argument to callback */
|
||||||
if (cc->cc_fn_vec){
|
if (cc->cc_fn_vec){
|
||||||
plugin_context_t pc = {0,};
|
|
||||||
argv = cc->cc_cvec ? cvec_dup(cc->cc_cvec) : NULL;
|
argv = cc->cc_cvec ? cvec_dup(cc->cc_cvec) : NULL;
|
||||||
cligen_fn_str_set(h, cc->cc_fn_str);
|
cligen_fn_str_set(h, cc->cc_fn_str);
|
||||||
if (plugin_context_get(&pc) < 0)
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
break;
|
break;
|
||||||
if ((retval = (*cc->cc_fn_vec)(
|
if ((retval = (*cc->cc_fn_vec)(
|
||||||
cligen_userhandle(h)?cligen_userhandle(h):h,
|
cligen_userhandle(h)?cligen_userhandle(h):h,
|
||||||
|
|
@ -553,13 +553,19 @@ cligen_clixon_eval(cligen_handle h,
|
||||||
cligen_fn_str_set(h, NULL);
|
cligen_fn_str_set(h, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, "CLIgen", cc->cc_fn_str) < 0)
|
if (plugin_context_check(pc, "CLIgen", cc->cc_fn_str) < 0)
|
||||||
break;
|
break;
|
||||||
|
if (pc){
|
||||||
|
free(pc);
|
||||||
|
pc = NULL;
|
||||||
|
}
|
||||||
if (argv != NULL)
|
if (argv != NULL)
|
||||||
cvec_free(argv);
|
cvec_free(argv);
|
||||||
cligen_fn_str_set(h, NULL);
|
cligen_fn_str_set(h, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -337,16 +337,6 @@ struct clixon_plugin_api{
|
||||||
#define ca_trans_abort u.cau_backend.cb_trans_abort
|
#define ca_trans_abort u.cau_backend.cb_trans_abort
|
||||||
#define ca_datastore_upgrade u.cau_backend.cb_datastore_upgrade
|
#define ca_datastore_upgrade u.cau_backend.cb_datastore_upgrade
|
||||||
|
|
||||||
/*! Structure for checking status before and after a plugin call
|
|
||||||
* Currently signal settings: blocked and handlers, could be extended to more
|
|
||||||
* @see plugin_context_check
|
|
||||||
*/
|
|
||||||
struct plugin_context {
|
|
||||||
sigset_t pc_sigset; /* See sigprocmask(2) */
|
|
||||||
struct sigaction pc_sigaction_vec[32]; /* See sigaction(2) */
|
|
||||||
int pc_status; /* 0: OK, -1: fail */
|
|
||||||
};
|
|
||||||
typedef struct plugin_context plugin_context_t;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Macros
|
* Macros
|
||||||
|
|
@ -359,6 +349,10 @@ typedef struct clixon_plugin_api clixon_plugin_api;
|
||||||
* The internal struct is defined in clixon_plugin.c */
|
* The internal struct is defined in clixon_plugin.c */
|
||||||
typedef struct clixon_plugin clixon_plugin_t;
|
typedef struct clixon_plugin clixon_plugin_t;
|
||||||
|
|
||||||
|
/*! Structure for checking status before and after a plugin call
|
||||||
|
* The internal struct is defined in clixon_plugin.c */
|
||||||
|
typedef struct plugin_context plugin_context_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prototypes
|
* Prototypes
|
||||||
*/
|
*/
|
||||||
|
|
@ -371,7 +365,6 @@ typedef struct clixon_plugin clixon_plugin_t;
|
||||||
*/
|
*/
|
||||||
clixon_plugin_api *clixon_plugin_init(clicon_handle h);
|
clixon_plugin_api *clixon_plugin_init(clicon_handle h);
|
||||||
|
|
||||||
|
|
||||||
clixon_plugin_api *clixon_plugin_api_get(clixon_plugin_t *cp);
|
clixon_plugin_api *clixon_plugin_api_get(clixon_plugin_t *cp);
|
||||||
char *clixon_plugin_name_get(clixon_plugin_t *cp);
|
char *clixon_plugin_name_get(clixon_plugin_t *cp);
|
||||||
plghndl_t clixon_plugin_handle_get(clixon_plugin_t *cp);
|
plghndl_t clixon_plugin_handle_get(clixon_plugin_t *cp);
|
||||||
|
|
@ -386,7 +379,7 @@ int clixon_plugins_load(clicon_handle h, const char *function, const char *dir,
|
||||||
|
|
||||||
int clixon_pseudo_plugin(clicon_handle h, const char *name, clixon_plugin_t **cpp);
|
int clixon_pseudo_plugin(clicon_handle h, const char *name, clixon_plugin_t **cpp);
|
||||||
|
|
||||||
int plugin_context_get(plugin_context_t *pc);
|
plugin_context_t * plugin_context_get(void);
|
||||||
int plugin_context_check(plugin_context_t *pc, const char *name, const char *fn);
|
int plugin_context_check(plugin_context_t *pc, const char *name, const char *fn);
|
||||||
|
|
||||||
int clixon_plugin_start_one(clixon_plugin_t *cp, clicon_handle h);
|
int clixon_plugin_start_one(clixon_plugin_t *cp, clicon_handle h);
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,15 @@
|
||||||
/*
|
/*
|
||||||
* Private types
|
* Private types
|
||||||
*/
|
*/
|
||||||
|
/*! Structure for checking status before and after a plugin call
|
||||||
|
* Currently signal settings: blocked and handlers, could be extended to more
|
||||||
|
* @see plugin_context_check
|
||||||
|
*/
|
||||||
|
struct plugin_context {
|
||||||
|
sigset_t pc_sigset; /* See sigprocmask(2) */
|
||||||
|
struct sigaction pc_sigaction_vec[32]; /* See sigaction(2) */
|
||||||
|
int pc_status; /* 0: OK, -1: fail */
|
||||||
|
};
|
||||||
|
|
||||||
/* Internal plugin structure with dlopen() handle and plugin_api
|
/* Internal plugin structure with dlopen() handle and plugin_api
|
||||||
* This is an internal type, not exposed in the API
|
* This is an internal type, not exposed in the API
|
||||||
|
|
@ -331,7 +340,7 @@ plugin_load_one(clicon_handle h,
|
||||||
clixon_plugin_t *cp = NULL;
|
clixon_plugin_t *cp = NULL;
|
||||||
char *name;
|
char *name;
|
||||||
char *p;
|
char *p;
|
||||||
plugin_context_t pc = {0,};
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
clicon_debug(1, "%s file:%s function:%s", __FUNCTION__, file, function);
|
clicon_debug(1, "%s file:%s function:%s", __FUNCTION__, file, function);
|
||||||
dlerror(); /* Clear any existing error */
|
dlerror(); /* Clear any existing error */
|
||||||
|
|
@ -350,9 +359,7 @@ plugin_load_one(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
clicon_err_reset();
|
clicon_err_reset();
|
||||||
|
if ((pc = plugin_context_get()) < 0)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if ((api = initfn(h)) == NULL) {
|
if ((api = initfn(h)) == NULL) {
|
||||||
|
|
@ -366,7 +373,7 @@ plugin_load_one(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, file, __FUNCTION__) < 0)
|
if (plugin_context_check(pc, file, __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* Note: sizeof clixon_plugin_api which is largest of clixon_plugin_api:s */
|
/* Note: sizeof clixon_plugin_api which is largest of clixon_plugin_api:s */
|
||||||
|
|
@ -392,6 +399,8 @@ plugin_load_one(clicon_handle h,
|
||||||
retval = 1;
|
retval = 1;
|
||||||
done:
|
done:
|
||||||
clicon_debug(1, "%s retval:%d", __FUNCTION__, retval);
|
clicon_debug(1, "%s retval:%d", __FUNCTION__, retval);
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
if (retval != 1 && handle)
|
if (retval != 1 && handle)
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
if (cp)
|
if (cp)
|
||||||
|
|
@ -495,14 +504,20 @@ done:
|
||||||
|
|
||||||
/*! Get system context, eg signal procmask (for blocking) and sigactions
|
/*! Get system context, eg signal procmask (for blocking) and sigactions
|
||||||
* Call this before a plugin
|
* Call this before a plugin
|
||||||
|
* @retval pc Plugin context structure, use free() to deallocate
|
||||||
|
* @retval NULL Error
|
||||||
* @see plugin_context_check
|
* @see plugin_context_check
|
||||||
*/
|
* */
|
||||||
int
|
plugin_context_t *
|
||||||
plugin_context_get(plugin_context_t *pc)
|
plugin_context_get(void)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
|
||||||
int i;
|
int i;
|
||||||
|
struct plugin_context *pc = NULL;
|
||||||
|
|
||||||
|
if ((pc = malloc(sizeof *pc)) == NULL){
|
||||||
|
clicon_err(OE_UNIX, errno, "malloc");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
if (sigprocmask(0, NULL, &pc->pc_sigset) < 0){
|
if (sigprocmask(0, NULL, &pc->pc_sigset) < 0){
|
||||||
clicon_err(OE_UNIX, errno, "sigprocmask");
|
clicon_err(OE_UNIX, errno, "sigprocmask");
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -521,9 +536,11 @@ plugin_context_get(plugin_context_t *pc)
|
||||||
pc->pc_sigaction_vec[i].sa_flags &= ~0x04000000;
|
pc->pc_sigaction_vec[i].sa_flags &= ~0x04000000;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
retval = 0;
|
return pc;
|
||||||
done:
|
done:
|
||||||
return retval;
|
if (pc)
|
||||||
|
free(pc);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Given an existing, old plugin context, check if anytjing has changed
|
/*! Given an existing, old plugin context, check if anytjing has changed
|
||||||
|
|
@ -535,39 +552,40 @@ plugin_context_get(plugin_context_t *pc)
|
||||||
* @see plugin_context_get
|
* @see plugin_context_get
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
plugin_context_check(plugin_context_t *oldpc,
|
plugin_context_check(plugin_context_t *oldpc0,
|
||||||
const char *name,
|
const char *name,
|
||||||
const char *fn)
|
const char *fn)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
int failed;
|
int failed;
|
||||||
int i;
|
int i;
|
||||||
plugin_context_t newpc = {0, };
|
struct plugin_context *oldpc = oldpc0;
|
||||||
|
struct plugin_context *newpc = NULL;
|
||||||
|
|
||||||
if (plugin_context_get(&newpc) < 0)
|
if ((newpc = plugin_context_get()) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
for (i=1; i<32; i++){
|
for (i=1; i<32; i++){
|
||||||
failed = 0;
|
failed = 0;
|
||||||
if (sigismember(&oldpc->pc_sigset, i) != sigismember(&newpc.pc_sigset, i)){
|
if (sigismember(&oldpc->pc_sigset, i) != sigismember(&newpc->pc_sigset, i)){
|
||||||
clicon_log(LOG_WARNING, "%s Plugin %s %s: Changed blocking of signal %s(%d) from %d to %d", __FUNCTION__,
|
clicon_log(LOG_WARNING, "%s Plugin %s %s: Changed blocking of signal %s(%d) from %d to %d", __FUNCTION__,
|
||||||
name, fn, strsignal(i), i,
|
name, fn, strsignal(i), i,
|
||||||
sigismember(&oldpc->pc_sigset, i),
|
sigismember(&oldpc->pc_sigset, i),
|
||||||
sigismember(&newpc.pc_sigset, i)
|
sigismember(&newpc->pc_sigset, i)
|
||||||
);
|
);
|
||||||
failed++;
|
failed++;
|
||||||
}
|
}
|
||||||
if (oldpc->pc_sigaction_vec[i].sa_flags != newpc.pc_sigaction_vec[i].sa_flags){
|
if (oldpc->pc_sigaction_vec[i].sa_flags != newpc->pc_sigaction_vec[i].sa_flags){
|
||||||
clicon_log(LOG_WARNING, "%s Plugin %s %s: Changed flags of signal %s(%d) from 0x%x to 0x%x", __FUNCTION__,
|
clicon_log(LOG_WARNING, "%s Plugin %s %s: Changed flags of signal %s(%d) from 0x%x to 0x%x", __FUNCTION__,
|
||||||
name, fn, strsignal(i), i,
|
name, fn, strsignal(i), i,
|
||||||
oldpc->pc_sigaction_vec[i].sa_flags,
|
oldpc->pc_sigaction_vec[i].sa_flags,
|
||||||
newpc.pc_sigaction_vec[i].sa_flags);;
|
newpc->pc_sigaction_vec[i].sa_flags);;
|
||||||
failed++;
|
failed++;
|
||||||
}
|
}
|
||||||
if (oldpc->pc_sigaction_vec[i].sa_sigaction != newpc.pc_sigaction_vec[i].sa_sigaction){
|
if (oldpc->pc_sigaction_vec[i].sa_sigaction != newpc->pc_sigaction_vec[i].sa_sigaction){
|
||||||
clicon_log(LOG_WARNING, "%s Plugin %s %s: Changed action of signal %s(%d) from %p to %p", __FUNCTION__,
|
clicon_log(LOG_WARNING, "%s Plugin %s %s: Changed action of signal %s(%d) from %p to %p", __FUNCTION__,
|
||||||
name, fn, strsignal(i), i,
|
name, fn, strsignal(i), i,
|
||||||
oldpc->pc_sigaction_vec[i].sa_sigaction,
|
oldpc->pc_sigaction_vec[i].sa_sigaction,
|
||||||
newpc.pc_sigaction_vec[i].sa_sigaction);
|
newpc->pc_sigaction_vec[i].sa_sigaction);
|
||||||
failed++;
|
failed++;
|
||||||
}
|
}
|
||||||
if (failed){
|
if (failed){
|
||||||
|
|
@ -577,6 +595,8 @@ plugin_context_check(plugin_context_t *oldpc,
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (newpc)
|
||||||
|
free(newpc);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -592,11 +612,10 @@ clixon_plugin_start_one(clixon_plugin_t *cp,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
plgstart_t *fn; /* Plugin start */
|
plgstart_t *fn; /* Plugin start */
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
if ((fn = cp->cp_api.ca_start) != NULL){
|
if ((fn = cp->cp_api.ca_start) != NULL){
|
||||||
plugin_context_t pc = {0,};
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (fn(h) < 0) {
|
if (fn(h) < 0) {
|
||||||
if (clicon_errno < 0)
|
if (clicon_errno < 0)
|
||||||
|
|
@ -604,11 +623,13 @@ clixon_plugin_start_one(clixon_plugin_t *cp,
|
||||||
__FUNCTION__, cp->cp_name);
|
__FUNCTION__, cp->cp_name);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, cp->cp_name, __FUNCTION__) < 0)
|
if (plugin_context_check(pc, cp->cp_name, __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -646,11 +667,10 @@ clixon_plugin_exit_one(clixon_plugin_t *cp,
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
char *error;
|
char *error;
|
||||||
plgexit_t *fn;
|
plgexit_t *fn;
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
if ((fn = cp->cp_api.ca_exit) != NULL){
|
if ((fn = cp->cp_api.ca_exit) != NULL){
|
||||||
plugin_context_t pc = {0,};
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (fn(h) < 0) {
|
if (fn(h) < 0) {
|
||||||
if (clicon_errno < 0)
|
if (clicon_errno < 0)
|
||||||
|
|
@ -658,7 +678,7 @@ clixon_plugin_exit_one(clixon_plugin_t *cp,
|
||||||
__FUNCTION__, cp->cp_name);
|
__FUNCTION__, cp->cp_name);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, cp->cp_name, __FUNCTION__) < 0)
|
if (plugin_context_check(pc, cp->cp_name, __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (dlclose(cp->cp_handle) != 0) {
|
if (dlclose(cp->cp_handle) != 0) {
|
||||||
error = (char*)dlerror();
|
error = (char*)dlerror();
|
||||||
|
|
@ -667,6 +687,8 @@ clixon_plugin_exit_one(clixon_plugin_t *cp,
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -717,12 +739,11 @@ clixon_plugin_auth_one(clixon_plugin_t *cp,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
plgauth_t *fn; /* Plugin auth */
|
plgauth_t *fn; /* Plugin auth */
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
clicon_debug(1, "%s", __FUNCTION__);
|
clicon_debug(1, "%s", __FUNCTION__);
|
||||||
if ((fn = cp->cp_api.ca_auth) != NULL){
|
if ((fn = cp->cp_api.ca_auth) != NULL){
|
||||||
plugin_context_t pc = {0,};
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if ((retval = fn(h, req, auth_type, authp)) < 0) {
|
if ((retval = fn(h, req, auth_type, authp)) < 0) {
|
||||||
if (clicon_errno < 0)
|
if (clicon_errno < 0)
|
||||||
|
|
@ -730,12 +751,14 @@ clixon_plugin_auth_one(clixon_plugin_t *cp,
|
||||||
__FUNCTION__, cp->cp_name);
|
__FUNCTION__, cp->cp_name);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, cp->cp_name, __FUNCTION__) < 0)
|
if (plugin_context_check(pc, cp->cp_name, __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
retval = 0; /* Ignored / no callback */
|
retval = 0; /* Ignored / no callback */
|
||||||
done:
|
done:
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
clicon_debug(1, "%s retval:%d auth:%s", __FUNCTION__, retval, *authp);
|
clicon_debug(1, "%s retval:%d auth:%s", __FUNCTION__, retval, *authp);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
@ -801,11 +824,10 @@ clixon_plugin_extension_one(clixon_plugin_t *cp,
|
||||||
{
|
{
|
||||||
int retval = 1;
|
int retval = 1;
|
||||||
plgextension_t *fn; /* Plugin extension fn */
|
plgextension_t *fn; /* Plugin extension fn */
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
if ((fn = cp->cp_api.ca_extension) != NULL){
|
if ((fn = cp->cp_api.ca_extension) != NULL){
|
||||||
plugin_context_t pc = {0,};
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (fn(h, yext, ys) < 0) {
|
if (fn(h, yext, ys) < 0) {
|
||||||
if (clicon_errno < 0)
|
if (clicon_errno < 0)
|
||||||
|
|
@ -813,11 +835,13 @@ clixon_plugin_extension_one(clixon_plugin_t *cp,
|
||||||
__FUNCTION__, cp->cp_name);
|
__FUNCTION__, cp->cp_name);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, cp->cp_name, __FUNCTION__) < 0)
|
if (plugin_context_check(pc, cp->cp_name, __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -871,11 +895,10 @@ clixon_plugin_datastore_upgrade_one(clixon_plugin_t *cp,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
datastore_upgrade_t *fn;
|
datastore_upgrade_t *fn;
|
||||||
|
plugin_context_t *pc = NULL;
|
||||||
|
|
||||||
if ((fn = cp->cp_api.ca_datastore_upgrade) != NULL){
|
if ((fn = cp->cp_api.ca_datastore_upgrade) != NULL){
|
||||||
plugin_context_t pc = {0,};
|
if ((pc = plugin_context_get()) == NULL)
|
||||||
|
|
||||||
if (plugin_context_get(&pc) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (fn(h, db, xt, msd) < 0) {
|
if (fn(h, db, xt, msd) < 0) {
|
||||||
if (clicon_errno < 0)
|
if (clicon_errno < 0)
|
||||||
|
|
@ -883,11 +906,13 @@ clixon_plugin_datastore_upgrade_one(clixon_plugin_t *cp,
|
||||||
__FUNCTION__, cp->cp_name);
|
__FUNCTION__, cp->cp_name);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (plugin_context_check(&pc, cp->cp_name, __FUNCTION__) < 0)
|
if (plugin_context_check(pc, cp->cp_name, __FUNCTION__) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (pc)
|
||||||
|
free(pc);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue