Libtrap: Internal development docs  1.16.1
Functions
Collaboration diagram for File_sender:

Functions

int file_write_buffer (void *priv, const void *data, uint32_t size, int timeout)
 Write data to a file. Data to write are expected as a trap_buffer_header_t structure, thus actual length of data to be written is determined from trap_buffer_header_t->data_length trap_buffer_header_t->data_length is expected to be in network byte order (little endian) More...
 
static void finish_buffer (file_buffer_t *buffer)
 
static void insert_into_buffer (file_buffer_t *buffer, const void *data, uint16_t size)
 
void file_flush (void *priv)
 
static int file_send (void *priv, const void *data, uint16_t size, int timeout)
 Store message into buffer. Write buffer into file if full. If buffering is disabled, the message is sent to the output interface immediately. More...
 
int32_t file_get_client_count (void *priv)
 
int8_t file_get_client_stats_json (void *priv, json_t *client_stats_arr)
 
char * file_send_ifc_get_id (void *priv)
 
int create_file_send_ifc (trap_ctx_priv_t *ctx, const char *params, trap_output_ifc_t *ifc, uint32_t idx)
 Allocate and initiate file output interface. This function is called by TRAP library to initialize one output interface. More...
 

Detailed Description

Function Documentation

◆ create_file_send_ifc()

int create_file_send_ifc ( trap_ctx_priv_t ctx,
const char *  params,
trap_output_ifc_t ifc,
uint32_t  idx 
)

Allocate and initiate file output interface. This function is called by TRAP library to initialize one output interface.

Parameters
[in,out]ctxPointer to the private libtrap context data (trap_ctx_init()).
[in]paramsConfiguration string containing colon separated values of these parameters (in this exact order): file_name:open_mode, where file_name is a path to a file in which data is to be written and open_mode is either a - append or w - write, if no mode is specified, the file will be opened in append mode.
[in,out]ifcIFC interface used for calling file module.
[in]idxIndex of IFC that is created.
Returns
0 on success (TRAP_E_OK), TRAP_E_MEMORY, TRAP_E_BADPARAMS on error

Definition at line 765 of file ifc_file.c.

◆ file_flush()

void file_flush ( void *  priv)

Definition at line 655 of file ifc_file.c.

◆ file_get_client_count()

int32_t file_get_client_count ( void *  priv)

Definition at line 738 of file ifc_file.c.

◆ file_get_client_stats_json()

int8_t file_get_client_stats_json ( void *  priv,
json_t *  client_stats_arr 
)

Definition at line 743 of file ifc_file.c.

◆ file_send()

static int file_send ( void *  priv,
const void *  data,
uint16_t  size,
int  timeout 
)
inlinestatic

Store message into buffer. Write buffer into file if full. If buffering is disabled, the message is sent to the output interface immediately.

Parameters
[in]privpointer to module private data
[in]datapointer to data to write
[in]sizesize of data to write
[in]timeoutNOT USED IN THIS INTERFACE
Returns
TRAP_E_OK Success.
TRAP_E_TIMEOUT Message was not stored into buffer and the attempt should be repeated.
TRAP_E_TERMINATED Libtrap was terminated during the process.

Definition at line 688 of file ifc_file.c.

◆ file_send_ifc_get_id()

char* file_send_ifc_get_id ( void *  priv)

Definition at line 749 of file ifc_file.c.

◆ file_write_buffer()

int file_write_buffer ( void *  priv,
const void *  data,
uint32_t  size,
int  timeout 
)

Write data to a file. Data to write are expected as a trap_buffer_header_t structure, thus actual length of data to be written is determined from trap_buffer_header_t->data_length trap_buffer_header_t->data_length is expected to be in network byte order (little endian)

Parameters
[in]privpointer to module private data
[in]datapointer to data to write
[in]sizesize of data to write - NOT USED IN THIS INTERFACE
[in]timeoutNOT USED IN THIS INTERFACE
Returns
0 on success (TRAP_E_OK), TRAP_E_IO_ERROR if error occurs during writing, TRAP_E_TERMINATED if interface was terminated.

Definition at line 564 of file ifc_file.c.

◆ finish_buffer()

static void finish_buffer ( file_buffer_t buffer)
inlinestatic

Definition at line 640 of file ifc_file.c.

◆ insert_into_buffer()

static void insert_into_buffer ( file_buffer_t buffer,
const void *  data,
uint16_t  size 
)
inlinestatic

Definition at line 647 of file ifc_file.c.