2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
24 /*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
25 /*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
26 /*%% (c) Copyright 1993, 1994 Novell, Inc. */
27 /*%% $XConsortium: isindexinfo.c /main/3 1995/10/23 11:40:56 rswiston $ */
29 static char sccsid[] = "@(#)isindexinfo.c 1.2 91/05/16 Copyr 1988 Sun Micro";
32 * Copyright (c) 1988 by Sun Microsystems, Inc.
39 * Access file status information
43 #include "isam_impl.h"
49 * err = isindexinfo(isfd, buffer, number)
51 * Return information about index.
52 * Return information about the data file (if number == 0).
54 * (this function is overloaded).
57 * EBADARG number is out of range
58 * ENOTOPEN isfd is not ISAM file descriptor of open ISAM file
61 #define dibuf ((struct dictinfo *)buffer)
64 isindexinfo(int isfd, struct keydesc *buffer, int number)
71 * Get File Access Block.
73 if ((fab = _isfd_find(isfd)) == NULL) {
74 _setiserrno2(ENOTOPEN, '9', '0');
79 * Call the Access Method or RPC client function, depending whether
80 * the file is local or remote.
86 * Get FCB corresponding to the isfhandle handle.
88 if ((fcb = _openfcb(&fab->isfhandle, &fab->errcode)) == NULL) {
94 * Update information in FCB from CNTL page on the disk
96 (void)_isfcb_cntlpg_r(fcb);
99 * Validate number argument.
101 if (number < 0 || number > fcb->nkeys) {
102 _amseterrcode(&fab->errcode, EBADARG);
109 * Return dictinfo structure.
111 dibuf->di_nkeys = fcb->nkeys;
112 dibuf->di_recsize = fcb->maxreclen;
113 dibuf->di_idxsize = fcb->keys[0].k2_len;
114 dibuf->di_nrecords = fcb->nrecords;
116 /* Set msb of di_nkeys for variable length records. */
117 if (fcb->varflag == TRUE)
118 dibuf->di_nkeys |= DICTVARLENBIT;
123 * Return index information.
125 _iskey_itox(fcb->keys + number - 1, buffer);
128 _amseterrcode(&fab->errcode, ISOK);
130 /* XXX This fixes a core dump that occurs when isindexinfo is
131 * called on brand new tables
143 * Restore FCB from CNTL page.
155 isreclen = fab->minreclen; /* for variable length */
157 _seterr_errcode(&fab->errcode);
160 * This is a patch to conform with the VSX 3.0 test that checks
161 * that k_leng == 2 and k_type == 1 for index 1 if the ISAM file
162 * has no primary key. I suspect that these numbers are returned by
163 * C-ISAM and the author of VSX tests diligently checks them even
164 * though they have no meaning.
166 if (ret == ISOK && number == 1 && buffer->k_nparts == 0) {
168 buffer->k_type = INTTYPE;