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_query_c.x 247c478bd9Sstevel@tonic-gate * 25a506a34cSth * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 26a506a34cSth * Use is subject to license terms. 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #if RPC_HDR 307c478bd9Sstevel@tonic-gate %#ifndef _DB_QUERY_H 317c478bd9Sstevel@tonic-gate %#define _DB_QUERY_H 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate % 347c478bd9Sstevel@tonic-gate %/* db_query is the structure that contains the components of a query. 357c478bd9Sstevel@tonic-gate % It contains the values for searching the indices. */ 367c478bd9Sstevel@tonic-gate % 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifdef USINGC 397c478bd9Sstevel@tonic-gate %#include "db_item_c.h" 407c478bd9Sstevel@tonic-gate %#include "db_entry_c.h" 417c478bd9Sstevel@tonic-gate %#include "db_scheme_c.h" 427c478bd9Sstevel@tonic-gate #else 437c478bd9Sstevel@tonic-gate %#include "db_item.h" 447c478bd9Sstevel@tonic-gate %#include "db_entry.h" 457c478bd9Sstevel@tonic-gate %#include "db_scheme.h" 46a506a34cSth #endif /* USINGC */ 47a506a34cSth #endif /* RPC_HDR */ 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate %/* A component of a query */ 507c478bd9Sstevel@tonic-gate struct db_qcomp { 517c478bd9Sstevel@tonic-gate int which_index; /* identifies which index is being used */ 527c478bd9Sstevel@tonic-gate item* index_value; /* value to be used in search */ 537c478bd9Sstevel@tonic-gate }; 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate #if RPC_HDR || RPC_XDR 567c478bd9Sstevel@tonic-gate #ifdef USINGC 577c478bd9Sstevel@tonic-gate struct db_query { 587c478bd9Sstevel@tonic-gate db_qcomp components<>; 597c478bd9Sstevel@tonic-gate }; 60a506a34cSth #endif /* USINGC */ 61a506a34cSth #endif /* RPC_HDR */ 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate #ifndef USINGC 647c478bd9Sstevel@tonic-gate #ifdef RPC_HDR 657c478bd9Sstevel@tonic-gate % 667c478bd9Sstevel@tonic-gate %class db_query { 677c478bd9Sstevel@tonic-gate %protected: 687c478bd9Sstevel@tonic-gate % int num_components; 697c478bd9Sstevel@tonic-gate % db_qcomp* components; 707c478bd9Sstevel@tonic-gate % public: 717c478bd9Sstevel@tonic-gate %/* Accessor: returns number of components */ 727c478bd9Sstevel@tonic-gate % int size() { return num_components; } 737c478bd9Sstevel@tonic-gate % 747c478bd9Sstevel@tonic-gate %/* Accessor: returns location of start of query */ 757c478bd9Sstevel@tonic-gate % db_qcomp* queryloc() { return components; } 767c478bd9Sstevel@tonic-gate % 777c478bd9Sstevel@tonic-gate % 787c478bd9Sstevel@tonic-gate %/* Null constructor: returns empty empty query. */ 797c478bd9Sstevel@tonic-gate % db_query() { num_components = 0; components = NULL; } 807c478bd9Sstevel@tonic-gate % 817c478bd9Sstevel@tonic-gate %/* Returns a db_query containing the index values as obtained from 827c478bd9Sstevel@tonic-gate % 'attrlist.' */ 837c478bd9Sstevel@tonic-gate % db_query( db_scheme*, int, nis_attr* ); 847c478bd9Sstevel@tonic-gate % 857c478bd9Sstevel@tonic-gate %/* Returns a newly db_query containing the index values as 86*1da57d55SToomas Soome % obtained from the given object. The object itself, 87*1da57d55SToomas Soome % along with information on the scheme given, will determine 887c478bd9Sstevel@tonic-gate % which values are extracted from the object and placed into the query. 897c478bd9Sstevel@tonic-gate % Returns an empty query if 'obj' is not a valid entry. 90*1da57d55SToomas Soome % Note that space is allocated for the query and the index values 917c478bd9Sstevel@tonic-gate % (i.e. do not share pointers with strings in 'obj'.) 927c478bd9Sstevel@tonic-gate %*/ 937c478bd9Sstevel@tonic-gate % db_query( db_scheme*, entry_object_p ); 947c478bd9Sstevel@tonic-gate % 957c478bd9Sstevel@tonic-gate % /* destructor (frees all components) */ 967c478bd9Sstevel@tonic-gate % ~db_query(); 977c478bd9Sstevel@tonic-gate % 987c478bd9Sstevel@tonic-gate % /* clear component structure */ 997c478bd9Sstevel@tonic-gate % void clear_components( int ); 1007c478bd9Sstevel@tonic-gate % 1017c478bd9Sstevel@tonic-gate %/* Print all components of this query to stdout. */ 1027c478bd9Sstevel@tonic-gate % void print(); 1037c478bd9Sstevel@tonic-gate %}; 1047c478bd9Sstevel@tonic-gate %typedef class db_query * db_query_p; 105a506a34cSth #endif /* RPC_HDR */ 106a506a34cSth #endif /* USINGC */ 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate #if RPC_HDR 109a506a34cSth %#endif /* _DB_QUERY_H */ 110a506a34cSth #endif /* RPC_HDR */ 111