Copyright ©1995 by NeXT Computer, Inc.  All Rights Reserved.

NIDomain



Inherits From: Object
Declared In: nikit/NIDomain.h



Class Description

NIDomain provides a connection to and interface with a NetInfo domain.



Instance Variables

char *fullPath;

char *masterServer;

char *currentServer;

char *domainTag;

id parentDomain;

id delegate;





char *parentDomainName;

void *domainHandle;

ni_status whatHappened;

BOOL connected;

ni_id  rootDirectory;

ni_fancyopenargs fancyStuff;

struct sockaddr_in  hostSocket;

struct hostent *serverHostEnt;

NXZone *domainZone;


fullPath The fully qualified pathname of the domain.
masterServer The host name of the master server of the domain.
currentServer The host name of the current server with which the object is communicating.
domainTag The domain tag.
parentDomain The parent domain object, if it's been opened.
delegate The delegate of the NIDomain object.
parentDomainName The fully qualified name of the parent domain.
domainHandle The NetInfo handle to the domain.
whatHappened The last error condition from a NetInfo call.
connected Indicates if a domain connection is open.
rootDirectory The NetInfo directory ID for the root directory of the domain.
fancyStuff Various parameter settings when a connection is set with arguments.
hostSocket The socket used when querying for a host name.
serverHostEnt The hostent used when querying for a host name.
domainZone Memory allocation zone.



Method Types

Allocating and initializing an NIDomain object
+ alloc
+ allocFromZone:
init
Freeing an NIDomain object free
Connecting to or disconnecting from a domain
setConnection:
setConnection:readTimeout:writeTimeout:canAbort:
mustWrite:
setTaggedConnection:to:
setTaggedConnection:to:readTimeout:writeTimeout:
canAbort:
disconnectFromCurrent:
Getting data about or from the current domain
getFullPath
getMasterServer
getCurrentServer
getTag
getServerIPAddress
getDomainHandle
findDirectory:withProperty:
Checking the error status lastError
Assigning a delegate setDelegate:



Class Methods

alloc
+ alloc

Returns a new NIDomain instance.  You should initialize this object by sending it an init message.



allocFromZone:
+ allocFromZone:(NXZone *)zone

Returns a new NIDomain instance.  Memory for the new object is allocated from zone.  You should initialize this object by sending it an init message.



Instance Methods

disconnectFromCurrent
disconnectFromCurrent

Terminates the connection to a domain but retains the NIDomain object.  Resets all instance variable values.  Returns self.



findDirectory:withProperty:
(ni_entrylist *)findDirectory:(const char *)parentDirectory
withProperty:(const char *)property

Returns a list containing the values associated with the indicated property in the named NetInfo directory.  The caller should free this list when it's no longer needed.  This method returns NULL if it couldn't read the requested information.  You can find the reason for the failure with lastError.



free
free

Deallocates the NIDomain object.  Returns nil.



getCurrentServer
(const char *)getCurrentServer

Returns the host name of the current server of the domain, or NULL if the object isn't currently connected to a domain or the host name couldn't be resolved.



getDomainHandle
(void *)getDomainHandle

Returns the NetInfo handle to the current domain, or NULL if no connection exists.  If this function returns NULL, you might be able to find out why with lastError.



getFullPath
(const char *)getFullPath

Returns the fully qualified pathname of the current domain, or NULL if the path couldn't be resolved.  If this function returns NULL, invoking lastError might help you find out the cause.



getMasterServer
(const char *)getMasterServer

Returns the host name of the master server of the current domain, or NULL if the object isn't currently connected to a domain or the host name couldn't be resolved.



getServerIPAddress
(const struct sockaddr_in *)getServerIPAddress

Returns the socket address of the current server of the current domain.  If an error occurs, NULL is returned.  If the object is connected, invoking lastError should return the reason for the failure.



getTag
(const char *)getTag

Returns the tag of the current domain, or NULL if there's no current connection or if it couldn't read the master server property. If the object is connected, invoking lastError should return the reason for the failure.



init
init

Initializes a newly allocated NIDomain instance.  The new instance isn't connected.  Returns self.



lastError
(ni_status)lastError

Returns the status code returned by the most recent NetInfo call.  This value can be translated to an English error message by the ni_error() function, which is described in the netinfo(3) UNIX manual page.



setConnection:
(ni_status)setConnection:(const char *)domain

Establishes a connection to the named domain.  Returns a value indicating status, corresponding to the constants defined in the header file netinfo/ni_prot.h.  This value can be translated to an English error message by the ni_error() function, which is described in the netinfo(3) UNIX manual page.



setConnection:readTimeout:writeTimeout:canAbort:mustWrite:
(ni_status)setConnection:(const char *)domain
readTimeout:(int)rtime
writeTimeout:(int)wtime
canAbort:(BOOL)abortFlag
mustWrite:(BOOL)writeFlag

Establishes a connection to the named domain with arguments corresponding to the ni_fancyopenargs structure described in the UNIX manual page for netinfo.  Values for rtime and wtime indicate the timeout, in seconds, for read and write attempts. If abortFlag is TRUE, failure will occur after a timeout or other error. Otherwise, attempts will continue forever. If writeFlag is TRUE, this method forces a connection to the master server of the domain, since writes can only be made there.  Returns a value indicating status, corresponding to the constants defined in the header file netinfo/ni_prot.h.  This value can be translated to an English error message by the ni_error() function, which is described in the netinfo(3) UNIX manual page.



setDelegate:
setDelegate:anObject

Sets the NIDomain object's delegate to anObject.  Returns self.



setTaggedConnection:to:
(ni_status)setTaggedConnection:(const char *)tag to:(char *)hostName

Establishes a connection to a domain by host name and tag rather than domain name.  Returns a value indicating status, corresponding to the constants defined in the header file netinfo/ni_prot.h.  This value can be translated to an English error message by the ni_error() function, which is described in the netinfo(3) UNIX manual page.



setTaggedConnection:to:readTimeout:writeTimeout:canAbort:
(ni_status)setTaggedConnection:(const char *)tag
to:(char *)hostName
readTimeout:(int)rtime
writeTimeout:(int)wtime
canAbort:(BOOL)abortFlag

Establishes a connection to a domain by host name and tag with arguments. Same as setConnection:readTimeout:writeTimeout:canAbort:mustWrite:, except that it doesn't include the writeFlag argument. Since the connection is being made to a specific server, the writeFlag argument is irrelevant.  Returns a value indicating status, corresponding to the constants defined in the header file netinfo/ni_prot.h.  This value can be translated to an English error message by the ni_error() function, which is described in the netinfo(3) UNIX manual page.



Methods Implemented by the Delegate

domain:willCloseBecause:
domain:sender willCloseBecause:(int)reason

Indicates that the connection to the current domain will terminate as a result of the disconnectFromCurrent method. The value of reason is always 0, indicating that the program requested closing.