1/* Project : miniupnp 2 * Author : Thomas BERNARD 3 * copyright (c) 2005-2008 Thomas Bernard 4 * This software is subjet to the conditions detailed in the 5 * provided LICENCE file. */ 6#ifndef __CODELENGTH_H__ 7#define __CODELENGTH_H__ 8 9/* Encode length by using 7bit per Byte : 10 * Most significant bit of each byte specifies that the 11 * following byte is part of the code */ 12#define DECODELENGTH(n, p) n = 0; \ 13 do { n = (n << 7) | (*p & 0x7f); } \ 14 while(*(p++)&0x80); 15 16#define CODELENGTH(n, p) if(n>=268435456) *(p++) = (n >> 28) | 0x80; \ 17 if(n>=2097152) *(p++) = (n >> 21) | 0x80; \ 18 if(n>=16384) *(p++) = (n >> 14) | 0x80; \ 19 if(n>=128) *(p++) = (n >> 7) | 0x80; \ 20 *(p++) = n & 0x7f; 21 22#endif 23 24