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.h 00019 * @brief ROHC macros and functions for traces 00020 * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com> 00021 * @author Didier Barvaux <didier@barvaux.org> 00022 */ 00023 00024 #ifndef ROHC_TRACES_H 00025 #define ROHC_TRACES_H 00026 00027 #include <stdio.h> 00028 #include <assert.h> 00029 #include "config.h" /* for ROHC_DEBUG_LEVEL */ 00030 #include "dllexport.h" 00031 00032 /// @brief Print information depending on the debug level and prefixed 00033 /// with the function name 00034 #define rohc_debugf(level, format, ...) \ 00035 rohc_debugf_(level, "%s[%s:%d %s()] " format, \ 00036 (level == 0 ? "[ERROR] " : ""), \ 00037 __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__) 00038 00039 /// Print information depending on the debug level 00040 #define rohc_debugf_(level, format, ...) \ 00041 do { \ 00042 if((level) <= ROHC_DEBUG_LEVEL) { \ 00043 printf(format, ##__VA_ARGS__); \ 00044 } \ 00045 } while(0) 00046 00047 /** 00048 * @brief Stop processing if the given condition is false 00049 * 00050 * In non-debug mode (ie. NDEBUG set): if the given condition fails, prints 00051 * the given message then jump to the given label. 00052 * 00053 * In debug mode (ie. NDEBUG not set): if the given condition fails, prints 00054 * the given message then asserts. 00055 */ 00056 #define rohc_assert(condition, label, format, ...) \ 00057 do { \ 00058 if(!(condition)) { \ 00059 rohc_debugf(0, format "\n", ##__VA_ARGS__); \ 00060 assert(condition); \ 00061 goto label; \ 00062 } \ 00063 } while(0) 00064 00065 00066 void ROHC_EXPORT rohc_dump_packet(const char *const descr, 00067 const unsigned char *const packet, 00068 const size_t length) 00069 __attribute__((nonnull(1, 2))); 00070 00071 00072 #endif 00073