Print this page
5910 libnisdb won't build with modern GCC
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libnisdb/db_mindex_c.x
+++ new/usr/src/lib/libnisdb/db_mindex_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_mindex_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 +%#include "nis_clnt.h"
32 +#endif /* RPC_XDR */
33 +
28 34 #if RPC_HDR
29 35 %#ifndef _DB_MINDEX_H
30 36 %#define _DB_MINDEX_H
31 37
32 38 #ifdef USINGC
33 39 %#include "db_vers_c.h"
34 40 %#include "db_table_c.h"
35 41 %#include "db_index_entry_c.h"
36 42 %#include "db_index_c.h"
37 43 %#include "db_scheme_c.h"
38 44 %#include "db_query_c.h"
39 45 #else
40 46 %#include "db_vers.h"
41 47 %#include "db_table.h"
42 48 %#include "db_index_entry.h"
43 49 %#include "db_index.h"
44 50 %#include "db_scheme.h"
45 51 %#include "db_query.h"
46 52 #endif /* USINGC */
47 53 %#include "ldap_parse.h"
48 54 %#include "nisdb_rw.h"
49 55 %#include "ldap_xdr.h"
50 56 #endif /* RPC_HDR */
51 57
52 58 #if RPC_HDR
53 59 %struct db_next_index_desc {
54 60 % entryp location;
55 61 % struct db_next_index_desc *next;
56 62
57 63 #ifndef USINGC
58 64 % db_next_index_desc( entryp loc, struct db_next_index_desc *n )
59 65 % { location = loc; next = n; }
60 66 #endif /* USINGC */
61 67
62 68 %};
63 69 #endif /* RPC_HDR */
64 70
65 71
66 72 #if RPC_HDR || RPC_XDR
67 73 #ifdef USINGC
68 74
69 75 struct db_mindex {
70 76 vers rversion;
71 77 db_index indices<>; /* indices[num_indices] */
72 78 db_table *table;
73 79 db_scheme *scheme;
74 80 __nisdb_ptr_t objPath;
75 81 __nisdb_flag_t noWriteThrough;
76 82 __nisdb_flag_t noLDAPquery;
77 83 __nisdb_flag_t initialLoad;
78 84 __nisdb_ptr_t dbptr;
79 85 __nisdb_rwlock_t mindex_rwlock;
80 86 };
81 87 typedef struct db_mindex * db_mindex_p;
↓ open down ↓ |
44 lines elided |
↑ open up ↑ |
82 88
83 89 typedef string strP<>;
84 90
85 91 struct xdr_nis_object_s {
86 92 int xversion;
87 93 nis_object *obj;
88 94 strP dirEntry<>;
89 95 };
90 96 typedef struct xdr_nis_object_s xdr_nis_object_t;
91 97
92 -%extern bool_t xdr_nis_object();
93 98 #endif /* USINGC */
94 99 #endif /* RPC_HDR */
95 100
96 101 #ifndef USINGC
97 102 #ifdef RPC_HDR
98 103 %
99 104 %struct xdr_nis_object_s {
100 105 % int version;
101 106 % nis_object *obj;
102 107 % struct {
103 108 % uint_t dirEntry_len;
104 109 % char **dirEntry_val;
105 110 % } dirEntry;
106 111 %};
107 112 %typedef struct xdr_nis_object_s xdr_nis_object_t;
108 113 %
109 -%extern bool_t xdr_nis_object();
110 -%
111 114 %class db_mindex {
112 115 % vers rversion;
113 116 %// int num_indices;
114 117 %// db_index * indices; /* indices[num_indices] */
115 118 % struct {
116 119 % int indices_len;
117 120 % db_index *indices_val;
118 121 % } indices;
119 122 % db_table *table;
120 123 % db_scheme *scheme;
121 124 % __nisdb_ptr_t objPath;
122 125 % __nisdb_flag_t noWriteThrough;
123 126 % __nisdb_flag_t noLDAPquery;
124 127 % __nisdb_flag_t initialLoad;
125 128 % __nisdb_ptr_t dbptr;
126 129 % STRUCTRWLOCK(mindex);
127 130 %
128 131 %/* Return a list of index_entries that satsify the given query 'q'.
129 132 % Return the size of the list in 'count'. Return NULL if list is empty.
130 133 % Return in 'valid' FALSE if query is not well formed. */
131 134 % db_index_entry_p satisfy_query(db_query *, long *, bool_t *valid,
132 135 % bool_t fromLDAP = FALSE);
133 136 % db_index_entry_p satisfy_query(db_query *, long *, bool_t *valid = NULL);
134 137 %
135 138 %/* Returns a newly db_query containing the index values as
136 139 % obtained from the given object. The object itself,
137 140 % along with information on the scheme given, will determine
138 141 % which values are extracted from the object and placed into the query.
139 142 % Returns an empty query if 'obj' is not a valid entry.
140 143 % Note that space is allocated for the query and the index values
141 144 % (i.e. do not share pointers with strings in 'obj'.) */
142 145 % db_query * extract_index_values_from_object( entry_object * );
143 146 %
144 147 %/* Returns a newly created db_query structure containing the index values
145 148 % as obtained from the record named by 'recnum'. The record itself, along
146 149 % with information on the schema definition of this table, will determine
147 150 % which values are extracted from the record and placed into the result.
148 151 % Returns NULL if recnum is not a valid entry.
149 152 % Note that space is allocated for the query and the index values
150 153 % (i.e. do not share pointers with strings in 'obj'.) */
151 154 % db_query * extract_index_values_from_record( entryp );
152 155 %
153 156 %/* Returns an array of size 'count' of 'entry_object_p's, pointing to
154 157 % copies of entry_objects named by the result list of db_index_entries 'res'.
155 158 %*/
156 159 % entry_object_p * prepare_results( int, db_index_entry_p, db_status* );
157 160 %
158 161 %/* Remove the entry identified by 'recloc' from:
159 162 % 1. all indices, as obtained by extracting the index values from the entry
160 163 % 2. table where entry is stored. */
161 164 % db_status remove_aux( entryp );
162 165 %
163 166 %/* entry_object * get_record( entryp );*/
164 167 % public:
165 168 %
166 169 %/* Constructor: Create empty table (no scheme, no table or indices). */
167 170 % db_mindex();
168 171 %
169 172 %/* Constructor: Create new table using scheme defintion supplied.
170 173 % (Make copy of scheme and keep it with table.) */
171 174 % db_mindex(db_scheme *, char *tablePath);
172 175 %
173 176 %/* destructor */
174 177 % ~db_mindex();
175 178 %
176 179 % db_index_entry_p satisfy_query_dbonly(db_query *, long *,
177 180 % bool_t checkExpire,
178 181 % bool_t *valid = NULL);
179 182 %
180 183 %/* Returns whether there table is valid (i.e. has scheme). */
181 184 % bool_t good() { return scheme != NULL && table != NULL; }
182 185 %
183 186 %/* Change the version of the table to the one given. */
184 187 % void change_version( vers *v ) { rversion.assign( v );}
185 188 %
186 189 %/* Return the current version of the table. */
187 190 % vers *get_version() { return( &rversion ); }
188 191 %
189 192 %/* Reset contents of tables by: deleting indice entries, table entries */
190 193 % void reset_tables();
191 194 %
192 195 %/* Reset the table by: deleting all the indices, table of entries, and its
193 196 % scheme. Reset version to 0 */
194 197 % void reset();
195 198 %
196 199 %/* Initialize table using information from specified file.
197 200 % The table is first 'reset', then the attempt to load from the file
198 201 % is made. If the load failed, the table is again reset.
199 202 % Therefore, the table will be modified regardless of the success of the
200 203 % load. Returns TRUE if successful, FALSE otherwise. */
201 204 % int load( char * );
202 205 %
203 206 %/* Initialize table using information given in scheme 'how'.
204 207 % Record the scheme for later use (make copy of it);
205 208 % create the required number of indices; and create table for storing
206 209 % entries.
207 210 % The 'tablePath' is passed on to db_table in order to obtain the
208 211 % NIS+/LDAP mapping information (if any). */
209 212 % void init( db_scheme *);
210 213 %
211 214 %/* Write this structure (table, indices, scheme) into the specified file. */
212 215 % int dump( char *);
213 216 %
214 217 %/* Removes the entry in the table named by given query 'q'.
215 218 % If a NULL query is supplied, all entries in table are removed.
216 219 % Returns DB_NOTFOUND if no entry is found.
217 220 % Returns DB_SUCCESS if one entry is found; this entry is removed from
218 221 % its record storage, and it is also removed from all the indices of the
219 222 % table. If more than one entry satisfying 'q' is found, all are removed. */
220 223 % db_status remove( db_query *);
221 224 %
222 225 %/* Add copy of given entry to table. Entry is identified by query 'q'.
223 226 % The entry (if any) satisfying the query is first deleted, then
224 227 % added to the indices (using index values extracted form the given entry)
225 228 % and the table.
226 229 % Returns DB_NOTUNIQUE if more than one entry satisfies the query.
227 230 % Returns DB_NOTFOUND if query is not well-formed.
228 231 % Returns DB_SUCCESS if entry can be added. */
229 232 % db_status add( db_query *, entry_object* );
230 233 %
231 234 %
232 235 %/* Finds entry that satisfy the query 'q'. Returns the answer by
233 236 % setting the pointer 'rp' to point to the list of answers.
234 237 % Note that the answers are pointers to copies of the entries.
235 238 % Returns the number of answers find in 'count'.
236 239 % Returns DB_SUCCESS if search found at least one answer;
237 240 % returns DB_NOTFOUND if none is found. */
238 241 % db_status lookup( db_query *, long *, entry_object_p ** );
239 242 %
240 243 %/* Returns the next entry in the table after 'previous' by setting 'answer' to
241 244 % point to a copy of the entry_object. Returns DB_SUCCESS if 'previous'
242 245 % is valid and next entry is found; DB_NOTFOUND otherwise. Sets 'where'
243 246 % to location of where entry is found for input as subsequent 'next'
244 247 % operation. */
245 248 % db_status next( entryp, entryp *, entry_object ** );
246 249 %
247 250 %/* Returns the next entry in the table after 'previous' by setting 'answer' to
248 251 % point to a copy of the entry_object. Returns DB_SUCCESS if 'previous'
249 252 % is valid and next entry is found; DB_NOTFOUND otherwise. Sets 'where'
250 253 % to location of where entry is found for input as subsequent 'next'
251 254 % operation. */
252 255 % db_status next( db_next_index_desc*, db_next_index_desc **, entry_object ** );
253 256 %
254 257 %/* Returns the first entry found in the table by setting 'answer' to
255 258 % a copy of the entry_object. Returns DB_SUCCESS if found;
256 259 % DB_NOTFOUND otherwise. */
257 260 % db_status first( entryp*, entry_object ** );
258 261 %
259 262 %/* Returns the first entry that satisfies query by setting 'answer' to
260 263 % a copy of the entry_object. Returns DB_SUCCESS if found;
261 264 % DB_NOTFOUND otherwise. */
262 265 % db_status first( db_query *, db_next_index_desc **, entry_object ** );
263 266 %
264 267 % /* Delete the given list of results; used when no longer interested in
265 268 % the results of the first/next query that returned this list. */
266 269 % db_status reset_next( db_next_index_desc *orig );
267 270 %
268 271 %/* Return all entries within table. Returns the answer by
269 272 % setting the pointer 'rp' to point to the list of answers.
270 273 % Note that the answers are pointers to copies of the entries.
271 274 % Returns the number of answers find in 'count'.
272 275 % Returns DB_SUCCESS if search found at least one answer;
273 276 % returns DB_NOTFOUND if none is found. */
274 277 % db_status all( long *, entry_object_p ** );
275 278 %
276 279 % /* for debugging */
277 280 %/* Prints statistics of the table. This includes the size of the table,
278 281 % the number of entries, and the index sizes. */
279 282 % void print_stats();
280 283 %
281 284 %/* Prints statistics about all indices of table. */
282 285 % void print_all_indices();
283 286 %
284 287 %
285 288 %/* Prints statistics about indices identified by 'n'. */
286 289 % void print_index( int n );
287 290 %
288 291 %/* Configure LDAP mapping */
289 292 % bool_t configure (char *objName);
290 293 %
291 294 %/* Mark this instance deferred */
292 295 % void markDeferred(void) {
293 296 % if (table != NULL) table->markDeferred();
294 297 % }
295 298 %/* Remove deferred mark */
296 299 % void unmarkDeferred(void) {
297 300 % if (table != NULL) table->unmarkDeferred();
298 301 % }
299 302 %
300 303 %/* Retrieve, remove, or store data from/in/to LDAP */
301 304 % int queryLDAP(db_query *, char *, int);
302 305 % int entriesFromLDAP(__nis_table_mapping_t *, db_query *, db_query *,
303 306 % char *, nis_object *, int);
304 307 %
305 308 % int removeLDAP(db_query *, nis_object *o);
306 309 %
307 310 % int storeObjLDAP(__nis_table_mapping_t *t, nis_object *o);
308 311 % int storeLDAP(db_query *, entry_obj *, nis_object *, entry_obj *,
309 312 % char *dbId);
310 313 %
311 314 %/* Set/clear no-write-through flag */
312 315 % void setNoWriteThrough(void);
313 316 % void clearNoWriteThrough(void);
314 317 %
315 318 %/* Set/clear no-LDAP-query flag */
316 319 % void setNoLDAPquery(void);
317 320 % void clearNoLDAPquery(void);
318 321 %
319 322 %/* Set/clear initialLoad flag */
320 323 % void setInitialLoad(void);
321 324 % void clearInitialLoad(void);
322 325 %
323 326 %/* Store/retrieve pointer to parent 'db' class instance */
324 327 % void setDbPtr(void *ptr);
325 328 % void *getDbPtr(void);
326 329 %
327 330 %/* Get pointer to private 'table' field */
328 331 % db_table *getTable(void);
329 332 %
330 333 %/*
331 334 % * Update table entry per the (entry_object *). If 'replace' is set,
332 335 % * the entry is replaced or added; otherwise, it is removed.
333 336 % */
334 337 % int updateTableEntry(entry_object *e, int replace, char *tableName,
335 338 % nis_object *obj, nis_object *tobj, uint32_t ttime,
336 339 % int *xid);
337 340 %
338 341 %/* Touch the indicated entry */
339 342 % bool_t touchEntry(entry_object *e);
340 343 % bool_t touchEntry(db_query *q);
341 344 %
342 345 %/* Return the 'scheme' pointer */
343 346 % db_scheme *getScheme(void) {return (scheme);}
344 347 %
345 348 %/* RW lock functions */
346 349 %
347 350 % int tryacqexcl(void) {
348 351 % return (TRYWLOCK(mindex));
349 352 % }
350 353 %
351 354 % int acqexcl(void) {
352 355 % return (WLOCK(mindex));
353 356 % }
354 357 %
355 358 % int relexcl(void) {
356 359 % return (WULOCK(mindex));
357 360 % }
358 361 %
359 362 % int acqnonexcl(void) {
360 363 % return (RLOCK(mindex));
361 364 % }
362 365 %
363 366 % int relnonexcl(void) {
364 367 % return (RULOCK(mindex));
365 368 % }
366 369 %};
367 370 %#ifdef __cplusplus
368 371 %extern "C" bool_t xdr_db_mindex(XDR*, db_mindex*);
369 372 %#elif __STDC__
370 373 %extern bool_t xdr_db_mindex(XDR*, db_mindex*);
371 374 %#endif
372 375 %typedef class db_mindex * db_mindex_p;
373 376 #endif /* RPC_HDR */
374 377 #endif /* USINGC */
375 378
376 379 #if RPC_HDR
377 380 %#endif /* _DB_MINDEX_H */
378 381 #endif /* RPC_HDR */
↓ open down ↓ |
258 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX