Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
ResolvConfParser


NAME

ResolvConfParser - parse resolv.conf configuration files

SYNOPSIS

TYPE Configuration = POINTER TO ConfigurationRec;
TYPE ConfigurationRec = RECORD (Disciplines.DisciplineRec) END;


TYPE SortListMember = POINTER TO SortListMemberRec; TYPE SortListMemberRec = RECORD (Objects.ObjectRec) ipaddr: IPv4Addresses.Address; netmask: IPv4Addresses.Address; netmaskDefined: BOOLEAN; END;

TYPE NameServer = POINTER TO NameServerRec; TYPE NameServerRec = RECORD (Objects.ObjectRec) ipaddr: IPv4Addresses.Address; END;

TYPE Option = POINTER TO OptionRec; TYPE OptionRec = RECORD (Objects.ObjectRec) name: ConstStrings.String; value: INTEGER; (* 1 for set BOOLEAN options *) END;

CONST dottedDecimalExpected = 0; CONST keywordExpected = 1; CONST domainExpected = 2; CONST multipleDomains = 3; CONST integerExpected = 3; CONST errors = 5; TYPE ErrorCode = SHORTINT; (* dottedEcimalExpected... *) TYPE ErrorEvent = POINTER TO ErrorEventRec; TYPE ErrorEventRec = RECORD (Events.EventRec) errorcode: ErrorCode; line, col: INTEGER; END; VAR error: Events.EventType; VAR errormsg: ARRAY errors OF Events.Message;

PROCEDURE Parse(VAR conf: Configuration; s: Streams.Stream; errors: RelatedEvents.Object) : BOOLEAN;

PROCEDURE IterateNameServers(conf: Configuration; VAR it: Iterators.Iterator);

PROCEDURE IterateSearchList(conf: Configuration; VAR it: Iterators.Iterator);

PROCEDURE IterateSortLists(conf: Configuration; VAR it: Iterators.Iterator);

PROCEDURE IterateOptions(conf: Configuration; VAR it: Iterators.Iterator);

PROCEDURE GetOption(conf: Configuration; name: ARRAY OF CHAR; VAR value: INTEGER) : BOOLEAN;

PROCEDURE GetLocalDomain(conf: Configuration; VAR domain: ARRAY OF CHAR) : BOOLEAN;

DESCRIPTION

ResolvConfParser parses configuration files that conform to resolv.conf(5). This module does not impose the limits of the traditional resolver library for C. The number of nameservers is not limited and conflicting configurations like ``domain'' and ``search'' can co-exist.

Parse parses s and creates a configuration conf.

IterateNameServers creates an iterator that returns objects of type NameServer for each of the ``nameserver'' declarations within the configuration conf.

IterateSearchList creates an iterator that returns objects of type ConstStrings.String for each of the domains that are specified within the ``search'' declaration.

IterateSortLists creates an iterator that returns objects of type SortListMember for each of the networks that are specified within the ``sortlist'' declaration.

Iterators created by IterateOption return an object of type Option for all options that are declared with an ``option'' directive. GetOption allows to retrieve option values by option names. FALSE is returned if an option named name was not found within the configuration.

GetLocalDomain returns the domain specified with the ``domain'' directive, if provided.

DIAGNOSTICS

Parse generates error events and returns FALSE in case of syntax errors:
dottedDecimalExpected
a dotted decimal (e.g. ``127.0.0.1'') was expected but not found
keywordExpected
a keyword (e.g. ``nameserver'') was expected but not found
domainExpected
a valid domain name was expected but not found
multipleDomains
more than one ``domain'' declaration was found
integerExpected
an integer value was expected but not found

FILES

/etc/resolv.conf
The standard location for this configuration file.

SEE ALSO

DNSStdResolvers
implements DNSResolvers using configuration files of this type

Edited by: borchert, last change: 2004/03/10, revision: 1.1, converted to HTML: 2004/03/10

Oberon || Library || Module Index || Search Engine || Definition || Module