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