codelength.h

Go to the documentation of this file.
00001 /* $Id: codelength.h,v 1.1 2008/10/06 22:04:06 nanard Exp $ */
00002 /* Project : miniupnp
00003  * Author : Thomas BERNARD
00004  * copyright (c) 2005-2008 Thomas Bernard
00005  * This software is subjet to the conditions detailed in the
00006  * provided LICENCE file. */
00007 #ifndef __CODELENGTH_H__
00008 #define __CODELENGTH_H__
00009 
00010 /* Encode length by using 7bit per Byte :
00011  * Most significant bit of each byte specifies that the
00012  * following byte is part of the code */
00013 #define DECODELENGTH(n, p) n = 0; \
00014                            do { n = (n << 7) | (*p & 0x7f); } \
00015                            while(*(p++)&0x80);
00016 
00017 #define CODELENGTH(n, p) if(n>=268435456) *(p++) = (n >> 28) | 0x80; \
00018                          if(n>=2097152) *(p++) = (n >> 21) | 0x80; \
00019                          if(n>=16384) *(p++) = (n >> 14) | 0x80; \
00020                          if(n>=128) *(p++) = (n >> 7) | 0x80; \
00021                          *(p++) = n & 0x7f;
00022 
00023 #endif
00024 
Generated on Mon Aug 30 23:09:48 2010 for Vidalia by  doxygen 1.6.3