PupChecksums.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
HGM October 15, 1980 7:37 PM
Russ Atkinson (RRA) February 4, 1985 12:53:24 pm PST
DIRECTORY
Checksum USING [ComputeChecksum],
PupRouterDefs USING [Checksum],
BufferDefs USING [PupBuffer];
PupChecksums: PROGRAM IMPORTS Checksum EXPORTS PupRouterDefs = {
checksum: PUBLIC PupRouterDefs.Checksum ← princOps;
SetPupChecksum: PUBLIC PROC [b: BufferDefs.PupBuffer] = {
size: CARDINAL ← (b.pupLength - 1)/2;
checksumLoc: LONG POINTER ← @b.pupLength + size;
SELECT checksum FROM
princOps => { checksumLoc^ ← Checksum.ComputeChecksum[0, size, @b.pupLength]; };
none => { checksumLoc^ ← 177777B; };
ENDCASE => ERROR;
};
TestPupChecksum: PUBLIC PROC [b: BufferDefs.PupBuffer] RETURNS [BOOLEAN] = {
size: CARDINAL ← ((LOOPHOLE[b.pupLength - 1, CARDINAL])/2);
checksumLoc: LONG POINTER ← @b.pupLength + size;
cs: CARDINAL;
IF checksumLoc^ = 177777B THEN RETURN[TRUE];
SELECT checksum FROM
princOps => {
BEWARE: The stack must be empty. Dont try RETURN[xx^=PupChecksum[xxx]];
cs ← Checksum.ComputeChecksum[0, size, @b.pupLength];
};
none => { RETURN[TRUE]; };
ENDCASE => ERROR;
RETURN[checksumLoc^ = cs];
};
}.