ROHC compression/decompression library
rohc_traces.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2012,2013 Didier Barvaux
00003  * Copyright 2009,2010 Thales Communications
00004  * Copyright 2012,2013 Viveris Technologies
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 /**
00022  * @file   rohc_traces.h
00023  * @brief  ROHC definitions for traces
00024  * @author Julien Bernard <julien.bernard@toulouse.viveris.com>
00025  * @author Audric Schiltknecht <audric.schiltknecht@toulouse.viveris.com>
00026  * @author Didier Barvaux <didier@barvaux.org>
00027  */
00028 
00029 #ifndef ROHC_TRACES_H
00030 #define ROHC_TRACES_H
00031 
00032 #ifdef __cplusplus
00033 extern "C"
00034 {
00035 #endif
00036 
00037 #if !defined(ROHC_ENABLE_DEPRECATED_API) || ROHC_ENABLE_DEPRECATED_API == 1
00038 #  include <rohc/rohc.h> /* for ROHC_DEPRECATED macro */
00039 #endif /* !ROHC_ENABLE_DEPRECATED_API */
00040 
00041 
00042 /**
00043  * @brief A general profile number used for traces not related to a specific
00044  *        profile
00045  *
00046  * @ingroup rohc
00047  */
00048 #define ROHC_PROFILE_GENERAL       0xffff
00049 
00050 
00051 /**
00052  * @brief The different levels of the traces
00053  *
00054  * Used for the \e level parameter of the \ref rohc_trace_callback_t
00055  * user-defined callback.
00056  *
00057  * @ingroup rohc
00058  *
00059  * @see rohc_trace_callback2_t
00060  * @see rohc_comp_set_traces_cb2
00061  * @see rohc_decomp_set_traces_cb2
00062  */
00063 typedef enum
00064 {
00065         ROHC_TRACE_DEBUG = 0,   /**< Print debug traces */
00066         ROHC_TRACE_INFO = 1,    /**< Print info (or lower) traces */
00067         ROHC_TRACE_WARNING = 2, /**< Print warning (or lower) traces */
00068         ROHC_TRACE_ERROR = 3,   /**< Print error (or lower) traces */
00069         ROHC_TRACE_LEVEL_MAX    /**< The maximum number of trace levels */
00070 } rohc_trace_level_t;
00071 
00072 
00073 /**
00074  * @brief The different entities concerned by the traces
00075  *
00076  * Used for the source \e entity parameter of the \ref rohc_trace_callback_t
00077  * user-defined callback.
00078  *
00079  * @ingroup rohc
00080  *
00081  * @see rohc_trace_callback2_t
00082  * @see rohc_comp_set_traces_cb2
00083  * @see rohc_decomp_set_traces_cb2
00084  */
00085 typedef enum
00086 {
00087         ROHC_TRACE_COMP = 0,    /**< Compressor traces */
00088         ROHC_TRACE_DECOMP = 1,  /**< Decompressor traces */
00089         ROHC_TRACE_ENTITY_MAX   /**< The maximum number of trace entities */
00090 } rohc_trace_entity_t;
00091 
00092 
00093 #if !defined(ROHC_ENABLE_DEPRECATED_API) || ROHC_ENABLE_DEPRECATED_API == 1
00094 
00095 /**
00096  * @brief The function prototype for the trace callback
00097  *
00098  * User-defined function that is called by the ROHC library every time it
00099  * wants to print something, from errors to debug. User may thus decide what
00100  * traces are interesting (filter on \e level, source \e entity, or
00101  * \e profile) and what to do with them (print on console, storage in file,
00102  * syslog...).
00103  *
00104  * The user-defined function is set by calling:
00105  *  \li function \ref rohc_comp_set_traces_cb for a ROHC compressor,
00106  *  \li function \ref rohc_decomp_set_traces_cb for a ROHC decompressor.
00107  *
00108  * Both functions accept the NULL value to fully disable tracing.
00109  *
00110  * @deprecated do not use this type anymore, use rohc_trace_callback2_t
00111  *             instead
00112  *
00113  * @param level    The level of the message, @see rohc_trace_level_t
00114  * @param entity   The entity concerned by the traces, @see rohc_trace_entity_t
00115  * @param profile  The number of the profile concerned by the message
00116  * @param format   The format string for the trace message
00117  *
00118  * @ingroup rohc
00119  *
00120  * @see rohc_trace_level_t
00121  * @see rohc_trace_entity_t
00122  * @see rohc_comp_set_traces_cb
00123  * @see rohc_decomp_set_traces_cb
00124  */
00125 typedef void (*rohc_trace_callback_t) (const rohc_trace_level_t level,
00126                                        const rohc_trace_entity_t entity,
00127                                        const int profile,
00128                                        const char *const format,
00129                                        ...)
00130 #if defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO == 1
00131         /* MinGW interprets 'printf' format as 'ms_printf', so force
00132          * usage of 'gnu_printf' */
00133         __attribute__((format(gnu_printf, 4, 5)));
00134 #else
00135         /* Use 'printf' format in other cases, because old GCC versions
00136          * and Clang do not recognize 'gnu_printf' format */
00137         __attribute__((format(printf, 4, 5)));
00138 #endif
00139 
00140 #endif /* !ROHC_ENABLE_DEPRECATED_API */
00141 
00142 
00143 /**
00144  * @brief The function prototype for the trace callback
00145  *
00146  * User-defined function that is called by the ROHC library every time it
00147  * wants to print something, from errors to debug. User may thus decide what
00148  * traces are interesting (filter on \e level, source \e entity, or
00149  * \e profile) and what to do with them (print on console, storage in file,
00150  * syslog...).
00151  *
00152  * The user-defined function is set by calling:
00153  *  \li function \ref rohc_comp_set_traces_cb2 for a ROHC compressor,
00154  *  \li function \ref rohc_decomp_set_traces_cb2 for a ROHC decompressor.
00155  *
00156  * Both functions accept the NULL value to fully disable tracing.
00157  *
00158  * @param priv_ctxt  An optional private context, may be NULL
00159  * @param level      The level of the message, @see rohc_trace_level_t
00160  * @param entity     The entity concerned by the traces
00161  *                   @see rohc_trace_entity_t
00162  * @param profile    The number of the profile concerned by the message
00163  * @param format     The format string for the trace message
00164  *
00165  * @ingroup rohc
00166  *
00167  * @see rohc_trace_level_t
00168  * @see rohc_trace_entity_t
00169  * @see rohc_comp_set_traces2_cb
00170  * @see rohc_decomp_set_traces2_cb
00171  */
00172 typedef void (*rohc_trace_callback2_t) (void *const priv_ctxt,
00173                                         const rohc_trace_level_t level,
00174                                         const rohc_trace_entity_t entity,
00175                                         const int profile,
00176                                         const char *const format,
00177                                         ...)
00178 #if defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO == 1
00179         /* MinGW interprets 'printf' format as 'ms_printf', so force
00180          * usage of 'gnu_printf' */
00181         __attribute__((format(gnu_printf, 5, 6)));
00182 #else
00183         /* Use 'printf' format in other cases, because old GCC versions
00184          * and Clang do not recognize 'gnu_printf' format */
00185         __attribute__((format(printf, 5, 6)));
00186 #endif
00187 
00188 
00189 #ifdef __cplusplus
00190 }
00191 #endif
00192 
00193 #endif /* ROHC_TRACES_H */
00194