17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * db_scheme_c.x 247c478bd9Sstevel@tonic-gate * 25*a506a34cSth160488 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 26*a506a34cSth160488 * Use is subject to license terms. 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate %#pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #if RPC_HDR 327c478bd9Sstevel@tonic-gate %#ifndef _DB_SCHEMA_H 337c478bd9Sstevel@tonic-gate %#define _DB_SCHEMA_H 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifdef USINGC 367c478bd9Sstevel@tonic-gate %#include "db_item_c.h" 377c478bd9Sstevel@tonic-gate %#include "db_entry_c.h" 387c478bd9Sstevel@tonic-gate #else 397c478bd9Sstevel@tonic-gate %#include "db_item.h" 407c478bd9Sstevel@tonic-gate %#include "db_entry.h" 41*a506a34cSth160488 #endif /* USINGC */ 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate const DB_KEY_CASE = TA_CASE; 447c478bd9Sstevel@tonic-gate 45*a506a34cSth160488 #endif /* RPC_HDR */ 467c478bd9Sstevel@tonic-gate % 477c478bd9Sstevel@tonic-gate %#include "nisdb_rw.h" 487c478bd9Sstevel@tonic-gate % 497c478bd9Sstevel@tonic-gate %/* Positional information of where field starts within record 507c478bd9Sstevel@tonic-gate % and its maximum length in terms of bytes. */ 517c478bd9Sstevel@tonic-gate struct db_posn_info { 527c478bd9Sstevel@tonic-gate short int start_column; 537c478bd9Sstevel@tonic-gate short int max_len; 547c478bd9Sstevel@tonic-gate }; 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate %/* Description of a key */ 577c478bd9Sstevel@tonic-gate struct db_key_desc { 587c478bd9Sstevel@tonic-gate item *key_name; 597c478bd9Sstevel@tonic-gate unsigned long key_flags; /* corresponds to tc_flags in table_col defn */ 607c478bd9Sstevel@tonic-gate int column_number; /* column within data structure */ 617c478bd9Sstevel@tonic-gate db_posn_info where; /* where within record entry is 'key' located */ 627c478bd9Sstevel@tonic-gate short int store_type; /* ISAM or SS ? maybe useless */ 637c478bd9Sstevel@tonic-gate }; 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate %/* Description of the data field. */ 667c478bd9Sstevel@tonic-gate struct db_data_desc { 677c478bd9Sstevel@tonic-gate db_posn_info where; /* where within record entry is 'data' located */ 687c478bd9Sstevel@tonic-gate short int store_type; /* ISAM or SS ? maybe useless */ 697c478bd9Sstevel@tonic-gate }; 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate %/* A scheme is a description of the fields of a table. */ 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate #if RPC_HDR || RPC_XDR 747c478bd9Sstevel@tonic-gate #ifdef USINGC 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate struct db_scheme { 777c478bd9Sstevel@tonic-gate db_key_desc keys<>; 787c478bd9Sstevel@tonic-gate short int max_columns; /* applies to data only ? */ 797c478bd9Sstevel@tonic-gate db_data_desc data; 807c478bd9Sstevel@tonic-gate __nisdb_rwlock_t scheme_rwlock; 817c478bd9Sstevel@tonic-gate }; 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate typedef struct db_scheme * db_scheme_p; 84*a506a34cSth160488 #endif /* USINGC */ 85*a506a34cSth160488 #endif /* RPC_HDR */ 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate #ifndef USINGC 887c478bd9Sstevel@tonic-gate #ifdef RPC_HDR 897c478bd9Sstevel@tonic-gate % 907c478bd9Sstevel@tonic-gate %class db_scheme { 917c478bd9Sstevel@tonic-gate % protected: 927c478bd9Sstevel@tonic-gate % struct { 937c478bd9Sstevel@tonic-gate % int keys_len; 947c478bd9Sstevel@tonic-gate % db_key_desc *keys_val; 957c478bd9Sstevel@tonic-gate % } keys; 967c478bd9Sstevel@tonic-gate % short int max_columns; /* applies to data only ? */ 977c478bd9Sstevel@tonic-gate % db_data_desc data; 987c478bd9Sstevel@tonic-gate % STRUCTRWLOCK(scheme); 997c478bd9Sstevel@tonic-gate % 1007c478bd9Sstevel@tonic-gate % public: 1017c478bd9Sstevel@tonic-gate %/* Accessor: return number of keys in scheme. */ 1027c478bd9Sstevel@tonic-gate % int numkeys() { return keys.keys_len; } 1037c478bd9Sstevel@tonic-gate % 1047c478bd9Sstevel@tonic-gate %/* Accessor: return location of array of key_desc's. */ 1057c478bd9Sstevel@tonic-gate % db_key_desc* keyloc () { return keys.keys_val; } 1067c478bd9Sstevel@tonic-gate % 1077c478bd9Sstevel@tonic-gate %/* Constructor: create empty scheme */ 1087c478bd9Sstevel@tonic-gate % db_scheme() { 1097c478bd9Sstevel@tonic-gate % keys.keys_len = 0; 1107c478bd9Sstevel@tonic-gate % keys.keys_val = NULL; 1117c478bd9Sstevel@tonic-gate % (void) __nisdb_rwinit(&scheme_rwlock); 1127c478bd9Sstevel@tonic-gate % } 1137c478bd9Sstevel@tonic-gate % 1147c478bd9Sstevel@tonic-gate %/* Constructor: create new scheme by making copy of 'orig'. 1157c478bd9Sstevel@tonic-gate % All items within old scheme are also copied (i.e. no shared pointers). */ 1167c478bd9Sstevel@tonic-gate % db_scheme( db_scheme* orig ); 1177c478bd9Sstevel@tonic-gate % 1187c478bd9Sstevel@tonic-gate %/* Constructor: create new sheme by using information in 'zdesc'. */ 1197c478bd9Sstevel@tonic-gate % db_scheme( table_obj * ); 1207c478bd9Sstevel@tonic-gate % 1217c478bd9Sstevel@tonic-gate %/* Destructor: delete all keys associated with scheme and scheme itself. */ 1227c478bd9Sstevel@tonic-gate % ~db_scheme(); 1237c478bd9Sstevel@tonic-gate % 1247c478bd9Sstevel@tonic-gate %/* Free space occupied by columns. */ 1257c478bd9Sstevel@tonic-gate % void clear_columns( int ); 1267c478bd9Sstevel@tonic-gate % 1277c478bd9Sstevel@tonic-gate %/* Predicate: return whether given string is one of the index names 1287c478bd9Sstevel@tonic-gate % of this scheme. If so, return in 'result' the index's number. */ 1297c478bd9Sstevel@tonic-gate % bool_t find_index( char*, int* ); 1307c478bd9Sstevel@tonic-gate % 1317c478bd9Sstevel@tonic-gate %/* Print out description of table. */ 1327c478bd9Sstevel@tonic-gate % void print(); 1337c478bd9Sstevel@tonic-gate % 1347c478bd9Sstevel@tonic-gate %/* Size of the non-MT/LDAP portion of the db_scheme structure */ 1357c478bd9Sstevel@tonic-gate % ulong_t oldstructsize(void) { 1367c478bd9Sstevel@tonic-gate % return ((ulong_t)&(this->scheme_rwlock) - (ulong_t)this); 1377c478bd9Sstevel@tonic-gate % } 1387c478bd9Sstevel@tonic-gate % 1397c478bd9Sstevel@tonic-gate %/* Locking methods */ 1407c478bd9Sstevel@tonic-gate % 1417c478bd9Sstevel@tonic-gate % int acqexcl(void) { 1427c478bd9Sstevel@tonic-gate % return (WLOCK(scheme)); 1437c478bd9Sstevel@tonic-gate % } 1447c478bd9Sstevel@tonic-gate % 1457c478bd9Sstevel@tonic-gate % int relexcl(void) { 1467c478bd9Sstevel@tonic-gate % return (WULOCK(scheme)); 1477c478bd9Sstevel@tonic-gate % } 1487c478bd9Sstevel@tonic-gate % 1497c478bd9Sstevel@tonic-gate % int acqnonexcl(void) { 1507c478bd9Sstevel@tonic-gate % return (RLOCK(scheme)); 1517c478bd9Sstevel@tonic-gate % } 1527c478bd9Sstevel@tonic-gate % 1537c478bd9Sstevel@tonic-gate % int relnonexcl(void) { 1547c478bd9Sstevel@tonic-gate % return (RULOCK(scheme)); 1557c478bd9Sstevel@tonic-gate % } 1567c478bd9Sstevel@tonic-gate %}; 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate %typedef class db_scheme * db_scheme_p; 159*a506a34cSth160488 #endif /* RPC_HDR */ 160*a506a34cSth160488 #endif /* USINGC */ 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate #if RPC_HDR 163*a506a34cSth160488 %#endif /* _DB_SCHEMA_H */ 1647c478bd9Sstevel@tonic-gate 165*a506a34cSth160488 #endif /* RPC_HDR */ 166