76#define TK_BUFF_SIZE 0xffff
89#define TK_NEXT(T) ((tk_token_t *)dlq_nextEntry(T))
92#define TK_TYP(T) ((T)->typ)
95#define TK_ID(T) ((T)->typ==TK_TT_TSTRING || (T)->typ==TK_TT_MSTRING)
98#define TK_VAL(T) (T)->val
101#define TK_NSID(T) (T)->nsid
104#define TK_MOD(T) (T)->mod
108 ((T)->cur ? (((T)->cur = (tk_token_t *)dlq_nextEntry((T)->cur)) \
109 ? NO_ERR : ERR_NCX_EOF) : ERR_NCX_EOF)
113 if (! ((T)->cur = (tk_token_t *)dlq_prevEntry((T)->cur))) \
114 (T)->cur = (tk_token_t *)(&((T)->tkQ))
122#define TK_CUR(T) ((T)->cur)
125#define TK_CUR_TYP(T) ((T)->cur->typ)
128#define TK_CUR_VAL(T) ((T)->cur->val)
131#define TK_CUR_LEN(T) ((T)->cur->len)
134#define TK_CUR_MOD(T) (T)->cur->mod
137#define TK_CUR_MODLEN(T) ((T)->cur->modlen)
140#define TK_CUR_STR(T) ((T)->cur->typ >= TK_TT_STRING && \
141 (T)->cur->typ <= TK_TT_SQSTRING)
144#define TK_TYP_STR(T) ((T) >= TK_TT_STRING && (T) <= TK_TT_SQSTRING)
147#define TK_CUR_NOWSTR(T) ((T)->cur->typ >= TK_TT_STRING && \
148 (T)->cur->typ <= TK_TT_SQSTRING)
151#define TK_CUR_NUM(T) ((T)->cur->typ==TK_TT_DNUM || \
152 (T)->cur->typ==TK_TT_HNUM || \
153 (T)->cur->typ==TK_TT_RNUM)
157#define TK_TYP_NUM(T) (((T) >= TK_TT_DNUM) && ((T) <= TK_TT_RNUM))
161#define TK_CUR_INUM(T) ((T)->cur->typ==TK_TT_DNUM || \
162 (T)->cur->typ==TK_TT_HNUM)
165#define TK_CUR_IQUAL(T) ((T)->cur->typ==TK_TT_QMARK || \
166 (T)->cur->typ==TK_TT_STAR || \
167 (T)->cur->typ==TK_TT_PLUS)
171#define TK_CUR_ID(T) ((T)->cur->typ==TK_TT_TSTRING || \
172 (T)->cur->typ==TK_TT_MSTRING)
175#define TK_CUR_SID(T) ((T)->cur->typ==TK_TT_SSTRING || \
176 (T)->cur->typ==TK_TT_MSSTRING)
179#define TK_CUR_LNUM(T) ((T)->cur->linenum)
182#define TK_CUR_LPOS(T) ((T)->cur->linepos)
188#define TK_CUR_TEXT(T) (((T)->cur->typ == TK_TT_STRING) || \
189 ((T)->cur->typ >= TK_TT_SSTRING && \
190 (T)->cur->typ <= TK_TT_RNUM))
194#define TK_CUR_NSID(T) (T)->cur->nsid
197#define TK_DOCMODE(TKC) ((TKC)->flags & TK_FL_DOCMODE)
200#define TK_HAS_ORIGTK(TK) (((TK)->typ == TK_TT_QSTRING || \
201 (TK)->typ == TK_TT_SQSTRING) && \
202 (TK)->origval != NULL)
205#define TK_SET_ESCERR(TK) (TK)->flags |= TK_FL_ESCSTR_ERR
208#define TK_GET_ESCERR(TK) ((TK)->flags & TK_FL_ESCSTR_ERR)
217#define TK_FL_REDO bit0
225#define TK_FL_MALLOC bit1
233#define TK_FL_DOCMODE bit2
242#define TK_FL_BINARYMODE bit3
250#define TK_FL_ESCSTR_ERR bit4
259#define TK_FL_VAL_MALLOC bit0
266#define TK_FL_ORIGVAL_MALLOC bit1
269#define TK_VALBUFF_LEN 8
279typedef enum tk_type_t_ {
337typedef enum tk_source_t_ {
350typedef enum tk_origstr_typ_t_ {
363typedef struct tk_origstr_t_ {
371typedef struct tk_token_t_ {
383 xmlChar valbuff[TK_VALBUFF_LEN];
391typedef struct tk_token_ptr_t_ {
415typedef struct tk_chain_t_ {
462 const xmlChar *filename);
511 const xmlChar *filename);
522 const xmlChar *filename);
535 const xmlChar *filename);
670extern const xmlChar *
831 const xmlChar *valstr);
846 const xmlChar *prefix,
848 const xmlChar *valstr);
860 const xmlChar *valstr);
924extern const xmlChar *
965extern const xmlChar *
dlq provides general double-linked list and queue support:
status_t
global error return code
Definition: status_enum.h:210
uint16 xmlns_id_t
integer handle for registered namespaces
Definition: xmlns.h:89
ncx_btype_t
enumeration of the built-in NCX types These types cannot be overridden and cannot be imported
Definition: ncxtypes.h:213
status_t tk_add_rbrace_token(tk_chain_t *tkc)
Allocatate a new right brace token and add it to the parse chain.
Definition: tk.c:4348
status_t tk_add_pid_token(tk_chain_t *tkc, const xmlChar *prefix, uint32 prefixlen, const xmlChar *valstr)
Allocatate a new prefixed ID token and add it to the parse chain.
Definition: tk.c:4220
tk_chain_t * tk_new_chain(void)
Allocatate a new token parse chain.
Definition: tk.c:2944
const char * tk_get_btype_sym(ncx_btype_t btyp)
Get the symbolic token symbol for one of the base types.
Definition: tk.c:3369
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:2970
status_t tk_check_save_origstr(tk_chain_t *tkc, tk_token_t *tk, const void *field)
Check the docmode and the specified token; Save a tk_origptr_t if needed with the field address.
Definition: tk.c:4421
void tk_setup_chain_json_buffs(tk_chain_t *tkc, tk_getline_fn_t getline_fn, void *cookie)
Setup a previously allocated chain for a JSON buffer chain.
Definition: tk.c:3177
tk_chain_t * tk_clone_chain(tk_chain_t *oldtkc)
Allocatate and a new token parse chain and fill it with the specified token chain contents.
Definition: tk.c:4109
void tk_setup_chain_docmode(tk_chain_t *tkc)
Setup a previously allocated chain for a yangdump docmode output.
Definition: tk.c:3202
tk_origstr_typ_t
preserve the original string type
Definition: tk.h:350
status_t tk_add_lbrace_token(tk_chain_t *tkc)
Allocatate a new left brace token and add it to the parse chain.
Definition: tk.c:4313
const char * tk_get_token_sym(tk_type_t ttyp)
Get the symbolic token symbol.
Definition: tk.c:3347
status_t(* tk_getline_fn_t)(xmlChar *fillbuff, uint32 fillbuffsize, void *cookie)
callback function to read a line into a buffer
Definition: tk.h:408
tk_chain_t * tk_tokenize_metadata_string(ncx_module_t *mod, xmlChar *str, status_t *res)
The specified ncx:metadata string is parsed into tokens convert the ncx:metadata content to 1 or 2 to...
Definition: tk.c:3978
void tk_dump_token(const tk_token_t *tk)
Debug printf the specified token !!! Very verbose !!!
Definition: tk.c:3537
uint32 tk_token_count(const tk_chain_t *tkc)
Get the number of tokens in the queue.
Definition: tk.c:4061
const xmlChar * tk_get_first_origstr(const tk_token_ptr_t *tkptr, boolean *dquote, boolean *morestr)
Get the first original string to use.
Definition: tk.c:4469
uint32 tk_tkptr_quotes(const tk_token_ptr_t *tkptr)
Get the specified token pointer record token ID type Use the first string or only string.
Definition: tk.c:4626
status_t tk_retokenize_cur_string(tk_chain_t *tkc, ncx_module_t *mod)
The current token is some sort of a string Reparse it according to the full YANG token list,...
Definition: tk.c:3907
const tk_token_ptr_t * tk_find_tkptr(const tk_chain_t *tkc, const void *field)
Find the specified token pointer record.
Definition: tk.c:4588
ncx_btype_t tk_get_yang_btype_id(const xmlChar *buff, uint32 len)
Check if the specified string is a YANG builtin type name checks for valid YANG data type name.
Definition: tk.c:3284
const xmlChar * tk_next_val(tk_chain_t *tkc)
Get the token type of the next token.
Definition: tk.c:3511
boolean tk_cur_is_first(const tk_chain_t *tkc)
Check if the current token is the first token.
Definition: tk.c:4656
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:3050
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:3680
void tk_setup_chain_cli(tk_chain_t *tkc, xmlChar *line)
Setup a previously allocated chain for a CLI command line.
Definition: tk.c:2997
status_t tk_add_semicol_token(tk_chain_t *tkc)
Allocatate a new semi-colon token and add it to the parse chain.
Definition: tk.c:4383
const xmlChar * tk_get_origstr_parts(const tk_origstr_t *origstr, boolean *dquote, boolean *newline)
Get the fields from the original string record.
Definition: tk.c:4556
boolean tk_is_wsp_string(const tk_token_t *tk)
Check if the current token is a string with whitespace in it.
Definition: tk.c:3623
tk_chain_t * tk_tokenize_xpath_string(ncx_module_t *mod, xmlChar *str, uint32 curlinenum, uint32 curlinepos, status_t *res)
The specified XPath string is parsed into tokens.
Definition: tk.c:4022
void tk_reset_chain(tk_chain_t *tkc)
Reset the token chain current pointer to the start.
Definition: tk.c:4084
const tk_origstr_t * tk_first_origstr_rec(const tk_token_ptr_t *tkptr)
Get the first tk_origstr_t struct (if any)
Definition: tk.c:4502
void tk_free_chain(tk_chain_t *tkc)
Cleanup and deallocate a tk_chain_t.
Definition: tk.c:3248
boolean tk_next_is_null(tk_chain_t *tkc)
Get the special sequence [null] is next.
Definition: tk.c:3456
const char * tk_get_token_name(tk_type_t ttyp)
Get the symbolic token name.
Definition: tk.c:3325
void tk_setup_chain_yang(tk_chain_t *tkc, FILE *fp, const xmlChar *filename)
Setup a previously allocated chain for a YANG file.
Definition: tk.c:3076
status_t tk_add_string_token(tk_chain_t *tkc, const xmlChar *valstr)
Allocatate a new string token and add it to the parse chain.
Definition: tk.c:4261
tk_type_t
different types of tokens parsed during 1st pass
Definition: tk.h:279
void tk_setup_chain_json_buffer(tk_chain_t *tkc, xmlChar *buff)
Setup a previously allocated chain for a JSON buffer.
Definition: tk.c:3153
const tk_origstr_t * tk_next_origstr_rec(const tk_origstr_t *origstr)
Get the next tk_origstr_t struct (if any)
Definition: tk.c:4526
tk_type_t tk_next_typ(tk_chain_t *tkc)
Get the token type of the next token.
Definition: tk.c:3394
status_t tk_add_id_token(tk_chain_t *tkc, const xmlChar *valstr)
Allocatate a new ID token and add it to the parse chain.
Definition: tk.c:4174
void tk_setup_chain_json_file(tk_chain_t *tkc, FILE *fp, const xmlChar *filename)
Setup a previously allocated chain for a JSON input stream.
Definition: tk.c:3127
void tk_dump_chain(const tk_chain_t *tkc)
Debug printf the token chain !!! Very verbose !!!
Definition: tk.c:3575
tk_source_t
token source context
Definition: tk.h:337
void tk_setup_chain_yin(tk_chain_t *tkc, const xmlChar *filename)
Setup a previously allocated chain for a YIN file.
Definition: tk.c:3102
tk_type_t tk_next_typ2(tk_chain_t *tkc)
Get the token type of the token after the next token.
Definition: tk.c:3421
void tk_setup_chain_cli_line(tk_chain_t *tkc, xmlChar *str)
Setup a previously allocated chain for yangcli CLI line of input.
Definition: tk.c:3223
void tk_setup_chain_fields(tk_chain_t *tkc, xmlChar *str)
Setup a previously allocated chain for 'fields' RESTCONF query parameter str value.
Definition: tk.c:3025
@ TK_ORIGSTR_SQUOTE
single quote
Definition: tk.h:354
@ TK_ORIGSTR_DQUOTE
double quote
Definition: tk.h:352
@ TK_ORIGSTR_DQUOTE_NL
souble quote + newline
Definition: tk.h:353
@ TK_ORIGSTR_SQUOTE_NL
single quote + newline
Definition: tk.h:355
@ TK_TT_LPAREN
left paren '('
Definition: tk.h:285
@ TK_TT_LT
less than char '<'
Definition: tk.h:299
@ TK_TT_VARBIND
XPath varbind '$NCName'.
Definition: tk.h:321
@ TK_TT_PLUS
plus mark '+'
Definition: tk.h:294
@ TK_TT_RBRACE
right brace '}'
Definition: tk.h:283
@ TK_TT_STAR
star '*'
Definition: tk.h:292
@ TK_TT_NOTEQUAL
not equal '!='
Definition: tk.h:306
@ TK_TT_RANGESEP
range sep, parent node '..'
Definition: tk.h:303
@ TK_TT_SSTRING
scoped token string
Definition: tk.h:314
@ TK_TT_LBRACK
left bracket '['
Definition: tk.h:287
@ TK_TT_COMMA
comma ','
Definition: tk.h:289
@ TK_TT_EQUAL
equal sign '='
Definition: tk.h:290
@ TK_TT_NCNAME_STAR
XPath NCName:* sequence.
Definition: tk.h:324
@ TK_TT_PERIOD
period char '.
Definition: tk.h:296
@ TK_TT_LEQUAL
less than or equal '<='
Definition: tk.h:307
@ TK_TT_GEQUAL
greater than or equal '>='
Definition: tk.h:308
@ TK_TT_GT
greater than char '>'
Definition: tk.h:300
@ TK_TT_SQSTRING
single quoted string
Definition: tk.h:319
@ TK_TT_RBRACK
right bracket ']'
Definition: tk.h:288
@ TK_TT_FSLASH
forward slash char '/'
Definition: tk.h:297
@ TK_TT_COLON
colon char ':'
Definition: tk.h:295
@ TK_TT_BAR
bar '|'
Definition: tk.h:291
@ TK_TT_MSSTRING
module-qualified scoped string
Definition: tk.h:317
@ TK_TT_STRING
unquoted string
Definition: tk.h:312
@ TK_TT_DBLCOLON
2 colon chars '::'
Definition: tk.h:304
@ TK_TT_QSTRING
double quoted string
Definition: tk.h:318
@ TK_TT_MSTRING
module-qualified token string
Definition: tk.h:316
@ TK_TT_MINUS
minus char '-'
Definition: tk.h:298
@ TK_TT_DBLFSLASH
2 fwd slashes '//'
Definition: tk.h:305
@ TK_TT_RNUM
real number
Definition: tk.h:329
@ TK_TT_HNUM
hex number
Definition: tk.h:328
@ TK_TT_LBRACE
left brace '{'
Definition: tk.h:282
@ TK_TT_QVARBIND
XPath varbind '$prefix:NCName'.
Definition: tk.h:322
@ TK_TT_DNUM
decimal number
Definition: tk.h:327
@ TK_TT_ATSIGN
at sign '@'
Definition: tk.h:293
@ TK_TT_TSTRING
token string
Definition: tk.h:315
@ TK_TT_NEWLINE
is significant in conf files
Definition: tk.h:332
@ TK_TT_LINE
raw command line
Definition: tk.h:313
@ TK_TT_RPAREN
right paren ')'
Definition: tk.h:286
@ TK_TT_SEMICOL
semi-colon ';'
Definition: tk.h:284
@ TK_SOURCE_JSON
JSON.
Definition: tk.h:342
@ TK_SOURCE_YANG
YANG.
Definition: tk.h:339
@ TK_SOURCE_XPATH
XPath.
Definition: tk.h:340
@ TK_SOURCE_FIELDS
RESTCONF fields parameter.
Definition: tk.h:343
@ TK_SOURCE_FEATURE
YANG 1.1 feature expr.
Definition: tk.h:344
@ TK_SOURCE_REDO
redo internal mode
Definition: tk.h:341
@ TK_SOURCE_CONF
config file
Definition: tk.h:338
YANG module data structures Many internal representations of YANG module constructs.
struct to remember error info tkc->cur_err will be checked before tkc->cur for error information
Definition: ncxtypes.h:877
representation of one module or submodule during and after parsing
Definition: ncxtypes.h:1138
token parsing chain (main parser control block)
Definition: tk.h:415
xmlChar * buff
buffer when source is buffer
Definition: tk.h:424
uint32 linepos
current line position
Definition: tk.h:427
dlq_hdr_t qhdr
queue header
Definition: tk.h:416
void * cookie
getline callback cookie
Definition: tk.h:431
const xmlChar * filename
filename when source is file
Definition: tk.h:422
tk_getline_fn_t getline_fn
getline callback
Definition: tk.h:430
uint32 flags
parser state flags
Definition: tk.h:428
dlq_hdr_t tkQ
Q of tk_token_t.
Definition: tk.h:417
tk_token_t * escerr_tk
backptr into tkQ
Definition: tk.h:420
xmlChar * bptr
current read buffer pointer
Definition: tk.h:425
dlq_hdr_t tkptrQ
Q of tk_token_ptr_t.
Definition: tk.h:418
FILE * fp
file when source is file
Definition: tk.h:423
tk_token_t * cur
current token pointer
Definition: tk.h:419
uint32 linenum
current line number
Definition: tk.h:426
xmlChar escerr_ch
first bad escaped char if escerr
Definition: tk.h:432
ncx_error_t * curerr
error token pointer
Definition: tk.h:421
tk_source_t source
source context
Definition: tk.h:429
each entry in the origstrQ is the 2nd through Nth string to be concated.
Definition: tk.h:363
tk_origstr_typ_t origtyp
original source type
Definition: tk.h:365
dlq_hdr_t qhdr
queue header
Definition: tk.h:364
xmlChar * str
original string
Definition: tk.h:366
token backptr to get at original token chain for strings used only by yangdump –format=yang|html
Definition: tk.h:391
const void * field
saved cookie
Definition: tk.h:394
dlq_hdr_t qhdr
queue header
Definition: tk.h:392
tk_token_t * tk
token
Definition: tk.h:393
single YANG language token type
Definition: tk.h:371
dlq_hdr_t origstrQ
Q of tk_origstr_t only used in DOCMODE.
Definition: tk.h:382
uint32 linepos
token source line osition
Definition: tk.h:380
dlq_hdr_t qhdr
queue header
Definition: tk.h:372
uint32 len
length of value
Definition: tk.h:378
xmlChar * origval
used in DOCMODE for yangdump
Definition: tk.h:377
uint32 modlen
length of 'mod'; not Z-string!
Definition: tk.h:375
tk_type_t typ
token type
Definition: tk.h:373
xmlChar * mod
only used if prefix found
Definition: tk.h:374
uint32 linenum
token source line number
Definition: tk.h:379
uint8 flags
parsing state flags
Definition: tk.h:384
xmlChar * val
value string for token if buffer too snall
Definition: tk.h:376
xmlns_id_t nsid
only used for TK_TT_MSTRING tokens
Definition: tk.h:381