SunYPAgent.mesa
Copyright Ó 1991 by Xerox Corporation. All rights reserved.
Demers, November 23, 1988 6:04:08 pm PST
DIRECTORY
Arpa USING [Address, nullAddress],
Rope USING [ROPE],
SunRPCAuth USING [Conversation],
SunYP USING [EachMapNameProc]
;
SunYPAgent: CEDAR DEFINITIONS
~ {
Types
ROPE: TYPE ~ Rope.ROPE;
Handle: TYPE ~ REF Object;
Object: TYPE;
Procedures
ObtainHandle: PROC [domainName: ROPE ¬ NIL, conversation: SunRPCAuth.Conversation ¬ NIL, serverAddress: Arpa.Address ¬ Arpa.nullAddress] RETURNS [h: Handle];
Obtain a handle to talk to a server for the specified domain (or to the default domain if "domainName" is allowed to default to NIL).
If a conversation is specified, that one is used; otherwise null credentials are used to create a conversation. In any case, the conversation is owned by the handle — client should not call SunRPCAuth.Terminate[c].
If a server is specified, that one is used; otherwise the agent tries to find a server.
! Error[$noYP | $domainNotFound | $timeout | $protocol].
RefreshHandle: PROC [h: Handle, conversation: SunRPCAuth.Conversation ¬ NIL, serverAddress: Arpa.Address ¬ Arpa.nullAddress];
Point h at a (another) server for the domain associated with h.
If a conversation is specified, that one is used; otherwise null credentials are used to create a conversation.
If a server is specified, that one is used; otherwise the agent tries to find a server.
! Error[$noYP | $domainNotFound | $timeout | $protocol].
ReleaseHandle: PROC [h: Handle];
It's okay to drop one on the floor occasionally.
Match: PROC [h: Handle, map: ROPE, key: ROPE] RETURNS [val: REF TEXT];
Find entry matching key in the given map.
! Error[$mapNotFound | $keyNotFound | $timeout | $protocol]
First: PROC [h: Handle, map: ROPE] RETURNS [key: ROPE, val: REF TEXT];
Return the first entry in the specified map.
! Error[$noMoreEntries | $mapNotFound | $keyNotFound | $timeout | $protocol]
Next: PROC [h: Handle, map: ROPE, keyBefore: ROPE] RETURNS [key: ROPE, val: REF TEXT];
Return the next entry in the specified map.
! Error[$noMoreEntries | $mapNotFound | $keyNotFound | $timeout | $protocol]
MapList: PROC [h: Handle, eachMap: SunYP.EachMapNameProc];
! Error[$moreEntries | $timeout | $protocol]
Utilities
For parsing values from the YP data bases
TextSeq: TYPE ~ REF TextSeqObject;
TextSeqObject: TYPE ~ RECORD [
length: CARDINAL,
refText: SEQUENCE maxLength: CARDINAL OF REF TEXT
];
Tokenize: PROC [in: REF READONLY TEXT] RETURNS [out: TextSeq];
Separate into tokens, delimited by white space.
TokenizeUsingSeparator: PROC [in: REF READONLY TEXT, sepChar: CHAR, trimLeadingSpace, trimTrailingSpace: BOOL ¬ TRUE] RETURNS [out: TextSeq];
Separate into tokens, delimited by occurrences of sepChar.
If requested, leading/trailing white space is trimmed from tokens.
Error
Error: ERROR [code: ATOM];
Codes:
$domainNameTooLong : see SunYP for max length.
$mapNameTooLong: see SunYP for max length.
$keyTooLong: see SunYP for max length.
$valueTooLong: see SunYP for max length.
$noYP : specified server not exporting YP.
$domainNotFound : can't find server for specified domain.
$mapNotFound : can't find specified map on server.
$keyNotFound : can't find entry with given key in map.
$noMoreEntries : for Next.
$moreEntries : couldn't get them all with MapList.
$timeout : timed out without getting a response from server.
$protocol : I'm confused.
}...