xref: /titanic_52/usr/src/lib/libnisdb/db_query_c.x (revision a506a34ceb0e9dcc6c61bf0560202f8538928650)
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  *
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_QUERY_H
337c478bd9Sstevel@tonic-gate %#define _DB_QUERY_H
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate %
367c478bd9Sstevel@tonic-gate %/* db_query is the structure that contains the components of a query.
377c478bd9Sstevel@tonic-gate %   It contains the values for searching the indices. */
387c478bd9Sstevel@tonic-gate %
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #ifdef USINGC
417c478bd9Sstevel@tonic-gate %#include "db_item_c.h"
427c478bd9Sstevel@tonic-gate %#include "db_entry_c.h"
437c478bd9Sstevel@tonic-gate %#include "db_scheme_c.h"
447c478bd9Sstevel@tonic-gate #else
457c478bd9Sstevel@tonic-gate %#include "db_item.h"
467c478bd9Sstevel@tonic-gate %#include "db_entry.h"
477c478bd9Sstevel@tonic-gate %#include "db_scheme.h"
48*a506a34cSth160488 #endif /* USINGC */
49*a506a34cSth160488 #endif /* RPC_HDR */
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate %/* A component of a query */
527c478bd9Sstevel@tonic-gate struct db_qcomp {
537c478bd9Sstevel@tonic-gate   int which_index;             /* identifies which index is being used */
547c478bd9Sstevel@tonic-gate   item* index_value;           /* value to be used in search */
557c478bd9Sstevel@tonic-gate };
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate #if RPC_HDR || RPC_XDR
587c478bd9Sstevel@tonic-gate #ifdef USINGC
597c478bd9Sstevel@tonic-gate struct db_query {
607c478bd9Sstevel@tonic-gate   db_qcomp components<>;
617c478bd9Sstevel@tonic-gate };
62*a506a34cSth160488 #endif /* USINGC */
63*a506a34cSth160488 #endif /* RPC_HDR */
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate #ifndef USINGC
667c478bd9Sstevel@tonic-gate #ifdef RPC_HDR
677c478bd9Sstevel@tonic-gate %
687c478bd9Sstevel@tonic-gate %class db_query {
697c478bd9Sstevel@tonic-gate %protected:
707c478bd9Sstevel@tonic-gate %  int num_components;
717c478bd9Sstevel@tonic-gate %  db_qcomp* components;
727c478bd9Sstevel@tonic-gate % public:
737c478bd9Sstevel@tonic-gate %/* Accessor:  returns number of components */
747c478bd9Sstevel@tonic-gate %  int size() { return num_components; }
757c478bd9Sstevel@tonic-gate %
767c478bd9Sstevel@tonic-gate %/* Accessor:  returns location of start of query */
777c478bd9Sstevel@tonic-gate %   db_qcomp* queryloc() { return components; }
787c478bd9Sstevel@tonic-gate %
797c478bd9Sstevel@tonic-gate %
807c478bd9Sstevel@tonic-gate %/* Null constructor:  returns empty empty query. */
817c478bd9Sstevel@tonic-gate %  db_query() { num_components = 0; components = NULL; }
827c478bd9Sstevel@tonic-gate %
837c478bd9Sstevel@tonic-gate %/* Returns a db_query containing the index values as obtained from
847c478bd9Sstevel@tonic-gate %   'attrlist.' */
857c478bd9Sstevel@tonic-gate %  db_query( db_scheme*, int, nis_attr* );
867c478bd9Sstevel@tonic-gate %
877c478bd9Sstevel@tonic-gate %/* Returns a newly db_query containing the index values as
887c478bd9Sstevel@tonic-gate %   obtained from the given object.  The object itself,
897c478bd9Sstevel@tonic-gate %   along with information on the scheme given, will determine
907c478bd9Sstevel@tonic-gate %   which values are extracted from the object and placed into the query.
917c478bd9Sstevel@tonic-gate %   Returns an empty query if 'obj' is not a valid entry.
927c478bd9Sstevel@tonic-gate %   Note that space is allocated for the query and the index values
937c478bd9Sstevel@tonic-gate %   (i.e. do not share pointers with strings in 'obj'.)
947c478bd9Sstevel@tonic-gate %*/
957c478bd9Sstevel@tonic-gate %  db_query( db_scheme*, entry_object_p );
967c478bd9Sstevel@tonic-gate %
977c478bd9Sstevel@tonic-gate %  /* destructor (frees all components) */
987c478bd9Sstevel@tonic-gate %  ~db_query();
997c478bd9Sstevel@tonic-gate %
1007c478bd9Sstevel@tonic-gate %  /* clear component structure */
1017c478bd9Sstevel@tonic-gate %  void clear_components( int );
1027c478bd9Sstevel@tonic-gate %
1037c478bd9Sstevel@tonic-gate %/* Print all components of this query to stdout. */
1047c478bd9Sstevel@tonic-gate %  void print();
1057c478bd9Sstevel@tonic-gate %};
1067c478bd9Sstevel@tonic-gate %typedef class db_query * db_query_p;
107*a506a34cSth160488 #endif /* RPC_HDR */
108*a506a34cSth160488 #endif /* USINGC */
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate #if RPC_HDR
111*a506a34cSth160488 %#endif /* _DB_QUERY_H */
112*a506a34cSth160488 #endif /* RPC_HDR */
113