yumapro  23.10T-9
YumaPro SDK
Loading...
Searching...
No Matches
xmlns.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_xmlns
13#define _H_xmlns
14/* FILE: xmlns.h
15*********************************************************************
16* *
17* P U R P O S E *
18* *
19*********************************************************************/
20
30/*********************************************************************
31* *
32* C H A N G E H I S T O R Y *
33* *
34*********************************************************************
35
36date init comment
37----------------------------------------------------------------------
3830-apr-05 abb Begun.
39*/
40
41#include <xmlstring.h>
42
43#ifndef _H_dlq
44#include "dlq.h"
45#endif
46
47#ifndef _H_status
48#include "status.h"
49#endif
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
55/********************************************************************
56* *
57* C O N S T A N T S *
58* *
59*********************************************************************/
60
61#define XMLNS_NULL_NS_ID 0
62
63#define XMLNS ((const xmlChar *)"xmlns")
64#define XMLNS_LEN 5
65
66#define XMLNS_SEPCH ':'
67
68/* only compare if both elements have namespaces specified
69 * If either one is 'no namespace', then it is considered a match
70 */
71#define XMLNS_EQ(NS1,NS2) (((NS1) && (NS2)) && ((NS1)==(NS2)))
72
73/********************************************************************
74* *
75* T Y P E S *
76* *
77*********************************************************************/
78
79
89typedef uint16 xmlns_id_t;
90
91
93typedef struct xmlns_qname_t_ {
95 const xmlChar *name;
97
99typedef struct xmlns_t_ {
102
104 xmlChar *ns_pfix;
105
107 xmlChar *ns_name;
108
110 xmlChar *ns_module;
111
113 struct ncx_module_t_ *ns_mod;
114
119
123 boolean ns_deleted;
124
129 boolean ns_mod_dup;
130} xmlns_t;
131
132
134typedef struct xmlns_pmap_t_ {
136 dlq_hdr_t qhdr;
137
140
142 xmlChar *nm_pfix;
143
145 boolean nm_topattr;
147
148
149/********************************************************************
150* *
151* F U N C T I O N S *
152* *
153*********************************************************************/
154
155
160extern void
161 xmlns_init (void);
162
163
168extern void
169 xmlns_cleanup (void);
170
171
187extern status_t
188 xmlns_register_ns (const xmlChar *ns,
189 const xmlChar *pfix,
190 const xmlChar *modname,
191 void *modptr,
192 xmlns_id_t *ns_id);
193
194
200extern void
202
203
213extern status_t
214 xmlns_register_temp_ns (const xmlChar *ns,
215 const xmlChar *pfix,
216 xmlns_id_t *ns_id);
217
218
229extern status_t
231 const xmlChar *pfix,
232 const xmlChar *modname,
233 void *modptr);
234
235
242extern const xmlChar *
244
245
252extern const xmlChar *
254
255
262extern xmlns_id_t
263 xmlns_find_ns_by_module (const xmlChar *modname);
264
265
273extern xmlns_id_t
274 xmlns_find_ns_by_module_str (const xmlChar *modname,
275 uint32 len);
276
277
284extern xmlns_id_t
285 xmlns_find_ns_by_prefix (const xmlChar *pfix);
286
287
294extern xmlns_id_t
295 xmlns_find_ns_by_name (const xmlChar *name);
296
297
305extern xmlns_id_t
306 xmlns_find_ns_by_name_str (const xmlChar *name,
307 uint32 namelen);
308
309
315extern xmlns_id_t
316 xmlns_nc_id (void);
317
318
324extern xmlns_id_t
325 xmlns_ncx_id (void);
326
327
333extern xmlns_id_t
334 xmlns_ns_id (void);
335
336
342extern xmlns_id_t
343 xmlns_inv_id (void);
344
345
351extern xmlns_id_t
352 xmlns_xs_id (void);
353
354
360extern xmlns_id_t
361 xmlns_xsi_id (void);
362
363
369extern xmlns_id_t
370 xmlns_xml_id (void);
371
372
379extern xmlns_id_t
380 xmlns_ncn_id (void);
381
382
389extern xmlns_id_t
390 xmlns_yang_id (void);
391
392
399extern xmlns_id_t
400 xmlns_yin_id (void);
401
402
409extern xmlns_id_t
410 xmlns_wildcard_id (void);
411
412
419extern xmlns_id_t
420 xmlns_wda_id (void);
421
422
429extern xmlns_id_t
430 xmlns_ywattrs_id (void);
431
432
439extern xmlns_id_t
440 xmlns_origin_id (void);
441
442
451extern const xmlChar *
453
454
461extern void *
463
464
471extern void
472 xmlns_set_modptrs (const xmlChar *modname,
473 void *modptr);
474
475
481extern void
482 xmlns_clear_modptrs (void *modptr);
483
484
492extern xmlns_pmap_t *
493 xmlns_new_pmap (uint32 buffsize);
494
495
501extern void
503
504
510extern xmlns_qname_t *
511 xmlns_new_qname (void);
512
513
519extern void
521
522
532extern boolean
534 xmlns_id_t ns2);
535
540extern void
542
543
552extern uint16
553 xmlns_get_mod_count (void);
554
555
559#ifdef __cplusplus
560} /* end extern 'C' */
561#endif
562
563#endif /* _H_xmlns */
dlq provides general double-linked list and queue support:
status_t
global error return code
Definition: status_enum.h:210
xmlns_id_t xmlns_ywattrs_id(void)
Get the ID for the YumaWorks attributes namespace or 0 if it doesn't exist.
Definition: xmlns.c:1117
uint16 xmlns_get_mod_count(void)
Get the total count of the currently loaded modules in the array of the Namespaces.
Definition: xmlns.c:1463
void xmlns_free_qname(xmlns_qname_t *qname)
free a xmlns_qname_t struct
Definition: xmlns.c:1378
void xmlns_init(void)
Initialize the module static variables.
Definition: xmlns.c:435
status_t xmlns_convert_temp_ns(xmlns_id_t nsid, const xmlChar *pfix, const xmlChar *modname, void *modptr)
Register the specified permanent namespace by converting the specified temporary NSID to a permanent ...
Definition: xmlns.c:591
xmlns_id_t xmlns_xsi_id(void)
Get the ID for the XSD Instance (XSI) namespace or 0 if it doesn't exist.
Definition: xmlns.c:991
const xmlChar * xmlns_get_module(xmlns_id_t nsid)
get the module name of the namespace ID
Definition: xmlns.c:1153
void xmlns_set_modptrs(const xmlChar *modname, void *modptr)
get the module pointer for the namespace ID
Definition: xmlns.c:1223
void xmlns_unregister_ns(xmlns_id_t ns_id)
Unregister the specified namespace.
Definition: xmlns.c:521
xmlns_id_t xmlns_xml_id(void)
Get the ID for the 1998 XML namespace or 0 if it doesn't exist.
Definition: xmlns.c:1008
status_t xmlns_register_ns(const xmlChar *ns, const xmlChar *pfix, const xmlChar *modname, void *modptr, xmlns_id_t *ns_id)
Register the specified namespace.
Definition: xmlns.c:492
xmlns_id_t xmlns_ns_id(void)
Get the ID for the XMLNS namespace or 0 if it doesn't exist.
Definition: xmlns.c:941
xmlns_id_t xmlns_find_ns_by_prefix(const xmlChar *pfix)
Find the NS ID from its prefix.
Definition: xmlns.c:790
const xmlChar * xmlns_get_ns_name(xmlns_id_t ns_id)
Get the name for the specified namespace.
Definition: xmlns.c:684
void * xmlns_get_modptr(xmlns_id_t nsid)
get the module pointer for the namespace ID
Definition: xmlns.c:1186
void xmlns_check_deleted_ns(void)
Check if a deleted namespace is pending and free it.
Definition: xmlns.c:1423
xmlns_qname_t * xmlns_new_qname(void)
malloc and initialize a new xmlns_qname_t struct
Definition: xmlns.c:1354
xmlns_id_t xmlns_inv_id(void)
Get the INVALID namespace ID.
Definition: xmlns.c:958
xmlns_id_t xmlns_nc_id(void)
Get the ID for the NETCONF namespace or 0 if it doesn't exist.
Definition: xmlns.c:907
xmlns_pmap_t * xmlns_new_pmap(uint32 buffsize)
malloc and initialize a new xmlns_pmap_t struct
Definition: xmlns.c:1296
xmlns_id_t xmlns_wda_id(void)
Get the ID for the wd:default XML attribute namespace or 0 if it doesn't exist.
Definition: xmlns.c:1098
const xmlChar * xmlns_get_ns_prefix(xmlns_id_t ns_id)
Get the prefix for the specified namespace.
Definition: xmlns.c:663
xmlns_id_t xmlns_ncx_id(void)
Get the ID for the NETCONF Extensions namespace or 0 if it doesn't exist.
Definition: xmlns.c:924
xmlns_id_t xmlns_xs_id(void)
Get the ID for the XSD namespace or 0 if it doesn't exist.
Definition: xmlns.c:975
uint16 xmlns_id_t
integer handle for registered namespaces
Definition: xmlns.h:89
void xmlns_clear_modptrs(void *modptr)
Clear the module pointer for the namespace ID.
Definition: xmlns.c:1261
xmlns_id_t xmlns_find_ns_by_name_str(const xmlChar *name, uint32 namelen)
Find the NS ID from its name (counted string version)
Definition: xmlns.c:864
status_t xmlns_register_temp_ns(const xmlChar *ns, const xmlChar *pfix, xmlns_id_t *ns_id)
Register the specified temporary namespace.
Definition: xmlns.c:557
xmlns_id_t xmlns_yin_id(void)
Get the ID for the YIN namespace or 0 if it doesn't exist.
Definition: xmlns.c:1062
xmlns_id_t xmlns_origin_id(void)
Get the ID for the ietf-origin namespace or 0 if it doesn't exist.
Definition: xmlns.c:1135
xmlns_id_t xmlns_wildcard_id(void)
Get the ID for the base:1.1 wildcard namespace or 0 if it doesn't exist.
Definition: xmlns.c:1080
xmlns_id_t xmlns_find_ns_by_name(const xmlChar *name)
Find the NS ID from its name.
Definition: xmlns.c:832
void xmlns_cleanup(void)
Cleanup module static data.
Definition: xmlns.c:456
xmlns_id_t xmlns_yang_id(void)
Get the ID for the YANG namespace or 0 if it doesn't exist.
Definition: xmlns.c:1044
xmlns_id_t xmlns_find_ns_by_module_str(const xmlChar *modname, uint32 len)
Find the NS ID from its module name that registered it.
Definition: xmlns.c:750
xmlns_id_t xmlns_ncn_id(void)
Get the ID for the NETCONF Notifications namespace or 0 if it doesn't exist.
Definition: xmlns.c:1026
void xmlns_free_pmap(xmlns_pmap_t *pmap)
free a xmlns_pmap_t struct
Definition: xmlns.c:1331
boolean xmlns_ids_equal(xmlns_id_t ns1, xmlns_id_t ns2)
compare 2 namespace IDs only if they are both non-zero and return TRUE if they are equal
Definition: xmlns.c:1404
xmlns_id_t xmlns_find_ns_by_module(const xmlChar *modname)
Find the NS ID from its module name that registered it.
Definition: xmlns.c:706
Global error messages for status code enumerations.
represents one namespace prefix mapping
Definition: xmlns.h:134
xmlns_id_t nm_id
namespace ID in mapping
Definition: xmlns.h:139
xmlChar * nm_pfix
namespace prefix in mapping
Definition: xmlns.h:142
dlq_hdr_t qhdr
queue header
Definition: xmlns.h:136
boolean nm_topattr
flag set if this xmlns is a top-level attribute
Definition: xmlns.h:145
represents one QName data element
Definition: xmlns.h:93
const xmlChar * name
local-name
Definition: xmlns.h:95
xmlns_id_t nsid
namespace ID
Definition: xmlns.h:94
represents one registered namespace
Definition: xmlns.h:99
boolean ns_temporary
temporary flag used for unknown and other runtime namespace assignments
Definition: xmlns.h:118
xmlns_id_t ns_id
namespace ID is slot number + 1
Definition: xmlns.h:101
struct ncx_module_t_ * ns_mod
module backptr if module loaded for this namespace
Definition: xmlns.h:113
xmlChar * ns_module
module name associated with this namespace
Definition: xmlns.h:110
xmlChar * ns_name
namespace URI value
Definition: xmlns.h:107
boolean ns_deleted
flag that the namespace is deleted and only actually remove this entry when no message processing is ...
Definition: xmlns.h:123
xmlChar * ns_pfix
XML prefix for namespace usually same as YANG module prefix.
Definition: xmlns.h:104
boolean ns_mod_dup
flag indicates that multiple modules are loaded for this NSID record.
Definition: xmlns.h:129