<<>> <> <> <> DIRECTORY Rope, SunRPC, NS, NSGetPut; NSGetPutImpl: CEDAR PROGRAM IMPORTS SunRPC EXPORTS NS, NSGetPut = BEGIN Handle: TYPE = SunRPC.Handle; ROPE: TYPE = Rope.ROPE; ReturnCodesNames: PUBLIC ARRAY NS.ReturnCodes OF ROPE _ [ "Success", "Unavailable", "IllegalInsertPid", "IllegalDeleteUid", "IllegalFindSpec", "ResourceFailure" ]; GetReturnCodes: PUBLIC PROC[h: Handle] RETURNS [res: NS.ReturnCodes] = { res _ VAL[SunRPC.GetInt32[h]]; }; PutReturnCodes: PUBLIC PROC[h: Handle, in: NS.ReturnCodes] = { SunRPC.PutInt32[h, ORD[in]]; }; DomainNames: PUBLIC ARRAY NS.Domain OF ROPE _ [ "localHost", "localArea" ]; GetDomain: PUBLIC PROC[h: Handle] RETURNS [res: NS.Domain] = { res _ VAL[SunRPC.GetInt32[h]]; }; PutDomain: PUBLIC PROC[h: Handle, in: NS.Domain] = { SunRPC.PutInt32[h, ORD[in]]; }; GetString: PUBLIC PROC[h: Handle] RETURNS [res: NS.String] = { res _ SunRPC.GetRope[h]; }; PutString: PUBLIC PROC[h: Handle, in: NS.String] = { SunRPC.PutRope[h, in]; }; ValueTypeNames: PUBLIC ARRAY NS.ValueType OF ROPE _ [ "text", "attributes", "any" ]; GetValueType: PUBLIC PROC[h: Handle] RETURNS [res: NS.ValueType] = { res _ VAL[SunRPC.GetInt32[h]]; }; PutValueType: PUBLIC PROC[h: Handle, in: NS.ValueType] = { SunRPC.PutInt32[h, ORD[in]]; }; GetValue: PUBLIC PROC[h: Handle] RETURNS [res: NS.Value] = { tag: NS.ValueType; tag _ GetValueType[h]; SELECT tag FROM text => { v: REF text NS.ValueObject _ NEW[text NS.ValueObject]; v.valStr _ GetString[h]; res _ v; }; attributes => { v: REF attributes NS.ValueObject _ NEW[attributes NS.ValueObject]; { len: INT _ SunRPC.GetInt32[h]; v.valPairs _ NEW[NS.SeqType0Object[len]]; FOR i: INT IN [0..len) DO v.valPairs[i] _ GetAttribute[h]; ENDLOOP; }; res _ v; }; any => { v: REF any NS.ValueObject _ NEW[any NS.ValueObject]; [] _ SunRPC.GetByte[h]; [] _ SunRPC.GetByte[h]; [] _ SunRPC.GetByte[h]; v.anyValue _ SunRPC.GetByte[h]; res _ v; }; ENDCASE => NULL; }; PutValue: PUBLIC PROC[h: Handle, in: NS.Value] = { PutValueType[h, in.vType]; SELECT in.vType FROM text => { v: REF text NS.ValueObject _ NARROW[in]; PutString[h, v.valStr]; }; attributes => { v: REF attributes NS.ValueObject _ NARROW[in]; SunRPC.PutInt32[h, v.valPairs.size]; FOR i: INT IN [0..v.valPairs.size) DO PutAttribute[h, v.valPairs[i]]; ENDLOOP; }; any => { v: REF any NS.ValueObject _ NARROW[in]; SunRPC.PutInt32[h, v.anyValue]; }; ENDCASE => NULL; }; GetAttribute: PUBLIC PROC[h: Handle] RETURNS [res: NS.Attribute] = { res.name _ GetString[h]; res.value _ GetValue[h]; }; PutAttribute: PUBLIC PROC[h: Handle, in: NS.Attribute] = { PutString[h, in.name]; PutValue[h, in.value]; }; GetObject: PUBLIC PROC[h: Handle] RETURNS [res: NS.Object] = { { len: INT _ SunRPC.GetInt32[h]; res _ NEW[NS.SeqType1Object[len]]; FOR i: INT IN [0..len) DO res[i] _ GetAttribute[h]; ENDLOOP; }; }; PutObject: PUBLIC PROC[h: Handle, in: NS.Object] = { SunRPC.PutInt32[h, in.size]; FOR i: INT IN [0..in.size) DO PutAttribute[h, in[i]]; ENDLOOP; }; GetProjectionList: PUBLIC PROC[h: Handle] RETURNS [res: NS.ProjectionList] = { { len: INT _ SunRPC.GetInt32[h]; res _ NEW[NS.SeqType2Object[len]]; FOR i: INT IN [0..len) DO res[i] _ GetString[h]; ENDLOOP; }; }; PutProjectionList: PUBLIC PROC[h: Handle, in: NS.ProjectionList] = { SunRPC.PutInt32[h, in.size]; FOR i: INT IN [0..in.size) DO PutString[h, in[i]]; ENDLOOP; }; GetProjectedObject: PUBLIC PROC[h: Handle] RETURNS [res: NS.ProjectedObject] = { { len: INT _ SunRPC.GetInt32[h]; res _ NEW[NS.SeqType3Object[len]]; FOR i: INT IN [0..len) DO res[i] _ GetValue[h]; ENDLOOP; }; }; PutProjectedObject: PUBLIC PROC[h: Handle, in: NS.ProjectedObject] = { SunRPC.PutInt32[h, in.size]; FOR i: INT IN [0..in.size) DO PutValue[h, in[i]]; ENDLOOP; }; ProjectTypeNames: PUBLIC ARRAY NS.ProjectType OF ROPE _ [ "projected", "complete" ]; GetProjectType: PUBLIC PROC[h: Handle] RETURNS [res: NS.ProjectType] = { res _ VAL[SunRPC.GetInt32[h]]; }; PutProjectType: PUBLIC PROC[h: Handle, in: NS.ProjectType] = { SunRPC.PutInt32[h, ORD[in]]; }; GetFoundObjects: PUBLIC PROC[h: Handle] RETURNS [res: NS.FoundObjects] = { tag: NS.ProjectType; tag _ GetProjectType[h]; SELECT tag FROM projected => { v: REF projected NS.FoundObjectsObject _ NEW[projected NS.FoundObjectsObject]; { len: INT _ SunRPC.GetInt32[h]; v.projectedObjects _ NEW[NS.SeqType4Object[len]]; FOR i: INT IN [0..len) DO v.projectedObjects[i] _ GetProjectedObject[h]; ENDLOOP; }; res _ v; }; complete => { v: REF complete NS.FoundObjectsObject _ NEW[complete NS.FoundObjectsObject]; { len: INT _ SunRPC.GetInt32[h]; v.objects _ NEW[NS.SeqType5Object[len]]; FOR i: INT IN [0..len) DO v.objects[i] _ GetObject[h]; ENDLOOP; }; res _ v; }; ENDCASE => NULL; }; PutFoundObjects: PUBLIC PROC[h: Handle, in: NS.FoundObjects] = { PutProjectType[h, in.pType]; SELECT in.pType FROM projected => { v: REF projected NS.FoundObjectsObject _ NARROW[in]; SunRPC.PutInt32[h, v.projectedObjects.size]; FOR i: INT IN [0..v.projectedObjects.size) DO PutProjectedObject[h, v.projectedObjects[i]]; ENDLOOP; }; complete => { v: REF complete NS.FoundObjectsObject _ NARROW[in]; SunRPC.PutInt32[h, v.objects.size]; FOR i: INT IN [0..v.objects.size) DO PutObject[h, v.objects[i]]; ENDLOOP; }; ENDCASE => NULL; }; GetInsertargs: PUBLIC PROC[h: Handle] RETURNS [res: NS.Insertargs] = { res.registrationKind _ GetString[h]; res.object _ GetObject[h]; res.pid _ SunRPC.GetInt32[h]; res.domain _ GetDomain[h]; }; PutInsertargs: PUBLIC PROC[h: Handle, in: NS.Insertargs] = { PutString[h, in.registrationKind]; PutObject[h, in.object]; SunRPC.PutInt32[h, in.pid]; PutDomain[h, in.domain]; }; GetInsertreturn: PUBLIC PROC[h: Handle] RETURNS [res: NS.Insertreturn] = { tag: NS.ReturnCodes; tag _ GetReturnCodes[h]; SELECT tag FROM Success => { v: REF Success NS.InsertreturnObject _ NEW[Success NS.InsertreturnObject]; v.uid _ GetString[h]; res _ v; }; ResourceFailure => { v: REF ResourceFailure NS.InsertreturnObject _ NEW[ResourceFailure NS.InsertreturnObject]; res _ v; }; IllegalFindSpec => { v: REF IllegalFindSpec NS.InsertreturnObject _ NEW[IllegalFindSpec NS.InsertreturnObject]; res _ v; }; IllegalDeleteUid => { v: REF IllegalDeleteUid NS.InsertreturnObject _ NEW[IllegalDeleteUid NS.InsertreturnObject]; res _ v; }; IllegalInsertPid => { v: REF IllegalInsertPid NS.InsertreturnObject _ NEW[IllegalInsertPid NS.InsertreturnObject]; res _ v; }; Unavailable => { v: REF Unavailable NS.InsertreturnObject _ NEW[Unavailable NS.InsertreturnObject]; res _ v; }; ENDCASE => NULL; }; PutInsertreturn: PUBLIC PROC[h: Handle, in: NS.Insertreturn] = { PutReturnCodes[h, in.returnCode]; SELECT in.returnCode FROM Success => { v: REF Success NS.InsertreturnObject _ NARROW[in]; PutString[h, v.uid]; }; ResourceFailure => { v: REF ResourceFailure NS.InsertreturnObject _ NARROW[in]; }; IllegalFindSpec => { v: REF IllegalFindSpec NS.InsertreturnObject _ NARROW[in]; }; IllegalDeleteUid => { v: REF IllegalDeleteUid NS.InsertreturnObject _ NARROW[in]; }; IllegalInsertPid => { v: REF IllegalInsertPid NS.InsertreturnObject _ NARROW[in]; }; Unavailable => { v: REF Unavailable NS.InsertreturnObject _ NARROW[in]; }; ENDCASE => NULL; }; GetDeleteargs: PUBLIC PROC[h: Handle] RETURNS [res: NS.Deleteargs] = { res.uid _ GetString[h]; res.domain _ GetDomain[h]; }; PutDeleteargs: PUBLIC PROC[h: Handle, in: NS.Deleteargs] = { PutString[h, in.uid]; PutDomain[h, in.domain]; }; GetReplaceargs: PUBLIC PROC[h: Handle] RETURNS [res: NS.Replaceargs] = { res.registrationKind _ GetString[h]; res.object _ GetObject[h]; res.uid _ GetString[h]; res.domain _ GetDomain[h]; }; PutReplaceargs: PUBLIC PROC[h: Handle, in: NS.Replaceargs] = { PutString[h, in.registrationKind]; PutObject[h, in.object]; PutString[h, in.uid]; PutDomain[h, in.domain]; }; GetFindargs: PUBLIC PROC[h: Handle] RETURNS [res: NS.Findargs] = { res.patterns _ GetObject[h]; res.projection _ GetProjectionList[h]; res.domain _ GetDomain[h]; }; PutFindargs: PUBLIC PROC[h: Handle, in: NS.Findargs] = { PutObject[h, in.patterns]; PutProjectionList[h, in.projection]; PutDomain[h, in.domain]; }; GetFindreturn: PUBLIC PROC[h: Handle] RETURNS [res: NS.Findreturn] = { tag: NS.ReturnCodes; tag _ GetReturnCodes[h]; SELECT tag FROM Success => { v: REF Success NS.FindreturnObject _ NEW[Success NS.FindreturnObject]; v.objects _ GetFoundObjects[h]; res _ v; }; ResourceFailure => { v: REF ResourceFailure NS.FindreturnObject _ NEW[ResourceFailure NS.FindreturnObject]; res _ v; }; IllegalFindSpec => { v: REF IllegalFindSpec NS.FindreturnObject _ NEW[IllegalFindSpec NS.FindreturnObject]; res _ v; }; IllegalDeleteUid => { v: REF IllegalDeleteUid NS.FindreturnObject _ NEW[IllegalDeleteUid NS.FindreturnObject]; res _ v; }; IllegalInsertPid => { v: REF IllegalInsertPid NS.FindreturnObject _ NEW[IllegalInsertPid NS.FindreturnObject]; res _ v; }; Unavailable => { v: REF Unavailable NS.FindreturnObject _ NEW[Unavailable NS.FindreturnObject]; res _ v; }; ENDCASE => NULL; }; PutFindreturn: PUBLIC PROC[h: Handle, in: NS.Findreturn] = { PutReturnCodes[h, in.returnCode]; SELECT in.returnCode FROM Success => { v: REF Success NS.FindreturnObject _ NARROW[in]; PutFoundObjects[h, v.objects]; }; ResourceFailure => { v: REF ResourceFailure NS.FindreturnObject _ NARROW[in]; }; IllegalFindSpec => { v: REF IllegalFindSpec NS.FindreturnObject _ NARROW[in]; }; IllegalDeleteUid => { v: REF IllegalDeleteUid NS.FindreturnObject _ NARROW[in]; }; IllegalInsertPid => { v: REF IllegalInsertPid NS.FindreturnObject _ NARROW[in]; }; Unavailable => { v: REF Unavailable NS.FindreturnObject _ NARROW[in]; }; ENDCASE => NULL; }; END.