4 #define G_254_SQUARE 64516 
    5 #define G_254_TIMES_2 508 
    7 #define G_RLE_OUTPUT_CODE(code) (*((unsigned char *) dst++) = (code)) 
    8 #define G_RLE_INPUT_CODE(codeP) (*(codeP) = *((unsigned char *) src++)) 
   12 static int G_rle_codeLength(
int length)
 
   28     while ((lPrime = lPrime / 254) != 0)
 
   30     return codeLength + 2;
 
   35 static char *rle_length2code(
int length, 
char *dst)
 
   70     while ((lPrime = lPrime / 254) != 0)
 
   83 static char *rle_code2length(
char *src, 
int *length)
 
  103         *length += 254 * code;
 
  114     *length += 254 * code;
 
  125     int length, nofEqual;
 
  126     char *head, *tail, *headStop, *headStop2;
 
  133     head = src + eltLength;
 
  136     headStop = src + nofElts * eltLength;
 
  138     while (head != headStop) {
 
  139         headStop2 = head + eltLength;
 
  141         while (head != headStop2) {
 
  142             if (*head != *tail) {
 
  143                 length += G_rle_codeLength(nofEqual) + eltLength;
 
  145                 tail = headStop2 - eltLength;
 
  152         if (head == headStop2) {
 
  159     length += G_rle_codeLength(nofEqual) + eltLength;
 
  161     return length + G_rle_codeLength(-1);
 
  168     int length, nofEqual;
 
  169     char *head, *tail, *headStop, *headStop2;
 
  176     head = src + eltLength;
 
  179     headStop = src + nofElts * eltLength;
 
  181     while (head != headStop) {
 
  182         headStop2 = head + eltLength;
 
  184         while (head != headStop2) {
 
  185             if (*head != *tail) {
 
  186                 dst = rle_length2code(nofEqual, dst);
 
  187                 tail = headStop2 - eltLength * (nofEqual + 1);
 
  188                 head = tail + eltLength;
 
  192                 length += G_rle_codeLength(nofEqual) + eltLength;
 
  194                 tail = headStop2 - eltLength;
 
  201         if (head == headStop2) {
 
  209     dst = rle_length2code(nofEqual, dst);
 
  210     tail = headStop - eltLength * nofEqual;
 
  211     head = tail + eltLength;
 
  214     length += G_rle_codeLength(nofEqual) + eltLength;
 
  215     dst = rle_length2code(-1, dst);
 
  216     length += G_rle_codeLength(-1);
 
  217     rle_code2length(dst - 2, &nofEqual);
 
  224              int *lengthEncode, 
int *lengthDecode)
 
  227     char *src2, *srcStop, *src2Stop, *dstFirst;
 
  229     srcStop = src + nofElts * eltLength;
 
  232     while (src != srcStop) {
 
  233         src = rle_code2length(src, &nofEqual);
 
  235         if (nofEqual == -1) {
 
  236             *lengthEncode = src - (srcStop - nofElts * eltLength);
 
  237             *lengthDecode = dst - dstFirst;
 
  243             src2Stop = src2 + eltLength;
 
  244             while (src2 != src2Stop)
 
  262         scanf(
"%d", &length);
 
  263         printf(
"length = %d\n", length);
 
  264         printf(
"codeLength %d   ", G_rle_codeLength(length));
 
  265         (void)rle_length2code(length, c);
 
  267         (void)rle_code2length(c, &length);
 
  268         printf(
"output length %d\n\n", length);
 
int G_rle_count_only(char *src, int nofElts, int eltLength)
 
#define G_RLE_INPUT_CODE(codeP)
 
void G_rle_encode(char *src, char *dst, int nofElts, int eltLength)
 
#define G_RLE_OUTPUT_CODE(code)
 
void G_rle_decode(char *src, char *dst, int nofElts, int eltLength, int *lengthEncode, int *lengthDecode)
 
void G3d_fatalError(const char *,...)
This function prints the error message msg, and terminates the program with an error status...