#include "ksi.h"
#include "fast_tlv.h"
#include "list.h"
Go to the source code of this file.
|
#define | KSI_TlvElementList_append(lst, o) KSI_APPLY_TO_NOT_NULL((lst), append, ((lst), (o))) |
|
#define | KSI_TlvElementList_remove(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), removeElement, ((lst), (pos), (o))) |
|
#define | KSI_TlvElementList_indexOf(lst, o, i) KSI_APPLY_TO_NOT_NULL((lst), indexOf, ((lst), (o), (i))) |
|
#define | KSI_TlvElementList_insertAt(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), insertAt, ((lst), (pos), (o))) |
|
#define | KSI_TlvElementList_replaceAt(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), replaceAt, ((lst), (pos), (o))) |
|
#define | KSI_TlvElementList_elementAt(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), elementAt, ((lst), (pos), (o))) |
|
#define | KSI_TlvElementList_length(lst) (((lst) != NULL && (lst)->length != NULL) ? (lst)->length((lst)) : 0) |
|
#define | KSI_TlvElementList_sort(lst, cmp) KSI_APPLY_TO_NOT_NULL((lst), sort, ((lst), (cmp))) |
|
#define | KSI_TlvElementList_foldl(lst, foldCtx, foldFn) (((lst) != NULL) ? (((lst)->foldl != NULL) ? ((lst)->foldl((lst), (foldCtx), (foldFn))) : KSI_INVALID_STATE) : KSI_OK) |
|
#define | KSI_TlvElementList_find(lst, o, f, i) KSI_APPLY_TO_NOT_NULL((lst), find, ((lst), (o), (f), (i))) |
|
|
int | KSI_TlvElementList_new (KSI_TlvElementList **list) |
|
void | KSI_TlvElementList_free (KSI_TlvElementList *list) |
|
KSI_TlvElement * | KSI_TlvElement_ref (KSI_TlvElement *o) |
|
int | KSI_TlvElement_new (KSI_TlvElement **out) |
|
int | KSI_TlvElement_parse (unsigned char *dat, size_t dat_len, KSI_TlvElement **out) |
|
int | KSI_TlvElement_detach (KSI_TlvElement *el) |
|
void | KSI_TlvElement_free (KSI_TlvElement *t) |
|
int | KSI_TlvElement_serialize (const KSI_TlvElement *element, unsigned char *buf, size_t buf_size, size_t *len, int opt) |
|
int | KSI_TlvElement_appendElement (KSI_TlvElement *parent, KSI_TlvElement *child) |
|
int | KSI_TlvElement_setElement (KSI_TlvElement *parent, KSI_TlvElement *child) |
|
int | KSI_TlvElement_getElement (KSI_TlvElement *parent, unsigned tag, KSI_TlvElement **el) |
|
int | KSI_TlvElement_removeElement (KSI_TlvElement *parent, unsigned tag, KSI_TlvElement **el) |
|
int | KSI_TlvElement_getUtf8String (KSI_TlvElement *parent, KSI_CTX *ctx, unsigned tag, KSI_Utf8String **out) |
|
int | KSI_TlvElement_getOctetString (KSI_TlvElement *parent, KSI_CTX *ctx, unsigned tag, KSI_OctetString **out) |
|
int | KSI_TlvElement_getInteger (KSI_TlvElement *parent, KSI_CTX *ctx, unsigned tag, KSI_Integer **out) |
|
int | KSI_TlvElement_setUtf8String (KSI_TlvElement *parent, unsigned tag, KSI_Utf8String *value) |
|
int | KSI_TlvElement_setOctetString (KSI_TlvElement *parent, unsigned tag, KSI_OctetString *value) |
|
int | KSI_TlvElement_setInteger (KSI_TlvElement *parent, unsigned tag, KSI_Integer *value) |
|
#define KSI_TlvElementList_elementAt |
( |
|
lst, |
|
|
|
pos, |
|
|
|
o |
|
) |
| KSI_APPLY_TO_NOT_NULL((lst), elementAt, ((lst), (pos), (o))) |
#define KSI_TlvElementList_find |
( |
|
lst, |
|
|
|
o, |
|
|
|
f, |
|
|
|
i |
|
) |
| KSI_APPLY_TO_NOT_NULL((lst), find, ((lst), (o), (f), (i))) |
#define KSI_TlvElementList_foldl |
( |
|
lst, |
|
|
|
foldCtx, |
|
|
|
foldFn |
|
) |
| (((lst) != NULL) ? (((lst)->foldl != NULL) ? ((lst)->foldl((lst), (foldCtx), (foldFn))) : KSI_INVALID_STATE) : KSI_OK) |
#define KSI_TlvElementList_indexOf |
( |
|
lst, |
|
|
|
o, |
|
|
|
i |
|
) |
| KSI_APPLY_TO_NOT_NULL((lst), indexOf, ((lst), (o), (i))) |
#define KSI_TlvElementList_insertAt |
( |
|
lst, |
|
|
|
pos, |
|
|
|
o |
|
) |
| KSI_APPLY_TO_NOT_NULL((lst), insertAt, ((lst), (pos), (o))) |
#define KSI_TlvElementList_length |
( |
|
lst | ) |
(((lst) != NULL && (lst)->length != NULL) ? (lst)->length((lst)) : 0) |
#define KSI_TlvElementList_remove |
( |
|
lst, |
|
|
|
pos, |
|
|
|
o |
|
) |
| KSI_APPLY_TO_NOT_NULL((lst), removeElement, ((lst), (pos), (o))) |
#define KSI_TlvElementList_replaceAt |
( |
|
lst, |
|
|
|
pos, |
|
|
|
o |
|
) |
| KSI_APPLY_TO_NOT_NULL((lst), replaceAt, ((lst), (pos), (o))) |
Append an element as the last child. The caller is responsible of freeing the sub element.
- Parameters
-
[in] | parent | The parent element. |
[in] | child | The child element. |
- Returns
- status code (KSI_OK, when operation succeeded, otherwise an error code).
This function detaches the element from outer resources. This is useful after KSI_TlvElement_parse function call if the underlying pointer needs to be reused or if the element has been altered (new sub-elements added or removed).
- Parameters
-
- Returns
- status code (KSI_OK, when operation succeeded, otherwise an error code).
Find and extract a sub element. The output variable will be NULL
if the element does not exist. If there are more than one elements with the given tag, the process will fail with an error.
- Parameters
-
[in] | parent | Parent element. |
[in] | tag | Tag value of the element being extracted. |
[out] | el | Pointer to the receiving pointer. |
- Returns
- status code (KSI_OK, when operation succeeded, otherwise an error code).
- Note
- It is the responsibility of the caller to free the output element.
Access method for a nested KSI_Integer value by the given tag. If there is no value with the specified tag, the output is evaluated to NULL
.
- Parameters
-
[in] | parent | Pointer to the parent element. |
[in] | ctx | KSI context. |
[in] | tag | Tag of the requested element. |
[out] | out | Pointer to the receiving pointer. |
- Note
- The output object must be free by the caller.
- Returns
- status code (KSI_OK, when operation succeeded, otherwise an error code).
Access method for a nested KSI_OctetString value by the given tag. If there is no value with the specified tag, the output is evaluated to NULL
.
- Parameters
-
[in] | parent | Pointer to the parent element. |
[in] | ctx | KSI context. |
[in] | tag | Tag of the requested element. |
[out] | out | Pointer to the receiving pointer. |
- Note
- The output object must be free by the caller.
- Returns
- status code (KSI_OK, when operation succeeded, otherwise an error code).
Access method for a nested KSI_Utf8String value by the given tag. If there is no value with the specified tag, the output is evaluated to NULL
.
- Parameters
-
[in] | parent | Pointer to the parent element. |
[in] | ctx | KSI context. |
[in] | tag | Tag of the requested element. |
[out] | out | Pointer to the receiving pointer. |
- Note
- The output object must be free by the caller.
- Returns
- status code (KSI_OK, when operation succeeded, otherwise an error code).
Creates a new KSI_TlvElement.
- Parameters
-
[out] | out | Pointer to the receiving pointer. |
- Returns
- status code (KSI_OK, when operation succeeded, otherwise an error code).
int KSI_TlvElement_parse |
( |
unsigned char * |
dat, |
|
|
size_t |
dat_len, |
|
|
KSI_TlvElement ** |
out |
|
) |
| |
Parses the input as a KSI_TlvElement object. The parsing process does not consume the input data pointer thus the data pointer may not be freed or modified. To detatch the data pointer from the object use KSI_TlvElement_detach.
- Parameters
-
[in] | dat | Pointer to the serialized TLV. |
[in] | dat_len | Length of the serialized TLV. |
[out] | out | Pointer to the receiving pointer. |
- Returns
- status code (KSI_OK, when operation succeeded, otherwise an error code).
- See also
- KSI_TlvElement_free, KSI_TlvElement_detach.
- Increases the inner reference count of that object. *
- Parameters
-
- Returns
- Returns the input pointer on success or
NULL
on error. *
- See also
- KSI_TlvElement_free
Removes a child element with the specified TLV tag. The process will fail if there is more than one element or no elements with the same tag. If output variable el
is not NULL
, the caller is responsible of freeing the removed element.
- Parameters
-
[in] | parent | The parent element. |
[in] | tag | Tag value of the element being removed. |
[out] | el | Pointer to the receiving pointer. |
- Returns
- status code (KSI_OK, when operation succeeded, otherwise an error code).
int KSI_TlvElement_serialize |
( |
const KSI_TlvElement * |
element, |
|
|
unsigned char * |
buf, |
|
|
size_t |
buf_size, |
|
|
size_t * |
len, |
|
|
int |
opt |
|
) |
| |
This function serializes the KSI_TlvElement. The buffer buf
may be NULL, but only if the buffer size buf_size
is equal to 0 - this can be used to calculate the length of the serialized value and after that allocate the buffer.
- Parameters
-
[in] | element | Pointer to the KSI_TlvElement. |
[in] | buf | Pointer to the buffer where to serialize the element. |
[in] | buf_size | Size of the buffer. |
[out] | len | Length of the serialized data (may be NULL). |
[in] | opt | Options for serialization. (see KSI_Serialize_Opt_en). |
- Returns
- status code (KSI_OK, when operation succeeded, otherwise an error code).
Inserts or replaces an element with the concrete TLV tag. There process will fail if there are already more than one elements with the same tag. The caller is responsible of freeing the sub element.
- Parameters
-
[in] | parent | The parent element. |
[in] | child | The child element. |
- Returns
- status code (KSI_OK, when operation succeeded, otherwise an error code).
A setter method for a nested KSI_Integer value. If the element already exists as a sub-element of parent
, the sub-element is replaced with the new value.
- Parameters
-
[in] | parent | Pointer to the parent element. |
[in] | tag | Tag of the requested element. |
[out] | value | Pointer to the receiving pointer. |
- Note
- The input value object must be free by the caller.
- Returns
- status code (KSI_OK, when operation succeeded, otherwise an error code).
A setter method for a nested KSI_OctetString value. If the element already exists as a sub-element of parent
, the sub-element is replaced with the new value.
- Parameters
-
[in] | parent | Pointer to the parent element. |
[in] | tag | Tag of the requested element. |
[out] | value | Pointer to the receiving pointer. |
- Note
- The input value object must be free by the caller.
- Returns
- status code (KSI_OK, when operation succeeded, otherwise an error code).
A setter method for a nested KSI_Utf8String value. If the element already exists as a sub-element of parent
, the sub-element is replaced with the new value.
- Parameters
-
[in] | parent | Pointer to the parent element. |
[in] | tag | Tag of the requested element. |
[out] | value | Pointer to the receiving pointer. |
- Note
- The input value object must be free by the caller.
- Returns
- status code (KSI_OK, when operation succeeded, otherwise an error code).