.ad 8
.bm 8
.fm 4
.bt $Copyright by   SAP AG, 1995$$Page %$
.tm 12
.hm 6
.hs 3
.tt 1 $SQL$Project Distributed Database System$VSP31$
.tt 2 $$$
.tt 3 $$RTE-Extension-31$1995-04-19$
***********************************************************
.nf


    ========== licence begin LGPL
    Copyright (C) 2000 SAP AG

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    ========== licence end

.fo
.nf
.sp
Module  : RTE-Extension-31
=========
.sp
Purpose : XOR
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :
 
        PROCEDURE
              s31xor (VAR buf  : tsp_moveobj;
                    pos, len   : tsp_int4;
                    VAR xorval : tsp_buf;
                    xorpos     : integer);
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : 
.sp
.cp 3
Created : 1986-09-05
.sp
.cp 3
Version : 1995-04-19
.sp
.cp 3
Release :  6.1.1 	 Date : 1995-04-19
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:
 
PROCEDURE S31XOR
.sp
This procedure xors a buffer in four byte steps and returns
a four byte integer.
.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:
 
.CM *-END-* description ---------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.nf
.oc _/1
Structure:
 
.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 10
.nf
.oc _/1
.CM -lll-
Code    :
 
 
(*------------------------------*) 
 
PROCEDURE
      s31xor (VAR buf  : tsp_moveobj;
            pos, len   : tsp_int4;
            VAR xorval : tsp_buf;
            xorpos     : integer);
 
TYPE
      four_byte_range = 0..31;
      four_byte_set   = PACKED SET OF four_byte_range;
 
      set_map_c4 = RECORD
            CASE boolean OF
                true :
                    (map_set : four_byte_set);
                false :
                    (map_c4  : tsp_c4);
                END;
            (*ENDCASE*) 
 
 
VAR
      lowbyte  : integer;
      startval : integer;
      i        : tsp_int4;
      llen     : tsp_int4;
      offset   : tsp_int4;
      xor_map  : set_map_c4;
      set_map  : set_map_c4;
 
BEGIN
FOR i := 1 TO 4 DO
    xorval [ xorpos + i - 1 ] := chr (0);
(*ENDFOR*) 
xor_map.map_set := [  ];
set_map.map_set := [  ];
offset          := 0;
i               := 0;
llen            := len;
IF  len <= 4
THEN
    BEGIN
    FOR i := 1 TO len DO
        xorval [ xorpos + i - 1 ] := buf [ pos + i - 1 ];
    (*ENDFOR*) 
    END
ELSE
    BEGIN
    startval := ord (buf [ pos ]) + ord (buf [ pos + 1 ]);
    lowbyte  := startval MOD 256;
    xor_map.map_c4 [ 2 ] := chr (lowbyte);
    IF  startval > 255
    THEN
        xor_map.map_c4 [ 1 ] := chr (1);
    (*ENDIF*) 
    WHILE len > 0 DO
        BEGIN
        IF  len > 4
        THEN
            BEGIN
            set_map.map_c4 [ 1 ] := buf [ pos + offset ];
            set_map.map_c4 [ 2 ] := buf [ pos + offset + 1 ];
            set_map.map_c4 [ 3 ] := buf [ pos + offset + 2 ];
            set_map.map_c4 [ 4 ] := buf [ pos + offset + 3 ];
            offset := offset + 4
            END
        ELSE
            BEGIN
            i := 1;
            WHILE (offset < llen) AND (i <= 4) DO
                BEGIN
                set_map.map_c4 [ i ] := buf [ pos + offset ];
                offset := offset + 1;
                i := i + 1;
                END;
            (*ENDWHILE*) 
            WHILE i <= 4 DO
                BEGIN
                set_map.map_c4 [ i ] := chr (0);
                i := i + 1
                END;
            (*ENDWHILE*) 
            END;
        (*ENDIF*) 
        xor_map.map_set := (xor_map.map_set + set_map.map_set) -
              (xor_map.map_set * set_map.map_set);
        len := len - 4;
        END;
    (*ENDWHILE*) 
    FOR i := 1 TO 4 DO
        xorval [ xorpos + i - 1 ] := xor_map.map_c4 [ i ]
    (*ENDFOR*) 
    END;
(*ENDIF*) 
END;
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
*-PRETTY-*  statements    :         34
*-PRETTY-*  lines of code :         94        PRETTY  3.09 
*-PRETTY-*  lines in file :        193         1992-11-23 
.PA 
