yumapro  20.10-12
YumaPro SDK
ext.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_ext
13 #define _H_ext
14 
15 /* FILE: ext.h
16 *********************************************************************
17 * *
18 * P U R P O S E *
19 * *
20 *********************************************************************/
21 
27 /*********************************************************************
28 * *
29 * C H A N G E H I S T O R Y *
30 * *
31 *********************************************************************
32 
33 date init comment
34 ----------------------------------------------------------------------
35 05-jan-08 abb Begun
36 
37 */
38 
39 #include <xmlstring.h>
40 #include <xmlregexp.h>
41 
42 #ifndef _H_ncxconst
43 #include "ncxconst.h"
44 #endif
45 
46 #ifndef _H_ncxtypes
47 #include "ncxtypes.h"
48 #endif
49 
50 #ifndef _H_status
51 #include "status.h"
52 #endif
53 
54 #ifndef _H_tk
55 #include "tk.h"
56 #endif
57 
58 #ifndef _H_xmlns
59 #include "xmlns.h"
60 #endif
61 
62 
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66 
67 /********************************************************************
68 * *
69 * C O N S T A N T S *
70 * *
71 *********************************************************************/
72 
73 #define EXT_CBFN_COOKIE(E) (E)->cbfn_cookie
74 
75 /********************************************************************
76 * *
77 * T Y P E S *
78 * *
79 *********************************************************************/
80 
81 
82 
118 typedef status_t (*ext_cbfn_t)
119  (void *rawpcb, // struct yang_pcb_t_ *pcb
120  ncx_module_t *mod,
121  tk_chain_t *tkc,
122  struct ext_template_t_ *ext,
123  void *cookie,
124  const xmlChar *arg,
125  ncx_node_t node_type,
126  void *node);
127 
128 
130 typedef struct ext_template_t_ {
131  dlq_hdr_t qhdr;
132  xmlChar *name;
133  xmlChar *descr;
134  xmlChar *ref;
135  xmlChar *arg;
137  ncx_status_t status;
138  boolean argel;
139  boolean used;
140  dlq_hdr_t appinfoQ;
141  ncx_error_t tkerr;
143  void *cbfn_cookie;
144 } ext_template_t;
145 
146 
147 /********************************************************************
148 * *
149 * F U N C T I O N S *
150 * *
151 *********************************************************************/
152 
153 
159 extern ext_template_t *
160  ext_new_template (void);
161 
162 
172 extern void
173  ext_free_template (ext_template_t *ext);
174 
175 
181 extern void
182  ext_clean_extensionQ (dlq_hdr_t *que);
183 
184 
193 extern ext_template_t *
194  ext_find_extension (ncx_module_t *mod,
195  const xmlChar *name);
196 
197 
205 extern ext_template_t *
206  ext_find_extension_que (dlq_hdr_t *extensionQ,
207  const xmlChar *name);
208 
209 
218 extern ext_template_t *
219  ext_find_extension_all (ncx_module_t *mod,
220  const xmlChar *name);
221 
222 
227 extern void
228  ext_init (void);
229 
234 extern void
235  ext_cleanup (void);
236 
237 
251 extern status_t
252  ext_register_cbfn (const xmlChar *modname,
253  const xmlChar *extname,
254  ext_cbfn_t cbfn,
255  void *cbfn_cookie);
256 
257 
266 extern void
267  ext_find_cbfn (const xmlChar *modname,
268  const xmlChar *extname,
269  ext_template_t *ext);
270 
271 
274 #ifdef __cplusplus
275 } /* end extern 'C' */
276 #endif
277 
278 #endif /* _H_ext */
ncx_appinfo.h
NCX Module Library Extension (Application Info) Utility Functions.
xml_strdup
xmlChar * xml_strdup(const xmlChar *copyFrom)
String duplicate for xmlChar.
Definition: xml_util.c:1553
ext_template_t_::descr
xmlChar * descr
malloced description-stmt
Definition: ext.h:133
ext_find_extension_que
ext_template_t * ext_find_extension_que(dlq_hdr_t *extensionQ, const xmlChar *name)
Find an ext_template_t struct in the specified Q.
Definition: ext.c:331
ncx_clean_appinfoQ
void ncx_clean_appinfoQ(dlq_hdr_t *appinfoQ)
Check an initialized appinfoQ for any entries Remove them from the queue and delete them.
Definition: ncx_appinfo.c:723
tk.h
NCX Syntax Token Handler.
ext_find_cbfn
void ext_find_cbfn(const xmlChar *modname, const xmlChar *extname, ext_template_t *ext)
Find the registered callback for the specified extension Set the callback handler if found.
Definition: ext.c:517
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.
ext_template_t_::name
xmlChar * name
malloced name
Definition: ext.h:132
ext_clean_extensionQ
void ext_clean_extensionQ(dlq_hdr_t *que)
Clean a queue of ext_template_t structs.
Definition: ext.c:200
ext_template_t_::argel
boolean argel
T:arg is an element, F: attribute.
Definition: ext.h:138
ext_init
void ext_init(void)
Init the extension callback handler queue.
Definition: ext.c:419
ncxconst.h
Contains NCX constants.
xmlns_id_t
uint16 xmlns_id_t
integer handle for registered namespaces
Definition: xmlns.h:89
def_reg.h
Definition Registry module.
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
ext_template_t_::arg
xmlChar * arg
malloced argument name
Definition: ext.h:135
ext_template_t_::appinfoQ
dlq_hdr_t appinfoQ
Q of ncx_appinfo_t.
Definition: ext.h:140
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
ncx_get_allincQ
dlq_hdr_t * ncx_get_allincQ(ncx_module_t *mod)
Find the correct Q of yang_node_t for all include files that have the same 'belongs-to' value.
Definition: ncx.c:9945
dlq_createSQue
void dlq_createSQue(dlq_hdrT *queAddr)
create a static queue header
Definition: dlq.c:177
ext_new_template
ext_template_t * ext_new_template(void)
Malloc and initialize the fields in a ext_template_t.
Definition: ext.c:134
ext_cbfn_t
status_t(* ext_cbfn_t)(void *rawpcb, ncx_module_t *mod, tk_chain_t *tkc, struct ext_template_t_ *ext, void *cookie, const xmlChar *arg, ncx_node_t node_type, void *node)
One YANG Extension Handler Callback.
Definition: ext.h:119
ext_template_t_::status
ncx_status_t status
status of parse
Definition: ext.h:137
ext_template_t_::used
boolean used
needed by yangdiff
Definition: ext.h:139
ext_register_cbfn
status_t ext_register_cbfn(const xmlChar *modname, const xmlChar *extname, ext_cbfn_t cbfn, void *cbfn_cookie)
Register a callback function for the specified extension If multiple callbacks for same extension,...
Definition: ext.c:467
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
ERR_INTERNAL_INIT_SEQ
@ ERR_INTERNAL_INIT_SEQ
007
Definition: status_enum.h:197
ERR_INTERNAL_PTR
@ ERR_INTERNAL_PTR
002
Definition: status_enum.h:192
typ.h
Parameter Type Handler.
NCX_STATUS_CURRENT
@ NCX_STATUS_CURRENT
current (default)
Definition: ncxtypes.h:420
dlq_nextEntry
#define dlq_nextEntry(nodeP)
get the next queue entry after the current entry
Definition: dlq.h:265
yang_find_node
yang_node_t * yang_find_node(const dlq_hdr_t *que, const xmlChar *name, const xmlChar *revision)
Find a YANG parser node in the specified Q.
Definition: yang.c:2778
ext_find_extension
ext_template_t * ext_find_extension(ncx_module_t *mod, const xmlChar *name)
Search a module for an ext_template_t structs with a given name Search mod to find extension name.
Definition: ext.c:232
xml_strcmp
int xml_strcmp(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar.
Definition: xml_util.c:1746
ext_cleanup
void ext_cleanup(void)
Cleanup the extension callback handler queue.
Definition: ext.c:436
ncxtypes.h
YANG module data structures Many internal representations of YANG module constructs.
ext_template_t_
One YANG 'extension' definition – language extension template.
Definition: ext.h:130
ext_find_extension_all
ext_template_t * ext_find_extension_all(ncx_module_t *mod, const xmlChar *name)
Search a module of ext_template_t structs for a given name Check all submodules as well.
Definition: ext.c:370
ext_template_t_::cbfn
ext_cbfn_t cbfn
callback function
Definition: ext.h:142
dlq_deque
void * dlq_deque(dlq_hdrT *listP)
remove the first queue node from the queue list
Definition: dlq.c:286
dlq_empty
#define dlq_empty(listP)
check if queue list is empty
Definition: dlq.h:367
ext_template_t_::tkerr
ncx_error_t tkerr
file and line infor for compiler
Definition: ext.h:141
dlq_firstEntry
#define dlq_firstEntry(listP)
get the first entry in the queue list
Definition: dlq.h:337
ncx.h
YANG module utility functions.
ext_template_t_::qhdr
dlq_hdr_t qhdr
queue header
Definition: ext.h:131
obj.h
Data Object Support.
grp.h
YANG Grouping Statement Handler.
ext_free_template
void ext_free_template(ext_template_t *ext)
Scrub the memory in a ext_template_t by freeing all the sub-fields and then freeing the entire struct...
Definition: ext.c:162
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
SET_ERROR
#define SET_ERROR(E)
macro SET_ERROR
Definition: status_enum.h:103
xmlns.h
XML namespace support.
ncx_get_parent_mod
ncx_module_t * ncx_get_parent_mod(ncx_module_t *mod)
Find the correct module by checking mod->parent nodes.
Definition: ncx.c:9995
status.h
Global error messages for status code enumerations.
ext_template_t_::cbfn_cookie
void * cbfn_cookie
managed by callback
Definition: ext.h:143
dlq.h
dlq provides general double-linked list and queue support:
ext_template_t_::nsid
xmlns_id_t nsid
namespace ID
Definition: ext.h:136
ext.h
YANG Extension Handler.
LOGDEBUG3
#define LOGDEBUG3
Check if at least log-level=debug3.
Definition: log.h:297
ext_template_t_::ref
xmlChar * ref
malloced reference-stmt
Definition: ext.h:134