yumapro  20.10-12
YumaPro SDK
conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 - 2012, Andy Bierman, All Rights Reserved.
3  * Copyright (c) 2012 - 2021, YumaWorks, Inc., All Rights Reserved.
4  *
5  * Unless required by applicable law or agreed to in writing,
6  * software distributed under the License is distributed on an
7  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8  * KIND, either express or implied. See the License for the
9  * specific language governing permissions and limitations
10  * under the License.
11  */
12 #ifndef _H_conf
13 #define _H_conf
14 
15 /* FILE: conf.h
16 *********************************************************************
17 * *
18 * P U R P O S E *
19 * *
20 *********************************************************************/
21 
28 /*********************************************************************
29 * *
30 * C H A N G E H I S T O R Y *
31 * *
32 *********************************************************************
33 
34 date init comment
35 ----------------------------------------------------------------------
36 22-oct-07 abb Begun
37 
38 */
39 
40 #include <xmlstring.h>
41 
42 #ifndef _H_status
43 #include "status.h"
44 #endif
45 
46 #ifndef _H_val
47 #include "val.h"
48 #endif
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 /********************************************************************
55 * *
56 * F U N C T I O N S *
57 * *
58 *********************************************************************/
59 
60 
61 /* group defined in cli.h */
91 extern status_t
92  conf_parse_val_from_filespec (const xmlChar *filespec,
93  val_value_t *val,
94  boolean keepvals,
95  boolean fileerr);
96 
97 
98 
124 extern status_t
125  conf_parse_val_from_filespec_ex (const xmlChar *filespec,
126  const xmlChar *banner_object,
127  val_value_t *val,
128  boolean keepvals,
129  boolean fileerr,
130  boolean *fileopened);
131 
134 #ifdef __cplusplus
135 } /* end extern 'C' */
136 #endif
137 
138 #endif /* _H_conf */
ERR_NCX_SKIPPED
@ ERR_NCX_SKIPPED
2001
Definition: status_enum.h:551
TK_TT_RBRACK
@ TK_TT_RBRACK
right bracket ']'
Definition: tk.h:292
xml_strlen
uint32 xml_strlen(const xmlChar *str)
Get the String len for xmlChar.
Definition: xml_util.c:1406
TK_TT_TSTRING
@ TK_TT_TSTRING
token string
Definition: tk.h:319
tk_next_typ
tk_type_t tk_next_typ(tk_chain_t *tkc)
Get the token type of the next token.
Definition: tk.c:3349
TK_CUR_TEXT
#define TK_CUR_TEXT(T)
return TRUE if the token is a text or number type, as opposed to a 1 or 2 char non-text token type YP...
Definition: tk.h:188
xml_strncpy
uint32 xml_strncpy(xmlChar *copyTo, const xmlChar *copyFrom, uint32 maxlen)
String copy for xmlChar – checks for buffer overflow.
Definition: xml_util.c:1518
obj_get_typdef
typ_def_t * obj_get_typdef(obj_template_t *obj)
Get the typdef for the leaf or leaf-list.
Definition: obj.c:11991
tk_new_chain
tk_chain_t * tk_new_chain(void)
Allocatate a new token parse chain.
Definition: tk.c:2919
ncx_warning_enabled
boolean ncx_warning_enabled(status_t res)
Check if a specific status_t code is enabled.
Definition: ncx.c:9394
val_set_name
void val_set_name(val_value_t *val, const xmlChar *name, uint32 namelen)
Set (or reset) the name of a value struct.
Definition: val.c:2875
NCX_IQUAL_ONE
@ NCX_IQUAL_ONE
no iqual == 1
Definition: ncxtypes.h:297
xmlns_find_ns_by_prefix
xmlns_id_t xmlns_find_ns_by_prefix(const xmlChar *pfix)
Find the NS ID from its prefix.
Definition: xmlns.c:755
val_find_child
val_value_t * val_find_child(const val_value_t *parent, const xmlChar *modname, const xmlChar *childname)
Find the first instance of the specified child node.
Definition: val.c:8560
val_change_nsid
void val_change_nsid(val_value_t *val, xmlns_id_t nsid)
Change the namespace ID for a value node and all its descendants.
Definition: val.c:12303
ERR_NCX_DEF_NOT_FOUND
@ ERR_NCX_DEF_NOT_FOUND
250
Definition: status_enum.h:289
log_error
void log_error(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_ERROR log entry.
val_make_string
val_value_t * val_make_string(xmlns_id_t nsid, const xmlChar *valname, const xmlChar *valstr)
Malloc and set a val_value_t as a generic NCX_BT_STRING namespace set to 0 !!!
Definition: val.c:7557
val.h
Value Node Basic Support.
val_make_simval_obj
val_value_t * val_make_simval_obj(obj_template_t *obj, const xmlChar *valstr, status_t *res)
Create and set a val_value_t as a simple type from an object template instead of individual fields Ca...
Definition: val_util.c:4389
tk_free_chain
void tk_free_chain(tk_chain_t *tkc)
Cleanup and deallocate a tk_chain_t.
Definition: tk.c:3205
obj_next_key
obj_key_t * obj_next_key(obj_key_t *objkey)
Get the next key record.
Definition: obj.c:9559
obj_first_key
obj_key_t * obj_first_key(obj_template_t *obj)
Get the first key record.
Definition: obj.c:9472
val_set_string2
status_t val_set_string2(val_value_t *val, const xmlChar *valname, typ_def_t *typdef, const xmlChar *valstr, uint32 valstrlen)
set a string with any typdef Set an initialized val_value_t as a simple type namespace set to 0 !...
Definition: val.c:6675
tk.h
NCX Syntax Token Handler.
tk_dump_chain
void tk_dump_chain(const tk_chain_t *tkc)
Debug printf the token chain !!! Very verbose !!!
Definition: tk.c:3532
val_get_mod_name
const xmlChar * val_get_mod_name(const val_value_t *val)
Get the module name associated with this value node.
Definition: val.c:12223
NCX_BT_ANYDATA
@ NCX_BT_ANYDATA
YANG 1.1 anydata.
Definition: ncxtypes.h:229
ncxconst.h
Contains NCX constants.
ncxmod.h
NCX Module Load Manager.
NCX_MAX_NCXNAME_LEN
#define NCX_MAX_NCXNAME_LEN
matches name length restriction in NcxName and NcxNumName
Definition: ncxconst.h:152
ERR_NCX_WRONG_VAL
@ ERR_NCX_WRONG_VAL
232
Definition: status_enum.h:271
TK_TT_SQSTRING
@ TK_TT_SQSTRING
single quoted string
Definition: tk.h:323
TK_ADV
#define TK_ADV(T)
advance the current token pointer
Definition: tk.h:107
ncx_print_errormsg
void ncx_print_errormsg(tk_chain_t *tkc, ncx_module_t *mod, status_t res)
Print an parse error message to STDOUT.
Definition: ncx.c:7048
ERR_NCX_UNKNOWN_PARM
@ ERR_NCX_UNKNOWN_PARM
227
Definition: status_enum.h:266
TK_CUR_VAL
#define TK_CUR_VAL(T)
return the current token value
Definition: tk.h:128
val_has_index
boolean val_has_index(const val_value_t *val)
Determine if this value has an index.
Definition: val.c:10660
xmlns_get_module
const xmlChar * xmlns_get_module(xmlns_id_t nsid)
get the module name of the namespace ID
Definition: xmlns.c:1126
xmlns_id_t
uint16 xmlns_id_t
integer handle for registered namespaces
Definition: xmlns.h:89
val_remove_child
void val_remove_child(val_value_t *child)
Remove a child value node from its parent value node.
Definition: val.c:8316
log_debug2
void void void void void void void void void log_debug2(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG2 log entry.
TK_CUR_ID
#define TK_CUR_ID(T)
return TRUE if the current token type is an identifier
Definition: tk.h:171
conf_parse_val_from_filespec_ex
status_t conf_parse_val_from_filespec_ex(const xmlChar *filespec, const xmlChar *banner_object, val_value_t *val, boolean keepvals, boolean fileerr, boolean *fileopened)
Parse a file as an NCX text config file against a specific parmset definition.
Definition: conf.c:1317
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
TK_TT_RBRACE
@ TK_TT_RBRACE
right brace '}'
Definition: tk.h:287
ERR_NCX_WRONG_TKTYPE
@ ERR_NCX_WRONG_TKTYPE
245
Definition: status_enum.h:284
val_dump_value
void val_dump_value(val_value_t *val, int32 startindent, log_debug_t lvl)
Printf the specified val_value_t struct to the logfile, or stdout if none set Uses conf file format (...
Definition: val.c:5688
tk_setup_chain_conf
void tk_setup_chain_conf(tk_chain_t *tkc, FILE *fp, const xmlChar *filename)
Setup a previously allocated chain for a text config file.
Definition: tk.c:2945
val_get_nsid
xmlns_id_t val_get_nsid(const val_value_t *val)
Get the namespace ID for the specified value node.
Definition: val.c:12277
TK_CUR_MOD
#define TK_CUR_MOD(T)
return the current token module qualifier value
Definition: tk.h:134
obj_get_name
const xmlChar * obj_get_name(const obj_template_t *obj)
Get the name field for this obj.
Definition: obj.c:10511
conf_parse_val_from_filespec
status_t conf_parse_val_from_filespec(const xmlChar *filespec, val_value_t *val, boolean keepvals, boolean fileerr)
Parse a file as an NCX text config file against a specific parmset definition.
Definition: conf.c:1267
ncx_find_object
obj_template_t * ncx_find_object(ncx_module_t *mod, const xmlChar *objname)
Find a top level module object.
Definition: ncx.c:4345
LOGDEBUG2
#define LOGDEBUG2
Check if at least log-level=debug2.
Definition: log.h:292
val_gen_index_chain
status_t val_gen_index_chain(const obj_template_t *obj, val_value_t *val)
Create an index chain for the just-parsed table or container struct.
Definition: val_util.c:2632
log_warn
void void void log_warn(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_WARN log entry.
ERR_NCX_CONF_PARM_EXISTS
@ ERR_NCX_CONF_PARM_EXISTS
1045
Definition: status_enum.h:534
TK_TT_NEWLINE
@ TK_TT_NEWLINE
is significant in conf files
Definition: tk.h:336
ncx_valid_name
boolean ncx_valid_name(const xmlChar *str, uint32 len)
Check if an xmlChar string is a valid YANG identifier value.
Definition: ncx.c:7596
val_child_add
status_t val_child_add(val_value_t *child, val_value_t *parent)
Add a child value node to a parent value node.
Definition: val_child.c:1542
val_util.h
Value Node Utilities.
val_index_match
boolean val_index_match(const val_value_t *val1, const val_value_t *val2)
Check 2 val_value structs for the same instance ID.
Definition: val.c:9032
ncx_get_gen_container
obj_template_t * ncx_get_gen_container(void)
Get the object template for the NCX generic container.
Definition: ncx.c:6678
ERR_NCX_INVALID_VALUE
@ ERR_NCX_INVALID_VALUE
258
Definition: status_enum.h:299
NCX_BT_EMPTY
@ NCX_BT_EMPTY
empty
Definition: ncxtypes.h:205
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
val_child.h
Value Node Child Access Support.
get_error_string
const char * get_error_string(status_t res)
Get the error message for a specific internal error.
Definition: status.c:239
NCX_BT_CONTAINER
@ NCX_BT_CONTAINER
internal container
Definition: ncxtypes.h:225
log_debug
void void void void void void void log_debug(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG log entry.
typ.h
Parameter Type Handler.
TK_CUR_STR
#define TK_CUR_STR(T)
return TRUE if the current token type is a string
Definition: tk.h:140
obj_is_anydata
boolean obj_is_anydata(const obj_template_t *obj)
Check if object is an anydata.
Definition: obj.c:13284
TK_TT_LINE
@ TK_TT_LINE
raw command line
Definition: tk.h:317
ERR_NCX_EOF
@ ERR_NCX_EOF
244
Definition: status_enum.h:283
conf.h
NCX Text Config file parser.
TK_TT_LBRACK
@ TK_TT_LBRACK
left bracket '['
Definition: tk.h:291
typ_has_index
boolean typ_has_index(ncx_btype_t btyp)
Check if this is a data type that has an index.
Definition: typ.c:3084
obj_is_anyxml
boolean obj_is_anyxml(const obj_template_t *obj)
Check if object is an anyxml.
Definition: obj.c:13271
typ_is_simple
boolean typ_is_simple(ncx_btype_t btyp)
Check if this is a simple data type.
Definition: typ.c:3107
NCX_BT_ANY
@ NCX_BT_ANY
anyxml
Definition: ncxtypes.h:202
EMPTY_STRING
#define EMPTY_STRING
empty string used to get const xmlChar * cast
Definition: ncxconst.h:289
obj_find_child
obj_template_t * obj_find_child(obj_template_t *obj, const xmlChar *modname, const xmlChar *objname)
Find a child object with the specified Qname.
Definition: obj.c:6116
ncx_find_any_object
obj_template_t * ncx_find_any_object(const xmlChar *objname)
Find any top-level object in any YANG module.
Definition: ncx.c:4025
xml_strcmp
int xml_strcmp(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar.
Definition: xml_util.c:1746
TK_TT_LBRACE
@ TK_TT_LBRACE
left brace '{'
Definition: tk.h:286
val_set_by_default
boolean val_set_by_default(const val_value_t *val)
Check if the value was set by val_add_defaults.
Definition: val.c:12571
log.h
NCX System Logging Manager.
ERR_BUFF_OVFL
@ ERR_BUFF_OVFL
106
Definition: status_enum.h:218
tk_next_typ2
tk_type_t tk_next_typ2(tk_chain_t *tkc)
Get the token type of the token after the next token.
Definition: tk.c:3374
ncx_conf_exp_err
void ncx_conf_exp_err(tk_chain_t *tkc, status_t result, const char *expstr)
Print an error for wrong token, expected a different token.
Definition: ncx.c:7192
LOGDEBUG
#define LOGDEBUG
Check if at least log-level=debug.
Definition: log.h:287
tk_tokenize_input
status_t tk_tokenize_input(tk_chain_t *tkc, ncx_module_t *mod)
Parse the input (FILE or buffer) into tk_token_t structs.
Definition: tk.c:3641
xml_strcpy
uint32 xml_strcpy(xmlChar *copyTo, const xmlChar *copyFrom)
String copy for xmlChar.
Definition: xml_util.c:1486
ncx_get_gen_string
obj_template_t * ncx_get_gen_string(void)
Get the object template for the NCX generic string leaf.
Definition: ncx.c:6692
obj_get_basetype
ncx_btype_t obj_get_basetype(const obj_template_t *obj)
Get the NCX base type enum for the object type.
Definition: obj.c:12077
NCX_IQUAL_OPT
@ NCX_IQUAL_OPT
'?' == 0 or 1
Definition: ncxtypes.h:298
val_new_value
val_value_t * val_new_value(void)
Malloc and initialize the fields in a val_value_t.
Definition: val.c:2697
ncx_get_source
xmlChar * ncx_get_source(const xmlChar *fspec, status_t *res)
Expand a filespec into an absolute path.
Definition: ncx.c:8362
ncx.h
YANG module utility functions.
obj.h
Data Object Support.
TK_CUR_TYP
#define TK_CUR_TYP(T)
return the current token type
Definition: tk.h:125
val_init_from_template
void val_init_from_template(val_value_t *val, struct obj_template_t_ *obj)
Initialize a value node from its object template.
ncx_file_close
void ncx_file_close(FILE *fp)
Close a file; check result.
Definition: ncx.c:13235
ncx_find_module
ncx_module_t * ncx_find_module(const xmlChar *modname, const xmlChar *revision)
Find a ncx_module_t in the ncx_sesmodQ.
Definition: ncx.c:3227
ERR_FIL_OPEN
@ ERR_FIL_OPEN
system errors start at 100
Definition: status_enum.h:212
NCX_BT_STRING
@ NCX_BT_STRING
string
Definition: ncxtypes.h:217
val_set_simval
status_t val_set_simval(val_value_t *val, typ_def_t *typdef, xmlns_id_t nsid, const xmlChar *valname, const xmlChar *valstr)
set any simple value with any typdef Set an initialized val_value_t as a simple type
Definition: val.c:6836
val_free_value
void val_free_value(val_value_t *val)
Scrub the memory in a val_value_t by freeing all the sub-fields and then freeing the entire struct it...
Definition: val.c:2842
ncx_conf_env_vars_enabled
boolean ncx_conf_env_vars_enabled(void)
Get the Config Environment Variable Replacement flag.
Definition: ncx.c:15340
obj_is_root
boolean obj_is_root(const obj_template_t *obj)
Check if object is marked as a root object.
Definition: obj.c:14152
obj_get_iqualval
ncx_iqual_t obj_get_iqualval(obj_template_t *obj)
Get the instance qualifier for this object.
Definition: obj.c:12427
status.h
Global error messages for status code enumerations.
NCX_BT_NONE
@ NCX_BT_NONE
base type not set
Definition: ncxtypes.h:201
obj_get_nsid
xmlns_id_t obj_get_nsid(const obj_template_t *obj)
Get the namespace ID for this object.
Definition: obj.c:12395
dlq.h
dlq provides general double-linked list and queue support:
LOGDEBUG3
#define LOGDEBUG3
Check if at least log-level=debug3.
Definition: log.h:297
NCX_DEF_INDENT
#define NCX_DEF_INDENT
default indent amount for nesting XML or other structured output
Definition: ncxconst.h:441