blob: 391d707670d097a3eeaf0d3e93dcdef71d94799c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* db_scheme_c.x
*
* Copyright 2015 Gary Mills
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#if RPC_XDR
%#include "ldap_xdr.h"
#endif /* RPC_XDR */
#if RPC_HDR
%#ifndef _DB_SCHEMA_H
%#define _DB_SCHEMA_H
#ifdef USINGC
%#include "db_item_c.h"
%#include "db_entry_c.h"
#else
%#include "db_item.h"
%#include "db_entry.h"
#endif /* USINGC */
const DB_KEY_CASE = TA_CASE;
#endif /* RPC_HDR */
%
%#include "nisdb_rw.h"
%
%/* Positional information of where field starts within record
% and its maximum length in terms of bytes. */
struct db_posn_info {
short int start_column;
short int max_len;
};
%/* Description of a key */
struct db_key_desc {
item *key_name;
unsigned long key_flags; /* corresponds to tc_flags in table_col defn */
int column_number; /* column within data structure */
db_posn_info where; /* where within record entry is 'key' located */
short int store_type; /* ISAM or SS ? maybe useless */
};
%/* Description of the data field. */
struct db_data_desc {
db_posn_info where; /* where within record entry is 'data' located */
short int store_type; /* ISAM or SS ? maybe useless */
};
%/* A scheme is a description of the fields of a table. */
#if RPC_HDR || RPC_XDR
#ifdef USINGC
struct db_scheme {
db_key_desc keys<>;
short int max_columns; /* applies to data only ? */
db_data_desc data;
__nisdb_rwlock_t scheme_rwlock;
};
typedef struct db_scheme * db_scheme_p;
#endif /* USINGC */
#endif /* RPC_HDR */
#ifndef USINGC
#ifdef RPC_HDR
%
%class db_scheme {
% protected:
% struct {
% int keys_len;
% db_key_desc *keys_val;
% } keys;
% short int max_columns; /* applies to data only ? */
% db_data_desc data;
% STRUCTRWLOCK(scheme);
%
% public:
%/* Accessor: return number of keys in scheme. */
% int numkeys() { return keys.keys_len; }
%
%/* Accessor: return location of array of key_desc's. */
% db_key_desc* keyloc () { return keys.keys_val; }
%
%/* Constructor: create empty scheme */
% db_scheme() {
% keys.keys_len = 0;
% keys.keys_val = NULL;
% (void) __nisdb_rwinit(&scheme_rwlock);
% }
%
%/* Constructor: create new scheme by making copy of 'orig'.
% All items within old scheme are also copied (i.e. no shared pointers). */
% db_scheme( db_scheme* orig );
%
%/* Constructor: create new sheme by using information in 'zdesc'. */
% db_scheme( table_obj * );
%
%/* Destructor: delete all keys associated with scheme and scheme itself. */
% ~db_scheme();
%
%/* Free space occupied by columns. */
% void clear_columns( int );
%
%/* Predicate: return whether given string is one of the index names
% of this scheme. If so, return in 'result' the index's number. */
% bool_t find_index( char*, int* );
%
%/* Print out description of table. */
% void print();
%
%/* Size of the non-MT/LDAP portion of the db_scheme structure */
% ulong_t oldstructsize(void) {
% return ((ulong_t)&(this->scheme_rwlock) - (ulong_t)this);
% }
%
%/* Locking methods */
%
% int acqexcl(void) {
% return (WLOCK(scheme));
% }
%
% int relexcl(void) {
% return (WULOCK(scheme));
% }
%
% int acqnonexcl(void) {
% return (RLOCK(scheme));
% }
%
% int relnonexcl(void) {
% return (RULOCK(scheme));
% }
%};
%typedef class db_scheme * db_scheme_p;
#endif /* RPC_HDR */
#endif /* USINGC */
#if RPC_HDR
%#endif /* _DB_SCHEMA_H */
#endif /* RPC_HDR */
|