C-style update: Unified comment, retvals in order, remove trailing spaces

Changed function name for `clicon_debug` functions
This commit is contained in:
Olof hagsand 2023-10-22 18:04:47 +02:00
parent 6e314dd96f
commit 62348fc9c7
204 changed files with 6047 additions and 4904 deletions

View file

@ -50,17 +50,17 @@ typedef enum {
* see https://clixon-docs.readthedocs.io/en/latest/netconf.html#ipc
* Must be local on device
*/
CLIXON_CLIENT_IPC,
CLIXON_CLIENT_IPC,
/* Regular NETCONF via local netconf binary
* Fork clixon_netconf locally which in turn communicates with backend
* Must be local on device
*/
CLIXON_CLIENT_NETCONF,
CLIXON_CLIENT_NETCONF,
/* Regular NETCONF using ssh sub-system via local SSH (openssh) client binary
* Fork ssh locally which in turn communicates remotely to device
* Must have openssh installed locally and device must have ssh sub-subsystem
*/
CLIXON_CLIENT_SSH
CLIXON_CLIENT_SSH
} clixon_client_type;
/*
@ -70,7 +70,7 @@ typedef enum {
#ifdef __cplusplus
extern "C" {
#endif
clixon_handle clixon_client_init(const char *config_file);
int clixon_client_terminate(clixon_handle h);
int clixon_client_lock(int sock, const char *descr, const int lock, const char *db);
@ -83,7 +83,7 @@ int clixon_client_get_uint8(clixon_client_handle ch, uint8_t *rval, const char
int clixon_client_get_uint16(clixon_client_handle ch, uint16_t *rval, const char *xnamespace, const char *xpath);
int clixon_client_get_uint32(clixon_client_handle ch, uint32_t *rval, const char *xnamespace, const char *xpath);
int clixon_client_get_uint64(clixon_client_handle ch, uint64_t *rval, const char *xnamespace, const char *xpath);
/* Access functions */
int clixon_client_socket_get(clixon_client_handle ch);

View file

@ -125,19 +125,19 @@ int clicon_socket_set(clicon_handle h, int s);
int clicon_client_socket_get(clicon_handle h);
int clicon_client_socket_set(clicon_handle h, int s);
/*! Set and get module state full and brief cached tree */
/* Set and get module state full and brief cached tree */
cxobj *clicon_modst_cache_get(clicon_handle h, int brief);
int clicon_modst_cache_set(clicon_handle h, int brief, cxobj *xms);
/*! Set and get yang/xml module revision changelog */
/* Set and get yang/xml module revision changelog */
cxobj *clicon_xml_changelog_get(clicon_handle h);
int clicon_xml_changelog_set(clicon_handle h, cxobj *xchlog);
/*! Set and get user command-line options (after --) */
/* Set and get user command-line options (after --) */
int clicon_argv_get(clicon_handle h, int *argc, char ***argv);
int clicon_argv_set(clicon_handle h, char *argv0, int argc, char **argv);
/*! Set and get (client/backend) session id */
/* Set and get (client/backend) session id */
int clicon_session_id_set(clicon_handle h, uint32_t id);
int clicon_session_id_get(clicon_handle h, uint32_t *id);
int clicon_session_id_del(clicon_handle h);

View file

@ -52,7 +52,7 @@ int xmldb_disconnect(clicon_handle h);
int xmldb_get(clicon_handle h, const char *db, cvec *nsc, char *xpath, cxobj **xtop);
int xmldb_get0(clicon_handle h, const char *db, yang_bind yb,
cvec *nsc, const char *xpath, int copy, withdefaults_type wdef,
cxobj **xtop, modstate_diff_t *msd, cxobj **xerr);
cxobj **xtop, modstate_diff_t *msd, cxobj **xerr);
int xmldb_get0_clear(clicon_handle h, cxobj *x);
int xmldb_get0_free(clicon_handle h, cxobj **xp);
int xmldb_put(clicon_handle h, const char *db, enum operation_type op, cxobj *xt, char *username, cbuf *cbret); /* in clixon_datastore_write.[ch] */

View file

