nis_hash.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*
* Copyright (c) 1988-1992 Sun Microsystems Inc
* All Rights Reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* GENERIC hash functions for NIS names.
*
* These functions provide a basic hashing mechanisim for efficiently
* looking up NIS names. The hashing function is __name_hash() and
* it hashes into a fixed size hash table of 64 entries. Collisions
* are dealt with by a "link" pointer to the next entry with the same
* key. The number 64 was chosen as a compromise between good hashing
* efficiency and memory usage. Large groups are expected to be about
* 1024 members which hash down to about 8 entries per table. With a
* mean search time of 4 name compares this gives us the desired
* performance.
* The hash table is augmented by a doubly linked list which points to
* all entries (used when enumerating groups).
*/
#include <string.h>
#include <ctype.h>
#include <malloc.h>
#include <syslog.h>
#define __NIS_PRIVATE_INTERFACES
/*
* LOWER(c) -- macro implementation of tolower(c), possibly more efficient.
*
* NOTA BENISSIME:
* Do NOT use this with side-effecting arguments such as LOWER(*s1++);
* either use the tolower() function or fix the arguments so they're
* side-effect-free (and cheap to evaluate, or this macro will lose).
*/
/*
* find_item(name, table) -- finds the item called <name> in <table>, or
* returns a pointer to the right place to insert an item with that name
* (the two cases are distinguished by whether the "right place" contains
* NULL).
*/
static NIS_HASH_ITEM **
{
int key = 0;
unsigned char *s;
NIS_HASH_ITEM **pp;
/* At this level we assume name, table != 0 */
for (s = (unsigned char *)name; *s != 0; s++) {
}
if (keyp != 0) {
}
break;
}
}
return (pp);
}
/*
* Keep this just in case someone actually uses this interface.
*/
int
int *key) /* pointer for key */
{
}
/*
* nis_insert_item()
*
* This function inserts the passed item into a hash table as pointed
* to by table. It returns 1 if the item was inserted or 0 if the item
* could not be inserted (because of an identically named
* item in the table.
*/
int
{
int key;
NIS_HASH_ITEM **pp;
return (0);
return (0); /* Already in the table */
/* Insert the item into the hash table, */
/* Insert the item into the serial, doubly linked list */
return (1);
}
/*
* __nis_find_item()
*
* This function will find a named NIS_HASH_ITEM in the indicated
* hash table. It returns either NULL if the item doesn't exist,
* or a pointer to the item.
*/
{
return (0);
}
/*
* nis_pop_item()
*
* This function pops the next NIS_ITEM struct off of the chain and
* returns it. (same as a remove item but doesn't require the user
* to pass it a name.)
*/
{
if (! table)
return (NULL);
return (NULL);
if (prev)
else
/* ==== error; this shouldn't happen */
else
break;
}
}
/* ASSERT (cur == item) */
return (item);
}
/*
* nis_remove_item()
*
* This function will remove a named NIS_HASH_ITEM from the indicated
* hash table and serial list. It returns either NULL if the
* item did not exist, or a pointer to the item which can then
* be freed by the calling function.
*/
{
NIS_HASH_ITEM **pp;
return (0);
if (nl == 0)
return (0);
/* Remove nl from the hash chain */
/* Remove nl from the linked list of all names */
else
return (nl);
}
static void /* A fine candidate for inlining */
{
}
/*
* nis_flush_table()
*
* This simple function will free all of the memory associated with
* a given table. It may be used to dump caches.
*/
void
void (*flush_func)(NIS_HASH_ITEM *))
{
if (table == 0)
return;
if (flush_func == 0) {
/*
* Assumes that 'it' and it->name were malloc()ed, and
* that nothing else was malloc()ed.
*/
}
(*flush_func)(it);
}
/*
* insert_name()
*
* This function inserts the requested name into the hash table
* at the appropriate place.
*/
void
{
if (!nl) {
return;
}
return;
}
}
}
/*
* remove_name()
*
* This function will remove a name from the hash table
* and fix up any has chains as appropriate.
*/
void
{
if (nl)
}
/*
* Remove all names from a table.
*/
void
{
}
/*
* nis_scan_table() -- iterate over all items in a hash table.
* The iterator function should *not* insert or delete items.
*/
void
void *funcarg)
{
int slot;
if (table == 0) {
return;
}
for (slot = 0;
slot++) {
return;
}
}
}
}