Libinfo-173.tar.gz
[apple/libinfo.git] / netinfo.subproj / ni_util.h
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * Utility routines for NetInfo
27 * Copyright (C) 1989 by NeXT, Inc.
28 */
29
30 #ifndef _NI_UTIL_H_
31 #define _NI_UTIL_H_
32
33 #include <netinfo/ni.h>
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #define NI_INDEX_NULL ((ni_index)-1)
40 #define NI_INIT(objp) bzero((void *)(objp), sizeof(*(objp)))
41
42 ni_name ni_name_dup(ni_name_const);
43 void ni_name_free(ni_name *);
44 int ni_name_match(ni_name_const, ni_name_const);
45
46 ni_namelist ni_namelist_dup(const ni_namelist);
47 void ni_namelist_free(ni_namelist *);
48 void ni_namelist_insert(ni_namelist *, ni_name_const, ni_index);
49 void ni_namelist_delete(ni_namelist *, ni_index);
50 ni_index ni_namelist_match(const ni_namelist, ni_name_const);
51
52 ni_property ni_prop_dup(const ni_property);
53 void ni_prop_free(ni_property *);
54
55 void ni_proplist_insert(ni_proplist *, const ni_property, ni_index);
56 void ni_proplist_delete(ni_proplist *, ni_index);
57 ni_index ni_proplist_match(const ni_proplist, ni_name_const, ni_name_const);
58 ni_proplist ni_proplist_dup(const ni_proplist);
59 void ni_proplist_free(ni_proplist *);
60
61 void ni_proplist_list_free(ni_proplist_list *);
62
63 void ni_idlist_insert(ni_idlist *, ni_index, ni_index);
64 int ni_idlist_delete(ni_idlist *, ni_index);
65 ni_idlist ni_idlist_dup(const ni_idlist);
66 void ni_idlist_free(ni_idlist *);
67
68 void ni_entrylist_insert(ni_entrylist *, ni_entry);
69 void ni_entrylist_delete(ni_entrylist *, ni_index);
70 void ni_entrylist_free(ni_entrylist *);
71
72 int innetgr(const char *, const char *, const char *, const char *);
73
74 /*
75 * Search for a directory for all subdirs with key=val, when val is
76 * a regular expression. Usage:
77 * status = ni_search(domain, directory, key, val, flags, &list);
78 * val and flags are passed to regcomp (see regex(3)).
79 */
80 ni_status ni_search(void *, ni_id *, ni_name, ni_name, int, ni_entrylist *);
81
82 /*
83 * Searches from local domain to root to find the first directory with a
84 * given pathname. Last argument is a timeout. Usage:
85 * status = ni_find(&domain, &dir, path, timeout);
86 */
87 ni_status ni_find(void **, ni_id *, ni_name, unsigned int);
88
89 /*
90 * Parses a NetInfo URL, and returns the domain and directory referenced
91 * by the URL. Usage:
92 * status = ni_url(ustring, &domain, &dir);
93 *
94 * BNF for NetInfo URLs:
95 * url ::= "netinfo://" <hostspec> [/[<domainspec>][:[<dirspec>]]]
96 * hostspec ::= [[[user][:[password]]]@]hostref
97 * hostref ::= <inet_addr> | <hostname>
98 * domainspec ::= <abs_domain> | <rel_domain>
99 * dirspec ::= <path> | <unsigned_integer>
100 */
101 ni_status ni_url(char *, void **, ni_id *);
102
103 #ifdef __cplusplus
104 }
105 #endif
106
107 #endif !_NI_UTIL_H_
108