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