<> <> <> <> <> <> FileOps: CEDAR DEFINITIONS = BEGIN Op: TYPE = CHAR; endOfFile: Op = 0C; startNode: Op = endOfFile+1; <> <> <> startNodeFirst: Op = startNode+1; startNodeLast: Op = startNodeFirst+numFormats; <> <> <> terminalTextNode: Op = startNodeLast+1; terminalTextNodeFirst: Op = terminalTextNode+1; terminalTextNodeLast: Op = terminalTextNodeFirst+numFormats; <> <> <> <> otherNode: Op = terminalTextNodeLast+1; <> <> <> <> otherNodeShort: Op = otherNode+1; <> otherNodeSpecs: Op = otherNodeShort+1; <> <> <> <> <> otherNodeSpecsShort: Op = otherNodeSpecs+1; <> prop: Op = otherNodeSpecsShort+1; <> <> <> <> <> <> propShort: Op = prop+1; <> endNode: Op = propShort+1; <> rope: Op = endNode+1; <> <> <> <> comment: Op = rope+1; <> runs: Op = comment+1; <> <> <> looks: Op = runs+1; <> <> <> <> looksFirst: Op = looks+1; looksLast: Op = looksFirst+numLooks; <> <> <> look1: Op = looksLast+1; <> look2: Op = look1+1; <> look3: Op = look2+1; <> numFormats: CARDINAL = 70; <> <> FormatIndex: TYPE = [0..numFormats); numLooks: CARDINAL = 50; <> <> <> LooksIndex: TYPE = [0..numLooks); numProps: CARDINAL = 50; <> PropIndex: TYPE = [0..numProps); <> <> <> <> <> <> IntBytes: TYPE = MACHINE DEPENDENT RECORD [ first (0:9..15): [0..127] _ 0, -- first byte written on file second (0:2..8): [0..127] _ 0, -- second byte written thirdBottom (0:0..1): [0..3] _ 0, -- bottom bits of third byte written thirdTop (1:11..15): [0..31] _ 0, -- top bits of third byte written fourth (1:4..10): [0..127] _ 0, -- fourth byte written unused (1:0..3): [0..15] _ 0 -- these are always 0 ]; LengthByte: TYPE = MACHINE DEPENDENT RECORD [ unused (0:0..7): [0..255] _ 0, others (0:8..8): BOOL _ FALSE, -- tells if other bytes are present data (0:9..15): [0..127] _ 0 ]; ThirdByte: TYPE = MACHINE DEPENDENT RECORD [ unused (0:0..7): [0..255] _ 0, others (0:8..8): BOOL _ FALSE, dataTop (0:9..13): [0..31] _ 0, -- top 5 bits of data dataBottom (0:14..15): [0..3] _ 0 -- bottom 2 bits of data ]; <<>> <> commentHeaderId: ARRAY [0..fileIdSize) OF CHAR = [0C,0C]; controlHeaderId: ARRAY [0..fileIdSize) OF CHAR = [235C,312C]; controlTrailerId: ARRAY [0..fileIdSize) OF CHAR = [205C,227C]; fileIdSize: NAT = 2; numTrailerLengths: NAT = 3; -- endSize: NAT = fileIdSize+numTrailerLengths*4; -- trailer plus three lengths END. Tioga file format is as follows: == == characters from (non-comment) nodes in display order with a CR after each node == == == byte length of == characters from comment nodes in display order with a CR after each node == == == == [..bytes..] as defined above Thus start with double 0's which can serve to mark end of . == byte length of == == gives length of == == [..bytes..] as defined above == byte address in file for start of comments == sequence of control bytes and control text. The last thing in the file is the . Thus to read a file, first check the and read the byte address for the . We also read the saved as a double check. The saved is a 4 byte checksum of the data part of the file. This lets us read the where we double check to make sure we have a valid file by reading the and the . Then we go to the , checking the and reading the . Finally, we check that ++ = . The , , and are written node by node starting at the root. For each node the following steps are taken: 1. Output a start node control byte of the appropriate sort. either startNode, terminalTextNode, otherNode, otherNodeShort, or something in the startNodeFirst..startNodeLast range or in the terminalTextNodeFirst..terminalTextNodeLast range. 2. Output the properties, if any, of the node. if the value is a rope, output ropeProp or ropePropShort else if the value is a node, output nodeProp or nodePropShort. then output the value itself text for props is put in rather than 3. Output the contents of the node. for a text node, first write the runs info, if any, and then the rope. if it is a comment node, then the text goes in comments, else it goes in data. for other varieties of node, write otherNodeSpecs or otherNodeSpecsShort followed by the text of the specifications. 4. Output the children of the node, if any, in the same manner 5. Output an endNode byte, unless this is a terminal text node Following the end of the root node, there is an endOfFile byte.