2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * db_scheme_c.x
2N/A *
2N/A * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A%#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A#if RPC_HDR
2N/A%#ifndef _DB_SCHEMA_H
2N/A%#define _DB_SCHEMA_H
2N/A
2N/A#ifdef USINGC
2N/A%#include "db_item_c.h"
2N/A%#include "db_entry_c.h"
2N/A#else
2N/A%#include "db_item.h"
2N/A%#include "db_entry.h"
2N/A#endif /* USINGC */
2N/A
2N/Aconst DB_KEY_CASE = TA_CASE;
2N/A
2N/A#endif /* RPC_HDR */
2N/A%
2N/A%#include "nisdb_rw.h"
2N/A%
2N/A%/* Positional information of where field starts within record
2N/A% and its maximum length in terms of bytes. */
2N/Astruct db_posn_info {
2N/A short int start_column;
2N/A short int max_len;
2N/A};
2N/A
2N/A%/* Description of a key */
2N/Astruct db_key_desc {
2N/A item *key_name;
2N/A unsigned long key_flags; /* corresponds to tc_flags in table_col defn */
2N/A int column_number; /* column within data structure */
2N/A db_posn_info where; /* where within record entry is 'key' located */
2N/A short int store_type; /* ISAM or SS ? maybe useless */
2N/A};
2N/A
2N/A%/* Description of the data field. */
2N/Astruct db_data_desc {
2N/A db_posn_info where; /* where within record entry is 'data' located */
2N/A short int store_type; /* ISAM or SS ? maybe useless */
2N/A};
2N/A
2N/A%/* A scheme is a description of the fields of a table. */
2N/A
2N/A#if RPC_HDR || RPC_XDR
2N/A#ifdef USINGC
2N/A
2N/Astruct db_scheme {
2N/A db_key_desc keys<>;
2N/A short int max_columns; /* applies to data only ? */
2N/A db_data_desc data;
2N/A __nisdb_rwlock_t scheme_rwlock;
2N/A};
2N/A
2N/Atypedef struct db_scheme * db_scheme_p;
2N/A#endif /* USINGC */
2N/A#endif /* RPC_HDR */
2N/A
2N/A#ifndef USINGC
2N/A#ifdef RPC_HDR
2N/A%
2N/A%class db_scheme {
2N/A% protected:
2N/A% struct {
2N/A% int keys_len;
2N/A% db_key_desc *keys_val;
2N/A% } keys;
2N/A% short int max_columns; /* applies to data only ? */
2N/A% db_data_desc data;
2N/A% STRUCTRWLOCK(scheme);
2N/A%
2N/A% public:
2N/A%/* Accessor: return number of keys in scheme. */
2N/A% int numkeys() { return keys.keys_len; }
2N/A%
2N/A%/* Accessor: return location of array of key_desc's. */
2N/A% db_key_desc* keyloc () { return keys.keys_val; }
2N/A%
2N/A%/* Constructor: create empty scheme */
2N/A% db_scheme() {
2N/A% keys.keys_len = 0;
2N/A% keys.keys_val = NULL;
2N/A% (void) __nisdb_rwinit(&scheme_rwlock);
2N/A% }
2N/A%
2N/A%/* Constructor: create new scheme by making copy of 'orig'.
2N/A% All items within old scheme are also copied (i.e. no shared pointers). */
2N/A% db_scheme( db_scheme* orig );
2N/A%
2N/A%/* Constructor: create new sheme by using information in 'zdesc'. */
2N/A% db_scheme( table_obj * );
2N/A%
2N/A%/* Destructor: delete all keys associated with scheme and scheme itself. */
2N/A% ~db_scheme();
2N/A%
2N/A%/* Free space occupied by columns. */
2N/A% void clear_columns( int );
2N/A%
2N/A%/* Predicate: return whether given string is one of the index names
2N/A% of this scheme. If so, return in 'result' the index's number. */
2N/A% bool_t find_index( char*, int* );
2N/A%
2N/A%/* Print out description of table. */
2N/A% void print();
2N/A%
2N/A%/* Size of the non-MT/LDAP portion of the db_scheme structure */
2N/A% ulong_t oldstructsize(void) {
2N/A% return ((ulong_t)&(this->scheme_rwlock) - (ulong_t)this);
2N/A% }
2N/A%
2N/A%/* Locking methods */
2N/A%
2N/A% int acqexcl(void) {
2N/A% return (WLOCK(scheme));
2N/A% }
2N/A%
2N/A% int relexcl(void) {
2N/A% return (WULOCK(scheme));
2N/A% }
2N/A%
2N/A% int acqnonexcl(void) {
2N/A% return (RLOCK(scheme));
2N/A% }
2N/A%
2N/A% int relnonexcl(void) {
2N/A% return (RULOCK(scheme));
2N/A% }
2N/A%};
2N/A
2N/A%typedef class db_scheme * db_scheme_p;
2N/A#endif /* RPC_HDR */
2N/A#endif /* USINGC */
2N/A
2N/A#if RPC_HDR
2N/A%#endif /* _DB_SCHEMA_H */
2N/A
2N/A#endif /* RPC_HDR */