964acb6cb7c49982f4ef85f4d4866d50a9356698
[become] / src / netg.h
1 /* -*-c-*-
2 *
3 * $Id: netg.h,v 1.1 1997/08/07 09:45:00 mdw Exp $
4 *
5 * A local database of netgroups
6 *
7 * (c) 1997 EBI
8 */
9
10 /*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of `become'
13 *
14 * `Become' is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * `Become' is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with `become'; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 */
28
29 /*----- Revision history --------------------------------------------------*
30 *
31 * $Log: netg.h,v $
32 * Revision 1.1 1997/08/07 09:45:00 mdw
33 * New source file added to maintain a netgroups database.
34 *
35 */
36
37 #ifndef NETG_H
38 #define NETG_H
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 /*----- Required headers --------------------------------------------------*/
45
46 #ifndef SYM_H
47 # include "sym.h"
48 #endif
49
50 /*----- Type definitions --------------------------------------------------*/
51
52 typedef sym_iter netg_iter;
53 typedef struct netg__sym netg;
54
55 /*----- Functions provided ------------------------------------------------*/
56
57 /* --- @netg_iterate@, @netg_iterate_r@ --- *
58 *
59 * Arguments: @netg_iter *i@ = pointer to a netgroup iterator object
60 *
61 * Returns: ---
62 *
63 * Use: Starts iterating over the netgroups.
64 */
65
66 extern void netg_iterate(void);
67 extern void netg_iterate_r(netg_iter */*i*/);
68
69 /* --- @netg_next@, @netg_next_r@ --- *
70 *
71 * Arguments: @netg_iter *i@ = pointer to a netgroup iterator object
72 *
73 * Returns: An opaque pointer to the next item, or null.
74 *
75 * Use: Returns the next netgroup.
76 */
77
78 extern netg *netg_next(void);
79 extern netg *netg_next_r(netg_iter */*i*/);
80
81 /* --- @netg_name@ --- *
82 *
83 * Arguments: @netg *n@ = netgroup handle returned by @netg_next@.
84 *
85 * Returns: A pointer to the name; you may not modify this string.
86 *
87 * Use: Returns the name of a netgroup.
88 */
89
90 extern const char *netg_name(netg */*n*/);
91
92 /* --- @netg_scan@ --- *
93 *
94 * Arguments: @netg *n@ = a netgroup handle returned by @netg_next@
95 * @int (*proc)(netg *n, const char *host, const char *user,@
96 * @const char *domain, void *ctx)@ = function to call
97 * for each member.
98 * @void *ctx@ = context pointer to pass to @proc@.
99 *
100 * Returns: Zero if all went well, or the nonzero return value from
101 * @proc@.
102 *
103 * Use: Passes all the members of the netgroup to a given function.
104 * The function is given the names, directly from the NIS
105 * netgroup map, except that any empty entries are passed as
106 * null pointers rather than empty strings. You may not modify
107 * any of the strings. The enumeration function, @proc@, may
108 * return nonzero to stop itself from being called any more;
109 * if this happens, the value it returns becomes the result of
110 * this function. If all the items are enumerated OK, this
111 * function returns zero.
112 */
113
114 extern int netg_scan(netg */*n*/,
115 int (*/*proc*/)(netg */*n*/, const char */*host*/,
116 const char */*user*/,
117 const char */*domain*/, void */*ctx*/),
118 void */*ctx*/);
119
120 /* --- @netg_init@ --- *
121 *
122 * Arguments: ---
123 *
124 * Returns: ---
125 *
126 * Use: Reads the netgroup database and turns it into something nice.
127 */
128
129 extern void netg_init(void);
130
131 /* --- @netg_reinit@ --- *
132 *
133 * Arguments: ---
134 *
135 * Returns: ---
136 *
137 * Use: Forces a re-read of the netgroups file.
138 */
139
140 extern void netg_reinit(void);
141
142 /*----- That's all, folks -------------------------------------------------*/
143
144 #ifdef __cplusplus
145 }
146 #endif
147
148 #endif