XNSAddressParsing.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Demers, October 16, 1986 10:07:06 am PDT
Translations between ROPEs and XNS.Addresses. For Clearinghouse name lookup see XNSClearinghouse.df.
DIRECTORY
Rope USING [ROPE],
XNS USING [Address, Host, Net, unknownSocket, Socket];
XNSAddressParsing: CEDAR DEFINITIONS ~ {
ROPE: TYPE ~ Rope.ROPE;
Address: TYPE ~ XNS.Address;
Net: TYPE ~ XNS.Net;
Host: TYPE ~ XNS.Host;
Socket: TYPE ~ XNS.Socket;
Syntax
A fully specified address string is of the form
<netNumber>.<hostNumber>.<socketNumber> or
<netNumber>#<hostNumber>#<socketNumber>
A number can have one of several forms:
1) Decimal: a sequence of characters in ['0..'9] optionally followed by 'D or 'd. The string may also have '- characters embedded, implying product format. A leading '- is not allowed.
2) Octal: a sequence of characters in ['0..'7] followed by 'B or 'b.
3) Hex: a sequence of characters in {IN['0..'9], IN['A..'F], IN['a..'f]} beginning with a digit and followed by 'H or 'h. The trailing 'H or 'h is optional if at least one character is in {IN['A..'F], IN['a..'f]}.
Additional forms are allowed for nostNumber:
4) The special string "ME" (in upper case), which is equivalent to specifing the Processor ID (XNS Host number) of the host where the code is running.
5) The special string "*", which is equivalent to specifing the broadcast XNS Host number.
The hostNumber must always be supplied. Both netNumber and socketNumber can be defaulted.
The translation routine will translate any string that is well formed and unambiguous.
Acceptable examples:
74B#25200000016#2
25200000016B
ME
*
1-000.ME.
131B.*.
#25200000016B#2
Ambiguous (because pair could mean net#host or host#socket):
74#2
Local Address
MyAddress: PROC RETURNS [Address];
Returns best address for this machine, with socket set to XNS.unknownSocket.
XNS.unknownAddress might happen if there are no drivers active.
MyRope: PROC [format: Format ← productSoftware] RETURNS [ROPE];
Equivalent to RopeFromAddress[MyAddress[], format];
Rope/Address translation
AddressFromRope: PROC [rope: ROPE, default: Socket ← XNS.unknownSocket] RETURNS [Address];
Parses the rope to an address.
If rope doesn't specify any socket number, then default will be used. The idea is that a program can have a well-known default socket number, but a wizard can specify a different socket number for debugging.
NetFromRope: PROC [rope: ROPE] RETURNS [Net];
HostFromRope: PROC [rope: ROPE] RETURNS [Host];
SocketFromRope: PROC [rope: ROPE] RETURNS [Socket];
Rope should represent a (single) number, with no '. or '# characters. Thus, for example, HostFromRope["12"] = AddressFromRope["1.12.123"].host
Format: TYPE ~ { octal, hex, productSoftware };
Controls the format in which a network address gets expanded by RopeFromAddress. "Octal" and "hex" do the obvious; "productSoftware" converts each field to decimal and inserts a '-' every 3 digits, starting from the right.
RopeFromAddress: PROC [address: Address, format: Format ← productSoftware] RETURNS [ROPE];
Returns a ROPE of the form "1.12.123".
An unknownSocket is expanded as the null string, e.g. "1.12." (no trailing 0).
RopeFromNet: PROC [net: Net, format: Format ← productSoftware] RETURNS [ROPE];
RopeFromHost: PROC [host: Host, format: Format ← productSoftware] RETURNS [ROPE];
RopeFromSocket: PROC [socket: Socket, format: Format ← productSoftware] RETURNS [ROPE];
Errors
ErrorCode: TYPE = { syntax, noResponse, errorFromServer, other };
For now we're not using Clearinghouse, so most of these "can't happen".
Error: ERROR [code: ErrorCode, text: ROPE];
}.