DIRECTORY Rope USING [ROPE], XNS USING [Address], XNSCH USING [Item, Name]; XNSCHItemOps: CEDAR DEFINITIONS = BEGIN ROPE: TYPE = Rope.ROPE; Name: TYPE = XNSCH.Name; Address: TYPE = XNS.Address; Item: TYPE = XNSCH.Item; RopeList: TYPE = LIST OF ROPE; NameList: TYPE = LIST OF Name; AddressList: TYPE = LIST OF Address; Error: ERROR [reason: ErrorType]; ErrorType: TYPE = { itemLength }; BoolFromItem: PROC [item: Item, index: CARDINAL ¬ 0] RETURNS [bool: BOOL, nextPos: CARDINAL]; Int16FromItem: PROC [item: Item, index: CARDINAL ¬ 0] RETURNS [int: INT16, nextPos: CARDINAL]; Int32FromItem: PROC [item: Item, index: CARDINAL ¬ 0] RETURNS [int: INT32, nextPos: CARDINAL]; Card16FromItem: PROC [item: Item, index: CARDINAL ¬ 0] RETURNS [card: CARD16, nextPos: CARDINAL]; Card32FromItem: PROC [item: Item, index: CARDINAL ¬ 0] RETURNS [card: CARD32, nextPos: CARDINAL]; RopeFromItem: PROC [item: Item, index: CARDINAL ¬ 0] RETURNS [rope: ROPE, nextPos: CARDINAL]; NameFromItem: PROC [item: Item, index: CARDINAL ¬ 0] RETURNS [name: Name, nextPos: CARDINAL]; AddressFromItem: PROC [item: Item, index: CARDINAL ¬ 0] RETURNS [address: XNS.Address, nextPos: CARDINAL]; RopeListFromItem: PROC [item: Item, index: CARDINAL ¬ 0] RETURNS [ropes: RopeList, nextPos: CARDINAL]; NameListFromItem: PROC [item: Item, index: CARDINAL ¬ 0] RETURNS [names: NameList, nextPos: CARDINAL]; AddressListFromItem: PROC [item: Item, index: CARDINAL ¬ 0] RETURNS [addresses: AddressList, nextPos: CARDINAL]; ItemFromBool: PROC [bool: BOOL, index: CARDINAL ¬ 0, item: Item ¬ NIL] RETURNS [newItem: Item, nextPos: CARDINAL]; ItemFromInt16: PROC [int: INT16, index: CARDINAL ¬ 0, item: Item ¬ NIL] RETURNS [newItem: Item, nextPos: CARDINAL]; ItemFromInt32: PROC [int: INT32, index: CARDINAL ¬ 0, item: Item ¬ NIL] RETURNS [newItem: Item, nextPos: CARDINAL]; ItemFromCard16: PROC [card: CARD16, index: CARDINAL ¬ 0, item: Item ¬ NIL] RETURNS [newItem: Item, nextPos: CARDINAL]; ItemFromCard32: PROC [card: CARD32, index: CARDINAL ¬ 0, item: Item ¬ NIL] RETURNS [newItem: Item, nextPos: CARDINAL]; ItemFromAddress: PROC [address: Address, index: CARDINAL ¬ 0, item: Item ¬ NIL] RETURNS [newItem: Item, nextPos: CARDINAL]; ItemFromRope: PROC [rope: ROPE, index: CARDINAL ¬ 0, item: Item ¬ NIL] RETURNS [newItem: Item, nextPos: CARDINAL]; ItemFromName: PROC [name: Name, index: CARDINAL ¬ 0, item: Item ¬ NIL] RETURNS [newItem: Item, nextPos: CARDINAL]; ItemFromAddressList: PROC [addresses: AddressList, index: CARDINAL ¬ 0, item: Item ¬ NIL] RETURNS [newItem: Item, nextPos: CARDINAL]; ItemFromRopeList: PROC [ropes: RopeList, index: CARDINAL ¬ 0, item: Item ¬ NIL] RETURNS [newItem: Item, nextPos: CARDINAL]; ItemFromNameList: PROC [names: NameList, index: CARDINAL ¬ 0, item: Item ¬ NIL] RETURNS [newItem: Item, nextPos: CARDINAL]; SizeOfBool: PROC RETURNS [size: CARDINAL]; SizeOfInt16: PROC RETURNS [size: CARDINAL]; SizeOfInt32: PROC RETURNS [size: CARDINAL]; SizeOfCard16: PROC RETURNS [size: CARDINAL]; SizeOfCard32: PROC RETURNS [size: CARDINAL]; SizeOfRope: PROC [rope: ROPE] RETURNS [size: CARDINAL]; SizeOfName: PROC [name: Name] RETURNS [size: CARDINAL]; SizeOfAddress: PROC RETURNS [size: CARDINAL]; SizeOfRopeList: PROC [ropes: RopeList] RETURNS [size: CARDINAL]; SizeOfNameList: PROC [names: NameList] RETURNS [size: CARDINAL]; SizeOfAddressList: PROC [addresses: AddressList] RETURNS [size: CARDINAL]; CreateNewItem: PROC [size: CARDINAL, index: CARDINAL ¬ 0, item: Item ¬ NIL] RETURNS [newItem: Item]; BoolIntoItem: PROC [item: Item, bool: BOOL, index: CARDINAL ¬ 0] RETURNS [nextPos: CARDINAL]; Int16IntoItem: PROC [item: Item, int: INT16, index: CARDINAL ¬ 0] RETURNS [nextPos: CARDINAL]; Int32IntoItem: PROC [item: Item, int: INT32, index: CARDINAL ¬ 0] RETURNS [nextPos: CARDINAL]; Card16IntoItem: PROC [item: Item, card: CARD16, index: CARDINAL ¬ 0] RETURNS [nextPos: CARDINAL]; Card32IntoItem: PROC [item: Item, card: CARD32, index: CARDINAL ¬ 0] RETURNS [nextPos: CARDINAL]; RopeIntoItem: PROC [item: Item, rope: ROPE, index: CARDINAL ¬ 0] RETURNS [nextPos: CARDINAL]; NameIntoItem: PROC [item: Item, name: Name, index: CARDINAL ¬ 0] RETURNS [nextPos: CARDINAL]; AddressIntoItem: PROC [item: Item, address: Address, index: CARDINAL ¬ 0] RETURNS [nextPos: CARDINAL]; RopeListIntoItem: PROC [item: Item, ropes: RopeList, index: CARDINAL ¬ 0] RETURNS [nextPos: CARDINAL]; NameListIntoItem: PROC [item: Item, names: NameList, index: CARDINAL ¬ 0] RETURNS [nextPos: CARDINAL]; AddressListIntoItem: PROC [item: Item, addresses: AddressList, index: CARDINAL ¬ 0] RETURNS [nextPos: CARDINAL]; END. È XNSCHItemOps.mesa Copyright Ó 1988, 1991 by Xerox Corporation. All rights reserved. Wes Irish, November 15, 1988 11:32:45 am PST For marshaling and unmarshaling XNSCH.Item. Some sample usages: To Unmarshal an Item that represents an XNSCH.Name: name: XNSCH.Name _ XNSCHItemOps.NameFromItem[item].name; To Create an Item containing a list of ropes: item _ XNSCHItemOps.ItemFromRopeList[LIST["First Rope", "Second Rope", "Etc..."]].item To Unmarshal the above example: ropeList: XNSCHItemOps.RopeList _ XNSCHItemOps.RopeListFromItem[item].ropes To Unmarshal an Item that represents a RECORD: mailboxInfo: RECORD [ time: CARD32, mailboxList: NameList ]; pos: CARDINAL; [mailboxInfo.time, pos] _ XNSCHItemOps.Card32FromItem[item, 0]; [mailboxInfo.mailboxList, pos] _ XNSCHItemOps.NameListFromItem[item, pos]; -- or, if you are only interested in the mailboxList: mailboxList: NameList _ XNSCHItemOps.NameListFromItem[item, XNSCHItemOps.SizeOfCard32[]].names; Errors Unmarshaling PROCs These PROCs take an Item and a starting index and return the unmarshaled data and the nextPos (where the next marshaled data should start). nextPos is normally used as the index to the next call within the same Item. nextPos >= item.length when you have exhausted the item. Will raise Error[itemLength] if unmarshaling runs off the end of the item. The following unmarshal a SEQUENCE of xxx from the Item into a LIST for Cedar. "Simple" Marshaling PROCs: These PROCs take your data and optionally a starting index and item. They create newItem big enough to accomadate your new data and/or the original item. All data from the original item is copied to newItem. Next, your new data is marshaled into newItem starting at index returning newItem and nextPos. nextPos is normally used as the index to the next call within the same Item. Will NOT raise Error[itemLength] since a new item is created of the needed size. The rest of the PROCs in this interface are utilities and/or for doing things more efficiently than making multiple calls to ItemFromXxx for "compound" items. SizeOf PROCs SizeOf... returns the number of (16 bit) words it would take to marshal the given data. This includes any overhead words, such as length information. Creates a new Item of size MAX[oldLength, index+size], where oldLength is item.length or 0 if item is NIL. The following follow the this model: you hand in an Item and a starting index and the PROC marshals your data and returns nextPos, that is where you should start your next marshaled data. nextPos is normally used as index to the next call within the same Item. nextPos >= item.length when you have filled the item. Will raise Error[itemLength] if marshaling runs off the end of the item. ÊÆ•NewlineDelimiter –(cedarcode) style™šœ™Jšœ Ïeœ6™BIcodešœ,™,J™—šÏk ˜ Kšœžœžœ˜Kšžœžœ ˜Kšžœžœ˜—K˜Kšœ žœ™+K˜šÐbn œžœž œ˜"Kšž˜K˜Kšžœžœžœ˜Kšœžœžœ˜Kšœ žœžœ ˜Kšœžœžœ˜K˜Kš œ žœžœžœžœ˜Kšœ žœžœžœ˜Kšœ žœžœžœ ˜$K˜J™šœ™J™šœ(žœ™3Kšœžœ-™8K™—šœ-™-Jšœ%žœ-™VJ™—šœ™JšœK™KJ™—šœ'žœ™.šœ žœ™Kšœžœ™ Kšœ™Kšœ™—Kšœžœ™Kšœ?™?KšœJ™JK™KšÏc5™5K™Kšœ_™_J™—K˜K˜—KšÏb™K™KšÏnœžœ˜!Kšœ žœ˜!K˜K˜š¡™K™Kšœ“™“K™KšœJ™J—K™Kš Ÿ œžœžœžœžœ žœ˜]Kš Ÿ œžœžœžœžœ žœ˜^Kš Ÿ œžœžœžœžœ žœ˜^Kš Ÿœžœžœžœžœ žœ˜aKš Ÿœžœžœžœžœ žœ˜aKš ¢ œžœžœžœžœ žœ˜]Kš ¢ œžœžœžœžœ˜]Kš ¢œžœžœžœ žœžœ˜jK™Kšœžœžœ ™NK˜Kš ¢œžœžœžœžœ˜fKš ¢œžœžœžœžœ˜fKš ¢œžœžœžœ#žœ˜pK˜K˜K˜š¡™K™Kšœÿ™ÿK™KšœžœH™P—J™KšŸ œžœžœ žœžœžœžœ˜rKšŸ œžœžœ žœžœžœžœ˜sKšŸ œžœžœ žœžœžœžœ˜sKšŸ ¢œžœžœ žœžœžœžœ˜vKšŸœžœžœ žœžœžœžœ˜vKš Ÿœžœžœžœžœžœ˜{KšŸ œžœžœ žœžœžœžœ˜rKš Ÿ œžœžœžœžœžœ˜rK™Kš Ÿœžœ!žœžœžœžœ˜…Kš Ÿ¢œžœžœžœžœžœ˜{š Ÿ ¢œžœžœžœžœžœ˜{K™—K™K™K™žK™š¡ ™ K™Kšœ–™–—K˜KšŸ œžœžœžœ˜*KšŸ œžœžœžœ˜+KšŸ œžœžœžœ˜+KšŸ œžœžœžœ˜,KšŸ œžœžœžœ˜,Kš Ÿ œžœžœžœžœ˜7KšŸ œžœžœžœ˜7šŸ œžœžœžœ˜-J™—Kš Ÿ ¢œžœžœžœ˜@Kš Ÿ ¢œžœžœžœ˜@šŸœžœžœžœ˜JJ™—K™š ¢ œžœžœ žœžœžœ˜dKšœžœHžœ™j—K˜K˜KšœVžœâ™¼K™šœH™HK™—Kš Ÿ œžœžœ žœžœ žœ˜]Kš Ÿ œžœžœ žœžœ žœ˜^Kš Ÿ œžœžœ žœžœ žœ˜^Kš Ÿœžœžœ žœžœ žœ˜aKš Ÿœžœžœ žœžœ žœ˜aKš Ÿ œžœžœ žœžœ žœ˜]Kš Ÿ œžœ!žœžœ žœ˜]Kš Ÿœžœ'žœžœ žœ˜fK™Kš Ÿœžœ&žœžœ žœ˜fKš Ÿœžœ&žœžœ žœ˜fKš Ÿœžœ-žœžœ žœ˜pK˜Kšžœ˜——…—ø$†