ROHC compression/decompression library
rohc_traces.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012,2013 Didier Barvaux
3  * Copyright 2009,2010 Thales Communications
4  * Copyright 2012,2013 Viveris Technologies
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file rohc_traces.h
23  * @brief ROHC definitions for traces
24  * @author Julien Bernard <julien.bernard@toulouse.viveris.com>
25  * @author Audric Schiltknecht <audric.schiltknecht@toulouse.viveris.com>
26  * @author Didier Barvaux <didier@barvaux.org>
27  */
28 
29 #ifndef ROHC_TRACES_H
30 #define ROHC_TRACES_H
31 
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #endif
36 
37 
38 /**
39  * @brief A general profile number used for traces not related to a specific
40  * profile
41  *
42  * @ingroup rohc
43  */
44 #define ROHC_PROFILE_GENERAL 0xffff
45 
46 
47 /**
48  * @brief The different levels of the traces
49  *
50  * Used for the \e level parameter of the \ref rohc_trace_callback2_t
51  * user-defined callback.
52  *
53  * @ingroup rohc
54  *
55  * @see rohc_trace_callback2_t
56  * @see rohc_comp_set_traces_cb2
57  * @see rohc_decomp_set_traces_cb2
58  */
59 typedef enum
60 {
61  ROHC_TRACE_DEBUG = 0, /**< Print debug traces */
62  ROHC_TRACE_INFO = 1, /**< Print info (or lower) traces */
63  ROHC_TRACE_WARNING = 2, /**< Print warning (or lower) traces */
64  ROHC_TRACE_ERROR = 3, /**< Print error (or lower) traces */
65  ROHC_TRACE_LEVEL_MAX /**< The maximum number of trace levels */
67 
68 
69 /**
70  * @brief The different entities concerned by the traces
71  *
72  * Used for the source \e entity parameter of the \ref rohc_trace_callback2_t
73  * user-defined callback.
74  *
75  * @ingroup rohc
76  *
77  * @see rohc_trace_callback2_t
78  * @see rohc_comp_set_traces_cb2
79  * @see rohc_decomp_set_traces_cb2
80  */
81 typedef enum
82 {
83  ROHC_TRACE_COMP = 0, /**< Compressor traces */
84  ROHC_TRACE_DECOMP = 1, /**< Decompressor traces */
85  ROHC_TRACE_ENTITY_MAX /**< The maximum number of trace entities */
87 
88 
89 /**
90  * @brief The function prototype for the trace callback
91  *
92  * User-defined function that is called by the ROHC library every time it
93  * wants to print something, from errors to debug. User may thus decide what
94  * traces are interesting (filter on \e level, source \e entity, or
95  * \e profile) and what to do with them (print on console, storage in file,
96  * syslog...).
97  *
98  * The user-defined function is set by calling:
99  * \li function \ref rohc_comp_set_traces_cb2 for a ROHC compressor,
100  * \li function \ref rohc_decomp_set_traces_cb2 for a ROHC decompressor.
101  *
102  * Both functions accept the NULL value to fully disable tracing.
103  *
104  * @param priv_ctxt An optional private context, may be NULL
105  * @param level The level of the message, @see rohc_trace_level_t
106  * @param entity The entity concerned by the traces
107  * @see rohc_trace_entity_t
108  * @param profile The number of the profile concerned by the message
109  * @param format The format string for the trace message
110  *
111  * @ingroup rohc
112  *
113  * @see rohc_trace_level_t
114  * @see rohc_trace_entity_t
115  * @see rohc_comp_set_traces2_cb
116  * @see rohc_decomp_set_traces2_cb
117  */
118 typedef void (*rohc_trace_callback2_t) (void *const priv_ctxt,
119  const rohc_trace_level_t level,
120  const rohc_trace_entity_t entity,
121  const int profile,
122  const char *const format,
123  ...)
124 #if defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO == 1
125  /* MinGW interprets 'printf' format as 'ms_printf', so force
126  * usage of 'gnu_printf' */
127  __attribute__((format(gnu_printf, 5, 6)));
128 #else
129  /* Use 'printf' format in other cases, because old GCC versions
130  * and Clang do not recognize 'gnu_printf' format */
131  __attribute__((format(printf, 5, 6)));
132 #endif
133 
134 
135 #ifdef __cplusplus
136 }
137 #endif
138 
139 #endif /* ROHC_TRACES_H */
140 
rohc_trace_level_t
The different levels of the traces.
Definition: rohc_traces.h:59
Definition: rohc_traces.h:63
Definition: rohc_traces.h:62
Definition: rohc_traces.h:65
Definition: rohc_traces.h:61
void(* rohc_trace_callback2_t)(void *const priv_ctxt, const rohc_trace_level_t level, const rohc_trace_entity_t entity, const int profile, const char *const format,...)
The function prototype for the trace callback.
Definition: rohc_traces.h:118
Definition: rohc_traces.h:85
Definition: rohc_traces.h:83
Definition: rohc_traces.h:64
rohc_trace_entity_t
The different entities concerned by the traces.
Definition: rohc_traces.h:81
Definition: rohc_traces.h:84