4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 2001 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include "ldap_scheme.h"
30 #include "ldap_util.h"
31 #include "ldap_nisdbquery.h"
35 * Input: A db_query where the 'which_index' fields refer to the schema
37 * Output: A db_query where the 'which_index' fields refer to the table
41 schemeQuery2Query(db_query
*qin
, db_scheme
*s
) {
44 char *myself
= "schemeQuery2Query";
46 q
= cloneQuery(qin
, 0);
50 for (i
= 0; i
< q
->components
.components_len
; i
++) {
51 int index
= q
->components
.components_val
[i
].which_index
;
52 if (index
>= s
->keys
.keys_len
) {
53 logmsg(MSG_NOTIMECHECK
, LOG_ERR
,
54 "%s: query index %d out-of-range (%d)",
55 myself
, index
, s
->keys
.keys_len
-1);
59 q
->components
.components_val
[i
].which_index
=
60 s
->keys
.keys_val
[index
].column_number
- 1;
66 static const char *dirCol
= "name";
69 * Input: A db_query where the 'which_index' fields refer to the scheme
70 * columns, space for a nis_attr array with at least q->components->
71 * components_len elements, a scheme, and a __nis_table_mapping_t
73 * Output: A nis_attr structure with the searchable columns.
76 schemeQuery2nisAttr(db_query
*q
, nis_attr
*space
, db_scheme
*s
,
77 __nis_table_mapping_t
*t
, int *numAttr
) {
81 char *myself
= "schemeQuery2nisAttr";
83 if (q
== 0 || space
== 0 || s
== 0 || t
== 0 || numAttr
== 0)
87 * A table will have the column names stored in the mapping
88 * structure, while a directory only has a single column
89 * called "name". The latter isn't stored in the mapping,
90 * so we create a column name array for a directory.
92 if (t
->numColumns
> 0) {
96 if (t
->objType
== NIS_DIRECTORY_OBJ
) {
97 col
= (char **)&dirCol
;
106 for (i
= 0, na
= 0; i
< q
->components
.components_len
; i
++) {
109 if (q
->components
.components_val
[i
].which_index
>=
111 logmsg(MSG_NOTIMECHECK
, LOG_ERR
,
112 "%s: query index %d out-of-range (%d)",
114 q
->components
.components_val
[i
].which_index
,
119 index
= s
->keys
.keys_val
[i
].column_number
- 1;
121 logmsg(MSG_NOTIMECHECK
, LOG_ERR
,
122 "%s: column index out-of-range (%d >= %d)",
127 a
[na
].zattr_ndx
= col
[index
];
128 a
[na
].zattr_val
.zattr_val_val
= q
->components
.
129 components_val
[i
].index_value
->itemvalue
.itemvalue_val
;
130 a
[na
].zattr_val
.zattr_val_len
= q
->components
.
131 components_val
[i
].index_value
->itemvalue
.itemvalue_len
;