ROHC compression/decompression library
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 2 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * This program is distributed in the hope that it will be useful, 00008 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00009 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00010 * GNU General Public License for more details. 00011 * 00012 * You should have received a copy of the GNU General Public License 00013 * along with this program; if not, write to the Free Software 00014 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00015 */ 00016 00017 /** 00018 * @file rohc_traces_internal.h 00019 * @brief Internal ROHC macros and functions for traces 00020 * @author Julien Bernard <julien.bernard@toulouse.viveris.com> 00021 * @author Audric Schiltknecht <audric.schiltknecht@toulouse.viveris.com> 00022 * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com> 00023 * @author Didier Barvaux <didier@barvaux.org> 00024 */ 00025 00026 #ifndef ROHC_TRACES_INTERNAL_H 00027 #define ROHC_TRACES_INTERNAL_H 00028 00029 #include "rohc_traces.h" 00030 00031 #include <stdlib.h> 00032 #include <assert.h> 00033 00034 #include "dllexport.h" 00035 00036 00037 /** Print information depending on the debug level (internal usage) */ 00038 #define __rohc_print(trace_cb, level, entity, profile, format, ...) \ 00039 do { \ 00040 if(trace_cb != NULL) { \ 00041 trace_cb(level, entity, profile, "[%s:%d %s()] " format, \ 00042 __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \ 00043 } \ 00044 } while(0) 00045 00046 /** Print information depending on the debug level */ 00047 #define rohc_print(entity_struct, level, entity, profile, format, ...) \ 00048 do { \ 00049 assert((entity_struct) != NULL); \ 00050 __rohc_print((entity_struct)->trace_callback, \ 00051 level, entity, profile, \ 00052 format, ##__VA_ARGS__); \ 00053 } while(0) 00054 00055 /** Print debug messages prefixed with the function name */ 00056 #define rohc_debug(entity_struct, entity, profile, format, ...) \ 00057 rohc_print(entity_struct, ROHC_TRACE_DEBUG, entity, profile, \ 00058 format, ##__VA_ARGS__) 00059 00060 /** Print information prefixed with the function name */ 00061 #define rohc_info(entity_struct, entity, profile, format, ...) \ 00062 rohc_print(entity_struct, ROHC_TRACE_INFO, entity, profile, \ 00063 format, ##__VA_ARGS__) 00064 00065 /** Print warning messages prefixed with the function name */ 00066 #define rohc_warning(entity_struct, entity, profile, format, ...) \ 00067 rohc_print(entity_struct, ROHC_TRACE_WARNING, entity, profile, \ 00068 format, ##__VA_ARGS__) 00069 00070 /** Print error messages prefixed with the function name */ 00071 #define rohc_error(entity_struct, entity, profile, format, ...) \ 00072 rohc_print(entity_struct, ROHC_TRACE_ERROR, entity, profile, \ 00073 format, ##__VA_ARGS__) 00074 00075 /** 00076 * @brief Stop processing if the given condition is false 00077 * 00078 * In non-debug mode (ie. NDEBUG set): if the given condition fails, prints 00079 * the given message then jump to the given label. 00080 * 00081 * In debug mode (ie. NDEBUG not set): if the given condition fails, prints 00082 * the given message then asserts. 00083 */ 00084 #define rohc_assert(entity_struct, entity, profile, \ 00085 condition, label, format, ...) \ 00086 do { \ 00087 if(!(condition)) { \ 00088 rohc_error(entity_struct, entity, profile, \ 00089 format, ##__VA_ARGS__); \ 00090 assert(condition); \ 00091 goto label; \ 00092 } \ 00093 } while(0) 00094 00095 00096 void ROHC_EXPORT rohc_dump_packet(const rohc_trace_callback_t trace_cb, 00097 const rohc_trace_entity_t trace_entity, 00098 const rohc_trace_level_t trace_level, 00099 const char *const descr, 00100 const unsigned char *const packet, 00101 const size_t length) 00102 __attribute__((nonnull(4, 5))); 00103 00104 00105 #endif 00106