Split config into multiple sub-files on mount-point boundaries and dont write clean subfiles
Added CLICON_XMLDB_MULTI option, added cl:xmldb-split extension
This commit is contained in:
parent
bd290e4594
commit
f511cb0030
30 changed files with 1311 additions and 285 deletions
|
|
@ -70,6 +70,7 @@ extern "C" {
|
|||
#include <clixon/clixon_uid.h>
|
||||
#include <clixon/clixon_queue.h>
|
||||
#include <clixon/clixon_hash.h>
|
||||
#include <clixon/clixon_digest.h>
|
||||
#include <clixon/clixon_handle.h>
|
||||
#include <clixon/clixon_yang.h>
|
||||
#include <clixon/clixon_xml.h>
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ struct db_elmnt {
|
|||
* reset by commit, discard
|
||||
*/
|
||||
int de_empty; /* Empty on read from file, xmldb_readfile and xmldb_put sets it */
|
||||
int de_volatile; /* Do not sync to disk on every update (ie xmldb_put) */
|
||||
int de_volatile; /* Disable auto-sync of cache to disk on every update (ie xmldb_put) */
|
||||
};
|
||||
typedef struct db_elmnt db_elmnt;
|
||||
|
||||
|
|
@ -66,16 +66,21 @@ typedef struct db_elmnt db_elmnt;
|
|||
db_elmnt *clicon_db_elmnt_get(clixon_handle h, const char *db);
|
||||
int clicon_db_elmnt_set(clixon_handle h, const char *db, db_elmnt *xc);
|
||||
int xmldb_db2file(clixon_handle h, const char *db, char **filename);
|
||||
int xmldb_db2subdir(clixon_handle h, const char *db, char **dir);
|
||||
|
||||
/* API */
|
||||
int xmldb_connect(clixon_handle h);
|
||||
int xmldb_disconnect(clixon_handle h);
|
||||
/* in clixon_datastore_read.[ch] */
|
||||
/* in clixon_datastore_read.[ch]: */
|
||||
int xmldb_get(clixon_handle h, const char *db, cvec *nsc, char *xpath, cxobj **xret);
|
||||
int xmldb_get0(clixon_handle h, const char *db, yang_bind yb,
|
||||
cvec *nsc, const char *xpath, int copy, withdefaults_type wdef,
|
||||
cxobj **xret, modstate_diff_t *msd, cxobj **xerr);
|
||||
int xmldb_put(clixon_handle h, const char *db, enum operation_type op, cxobj *xt, char *username, cbuf *cbret); /* in clixon_datastore_write.[ch] */
|
||||
/* in clixon_datastore_write.[ch]: */
|
||||
int xmldb_put(clixon_handle h, const char *db, enum operation_type op, cxobj *xt, char *username, cbuf *cbret);
|
||||
int xmldb_dump(clixon_handle h, FILE *f, cxobj *xt, enum format_enum format, int pretty, withdefaults_type wdef, int multi, const char *multidb);
|
||||
int xmldb_write_cache2file(clixon_handle h, const char *db);
|
||||
|
||||
int xmldb_copy(clixon_handle h, const char *from, const char *to);
|
||||
int xmldb_lock(clixon_handle h, const char *db, uint32_t id);
|
||||
int xmldb_unlock(clixon_handle h, const char *db);
|
||||
|
|
@ -98,7 +103,5 @@ int xmldb_volatile_set(clixon_handle h, const char *db, int value);
|
|||
int xmldb_print(clixon_handle h, FILE *f);
|
||||
int xmldb_rename(clixon_handle h, const char *db, const char *newdb, const char *suffix);
|
||||
int xmldb_populate(clixon_handle h, const char *db);
|
||||
int xmldb_write_cache2file(clixon_handle h, const char *db);
|
||||
int xmldb_dump(clixon_handle h, FILE *f, cxobj *xt, withdefaults_type wdef);
|
||||
|
||||
#endif /* _CLIXON_DATASTORE_H */
|
||||
|
|
|
|||
43
lib/clixon/clixon_digest.h
Normal file
43
lib/clixon/clixon_digest.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
*
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
|
||||
Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren
|
||||
Copyright (C) 2017-2019 Olof Hagsand
|
||||
Copyright (C) 2020-2022 Olof Hagsand and Rubicon Communications, LLC (Netgate)
|
||||
|
||||
This file is part of CLIXON.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
the GNU General Public License Version 3 or later (the "GPL"),
|
||||
in which case the provisions of the GPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of the GPL, and not to allow others to
|
||||
use your version of this file under the terms of Apache License version 2,
|
||||
indicate your decision by deleting the provisions above and replace them with
|
||||
the notice and other provisions required by the GPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the Apache License version 2 or the GPL.
|
||||
|
||||
***** END LICENSE BLOCK *****
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _CLIXON_DIGEST_H_
|
||||
#define _CLIXON_DIGEST_H_
|
||||
|
||||
int clixon_digest_hex(const char *string, char **hexstrp);
|
||||
|
||||
#endif /* _CLIXON_DIGEST_H_ */
|
||||
|
|
@ -43,6 +43,7 @@ int clicon_file_dirent(const char *dir, struct dirent **ent,
|
|||
const char *regexp, mode_t type);
|
||||
int clicon_files_recursive(const char *dir, const char *regexp, cvec *cvv);
|
||||
int clicon_file_copy(char *src, char *target);
|
||||
int clicon_dir_copy(char *src, char *target);
|
||||
int clicon_file_cbuf(const char *filename, cbuf *cb);
|
||||
|
||||
#endif /* _CLIXON_FILE_H_ */
|
||||
|
|
|
|||
|
|
@ -207,6 +207,7 @@ enum format_enum{
|
|||
#define XML_FLAG_TOP 0x80 /* Top datastore symbol */
|
||||
#define XML_FLAG_BODYKEY 0x100 /* Text parsing key to be translated from body to key */
|
||||
#define XML_FLAG_ANYDATA 0x200 /* Treat as anydata, eg mount-points before bound */
|
||||
#define XML_FLAG_CACHE_DIRTY 0x400 /* This part of XML tree is not synced to disk */
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
|
|
|
|||
|
|
@ -44,8 +44,12 @@
|
|||
* Prototypes
|
||||
*/
|
||||
int clixon_xml2file1(FILE *f, cxobj *xn, int level, int pretty, char *prefix,
|
||||
clicon_output_cb *fn, int skiptop, int autocliext, withdefaults_type wdef);
|
||||
clicon_output_cb *fn, int skiptop, int autocliext, withdefaults_type wdef,
|
||||
int multi);
|
||||
int clixon_xml2file(FILE *f, cxobj *xn, int level, int pretty, char *prefix, clicon_output_cb *fn, int skiptop, int autocliext);
|
||||
int clixon_xml2file_multi(clixon_handle h, const char *db, cxobj *xn, int level, int pretty,
|
||||
char *prefix, clicon_output_cb *fn, int skiptop, int autocliext,
|
||||
withdefaults_type wdef);
|
||||
int xml_print(FILE *f, cxobj *xn);
|
||||
int xml_dump(FILE *f, cxobj *x);
|
||||
int clixon_xml2cbuf1(cbuf *cb, cxobj *x, int level, int prettyprint, char *prefix,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue