Print this page
5910 libnisdb won't build with modern GCC
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libnisdb/db_index_c.x
+++ new/usr/src/lib/libnisdb/db_index_c.x
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * db_index_c.x
23 23 *
24 + * Copyright 2015 Gary Mills
24 25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 26 * Use is subject to license terms.
26 27 */
27 28
29 +#if RPC_XDR
30 +%#include "ldap_xdr.h"
31 +#endif /* RPC_XDR */
32 +
28 33 #if RPC_HDR
29 34 %#ifndef _DB_INDEX_H
30 35 %#define _DB_INDEX_H
31 36
32 37 %
33 38 %/* db_index is a hash table with separate overflow buckets. */
34 39 %
35 40
36 41
37 42 #ifdef USINGC
38 43 %#include "db_item_c.h"
39 44 %#include "db_index_entry_c.h"
40 45 %#include "db_table_c.h"
41 46 %#include "db_scheme_c.h"
42 47 #else
43 48 %#include "db_item.h"
44 49 %#include "db_index_entry.h"
45 50 %#include "db_table.h"
46 51 %#include "db_scheme.h"
47 52 #endif /* USINGC */
48 53 #endif /* RPC_HDR */
49 54 %
50 55 %#include "nisdb_rw.h"
51 56 %
52 57 #if RPC_HDR || RPC_XDR
53 58 #ifdef USINGC
54 59 struct db_index {
55 60 db_index_entry_p tab<>;
56 61 int count;
57 62 bool case_insens;
58 63 __nisdb_rwlock_t index_rwlock;
59 64 };
60 65 typedef struct db_index * db_index_p;
61 66 #endif /* USINGC */
62 67 #endif /* RPC_HDR */
63 68
64 69 #ifndef USINGC
65 70 #ifdef RPC_HDR
66 71 %class db_index {
67 72 % long table_size;
68 73 % db_index_entry_p *tab;
69 74 % int count;
70 75 % bool_t case_insens;
71 76 % STRUCTRWLOCK(index);
72 77 %
73 78 %/* Grow the current hashtable upto the next size.
74 79 % The contents of the existing hashtable is copied to the new one and
75 80 % relocated according to its hashvalue relative to the new size.
76 81 % Old table is deleted after the relocation. */
77 82 % void grow();
78 83 %
79 84 %/* Clear the chains created in db_index_entrys */
80 85 %/* void clear_results();*/
81 86 % public:
82 87 %
83 88 %/* Constructor: creates empty index. */
84 89 % db_index();
85 90 %
86 91 %/* Constructor: creates index by loading it from the specified file.
87 92 % If loading fails, creates empty index. */
88 93 % db_index( char *);
89 94 %
90 95 %/* Destructor: deletes index, including all associated db_index_entry. */
91 96 % ~db_index();
92 97 %
93 98 %/* Empty table (deletes index, including all associated db_index_entry) */
94 99 % void reset();
95 100 %
96 101 %/* Initialize index according to the specification of the key descriptor.
97 102 % Currently, only affects case_insens flag of index. */
98 103 % void init( db_key_desc * );
99 104 %
100 105 %/* Moves an index from an xdr index */
101 106 % db_status move_xdr_db_index(db_index *orig);
102 107 %
103 108 %/* Dumps this index to named file. */
104 109 % int dump( char *);
105 110 %
106 111 %
107 112 %/* Look up given index value in hashtable.
108 113 % Return pointer to db_index_entries that match the given value, linked
109 114 % via the 'next_result' pointer. Return in 'how_many_found' the size
110 115 % of this list. Return NULL if not found. */
111 116 % db_index_entry *lookup(item *, long *, db_table *, bool_t);
112 117 %
113 118 %/* Remove the entry with the given index value and location 'recnum'.
114 119 % If successful, return DB_SUCCESS; otherwise DB_NOTUNIQUE if index_value
115 120 % is null; DB_NOTFOUND if entry is not found.
116 121 % If successful, decrement count of number of entries in hash table. */
117 122 % db_status remove( item*, entryp );
118 123 %
119 124 %/* Add a new index entry with the given index value and location 'recnum'.
120 125 % Return DB_NOTUNIQUE, if entry with identical index_value and recnum
121 126 % already exists. If entry is added, return DB_SUCCESS.
122 127 % Increment count of number of entries in index table and grow table
123 128 % if table is more than half full.
124 129 % Note that a copy of index_value is made for new entry. */
125 130 % db_status add( item*, entryp );
126 131 %
127 132 %/* Return in 'tsize' the table_size, and 'tcount' the number of entries
128 133 % in the table. */
129 134 % void stats( long* tsize, long* tcount);
130 135 %
131 136 %
132 137 %/* Print all entries in the table. */
133 138 % void print();
134 139 %
135 140 %/* Locking methods */
136 141 %
137 142 % int acqexcl(void) {
138 143 % return (WLOCK(index));
139 144 % }
140 145 %
141 146 % int relexcl(void) {
142 147 % return (WULOCK(index));
143 148 % }
144 149 %
145 150 % int acqnonexcl(void) {
146 151 % return (RLOCK(index));
147 152 % }
148 153 %
149 154 % int relnonexcl(void) {
150 155 % return (RULOCK(index));
151 156 % }
152 157 %};
153 158 %#ifdef __cplusplus
154 159 %extern "C" bool_t xdr_db_index(XDR *, db_index *);
155 160 %#elif __STDC__
156 161 %extern bool_t xdr_db_index(XDR *, db_index *);
157 162 %#endif
158 163 %typedef class db_index * db_index_p;
159 164 #endif /* RPC_HDR */
160 165 #endif /* USINGC */
161 166
162 167 #if RPC_HDR
163 168 %#endif /* _DB_INDEX_H */
164 169 #endif /* RPC_HDR */
↓ open down ↓ |
127 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX