DIRECTORY RefText USING [New, ObtainScratch, ReleaseScratch, TrustTextRopeAsText], Rope USING [FromRefText, Flatten, ROPE], SunRPC, SunRPCAuth USING [Conversation, Flavor, GetCredentialsAndNextVerifier, maxValueBytes, nullFlavor], SunRPCNumbers USING [], SunRPCType USING [AcceptStat, MsgType, ReplyStat, rpcVersion] ; SunRPCImpl: CEDAR PROGRAM IMPORTS RefText, Rope, SunRPC, SunRPCAuth EXPORTS SunRPC, SunRPCNumbers ~ { OPEN RPCT: SunRPCType; ROPE: TYPE ~ Rope.ROPE; Handle: TYPE ~ SunRPC.Handle; Conversation: TYPE ~ SunRPCAuth.Conversation; AuthFlavor: TYPE ~ SunRPCAuth.Flavor; nullFlavor: AuthFlavor ~ SunRPCAuth.nullFlavor; AuthValue: TYPE ~ REF TEXT; Error: PUBLIC ERROR [code: ATOM] ~ CODE; maxRefTextLength: CARDINAL ¬ 8*1024; maxAuthBytes: CARDINAL ~ SunRPCAuth.maxValueBytes; GetFlavor: PUBLIC PROC [h: Handle] RETURNS [flavor: ATOM] ~ { RETURN [ h.flavor ]; }; StartCall: PUBLIC PROC [h: Handle, c: Conversation, pgm, version, proc: CARD] ~ { cFlavor, vFlavor: AuthFlavor; credentials, verifier: AuthValue; h.procs.prepareForMessage[h]; h.xid ¬ h.xid + 1; h.authData ¬ c; SunRPC.PutCard32[h, h.xid]; -- xid SunRPC.PutCard32[h, ORD[RPCT.MsgType.call]]; -- msgType SunRPC.PutCard32[h, RPCT.rpcVersion]; -- rpcvers SunRPC.PutCard32[h, pgm]; -- prog SunRPC.PutCard32[h, version]; -- vers SunRPC.PutCard32[h, proc]; -- proc [cFlavor, credentials, vFlavor, verifier] ¬ SunRPCAuth.GetCredentialsAndNextVerifier[c]; SunRPC.PutCard32[h, cFlavor]; SunRPC.PutCard32[h, credentials.length]; IF credentials.length > 0 THEN SunRPC.PutBlock[h, credentials, 0, credentials.length]; SunRPC.PutCard32[h, vFlavor]; SunRPC.PutCard32[h, verifier.length]; IF verifier.length > 0 THEN SunRPC.PutBlock[h, verifier, 0, verifier.length]; }; StartAcceptReply: PUBLIC PROC [h: Handle, acceptStat: CARD32] ~ { h.procs.prepareForMessage[h]; SunRPC.PutCard32[h, h.xid]; -- xid SunRPC.PutCard32[h, ORD[RPCT.MsgType.reply]]; -- msgType SunRPC.PutCard32[h, ORD[RPCT.ReplyStat.msgAccepted]]; -- replyStat SunRPC.PutAuth[h, h.authFlavor, NARROW[h.authData]]; -- replyVerifier SunRPC.PutCard32[h, acceptStat]; -- acceptStat }; StartRejectReply: PUBLIC PROC [h: Handle, rejectStat: CARD32] ~ { h.procs.prepareForMessage[h]; SunRPC.PutCard32[h, h.xid]; -- xid SunRPC.PutCard32[h, ORD[RPCT.MsgType.reply]]; -- msgType SunRPC.PutCard32[h, ORD[RPCT.ReplyStat.msgDenied]]; -- replyStat SunRPC.PutCard32[h, rejectStat]; -- rejectStat }; StartReply: PUBLIC PROC [h: Handle] ~ { StartAcceptReply[h, ORD[RPCT.AcceptStat.success]]; }; SkipBytes: PUBLIC PROC [h: Handle, bytes: CARDINAL] ~ { h.procs.skipBytes[h, bytes]; }; GetRefText: PUBLIC PROC [h: Handle] RETURNS [refText: REF TEXT] ~ { length: CARD ¬ SunRPC.GetCard32[h]; IF length > maxRefTextLength THEN ERROR Error[$outOfBufferSpace]; refText ¬ RefText.New[length]; SunRPC.GetBlock[h, refText, 0, length]; SunRPC.GetAlign[h]; }; GetEphemeralRefText: PUBLIC PROC [h: Handle, oldBuffer: REF TEXT] RETURNS [newBuffer: REF TEXT] ~ { length: CARD ¬ SunRPC.GetCard32[h]; IF length > maxRefTextLength THEN ERROR Error[$outOfBufferSpace]; SELECT TRUE FROM (oldBuffer = NIL) => { newBuffer ¬ RefText.ObtainScratch[length]; }; (oldBuffer.maxLength < length) => { RefText.ReleaseScratch[oldBuffer]; newBuffer ¬ RefText.ObtainScratch[length]; }; ENDCASE => { newBuffer ¬ oldBuffer; }; IF (newBuffer.length ¬ length) > 0 THEN { SunRPC.GetBlock[h, newBuffer, 0, length]; SunRPC.GetAlign[h]; }; }; GetRope: PUBLIC PROC [h: Handle] RETURNS [ROPE] ~ { temp: REF TEXT ¬ GetEphemeralRefText[h, NIL]; result: ROPE ¬ Rope.FromRefText[temp]; RefText.ReleaseScratch[temp]; RETURN [result]; }; GetAuth: PUBLIC PROC [h: Handle] RETURNS [flavor: AuthFlavor, value: AuthValue] ~ { flavor ¬ [SunRPC.GetCard32[h]]; value ¬ GetEphemeralRefText[h, NIL]; }; GetBool: PUBLIC PROC [h: Handle] RETURNS [BOOL] ~ { rep: CARD32 ~ SunRPC.GetCard32[h]; RETURN [rep#0] }; GetInt64: PUBLIC PROC [h: Handle] RETURNS [INT64] ~ { a: PACKED ARRAY [0..1] OF CARD32; a[0] ¬ SunRPC.GetCard32[h]; a[1] ¬ SunRPC.GetCard32[h]; RETURN [LOOPHOLE[a]]; }; GetCard64: PUBLIC PROC [h: Handle] RETURNS [CARD64] ~ { a: PACKED ARRAY [0..1] OF CARD32; a[0] ¬ SunRPC.GetCard32[h]; a[1] ¬ SunRPC.GetCard32[h]; RETURN [LOOPHOLE[a]]; }; GetReal: PUBLIC PROC [h: Handle] RETURNS [REAL] ~ { rep: CARD32 ~ SunRPC.GetCard32[h]; RETURN [LOOPHOLE[rep]] }; oneDRealRep: PACKED ARRAY [0..1] OF CARD32 ~ LOOPHOLE[DREAL[1.0]]; drealHi: [0..1] ~ IF oneDRealRep[1] = 0 THEN 0 ELSE 1; drealLo: [0..1] ~ 1 - drealHi; GetDReal: PUBLIC PROC [h: Handle] RETURNS [DREAL] ~ { a: PACKED ARRAY [0..1] OF CARD32; a[drealHi] ¬ SunRPC.GetCard32[h]; a[drealLo] ¬ SunRPC.GetCard32[h]; RETURN [LOOPHOLE[a]] }; PutRefText: PUBLIC PROC [h: Handle, refText: REF READONLY TEXT] ~ { SunRPC.PutCard32[h, refText.length]; SunRPC.PutBlock[h, refText, 0, refText.length]; SunRPC.PutAlign[h, 0]; }; PutRope: PUBLIC PROC [h: Handle, rope: ROPE] ~ { IF rope = NIL THEN { SunRPC.PutCard32[h, 0]; } ELSE TRUSTED { PutRefText[h, RefText.TrustTextRopeAsText[Rope.Flatten[rope]]]; }; }; PutAuth: PUBLIC PROC [h: Handle, flavor: AuthFlavor, value: AuthValue] ~ { SunRPC.PutCard32[h, flavor]; IF value.length > maxAuthBytes THEN ERROR; SunRPC.PutCard32[h, value.length]; IF value.length > 0 THEN SunRPC.PutBlock[h, value, 0, value.length]; SunRPC.PutAlign[h, 0]; }; PutBool: PUBLIC PROC [h: Handle, bool: BOOL] ~ { SunRPC.PutCard32[h, ORD[bool]]; }; PutInt64: PUBLIC PROC [h: Handle, int64: INT64] ~ { a: PACKED ARRAY [0..1] OF CARD32 ¬ LOOPHOLE[int64]; SunRPC.PutCard32[h, a[0]]; SunRPC.PutCard32[h, a[1]]; }; PutCard64: PUBLIC PROC [h: Handle, card64: CARD64] ~ { a: PACKED ARRAY [0..1] OF CARD32 ¬ LOOPHOLE[card64]; SunRPC.PutCard32[h, a[0]]; SunRPC.PutCard32[h, a[1]]; }; PutReal: PUBLIC PROC [h: Handle, real: REAL] ~ { SunRPC.PutCard32[h, LOOPHOLE[real]]; }; PutDReal: PUBLIC PROC [h: Handle, dreal: DREAL] ~ { a: PACKED ARRAY [0..1] OF CARD32 ¬ LOOPHOLE[dreal]; SunRPC.PutCard32[h, a[drealHi]]; SunRPC.PutCard32[h, a[drealLo]]; }; }... ( SunRPCImpl.mesa Copyright Σ 1989, 1991, 1992 by Xerox Corporation. All rights reserved. Demers, November 23, 1988 2:45:39 pm PST Carl Hauser, November 22, 1988 4:01:56 pm PST Willie-Sue, March 16, 1989 7:03:43 pm PST Michael Plass, September 23, 1991 11:51 am PDT David Nichols, January 15, 1991 5:44 pm PST Willie-s, August 21, 1991 12:27 pm PDT Chauser, January 3, 1992 1:48 pm PST Types Parameters Clients Fill in the call message header ... Servers Fill in the reply message header ... through acceptStat Fill in the reply message header ... through rejectStat Serializing / Deserializing BEWARE: the returned value is ephemeral (allocated with ObtainScratch rather than New). Assumes INT64 is big-endian. Assumes CARD64 is big-endian. Assumes INT64 is big-endian. Assumes CARD64 is big-endian. ΚΤ•NewlineDelimiter –(cedarcode) style™code™Kšœ Οeœ=™HK™(K™-K™)K™.K™+K™&K™$K˜—šΟk ˜ Kšœžœ;˜HKšœžœžœ˜(K˜Kšœ˜Kšœ žœR˜bKšœžœ˜Kšœ žœ-˜=K˜K˜—šΟn œžœž˜Kšžœ"˜)Kšžœ˜K˜Kšžœžœ ˜head™Kšžœžœžœ˜K˜Kšœžœ˜K˜Kšœžœ˜-šœ žœ˜%Kšœ/˜/—Kšœ žœžœžœ˜K˜Kš Ÿœžœžœžœžœ˜(—™ Kšœžœ ˜$Kšœžœ˜2K˜—™š Ÿ œžœžœ žœ žœ˜=Kšžœ˜Kšœ˜K™—šŸ œžœžœ2žœ˜QK˜K˜!K˜K˜K˜K˜K˜™#KšœΟc˜"Kšœžœžœ  ˜7Kšœžœ  ˜0Kšœ ˜!Kšœ ˜%Kšœ ˜"K˜KšœX˜XKšœ˜Kšœ(˜(Kšžœžœ8˜VKšœ˜Kšœ%˜%Kšžœžœ2˜M—K˜K˜K˜——™K˜šŸœžœžœžœ˜=Kšœ˜K™7K˜K˜Kšœ ˜"Kšœžœžœ  ˜8Kšœžœžœ  ˜BK˜Kšœ žœ ˜EK˜Kšœ!  ˜.K˜K˜—šŸœžœžœžœ˜AK™7K˜K˜Kšœ ˜"Kšœžœžœ  ˜8Kšœžœžœ  ˜@Kšœ!  ˜.K˜K˜—šŸ œžœžœ˜'Kšœžœžœ˜2K˜K˜——™šŸ œžœžœžœ˜7K˜Kšœ˜—K˜š Ÿ œžœžœ žœ žœžœ˜CKšœžœ˜#Kšžœžœžœ˜AK˜K˜'K˜K˜K˜—š Ÿœžœžœ"žœ žœžœ˜cKšœžœ˜#Kšžœžœžœ˜Ašžœžœž˜šœ žœ˜Kšœ*˜*K˜—˜#Kšœ"˜"Kšœ*˜*K˜—šžœ˜ K˜K˜——šžœ žœ˜)Kšœ)˜)K˜K˜—K˜K˜—š Ÿœžœžœ žœžœ˜3Kšœžœžœžœ˜-Kšœžœ˜&K˜Kšžœ ˜K˜K˜—šŸœžœžœ žœ+˜SK™WKšœ˜Kšœžœ˜$K˜K˜—š Ÿœžœžœ žœžœ˜3Kšœžœ˜"Kšžœ˜Kšœ˜K˜—š Ÿœžœžœ žœžœ˜5Kšœžœ™Kš œžœžœžœžœ˜!Kšœ˜Kšœ˜Kšžœžœ˜Kšœ˜K˜—š Ÿ œžœžœ žœžœ˜7Kšœžœ™Kš œžœžœžœžœ˜!Kšœ˜Kšœ˜Kšžœžœ˜Kšœ˜K˜—š Ÿœžœžœ žœžœ˜3Kšœžœ˜"Kšžœžœ˜Kšœ˜K˜—Kš œ žœžœžœžœžœžœ˜BKšœžœžœžœ˜6Kšœ˜š Ÿœžœžœ žœžœ˜5Kš œžœžœžœžœ˜!Kšœ!˜!Kšœ!˜!Kšžœžœ˜Kšœ˜K˜—š Ÿ œžœžœžœžœžœ˜CK˜$K˜/K˜K˜K˜—šŸœžœžœžœ˜0šžœž˜ šžœ˜Kšœ˜K˜—šžœžœ˜Kšœ?˜?K˜——K˜K˜—šŸœžœžœ6˜JK˜Kšžœžœžœ˜*K˜"Kšžœžœ,˜DK˜˜K˜——šŸœžœžœžœ˜0Kšœžœ˜Kšœ˜K˜—šŸœžœžœžœ˜3Kšœžœ™Kš œžœžœžœžœžœ˜3Kšœ˜Kšœ˜Kšœ˜K˜—šŸ œžœžœžœ˜6Kšœžœ™Kš œžœžœžœžœžœ ˜4Kšœ˜Kšœ˜Kšœ˜K˜—šŸœžœžœžœ˜0Kšœžœ˜$Kšœ˜K˜—šŸœžœžœžœ˜3Kš œžœžœžœžœžœ˜3Kšœ ˜ Kšœ ˜ Kšœ˜K˜—K˜——K˜—…—h#d