@ -38,6 +38,7 @@
#define _CLIXON_DISPATCH_DISPATCHER_H
/*! Prototype for a function to handle a path
*
* minimally needs the path it's working on, but probably
* we want to hand down cached data somehow
* @param[in] h Generic handler

View file

@ -45,7 +45,7 @@
/*
* Constants
*/
*/
#define ERR_STRLEN 256
/* Special error number for clicon_suberrno
@ -57,9 +57,9 @@
* Types
* Add error category here,
* @see EV variable in clixon_err.c but must also add an entry there
*/
*/
enum clicon_err{
/* 0 means error not set) */
/* 0 means error not set) */
OE_DB = 1, /* database registries */
OE_DAEMON, /* daemons: pidfiles, etc */
OE_EVENTS, /* events, filedescriptors, timeouts */
@ -79,11 +79,12 @@ enum clicon_err{
OE_UNDEF,
/*-- From here error extensions using clixon_err_cat_reg, XXX register dynamically? --*/
OE_SSL, /* Openssl errors, see eg ssl_get_error and clixon_openssl_log_cb */
OE_SNMP , /* Netsnmp error */
OE_SNMP , /* Netsnmp error */
OE_NGHTTP2, /* nghttp2 errors, see HAVE_LIBNGHTTP2 */
};
/* Clixon error category log callback
/*! Clixon error category log callback
*
* @param[in] handle Application-specific handle
* @param[in] suberr Application-specific handle
* @param[out] cb Read log/error string into this buffer

View file

@ -59,7 +59,7 @@ int clixon_event_reg_fd(int fd, int (*fn)(int, void*), void *arg, char *str);
int clixon_event_unreg_fd(int s, int (*fn)(int, void*));
int clixon_event_reg_timeout(struct timeval t, int (*fn)(int, void*),
int clixon_event_reg_timeout(struct timeval t, int (*fn)(int, void*),
void *arg, char *str);
int clixon_event_unreg_timeout(int (*fn)(int, void*), void *arg);

View file

@ -40,7 +40,7 @@
#define _CLIXON_FILE_H_
int clicon_file_dirent(const char *dir, struct dirent **ent,
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);

View file

@ -60,7 +60,7 @@ typedef void *plghndl_t;
*/
typedef int (clicon_output_cb)(
FILE *f,
const char *templ, ...
const char *templ, ...
) __attribute__ ((format (printf, 2, 3)));
/*

View file

@ -67,10 +67,15 @@ size_t clicon_log_string_limit_get(void);
int clicon_get_logflags(void);
int clicon_log_str(int level, char *msg);
int clicon_log(int level, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
int clicon_debug(int dbglevel, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
int clicon_debug_init(int dbglevel, FILE *f);
int clicon_debug_get(void);
int clixon_debug(int dbglevel, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
int clixon_debug_init(int dbglevel, FILE *f);
int clixon_debug_get(void);
char *mon2name(int md);
/* 6.4 backward compatability */
#if 1
#define clicon_debug clixon_debug
#define clicon_debug_init clixon_debug_init
#define clicon_debug_get clixon_debug_get
#endif
#endif /* _CLIXON_LOG_H_ */

View file

@ -49,7 +49,7 @@ extern "C" {
#endif
ssize_t netconf_input_read2(int s, unsigned char *buf, ssize_t buflen, int *eof);
int netconf_input_msg2(unsigned char **bufp, size_t *lenp, cbuf *cbmsg,
int netconf_input_msg2(unsigned char **bufp, size_t *lenp, cbuf *cbmsg,
netconf_framing_type framing, int *frame_state, size_t *frame_size,
int *eom);
int netconf_input_frame2(cbuf *cb, yang_bind yb, yang_stmt *yspec, cxobj **xrecv, cxobj **xerr);

View file

@ -97,7 +97,8 @@
/*
* Types
*/
/*! Content query parameter RFC 8040 Sec 4.8.1
/*! Content query parameter RFC 8040 Sec 4.8.1
*
* Clixon extention: content so that RFC8040 content attribute can be conveyed
* internally used in <get>
*/
@ -111,7 +112,7 @@ typedef enum netconf_content netconf_content;
enum target_type{ /* netconf */
RUNNING,
CANDIDATE
};
};
enum test_option{ /* edit-config */
SET,
@ -126,7 +127,7 @@ enum error_option{ /* edit-config */
/* NETCONF framing
*/
enum framing_type{
enum framing_type{
NETCONF_SSH_EOM=0, /* RFC 4742, RFC 6242 hello msg (end-of-msg: ]]>]]>)*/
NETCONF_SSH_CHUNKED, /* RFC 6242 Chunked framing */
};
@ -135,7 +136,7 @@ typedef enum framing_type netconf_framing_type;
/* NETCONF with-defaults
* @see RFC 6243
*/
enum withdefaults_type{
enum withdefaults_type{
WITHDEFAULTS_REPORT_ALL = 0, /* default behavior: <= Clixon 6.0 */
WITHDEFAULTS_TRIM,
WITHDEFAULTS_EXPLICIT, /* default behavior: > Clixon 6.0 */
@ -147,6 +148,7 @@ typedef enum withdefaults_type withdefaults_type;
* Macros
*/
/*! Generate textual error log from Netconf error message
*
* @param[in] xerr Netconf error xml tree on the form: <rpc-error>
* @param[in] format Format string
* @param[in] arg String argument to format (optional)

View file

@ -46,6 +46,7 @@
* Constants
*/
/*! Clixon configuration namespace
*
* Probably should be defined somewhere else or extracted from yang
* @see clixon-config.yang
* @see clixon-lib.yang
@ -85,6 +86,7 @@ enum nacm_credentials_t{
};
/*! Datastore cache behaviour, see clixon_datastore.[ch]
*
* See config option type datastore_cache in clixon-config.yang
*/
enum datastore_cache{
@ -94,6 +96,7 @@ enum datastore_cache{
};
/*! yang clixon regexp engine
*
* @see regexp_mode in clixon-config.yang
*/
enum regexp_mode{

View file

@ -65,7 +65,7 @@ typedef struct {
qelem_t cp_qelem; /* List header */
char *cp_prefix; /* Prefix or module name, should be resolved + id to cp_yang */
char *cp_id; /* Identifier */
cvec *cp_cvk; /* Key values: list of (name:value) pairs alt (NULL:value)
cvec *cp_cvk; /* Key values: list of (name:value) pairs alt (NULL:value)
* Can also be single uint32, if so positional eg x/y[42]
* This seems kludgy but follows RFC 7950 Sec 9.13
*/
@ -81,7 +81,7 @@ int yang2api_path_fmt(yang_stmt *ys, int inclkey, char **api_path_fmt);
int api_path_fmt2api_path(const char *api_path_fmt, cvec *cvv, char **api_path, int *cvvi);
int api_path_fmt2xpath(char *api_path_fmt, cvec *cvv, char **xpath);
int api_path2xpath(char *api_path, yang_stmt *yspec, char **xpath, cvec **nsc, cxobj **xerr);
int api_path2xml(char *api_path, yang_stmt *yspec, cxobj *xtop,
int api_path2xml(char *api_path, yang_stmt *yspec, cxobj *xtop,
yang_class nodeclass, int strict,
cxobj **xpathp, yang_stmt **ypathp, cxobj **xerr);
int xml2api_path_1(cxobj *x, cbuf *cb);

View file

@ -50,7 +50,7 @@
/*
* Types
*/
/*! Registered RPC callback function
*
* @param[in] h Clicon handle
@ -62,11 +62,11 @@
* @retval -1 Error
*/
typedef int (*clicon_rpc_cb)(
clicon_handle h,
cxobj *xn,
cbuf *cbret,
void *arg,
void *regarg
clicon_handle h,
cxobj *xn,
cbuf *cbret,
void *arg,
void *regarg
);
/*! Registered Upgrade callback function
@ -84,22 +84,22 @@ typedef int (*clicon_rpc_cb)(
* @retval -1 Error
*/
typedef int (*clicon_upgrade_cb)(
clicon_handle h,
cxobj *xn,
clicon_handle h,
cxobj *xn,
char *ns,
uint16_t op,
uint32_t from,
uint32_t to,
void *arg,
void *arg,
cbuf *cbret
);
);
/* Clixon authentication type
* @see http-auth-type in clixon-restconf.yang
* For now only used by restconf frontend
*/
enum clixon_auth_type {
CLIXON_AUTH_NONE = 0, /* Message is authenticated automatically to
CLIXON_AUTH_NONE = 0, /* Message is authenticated automatically to
anonymous user, maye be changed by ca-auth callback
FEATURE clixon-restconf:allow-auth-none must be enabled */
CLIXON_AUTH_CLIENT_CERTIFICATE, /* TLS Client certification authentication */
@ -108,13 +108,15 @@ enum clixon_auth_type {
};
typedef enum clixon_auth_type clixon_auth_type_t;
/* Common plugin function names, function types and signatures.
/*! Common plugin function names, function types and signatures.
*
* This plugin code is exytended by backend, cli, netconf, restconf plugins
* Cli see cli_plugin.c
* Backend see config_plugin.c
*/
/* Called when application is "started", (almost) all initialization is complete
/*! Called when application is "started", (almost) all initialization is complete
*
* Backend: daemon is in the background. If daemon privileges are dropped
* this callback is called *before* privileges are dropped.
* @param[in] h Clixon handle
@ -203,7 +205,7 @@ typedef int (plgauth_t)(clicon_handle h, void *req, clixon_auth_type_t auth_type
* @retval 0 OK
* @retval -1 Fatal error
*/
typedef int (plgreset_t)(clicon_handle h, const char *db);
typedef int (plgreset_t)(clicon_handle h, const char *db);
/* Provide state data from plugin
*
@ -215,7 +217,7 @@ typedef int (plgreset_t)(clicon_handle h, const char *db);
*
* @param[in] h Clicon handle
* @param[in] xpath Part of state requested
* @param[in] nsc XPATH namespace context.
* @param[in] nsc XPath namespace context.
* @param[out] xtop XML tree where statedata is added
* @retval 0 OK
* @retval -1 Fatal error
@ -226,7 +228,8 @@ typedef int (plgreset_t)(clicon_handle h, const char *db);
*/
typedef int (plgstatedata_t)(clicon_handle h, cvec *nsc, char *xpath, cxobj *xtop);
/* Pagination-data type
/*! Pagination-data type
*
* @see pagination_data_t in for full pagination data structure
* @see pagination_offset() and other accessor functions
*/
@ -243,7 +246,8 @@ typedef void *pagination_data;
*/
typedef int (plglockdb_t)(clicon_handle h, char *db, int lock, int id);
/* Transaction-data type
/*! Transaction-data type
*
* @see transaction_data_t and clixon_backend_transaction.h for full transaction API
*/
typedef void *transaction_data;
@ -252,6 +256,7 @@ typedef void *transaction_data;
typedef int (trans_cb_t)(clicon_handle h, transaction_data td);
/*! Hook to override default prompt with explicit function
*
* Format prompt before each getline
* @param[in] h Clicon handle
* @param[in] mode Cligen syntax mode
@ -311,6 +316,7 @@ typedef int (yang_mount_t)(clicon_handle h, cxobj *xt, int *config,
typedef int (yang_patch_t)(clicon_handle h, yang_stmt *ymod);
/*! Startup status for use in startup-callback
*
* Note that for STARTUP_ERR and STARTUP_INVALID, running runs in failsafe mode
* and startup contains the erroneous or invalid database.
* The user should repair the startup and
@ -400,6 +406,7 @@ typedef struct clixon_plugin_api clixon_plugin_api;
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;

View file

@ -40,7 +40,7 @@
/*
* Types
*/
*/
typedef struct process_entry_t process_entry_t;
/* Process operations */
@ -52,7 +52,7 @@ typedef enum proc_operation {
PROC_OP_STATUS
} proc_operation;
/*! Process RPC callback function
/*! Process RPC callback function
*
* @param[in] h Clixon handle
* @param[in] pe Process entry
@ -64,7 +64,7 @@ typedef int (proc_cb_t)(clicon_handle h,
/*
* Prototypes
*/
*/
int clixon_proc_socket(char **argv, int sock_flags, pid_t *pid, int *sock);
int clixon_proc_socket_close(pid_t pid, int sock);
int clixon_process_pid(clicon_handle h, const char *name, pid_t *pid);

View file

@ -53,7 +53,7 @@ struct clicon_msg {
/*
* Prototypes
*/
*/
char *format_int2str(enum format_enum showas);
enum format_enum format_str2int(char *str);
@ -68,7 +68,7 @@ int clicon_rpc_connect_unix(clicon_handle h,
int *sock0);
int clicon_rpc_connect_inet(clicon_handle h,
char *dst,
char *dst,
uint16_t port,
int *sock0);

View file

@ -48,7 +48,7 @@ int clicon_rpc_msg_persistent(clicon_handle h, struct clicon_msg *msg, cxobj **x
int clicon_rpc_netconf(clicon_handle h, char *xmlst, cxobj **xret, int *sp);
int clicon_rpc_netconf_xml(clicon_handle h, cxobj *xml, cxobj **xret, int *sp);
int clicon_rpc_get_config(clicon_handle h, char *username, char *db, char *xpath, cvec *nsc, char *defaults, cxobj **xret);
int clicon_rpc_edit_config(clicon_handle h, char *db, enum operation_type op,
int clicon_rpc_edit_config(clicon_handle h, char *db, enum operation_type op,
char *xml);
int clicon_rpc_copy_config(clicon_handle h, char *db1, char *db2);
int clicon_rpc_delete_config(clicon_handle h, char *db);
@ -56,7 +56,7 @@ int clicon_rpc_lock(clicon_handle h, char *db);
int clicon_rpc_unlock(clicon_handle h, char *db);
int clicon_rpc_get2(clicon_handle h, char *xpath, cvec *nsc, netconf_content content, int32_t depth, char *defaults, int bind, cxobj **xret);
int clicon_rpc_get(clicon_handle h, char *xpath, cvec *nsc, netconf_content content, int32_t depth, char *defaults, cxobj **xret);
int clicon_rpc_get_pageable_list(clicon_handle h, char *datastore, char *xpath,
int clicon_rpc_get_pageable_list(clicon_handle h, char *datastore, char *xpath,
cvec *nsc, netconf_content content, int32_t depth, char *defaults,
uint32_t offset, uint32_t limit,
char *direction, char *sort, char *where,

View file

@ -40,6 +40,7 @@
#define _CLIXON_QUEUE_H_
/*! Circular queue structure for use as first entry in a parent structure.
*
* Add qelem_t as first element in struct
* @code
* struct a{
@ -55,6 +56,7 @@ typedef struct _qelem_t {
} qelem_t;
/*! Append element 'elem' to queue.
*
* @param[in] elem Element to be added
* @param[in,out] pred Add element after this
* @code
@ -78,6 +80,7 @@ typedef struct _qelem_t {
}
/*! Insert element 'elem' in queue after 'pred'
*
* @param[in] elem Element to be added
* @param[in,out] pred Add element after this
* @code
@ -100,7 +103,8 @@ typedef struct _qelem_t {
pred = elem; \
}
/*! Remove element 'elem' from queue. 'head' is the pointer to the queue and
/*! Remove element 'elem' from queue. 'head' is the pointer to the queue and
*
* is of 'type'.
* @param[in] elem
* @param[in] head
@ -121,6 +125,7 @@ typedef struct _qelem_t {
}
/*! Get next entry in list
*
* @param[in] type Type of element
* @param[in] el Return next element after elem.
* @code

View file

@ -40,7 +40,7 @@
/*
* Prototypes
*/
*/
int regexp_xsd2posix(char *xsd, char **posix);
int regex_compile(clicon_handle h, char *regexp, void **recomp);
int regex_exec(clicon_handle h, void *recomp, char *string);

View file

@ -45,7 +45,7 @@ typedef void (*sigfn_t)(int);
/*
* Prototypes
*/
*/
int set_signal(int signo, void (*handler)(int), void (**oldhandler)(int));
int set_signal_flags(int signo, int flags, void (*handler)(int), void (**oldhandler)(int));
int clixon_signal_save(sigset_t *sigset, struct sigaction sigaction_vec[32]);

View file

@ -45,7 +45,8 @@
/*
* Types
*/
/* Subscription callback
/*! Subscription callback
*
* @param[in] h Clicon handle
* @param[in] op Operation: 0 OK, 1 Close
* @param[in] event Event as XML

View file

@ -39,12 +39,13 @@
#define _CLIXON_STRING_H_
/*! Struct used to map between int and strings. Typically used to map between
*
* values and their names. Note NULL terminated
* Example:
* @code
static const map_str2int atmap[] = {
{"One", 1},
{"Two", 2},
{"One", 1},
{"Two", 2},
{NULL, -1}
};
* @endcode
@ -73,7 +74,7 @@ typedef struct map_str2str map_str2str;
#include <string.h>
/*! A strdup version that aligns on 4 bytes. To avoid warning from valgrind */
static inline char * strdup4(char *str)
static inline char * strdup4(char *str)
{
char *dup;
size_t len;
@ -86,7 +87,7 @@ static inline char * strdup4(char *str)
/*
* Prototypes
*/
*/
char **clicon_strsep(char *string, char *delim, int *nvec0);
char *clicon_strjoin (int argc, char **argv, char *delim);
char *clixon_string_del_join(char *str1, char *del, char *str2);

View file

@ -41,7 +41,7 @@
/*
* Prototypes
*/
*/
int group_name2gid(const char *name, gid_t *gid);
int name2uid(const char *name, uid_t *uid);
int uid2name(const uid_t uid, char **name);

View file

@ -85,7 +85,7 @@
* This is a "neutral" symbol without any meaning as opposed to the previous symbols ^
* @see DATASTORE_TOP_SYMBOL which should be used for clixon top-level config trees
*/
#define XML_TOP_SYMBOL "top"
#define XML_TOP_SYMBOL "top"
/*
* Types
@ -102,16 +102,16 @@ enum operation_type{ /* edit-config operation */
/* Netconf insert type (see RFC7950 Sec 7.8.6) */
enum insert_type{ /* edit-config insert */
INS_FIRST,
INS_LAST,
INS_BEFORE,
INS_AFTER,
INS_FIRST,
INS_LAST,
INS_BEFORE,
INS_AFTER,
};
/* XML object types */
enum cxobj_type {CX_ERROR=-1,
CX_ELMNT,
CX_ATTR,
enum cxobj_type {CX_ERROR=-1,
CX_ELMNT,
CX_ATTR,
CX_BODY};
/* How to bind yang to XML top-level when parsing
@ -145,7 +145,7 @@ enum cxobj_type {CX_ERROR=-1,
* / \ / \
* x1 x2 - - y1 y2
*/
enum yang_bind{
enum yang_bind{
YB_NONE=0, /* Dont do Yang binding */
YB_MODULE, /* Search for matching yang binding among top-level symbols of Yang modules of direct
* children
@ -165,7 +165,7 @@ typedef enum yang_bind yang_bind;
typedef struct xml cxobj; /* struct defined in clicon_xml.c */
/*! Callback function type for xml_apply
/*! Callback function type for xml_apply
*
* @param[in] x XML node
* @param[in] arg General-purpose argument
@ -182,9 +182,9 @@ typedef struct clixon_xml_vec clixon_xvec; /* struct defined in clicon_xml_vec.c
* @see format_int2str, format_str2int
*/
enum format_enum{
FORMAT_XML,
FORMAT_JSON,
FORMAT_TEXT,
FORMAT_XML,
FORMAT_JSON,
FORMAT_TEXT,
FORMAT_CLI,
FORMAT_NETCONF
};
@ -304,7 +304,7 @@ char *xml_operation2str(enum operation_type op);
int xml_attr_insert2val(char *instr, enum insert_type *ins);
int xml_add_attr(cxobj *xn, char *name, char *value, char *prefix, char *ns);
int clicon_log_xml(int level, cxobj *x, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
int clicon_debug_xml(int dbglevel, cxobj *x, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
int clixon_debug_xml(int dbglevel, cxobj *x, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
#ifdef XML_EXPLICIT_INDEX
int xml_search_index_p(cxobj *x);

View file

@ -50,7 +50,7 @@ int clixon_xml2cbuf(cbuf *cb, cxobj *x, int level, int prettyprint, char *pref
int xmltree2cbuf(cbuf *cb, cxobj *x, int level);
int clixon_xml_parse_file(FILE *f, yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xerr);
int clixon_xml_parse_string(const char *str, yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xerr);
int clixon_xml_parse_va(yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xerr,
int clixon_xml_parse_va(yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xerr,
const char *format, ...) __attribute__ ((format (printf, 5, 6)));
int clixon_xml_attr_copy(cxobj *xin, cxobj *xout, char *name);
int clixon_xml_diff2cbuf(cbuf *cb, cxobj *x0, cxobj *x1);

View file

@ -53,9 +53,9 @@ int isxmlns(cxobj *x);
int xmlns_assign(cxobj *x);
int xml2cvec(cxobj *xt, yang_stmt *ys, cvec **cvv0);
int cvec2xml_1(cvec *cvv, char *toptag, cxobj *xp, cxobj **xt0);
int xml_diff(cxobj *x0, cxobj *x1,
cxobj ***first, int *firstlen,
cxobj ***second, int *secondlen,
int xml_diff(cxobj *x0, cxobj *x1,
cxobj ***first, int *firstlen,
cxobj ***second, int *secondlen,
cxobj ***changed_x0, cxobj ***changed_x1, int *changedlen);
int xml_tree_equal(cxobj *x0, cxobj *x1);
int xml_tree_prune_flagged_sub(cxobj *xt, int flag, int test, int *upmark);

View file

@ -32,7 +32,7 @@
***** END LICENSE BLOCK *****
* Clixon XML XPATH 1.0 according to https://www.w3.org/TR/xpath-10
* Clixon XML XPath 1.0 according to https://www.w3.org/TR/xpath-10
*/
#ifndef _CLIXON_XPATH_H
#define _CLIXON_XPATH_H
@ -66,10 +66,10 @@ enum axis_type{
A_ANCESTOR_OR_SELF,
A_ATTRIBUTE,
A_CHILD,
A_DESCENDANT,
A_DESCENDANT,
A_DESCENDANT_OR_SELF,
A_FOLLOWING,
A_FOLLOWING_SIBLING,
A_FOLLOWING_SIBLING,
A_NAMESPACE,
A_PARENT,
A_PRECEDING,
@ -103,9 +103,10 @@ enum xp_type{
};
/*! XPATH Parsing generates a tree of nodes that is later traversed
* That is, a tree-structured XPATH.
* Note that the structure follows XPATH 1.0 closely. The drawback wit this is that the tree gets
* very deep very quickly, even for simple XPATHs.
*
* That is, a tree-structured XPath.
* Note that the structure follows XPath 1.0 closely. The drawback wit this is that the tree gets
* very deep very quickly, even for simple XPaths.
*/
struct xpath_tree{
enum xp_type xs_type;
@ -136,7 +137,7 @@ int xpath_parse(const char *xpath, xpath_tree **xptree);
int xpath_vec_ctx(cxobj *xcur, cvec *nsc, const char *xpath, int localonly, xp_ctx **xrp);
int xpath_vec_bool(cxobj *xcur, cvec *nsc, const char *xpformat, ...) __attribute__ ((format (printf, 3, 4)));
int xpath_vec_flag(cxobj *xcur, cvec *nsc, const char *xpformat, uint16_t flags,
int xpath_vec_flag(cxobj *xcur, cvec *nsc, const char *xpformat, uint16_t flags,
cxobj ***vec, size_t *veclen, ...) __attribute__ ((format (printf, 3, 7)));
/* Functions with explicit namespace context (nsc) set. If you do not need

View file

@ -33,8 +33,8 @@
***** END LICENSE BLOCK *****
* Clixon XML XPATH 1.0 according to https://www.w3.org/TR/xpath-10
* This file defines XPATH contexts using in traversing the XPATH parse tree.
* Clixon XML XPath 1.0 according to https://www.w3.org/TR/xpath-10
* This file defines XPath contexts using in traversing the XPath parse tree.
*/
#ifndef _CLIXON_XPATH_CTX_H
#define _CLIXON_XPATH_CTX_H
@ -43,7 +43,8 @@
* Types
*/
/*! XPATH expression type
/*! XPath expression type
*
* An expression is evaluated to yield an object, which has one of the following four basic types:
* node-set (an unordered collection of nodes without duplicates)
* boolean (true or false)

View file

@ -32,7 +32,7 @@
***** END LICENSE BLOCK *****
* Clixon XML XPATH 1.0 according to https://www.w3.org/TR/xpath-10
* Clixon XML XPath 1.0 according to https://www.w3.org/TR/xpath-10
* See XPATH_LIST_OPTIMIZE
*/
#ifndef _CLIXON_XPATH_OPTIMIZE_H
@ -40,7 +40,7 @@
int xpath_list_optimize_stats(int *hits);
int xpath_list_optimize_set(int enable);
int xpath_list_optimize_set(int enable);
void xpath_optimize_exit(void);
int xpath_optimize_check(xpath_tree *xs, cxobj *xv, cxobj ***xvec0, int *xlen0);

View file

@ -32,9 +32,9 @@
***** END LICENSE BLOCK *****
* Clixon XML XPATH 1.0 according to https://www.w3.org/TR/xpath-10
* Clixon XML XPath 1.0 according to https://www.w3.org/TR/xpath-10
* Note: for YANG which is constrained to path-arg as defined in rfc7950
* See: clixon_xpath.[ch] for full XML XPATH implementation
* See: clixon_xpath.[ch] for full XML XPath implementation
*/
#ifndef _CLIXON_XPATH_YANG_H
#define _CLIXON_XPATH_YANG_H

View file

@ -49,7 +49,7 @@
#define V_UNSET 0x10 /* Used by XML code to denote a value is not default */
/*
* Yang flags used in
* Yang flags used in
*/
#define YANG_FLAG_MARK 0x01 /* (Dynamic) marker for dynamic algorithms, eg expand and DAG */
#define YANG_FLAG_TMP 0x02 /* (Dynamic) marker for dynamic algorithms, eg DAG detection */
@ -66,7 +66,7 @@
#define YANG_FLAG_CONFIG_VALUE 0x20 /* Ancestor config cache value */
#endif
#define YANG_FLAG_DISABLED 0x40 /* Disabled due to if-feature evaluate to false
#define YANG_FLAG_DISABLED 0x40 /* Disabled due to if-feature evaluate to false
* Transformed to ANYDATA but some code may need to check
* why it is an ANYDATA
*/
@ -88,6 +88,7 @@
* Types
*/
/*! YANG keywords from RFC6020.
*
* See also keywords generated by yacc/bison in clicon_yang_parse.tab.h, but they start with K_
* instead of Y_
* Wanted to unify these (K_ and Y_) but gave up for several reasons:
@ -129,7 +130,7 @@ enum rfc_6020{
Y_LEAF,
Y_LEAF_LIST,
Y_LENGTH,
Y_LIST,
Y_LIST,
Y_MANDATORY,
Y_MAX_ELEMENTS,
Y_MIN_ELEMENTS,
@ -183,14 +184,15 @@ struct xml;
/* This is the external handle type exposed in the API.
* The internal struct is defined in clixon_yang_internal.h */
typedef struct yang_stmt yang_stmt;
typedef struct yang_stmt yang_stmt;
/*! Yang apply function worker
*
* @param[in] yn yang node
* @param[in] arg Argument
* @retval -1 Error, abort
* @retval 0 OK, continue with next
* @retval n OK, abort traversal and return to caller with "n"
* @retval 0 OK, continue with next
* @retval -1 Error, abort
*/
typedef int (yang_applyfn_t)(yang_stmt *ys, void *arg);

View file

@ -47,7 +47,8 @@
* Types
*/
/* Struct containing module state differences between two modules or two
/*! Struct containing module state differences between two modules or two
*
* revisions of same module.
* The most significant usecase is one module-state is a loaded datastore and the other
* is the one loaded by the server by its YANG files.

View file

@ -46,6 +46,7 @@
/* Limitations/deviations from RFC 8528 */
/*! Only support YANG presende containers as mount-points
*
* This is a limitation of othe current implementation
*/
#define YANG_SCHEMA_MOUNT_ONLY_PRESENCE_CONTAINERS

View file

@ -62,13 +62,13 @@ yang_stmt *yang_find_identity(yang_stmt *ys, char *identity);
yang_stmt *yang_find_identity_nsc(yang_stmt *yspec, char *identity, cvec *nsc);
int ys_cv_validate(clicon_handle h, cg_var *cv, yang_stmt *ys, yang_stmt **ysub, char **reason);
int clicon_type2cv(char *type, char *rtype, yang_stmt *ys, enum cv_type *cvtype);
int yang_type_get(yang_stmt *ys, char **otype, yang_stmt **restype,
int yang_type_get(yang_stmt *ys, char **otype, yang_stmt **restype,
int *options, cvec **cvv,
cvec *patterns, cvec *regexps,
uint8_t *fraction_digits);
int yang_type_resolve(yang_stmt *yorig, yang_stmt *ys,
yang_stmt *ytype,
yang_stmt **restype, int *options,
yang_stmt *ytype,
yang_stmt **restype, int *options,
cvec **cvv, cvec *patterns, cvec *regexps,
uint8_t *fraction);
enum cv_type yang_type2cv(yang_stmt *ys);