100 lines
2.8 KiB
C
100 lines
2.8 KiB
C
/****************************************************************************
|
|
|
|
|
| (C) Copyright 1995-1997 Novell, Inc.
|
|
| All Rights Reserved.
|
|
|
|
|
| This program is free software; you can redistribute it and/or
|
|
| modify it under the terms of version 2 of the GNU General Public
|
|
| License as published by the Free Software Foundation.
|
|
|
|
|
| This program is distributed in the hope that it will be useful,
|
|
| but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| GNU General Public License for more details.
|
|
|
|
|
| You should have received a copy of the GNU General Public License
|
|
| along with this program; if not, contact Novell, Inc.
|
|
|
|
|
| To contact Novell about this file by physical or electronic mail,
|
|
| you may find current contact information at www.novell.com
|
|
|
|
|
|***************************************************************************
|
|
|
|
|
| NetWare Advance File Services (PSS) Initialization module
|
|
|
|
|
|---------------------------------------------------------------------------
|
|
|
|
|
| $Author: taysom $
|
|
| $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $
|
|
| $RCSfile$
|
|
| $Revision: 465 $
|
|
|
|
|
|---------------------------------------------------------------------------
|
|
| This module is used to: Typedefs for hash code.
|
|
+-------------------------------------------------------------------------*/
|
|
#ifndef _NSS_HASH_H_
|
|
#define _NSS_HASH_H_
|
|
|
|
#ifndef _ZOMNI_H_
|
|
#include "zOmni.h"
|
|
#endif
|
|
|
|
#ifndef _CRC_H_
|
|
#include "crc.h"
|
|
#endif
|
|
|
|
typedef struct HashRecord_s {
|
|
struct HashRecord_s *next;
|
|
crc_t crc;
|
|
} HashRecord_s;
|
|
|
|
typedef struct HashTable_s {
|
|
NINT mask; /* num buckets - 1 (num buckets is power of two) */
|
|
NINT numRecords;
|
|
BOOL (*isMatch)(void *key, HashRecord_s *rec);
|
|
crc_t (*hash)(void *key);
|
|
void *(*alloc)(void *key, void *data);
|
|
void (*destroy)(void *rec);
|
|
HashRecord_s **table;
|
|
} HashTable_s;
|
|
|
|
typedef struct HashStats_s
|
|
{
|
|
NINT totalRecords;
|
|
NINT numBuckets;
|
|
NINT maxChain;
|
|
NINT minChain;
|
|
#ifdef UNIX
|
|
float avgChain;
|
|
#endif
|
|
} HashStats_s;
|
|
|
|
/*
|
|
* Hash function prototypes
|
|
*/
|
|
extern HashTable_s *hashInit(
|
|
HashTable_s *ht,
|
|
NINT numBuckets,
|
|
BOOL (*isMatch)(void *key, HashRecord_s *rec),
|
|
crc_t (*hash)(void *key),
|
|
void *(*alloc)(void *key, void *data),
|
|
void (*destroy)(void *rec));
|
|
|
|
extern STATUS hashApply(
|
|
HashTable_s *ht,
|
|
STATUS (*myFunc)(HashRecord_s *rec, void *metaData),
|
|
void *metaData);
|
|
|
|
extern HashStats_s *hashStats(
|
|
HashTable_s *ht,
|
|
HashStats_s *stats);
|
|
|
|
extern void hashDelete(HashTable_s *ht, void *key);
|
|
extern void *hashFind(HashTable_s *ht, void *key);
|
|
extern void *hashInsert(HashTable_s *ht, void *key, void *data);
|
|
extern HashTable_s *hashGrow(HashTable_s *ht, NINT factor);
|
|
extern HashTable_s *hashShrink (HashTable_s *ht, NINT factor);
|
|
extern void hashDestroy(HashTable_s *ht);
|
|
|
|
#endif
|