#include <stdio.h>
Go to the source code of this file.
|
int | KSI_FTLV_fileRead (FILE *f, unsigned char *buf, size_t len, size_t *consumed, struct fast_tlv_s *t) |
|
int | KSI_FTLV_socketRead (int fd, unsigned char *buf, size_t len, size_t *consumed, KSI_FTLV *t) |
|
int | KSI_FTLV_memRead (const unsigned char *m, size_t l, KSI_FTLV *t) |
|
int | KSI_FTLV_memReadN (const unsigned char *buf, size_t buf_len, KSI_FTLV *arr, size_t arr_len, size_t *rd) |
|
Enumerator |
---|
KSI_TLV_OPT_NO_HEADER |
Do not write the header while serializing.
|
KSI_TLV_OPT_NO_MOVE |
Keep the TLV serialized to the end of the buffer.
|
int KSI_FTLV_fileRead |
( |
FILE * |
f, |
|
|
unsigned char * |
buf, |
|
|
size_t |
len, |
|
|
size_t * |
consumed, |
|
|
struct fast_tlv_s * |
t |
|
) |
| |
Read the TLV from a file.
- Parameters
-
[in] | f | File descriptor. |
[in] | buf | Pointer to memory buffer. |
[in] | len | Length of the buffer. |
[out] | consumed | Number of bytes read. |
[in] | t | Pointer to the KSI_FTLV object. |
- Returns
- status code (
KSI_OK
, when operation succeeded, otherwise an error code).
int KSI_FTLV_memRead |
( |
const unsigned char * |
m, |
|
|
size_t |
l, |
|
|
KSI_FTLV * |
t |
|
) |
| |
Read the TLV from a memory buffer. This function will try to parse as much information as possible even if the input is not complete (e.g. even the header is not fully available). It will return KSI_OK only if the header is fully available.
- Parameters
-
[in] | m | Pointer to the memory buffer. |
[in] | l | Length of the buffer. |
[in] | t | Pointer to the KSI_FTLV object. |
- Returns
- status code (
KSI_OK
, when operation succeeded, otherwise an error code).
- Note
- The function does not initiate the output variable if there is an issue parsing the TLV.
int KSI_FTLV_memReadN |
( |
const unsigned char * |
buf, |
|
|
size_t |
buf_len, |
|
|
KSI_FTLV * |
arr, |
|
|
size_t |
arr_len, |
|
|
size_t * |
rd |
|
) |
| |
Reads up to arr_len
TLV's from the buffer. The number of read elements is returned via rd
output parameter. If the arr
pointer is set to NULL
and arr_len
equals 0, the function calculates the required length for the buffer arr
.
- Parameters
-
[in] | buf | Pointer to the memory buffer. |
[in] | buf_len | Length of the buffer. |
[in] | arr | Pointer to the output buffer (can be NULL ). |
[in] | arr_len | Length of the output buffer (must be equal to 0, if arr is NULL ). |
[out] | rd | Output parameter for the number of TLV read (can be NULL ). |
- Returns
- status code (
KSI_OK
, when operation succeeded, otherwise an error code).
- Note
- This method is using optimized to do as little copy operations as possible. In case of an error during this process, the buffer will probably get corrupted. If this corruption of the buffer is an issue, you may call this function twice - the first time just leave
arr
as NULL
and arr_len
equal to 0.
int KSI_FTLV_socketRead |
( |
int |
fd, |
|
|
unsigned char * |
buf, |
|
|
size_t |
len, |
|
|
size_t * |
consumed, |
|
|
KSI_FTLV * |
t |
|
) |
| |
Read the TLV from a socket.
- Parameters
-
[in] | fd | Socket descriptor. |
[in] | buf | Pointer to memory buffer. |
[in] | len | Length of the buffer. |
[out] | consumed | Number of bytes read. |
[in] | t | Pointer to the KSI_FTLV object. |
- Returns
- status code (
KSI_OK
, when operation succeeded, otherwise an error code).