home *** CD-ROM | disk | FTP | other *** search
-
- /**
- * Este fichero ha sido diseqado para manejar de forma estandar
- * las entradas salidas que son necesarias de forma binaria
- * Se ha intentado optimizar al maximo para aumentar la velocidad
- * sin preocuparse si el origen o destino es memoria o un fichero
- *
- **/
-
-
- /* compress InputByte , OutputBits , OutputBit */
- /* expand OutputByte , InputBits , InputBit */
-
- /* START of COMPRESS */
-
- /* UBYTE endoffile */
- /* CHARS *inpb */
- /* CHARS *endinp */
- /* CHARS *outb */
- /* CHARS *endout */
- /* ULONG ioaux */
-
- #define InitOutput() { \
- outb = (CHARS *)xpar->OutBuf; \
- *outb = 0; \
- outmask = 0x80; \
- endout = (CHARS *) \
- ((long)xpar->OutBuf+(long)xpar->OutBufLen); \
- }
-
- #define InitInput() { \
- inpb = (CHARS *)xpar->InBuf; \
- inpmask = 0x80; \
- endinp = (CHARS *) \
- ((long)xpar->InBuf+(long)xpar->InLen); \
- }
-
-
- #define OutputBit( bit ) { \
- if ( bit ) \
- *outb |= outmask; \
- outmask >>= 1; \
- if ( !outmask ) \
- { \
- if( ++outb >= endout ) \
- return( XPKERR_EXPANSION ); \
- *outb = 0; \
- outmask = 0x80; \
- } \
- }
-
- #define OutputBits( code, count ) { \
- ioaux = 1L << ( count - 1 ); \
- while ( ioaux != 0) \
- { \
- if ( code & ioaux ) \
- *outb |= outmask; \
- outmask >>= 1; \
- if ( !outmask ) \
- { \
- if( ++outb >= endout ) \
- return( XPKERR_EXPANSION ); \
- *outb = 0; \
- outmask = 0x80; \
- } \
- ioaux >>= 1; \
- } \
- }
-
- #define InputByte( ) { \
- if(inpb++ >=endinp ) \
- endoffile = 1; \
- }
-
- #define EndOfFile() ( endoffile )
-
- /* START OF EXPAND */
-
- /* Definir UBYTE inpmask */
- /* UBYTE endoffile */
- /* CHARS *inpb */
- /* CHARS *endinp */
- /* CHARS *outb */
- /* CHARS *endout */
- /* ULONG ioaux */
-
- #define InputBit( code ) { \
- if( inpmask == 0x80 ) \
- if( inpb >= endinp) \
- endoffile=1; \
- code = (*inpb) & inpmask; \
- inpmask >>= 1; \
- if ( !inpmask ) \
- { \
- inpmask = 0x80; \
- inpb++; \
- } \
- }
-
- #define InputBits( code , bit_count ) { \
- ioaux = 1L << (bit_count -1); \
- code = 0; \
- while( ioaux ) \
- { \
- if( inpmask == 0x80 ) \
- if( inpb >= endinp ) \
- endoffile=1; \
- if( (*inpb) & inpmask ) \
- code |= ioaux; \
- ioaux >>=1; \
- inpmask >>= 1; \
- if ( !inpmask ) \
- { \
- inpmask = 0x80; \
- inpb++; \
- } \
- } \
- }
-
-
- #define OutputByte( car ) { \
- *outb = car; \
- if( ++outb >= endout ) \
- return( XPKERR_SMALLBUF ); \
- }
-
- /*************************** End of BITIO.C **************************/
-