yumapro
24.10-2
YumaPro SDK
|
NCX Lists are simple string based lists. More...
Functions | |
ncx_list_t * | ncx_new_list (ncx_btype_t btyp) |
Malloc Initialize an allocated ncx_list_t. More... | |
void | ncx_init_list (ncx_list_t *list, ncx_btype_t btyp) |
Initialize an allocated ncx_list_t. More... | |
void | ncx_clean_list (ncx_list_t *list) |
Scrub the memory of a ncx_list_t but do not delete it. More... | |
void | ncx_free_list (ncx_list_t *list) |
Clean and free an allocated ncx_list_t. More... | |
uint32 | ncx_list_cnt (const ncx_list_t *list) |
Get the number of entries in the list. More... | |
uint32 | ncx_list_linelen (const ncx_list_t *list) |
Get the length of the string if the list was printed in 1 line with spaces between the entries. More... | |
boolean | ncx_list_empty (const ncx_list_t *list) |
Check if the list is empty or not. More... | |
boolean | ncx_string_in_list (const xmlChar *str, const ncx_list_t *list) |
Check if the string value is in the list List type must be string based, or an enum. More... | |
int32 | ncx_compare_lists (const ncx_list_t *list1, const ncx_list_t *list2) |
Compare 2 ncx_list_t struct contents. More... | |
status_t | ncx_copy_list (const ncx_list_t *list1, ncx_list_t *list2) |
Copy the contents of list1 to list2 Supports base type NCX_BT_SLIST. More... | |
void | ncx_merge_list (ncx_list_t *src, ncx_list_t *dest, ncx_merge_t mergetyp, boolean allow_dups) |
The merge function is handled specially for lists. More... | |
status_t | ncx_replace_list (const ncx_list_t *src, ncx_list_t *dest) |
The replace function is handled specially for lists. More... | |
status_t | ncx_set_strlist (const xmlChar *liststr, ncx_list_t *list) |
Consume a generic string list with no type checking. More... | |
status_t | ncx_set_list (ncx_btype_t btyp, const xmlChar *strval, ncx_list_t *list) |
consume a generic string list with base type checking Parse the XML input as an NCX_BT_SLIST More... | |
status_t | ncx_finish_list (typ_def_t *typdef, ncx_list_t *list) |
2nd pass of parsing a ncx_list_t Finish converting the list members to the proper format More... | |
ncx_lmem_t * | ncx_new_lmem (void) |
Malloc and fill in a new ncx_lmem_t struct. More... | |
void | ncx_clean_lmem (ncx_lmem_t *lmem, ncx_btype_t btyp) |
Scrub the memory of a ncx_lmem_t but do not delete it. More... | |
void | ncx_free_lmem (ncx_lmem_t *lmem, ncx_btype_t btyp) |
Free all the memory in a ncx_lmem_t struct. More... | |
ncx_lmem_t * | ncx_find_lmem (ncx_list_t *list, const ncx_lmem_t *memval) |
Find a the first matching list member with the specified value. More... | |
void | ncx_insert_lmem (ncx_list_t *list, ncx_lmem_t *memval, ncx_merge_t mergetyp) |
Insert a list entry into the specified list. More... | |
uint32 | ncx_lmem_count (ncx_list_t *list) |
Return the number of list members. More... | |
ncx_lmem_t * | ncx_first_lmem (ncx_list_t *list) |
Return the first list member. More... | |
ncx_lmem_t * | ncx_next_lmem (ncx_lmem_t *cur) |
Return the next list member. More... | |
status_t | ncx_add_strlist (const xmlChar *liststr, uint32 liststrlen, ncx_list_t *list) |
add a string as a complete list member to an initialized list must be type NCX_BT_STRING More... | |
const xmlChar * | ncx_get_lmem_strval (const ncx_lmem_t *lmem) |
Get the string value from an lmem must be type NCX_BT_STRING. More... | |
xmlChar * | ncx_list_to_string (const ncx_list_t *list) |
Convert a list into a string with spaces between the entries. More... | |
status_t | ncx_add_bit_to_list (ncx_list_t *list, uint32 bitpos, const xmlChar *bitname) |
Add a lmem struct for a bits list. More... | |
NCX Lists are simple string based lists.
Originally used to support xsd:list data types. Now YANG bits data type uses the ncx_list_t structure.
status_t ncx_add_bit_to_list | ( | ncx_list_t * | list, |
uint32 | bitpos, | ||
const xmlChar * | bitname | ||
) |
Add a lmem struct for a bits list.
Make a finished lmem struct for a bit and add to end MUST INSERT BITS IN ORDER FOR INTERNAL PROCESSING TO WORK Does not check for duplicates!
list | list struct to add new ncx_lmem_t struct |
bitpos | bit position to add |
bitname | bit name to add |
status_t ncx_add_strlist | ( | const xmlChar * | liststr, |
uint32 | liststrlen, | ||
ncx_list_t * | list | ||
) |
add a string as a complete list member to an initialized list must be type NCX_BT_STRING
liststr | list string to add |
liststrlen | length od liststr |
list | ncx_list_t that should be initialized and filled with the values from the string |
void ncx_clean_list | ( | ncx_list_t * | list | ) |
Scrub the memory of a ncx_list_t but do not delete it.
list | ncx_list_t struct to clean |
void ncx_clean_lmem | ( | ncx_lmem_t * | lmem, |
ncx_btype_t | btyp | ||
) |
Scrub the memory of a ncx_lmem_t but do not delete it.
lmem | ncx_lmem_t struct to clean |
btyp | base type of list member (lmem) |
int32 ncx_compare_lists | ( | const ncx_list_t * | list1, |
const ncx_list_t * | list2 | ||
) |
Compare 2 ncx_list_t struct contents.
Expected data type (NCX_BT_SLIST)
list1 | first list to compare |
list2 | second list to compare |
-1 if list1 is < list2 0 if list1 == list2 (also for error, after SET_ERROR called) 1 if list1 is > list2
status_t ncx_copy_list | ( | const ncx_list_t * | list1, |
ncx_list_t * | list2 | ||
) |
Copy the contents of list1 to list2 Supports base type NCX_BT_SLIST.
A partial copy may occur, and list2 should be properly cleaned and freed, even if an error is returned
list1 | copy from list |
list2 | copy to list |
ncx_lmem_t * ncx_find_lmem | ( | ncx_list_t * | list, |
const ncx_lmem_t * | memval | ||
) |
Find a the first matching list member with the specified value.
list | list to check |
memval | value to find, based on list->btyp |
status_t ncx_finish_list | ( | typ_def_t * | typdef, |
ncx_list_t * | list | ||
) |
2nd pass of parsing a ncx_list_t Finish converting the list members to the proper format
Used by YANG compiler only
typdef | typ_def_t for the designated list member type | |
[in,out] | list | == list struct with ncx_lmem_t structs to check
|
* If return other than NO_ERR: * each list->lmem.flags field may contain bits set * for errors: * NCX_FL_RANGE_ERR: size out of range * NCX_FL_VALUE_ERR value not permitted by value set, * or pattern
ncx_lmem_t * ncx_first_lmem | ( | ncx_list_t * | list | ) |
Return the first list member.
list | list to check |
void ncx_free_list | ( | ncx_list_t * | list | ) |
Clean and free an allocated ncx_list_t.
list | pointer to ncx_list_t memory |
void ncx_free_lmem | ( | ncx_lmem_t * | lmem, |
ncx_btype_t | btyp | ||
) |
Free all the memory in a ncx_lmem_t struct.
lmem | struct to clean and free |
btyp | base type of the list member |
const xmlChar * ncx_get_lmem_strval | ( | const ncx_lmem_t * | lmem | ) |
Get the string value from an lmem must be type NCX_BT_STRING.
lmem | list member to check |
void ncx_init_list | ( | ncx_list_t * | list, |
ncx_btype_t | btyp | ||
) |
Initialize an allocated ncx_list_t.
Called when ncx_list_t is static inside another struct
list | pointer to ncx_list_t memory |
btyp | base type of each list member desired |
void ncx_insert_lmem | ( | ncx_list_t * | list, |
ncx_lmem_t * | memval, | ||
ncx_merge_t | mergetyp | ||
) |
Insert a list entry into the specified list.
list | list to insert into |
memval | value to insert, based on list->btyp |
mergetyp | requested merge type for the insertion |
uint32 ncx_list_cnt | ( | const ncx_list_t * | list | ) |
Get the number of entries in the list.
list | pointer to ncx_list_t memory |
boolean ncx_list_empty | ( | const ncx_list_t * | list | ) |
Check if the list is empty or not.
list | pointer to ncx_list_t memory to check |
uint32 ncx_list_linelen | ( | const ncx_list_t * | list | ) |
Get the length of the string if the list was printed in 1 line with spaces between the entries.
list | pointer to ncx_list_t memory to check |
xmlChar * ncx_list_to_string | ( | const ncx_list_t * | list | ) |
Convert a list into a string with spaces between the entries.
list | pointer to ncx_list_t memory to convert |
uint32 ncx_lmem_count | ( | ncx_list_t * | list | ) |
Return the number of list members.
list | list to check |
void ncx_merge_list | ( | ncx_list_t * | src, |
ncx_list_t * | dest, | ||
ncx_merge_t | mergetyp, | ||
boolean | allow_dups | ||
) |
The merge function is handled specially for lists.
The contents are not completely replaced like a string. Instead, only new entries from src are added to the dest list.
NCX merge algorithm for lists:
If list types not the same, then error exit;
If allow_dups == FALSE: check if entry exists; if so, exit; Merge src list member into dest, based on mergetyp enum
src | ncx_list_t struct to merge from | |
[in,out] | dest | ncx_list_t struct to merge into
|
mergetyp | type of merge used for this list | |
allow_dups | TRUE if this list allows duplicate values |
ncx_list_t * ncx_new_list | ( | ncx_btype_t | btyp | ) |
Malloc Initialize an allocated ncx_list_t.
btyp | base type of each list member desired |
ncx_lmem_t * ncx_new_lmem | ( | void | ) |
Malloc and fill in a new ncx_lmem_t struct.
This is a list member used within an ncx_list_t
ncx_lmem_t * ncx_next_lmem | ( | ncx_lmem_t * | cur | ) |
Return the next list member.
cur | current lmem to check |
status_t ncx_replace_list | ( | const ncx_list_t * | src, |
ncx_list_t * | dest | ||
) |
The replace function is handled specially for lists.
The destination list is cleaned and then the src list is copied into the dest list. Only the dest list is altered.
src | ncx_list_t struct to replace from | |
[in,out] | dest | ncx_list_t struct to replace into
|
status_t ncx_set_list | ( | ncx_btype_t | btyp, |
const xmlChar * | strval, | ||
ncx_list_t * | list | ||
) |
consume a generic string list with base type checking Parse the XML input as an NCX_BT_SLIST
Do not check the individual strings against any restrictions Just check that the strings parse as the expected type. Mark list members with errors as needed
Must call ncx_init_list first!!!
btyp | expected basetype for the list member type | |
strval | cleaned XML string to parse into ncx_str_t or ncx_num_t values | |
[in,out] | list | ncx_list_t in progress that will get the ncx_lmem_t structs added to it, as they are parsed
|
status_t ncx_set_strlist | ( | const xmlChar * | liststr, |
ncx_list_t * | list | ||
) |
Consume a generic string list with no type checking.
Convert a text line into an ncx_list_t using NCX_BT_STRING as the list type.
liststr | list value in string form | |
[out] | list | ncx_list_t that should be initialized and filled with the values from the string
|
boolean ncx_string_in_list | ( | const xmlChar * | str, |
const ncx_list_t * | list | ||
) |
Check if the string value is in the list List type must be string based, or an enum.
str | string to find in the list |
list | list to check |