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