yumapro  20.10-12
YumaPro SDK
yang_feature.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_yang_feature
13 #define _H_yang_feature
14 
15 /* FILE: yang_feature.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 20-nov-15 abb Begun; start from yang_obj.c
37 
38 */
39 
40 #ifndef _H_dlq
41 #include "dlq.h"
42 #endif
43 
44 #ifndef _H_grp
45 #include "grp.h"
46 #endif
47 
48 #ifndef _H_ncxtypes
49 #include "ncxtypes.h"
50 #endif
51 
52 #ifndef _H_obj
53 #include "obj.h"
54 #endif
55 
56 #ifndef _H_status
57 #include "status.h"
58 #endif
59 
60 #ifndef _H_tk
61 #include "tk.h"
62 #endif
63 
64 #ifndef _H_yang
65 #include "yang.h"
66 #endif
67 
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 
72 /********************************************************************
73 * *
74 * T Y P E S *
75 * *
76 *********************************************************************/
77 
78 
79 /********************************************************************
80 * *
81 * F U N C T I O N S *
82 * *
83 *********************************************************************/
84 
85 /* Group definied in ncx_feature.h */
86 
87 
118 extern status_t
119  yang_feature_consume_iffeature (tk_chain_t *tkc,
120  ncx_module_t *mod,
121  dlq_hdr_t *iffeatureQ,
122  dlq_hdr_t *appinfoQ);
123 
124 
125 
141 extern status_t
142  yang_feature_consume_feature (tk_chain_t *tkc,
143  ncx_module_t *mod);
144 
145 
159 extern status_t
160  yang_feature_resolve_feature (yang_pcb_t *pcb,
161  tk_chain_t *tkc,
162  ncx_module_t *mod,
163  ncx_feature_t *feature);
164 
165 
183 extern status_t
184  yang_feature_check_feature_loop (tk_chain_t *tkc,
185  ncx_module_t *mod,
186  ncx_feature_t *feature,
187  ncx_feature_t *startfeature);
188 
189 
202 extern status_t
203  yang_feature_resolve_iffeatureQ (yang_pcb_t *pcb,
204  tk_chain_t *tkc,
205  ncx_module_t *mod,
206  obj_template_t *obj);
207 
208 
223 extern status_t
224  yang_feature_resolve_iffeatureQ2 (yang_pcb_t *pcb,
225  tk_chain_t *tkc,
226  ncx_module_t *mod,
227  dlq_hdr_t *iffeatureQ);
228 
229 
245 extern status_t
246  yang_feature_check_iffeature_mismatch (tk_chain_t *tkc,
247  ncx_module_t *mod,
248  obj_template_t *ancestor,
249  obj_template_t *testobj,
250  ncx_iffeature_t *iff,
251  boolean iserror);
252 
253 
262 extern boolean
263  yang_feature_eval_iffeature (ncx_module_t *mod,
264  ncx_iffeature_t *iff);
265 
266 
275 extern boolean
276  yang_feature_eval_iffeatureQ (ncx_module_t *mod,
277  dlq_hdr_t *iffQ);
278 
279 
283 #ifdef __cplusplus
284 } /* end extern 'C' */
285 #endif
286 
287 
288 #endif /* _H_yang_feature */
yang_feature_eval_iffeature
boolean yang_feature_eval_iffeature(ncx_module_t *mod, ncx_iffeature_t *iff)
Evaluate the if-feature expression.
Definition: yang_feature.c:1649
TK_CUR
#define TK_CUR(T)
return the current token
Definition: tk.h:122
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
ncx_feature.h
NCX Module Library YANG Feature Utility Functions.
ncx_consume_appinfo
status_t ncx_consume_appinfo(tk_chain_t *tkc, ncx_module_t *mod, dlq_hdr_t *appinfoQ)
Check if an appinfo clause is present.
Definition: ncx_appinfo.c:761
ncx_appinfo.h
NCX Module Library Extension (Application Info) Utility Functions.
tk_get_token_name
const char * tk_get_token_name(tk_type_t ttyp)
Get the symbolic token name.
Definition: tk.c:3280
tk_new_chain
tk_chain_t * tk_new_chain(void)
Allocatate a new token parse chain.
Definition: tk.c:2919
ncx_new_feature
ncx_feature_t * ncx_new_feature(void)
Get a new ncx_feature_t struct.
Definition: ncx_feature.c:789
ncx_warning_enabled
boolean ncx_warning_enabled(status_t res)
Check if a specific status_t code is enabled.
Definition: ncx.c:9394
ERR_NCX_WRONG_TKVAL
@ ERR_NCX_WRONG_TKVAL
246
Definition: status_enum.h:285
yang_feature_check_feature_loop
status_t yang_feature_check_feature_loop(tk_chain_t *tkc, ncx_module_t *mod, ncx_feature_t *feature, ncx_feature_t *startfeature)
Check for a feature loop.
Definition: yang_feature.c:1410
ncx_find_feature_all
ncx_feature_t * ncx_find_feature_all(ncx_module_t *mod, const xmlChar *name)
Find a ncx_feature_t struct in the module and perhaps any of its submodules.
Definition: ncx_feature.c:983
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.
yang_feature.h
YANG feature statement support.
tk_next_val
const xmlChar * tk_next_val(tk_chain_t *tkc)
Get the token type of the next token.
Definition: tk.c:3464
xml_util.h
XML Utilities.
TK_CUR_LNUM
#define TK_CUR_LNUM(T)
return the current line number
Definition: tk.h:179
tk.h
NCX Syntax Token Handler.
log_debug3
void void void void void void void void void void void log_debug3(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG3 log entry.
tk_dump_chain
void tk_dump_chain(const tk_chain_t *tkc)
Debug printf the token chain !!! Very verbose !!!
Definition: tk.c:3532
ncx_set_feature_parms
void ncx_set_feature_parms(ncx_feature_t *feature)
Check if any feature parameters were set for the specified feature struct.
Definition: ncx_feature.c:1526
yang_feature_resolve_iffeatureQ
status_t yang_feature_resolve_iffeatureQ(yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod, obj_template_t *obj)
Check the Q of if-feature statements for the specified object.
Definition: yang_feature.c:1479
yang_skip_statement
void yang_skip_statement(tk_chain_t *tkc, ncx_module_t *mod)
Skip past the current invalid statement, starting at an invalid keyword.
Definition: yang.c:3421
yang_new_feature_stmt
yang_stmt_t * yang_new_feature_stmt(ncx_feature_t *feature)
Create a new YANG stmt node for a feature definition.
Definition: yang.c:3131
ERR_NCX_DUP_ENTRY
@ ERR_NCX_DUP_ENTRY
224
Definition: status_enum.h:263
ncxconst.h
Contains NCX constants.
ncx_new_iff_ref
ncx_iff_ref_t * ncx_new_iff_ref(const xmlChar *prefix, uint32 prefix_len, const xmlChar *featname)
Get a new ncx_iff_ref_t struct.
Definition: ncx_feature.c:515
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
yang_consume_string
status_t yang_consume_string(tk_chain_t *tkc, ncx_module_t *mod, xmlChar **field)
consume 1 string token
Definition: yang.c:227
TK_CUR_VAL
#define TK_CUR_VAL(T)
return the current token value
Definition: tk.h:128
TK_CUR_LPOS
#define TK_CUR_LPOS(T)
return the current line position
Definition: tk.h:182
ERR_NCX_DUP_IF_FEATURE
@ ERR_NCX_DUP_IF_FEATURE
1026
Definition: status_enum.h:515
ncx_warning_elevated
boolean ncx_warning_elevated(status_t res)
Check if a specific status_t code is elevated.
Definition: ncx.c:9439
xpath1.h
XPath 1.0 expression support.
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
xpath.h
Schema and data model Xpath search support.
TK_TT_RBRACE
@ TK_TT_RBRACE
right brace '}'
Definition: tk.h:287
TK_TT_LPAREN
@ TK_TT_LPAREN
left paren '('
Definition: tk.h:289
ncx_get_yang_version
ncx_yang_version_t ncx_get_yang_version(const ncx_module_t *mod)
Get the yang-version used in the module.
Definition: ncx.c:12937
ERR_NCX_WRONG_TKTYPE
@ ERR_NCX_WRONG_TKTYPE
245
Definition: status_enum.h:284
yang_feature_eval_iffeatureQ
boolean yang_feature_eval_iffeatureQ(ncx_module_t *mod, dlq_hdr_t *iffQ)
Evaluate a Q ofif-feature expressions.
Definition: yang_feature.c:1697
TK_CUR_MOD
#define TK_CUR_MOD(T)
return the current token module qualifier value
Definition: tk.h:134
log_debug4
void void void void void void void void void void void void void log_debug4(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG4 log entry.
obj_get_name
const xmlChar * obj_get_name(const obj_template_t *obj)
Get the name field for this obj.
Definition: obj.c:10511
log_warn
void void void log_warn(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_WARN log entry.
ERR_INTERNAL_VAL
@ ERR_INTERNAL_VAL
004
Definition: status_enum.h:194
set_tkc_error
status_t set_tkc_error(tk_chain_t *tkc, ncx_module_t *mod, ncx_error_t *err, status_t res)
utility function for setting and reporting tkc errors.
Definition: yang_obj.c:12565
ERR_NCX_INVALID_VALUE
@ ERR_NCX_INVALID_VALUE
258
Definition: status_enum.h:299
ncx_free_feature
void ncx_free_feature(ncx_feature_t *feature)
Free a malloced ncx_feature_t struct.
Definition: ncx_feature.c:823
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
tk_setup_chain_feature
void tk_setup_chain_feature(tk_chain_t *tkc, xmlChar *str)
Setup a previously allocated chain for 'if-feature' YANG 1.1.
Definition: tk.c:3021
yang.h
YANG Module parser utilities.
ncx_module_t_::prefix
xmlChar * prefix
module prefix
Definition: ncxtypes.h:927
ncx_new_iffeature
ncx_iffeature_t * ncx_new_iffeature(void)
Get a new ncx_iffeature_t struct.
Definition: ncx_feature.c:455
ncx_module_t_::langver
ncx_yang_version_t langver
YANG lang.
Definition: ncxtypes.h:939
typ.h
Parameter Type Handler.
yangconst.h
Contains YANG constants separated to prevent H file include loops.
ncx_find_feature
ncx_feature_t * ncx_find_feature(ncx_module_t *mod, const xmlChar *name)
Find a ncx_feature_t struct in the module and perhaps any of its submodules.
Definition: ncx_feature.c:855
TK_CUR_MODLEN
#define TK_CUR_MODLEN(T)
return the current token module qualifier value length
Definition: tk.h:137
yang_consume_descr
status_t yang_consume_descr(tk_chain_t *tkc, ncx_module_t *mod, xmlChar **str, boolean *dupflag, dlq_hdr_t *appinfoQ)
consume one descriptive string clause
Definition: yang.c:888
ERR_NCX_EOF
@ ERR_NCX_EOF
244
Definition: status_enum.h:283
dlq_nextEntry
#define dlq_nextEntry(nodeP)
get the next queue entry after the current entry
Definition: dlq.h:265
TK_TT_RPAREN
@ TK_TT_RPAREN
right paren ')'
Definition: tk.h:290
tk_reset_chain
void tk_reset_chain(tk_chain_t *tkc)
Reset the token chain current pointer to the start.
Definition: tk.c:4042
TK_TT_SEMICOL
@ TK_TT_SEMICOL
semi-colon ';'
Definition: tk.h:288
yang_consume_pid_string
status_t yang_consume_pid_string(tk_chain_t *tkc, ncx_module_t *mod, xmlChar **prefix, xmlChar **field)
consume an identifier-ref-str token
Definition: yang.c:581
ncx_set_error
void ncx_set_error(ncx_error_t *tkerr, ncx_module_t *mod, uint32 linenum, uint32 linepos)
Set the fields in an ncx_error_t struct.
Definition: ncx.c:9746
xpath_yang.h
YANG-specific Xpath support.
ERR_NCX_OPERATION_NOT_SUPPORTED
@ ERR_NCX_OPERATION_NOT_SUPPORTED
273
Definition: status_enum.h:314
log_debug4_append
void void void void void void void void void void void void void void log_debug4_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_DEBUG4 log entry.
ncx_module_t_::ref
xmlChar * ref
reference-stmt (not saved on server)
Definition: ncxtypes.h:921
ncx_module_t_::appinfoQ
dlq_hdr_t appinfoQ
Q of ncx_appinfo_t.
Definition: ncxtypes.h:963
EMPTY_STRING
#define EMPTY_STRING
empty string used to get const xmlChar * cast
Definition: ncxconst.h:289
ncx_module_t_::name
xmlChar * name
module name
Definition: ncxtypes.h:902
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
ERR_NCX_INVALID_CONDITIONAL
@ ERR_NCX_INVALID_CONDITIONAL
343
Definition: status_enum.h:386
LOGDEBUG4
#define LOGDEBUG4
Check if at least log-level=debug4.
Definition: log.h:302
log.h
NCX System Logging Manager.
yang_find_imp_feature
status_t yang_find_imp_feature(yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod, const xmlChar *prefix, const xmlChar *name, ncx_error_t *tkerr, ncx_feature_t **feature)
Find the specified imported feature.
Definition: yang.c:2330
ncxtypes.h
YANG module data structures Many internal representations of YANG module constructs.
ERR_NCX_UNIQUE_CONDITIONAL_MISMATCH
@ ERR_NCX_UNIQUE_CONDITIONAL_MISMATCH
1050
Definition: status_enum.h:539
ncx_feature_enabled
boolean ncx_feature_enabled(ncx_feature_t *feature)
Check if the specified feature and any referenced if-features are enabled.
Definition: ncx_feature.c:1181
yang_consume_id_string
status_t yang_consume_id_string(tk_chain_t *tkc, ncx_module_t *mod, xmlChar **field)
consume an identifier-str token
Definition: yang.c:510
ncx_first_feature_from_iff
ncx_feature_t * ncx_first_feature_from_iff(ncx_iffeature_t *iff)
Get the feature in the first ncx_iff_ref_t struct.
Definition: ncx_feature.c:1596
yang_feature_consume_iffeature
status_t yang_feature_consume_iffeature(tk_chain_t *tkc, ncx_module_t *mod, dlq_hdr_t *iffeatureQ, dlq_hdr_t *appinfoQ)
Consume an if-feature-stmt.
Definition: yang_feature.c:1311
ncx_list.h
NCX Module Library List Utility Functions.
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
yang_consume_semiapp
status_t yang_consume_semiapp(tk_chain_t *tkc, ncx_module_t *mod, dlq_hdr_t *appinfoQ)
consume a stmtsep clause
Definition: yang.c:145
dlq_firstEntry
#define dlq_firstEntry(listP)
get the first entry in the queue list
Definition: dlq.h:337
ncx_mod_exp_err
void ncx_mod_exp_err(tk_chain_t *tkc, ncx_module_t *mod, status_t result, const char *expstr)
Print an error for wrong token, expected a different token.
Definition: ncx.c:7220
ncx.h
YANG module utility functions.
yang_feature_resolve_feature
status_t yang_feature_resolve_feature(yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod, ncx_feature_t *feature)
Validate all the if-feature clauses present in the specified feature.
Definition: yang_feature.c:1359
ncx_find_iff_ref
ncx_iff_ref_t * ncx_find_iff_ref(dlq_hdr_t *iff_refQ, const xmlChar *prefix, uint32 prefix_len, const xmlChar *featname)
Find a ncx_iff_ref_t struct.
Definition: ncx_feature.c:562
obj.h
Data Object Support.
TK_CUR_TYP
#define TK_CUR_TYP(T)
return the current token type
Definition: tk.h:125
yang_obj.h
YANG Module parser support for data-def-stmt.
ERR_NCX_DEF_LOOP
@ ERR_NCX_DEF_LOOP
325
Definition: status_enum.h:368
grp.h
YANG Grouping Statement Handler.
yang_feature_check_iffeature_mismatch
status_t yang_feature_check_iffeature_mismatch(tk_chain_t *tkc, ncx_module_t *mod, obj_template_t *ancestor, obj_template_t *testobj, ncx_iffeature_t *iff, boolean iserror)
Check the child object against the ancestor node for 1 if-feature.
Definition: yang_feature.c:1581
dlq_enque
void dlq_enque(REG void *newP, REG dlq_hdrT *listP)
add a queue node to the end of a queue list Add newP to listP
Definition: dlq.c:246
yang_consume_status
status_t yang_consume_status(tk_chain_t *tkc, ncx_module_t *mod, ncx_status_t *status, boolean *dupflag, dlq_hdr_t *appinfoQ)
consume one status clause
Definition: yang.c:1115
ncx_find_iffeature
ncx_iffeature_t * ncx_find_iffeature(dlq_hdr_t *iffeatureQ, const xmlChar *prefix, const xmlChar *name, const xmlChar *modprefix)
Search a Q of ncx_iffeature_t structs for a match.
Definition: ncx_feature.c:745
SET_ERROR
#define SET_ERROR(E)
macro SET_ERROR
Definition: status_enum.h:103
NEED_EXIT
#define NEED_EXIT(res)
used in parser routines to decide if processing can continue does not return, just evaluates to TRUE ...
Definition: yangconst.h:234
yang_feature_consume_feature
status_t yang_feature_consume_feature(tk_chain_t *tkc, ncx_module_t *mod)
Parse the next N tokens as a feature statement.
Definition: yang_feature.c:1114
obj_get_typestr
const xmlChar * obj_get_typestr(const obj_template_t *obj)
Get the name of the object type.
Definition: obj.c:11392
TK_TT_MSTRING
@ TK_TT_MSTRING
module-qualified token string
Definition: tk.h:320
status.h
Global error messages for status code enumerations.
yang_feature_resolve_iffeatureQ2
status_t yang_feature_resolve_iffeatureQ2(yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod, dlq_hdr_t *iffeatureQ)
Check the Q of if-feature statements for the specified object.
Definition: yang_feature.c:1519
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