xp_comm_proj/wr_ps/wr_ps.c
/*****************************************************************************
Function: RLD1Byte()
Purpose:  Decodes run length encoded streams whose elements are exactly one
          byte in size.  Refer to the documentation for the RunLengthDecode()
	  and RunLengthEncode() functions for more information.
Params:   inData  A pointer to an RLEBlock containing the encoded stream
	          to decode (restore).
          outBuf  A pointer to a buffer into which the original stream will
	          be decoded.  This stream must be nEls bytes in length.
State:    ---
Returns:  1  for success,
          0  for failure (unable to decode).
*****************************************************************************/
RLD1Byte()
Purpose:  Decodes run length encoded streams whose elements are exactly one
byte in size.  Refer to the documentation for the RunLengthDecode()
and RunLengthEncode() functions for more information.
Params:   inData  A pointer to an RLEBlock containing the encoded stream
to decode (restore).
outBuf  A pointer to a buffer into which the original stream will
be decoded.  This stream must be nEls bytes in length.
State:
Returns:  1  for success,
0  for failure (unable to decode).
RLD1Byte () Purpose : Decodes run length encoded streams whose elements are exactly one byte in size . Refer to the documentation for the RunLengthDecode () and RunLengthEncode () functions for more information . Params : inData A pointer to an RLEBlock containing the encoded stream to decode ( restore ) . outBuf A pointer to a buffer into which the original stream will be decoded . This stream must be nEls bytes in length . State : Returns : 1 for success 0 for failure ( unable to decode ) .
static int RLDecode(unsigned char *inBuf, int dataSize, void *outBuf)
{
   unsigned char *in = inBuf;
   unsigned char *out = (unsigned char *)outBuf;
   unsigned char *count;
   int n;
   unsigned num = 0;
   if ((dataSize == 0) || (!inBuf))
      return 0;
   n = 0;
   while (n < dataSize)
   {
      count = in++;
      num = (unsigned)(*count);
      ++n;
      if (num <= 127)
      {
	 int i;
	 for (i = 0; i <= num; i++)
	 {
	    *out++ = *in++;
	    ++n;
	 }
      }
      else if (num >= 129)
      {
	 int rep = 257 - num;
	 unsigned char ch = *in++;
	 while (rep--)
	    *out++ = ch;
         ++n;
      }
      else
	 break;
   }
   return (n == dataSize);
}
static int RLDecode ( unsigned char * inBuf , int dataSize , void * outBuf ) { unsigned char * in = inBuf ; unsigned char * out = ( unsigned char * ) outBuf ; unsigned char * count ; int n ; unsigned num = 0 ; if ( ( dataSize == 0 ) || ( ! inBuf ) ) return 0 ; n = 0 ; while ( n < dataSize ) { count = in ++ ; num = ( unsigned ) ( * count ) ; ++ n ; if ( num <= 127 ) { int i ; for ( i = 0 ; i <= num ; i ++ ) { * out ++ = * in ++ ; ++ n ; } } else if ( num >= 129 ) { int rep = 257 - num ; unsigned char ch = * in ++ ; while ( rep -- ) * out ++ = ch ; ++ n ; } else break ; } return ( n == dataSize ) ; }
Function: RLD1Byte()
Purpose:  Decodes run length encoded streams whose elements are exactly one
byte in size.
Function : RLD1Byte () Purpose : Decodes run length encoded streams whose elements are exactly one byte in size .