]> git.saurik.com Git - apple/libinfo.git/blame - netinfo.subproj/netinfo.3
Libinfo-129.4.tar.gz
[apple/libinfo.git] / netinfo.subproj / netinfo.3
CommitLineData
3b7c7bd7
A
1.TH NETINFO 3 "August 29, 1989" "Apple Computer, Inc."
2.SH NAME
3netinfo \- library routines for NetInfo calls
4.SH SYNOPSIS
5\fB#include <netinfo/ni.h>\fR
6.SH DESCRIPTION
7These calls are the programming interface to NetInfo. Typically,
8a handle (of type "void *") is allocated through a call to
9.I ni_new,
10.I ni_open,
11or
12.I ni_connect.
13This handle opens a connection to the given NetInfo domain. Read calls
14may go to either the master or the clone servers, while writes will
15always go to the master server. If the master is unavailable,
16no writes can be performed.
17The handle is then passed to one of several NetInfo routines for database
18operations and then freed using
19.I ni_free.
20Several utility routines are also supplied which operate on NetInfo data
21structures. These routines don't require NetInfo handles.
22.LP
23.SH MACROS
24.PP
25.B NI_INDEX_NULL
26.IP
27A constant which evaluates to the highest unsigned integer. It is useful
28for indicating something which should go at the end of a list, as opposed
29to a smaller value which indicates the precise position at which the insert
30should occur.
31.PP
32\fBNI_INIT\fR(\fIptr\fR)
33.IP
34Initializes a NetInfo data structure. It effectively zeros out the structure
35referred to by
36.I ptr.
37This macro is useful for indicating an empty list or NULL value with one
38of the many NetInfo data structures.
39.SH "DATATYPES AND ASSOCIATED UTILITY ROUTINES"
40.PP
41.B ni_status
42.IP
43The result code of most NetInfo routines.
44.PP
45const char *\fBni_error\fR(ni_status \fIstatus\fR)
46.IP
47Returns the error string associated with the given NetInfo status.
48.PP
49.B ni_index
50.IP
51An index into a NetInfo list.
52.PP
53.B ni_id
54.IP
55NetInfo directories are identified through the
56.I ni_id
57data structure. It records the ID of the directory in the
58.I nii_object
59field and the instance of the directory in the
60.I nii_instance
61field. The instance indicates which version of the directory is being
62operated on and is only relevant for writes. Each time a write is
63performed, the instance is incremented to reflect the new version. If
64the instance given does not match the current instance of the directory,
65the error NI_STALE is returned, indicating a stale ID. All NetInfo
66routines which operate on directories will return the latest value of
67the instance.
68.PP
69.B ni_name
70.IP
71A NetInfo name. It is equivalent to a C string.
72.PP
73ni_name \fBni_name_dup\fR(const ni_name \fIname\fR)
74.IP
75Returns a mallocated copy of a NetInfo name.
76.PP
77void \fBni_name_free\fR(ni_name *\fInamep\fR)
78.IP
79Frees a NetInfo name. The pointer is converted to NULL. A NULL pointer
80will not be freed.
81.PP
82int \fBni_name_match\fR(const ni_name \fIname1\fR, const ni_name \fIname2\fR)
83.IP
84Compares two NetInfo names for equality. Returns non-zero for success,
85zero for failure.
86.PP
87.B ni_namelist
88.IP
89A list of NetInfo names.
90.PP
91ni_namelist \fBni_namelist_dup\fR(const ni_namelist \fInl\fR)
92.IP
93Returns a mallocated duplicate of a NetInfo namelist.
94.PP
95void \fBni_namelist_free\fR(ni_namelist *\fInl\fR)
96.IP
97Frees a NetInfo namelist. The namelist structure is zeroed. Zeroed
98namelists will not be freed.
99.PP
100void \fBni_namelist_insert\fR(ni_namelist *\fInl\fR, const ni_name \fIname\fR, ni_index \fIwhere\fR)
101.IP
102Duplicates and inserts the given name at the given location into the namelist.
103.PP
104void \fBni_namelist_delete\fR(ni_namelist *\fInl\fR, ni_index \fIwhere\fR)
105.IP
106Deletes and frees the name at the given location in the namelist.
107.PP
108ni_index \fBni_namelist_match\fR(const ni_namelist \fInl\fR, const ni_name \fIname\fR)
109.IP
110If the name is in the given namelist, the first index of its occurrence
111is returned. Otherwise, NI_INDEX_NULL is returned indicating failure.
112.PP
113.B ni_property
114.IP
115A NetInfo property. It contains a name and a namelist of associated values.
116.PP
117ni_property \fBni_prop_dup\fR(const ni_property \fIprop\fR)
118.IP
119Returns a mallocated duplicate of the given NetInfo property.
120.PP
121void \fBni_prop_free\fR(ni_property *\fIprop\fR)
122.IP
123Frees and zeros the NetInfo property. Zeroed properties will not be freed
124again.
125.PP
126.B ni_proplist
127.IP
128A list of NetInfo properties.
129.PP
130void \fBni_proplist_insert\fR(ni_proplist *\fIpl\fR, const ni_property \fIprop\fR, ni_index \fIwhere\fR)
131.IP
132Duplicates and inserts the given property at the given location into the given property
133list.
134.PP
135void \fBni_proplist_delete\fR(ni_proplist *\fIpl\fR, ni_index \fIwhere\fR)
136.IP
137Frees and deletes the property at the given location in the property list.
138.PP
139ni_index \fBni_proplist_match\fR(const ni_proplist \fIpl\fR, const ni_name \fIname\fR, const ni_name \fIval\fR)
140.IP
141Returns the location in the property list of the first property with a name
142of
143.I name
144and having value
145.I val.
146NI_INDEX_NULL is returned on failure.
147If NULL is the \fIvalue\fR argument,
148\fBni_proplist_match\fR will match on only the \fIname\fR argument.
149.PP
150ni_proplist \fBni_proplist_dup\fR(const ni_proplist \fIpl\fR)
151.IP
152Returns a mallocated duplicate property list.
153.PP
154void \fBni_proplist_free\fR(ni_proplist *\fIpl\fR)
155.IP
156Frees and zeroes the property list. A zeroed property will not be freed again.
157.PP
158.B ni_idlist
159.IP
160A list of NetInfo indices (usually directory ID's).
161.PP
162void \fBni_idlist_free\fR(ni_idlist *\fIidl\fR)
163.IP
164Frees and zeroes the given ID list. A zeroed ID list will not be freed again.
165.PP
166.B ni_entry
167.IP
168An entry in a NetInfo directory. It contains the ID of the directory and
169a list of values assocated with whatever property was requested in the
170.I ni_list
171routine. The list may be NULL, indicating that there is not associated
172property for this directory.
173.PP
174.B ni_entrylist
175.IP
176A list of NetInfo entries.
177.PP
178void \fBni_entrylist_free\fR(ni_entrylist *\fIentries\fR)
179.IP
180Frees and zeros the given entry list. A zeroed entry list will not be
181freed again.
182.LP
183.SH "ROUTINES"
184.PP
185ni_status \fBni_addrtag\fR(void *\fIhandle\fR, struct sockaddr_in *\fIaddr\fR, ni_name *\fItag\fR)
186.IP
187Returns the address and domain tag associated with the connected
188NetInfo handle.
189.PP
190ni_status \fBni_children\fR(void *\fIhandle\fR, ni_id *\fIdir\fR, ni_idlist *\fIidlist\fR)
191.IP
192Lists the children ID's (subdirectories) of the given directory.
193.PP
194void *\fBni_connect\fR(struct sockaddr_in *\fIaddr\fR, ni_name \fItag\fR)
195.IP
196Returns a NetInfo handle to the NetInfo domain at the given address
197and domain tag. Returns NULL on failure.
198.PP
199ni_status \fBni_create\fR(void *\fIhandle\fR, ni_id *\fIparent\fR, ni_proplist \fIprops\fR, ni_id *\fIchild\fR, ni_index \fIwhere\fR)
200.IP
201Creates a new directory at the given index initialized with the given
202properties.
203.PP
204ni_status \fBni_createname\fR(void *\fIhandle\fR, ni_id *\fIdir\fR, ni_index \fIprop_index\fR, ni_name \fIname\fR, ni_index \fIval_index\fR)
205.IP
206Inserts the name into the value list of the given directory at the property
207indexed by prop_index and value list location val_index.
208.PP
209ni_status \fBni_createprop\fR(void *\fIhandle\fR, ni_id *\fIdir\fR, ni_property \fIprop\fR, ni_index \fIwhere\fR)
210.IP
211Creates a new property at the given index in the given directory.
212.PP
213ni_status \fBni_destroy\fR(void *\fIhandle\fR, ni_id *\fIparent\fR, ni_id \fIchild\fR)
214.IP
215Destroys the directory child in the given parent directory. Both instance
216must be the latest values or the error NI_STALE is returned.
217.PP
218ni_status \fBni_destroyname\fR(void *\fIhandle\fR, ni_id *\fIdir\fR, ni_index \fIprop_index\fR, ni_index \fIval_index\fR)
219.IP
220Destroys a property value in the given directory at the given prop_index and
221value-list val_index.
222.PP
223ni_status \fBni_destroyprop\fR(void *\fIhandle\fR, ni_id *\fIdir\fR, ni_index \fIwhere\fR)
224.IP
225Destroys the property at property index
226.I where
227in the given directory.
228.PP
229ni_status \fBni_fancyopen\fR(void *\fIhandle\fR, ni_name \fIdomain\fR, void **\fIrethandle\fR, ni_fancyopenargs *\fIargs\fR)
230.PP
231.nf
232typedef struct ni_fancyopenargs {
233 int rtimeout;
234 int wtimeout;
235 int abort;
236 int needwrite;
237} ni_fancyopenargs;
238.fi
239.IP
240A fancier version of ni_open which allows one to set
241various attributes on the the returned handle. See
242.I ni_setreadtimeout(),
243.I ni_setwritetimeout(),
244.I ni_setabort()
245and
246.I ni_needwrite()
247for descriptions of the fields
248in the ni_fancyopenargs structure. A 0 in the
249rtimeout or wtimeout field indicates the
250default timeout should be used.
251.PP
252void \fBni_free\fR(void *\fIhandle\fR)
253.IP
254Frees a NetInfo handle and closes any associated connections.
255.PP
256ni_status \fBni_list\fR(void *\fIhandle\fR, ni_id *\fIdir\fR , ni_name \fIname\fR, ni_entrylist *\fIentries\fR)
257.IP
258Lists all the subdirectories of the given directory along with any associated
259values they may have for the property
260.I name.
261If a subdirectory doesn't have the property \fIname\fR,
262the entry is still returned but with a NULL property list.
263.PP
264ni_status \fBni_listprops\fR(void *\fIhandle\fR, ni_id *\fIdir\fR, ni_namelist *\fInl\fR)
265.IP
266Returns the list of property names associated with the given directory.
267.PP
268ni_status \fBni_lookup\fR(void *\fIhandle\fR, ni_id *\fIdir\fR, ni_name \fIname\fR, ni_name \fIval\fR, ni_idlist *\fIfound\fR)
269.IP
270Returns a list of subdirectories which satisfy the relation
271.I name
272equals
273.I val.
274.PP
275ni_status \fBni_lookupprop\fR(void *\fIhandle\fR, ni_id *\fIdir\fR, ni_name \fIname\fR, ni_namelist *\fIval\fR)
276.IP
277Returns the values associated with the property named
278.I name
279in the given directory.
280.PP
281ni_status \fBni_lookupread\fR(void *\fIhandle\fR, ni_id *\fIdirid\fR, ni_name \fIpropname\fR, ni_name \fIpropval\fR, ni_proplist *\fIprops\fR)
282.IP
283Looks up the subdirectory given the
284.I (propname, propval\)
285pair
286and returns the subdirectory's properties. This call is equivalent to
287an
288.I ni_lookup()
289followed by an
290.I ni_read().
291.PP
292void \fBni_needwrite\fR(void *\fIhandle\fR, int \fIneedwrite\fR)
293.IP
294Indicates whether subsequent calls will need to write to a
295netinfo server. By default, the flag is off and the netinfo
296library will automatically switch to a server capable of
297writing whenever a write call occurs. However, since writes
298may take some time to reach the clone server, one could read
299stale information from a clone server and then attempt to
300write the master based upon the stale information. Setting
301.I needwrite
302will lock the handle onto the master netinfo server even for
303reads to prevent this from happening.
304.PP
305ni_status \fBni_open\fR(void *\fIrelativeto\fR, ni_name \fIdomain\fR, void **\fIresult\fR)
306.IP
307Opens a connection to the NetInfo domain
308.I domain.
309The returned handle is opened relative to the domain specified in the
310.I relativeto.
311This handle may be passed as NULL, indicating relative to the local
312NetInfo domain. The path may contain "/"s to indicate a multilevel
313search and may also be "." or ".." to indicate the current domain or
314parent domain, respectively.
315.PP
316ni_status \fBni_parent\fR(void *\fIhandle\fR, ni_id *\fIdir\fR, ni_index *\fIparent_id\fR)
317.IP
318Returns the parent ID of the given directory.
319.PP
320ni_status \fBni_pathsearch\fR(void *\fIhandle\fR, ni_id *\fIdir\fR, ni_name \fIpath\fR)
321.IP
322Does a multilevel lookup on a directory, relative to the given directory
323ID. The path may contain "/"s to separative directory components. "="s
324are used to specify relations and both may be escaped using "\\"s. For
325example, to find the directory associated with the superuser, you may
326specify (relative to the root directory) "/name=users/uid=0". Note that
327the equal signs are not mandatory and will default to "name=" if none
328are specified. In the previous example, "/users/uid=0" would accomplish
329the same result.
330.PP
331ni_status \fBni_read\fR(void *\fIhandle\fR, ni_id *\fIdir\fR, ni_proplist *\fIprops\fR)
332.IP
333Reads all of the properties of the given directory.
334.PP
335ni_status \fBni_readname\fR(void *\fIhandle\fR, ni_id *\fIdir\fR, ni_index \fIprop_index\fR, ni_index \fIval_index\fR, ni_name *\fIvalue\fR)
336.IP
337Reads a value from a property in the given directory. The value is indexed
338by property index
339.I prop_index
340and value index
341.I val_index.
342.PP
343ni_status \fBni_readprop\fR(void *\fIhandle\fR, ni_id *\fIdir\fR, ni_index \fIprop_index\fr, ni_namelist *\fInl\fR)
344.IP
345Reads the value-list associated with the given property, indexed by
346.I prop_index.
347.PP
348ni_status \fBni_renameprop\fR(void *\fIhandle\fR, ni_id *\fIdir\fR, ni_index \fIprop_index\fR, ni_name \fInewname\fR)
349.IP
350Renames the property indexed by
351.I prop_index
352to the new name
353.I newname.
354.PP
355ni_status \fBni_resync\fR(void *\fIhandle\fR)
356.IP
357Attempts to resynchronize the clone servers with the master copy of
358the database.
359.PP
360ni_status \fBni_root\fR(void *\fIhandle\fR, ni_id *\fIdir\fR)
361.IP
362Returns the directory ID of the root of the directory tree.
363.PP
364ni_status \fBni_self\fR(void *\fIhandle\fR, ni_id *\fIdir\fR)
365.IP
366Returns the directory ID of the given directory. Simply refreshes the
367instance field to the latest value.
368.PP
369void \fBni_setabort\fR(void *\fIhandle\fR, int \fIshouldabort\fR)
370.IP
371By default, netinfo calls will try forever until an answer
372is returned from a server.
373.I ni_setabort
374 allows one to have
375netinfo return failure upon the first timeout or other failure.
376.PP
377ni_status \fBni_setpassword\fR(void *\fIhandle\fR, ni_name \fIpassword\fR)
378.IP
379Sets the password for the session to
380.I password.
381By default, no password is sent.
382.PP
383void \fBni_setreadtimeout\fR(void *\fIhandle\fR, int \fIseconds\fR)
384.IP
385Sets the timeout associated with reads on netinfo. The timeout
386is only a hint and the effective timeout may be longer. Note
387that calls will not abort even if a timeout is set unless the
388abort flag has been set (see
389.I ni_setabort()).
390.PP
391ni_status \fBni_setuser\fr(void *\fIhandle\fR, ni_name \fIusername\fR)
392.IP
393Changes the username associated with the session. By default, the username
394is the one associated with the user-ID that was used during the UNIX login
395process.
396.PP
397void \fBni_setwritetimeout\fR(void *\fIhandle\fR, int \fIseconds\fR)
398.IP
399Sets the timeout associated with writes on netinfo. The timeout
400is only a hint and the effective timeout may be a longer. Note
401that calls will not abort even if a timeout is set unless the
402abort flag has been set (see
403.I ni_setabort()).
404.PP
405ni_status \fBni_statistics\fR(void *\fIhandle\fR, ni_proplist *\fIstatistics\fR)
406.IP
407Returns various statistics from the server.
408.PP
409ni_status \fBni_write\fR(void *\fIhandle\fR, ni_id *\fIdir\fR, ni_proplist \fIprops\fR)
410.IP
411Writes a new property list to the directory.
412.PP
413ni_status \fBni_writename\fr(void *\fIhandle\fR, ni_id *\fIdir\fR, ni_index \fIprop_index\fr, ni_index \fIname_index\fR, ni_name \fIval\fR)
414.IP
415Writes a new property value to the property indexed by
416.I prop_index
417and value indexed by
418.I val_index.
419.PP
420ni_status \fBni_writeprop\fr(void *\fIhandle\fR, ni_id *\fIdir\fR, ni_index \fIprop_index\fR, ni_namelist \fIvalues\fR)
421.IP
422Writes a new value list to the property indexed by
423.I prop_index.
424It is allowable to have more than one property with the same name.
425.IP