yumapro  23.10T-7
YumaPro SDK
Loading...
Searching...
No Matches
YANG Simple List (ncx_list_t)

NCX Lists are simple string based lists. More...

Collaboration diagram for YANG Simple List (ncx_list_t):

Functions

ncx_list_tncx_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_tncx_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_tncx_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_tncx_first_lmem (ncx_list_t *list)
 Return the first list member. More...
 
ncx_lmem_tncx_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...
 

Detailed Description

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.

Function Documentation

◆ ncx_add_bit_to_list()

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!

Parameters
listlist struct to add new ncx_lmem_t struct
bitposbit position to add
bitnamebit name to add
Returns
status
Here is the call graph for this function:

◆ ncx_add_strlist()

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

Parameters
liststrlist string to add
liststrlenlength od liststr
listncx_list_t that should be initialized and filled with the values from the string
Returns
status
Here is the call graph for this function:

◆ ncx_clean_list()

void ncx_clean_list ( ncx_list_t list)

Scrub the memory of a ncx_list_t but do not delete it.

Parameters
listncx_list_t struct to clean
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_clean_lmem()

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.

Parameters
lmemncx_lmem_t struct to clean
btypbase type of list member (lmem)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_compare_lists()

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)

Parameters
list1first list to compare
list2second list to compare
Returns
compare value
      -1 if list1 is < list2
       0 if list1 == list2   (also for error, after SET_ERROR called)
       1 if list1 is > list2
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_copy_list()

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

Parameters
list1copy from list
list2copy to list
Returns
status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_find_lmem()

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.

Parameters
listlist to check
memvalvalue to find, based on list->btyp
Returns
pointer to the first instance of this value, or NULL if none
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_finish_list()

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

Parameters
typdeftyp_def_t for the designated list member type
[in,out]list== list struct with ncx_lmem_t structs to check
  • list->lmem
*   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
Returns
status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_first_lmem()

ncx_lmem_t * ncx_first_lmem ( ncx_list_t list)

Return the first list member.

Parameters
listlist to check
Returns
pointer to the first list member or NULL if none
See also
ncx_next_lmem
Here is the caller graph for this function:

◆ ncx_free_list()

void ncx_free_list ( ncx_list_t list)

Clean and free an allocated ncx_list_t.

Parameters
listpointer to ncx_list_t memory
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_free_lmem()

void ncx_free_lmem ( ncx_lmem_t lmem,
ncx_btype_t  btyp 
)

Free all the memory in a ncx_lmem_t struct.

Parameters
lmemstruct to clean and free
btypbase type of the list member
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_get_lmem_strval()

const xmlChar * ncx_get_lmem_strval ( const ncx_lmem_t lmem)

Get the string value from an lmem must be type NCX_BT_STRING.

Parameters
lmemlist member to check
Returns
pointer to string value in the lmem

◆ ncx_init_list()

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

Parameters
listpointer to ncx_list_t memory
btypbase type of each list member desired
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_insert_lmem()

void ncx_insert_lmem ( ncx_list_t list,
ncx_lmem_t memval,
ncx_merge_t  mergetyp 
)

Insert a list entry into the specified list.

Parameters
listlist to insert into
memvalvalue to insert, based on list->btyp
mergetyprequested merge type for the insertion
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_list_cnt()

uint32 ncx_list_cnt ( const ncx_list_t list)

Get the number of entries in the list.

Parameters
listpointer to ncx_list_t memory
Returns
number of entries counted
Here is the caller graph for this function:

◆ ncx_list_empty()

boolean ncx_list_empty ( const ncx_list_t list)

Check if the list is empty or not.

Parameters
listpointer to ncx_list_t memory to check
Returns
TRUE if list is empty; FALSE otherwise
Here is the caller graph for this function:

◆ ncx_list_linelen()

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.

Parameters
listpointer to ncx_list_t memory to check
Returns
length of string that would occur if printed in 1 line
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_list_to_string()

xmlChar * ncx_list_to_string ( const ncx_list_t list)

Convert a list into a string with spaces between the entries.

Parameters
listpointer to ncx_list_t memory to convert
Returns
malloced string for the list
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_lmem_count()

uint32 ncx_lmem_count ( ncx_list_t list)

Return the number of list members.

Parameters
listlist to check
Returns
number of list members found
Here is the call graph for this function:

◆ ncx_merge_list()

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

Parameters
srcncx_list_t struct to merge from
[in,out]destncx_list_t struct to merge into
  • dest ncx_lmem_t structs will be moved from the src to dest as needed
mergetyptype of merge used for this list
allow_dupsTRUE if this list allows duplicate values
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_new_list()

ncx_list_t * ncx_new_list ( ncx_btype_t  btyp)

Malloc Initialize an allocated ncx_list_t.

Parameters
btypbase type of each list member desired
Returns
pointer to new entry, or NULL if memory error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_new_lmem()

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

Returns
pointer to malloced and initialized ncx_lmem_t struct NULL if malloc error
Here is the caller graph for this function:

◆ ncx_next_lmem()

ncx_lmem_t * ncx_next_lmem ( ncx_lmem_t cur)

Return the next list member.

Parameters
curcurrent lmem to check
Returns
pointer to the next list member or NULL if none
See also
ncx_first_lmem
Here is the caller graph for this function:

◆ ncx_replace_list()

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.

Parameters
srcncx_list_t struct to replace from
[in,out]destncx_list_t struct to replace into
  • dest ncx_lmem_t structs will be copied from the src to dest as needed
Returns
status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_set_list()

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!!!

Parameters
btypexpected basetype for the list member type
strvalcleaned XML string to parse into ncx_str_t or ncx_num_t values
[in,out]listncx_list_t in progress that will get the ncx_lmem_t structs added to it, as they are parsed
  • list->memQ has 1 or more ncx_lmem_t structs appended to it
Returns
status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_set_strlist()

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.

Parameters
liststrlist value in string form
[out]listncx_list_t that should be initialized and filled with the values from the string
  • list filled in from liststr values
Returns
status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_string_in_list()

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.

Parameters
strstring to find in the list
listlist to check
Returns
TRUE if string is found; FALSE otherwise
Here is the call graph for this function:
Here is the caller graph for this function: