/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*
* Copyright (c) 1988-2000 by Sun Microsystems, Inc.
* All Rights Reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "db_headers.h"
#include "db_query.h"
#include "nisdb_mt.h"
#include <string.h>
/* Returns db_query containing the index values as obtained from 'attrlist.' */
{
int i;
if (components == NULL) {
num_components = 0;
"db_query::db_query: cannot allocate space for components",
}
for (i = 0; i < size; i++) {
&(components[i].which_index))) {
clear_components(i);
return;
}
components[i].index_value = new
clear_components(i);
"db_query::db_query:cannot allocate space for index",
}
}
}
/*
* Returns a newly db_query containing the index values as
* obtained from the given object. The object itself,
* along with information on the scheme given, will determine
* which values are extracted from the object and placed into the query.
* Returns an empty query if 'obj' is not a valid entry.
* Note that space is allocated for the query and the index values
* (i.e. do not share pointers with strings in 'obj'.)
*/
{
/* components of query to be returned */
int wherein_obj, i;
if (components == NULL) {
"db_query::db_query: cannot allocate space for components",
}
/* fill in each component of query */
for (i = 0; i < num_components; i++) {
if (wherein_obj >= objsize) {
"db_query::column %d cannot occur in object with %d columns (start counting at 0)\n",
clear_components(i); // clean up
return;
}
components[i].index_value = new
clear_components(i);
"db_query::db_query:cannot allocate space for index",
}
/* do something about null keys? */
}
}
void
{
int i;
if (components) {
for (i = 0; i < how_many; i++)
if (components[i].index_value)
delete components[i].index_value;
delete components;
components = NULL;
}
num_components = 0;
}
/* destructor */
{
}
/* Print all components of this query to stdout. */
void
{
int i;
for (i = 0; i < num_components; i++) {
putchar('\n');
}
}