4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
24 * Copyright 2015 Gary Mills
25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
30 %#include "ldap_xdr.h"
38 %/* db_index is a hash table with separate overflow buckets. */
43 %#include "db_item_c.h"
44 %#include "db_index_entry_c.h"
45 %#include "db_table_c.h"
46 %#include "db_scheme_c.h"
49 %#include "db_index_entry.h"
50 %#include "db_table.h"
51 %#include "db_scheme.h"
55 %#include "nisdb_rw.h"
57 #if RPC_HDR || RPC_XDR
60 db_index_entry_p tab<>;
63 __nisdb_rwlock_t index_rwlock;
65 typedef struct db_index * db_index_p;
73 % db_index_entry_p *tab;
76 % STRUCTRWLOCK(index);
78 %/* Grow the current hashtable upto the next size.
79 % The contents of the existing hashtable is copied to the new one and
80 % relocated according to its hashvalue relative to the new size.
81 % Old table is deleted after the relocation. */
84 %/* Clear the chains created in db_index_entrys */
85 %/* void clear_results();*/
88 %/* Constructor: creates empty index. */
91 %/* Constructor: creates index by loading it from the specified file.
92 % If loading fails, creates empty index. */
95 %/* Destructor: deletes index, including all associated db_index_entry. */
98 %/* Empty table (deletes index, including all associated db_index_entry) */
101 %/* Initialize index according to the specification of the key descriptor.
102 % Currently, only affects case_insens flag of index. */
103 % void init( db_key_desc * );
105 %/* Moves an index from an xdr index */
106 % db_status move_xdr_db_index(db_index *orig);
108 %/* Dumps this index to named file. */
112 %/* Look up given index value in hashtable.
113 % Return pointer to db_index_entries that match the given value, linked
114 % via the 'next_result' pointer. Return in 'how_many_found' the size
115 % of this list. Return NULL if not found. */
116 % db_index_entry *lookup(item *, long *, db_table *, bool_t);
118 %/* Remove the entry with the given index value and location 'recnum'.
119 % If successful, return DB_SUCCESS; otherwise DB_NOTUNIQUE if index_value
120 % is null; DB_NOTFOUND if entry is not found.
121 % If successful, decrement count of number of entries in hash table. */
122 % db_status remove( item*, entryp );
124 %/* Add a new index entry with the given index value and location 'recnum'.
125 % Return DB_NOTUNIQUE, if entry with identical index_value and recnum
126 % already exists. If entry is added, return DB_SUCCESS.
127 % Increment count of number of entries in index table and grow table
128 % if table is more than half full.
129 % Note that a copy of index_value is made for new entry. */
130 % db_status add( item*, entryp );
132 %/* Return in 'tsize' the table_size, and 'tcount' the number of entries
134 % void stats( long* tsize, long* tcount);
137 %/* Print all entries in the table. */
140 %/* Locking methods */
142 % int acqexcl(void) {
143 % return (WLOCK(index));
146 % int relexcl(void) {
147 % return (WULOCK(index));
150 % int acqnonexcl(void) {
151 % return (RLOCK(index));
154 % int relnonexcl(void) {
155 % return (RULOCK(index));
159 %extern "C" bool_t xdr_db_index(XDR *, db_index *);
161 %extern bool_t xdr_db_index(XDR *, db_index *);
163 %typedef class db_index * db_index_p;
168 %#endif /* _DB_INDEX_H */