Input Output Element Management APIs are used to set the value to, or retrieve the value from, the input output (I/O) element. I/O elements are similar to XML containers; they have a name-value pair. You can nest them arbitrarily within other elements.
This page contains information about the Input Output Element Management APIs for C and C++, including the description and syntax, and the input, input types, input description, and input return values.
Prototype
na_elem_t* na_child_add(na_elem_t* elt, na_elem_t* childelt);
Description
Adds the nested child element childelt to the parent element elt.
All nested elements are unordered and are accessed by their name. However, this API adds the child element to the end of the nested element list.
|
Input |
Type |
Description |
|
elt |
na_elem_t* |
The pointer to the parent element. |
|
childelt |
na_elem_t* |
The pointer to the child element that is to be added to the parent element elt. |
Return value
The address of the child element
NULL in case of failure
Prototype
na_elem_t* na_child_add_int(na_elem_t * elt, const char * name, int value);
Description
Creates a new child element with the given name and value of type integer.
Adds this child element to the nested element list of the parent element.
|
Input |
Type |
Description |
|
elt |
na_elem_t* |
The pointer to the parent element. |
|
name |
const char * |
The name of the child element. |
|
value |
int |
The value to be assigned to the child element. |
Return value
The address of the child element
NULL on failure
Prototype
na_elem_t * na_child_add_int64(na_elem_t * e, const char * name, int64_t value);
Description
Creates a new child element with the given name and value of type 64-bit integer.
Adds this child element to the nested element list of the parent element.
|
Input |
Type |
Description |
|
elt |
na_elem_t* |
The pointer to the parent element. |
|
name |
const char * |
The name of the child element. |
|
value |
int64_t |
The 64-bit integer value to be assigned to the child element. |
Return value
The address of the child element
NULL on failure
na_elem_t* na_child_add_uint32(na_elem_t * e, const char * name, uint32_t value);
Creates a new child element with the given name and value of type 32-bit unsigned integer.
Adds this child element to the nested element list of the parent element.
|
Input |
Type |
Description |
|
elt |
na_elem_t* |
The pointer to the parent element. |
|
name |
const char * |
The name of the child element. |
|
value |
uint32_t |
The 32-bit unsigned integer value to be assigned to the child element. |
The address of the child element
NULL on failure
Prototype
na_elem_t * na_child_add_uint64(na_elem_t * e, const char * name, uint64_t value);
Description
Creates a new child element with the given name and value of type 64-bit unsigned integer.
Adds this child element to the nested element list of the parent element.
|
Input |
Type |
Description |
|
elt |
na_elem_t* |
The pointer to the parent element. |
|
name |
const char * |
The name of the child element. |
|
value |
uint64_t |
The 64-bit unsigned integer value to be assigned to the child element. |
Return value
The address of the child element
NULL on failure
Prototype
na_elem_t* na_child_add_string(na_elem_t* elt, const char* name, const char* value);
Description
Creates a new child element with the given name and value.
Adds this child element to the nested element list of elt.
|
Input |
Type |
Description |
|
elt |
na_elem_t* |
The pointer to the parent element. |
|
name |
const char * |
The name of the child element. |
|
value |
char * |
The value to be assigned to the child element. |
Return value
The address of the child element
NULL on failure
Prototype
na_elem_t* na_child_add_string_encrypted(na_elem_t* elt, const char* name, const char* value, const char* key);
Description
Creates a new element with the given name and value pair.
Encrypts the data contained in the value with the encryption key.
Adds this child element to the nested element list of the parent element.
|
Input |
Type |
Description |
|
elt |
na_elem_t * |
The pointer to the parent element. |
|
name |
const char * |
The name of the child element. |
|
value |
const char * |
The value to be assigned to the child element. |
|
key |
const char* |
The encryption key. |
Return value
The address of the child element
NULL on failure
Prototype
int na_elem_set_content(na_elem_t* elt, const char* value);
Description
Sets or modifies the value of the given element.
The value to be set can only be of string type. If a non-string value is required to be set, then it should be converted to string first and then passed to this API.
|
Input |
Type |
Description |
|
elt |
na_elem_t * |
The pointer to the element. |
|
name |
const char * |
The value of the element that is to be set. |
Return value
1 (TRUE) on success
0 (FALSE) on failure
Prototype
bool_t na_child_get_bool(na_elem_t * elt, const char * name, bool_t deflt);
Description
Gets the boolean value of the given child element, which is nested under the element elt.
|
Input |
Type |
Description |
|
elt |
na_elem_t * |
The pointer to the parent element. |
|
name |
const char * |
The name of the child element. |
|
deflt |
bool_t |
The default boolean value. |
Return value
The boolean value of the child element
The default value deflt, under the following conditions:
The child element does not exist
The child element does not contain any value
False if the child element value is 0, "no", "off", or "false"
True in all other cases
Prototype
int na_child_get_int(na_elem_t *, const char *, int);
Description
Gets the integer value of the given child element, which is nested under the element elt.
|
Input |
Type |
Description |
|
elt |
na_elem_t * |
The pointer to the parent element. |
|
name |
const char * |
The name of the child element. |
|
deflt |
int |
The default integer value. |
Return value
An integer value of the child element
The default value deflt, under the following conditions:
The child element does not exist
The child element does not contain any value
Prototype
int64_t na_child_get_int64(na_elem_t * e, const char * name, int64_t deflt);
Description
Gets the 64-bit integer value of the given child element, which is nested under the element elt.
|
Input |
Type |
Description |
|
elt |
na_elem_t * |
The pointer to the parent element. |
|
name |
const char * |
The name of the child element. |
|
deflt |
int64_t |
The default 64-bit integer value. |
Return value
An 64-bit integer value of the child element
The default value deflt, under the following conditions:
The child element does not exist
The child element does not contain any value
uint32_t na_child_get_uint32(na_elem_t * e, const char * name, uint32_t deflt);
Gets the 32-bit unsigned integer value of the given child element, which is nested under element elt.
|
Input |
Type |
Description |
|
elt |
na_elem_t * |
The pointer to the parent element. |
|
name |
const char * |
The name of the child element. |
|
deflt |
int64_t |
The default 32-bit integer value. |
A 32-bit unsigned integer value of the child element
The default value deflt, under the following conditions:
The child element does not exist
The child element does not contain any value
uint64_t na_child_get_uint64(na_elem_t * e, const char * name, uint64_t deflt);
Description
Gets the 64-bit unsigned integer value of the given child element, which is nested under the element elt.
|
Input |
Type |
Description |
|
elt |
na_elem_t * |
The pointer to the parent element. |
|
name |
const char * |
The name of the child element. |
|
deflt |
uint64_t |
The default 64-bit unsigned integer value. |
Return value
An 64-bit unsigned integer value of the child element
The default value deflt, under the following conditions:
The child element does not exist
The child element does not contain any value
Prototype
const char* na_child_get_string(na_elem_t* elt, const char* name);
Description
Gets the string value of the given child element, which is nested under the element elt.
|
Input |
Type |
Description |
|
elt |
na_elem_t * |
The pointer to the parent element. |
|
name |
const char * |
The name of the child element. |
Return value
The string value of the given child element
NULL if the given child element does not exist
Prototype
char* na_child_get_string_encrypted(na_elem_t* elt, const char* name, const char* key);
Description
Gets the decrypted string value of the given child element, which is nested under element elt.
The string is decrypted using the given key. The default key is used if the given key is NULL. The system allocates memory for the decrypted data. You must explicitly free it with na_free() after the API call is over.
|
Input |
Type |
Description |
|
elt |
na_elem_t * |
The pointer to the parent element. |
|
name |
const char * |
The name of the child element. |
|
key |
const char * |
The decrypt key. |
Return value
The pointer to the decrypted data
NULL on failure
Prototype
na_elem_t* na_elem_child(na_elem_t* elt, const char* eltname);
Description
Gets the child element address, which is nested under the element elt.
|
Input |
Type |
Description |
|
elt |
na_elem_t * |
The pointer to the parent element. |
|
eltname |
const char * |
The name of the child element. |
Return value
The address of the child element
NULL if the child element is not found
Prototype
const char* na_elem_get_content(na_elem_t * elt);
Description
Gets the content of the element elt.
|
Input |
Type |
Description |
|
elt |
na_elem_t * |
The pointer to the element. |
Return value
The content of the element
NULL if the content of the element is not found
Prototype
const char* na_elem_get_name(na_elem_t * e);
Description
Gets the name of the element.
|
Input |
Type |
Description |
|
elt |
na_elem_t * |
The pointer to the element. |
Return value
The name of the given element
An empty string if the name of the element is NULL
NULL if the element is NULL
Prototype
int na_elem_has_children(na_elem_t* elt);
Description
Checks whether the element has any nested elements within it.
|
Input |
Type |
Description |
|
elt |
na_elem_t * |
The pointer to the element. |
Return value
1 (TRUE) if the element has any children
0 (FALSE) if the element has no children
Prototype
void na_encrypt_basic(const char *key, const char* input, char * output, int nbytes);
Description
Takes an input value (as a series of bytes).
Encrypts the data.
Assumptions:
The encryption-key must be 16 characters.
The output space provided is at least as long as the input space.
|
Input |
Type |
Description |
|
key |
const char * |
The encryption key. |
|
input |
const char * |
The string to be encrypted. |
|
output |
char * |
The string that is encrypted. |
|
nBytes |
int |
The number of bytes of the input string. |
Return value
None
Prototype
na_elem_iter_t na_child_iterator(na_elem_t* elt);
Description
Sets an iterator for traversing the child elements of elt.
You call na_iterator_next() on this iterator to walk through the nested element list.
|
Input |
Type |
Description |
|
elt |
na_elem_t * |
The pointer to the element. |
Return value
The element iterator for looping through the children of an element
Prototype
na_elem_t* na_iterator_next(na_elem_iter_t* tag);
Description
Repeatedly iterates through all the children of elt for a given tag returned by the na_child_iterator(elt).
|
Input |
Type |
Description |
|
tag |
na_elem_iter_t* |
The pointer to the iterator. |
Return value
The next item from an iterator
Prototype
na_elem_t* na_zapi_get_elem_from_raw_xmlinput(char * val);
Description
Retrieves the API element from a raw XML input.
|
Input |
Type |
Description |
|
val |
char * |
The pointer to the raw XML input. |
Return value
The pointer to the API element for a given raw XML
Prototype
char* na_elem_sprintf(na_elem_t* elt);
Description
Gets the content of the input output element in XML format and writes into a string buffer.
You should free the returned buffer using na_free().
|
Input |
Type |
Description |
|
elt |
na_elem_t * |
The pointer to the input output element. |
Return value:
The string with the contents of the input output element in XML format, terminated with a new line
NULL on failure