datastore handles
This commit is contained in:
parent
d8fa7bc033
commit
540cd96e74
21 changed files with 286 additions and 146 deletions
|
|
@ -77,7 +77,7 @@
|
||||||
|
|
||||||
/*! Terminate. Cannot use h after this */
|
/*! Terminate. Cannot use h after this */
|
||||||
static int
|
static int
|
||||||
config_terminate(clicon_handle h)
|
backend_terminate(clicon_handle h)
|
||||||
{
|
{
|
||||||
yang_spec *yspec;
|
yang_spec *yspec;
|
||||||
char *pidfile = clicon_backend_pidfile(h);
|
char *pidfile = clicon_backend_pidfile(h);
|
||||||
|
|
@ -91,6 +91,7 @@ config_terminate(clicon_handle h)
|
||||||
unlink(pidfile);
|
unlink(pidfile);
|
||||||
if (sockpath)
|
if (sockpath)
|
||||||
unlink(sockpath);
|
unlink(sockpath);
|
||||||
|
xmldb_plugin_unload(h); /* unload storage plugin */
|
||||||
backend_handle_exit(h); /* Cannot use h after this */
|
backend_handle_exit(h); /* Cannot use h after this */
|
||||||
event_exit();
|
event_exit();
|
||||||
clicon_log_register_callback(NULL, NULL);
|
clicon_log_register_callback(NULL, NULL);
|
||||||
|
|
@ -101,7 +102,7 @@ config_terminate(clicon_handle h)
|
||||||
/*! Unlink pidfile and quit
|
/*! Unlink pidfile and quit
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
config_sig_term(int arg)
|
backend_sig_term(int arg)
|
||||||
{
|
{
|
||||||
static int i=0;
|
static int i=0;
|
||||||
|
|
||||||
|
|
@ -238,11 +239,11 @@ server_socket(clicon_handle h)
|
||||||
int ss;
|
int ss;
|
||||||
|
|
||||||
/* Open control socket */
|
/* Open control socket */
|
||||||
if ((ss = config_socket_init(h)) < 0)
|
if ((ss = backend_socket_init(h)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
/* ss is a server socket that the clients connect to. The callback
|
/* ss is a server socket that the clients connect to. The callback
|
||||||
therefore accepts clients on ss */
|
therefore accepts clients on ss */
|
||||||
if (event_reg_fd(ss, config_accept_client, h, "server socket") < 0) {
|
if (event_reg_fd(ss, backend_accept_client, h, "server socket") < 0) {
|
||||||
close(ss);
|
close(ss);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -254,7 +255,7 @@ server_socket(clicon_handle h)
|
||||||
* log event.
|
* log event.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
config_log_cb(int level,
|
backend_log_cb(int level,
|
||||||
char *msg,
|
char *msg,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
|
|
@ -320,7 +321,7 @@ main(int argc, char **argv)
|
||||||
/* Initiate CLICON handle */
|
/* Initiate CLICON handle */
|
||||||
if ((h = backend_handle_init()) == NULL)
|
if ((h = backend_handle_init()) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
if (config_plugin_init(h) != 0)
|
if (backend_plugin_init(h) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
foreground = 0;
|
foreground = 0;
|
||||||
once = 0;
|
once = 0;
|
||||||
|
|
@ -623,14 +624,14 @@ main(int argc, char **argv)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* Register log notifications */
|
/* Register log notifications */
|
||||||
if (clicon_log_register_callback(config_log_cb, h) < 0)
|
if (clicon_log_register_callback(backend_log_cb, h) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
clicon_log(LOG_NOTICE, "%s: %u Started", __PROGRAM__, getpid());
|
clicon_log(LOG_NOTICE, "%s: %u Started", __PROGRAM__, getpid());
|
||||||
if (set_signal(SIGTERM, config_sig_term, NULL) < 0){
|
if (set_signal(SIGTERM, backend_sig_term, NULL) < 0){
|
||||||
clicon_err(OE_DEMON, errno, "Setting signal");
|
clicon_err(OE_DEMON, errno, "Setting signal");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (set_signal(SIGINT, config_sig_term, NULL) < 0){
|
if (set_signal(SIGINT, backend_sig_term, NULL) < 0){
|
||||||
clicon_err(OE_DEMON, errno, "Setting signal");
|
clicon_err(OE_DEMON, errno, "Setting signal");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
@ -646,7 +647,7 @@ main(int argc, char **argv)
|
||||||
goto done;
|
goto done;
|
||||||
done:
|
done:
|
||||||
clicon_log(LOG_NOTICE, "%s: %u Terminated", __PROGRAM__, getpid());
|
clicon_log(LOG_NOTICE, "%s: %u Terminated", __PROGRAM__, getpid());
|
||||||
config_terminate(h); /* Cannot use h after this */
|
backend_terminate(h); /* Cannot use h after this */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ config_find_plugin(clicon_handle h,
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
config_plugin_init(clicon_handle h)
|
backend_plugin_init(clicon_handle h)
|
||||||
{
|
{
|
||||||
find_plugin_t *fp = config_find_plugin;
|
find_plugin_t *fp = config_find_plugin;
|
||||||
clicon_hash_t *data = clicon_data(h);
|
clicon_hash_t *data = clicon_data(h);
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ typedef struct {
|
||||||
/*
|
/*
|
||||||
* Prototypes
|
* Prototypes
|
||||||
*/
|
*/
|
||||||
int config_plugin_init(clicon_handle h);
|
int backend_plugin_init(clicon_handle h);
|
||||||
int plugin_initiate(clicon_handle h);
|
int plugin_initiate(clicon_handle h);
|
||||||
int plugin_finish(clicon_handle h);
|
int plugin_finish(clicon_handle h);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ config_socket_init_unix(clicon_handle h, char *sock)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
config_socket_init(clicon_handle h)
|
backend_socket_init(clicon_handle h)
|
||||||
{
|
{
|
||||||
char *sock;
|
char *sock;
|
||||||
|
|
||||||
|
|
@ -197,7 +197,7 @@ config_socket_init(clicon_handle h)
|
||||||
* XXX: credentials not properly implemented
|
* XXX: credentials not properly implemented
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
config_accept_client(int fd,
|
backend_accept_client(int fd,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
/*
|
/*
|
||||||
* Prototypes
|
* Prototypes
|
||||||
*/
|
*/
|
||||||
int config_socket_init(clicon_handle h);
|
int backend_socket_init(clicon_handle h);
|
||||||
int config_accept_client(int fd, void *arg);
|
int backend_accept_client(int fd, void *arg);
|
||||||
|
|
||||||
#endif /* _BACKEND_SOCKET_H_ */
|
#endif /* _BACKEND_SOCKET_H_ */
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,6 @@ struct backend_handle {
|
||||||
int bh_magic; /* magic (HDR)*/
|
int bh_magic; /* magic (HDR)*/
|
||||||
clicon_hash_t *bh_copt; /* clicon option list (HDR) */
|
clicon_hash_t *bh_copt; /* clicon option list (HDR) */
|
||||||
clicon_hash_t *bh_data; /* internal clicon data (HDR) */
|
clicon_hash_t *bh_data; /* internal clicon data (HDR) */
|
||||||
void *bh_xmldb; /* XMLDB storage handle, uie xmldb_handle */
|
|
||||||
/* ------ end of common handle ------ */
|
/* ------ end of common handle ------ */
|
||||||
struct client_entry *bh_ce_list; /* The client list */
|
struct client_entry *bh_ce_list; /* The client list */
|
||||||
int bh_ce_nr; /* Number of clients, just increment */
|
int bh_ce_nr; /* Number of clients, just increment */
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,6 @@ struct cli_handle {
|
||||||
int cl_magic; /* magic (HDR)*/
|
int cl_magic; /* magic (HDR)*/
|
||||||
clicon_hash_t *cl_copt; /* clicon option list (HDR) */
|
clicon_hash_t *cl_copt; /* clicon option list (HDR) */
|
||||||
clicon_hash_t *cl_data; /* internal clicon data (HDR) */
|
clicon_hash_t *cl_data; /* internal clicon data (HDR) */
|
||||||
void *cl_xmldb; /* XMLDB storage handle, uie xmldb_handle */
|
|
||||||
/* ------ end of common handle ------ */
|
/* ------ end of common handle ------ */
|
||||||
cligen_handle cl_cligen; /* cligen handle */
|
cligen_handle cl_cligen; /* cligen handle */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,14 @@
|
||||||
|
|
||||||
***** END LICENSE BLOCK *****
|
***** END LICENSE BLOCK *****
|
||||||
|
|
||||||
|
* Examples:
|
||||||
|
|
||||||
|
./datastore_client -d candidate -b /usr/local/var/routing -p /home/olof/src/clixon/datastore/keyvalue/keyvalue.so -y /usr/local/share/routing/yang -m ietf-ip get /
|
||||||
|
|
||||||
|
sudo ./datastore_client -d candidate -b /usr/local/var/routing -p /home/olof/src/clixon/datastore/keyvalue/keyvalue.so -y /usr/local/share/routing/yang -m ietf-ip put merge /interfaces/interface=eth0
|
||||||
|
<config>eth66</config>
|
||||||
|
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
|
@ -221,8 +229,8 @@ main(int argc, char **argv)
|
||||||
goto done;
|
goto done;
|
||||||
if (xmldb_put(h, db, op, argv[2], xn) < 0)
|
if (xmldb_put(h, db, op, argv[2], xn) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (xt)
|
if (xn)
|
||||||
xml_free(xt);
|
xml_free(xn);
|
||||||
}
|
}
|
||||||
else if (strcmp(cmd, "copy")==0){
|
else if (strcmp(cmd, "copy")==0){
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
|
|
|
||||||
|
|
@ -424,7 +424,7 @@ db_regexp(char *file,
|
||||||
/* Retrieve value if required */
|
/* Retrieve value if required */
|
||||||
if ( ! noval) {
|
if ( ! noval) {
|
||||||
if((val = dpget(iterdp, key, -1, 0, -1, &vlen)) == NULL) {
|
if((val = dpget(iterdp, key, -1, 0, -1, &vlen)) == NULL) {
|
||||||
clicon_log(OE_DB, "%s: dpget: %s", __FUNCTION__, dperrmsg(dpecode));
|
clicon_log(LOG_WARNING, "%s: dpget: %s", __FUNCTION__, dperrmsg(dpecode));
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,13 +76,12 @@
|
||||||
#include <clixon/clixon_xml.h>
|
#include <clixon/clixon_xml.h>
|
||||||
#include <clixon/clixon_proto.h>
|
#include <clixon/clixon_proto.h>
|
||||||
#include <clixon/clixon_proto_client.h>
|
#include <clixon/clixon_proto_client.h>
|
||||||
|
#include <clixon/clixon_plugin.h>
|
||||||
#include <clixon/clixon_options.h>
|
#include <clixon/clixon_options.h>
|
||||||
#include <clixon/clixon_xml_map.h>
|
#include <clixon/clixon_xml_map.h>
|
||||||
#include <clixon/clixon_xml_db.h>
|
#include <clixon/clixon_xml_db.h>
|
||||||
#include <clixon/clixon_xsl.h>
|
#include <clixon/clixon_xsl.h>
|
||||||
#include <clixon/clixon_json.h>
|
#include <clixon/clixon_json.h>
|
||||||
#include <clixon/clixon_plugin.h>
|
|
||||||
#include <clixon/clixon_plugin.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Global variables generated by Makefile
|
* Global variables generated by Makefile
|
||||||
|
|
|
||||||
|
|
@ -71,10 +71,4 @@ clicon_hash_t *clicon_options(clicon_handle h);
|
||||||
/* Return internal clicon data (hash-array) given a handle.*/
|
/* Return internal clicon data (hash-array) given a handle.*/
|
||||||
clicon_hash_t *clicon_data(clicon_handle h);
|
clicon_hash_t *clicon_data(clicon_handle h);
|
||||||
|
|
||||||
/* Set or reset XMLDB storage handle */
|
|
||||||
int clicon_handle_xmldb_set(clicon_handle h, void *xh); /* ie xmldb_handle */
|
|
||||||
|
|
||||||
/* Get XMLDB storage handle */
|
|
||||||
void *clicon_handle_xmldb_get(clicon_handle h);
|
|
||||||
|
|
||||||
#endif /* _CLIXON_HANDLE_H_ */
|
#endif /* _CLIXON_HANDLE_H_ */
|
||||||
|
|
|
||||||
|
|
@ -120,4 +120,16 @@ int clicon_dbspec_yang_set(clicon_handle h, struct yang_spec *ys);
|
||||||
char *clicon_dbspec_name(clicon_handle h);
|
char *clicon_dbspec_name(clicon_handle h);
|
||||||
int clicon_dbspec_name_set(clicon_handle h, char *name);
|
int clicon_dbspec_name_set(clicon_handle h, char *name);
|
||||||
|
|
||||||
|
int clicon_xmldb_plugin_set(clicon_handle h, plghndl_t handle);
|
||||||
|
|
||||||
|
plghndl_t clicon_xmldb_plugin_get(clicon_handle h);
|
||||||
|
|
||||||
|
int clicon_xmldb_api_set(clicon_handle h, void *xa_api);
|
||||||
|
|
||||||
|
void *clicon_xmldb_api_get(clicon_handle h);
|
||||||
|
|
||||||
|
int clicon_xmldb_handle_set(clicon_handle h, void *xh);
|
||||||
|
|
||||||
|
void *clicon_xmldb_handle_get(clicon_handle h);
|
||||||
|
|
||||||
#endif /* _CLIXON_OPTIONS_H_ */
|
#endif /* _CLIXON_OPTIONS_H_ */
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@
|
||||||
#include "clixon_handle.h"
|
#include "clixon_handle.h"
|
||||||
#include "clixon_err.h"
|
#include "clixon_err.h"
|
||||||
#include "clixon_yang.h"
|
#include "clixon_yang.h"
|
||||||
|
#include "clixon_plugin.h"
|
||||||
#include "clixon_options.h"
|
#include "clixon_options.h"
|
||||||
|
|
||||||
#define CLICON_MAGIC 0x99aafabe
|
#define CLICON_MAGIC 0x99aafabe
|
||||||
|
|
@ -66,7 +67,6 @@ struct clicon_handle {
|
||||||
int ch_magic; /* magic (HDR) */
|
int ch_magic; /* magic (HDR) */
|
||||||
clicon_hash_t *ch_copt; /* clicon option list (HDR) */
|
clicon_hash_t *ch_copt; /* clicon option list (HDR) */
|
||||||
clicon_hash_t *ch_data; /* internal clicon data (HDR) */
|
clicon_hash_t *ch_data; /* internal clicon data (HDR) */
|
||||||
void *ch_xmldb; /* XMLDB storage handle, uie xmldb_handle */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! Internal call to allocate a CLICON handle.
|
/*! Internal call to allocate a CLICON handle.
|
||||||
|
|
@ -166,30 +166,3 @@ clicon_data(clicon_handle h)
|
||||||
return ch->ch_data;
|
return ch->ch_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Set or reset XMLDB storage handle
|
|
||||||
* @param[in] h Clicon handle
|
|
||||||
* @param[in] xh XMLDB storage handle. If NULL reset it
|
|
||||||
* @note Just keep note of it, dont allocate it or so.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
clicon_handle_xmldb_set(clicon_handle h,
|
|
||||||
void *xh)
|
|
||||||
{
|
|
||||||
struct clicon_handle *ch = handle(h);
|
|
||||||
|
|
||||||
ch->ch_xmldb = xh;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Get XMLDB storage handle
|
|
||||||
* @param[in] h Clicon handle
|
|
||||||
* @retval xh XMLDB storage handle. If not connected return NULL
|
|
||||||
*/
|
|
||||||
void *
|
|
||||||
clicon_handle_xmldb_get(clicon_handle h)
|
|
||||||
|
|
||||||
{
|
|
||||||
struct clicon_handle *ch = handle(h);
|
|
||||||
|
|
||||||
return ch->ch_xmldb;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -200,8 +200,8 @@ hash_value(clicon_hash_t *hash,
|
||||||
/*! Copy value and add hash entry.
|
/*! Copy value and add hash entry.
|
||||||
*
|
*
|
||||||
* @param[in] hash Hash table
|
* @param[in] hash Hash table
|
||||||
* @param[in] key New variable name
|
* @param[in] key Variable name
|
||||||
* @param[in] val New variable value
|
* @param[in] val Variable value
|
||||||
* @param[in] vlen Length of variable value
|
* @param[in] vlen Length of variable value
|
||||||
* @retval variable New hash structure on success
|
* @retval variable New hash structure on success
|
||||||
* @retval NULL Failure
|
* @retval NULL Failure
|
||||||
|
|
@ -213,7 +213,8 @@ hash_add(clicon_hash_t *hash,
|
||||||
size_t vlen)
|
size_t vlen)
|
||||||
{
|
{
|
||||||
void *newval;
|
void *newval;
|
||||||
clicon_hash_t h, new = NULL;
|
clicon_hash_t h;
|
||||||
|
clicon_hash_t new = NULL;
|
||||||
|
|
||||||
/* If variable exist, don't allocate a new. just replace value */
|
/* If variable exist, don't allocate a new. just replace value */
|
||||||
h = hash_lookup (hash, key);
|
h = hash_lookup (hash, key);
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@
|
||||||
#include "clixon_handle.h"
|
#include "clixon_handle.h"
|
||||||
#include "clixon_log.h"
|
#include "clixon_log.h"
|
||||||
#include "clixon_yang.h"
|
#include "clixon_yang.h"
|
||||||
|
#include "clixon_plugin.h"
|
||||||
#include "clixon_options.h"
|
#include "clixon_options.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -625,12 +626,12 @@ clicon_dbspec_yang(clicon_handle h)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*! Set yang database specification
|
||||||
* Set dbspec (YANG variant)
|
|
||||||
* ys must be a malloced pointer
|
* ys must be a malloced pointer
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
clicon_dbspec_yang_set(clicon_handle h, struct yang_spec *ys)
|
clicon_dbspec_yang_set(clicon_handle h,
|
||||||
|
struct yang_spec *ys)
|
||||||
{
|
{
|
||||||
clicon_hash_t *cdat = clicon_data(h);
|
clicon_hash_t *cdat = clicon_data(h);
|
||||||
|
|
||||||
|
|
@ -642,8 +643,7 @@ clicon_dbspec_yang_set(clicon_handle h, struct yang_spec *ys)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*! Get dbspec name as read from spec. Can be used in CLI '@' syntax.
|
||||||
* Get dbspec name as read from spec. Can be used in CLI '@' syntax.
|
|
||||||
* XXX: this we muśt change,...
|
* XXX: this we muśt change,...
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
|
|
@ -654,11 +654,103 @@ clicon_dbspec_name(clicon_handle h)
|
||||||
return clicon_option_str(h, "dbspec_name");
|
return clicon_option_str(h, "dbspec_name");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*! Set dbspec name as read from spec. Can be used in CLI '@' syntax.
|
||||||
* Set dbspec name as read from spec. Can be used in CLI '@' syntax.
|
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
clicon_dbspec_name_set(clicon_handle h, char *name)
|
clicon_dbspec_name_set(clicon_handle h, char *name)
|
||||||
{
|
{
|
||||||
return clicon_option_str_set(h, "dbspec_name", name);
|
return clicon_option_str_set(h, "dbspec_name", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Set xmldb datastore plugin handle, as used by dlopen/dlsym/dlclose */
|
||||||
|
int
|
||||||
|
clicon_xmldb_plugin_set(clicon_handle h,
|
||||||
|
plghndl_t handle)
|
||||||
|
{
|
||||||
|
clicon_hash_t *cdat = clicon_data(h);
|
||||||
|
|
||||||
|
if (hash_add(cdat, "xmldb_plugin", &handle, sizeof(void*)) == NULL)
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Get xmldb datastore plugin handle, as used by dlopen/dlsym/dlclose */
|
||||||
|
plghndl_t
|
||||||
|
clicon_xmldb_plugin_get(clicon_handle h)
|
||||||
|
{
|
||||||
|
clicon_hash_t *cdat = clicon_data(h);
|
||||||
|
size_t len;
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
if ((p = hash_value(cdat, "xmldb_plugin", &len)) != NULL)
|
||||||
|
return *(plghndl_t*)p;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Set or reset XMLDB API struct pointer
|
||||||
|
* @param[in] h Clicon handle
|
||||||
|
* @param[in] xa XMLDB API struct
|
||||||
|
* @note xa is really of type struct xmldb_api*
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
clicon_xmldb_api_set(clicon_handle h,
|
||||||
|
void *xa)
|
||||||
|
{
|
||||||
|
clicon_hash_t *cdat = clicon_data(h);
|
||||||
|
|
||||||
|
/* It is the pointer to xa_api that should be copied by hash,
|
||||||
|
so we send a ptr to the ptr to indicate what to copy.
|
||||||
|
*/
|
||||||
|
if (hash_add(cdat, "xmldb_api", &xa, sizeof(void*)) == NULL)
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Get XMLDB API struct pointer
|
||||||
|
* @param[in] h Clicon handle
|
||||||
|
* @retval xa XMLDB API struct
|
||||||
|
* @note xa is really of type struct xmldb_api*
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
clicon_xmldb_api_get(clicon_handle h)
|
||||||
|
{
|
||||||
|
clicon_hash_t *cdat = clicon_data(h);
|
||||||
|
size_t len;
|
||||||
|
void *xa;
|
||||||
|
|
||||||
|
if ((xa = hash_value(cdat, "xmldb_api", &len)) != NULL)
|
||||||
|
return *(void**)xa;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Set or reset XMLDB storage handle
|
||||||
|
* @param[in] h Clicon handle
|
||||||
|
* @param[in] xh XMLDB storage handle. If NULL reset it
|
||||||
|
* @note Just keep note of it, dont allocate it or so.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
clicon_xmldb_handle_set(clicon_handle h,
|
||||||
|
void *xh)
|
||||||
|
{
|
||||||
|
clicon_hash_t *cdat = clicon_data(h);
|
||||||
|
|
||||||
|
if (hash_add(cdat, "xmldb_handle", &xh, sizeof(void*)) == NULL)
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Get XMLDB storage handle
|
||||||
|
* @param[in] h Clicon handle
|
||||||
|
* @retval xh XMLDB storage handle. If not connected return NULL
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
clicon_xmldb_handle_get(clicon_handle h)
|
||||||
|
{
|
||||||
|
clicon_hash_t *cdat = clicon_data(h);
|
||||||
|
size_t len;
|
||||||
|
void *xh;
|
||||||
|
|
||||||
|
if ((xh = hash_value(cdat, "xmldb_handle", &len)) != NULL)
|
||||||
|
return *(void**)xh;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@
|
||||||
#include "clixon_hash.h"
|
#include "clixon_hash.h"
|
||||||
#include "clixon_handle.h"
|
#include "clixon_handle.h"
|
||||||
#include "clixon_yang.h"
|
#include "clixon_yang.h"
|
||||||
|
#include "clixon_plugin.h"
|
||||||
#include "clixon_options.h"
|
#include "clixon_options.h"
|
||||||
#include "clixon_xml.h"
|
#include "clixon_xml.h"
|
||||||
#include "clixon_xsl.h"
|
#include "clixon_xsl.h"
|
||||||
|
|
|
||||||
|
|
@ -59,17 +59,15 @@
|
||||||
#include "clixon_handle.h"
|
#include "clixon_handle.h"
|
||||||
#include "clixon_xml.h"
|
#include "clixon_xml.h"
|
||||||
#include "clixon_yang.h"
|
#include "clixon_yang.h"
|
||||||
|
#include "clixon_plugin.h"
|
||||||
#include "clixon_options.h"
|
#include "clixon_options.h"
|
||||||
#include "clixon_xml_db.h"
|
#include "clixon_xml_db.h"
|
||||||
|
|
||||||
static struct xmldb_api *_xa_api = NULL;
|
/*! Load an xmldb storage plugin according to filename
|
||||||
|
|
||||||
/*! Load a specific plugin, call its init function and add it to plugins list
|
|
||||||
* If init function fails (not found, wrong version, etc) print a log and dont
|
* If init function fails (not found, wrong version, etc) print a log and dont
|
||||||
* add it.
|
* add it.
|
||||||
* @param[in] name Filename (complete path) of plugin
|
* @param[in] h CLicon handle
|
||||||
* @param[in] filename Actual filename with path
|
* @param[in] filename Actual filename with path
|
||||||
* @param[out] plugin Plugin data structure for invoking. Dealloc with free
|
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xmldb_plugin_load(clicon_handle h,
|
xmldb_plugin_load(clicon_handle h,
|
||||||
|
|
@ -78,8 +76,9 @@ xmldb_plugin_load(clicon_handle h,
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
char *dlerrcode;
|
char *dlerrcode;
|
||||||
plugin_init_t *initfun;
|
plugin_init_t *initfun;
|
||||||
void *handle = NULL;
|
plghndl_t handle = NULL;
|
||||||
char *error;
|
char *error;
|
||||||
|
struct xmldb_api *xa = NULL;
|
||||||
|
|
||||||
dlerror(); /* Clear any existing error */
|
dlerror(); /* Clear any existing error */
|
||||||
if ((handle = dlopen(filename, RTLD_NOW|RTLD_GLOBAL)) == NULL) {
|
if ((handle = dlopen(filename, RTLD_NOW|RTLD_GLOBAL)) == NULL) {
|
||||||
|
|
@ -94,21 +93,27 @@ xmldb_plugin_load(clicon_handle h,
|
||||||
XMLDB_PLUGIN_INIT_FN, dlerrcode);
|
XMLDB_PLUGIN_INIT_FN, dlerrcode);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if ((_xa_api = initfun(XMLDB_API_VERSION)) == NULL) {
|
if ((xa = initfun(XMLDB_API_VERSION)) == NULL) {
|
||||||
clicon_log(LOG_WARNING, "%s: failed when running init function %s: %s",
|
clicon_log(LOG_WARNING, "%s: failed when running init function %s: %s",
|
||||||
filename, XMLDB_PLUGIN_INIT_FN, errno?strerror(errno):"");
|
filename, XMLDB_PLUGIN_INIT_FN, errno?strerror(errno):"");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if (_xa_api->xa_version != XMLDB_API_VERSION){
|
if (xa->xa_version != XMLDB_API_VERSION){
|
||||||
clicon_log(LOG_WARNING, "%s: Unexpected plugin version number: %d",
|
clicon_log(LOG_WARNING, "%s: Unexpected plugin version number: %d",
|
||||||
filename, _xa_api->xa_version);
|
filename, xa->xa_version);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if (_xa_api->xa_magic != XMLDB_API_MAGIC){
|
if (xa->xa_magic != XMLDB_API_MAGIC){
|
||||||
clicon_log(LOG_WARNING, "%s: Wrong plugin magic number: %x",
|
clicon_log(LOG_WARNING, "%s: Wrong plugin magic number: %x",
|
||||||
filename, _xa_api->xa_magic);
|
filename, xa->xa_magic);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
/* Add plugin */
|
||||||
|
if (clicon_xmldb_plugin_set(h, handle) < 0)
|
||||||
|
goto done;
|
||||||
|
/* Add API */
|
||||||
|
if (clicon_xmldb_api_set(h, xa) < 0)
|
||||||
|
goto done;
|
||||||
clicon_log(LOG_WARNING, "xmldb plugin %s loaded", filename);
|
clicon_log(LOG_WARNING, "xmldb plugin %s loaded", filename);
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
|
@ -120,11 +125,41 @@ xmldb_plugin_load(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! XXX: fixme */
|
/*! Unload the xmldb storage plugin */
|
||||||
int
|
int
|
||||||
xmldb_plugin_unload(clicon_handle h)
|
xmldb_plugin_unload(clicon_handle h)
|
||||||
{
|
{
|
||||||
return 0;
|
int retval = -1;
|
||||||
|
plghndl_t handle;
|
||||||
|
struct xmldb_api *xa;
|
||||||
|
xmldb_handle xh;
|
||||||
|
char *error;
|
||||||
|
|
||||||
|
if ((handle = clicon_xmldb_plugin_get(h)) == NULL){
|
||||||
|
clicon_err(OE_PLUGIN, errno, "No plugin handle");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
/* If connected storage handle then disconnect */
|
||||||
|
if ((xh = clicon_xmldb_handle_get(h)) != NULL)
|
||||||
|
xmldb_disconnect(h); /* sets xmldb handle to NULL */
|
||||||
|
/* Deregister api */
|
||||||
|
if ((xa = clicon_xmldb_api_get(h)) != NULL){
|
||||||
|
/* Call plugin_exit */
|
||||||
|
if (xa->xa_plugin_exit_fn != NULL)
|
||||||
|
xa->xa_plugin_exit_fn();
|
||||||
|
/* Deregister API (it is allocated in plugin) */
|
||||||
|
clicon_xmldb_api_set(h, NULL);
|
||||||
|
}
|
||||||
|
/* Unload plugin */
|
||||||
|
dlerror(); /* Clear any existing error */
|
||||||
|
if (dlclose(handle) != 0) {
|
||||||
|
error = (char*)dlerror();
|
||||||
|
clicon_err(OE_PLUGIN, errno, "dlclose: %s\n", error ? error : "Unknown error");
|
||||||
|
/* Just report no -1 return*/
|
||||||
|
}
|
||||||
|
retval = 0;
|
||||||
|
done:
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Connect to a datastore plugin
|
/*! Connect to a datastore plugin
|
||||||
|
|
@ -141,19 +176,19 @@ xmldb_connect(clicon_handle h)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
xmldb_handle xh;
|
xmldb_handle xh;
|
||||||
|
struct xmldb_api *xa;
|
||||||
|
|
||||||
if (_xa_api == NULL){
|
if ((xa = clicon_xmldb_api_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb plugin");
|
clicon_err(OE_DB, 0, "No xmldb plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (_xa_api->xa_connect_fn == NULL){
|
if (xa->xa_connect_fn == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb function");
|
clicon_err(OE_DB, 0, "No xmldb function");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((xh = _xa_api->xa_connect_fn()) == NULL)
|
if ((xh = xa->xa_connect_fn()) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
clicon_handle_xmldb_set(h, xh);
|
clicon_xmldb_handle_set(h, xh);
|
||||||
|
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
return retval;
|
return retval;
|
||||||
|
|
@ -168,22 +203,23 @@ xmldb_disconnect(clicon_handle h)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
xmldb_handle xh;
|
xmldb_handle xh;
|
||||||
|
struct xmldb_api *xa;
|
||||||
|
|
||||||
if (_xa_api == NULL){
|
if ((xa = clicon_xmldb_api_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb plugin");
|
clicon_err(OE_DB, 0, "No xmldb plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (_xa_api->xa_disconnect_fn == NULL){
|
if (xa->xa_disconnect_fn == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb function");
|
clicon_err(OE_DB, 0, "No xmldb function");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((xh = clicon_handle_xmldb_get(h)) == NULL){
|
if ((xh = clicon_xmldb_handle_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "Already disconnected from datastore plugin");
|
clicon_err(OE_DB, 0, "Already disconnected from datastore plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (_xa_api->xa_disconnect_fn(xh) < 0)
|
if (xa->xa_disconnect_fn(xh) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
clicon_handle_xmldb_set(h, NULL);
|
clicon_xmldb_handle_set(h, NULL);
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
return retval;
|
return retval;
|
||||||
|
|
@ -203,20 +239,21 @@ xmldb_getopt(clicon_handle h,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
xmldb_handle xh;
|
xmldb_handle xh;
|
||||||
|
struct xmldb_api *xa;
|
||||||
|
|
||||||
if (_xa_api == NULL){
|
if ((xa = clicon_xmldb_api_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb plugin");
|
clicon_err(OE_DB, 0, "No xmldb plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (_xa_api->xa_getopt_fn == NULL){
|
if (xa->xa_getopt_fn == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb function");
|
clicon_err(OE_DB, 0, "No xmldb function");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((xh = clicon_handle_xmldb_get(h)) == NULL){
|
if ((xh = clicon_xmldb_handle_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = _xa_api->xa_getopt_fn(xh, optname, value);
|
retval = xa->xa_getopt_fn(xh, optname, value);
|
||||||
done:
|
done:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
@ -235,20 +272,21 @@ xmldb_setopt(clicon_handle h,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
xmldb_handle xh;
|
xmldb_handle xh;
|
||||||
|
struct xmldb_api *xa;
|
||||||
|
|
||||||
if (_xa_api == NULL){
|
if ((xa = clicon_xmldb_api_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb plugin");
|
clicon_err(OE_DB, 0, "No xmldb plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (_xa_api->xa_setopt_fn == NULL){
|
if (xa->xa_setopt_fn == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb function");
|
clicon_err(OE_DB, 0, "No xmldb function");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((xh = clicon_handle_xmldb_get(h)) == NULL){
|
if ((xh = clicon_xmldb_handle_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = _xa_api->xa_setopt_fn(xh, optname, value);
|
retval = xa->xa_setopt_fn(xh, optname, value);
|
||||||
done:
|
done:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
@ -293,20 +331,22 @@ xmldb_get(clicon_handle h,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
xmldb_handle xh;
|
xmldb_handle xh;
|
||||||
|
struct xmldb_api *xa;
|
||||||
|
|
||||||
if (_xa_api == NULL){
|
if ((xa = clicon_xmldb_api_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb plugin");
|
clicon_err(OE_DB, 0, "No xmldb plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (_xa_api->xa_get_fn == NULL){
|
if (xa->xa_get_fn == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb function");
|
clicon_err(OE_DB, 0, "No xmldb function");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((xh = clicon_handle_xmldb_get(h)) == NULL){
|
if ((xh = clicon_xmldb_handle_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = _xa_api->xa_get_fn(xh, db, xpath, xtop, xvec, xlen);
|
clicon_log(LOG_WARNING, "%s: db:%s xpath:%s", __FUNCTION__, db, xpath);
|
||||||
|
retval = xa->xa_get_fn(xh, db, xpath, xtop, xvec, xlen);
|
||||||
done:
|
done:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
@ -341,20 +381,30 @@ xmldb_put(clicon_handle h,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
xmldb_handle xh;
|
xmldb_handle xh;
|
||||||
|
struct xmldb_api *xa;
|
||||||
|
|
||||||
if (_xa_api == NULL){
|
if ((xa = clicon_xmldb_api_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb plugin");
|
clicon_err(OE_DB, 0, "No xmldb plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (_xa_api->xa_put_fn == NULL){
|
if (xa->xa_put_fn == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb function");
|
clicon_err(OE_DB, 0, "No xmldb function");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((xh = clicon_handle_xmldb_get(h)) == NULL){
|
if ((xh = clicon_xmldb_handle_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = _xa_api->xa_put_fn(xh, db, op, api_path, xt);
|
{
|
||||||
|
cbuf *cb = cbuf_new();
|
||||||
|
if (clicon_xml2cbuf(cb, xt, 0, 0) < 0)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
clicon_log(LOG_WARNING, "%s: db:%s op:%d api_path:%s xml:%s", __FUNCTION__,
|
||||||
|
db, op, api_path, cbuf_get(cb));
|
||||||
|
cbuf_free(cb);
|
||||||
|
}
|
||||||
|
retval = xa->xa_put_fn(xh, db, op, api_path, xt);
|
||||||
done:
|
done:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
@ -373,20 +423,21 @@ xmldb_copy(clicon_handle h,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
xmldb_handle xh;
|
xmldb_handle xh;
|
||||||
|
struct xmldb_api *xa;
|
||||||
|
|
||||||
if (_xa_api == NULL){
|
if ((xa = clicon_xmldb_api_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb plugin");
|
clicon_err(OE_DB, 0, "No xmldb plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (_xa_api->xa_copy_fn == NULL){
|
if (xa->xa_copy_fn == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb function");
|
clicon_err(OE_DB, 0, "No xmldb function");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((xh = clicon_handle_xmldb_get(h)) == NULL){
|
if ((xh = clicon_xmldb_handle_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = _xa_api->xa_copy_fn(xh, from, to);
|
retval = xa->xa_copy_fn(xh, from, to);
|
||||||
done:
|
done:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
@ -405,20 +456,21 @@ xmldb_lock(clicon_handle h,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
xmldb_handle xh;
|
xmldb_handle xh;
|
||||||
|
struct xmldb_api *xa;
|
||||||
|
|
||||||
if (_xa_api == NULL){
|
if ((xa = clicon_xmldb_api_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb plugin");
|
clicon_err(OE_DB, 0, "No xmldb plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (_xa_api->xa_lock_fn == NULL){
|
if (xa->xa_lock_fn == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb function");
|
clicon_err(OE_DB, 0, "No xmldb function");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((xh = clicon_handle_xmldb_get(h)) == NULL){
|
if ((xh = clicon_xmldb_handle_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = _xa_api->xa_lock_fn(xh, db, pid);
|
retval = xa->xa_lock_fn(xh, db, pid);
|
||||||
done:
|
done:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
@ -438,20 +490,21 @@ xmldb_unlock(clicon_handle h,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
xmldb_handle xh;
|
xmldb_handle xh;
|
||||||
|
struct xmldb_api *xa;
|
||||||
|
|
||||||
if (_xa_api == NULL){
|
if ((xa = clicon_xmldb_api_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb plugin");
|
clicon_err(OE_DB, 0, "No xmldb plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (_xa_api->xa_unlock_fn == NULL){
|
if (xa->xa_unlock_fn == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb function");
|
clicon_err(OE_DB, 0, "No xmldb function");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((xh = clicon_handle_xmldb_get(h)) == NULL){
|
if ((xh = clicon_xmldb_handle_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = _xa_api->xa_unlock_fn(xh, db, pid);
|
retval = xa->xa_unlock_fn(xh, db, pid);
|
||||||
done:
|
done:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
@ -468,20 +521,21 @@ xmldb_unlock_all(clicon_handle h,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
xmldb_handle xh;
|
xmldb_handle xh;
|
||||||
|
struct xmldb_api *xa;
|
||||||
|
|
||||||
if (_xa_api == NULL){
|
if ((xa = clicon_xmldb_api_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb plugin");
|
clicon_err(OE_DB, 0, "No xmldb plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (_xa_api->xa_unlock_all_fn == NULL){
|
if (xa->xa_unlock_all_fn == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb function");
|
clicon_err(OE_DB, 0, "No xmldb function");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((xh = clicon_handle_xmldb_get(h)) == NULL){
|
if ((xh = clicon_xmldb_handle_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval =_xa_api->xa_unlock_all_fn(xh, pid);
|
retval =xa->xa_unlock_all_fn(xh, pid);
|
||||||
done:
|
done:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
@ -499,20 +553,21 @@ xmldb_islocked(clicon_handle h,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
xmldb_handle xh;
|
xmldb_handle xh;
|
||||||
|
struct xmldb_api *xa;
|
||||||
|
|
||||||
if (_xa_api == NULL){
|
if ((xa = clicon_xmldb_api_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb plugin");
|
clicon_err(OE_DB, 0, "No xmldb plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (_xa_api->xa_islocked_fn == NULL){
|
if (xa->xa_islocked_fn == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb function");
|
clicon_err(OE_DB, 0, "No xmldb function");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((xh = clicon_handle_xmldb_get(h)) == NULL){
|
if ((xh = clicon_xmldb_handle_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval =_xa_api->xa_islocked_fn(xh, db);
|
retval =xa->xa_islocked_fn(xh, db);
|
||||||
done:
|
done:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
@ -530,20 +585,21 @@ xmldb_exists(clicon_handle h,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
xmldb_handle xh;
|
xmldb_handle xh;
|
||||||
|
struct xmldb_api *xa;
|
||||||
|
|
||||||
if (_xa_api == NULL){
|
if ((xa = clicon_xmldb_api_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb plugin");
|
clicon_err(OE_DB, 0, "No xmldb plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (_xa_api->xa_exists_fn == NULL){
|
if (xa->xa_exists_fn == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb function");
|
clicon_err(OE_DB, 0, "No xmldb function");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((xh = clicon_handle_xmldb_get(h)) == NULL){
|
if ((xh = clicon_xmldb_handle_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = _xa_api->xa_exists_fn(xh, db);
|
retval = xa->xa_exists_fn(xh, db);
|
||||||
done:
|
done:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
@ -560,20 +616,21 @@ xmldb_delete(clicon_handle h,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
xmldb_handle xh;
|
xmldb_handle xh;
|
||||||
|
struct xmldb_api *xa;
|
||||||
|
|
||||||
if (_xa_api == NULL){
|
if ((xa = clicon_xmldb_api_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb plugin");
|
clicon_err(OE_DB, 0, "No xmldb plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (_xa_api->xa_delete_fn == NULL){
|
if (xa->xa_delete_fn == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb function");
|
clicon_err(OE_DB, 0, "No xmldb function");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((xh = clicon_handle_xmldb_get(h)) == NULL){
|
if ((xh = clicon_xmldb_handle_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = _xa_api->xa_delete_fn(xh, db);
|
retval = xa->xa_delete_fn(xh, db);
|
||||||
done:
|
done:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
@ -590,20 +647,21 @@ xmldb_init(clicon_handle h,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
xmldb_handle xh;
|
xmldb_handle xh;
|
||||||
|
struct xmldb_api *xa;
|
||||||
|
|
||||||
if (_xa_api == NULL){
|
if ((xa = clicon_xmldb_api_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb plugin");
|
clicon_err(OE_DB, 0, "No xmldb plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (_xa_api->xa_init_fn == NULL){
|
if (xa->xa_init_fn == NULL){
|
||||||
clicon_err(OE_DB, 0, "No xmldb function");
|
clicon_err(OE_DB, 0, "No xmldb function");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((xh = clicon_handle_xmldb_get(h)) == NULL){
|
if ((xh = clicon_xmldb_handle_get(h)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
clicon_err(OE_DB, 0, "Not connected to datastore plugin");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = _xa_api->xa_init_fn(xh, db);
|
retval = xa->xa_init_fn(xh, db);
|
||||||
done:
|
done:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@
|
||||||
#include "clixon_string.h"
|
#include "clixon_string.h"
|
||||||
#include "clixon_yang.h"
|
#include "clixon_yang.h"
|
||||||
#include "clixon_yang_type.h"
|
#include "clixon_yang_type.h"
|
||||||
|
#include "clixon_plugin.h"
|
||||||
#include "clixon_options.h"
|
#include "clixon_options.h"
|
||||||
#include "clixon_xml.h"
|
#include "clixon_xml.h"
|
||||||
#include "clixon_xsl.h"
|
#include "clixon_xsl.h"
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@
|
||||||
#include "clixon_file.h"
|
#include "clixon_file.h"
|
||||||
#include "clixon_yang.h"
|
#include "clixon_yang.h"
|
||||||
#include "clixon_hash.h"
|
#include "clixon_hash.h"
|
||||||
|
#include "clixon_plugin.h"
|
||||||
#include "clixon_options.h"
|
#include "clixon_options.h"
|
||||||
#include "clixon_yang_type.h"
|
#include "clixon_yang_type.h"
|
||||||
#include "clixon_yang_parse.h"
|
#include "clixon_yang_parse.h"
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@
|
||||||
#include "clixon_handle.h"
|
#include "clixon_handle.h"
|
||||||
#include "clixon_yang.h"
|
#include "clixon_yang.h"
|
||||||
#include "clixon_hash.h"
|
#include "clixon_hash.h"
|
||||||
|
#include "clixon_plugin.h"
|
||||||
#include "clixon_options.h"
|
#include "clixon_options.h"
|
||||||
#include "clixon_yang.h"
|
#include "clixon_yang.h"
|
||||||
#include "clixon_yang_type.h"
|
#include "clixon_yang_type.h"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue