- Restructure plugin module using a "module struct" rather than global variables.
This include plugin module init and exit functions New type: clixon_plugin_t exposed via public API while struct clixon_plugin is private - Makefile changes for static linkage using "LINKAGE=static" - Moved nacm external init to later stage in backend_main
This commit is contained in:
parent
7ebb538ebf
commit
b88722fa25
29 changed files with 557 additions and 345 deletions
|
|
@ -46,7 +46,9 @@ endif
|
|||
SH_SUFFIX = @SH_SUFFIX@
|
||||
INSTALLFLAGS = @INSTALLFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
ifeq ($(LINKAGE),static)
|
||||
LDFLAGS += -rdynamic -L.
|
||||
endif
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
bindir = @bindir@
|
||||
|
|
@ -63,7 +65,7 @@ CLIXON_MINOR = @CLIXON_VERSION_MINOR@
|
|||
|
||||
# Use this clixon lib for linking
|
||||
ifeq ($(LINKAGE),static)
|
||||
CLIXON_LIB = libclixon$(SH_SUFFIX)
|
||||
CLIXON_LIB = libclixon.a
|
||||
else
|
||||
CLIXON_LIB = libclixon$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR)
|
||||
endif
|
||||
|
|
@ -113,6 +115,7 @@ $(top_srcdir)/lib/src/$(CLIXON_LIB):
|
|||
|
||||
clean:
|
||||
rm -f *.core $(APPL) $(APPOBJ) $(LIBOBJ) $(MYLIB) $(MYLIBSO) $(MYLIBLINK) test test.c
|
||||
rm -f *.gcda *.gcno *.gcov # coverage
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile *~ .depend
|
||||
|
|
@ -130,8 +133,8 @@ install-lib: $(MYLIB)
|
|||
install -m 0644 $(INSTALLFLAGS) $(MYLIB) $(DESTDIR)$(libdir)
|
||||
install -d -m 0755 $(DESTDIR)$(libdir)/clixon/plugins/backend
|
||||
ifeq ($(LINKAGE),dynamic)
|
||||
ln -sf $(MYLIB) $(DESTDIR)$(libdir)/$(MYLIBSO) # -l:libclixon_config.so.2
|
||||
ln -sf $(MYLIBSO) $(DESTDIR)$(libdir)/$(MYLIBLINK) # -l:libclixon_config.so
|
||||
ln -sf $(MYLIB) $(DESTDIR)$(libdir)/$(MYLIBSO) # -l:libclixon_backend.so.2
|
||||
ln -sf $(MYLIBSO) $(DESTDIR)$(libdir)/$(MYLIBLINK) # -l:libclixon_backend.so
|
||||
endif
|
||||
|
||||
uninstall:
|
||||
|
|
@ -147,7 +150,7 @@ install-include: clixon_backend.h clixon_backend_handle.h clixon_backend_transac
|
|||
.SUFFIXES: .c .o
|
||||
|
||||
.c.o:
|
||||
$(CC) $(INCLUDES) -D__PROGRAM__=\"$(APPL)\" $(CPPFLAGS) $(CFLAGS) -c $<
|
||||
$(CC) $(INCLUDES) $(CPPFLAGS) -D__PROGRAM__=\"$(APPL)\" $(CFLAGS) -c $<
|
||||
|
||||
# Just link test programs
|
||||
test.c :
|
||||
|
|
@ -157,7 +160,11 @@ test: test.c $(LIBOBJ) $(MYLIB)
|
|||
$(CC) $(INCLUDES) $(LDFLAGS) $< $(LIBOBJ) -L. $(MYLIB) $(LIBS) -o $@
|
||||
|
||||
$(APPL) : $(APPOBJ) $(MYLIB) $(LIBDEPS)
|
||||
ifeq ($(LINKAGE),dynamic)
|
||||
$(CC) $(LDFLAGS) $(APPOBJ) -L. $(MYLIB) $(LIBS) -o $@
|
||||
else
|
||||
$(CC) $(LDFLAGS) $(APPOBJ) -L. $(LIBOBJ) $(LIBS) -o $@
|
||||
endif
|
||||
|
||||
$(MYLIBDYNAMIC): $(LIBOBJ) $(LIBDEPS)
|
||||
ifeq ($(HOST_VENDOR),apple)
|
||||
|
|
|
|||
|
|
@ -1547,7 +1547,7 @@ from_client_restart_plugin(clicon_handle h,
|
|||
cxobj **vec = NULL;
|
||||
size_t veclen;
|
||||
int i;
|
||||
clixon_plugin *cp;
|
||||
clixon_plugin_t *cp;
|
||||
int ret;
|
||||
|
||||
if (xpath_vec(xe, NULL, "plugin", &vec, &veclen) < 0)
|
||||
|
|
|
|||
|
|
@ -878,7 +878,7 @@ from_client_validate(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
from_client_restart_one(clicon_handle h,
|
||||
clixon_plugin *cp,
|
||||
clixon_plugin_t *cp,
|
||||
cbuf *cbret)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -895,7 +895,7 @@ from_client_restart_one(clicon_handle h,
|
|||
if (xmldb_db_reset(h, db) < 0)
|
||||
goto done;
|
||||
/* Application may define extra xml in its reset function*/
|
||||
if ((resetfn = cp->cp_api.ca_reset) != NULL){
|
||||
if ((resetfn = clixon_plugin_api_get(cp)->ca_reset) != NULL){
|
||||
if ((retval = resetfn(h, db)) < 0) {
|
||||
clicon_debug(1, "plugin_start() failed");
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -50,6 +50,6 @@ int from_client_commit(clicon_handle h, cxobj *xe, cbuf *cbret, void *arg, void
|
|||
int from_client_discard_changes(clicon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg);
|
||||
int from_client_cancel_commit(clicon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg);
|
||||
int from_client_validate(clicon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg);
|
||||
int from_client_restart_one(clicon_handle h, clixon_plugin *cp, cbuf *cbret);
|
||||
int from_client_restart_one(clicon_handle h, clixon_plugin_t *cp, cbuf *cbret);
|
||||
|
||||
#endif /* _BACKEND_COMMIT_H_ */
|
||||
|
|
|
|||
|
|
@ -125,11 +125,8 @@ backend_terminate(clicon_handle h)
|
|||
if ((x = clicon_conf_xml(h)) != NULL)
|
||||
xml_free(x);
|
||||
stream_publish_exit();
|
||||
clixon_plugin_exit_all(h);
|
||||
/* Delete all backend plugin RPC callbacks */
|
||||
rpc_callback_delete_all(h);
|
||||
/* Delete all backend plugin upgrade callbacks */
|
||||
upgrade_callback_delete_all(h);
|
||||
/* Delete all plugins, RPC callbacks, and upgrade callbacks */
|
||||
clixon_plugin_module_exit(h);
|
||||
/* Delete all process-control entries */
|
||||
clixon_process_delete_all(h);
|
||||
|
||||
|
|
@ -517,7 +514,6 @@ main(int argc,
|
|||
/* Initiate CLICON handle */
|
||||
if ((h = backend_handle_init()) == NULL)
|
||||
return -1;
|
||||
|
||||
foreground = 0;
|
||||
once = 0;
|
||||
zap = 0;
|
||||
|
|
@ -582,12 +578,10 @@ main(int argc,
|
|||
clicon_option_str_set(h, "CLICON_WWWUSER", WWWUSER);
|
||||
clicon_option_str_set(h, "CLICON_WWWDIR", WWWDIR);
|
||||
|
||||
/* External NACM file? */
|
||||
nacm_mode = clicon_option_str(h, "CLICON_NACM_MODE");
|
||||
if (nacm_mode && strcmp(nacm_mode, "external") == 0)
|
||||
if (nacm_load_external(h) < 0)
|
||||
goto done;
|
||||
|
||||
/* Initialize plugin module by creating a handle holding plugin and callback lists */
|
||||
if (clixon_plugin_module_init(h) < 0)
|
||||
goto done;
|
||||
|
||||
/* Now run through the operational args */
|
||||
opterr = 1;
|
||||
optind = 1;
|
||||
|
|
@ -780,6 +774,14 @@ main(int argc,
|
|||
if (netconf_module_features(h) < 0)
|
||||
goto done;
|
||||
|
||||
/* External NACM file?
|
||||
* Note, loads yang -> extensions -> plugins
|
||||
*/
|
||||
nacm_mode = clicon_option_str(h, "CLICON_NACM_MODE");
|
||||
if (nacm_mode && strcmp(nacm_mode, "external") == 0)
|
||||
if (nacm_load_external(h) < 0)
|
||||
goto done;
|
||||
|
||||
/* Create top-level yang spec and store as option */
|
||||
if ((yspec = yspec_new()) == NULL)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -74,18 +74,18 @@
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
clixon_plugin_reset_one(clixon_plugin *cp,
|
||||
clixon_plugin_reset_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
char *db)
|
||||
{
|
||||
int retval = -1;
|
||||
plgreset_t *fn; /* callback */
|
||||
|
||||
if ((fn = cp->cp_api.ca_reset) != NULL){
|
||||
if ((fn = clixon_plugin_api_get(cp)->ca_reset) != NULL){
|
||||
if (fn(h, db) < 0) {
|
||||
if (clicon_errno < 0)
|
||||
clicon_log(LOG_WARNING, "%s: Internal error: Reset callback in plugin: %s returned -1 but did not make a clicon_err call",
|
||||
__FUNCTION__, cp->cp_name);
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -106,7 +106,7 @@ clixon_plugin_reset_all(clicon_handle h,
|
|||
char *db)
|
||||
{
|
||||
int retval = -1;
|
||||
clixon_plugin *cp = NULL;
|
||||
clixon_plugin_t *cp = NULL;
|
||||
|
||||
/* Loop through all plugins, call callbacks in each */
|
||||
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
|
||||
|
|
@ -125,18 +125,18 @@ clixon_plugin_reset_all(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
clixon_plugin_pre_daemon_one(clixon_plugin *cp,
|
||||
clixon_plugin_pre_daemon_one(clixon_plugin_t *cp,
|
||||
clicon_handle h)
|
||||
{
|
||||
int retval = -1;
|
||||
plgdaemon_t *fn; /* Daemonize plugin callback function */
|
||||
|
||||
if ((fn = cp->cp_api.ca_pre_daemon) != NULL){
|
||||
if ((fn = clixon_plugin_api_get(cp)->ca_pre_daemon) != NULL){
|
||||
if (fn(h) < 0) {
|
||||
if (clicon_errno < 0)
|
||||
clicon_log(LOG_WARNING, "%s: Internal error: Pre-daemon callback in plugin:\
|
||||
%s returned -1 but did not make a clicon_err call",
|
||||
__FUNCTION__, cp->cp_name);
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -158,7 +158,7 @@ int
|
|||
clixon_plugin_pre_daemon_all(clicon_handle h)
|
||||
{
|
||||
int retval = -1;
|
||||
clixon_plugin *cp = NULL;
|
||||
clixon_plugin_t *cp = NULL;
|
||||
|
||||
/* Loop through all plugins, call callbacks in each */
|
||||
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
|
||||
|
|
@ -177,17 +177,17 @@ clixon_plugin_pre_daemon_all(clicon_handle h)
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
clixon_plugin_daemon_one(clixon_plugin *cp,
|
||||
clixon_plugin_daemon_one(clixon_plugin_t *cp,
|
||||
clicon_handle h)
|
||||
{
|
||||
int retval = -1;
|
||||
plgdaemon_t *fn; /* Daemonize plugin callback function */
|
||||
|
||||
if ((fn = cp->cp_api.ca_daemon) != NULL){
|
||||
if ((fn = clixon_plugin_api_get(cp)->ca_daemon) != NULL){
|
||||
if (fn(h) < 0) {
|
||||
if (clicon_errno < 0)
|
||||
clicon_log(LOG_WARNING, "%s: Internal error: Daemon callback in plugin: %s returned -1 but did not make a clicon_err call",
|
||||
__FUNCTION__, cp->cp_name);
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -211,7 +211,7 @@ int
|
|||
clixon_plugin_daemon_all(clicon_handle h)
|
||||
{
|
||||
int retval = -1;
|
||||
clixon_plugin *cp = NULL;
|
||||
clixon_plugin_t *cp = NULL;
|
||||
|
||||
/* Loop through all plugins, call callbacks in each */
|
||||
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
|
||||
|
|
@ -244,7 +244,7 @@ clixon_plugin_daemon_all(clicon_handle h)
|
|||
* @retval 1 OK if callback found (and called) xret is set
|
||||
*/
|
||||
static int
|
||||
clixon_plugin_statedata_one(clixon_plugin *cp,
|
||||
clixon_plugin_statedata_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
cvec *nsc,
|
||||
char *xpath,
|
||||
|
|
@ -254,13 +254,13 @@ clixon_plugin_statedata_one(clixon_plugin *cp,
|
|||
plgstatedata_t *fn; /* Plugin statedata fn */
|
||||
cxobj *x = NULL;
|
||||
|
||||
if ((fn = cp->cp_api.ca_statedata) != NULL){
|
||||
if ((fn = clixon_plugin_api_get(cp)->ca_statedata) != NULL){
|
||||
if ((x = xml_new(XML_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
if (fn(h, nsc, xpath, x) < 0){
|
||||
if (clicon_errno < 0)
|
||||
clicon_log(LOG_WARNING, "%s: Internal error: State callback in plugin: %s returned -1 but did not make a clicon_err call",
|
||||
__FUNCTION__, cp->cp_name);
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto fail; /* Dont quit here on user callbacks */
|
||||
}
|
||||
|
||||
|
|
@ -298,7 +298,7 @@ clixon_plugin_statedata_all(clicon_handle h,
|
|||
int retval = -1;
|
||||
int ret;
|
||||
cxobj *x = NULL;
|
||||
clixon_plugin *cp = NULL;
|
||||
clixon_plugin_t *cp = NULL;
|
||||
cbuf *cberr = NULL;
|
||||
cxobj *xerr = NULL;
|
||||
|
||||
|
|
@ -313,7 +313,7 @@ clixon_plugin_statedata_all(clicon_handle h,
|
|||
}
|
||||
/* error reason should be in clicon_err_reason */
|
||||
cprintf(cberr, "Internal error, state callback in plugin %s returned invalid XML: %s",
|
||||
cp->cp_name, clicon_err_reason);
|
||||
clixon_plugin_name_get(cp), clicon_err_reason);
|
||||
if (netconf_operation_failed_xml(&xerr, "application", cbuf_get(cberr)) < 0)
|
||||
goto done;
|
||||
xml_free(*xret);
|
||||
|
|
@ -338,7 +338,7 @@ clixon_plugin_statedata_all(clicon_handle h,
|
|||
if (ret == 0){
|
||||
if (clixon_netconf_internal_error(xerr,
|
||||
". Internal error, state callback returned invalid XML from plugin: ",
|
||||
cp->cp_name) < 0)
|
||||
clixon_plugin_name_get(cp)) < 0)
|
||||
goto done;
|
||||
xml_free(*xret);
|
||||
*xret = xerr;
|
||||
|
|
@ -432,18 +432,18 @@ transaction_free(transaction_data_t *td)
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
plugin_transaction_begin_one(clixon_plugin *cp,
|
||||
plugin_transaction_begin_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
trans_cb_t *fn;
|
||||
|
||||
if ((fn = cp->cp_api.ca_trans_begin) != NULL){
|
||||
if ((fn = clixon_plugin_api_get(cp)->ca_trans_begin) != NULL){
|
||||
if (fn(h, (transaction_data)td) < 0){
|
||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||
clicon_log(LOG_NOTICE, "%s: Plugin '%s' callback does not make clicon_err call on error",
|
||||
__FUNCTION__, cp->cp_name);
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -465,7 +465,7 @@ plugin_transaction_begin_all(clicon_handle h,
|
|||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
clixon_plugin *cp = NULL;
|
||||
clixon_plugin_t *cp = NULL;
|
||||
|
||||
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
|
||||
if (plugin_transaction_begin_one(cp, h, td) < 0)
|
||||
|
|
@ -484,18 +484,18 @@ plugin_transaction_begin_all(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
plugin_transaction_validate_one(clixon_plugin *cp,
|
||||
plugin_transaction_validate_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
trans_cb_t *fn;
|
||||
|
||||
if ((fn = cp->cp_api.ca_trans_validate) != NULL){
|
||||
if ((fn = clixon_plugin_api_get(cp)->ca_trans_validate) != NULL){
|
||||
if (fn(h, (transaction_data)td) < 0){
|
||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||
clicon_log(LOG_NOTICE, "%s: Plugin '%s' callback does not make clicon_err call on error",
|
||||
__FUNCTION__, cp->cp_name);
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -515,7 +515,7 @@ plugin_transaction_validate_all(clicon_handle h,
|
|||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
clixon_plugin *cp = NULL;
|
||||
clixon_plugin_t *cp = NULL;
|
||||
|
||||
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
|
||||
if (plugin_transaction_validate_one(cp, h, td) < 0)
|
||||
|
|
@ -535,18 +535,18 @@ plugin_transaction_validate_all(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
plugin_transaction_complete_one(clixon_plugin *cp,
|
||||
plugin_transaction_complete_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
trans_cb_t *fn;
|
||||
|
||||
if ((fn = cp->cp_api.ca_trans_complete) != NULL){
|
||||
if ((fn = clixon_plugin_api_get(cp)->ca_trans_complete) != NULL){
|
||||
if (fn(h, (transaction_data)td) < 0){
|
||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||
clicon_log(LOG_NOTICE, "%s: Plugin '%s' callback does not make clicon_err call on error",
|
||||
__FUNCTION__, cp->cp_name);
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -568,7 +568,7 @@ plugin_transaction_complete_all(clicon_handle h,
|
|||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
clixon_plugin *cp = NULL;
|
||||
clixon_plugin_t *cp = NULL;
|
||||
|
||||
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
|
||||
if (plugin_transaction_complete_one(cp, h, td) < 0)
|
||||
|
|
@ -594,15 +594,15 @@ plugin_transaction_revert_all(clicon_handle h,
|
|||
int nr)
|
||||
{
|
||||
int retval = 0;
|
||||
clixon_plugin *cp = NULL;
|
||||
clixon_plugin_t *cp = NULL;
|
||||
trans_cb_t *fn;
|
||||
|
||||
while ((cp = clixon_plugin_each_revert(h, cp, nr)) != NULL) {
|
||||
if ((fn = cp->cp_api.ca_trans_revert) == NULL)
|
||||
if ((fn = clixon_plugin_api_get(cp)->ca_trans_revert) == NULL)
|
||||
continue;
|
||||
if ((retval = fn(h, (transaction_data)td)) < 0){
|
||||
clicon_log(LOG_NOTICE, "%s: Plugin '%s' trans_revert callback failed",
|
||||
__FUNCTION__, cp->cp_name);
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -618,18 +618,18 @@ plugin_transaction_revert_all(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
plugin_transaction_commit_one(clixon_plugin *cp,
|
||||
plugin_transaction_commit_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
trans_cb_t *fn;
|
||||
|
||||
if ((fn = cp->cp_api.ca_trans_commit) != NULL){
|
||||
if ((fn = clixon_plugin_api_get(cp)->ca_trans_commit) != NULL){
|
||||
if (fn(h, (transaction_data)td) < 0){
|
||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||
clicon_log(LOG_NOTICE, "%s: Plugin '%s' callback does not make clicon_err call on error",
|
||||
__FUNCTION__, cp->cp_name);
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -652,7 +652,7 @@ plugin_transaction_commit_all(clicon_handle h,
|
|||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
clixon_plugin *cp = NULL;
|
||||
clixon_plugin_t *cp = NULL;
|
||||
int i=0;
|
||||
|
||||
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
|
||||
|
|
@ -677,18 +677,18 @@ plugin_transaction_commit_all(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
plugin_transaction_commit_done_one(clixon_plugin *cp,
|
||||
plugin_transaction_commit_done_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
trans_cb_t *fn;
|
||||
|
||||
if ((fn = cp->cp_api.ca_trans_commit_done) != NULL){
|
||||
if ((fn = clixon_plugin_api_get(cp)->ca_trans_commit_done) != NULL){
|
||||
if (fn(h, (transaction_data)td) < 0){
|
||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||
clicon_log(LOG_NOTICE, "%s: Plugin '%s' callback does not make clicon_err call on error",
|
||||
__FUNCTION__, cp->cp_name);
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -709,7 +709,7 @@ plugin_transaction_commit_done_all(clicon_handle h,
|
|||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
clixon_plugin *cp = NULL;
|
||||
clixon_plugin_t *cp = NULL;
|
||||
|
||||
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
|
||||
if (plugin_transaction_commit_done_one(cp, h, td) < 0)
|
||||
|
|
@ -728,18 +728,18 @@ plugin_transaction_commit_done_all(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
plugin_transaction_end_one(clixon_plugin *cp,
|
||||
plugin_transaction_end_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
trans_cb_t *fn;
|
||||
|
||||
if ((fn = cp->cp_api.ca_trans_end) != NULL){
|
||||
if ((fn = clixon_plugin_api_get(cp)->ca_trans_end) != NULL){
|
||||
if (fn(h, (transaction_data)td) < 0){
|
||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||
clicon_log(LOG_NOTICE, "%s: Plugin '%s' callback does not make clicon_err call on error",
|
||||
__FUNCTION__, cp->cp_name);
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -759,7 +759,7 @@ plugin_transaction_end_all(clicon_handle h,
|
|||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
clixon_plugin *cp = NULL;
|
||||
clixon_plugin_t *cp = NULL;
|
||||
|
||||
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
|
||||
if (plugin_transaction_end_one(cp, h, td) < 0)
|
||||
|
|
@ -771,18 +771,18 @@ plugin_transaction_end_all(clicon_handle h,
|
|||
}
|
||||
|
||||
int
|
||||
plugin_transaction_abort_one(clixon_plugin *cp,
|
||||
plugin_transaction_abort_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
trans_cb_t *fn;
|
||||
|
||||
if ((fn = cp->cp_api.ca_trans_abort) != NULL){
|
||||
if ((fn = clixon_plugin_api_get(cp)->ca_trans_abort) != NULL){
|
||||
if (fn(h, (transaction_data)td) < 0){
|
||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||
clicon_log(LOG_NOTICE, "%s: Plugin '%s' callback does not make clicon_err call on error",
|
||||
__FUNCTION__, cp->cp_name);
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -802,7 +802,7 @@ plugin_transaction_abort_all(clicon_handle h,
|
|||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
clixon_plugin *cp = NULL;
|
||||
clixon_plugin_t *cp = NULL;
|
||||
|
||||
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
|
||||
if (plugin_transaction_abort_one(cp, h, td) < 0)
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ typedef struct {
|
|||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
int clixon_plugin_reset_one(clixon_plugin *cp, clicon_handle h, char *db);
|
||||
int clixon_plugin_reset_one(clixon_plugin_t *cp, clicon_handle h, char *db);
|
||||
int clixon_plugin_reset_all(clicon_handle h, char *db);
|
||||
|
||||
int clixon_plugin_pre_daemon_all(clicon_handle h);
|
||||
|
|
@ -80,25 +80,25 @@ int clixon_plugin_statedata_all(clicon_handle h, yang_stmt *yspec, cvec *nsc, ch
|
|||
transaction_data_t * transaction_new(void);
|
||||
int transaction_free(transaction_data_t *);
|
||||
|
||||
int plugin_transaction_begin_one(clixon_plugin *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_begin_one(clixon_plugin_t *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_begin_all(clicon_handle h, transaction_data_t *td);
|
||||
|
||||
int plugin_transaction_validate_one(clixon_plugin *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_validate_one(clixon_plugin_t *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_validate_all(clicon_handle h, transaction_data_t *td);
|
||||
|
||||
int plugin_transaction_complete_one(clixon_plugin *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_complete_one(clixon_plugin_t *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_complete_all(clicon_handle h, transaction_data_t *td);
|
||||
|
||||
int plugin_transaction_commit_one(clixon_plugin *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_commit_one(clixon_plugin_t *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_commit_all(clicon_handle h, transaction_data_t *td);
|
||||
|
||||
int plugin_transaction_commit_done_one(clixon_plugin *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_commit_done_one(clixon_plugin_t *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_commit_done_all(clicon_handle h, transaction_data_t *td);
|
||||
|
||||
int plugin_transaction_end_one(clixon_plugin *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_end_one(clixon_plugin_t *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_end_all(clicon_handle h, transaction_data_t *td);
|
||||
|
||||
int plugin_transaction_abort_one(clixon_plugin *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_abort_one(clixon_plugin_t *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_abort_all(clicon_handle h, transaction_data_t *td);
|
||||
|
||||
#endif /* _BACKEND_PLUGIN_H_ */
|
||||
|
|
|
|||
|
|
@ -300,13 +300,13 @@ backend_plugin_restconf_register(clicon_handle h,
|
|||
yang_stmt *yspec)
|
||||
{
|
||||
int retval = -1;
|
||||
clixon_plugin *cp = NULL;
|
||||
clixon_plugin_t *cp = NULL;
|
||||
|
||||
if (clixon_pseudo_plugin(h, "restconf pseudo plugin", &cp) < 0)
|
||||
goto done;
|
||||
|
||||
cp->cp_api.ca_trans_validate = restconf_pseudo_process_validate;
|
||||
cp->cp_api.ca_trans_commit = restconf_pseudo_process_commit;
|
||||
clixon_plugin_api_get(cp)->ca_trans_validate = restconf_pseudo_process_validate;
|
||||
clixon_plugin_api_get(cp)->ca_trans_commit = restconf_pseudo_process_commit;
|
||||
|
||||
/* Register generic process-control of restconf daemon, ie start/stop restconf */
|
||||
if (restconf_pseudo_process_control(h) < 0)
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ transaction_print(FILE *f,
|
|||
xn = td->td_avec[i];
|
||||
xml_print(f, xn);
|
||||
}
|
||||
fprintf(stderr, "Changed\n=========\n");
|
||||
fprintf(f, "Changed\n=========\n");
|
||||
for (i=0; i<td->td_clen; i++){
|
||||
xn = td->td_scvec[i];
|
||||
xml_print(f, xn);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue