Print this page
5910 libnisdb won't build with modern GCC
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libnisdb/db_dictionary_c.x
+++ new/usr/src/lib/libnisdb/db_dictionary_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, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 23 * db_dictionary_c.x
24 24 *
25 + * Copyright 2015 Gary Mills
25 26 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
26 27 * Use is subject to license terms.
27 28 */
28 29
29 -%#pragma ident "%Z%%M% %I% %E% SMI"
30 +#if RPC_XDR
31 +%#include "xdr_nullptr.h"
32 +#endif /* RPC_XDR */
30 33
31 34 #if RPC_HDR
32 35 %#ifndef _DB_DICTIONARY_H
33 36 %#define _DB_DICTIONARY_H
34 37
35 38 #ifdef USINGC
36 39 %#include "nisdb_rw.h"
37 40 %#include "nisdb_ldap.h"
38 41 %#include "db_entry_c.h"
39 42 %#include "db_scheme_c.h"
40 43 %#include "db_vers_c.h"
41 44 %#include "ldap_xdr.h"
42 45 %typedef void *nullptr;
43 46 %typedef u_int db_dict_version;
44 47 #else
45 48 %#include "nisdb_rw.h"
46 49 %#include "nisdb_ldap.h"
47 50 %#include "db_entry.h"
48 51 %#include "db_scheme.h"
49 52 %#include "db.h"
50 53 %#include "db_vers.h"
51 54 %#include "db_dictlog.h"
52 55 %#include "ldap_xdr.h"
53 56 #endif /* USINGC */
54 57 #endif /* RPC_HDR */
55 58
56 59 struct db_table_desc {
57 60 string table_name<NIS_MAXNAMELEN>;
58 61 u_long hashval;
59 62 db_scheme * scheme;
60 63 #ifdef USINGC
61 64 nullptr database; /* for XDR, keep database from descriptor */
62 65 #else
63 66 db *database; /* for program use in c++ code */
64 67 #endif /* USINGC */
65 68 db_table_desc *next;
66 69 };
67 70 typedef struct db_table_desc * db_table_desc_p;
68 71
69 72 /* Defining own version of xdr_db_dict_version */
70 73 #if RPC_HDR
71 74 #ifndef USINGC
72 75 typedef u_int db_dict_version;
73 76 %bool_t xdr_db_dict_version();
74 77 #endif /* USINGC */
75 78
76 79 typedef char * db_table_namep;
77 80 typedef db_table_namep db_table_names<>;
78 81
79 82 /* Defining own version of xdr_db_dict_desc */
80 83 #ifndef USINGC
81 84 struct db_dict_desc {
82 85 db_dict_version impl_vers;
83 86 db_table_desc_p tables<>;
84 87 int count;
85 88 };
86 89 #else
87 90 %struct db_dict_desc {
88 91 % db_dict_version impl_vers;
89 92 % struct {
90 93 % u_int tables_len;
91 94 % db_table_desc_p *tables_val;
92 95 % } tables;
93 96 % int count;
94 97 %};
95 98 %typedef struct db_dict_desc db_dict_desc;
96 99 %bool_t xdr_db_dict_desc();
97 100 #endif /* USINGC */
98 101
99 102 #endif
100 103
101 104 typedef struct db_dict_desc * db_dict_desc_p;
102 105
103 106 #if RPC_HDR
104 107 struct __nisdb_dictionary_defer_struct {
105 108 db_dict_desc *dictionary; /* Old incarnation */
106 109 };
107 110 typedef struct __nisdb_dictionary_defer_struct __nisdb_dictionary_defer_t;
108 111 #ifdef USINGC
109 112 %bool_t xdr___nisdb_dictionary_defer_t();
110 113 #endif /* USINGC */
111 114 #endif
112 115
113 116 #ifndef USINGC
114 117 #ifdef RPC_HDR
115 118 %class db_dictionary {
116 119 % db_dict_desc_p dictionary;
117 120 % bool_t initialized;
118 121 % char* filename;
119 122 % char* tmpfilename;
120 123 % char* logfilename;
121 124 % db_dictlog *logfile;
122 125 % bool_t logfile_opened;
123 126 % bool_t changed;
124 127 % __nisdb_dictionary_defer_t deferred;
125 128 % __nisdb_flag_t noWriteThrough;
126 129 % STRUCTRWLOCK(dict);
127 130 %
128 131 %/* Dump contents of this dictionary (minus the database representation)
129 132 % to its file. Returns 0 if operation succeeds, -1 otherwise. */
130 133 % int dump();
131 134 %
132 135 %/* Delete old log file and descriptor */
133 136 % int reset_log();
134 137 %
135 138 %/* Open log file (and creates descriptor) if it has not been opened */
136 139 % int open_log();
137 140 %
138 141 %/* Incorporate updates in log to dictionary already loaded.
139 142 % Does not affect "logfile" */
140 143 % int incorporate_log( char * );
141 144 %
142 145 % /* closes log file if opened */
143 146 % int close_log();
144 147 %
145 148 %/* Log the given action and execute it.
146 149 % The minor version of the dictionary is updated after the action has
147 150 % been executed and the dictionary is flagged as being changed.
148 151 % Return the structure db_result, or NULL if the loggin failed or the
149 152 % action is unknown. */
150 153 % db_status log_action(int, char* table, table_obj* tobj =0);
151 154 %
152 155 % db_status create_table_desc(char* table_name, table_obj* table_desc,
153 156 % db_table_desc**);
154 157 %
155 158 % db_dict_desc_p db_copy_dictionary(void);
156 159 %
157 160 % public:
158 161 %/* Constructor: creates an empty, uninitialized dictionary. */
159 162 % db_dictionary();
160 163 %
161 164 %/* Destructor: noop. Use db_shutdown if you really want to clean up. */
162 165 % ~db_dictionary() {}
163 166 %
164 167 % db_status merge_dict (db_dictionary&, char *, char *);
165 168 %
166 169 % db_status massage_dict (char *, char *, char *);
167 170 % int db_clone_bucket (db_table_desc *, db_table_desc_p *);
168 171 % int change_table_name (db_table_desc *, char *, char *);
169 172 % bool_t extract_entries (db_dictionary&, char **, int );
170 173 %
171 174 %/* Real destructor: deletes filename and table descriptors */
172 175 % db_status db_shutdown();
173 176 %
174 177 %/* Initialize dictionary from contents in 'file'.
175 178 % If there is already information in this dictionary, it is removed.
176 179 % Therefore, regardless of whether the load from the file succeeds,
177 180 % the contents of this dictionary will be altered. Returns
178 181 % whether table has been initialized successfully. */
179 182 % bool_t init( char* fname );
180 183 % bool_t inittemp( char* fname, db_dictionary&);
181 184 %
182 185 %/* closes any open log files for all tables in dictionary or 'tab'.
183 186 % "tab" is an optional argument.
184 187 % */
185 188 % db_status db_standby( char* tab = 0 );
186 189 %
187 190 %/* Write out in-memory copy of dictionary to file.
188 191 % 1. Update major version.
189 192 % 2. Dump contents to temporary file.
190 193 % 3. Rename temporary file to real dictionary file.
191 194 % 4. Remove log file.
192 195 % A checkpoint is done only if it has changed since the previous checkpoint.
193 196 % Returns TRUE if checkpoint was successful; FALSE otherwise. */
194 197 % db_status checkpoint();
195 198 %
196 199 %/* Checkpoints table specified by 'tab', or all tables if 'tab' is 0. */
197 200 % db_status db_checkpoint( char* tab = 0 );
198 201
199 202 %/* Add table with given name 'tab' and description 'zdesc' to dictionary.
200 203 % Returns error code if table already exists, or if no memory can be found
201 204 % to store the descriptor, or if dictionary has not been intialized.
202 205 % Dictionary is updated to stable store before addition.
203 206 % Fatal error occurs if dictionary cannot be saved.
204 207 % Returns DB_SUCCESS if dictionary has been updated successfully. */
205 208 % db_status add_table_aux(char* table_name, table_obj* table_desc, int mode);
206 209 %
207 210 %/* Delete table with given name 'tab' from dictionary.
208 211 % Returns error code if table does not exist or if dictionary has not been
209 212 % initialized. Dictionary is updated to stable store if deletion is
210 213 % successful. Fatal error occurs if dictionary cannot be saved.
211 214 % Returns DB_SUCCESS if dictionary has been updated successfully.
212 215 % Note that the files associated with the table are also removed. */
213 216 % db_status delete_table_aux( char* table_name, int mode );
214 217 %
215 218 % db_status add_table( char* table_name, table_obj* table_desc );
216 219 % int copyfile( char* infile, char *outfile);
217 220 %
218 221 % db_status delete_table( char* table_name );
219 222 %
220 223 %/* Return database structure of table named by 'table_name'.
221 224 % If 'where' is set, set it to the table_desc of 'table_name.'
222 225 % The database is loaded in from stable store if it has not been loaded.
223 226 % If it cannot be loaded, it is initialized using the scheme stored in
224 227 % the table_desc. NULL is returned if the initialization fails. */
225 228 % db* find_table( char* table_name, db_table_desc ** where = NULL );
226 229 %
227 230 % db *find_table(char *table_name, db_table_desc **where,
228 231 % bool_t searchDeferred);
229 232 % db *find_table(char *table_name, db_table_desc **where,
230 233 % bool_t searchDeferred, bool_t doLDAP,
231 234 % bool_t doLoad);
232 235 %
233 236 % db *find_table_noLDAP(char *table_name, db_table_desc **where,
234 237 % bool_t searchDeferred, bool_t doLoad);
235 238 %
236 239 %/* Returns db_table_desc of table name 'tab'.
237 240 % Use this if you do not want table to be loaded. */
238 241 % db_table_desc * find_table_desc( char* table_name );
239 242 %
240 243 % db_table_desc * find_table_desc(char *table_name, bool_t searchDeferred);
241 244 %
242 245 %/* Translate given nis attribute list to a db_query structure.
243 246 % Return FALSE if dictionary has not been initialized, or
244 247 % table does not have a scheme (which should be a fatal error?). */
245 248 % db_query * translate_to_query( db_table_desc*, int, nis_attr * );
246 249 %
247 250 %/* Return an array of strings of table names of all tables in dictionary. */
248 251 % db_table_names * get_table_names();
249 252 %
250 253 %/* Set/clear no-write-through flag */
251 254 % void setNoWriteThrough(void);
252 255 % void clearNoWriteThrough(void);
253 256 %
254 257 %/* Locking */
255 258 % int acqexcl(void) {
256 259 % return(WLOCK(dict));
257 260 % }
258 261 %
259 262 % int relexcl(void) {
260 263 % return (WULOCK(dict));
261 264 % }
262 265 %
263 266 % int acqnonexcl(void) {
264 267 % return (RLOCK(dict));
265 268 % }
266 269 %
267 270 % int relnonexcl(void) {
268 271 % return (RULOCK(dict));
269 272 % }
270 273 %
271 274 %/* Set deferred commit mode; intended for replica resync */
272 275 % db_status defer(char *table);
273 276 %
274 277 %/* Commit deferred changes; intended for replica resync */
275 278 % db_status commit(char *table);
276 279 %
277 280 %/* Roll back deferred changes; intended for replica resync */
278 281 % db_status rollback(char *table);
279 282 %};
280 283 %#ifdef __STDC__
281 284 %extern "C" bool_t xdr_db_table_desc_p(XDR *, db_table_desc_p *);
282 285 %extern "C" bool_t xdr_db_table_desc(XDR *, db_table_desc *);
283 286 %extern "C" bool_t xdr_db_dict_desc_p(XDR *, db_dict_desc_p *);
284 287 %extern "C" bool_t xdr_db_table_namep(XDR *, db_table_namep *);
285 288 %extern "C" bool_t xdr_db_table_names(XDR *, db_table_names *);
286 289 %#endif
287 290
288 291 #endif /* RPC_HDR */
289 292 #endif /* USINGC */
290 293
291 294 #if RPC_HDR
292 295 %#endif /* _DB_DICTIONARY_H */
293 296 #endif /* RPC_HDR */
294 297
↓ open down ↓ |
255 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX