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