xref: /freebsd/libexec/revnetgroup/hash.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
1*df57947fSPedro F. Giffuni /*-
2*df57947fSPedro F. Giffuni  * SPDX-License-Identifier: BSD-4-Clause
3*df57947fSPedro F. Giffuni  *
4a44e4d14SBill Paul  * Copyright (c) 1995
5a44e4d14SBill Paul  *	Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
6a44e4d14SBill Paul  *
7a44e4d14SBill Paul  * Redistribution and use in source and binary forms, with or without
8a44e4d14SBill Paul  * modification, are permitted provided that the following conditions
9a44e4d14SBill Paul  * are met:
10a44e4d14SBill Paul  * 1. Redistributions of source code must retain the above copyright
11a44e4d14SBill Paul  *    notice, this list of conditions and the following disclaimer.
12a44e4d14SBill Paul  * 2. Redistributions in binary form must reproduce the above copyright
13a44e4d14SBill Paul  *    notice, this list of conditions and the following disclaimer in the
14a44e4d14SBill Paul  *    documentation and/or other materials provided with the distribution.
15a44e4d14SBill Paul  * 3. All advertising materials mentioning features or use of this software
16a44e4d14SBill Paul  *    must display the following acknowledgement:
17a44e4d14SBill Paul  *	This product includes software developed by Bill Paul.
18a44e4d14SBill Paul  * 4. Neither the name of the author nor the names of any co-contributors
19a44e4d14SBill Paul  *    may be used to endorse or promote products derived from this software
20a44e4d14SBill Paul  *    without specific prior written permission.
21a44e4d14SBill Paul  *
22a44e4d14SBill Paul  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
23a44e4d14SBill Paul  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24a44e4d14SBill Paul  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25a44e4d14SBill Paul  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE
26a44e4d14SBill Paul  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27a44e4d14SBill Paul  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28a44e4d14SBill Paul  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29a44e4d14SBill Paul  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30a44e4d14SBill Paul  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31a44e4d14SBill Paul  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32a44e4d14SBill Paul  * SUCH DAMAGE.
33a44e4d14SBill Paul  */
34a44e4d14SBill Paul 
35a44e4d14SBill Paul /* Groupname entry hung off a member_entry node. */
36a44e4d14SBill Paul struct grouplist {
37a44e4d14SBill Paul 	char *groupname;
38a44e4d14SBill Paul 	struct grouplist *next;
39a44e4d14SBill Paul };
40a44e4d14SBill Paul 
41a44e4d14SBill Paul /* Entry in the cooked member list hash table. */
42a44e4d14SBill Paul struct member_entry {
43a44e4d14SBill Paul 	char *key;
44a44e4d14SBill Paul 	char *domain;
45a44e4d14SBill Paul 	struct grouplist *groups;
46a44e4d14SBill Paul 	struct member_entry *next;
47a44e4d14SBill Paul };
48a44e4d14SBill Paul 
49a44e4d14SBill Paul /* Entry in the raw netgroup table. */
50a44e4d14SBill Paul struct group_entry {
51a44e4d14SBill Paul 	char *key;
52a44e4d14SBill Paul 	char *data;
53a44e4d14SBill Paul 	struct group_entry *next;
54a44e4d14SBill Paul };
55a44e4d14SBill Paul 
56a44e4d14SBill Paul /* Table size (chosen arbitrarily). Not too big, not too small. */
57a44e4d14SBill Paul #define TABLESIZE 256
58a44e4d14SBill Paul #define HASH_MASK 0x000000FF
5979cc85d3SBill Paul 
6079cc85d3SBill Paul #define LINSIZ 1024 * 10
6179cc85d3SBill Paul 
62266ebcd3SWarner Losh extern void store(struct group_entry ** , char *, char *);
63266ebcd3SWarner Losh extern void mstore(struct member_entry ** , char *, char *, char *);
64266ebcd3SWarner Losh extern char *lookup(struct group_entry **, char *);
65266ebcd3SWarner Losh extern void __endnetgrent(void);
66266ebcd3SWarner Losh extern void __setnetgrent(char *);
67266ebcd3SWarner Losh extern int __getnetgrent(char **, char **, char **);
68