yumapro
24.10-1
YumaPro SDK
|
Convert YANG files and other syntaxes into a queue of tokens. More...
Data Structures | |
struct | tk_origstr_t |
each entry in the origstrQ is the 2nd through Nth string to be concated. More... | |
struct | tk_token_t |
single YANG language token type More... | |
struct | tk_token_ptr_t |
token backptr to get at original token chain for strings used only by yangdump –format=yang|html More... | |
struct | tk_chain_t |
token parsing chain (main parser control block) More... | |
Macros | |
#define | TK_BUFF_SIZE 0xffff |
maximum line size allowed in an YANG module | |
#define | TK_NEXT(T) ((tk_token_t *)dlq_nextEntry(T)) |
move through token chain without advancing the cur pointer | |
#define | TK_TYP(T) ((T)->typ) |
return the token type | |
#define | TK_ID(T) ((T)->typ==TK_TT_TSTRING || (T)->typ==TK_TT_MSTRING) |
return TRUE if the token type is an identifier | |
#define | TK_VAL(T) (T)->val |
return the token value | |
#define | TK_NSID(T) (T)->nsid |
return the token namespace ID value | |
#define | TK_MOD(T) (T)->mod |
return the token prefix pointer if any | |
#define | TK_ADV(T) |
advance the current token pointer | |
#define | TK_BKUP(T) |
back-up the current token pointer | |
#define | TK_CUR(T) ((T)->cur) |
return the current token | |
#define | TK_CUR_TYP(T) ((T)->cur->typ) |
return the current token type | |
#define | TK_CUR_VAL(T) ((T)->cur->val) |
return the current token value | |
#define | TK_CUR_LEN(T) ((T)->cur->len) |
return the current token value length | |
#define | TK_CUR_MOD(T) (T)->cur->mod |
return the current token module qualifier value | |
#define | TK_CUR_MODLEN(T) ((T)->cur->modlen) |
return the current token module qualifier value length | |
#define | TK_CUR_STR(T) |
return TRUE if the current token type is a string | |
#define | TK_TYP_STR(T) ((T) >= TK_TT_STRING && (T) <= TK_TT_SQSTRING) |
return TRUE if the specified token type is a string | |
#define | TK_CUR_NOWSTR(T) |
return TRUE if the cur tk type allows a non-whitespace string | |
#define | TK_CUR_NUM(T) |
return TRUE if the current token type is a number | |
#define | TK_TYP_NUM(T) (((T) >= TK_TT_DNUM) && ((T) <= TK_TT_RNUM)) |
return TRUE if the specified token type is a number | |
#define | TK_CUR_INUM(T) |
return TRUE if the current token type is an integral number | |
#define | TK_CUR_IQUAL(T) |
return TRUE if the current token type is an instance qualifier | |
#define | TK_CUR_ID(T) |
return TRUE if the current token type is an identifier | |
#define | TK_CUR_SID(T) |
return TRUE if the current token type is a scoped identifier | |
#define | TK_CUR_LNUM(T) ((T)->cur->linenum) |
return the current line number | |
#define | TK_CUR_LPOS(T) ((T)->cur->linepos) |
return the current line position | |
#define | TK_CUR_TEXT(T) |
return TRUE if the token is a text or number type, as opposed to a 1 or 2 char non-text token type YPW-1763: the plain string type should also be accepted | |
#define | TK_CUR_NSID(T) (T)->cur->nsid |
return the namespace ID field in the token | |
#define | TK_DOCMODE(TKC) ((TKC)->flags & TK_FL_DOCMODE) |
return non-zero if token preservation docmode | |
#define | TK_HAS_ORIGTK(TK) |
token has an origval saved | |
#define | TK_SET_ESCERR(TK) (TK)->flags |= TK_FL_ESCSTR_ERR |
SET access the escaped string error fields. | |
#define | TK_GET_ESCERR(TK) ((TK)->flags & TK_FL_ESCSTR_ERR) |
GET access the escaped string error fields. | |
#define | TK_FL_REDO bit0 |
start bits for tk_chain_t flags field == 1: the current parse call is to redo a previously parsed token == 0: normal parse mode | |
#define | TK_FL_MALLOC bit1 |
== 1: the tkc->buff field is malloced by this module and will be freed in tk_free_chain == 0: the tkc->buff memory was provided externally and will not be freed in tk_free_chain | |
#define | TK_FL_DOCMODE bit2 |
== 1: DOC mode: the tk->origtkQ field will be used to preserve pre-string concat and processing == 0: normal mode: the tkc->origtkQ will not be used and only the result token will be saved | |
#define | TK_FL_BINARYMODE bit3 |
== 1: BINARY mode: the tkc->buff buffer is allowed to contain binary characters == 0: TEXT mode: the tkc->buff is not allowed to contain binary characters | |
#define | TK_FL_ESCSTR_ERR bit4 |
== 1: escerr fields are set for YANG 1.1 illegal escaped char 1 or more double-quoted strings have been converted == 0: no escerr was detected in the parsed tokens | |
#define | TK_FL_VAL_MALLOC bit0 |
start flags for the tk->flags field == 1: VAL malloc: the tk->val field is malloced == 0: VAL buffer: tk->val points to tk->valbuff | |
#define | TK_FL_ORIGVAL_MALLOC bit1 |
== 1: ORIGVAL malloc: the tk->origval field is malloced == 0: ORIGVAL buffer: tk->origval points to tk->valbuff | |
Typedefs | |
typedef status_t(* | tk_getline_fn_t) (xmlChar *fillbuff, uint32 fillbuffsize, void *cookie) |
callback function to read a line into a buffer More... | |
Enumerations | |
enum | tk_type_t { } |
different types of tokens parsed during 1st pass More... | |
enum | tk_source_t { TK_SOURCE_CONF , TK_SOURCE_YANG , TK_SOURCE_XPATH , TK_SOURCE_REDO , TK_SOURCE_JSON , TK_SOURCE_FIELDS , TK_SOURCE_FEATURE , TK_SOURCE_CLI } |
token source context More... | |
enum | tk_origstr_typ_t { } |
preserve the original string type More... | |
Functions | |
tk_chain_t * | tk_new_chain (void) |
Allocatate a new token parse chain. More... | |
void | tk_setup_chain_conf (tk_chain_t *tkc, FILE *fp, const xmlChar *filename) |
Setup a previously allocated chain for a text config file. More... | |
void | tk_setup_chain_cli (tk_chain_t *tkc, xmlChar *line) |
Setup a previously allocated chain for a CLI command line. More... | |
void | tk_setup_chain_fields (tk_chain_t *tkc, xmlChar *str) |
Setup a previously allocated chain for 'fields' RESTCONF query parameter str value. More... | |
void | tk_setup_chain_feature (tk_chain_t *tkc, xmlChar *str) |
Setup a previously allocated chain for 'if-feature' YANG 1.1. More... | |
void | tk_setup_chain_yang (tk_chain_t *tkc, FILE *fp, const xmlChar *filename) |
Setup a previously allocated chain for a YANG file. More... | |
void | tk_setup_chain_yin (tk_chain_t *tkc, const xmlChar *filename) |
Setup a previously allocated chain for a YIN file. More... | |
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. More... | |
void | tk_setup_chain_json_buffer (tk_chain_t *tkc, xmlChar *buff) |
Setup a previously allocated chain for a JSON buffer. More... | |
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. More... | |
void | tk_setup_chain_docmode (tk_chain_t *tkc) |
Setup a previously allocated chain for a yangdump docmode output. More... | |
void | tk_setup_chain_cli_line (tk_chain_t *tkc, xmlChar *str) |
Setup a previously allocated chain for yangcli CLI line of input. More... | |
void | tk_free_chain (tk_chain_t *tkc) |
Cleanup and deallocate a tk_chain_t. More... | |
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. More... | |
const char * | tk_get_token_name (tk_type_t ttyp) |
Get the symbolic token name. More... | |
const char * | tk_get_token_sym (tk_type_t ttyp) |
Get the symbolic token symbol. More... | |
const char * | tk_get_btype_sym (ncx_btype_t btyp) |
Get the symbolic token symbol for one of the base types. More... | |
tk_type_t | tk_next_typ (tk_chain_t *tkc) |
Get the token type of the next token. More... | |
tk_type_t | tk_next_typ2 (tk_chain_t *tkc) |
Get the token type of the token after the next token. More... | |
boolean | tk_next_is_null (tk_chain_t *tkc) |
Get the special sequence [null] is next. More... | |
const xmlChar * | tk_next_val (tk_chain_t *tkc) |
Get the token type of the next token. More... | |
void | tk_dump_token (const tk_token_t *tk) |
Debug printf the specified token !!! Very verbose !!! More... | |
void | tk_dump_chain (const tk_chain_t *tkc) |
Debug printf the token chain !!! Very verbose !!! More... | |
boolean | tk_is_wsp_string (const tk_token_t *tk) |
Check if the current token is a string with whitespace in it. More... | |
status_t | tk_tokenize_input (tk_chain_t *tkc, ncx_module_t *mod) |
Parse the input (FILE or buffer) into tk_token_t structs. More... | |
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, as needed. More... | |
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 tokens. More... | |
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. More... | |
uint32 | tk_token_count (const tk_chain_t *tkc) |
Get the number of tokens in the queue. More... | |
void | tk_reset_chain (tk_chain_t *tkc) |
Reset the token chain current pointer to the start. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
status_t | tk_add_lbrace_token (tk_chain_t *tkc) |
Allocatate a new left brace token and add it to the parse chain. More... | |
status_t | tk_add_rbrace_token (tk_chain_t *tkc) |
Allocatate a new right brace token and add it to the parse chain. More... | |
status_t | tk_add_semicol_token (tk_chain_t *tkc) |
Allocatate a new semi-colon token and add it to the parse chain. More... | |
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. More... | |
const xmlChar * | tk_get_first_origstr (const tk_token_ptr_t *tkptr, boolean *dquote, boolean *morestr) |
Get the first original string to use. More... | |
const tk_origstr_t * | tk_first_origstr_rec (const tk_token_ptr_t *tkptr) |
Get the first tk_origstr_t struct (if any) More... | |
const tk_origstr_t * | tk_next_origstr_rec (const tk_origstr_t *origstr) |
Get the next tk_origstr_t struct (if any) More... | |
const xmlChar * | tk_get_origstr_parts (const tk_origstr_t *origstr, boolean *dquote, boolean *newline) |
Get the fields from the original string record. More... | |
const tk_token_ptr_t * | tk_find_tkptr (const tk_chain_t *tkc, const void *field) |
Find the specified token pointer record. More... | |
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. More... | |
boolean | tk_cur_is_first (const tk_chain_t *tkc) |
Check if the current token is the first token. More... | |
Convert YANG files and other syntaxes into a queue of tokens.
Processes YANG, XPath, JSON, and other languages used by the YANG compiler and the server in protocol messages.
typedef status_t(* tk_getline_fn_t) (xmlChar *fillbuff, uint32 fillbuffsize, void *cookie) |
callback function to read a line into a buffer
[out] | fillbuff | buffer to contain the next input line
|
fillbuffsize | number of bytes allowed in fillbuff | |
cookie | user cookie passed at init time |
enum tk_origstr_typ_t |
enum tk_source_t |
enum tk_type_t |
different types of tokens parsed during 1st pass
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.
tkc | token chain to use |
valstr | ID name |
status_t tk_add_lbrace_token | ( | tk_chain_t * | tkc | ) |
Allocatate a new left brace token and add it to the parse chain.
tkc | token chain to use |
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.
tkc | token chain to use |
prefix | ID prefix |
prefixlen | 'prefix' length in bytes |
valstr | ID name |
status_t tk_add_rbrace_token | ( | tk_chain_t * | tkc | ) |
Allocatate a new right brace token and add it to the parse chain.
tkc | token chain to use |
status_t tk_add_semicol_token | ( | tk_chain_t * | tkc | ) |
Allocatate a new semi-colon token and add it to the parse chain.
tkc | token chain to use |
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.
tkc | token chain to use |
valstr | string value to use |
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.
tkc | token chain to use |
tk | token to use (usually TK_CUR()) |
field | address of string field to save as the key |
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.
oldtkc | token chain to clone |
boolean tk_cur_is_first | ( | const tk_chain_t * | tkc | ) |
Check if the current token is the first token.
tkc | token chain to use |
void tk_dump_chain | ( | const tk_chain_t * | tkc | ) |
Debug printf the token chain !!! Very verbose !!!
tkc | token chain |
void tk_dump_token | ( | const tk_token_t * | tk | ) |
Debug printf the specified token !!! Very verbose !!!
tk | token to dump |
const tk_token_ptr_t * tk_find_tkptr | ( | const tk_chain_t * | tkc, |
const void * | field | ||
) |
Find the specified token pointer record.
tkc | token chain to use |
field | address of field to use as key to find |
const tk_origstr_t * tk_first_origstr_rec | ( | const tk_token_ptr_t * | tkptr | ) |
Get the first tk_origstr_t struct (if any)
tkptr | token pointer to use |
void tk_free_chain | ( | tk_chain_t * | tkc | ) |
Cleanup and deallocate a tk_chain_t.
tkc | TK chain to delete |
const char * tk_get_btype_sym | ( | ncx_btype_t | btyp | ) |
Get the symbolic token symbol for one of the base types.
btyp | base type |
const xmlChar * tk_get_first_origstr | ( | const tk_token_ptr_t * | tkptr, |
boolean * | dquote, | ||
boolean * | morestr | ||
) |
Get the first original string to use.
tkptr | token pointer to use | |
[out] | dquote | address of return double quote flag
|
[out] | morestr | address of return more string fragments flag
|
const xmlChar * tk_get_origstr_parts | ( | const tk_origstr_t * | origstr, |
boolean * | dquote, | ||
boolean * | newline | ||
) |
Get the fields from the original string record.
origstr | original string record pointer to use | |
[out] | dquote | address of return double quote flag
|
[out] | newline | address of return need newline flag
|
const char * tk_get_token_name | ( | tk_type_t | ttyp | ) |
Get the symbolic token name.
ttyp | token type |
const char * tk_get_token_sym | ( | tk_type_t | ttyp | ) |
Get the symbolic token symbol.
ttyp | token type |
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.
buff | token string to check – NOT ZERO-TERMINATED |
len | length of string to check |
boolean tk_is_wsp_string | ( | const tk_token_t * | tk | ) |
Check if the current token is a string with whitespace in it.
tk | token to check |
tk_chain_t * tk_new_chain | ( | void | ) |
Allocatate a new token parse chain.
boolean tk_next_is_null | ( | tk_chain_t * | tkc | ) |
Get the special sequence [null] is next.
tkc | token chain |
const tk_origstr_t * tk_next_origstr_rec | ( | const tk_origstr_t * | origstr | ) |
Get the next tk_origstr_t struct (if any)
origstr | origisnal string record pointer to use |
tk_type_t tk_next_typ | ( | tk_chain_t * | tkc | ) |
Get the token type of the next token.
tkc | token chain |
tk_type_t tk_next_typ2 | ( | tk_chain_t * | tkc | ) |
Get the token type of the token after the next token.
tkc | token chain |
const xmlChar * tk_next_val | ( | tk_chain_t * | tkc | ) |
Get the token type of the next token.
tkc | token chain |
void tk_reset_chain | ( | tk_chain_t * | tkc | ) |
Reset the token chain current pointer to the start.
tkc | token chain to reset |
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, as needed.
The current token may be replaced with one or more tokens
tkc | token chain |
mod | module in progress (NULL if not used) |
void tk_setup_chain_cli | ( | tk_chain_t * | tkc, |
xmlChar * | line | ||
) |
Setup a previously allocated chain for a CLI command line.
tkc | token chain to setup |
line | CLI buffer to parse; this pointer is just borrowed it will not be freed when the token chain is freed |
void tk_setup_chain_cli_line | ( | tk_chain_t * | tkc, |
xmlChar * | str | ||
) |
Setup a previously allocated chain for yangcli CLI line of input.
tkc | token chain to setup |
str | CLI input to parse |
void tk_setup_chain_conf | ( | tk_chain_t * | tkc, |
FILE * | fp, | ||
const xmlChar * | filename | ||
) |
Setup a previously allocated chain for a text config file.
tkc | token chain to setup |
fp | open file to use for text source |
filename | source filespec |
void tk_setup_chain_docmode | ( | tk_chain_t * | tkc | ) |
Setup a previously allocated chain for a yangdump docmode output.
tkc | token chain to setup |
void tk_setup_chain_feature | ( | tk_chain_t * | tkc, |
xmlChar * | str | ||
) |
Setup a previously allocated chain for 'if-feature' YANG 1.1.
tkc | token chain to setup |
str | if-feature expression |
void tk_setup_chain_fields | ( | tk_chain_t * | tkc, |
xmlChar * | str | ||
) |
Setup a previously allocated chain for 'fields' RESTCONF query parameter str value.
tkc | token chain to setup |
str | fields RESTCONF query parameter value to parse; this pointer is just borrowed it will not be freed when the token chain is freed |
void tk_setup_chain_json_buffer | ( | tk_chain_t * | tkc, |
xmlChar * | buff | ||
) |
Setup a previously allocated chain for a JSON buffer.
tkc | token chain to setup |
buff | buffer to use for text source |
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.
tkc | token chain to setup |
getline_fn | get next line function |
cookie | cookie pointer to pass to get_next_buff_fn callback |
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.
tkc | token chain to setup |
fp | open file to use for text source |
filename | source filespec |
void tk_setup_chain_yang | ( | tk_chain_t * | tkc, |
FILE * | fp, | ||
const xmlChar * | filename | ||
) |
Setup a previously allocated chain for a YANG file.
tkc | token chain to setup |
fp | open file to use for text source |
filename | source filespec |
void tk_setup_chain_yin | ( | tk_chain_t * | tkc, |
const xmlChar * | filename | ||
) |
Setup a previously allocated chain for a YIN file.
tkc | token chain to setup |
filename | source filespec |
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.
tkptr | token pointer to use |
uint32 tk_token_count | ( | const tk_chain_t * | tkc | ) |
Get the number of tokens in the queue.
tkc | token chain to check |
status_t tk_tokenize_input | ( | tk_chain_t * | tkc, |
ncx_module_t * | mod | ||
) |
Parse the input (FILE or buffer) into tk_token_t structs.
The tkc param must be initialized to use the internal buffer to read from the specified filespec:
tkc->filename tkc->flags tkc->fp tkc->source External buffer mode:
If no filename is provided, the the TK_FL_MALLOC flag will not be set, and the tkc->buff field must be initialized before this function is called. This function will not free the buffer, but just read from it until a '0' char is reached.
Error messages are printed by this function!! Do not duplicate error messages upon error return
tkc | token chain |
mod | module in progress (NULL if not used) !!! Just used for error messages !!! |
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 tokens.
mod | module in progress for error purposes (may be NULL) | |
str | string to tokenize | |
[out] | res | address of return status
|
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.
mod | module in progress for error purposes (may be NULL) | |
str | string to tokenize | |
curlinenum | current line number | |
curlinepos | current line position | |
[out] | res | address of return status
|