yumapro  20.10-12
YumaPro SDK
typ_userdef.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 - 2021, YumaWorks, Inc., All Rights Reserved.
3  *
4  * Unless required by applicable law or agreed to in writing,
5  * software distributed under the License is distributed on an
6  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
7  * KIND, either express or implied. See the License for the
8  * specific language governing permissions and limitations
9  * under the License.
10  */
11 #ifndef _H_typ_userdef
12 #define _H_typ_userdef
13 
14 /* FILE: typ_userdef.h
15 *********************************************************************
16 * *
17 * P U R P O S E *
18 * *
19 *********************************************************************/
20 
31 /*********************************************************************
32 * *
33 * C H A N G E H I S T O R Y *
34 * *
35 *********************************************************************
36 
37 date init comment
38 ----------------------------------------------------------------------
39 07-apr-18 abb Begun
40 */
41 
42 // for XSD pattern: xmlRexexpPtr pattern
43 #include <xmlstring.h>
44 
45 #ifndef _H_status_enum
46 #include "status_enum.h"
47 #endif
48 
49 
50 #ifndef _H_val
51 #include "val.h"
52 #endif
53 
54 #ifndef _H_typ
55 #include "typ.h"
56 #endif
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 /********************************************************************
63 * *
64 * C O N S T A N T S *
65 * *
66 *********************************************************************/
67 
68 
69 
70 /********************************************************************
71 * *
72 * T Y P E S *
73 * *
74 *********************************************************************/
75 
101 typedef status_t
102  (*typ_validate_fn_t) (typ_def_t *typdef,
103  val_value_t *val,
104  void *cookie);
105 
106 
117 typedef status_t
118  (*typ_canonical_fn_t) (typ_def_t *typdef,
119  val_value_t *val,
120  void *cookie);
121 
122 
135 typedef status_t
136  (*typ_compare_fn_t) (const typ_def_t *typdef,
137  const val_value_t *val1,
138  const val_value_t *val2,
139  void *cookie,
140  int *retval);
141 
142 
146 typedef struct typ_userdef_t_ {
150  void *cookie;
151 } typ_userdef_t;
152 
153 
154 /********************************************************************
155 * *
156 * F U N C T I O N S *
157 * *
158 *********************************************************************/
159 
174 extern status_t
175  typ_userdef_register (const xmlChar *modname,
176  const xmlChar *typname,
177  typ_validate_fn_t validate_fn,
178  typ_canonical_fn_t canonical_fn,
179  typ_compare_fn_t compare_fn,
180  void *cookie);
181 
182 
188 extern void
189  typ_userdef_clean_typdef (typ_def_t *typdef);
190 
191 
199 extern status_t
200  typ_userdef_validate (val_value_t *val);
201 
202 
211 extern status_t
212  typ_userdef_canonical (val_value_t *val);
213 
214 
225 extern status_t
226  typ_userdef_compare (const val_value_t *val1,
227  const val_value_t *val2,
228  int32 *ret);
229 
233 #ifdef __cplusplus
234 } /* end extern 'C' */
235 #endif
236 
237 #endif /* _H_typ_userdef */
typ_userdef_t_::validate_fn
typ_validate_fn_t validate_fn
validate callback
Definition: typ_userdef.h:147
ERR_NCX_SKIPPED
@ ERR_NCX_SKIPPED
2001
Definition: status_enum.h:551
typ_userdef_t_::canonical_fn
typ_canonical_fn_t canonical_fn
canonical callback
Definition: typ_userdef.h:148
VAL_IS_CANONICAL
#define VAL_IS_CANONICAL(V)
check if the value is set by canonical
Definition: val.h:660
val_get_leafref_typdef
typ_def_t * val_get_leafref_typdef(val_value_t *val)
Return a base typedef of type NCX_BT_LEAFREF.
Definition: val.c:15237
typ_userdef_compare
status_t typ_userdef_compare(const val_value_t *val1, const val_value_t *val2, int32 *ret)
Invoke the compare callback function for a user defined type if it exists.
Definition: typ_userdef.c:303
ERR_NCX_DEF_NOT_FOUND
@ ERR_NCX_DEF_NOT_FOUND
250
Definition: status_enum.h:289
xpath_pcb_t_::val
val_value_t * val
saved state for the current() function result
Definition: xpath.h:757
val.h
Value Node Basic Support.
VAL_CLR_CANONICAL
#define VAL_CLR_CANONICAL(V)
clear the value as set by canonical
Definition: val.h:657
status_enum.h
global error status code enumerations
NCX_BT_LEAFREF
@ NCX_BT_LEAFREF
leafref (needs special processing)
Definition: ncxtypes.h:221
typ_userdef_t_::cookie
void * cookie
registration cookie
Definition: typ_userdef.h:150
ncx_find_type
typ_template_t * ncx_find_type(ncx_module_t *mod, const xmlChar *typname, boolean useall)
Check if a typ_template_t in the mod->typeQ.
Definition: ncx.c:3522
typ_userdef_canonical
status_t typ_userdef_canonical(val_value_t *val)
Invoke the canonical callback function for a user defined type if it exists.
Definition: typ_userdef.c:245
typ_userdef.h
User Defined Types.
VAL_NAME
#define VAL_NAME(V)
Access the value name.
Definition: val.h:399
ncxconst.h
Contains NCX constants.
typ_userdef_clean_typdef
void typ_userdef_clean_typdef(typ_def_t *typdef)
Clean the user typedef fields.
Definition: typ_userdef.c:180
VAL_TYPDEF
#define VAL_TYPDEF(V)
Access the typedef (simple types only)
Definition: val.h:393
typ_compare_fn_t
status_t(* typ_compare_fn_t)(const typ_def_t *typdef, const val_value_t *val1, const val_value_t *val2, void *cookie, int *retval)
userdef compare callback function compare 2 val_value_t nodes of the same user defined type
Definition: typ_userdef.h:136
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
ERR_NCX_MOD_NOT_FOUND
@ ERR_NCX_MOD_NOT_FOUND
236
Definition: status_enum.h:275
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.
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
typ.h
Parameter Type Handler.
VAL_SET_CANONICAL
#define VAL_SET_CANONICAL(V)
flag the value as set by canonical
Definition: val.h:654
LOGDEBUG4
#define LOGDEBUG4
Check if at least log-level=debug4.
Definition: log.h:302
typ_userdef_validate
status_t typ_userdef_validate(val_value_t *val)
Invoke the validate callback function for a user defined type if it exists.
Definition: typ_userdef.c:202
xpath_pcb_t_::cookie
void * cookie
The cookie registered with the getvar_fn.
Definition: xpath.h:799
typ_canonical_fn_t
status_t(* typ_canonical_fn_t)(typ_def_t *typdef, val_value_t *val, void *cookie)
userdef canonical callback function convert the inval to the canonical format for the type
Definition: typ_userdef.h:118
typ_userdef_register
status_t typ_userdef_register(const xmlChar *modname, const xmlChar *typname, typ_validate_fn_t validate_fn, typ_canonical_fn_t canonical_fn, typ_compare_fn_t compare_fn, void *cookie)
Register the callback functions for a user defined type.
Definition: typ_userdef.c:118
VAL_TYPE
#define VAL_TYPE(V)
Access the base type : same as VAL_BTYPE.
Definition: val.h:387
ncx.h
YANG module utility functions.
typ_validate_fn_t
status_t(* typ_validate_fn_t)(typ_def_t *typdef, val_value_t *val, void *cookie)
userdef validate callback function user validation callback for a userdef type
Definition: typ_userdef.h:102
typ_get_userdef_typdef
typ_def_t * typ_get_userdef_typdef(typ_def_t *typdef)
Get the base typ_def_t in a chain – for NCX_CL_NAMED chained typed.
Definition: typ.c:2265
typ_get_cuserdef_typdef
const typ_def_t * typ_get_cuserdef_typdef(const typ_def_t *typdef)
Get the base typ_def_t in a chain – for NCX_CL_NAMED chained typed.
Definition: typ.c:2311
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
typ_userdef_t_::compare_fn
typ_compare_fn_t compare_fn
compare callback
Definition: typ_userdef.h:149
typ_userdef_t_
one userdef control block The CB will exist if one or more callbacks are registered
Definition: typ_userdef.h:146
dlq.h
dlq provides general double-linked list and queue support: