A Vision for Open Hypermedia Systems |
Nürnberg and Leggett |
Appendix A. Generic Encoding Layer Rules
The following is an algorithm to map a set of generic structure
objects to a byte stream suitable for transport with an OSI Layer 4
transport mechanism. The corresponding algorithm to map a byte stream
to an object is not provided, but is easily derived from this
algorithm.
Let:
- an object obji be defined as
{contenti, attrsi,
endsetsi};
- contenti be an arbitrary byte block of known
size sizeof (contenti);
- attrsi be an array of known size sizeof
(attrsi);
- each element of attrsi, say
attrsi,j, be defined as
{attr_namei,j, valuesi,j};
- valuesi,j be an array of known size sizeof
(valuesi,j);
- attr_namei,j and each member of
valuesi,j, say valuesi,j,k, be a
NULL-terminated string;
- endseti be an array of known size sizeof
(endseti);
- each element of endseti, say
endseti,j, be defined as
{endset_namei,j, endpointsi,j};
- endpointsi,j be an array of known size sizeof
(endpointsi,j);
- endset_namei,j be a NULL-terminated string;
- each member of endpointsi,j, say
endpointsi,j,k, be an arbitrary byte block of known
size sizeof (endpointsi,j,k;
- sizeof (x), where x is a NULL-terminated string,
return the number of bytes (including the NULL termination byte) in
the string; and,
- sizeof (x) return an 8 byte integer.
Also, in the algorithm, let:
- size and offset be 8 byte integers;
- block be a block of memory that may be indexed by
offset; and,
- append (block, offset, param, param_size) be an
operation that copies param_size bytes from param into
the memory starting offset bytes into block, and that
increments offset by param_size.
Given {obji}, do:
1. Set size and offset to 0.
2. For each object obji,j, do:
2.1 append (block, offset, sizeof (contenti),
8)
2.2 append (block, offset, contenti, sizeof
(contenti))
2.3 For each attribute attri,j, do:
2.3.1 append (block, offset, attr_namei,j,
sizeof (attr_namei,j))
2.3.2 append (block, offset, sizeof (attri,j),
8)
2.3.3 For each attribute value valuesi,j,k, do:
2.3.3.1 append (block, offset, valuesi,j,k,
sizeof (valuesi,j,k)
2.4 For each endset endseti,j, do:
2.4.1 append (block, offset, endset_namei,j,
sizeof (endset_namei,j))
2.4.2 append (block, offset, sizeof
(endseti,j), 8)
2.4.3 For each endpoint endpointsi,j,k,
do:
2.4.3.1 append (block, offset, sizeof
(endpointsi,j,k), 8)
2.4.3.2 append (block, offset,
endpointsi,j,k, sizeof (endpointsi,j,k))
The byte stream that is written to the Transport Layer is the 8 byte
integer size followed by the size byte block
block.
Ignored here are issues about integer representation (e.g., 1's
complement, 2's complement, etc.) and byte-order. These issues must be
addressed by the OHSWG.
Contents
Peter J. Nürnberg,
John J. Leggett
HRL,
CSDL,
Texas A&M
original page URL: http://jodi.ecs.soton.ac.uk/Articles/v01/i02/Nurnberg/appa.html