Guardtime KSI c SDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Structures | Typedefs | Enumerations | Functions
fast_tlv.h File Reference
#include <stdio.h>

Go to the source code of this file.

Data Structures

struct  fast_tlv_s
 

Typedefs

typedef struct fast_tlv_s KSI_FTLV
 

Enumerations

enum  KSI_Serialize_Opt_en { KSI_TLV_OPT_NO_HEADER = 0x01, KSI_TLV_OPT_NO_MOVE = 0x02 }
 

Functions

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)
 

Typedef Documentation

typedef struct fast_tlv_s KSI_FTLV

Enumeration Type Documentation

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.

Function Documentation

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]fFile descriptor.
[in]bufPointer to memory buffer.
[in]lenLength of the buffer.
[out]consumedNumber of bytes read.
[in]tPointer 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]mPointer to the memory buffer.
[in]lLength of the buffer.
[in]tPointer 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]bufPointer to the memory buffer.
[in]buf_lenLength of the buffer.
[in]arrPointer to the output buffer (can be NULL).
[in]arr_lenLength of the output buffer (must be equal to 0, if arr is NULL).
[out]rdOutput 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]fdSocket descriptor.
[in]bufPointer to memory buffer.
[in]lenLength of the buffer.
[out]consumedNumber of bytes read.
[in]tPointer to the KSI_FTLV object.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).