rohc_comp_set_traces_cb2

NAME
SYNOPSIS
DESCRIPTION
PARAMETERS
STRUCTURES
RETURN VALUE
NOTES
EXAMPLE
SEE ALSO

NAME

rohc_comp_set_traces_cb2 − Set the callback function used to manage traces in compressor.

SYNOPSIS

#include <rohc/rohc_comp.h>

bool rohc_comp_set_traces_cb2(
struct rohc_comp *const comp
,
rohc_trace_callback2_t callback
,
void *const priv_ctxt

);

DESCRIPTION

Set the user−defined callback function used to manage traces in the compressor.

The function will be called by the ROHC library every time it wants to print something related to compression, from errors to debug. User may thus decide what traces are interesting (filter on level, source entity, or profile) and what to do with them (print on console, storage in file, syslog...).

PARAMETERS

comp

The ROHC compressor

callback

Two possible cases:

• The callback function used to manage traces

• NULL to remove the previous callback

priv_ctxt

An optional private context, may be NULL

STRUCTURES

RETURN VALUE

true on success, false otherwise

NOTES

The callback can not be modified after library initialization

EXAMPLE

/**
* @brief Callback to print traces of the ROHC library
*
* @param priv_ctxt An optional private context, may be NULL
* @param level The priority level of the trace
* @param entity The entity that emitted the trace among:
* − ROHC_TRACE_COMP
* − ROHC_TRACE_DECOMP
* @param profile The ID of the ROHC compression/decompression profile
* the trace is related to
* @param format The format string of the trace
*/
static void print_rohc_traces(void *const priv_ctxt,
const rohc_trace_level_t level,
const rohc_trace_entity_t entity,
const int profile,
const char *const format,
...)
{
va_list args;
va_start(args, format);
vfprintf(stdout, format, args);
va_end(args);
}

...

struct rohc_comp *compressor; /* the ROHC compressor */

...

compressor = rohc_comp_new2(ROHC_SMALL_CID, ROHC_SMALL_CID_MAX,
gen_random_num, NULL);
if(compressor == NULL)
{
fprintf(stderr, "failed create the ROHC compressor0);
goto error;
}

...

if(!rohc_comp_set_traces_cb2(compressor, print_rohc_traces, NULL))
{
fprintf(stderr, "failed to set the callback for traces on "
"compressor0);
goto release_compressor;
}

...

rohc_comp_free(compressor);

SEE ALSO

rohc_comp.h(3)