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 * Copyright (c) 1988 by Sun Microsystems, Inc.
36 * Access file status information
40 #include "isam_impl.h"
46 * err = isindexinfo(isfd, buffer, number)
48 * Return information about index.
49 * Return information about the data file (if number == 0).
51 * (this function is overloaded).
54 * EBADARG number is out of range
55 * ENOTOPEN isfd is not ISAM file descriptor of open ISAM file
58 #define dibuf ((struct dictinfo *)buffer)
61 isindexinfo(int isfd, struct keydesc *buffer, int number)
68 * Get File Access Block.
70 if ((fab = _isfd_find(isfd)) == NULL) {
71 _setiserrno2(ENOTOPEN, '9', '0');
76 * Call the Access Method or RPC client function, depending whether
77 * the file is local or remote.
83 * Get FCB corresponding to the isfhandle handle.
85 if ((fcb = _openfcb(&fab->isfhandle, &fab->errcode)) == NULL) {
91 * Update information in FCB from CNTL page on the disk
93 (void)_isfcb_cntlpg_r(fcb);
96 * Validate number argument.
98 if (number < 0 || number > fcb->nkeys) {
99 _amseterrcode(&fab->errcode, EBADARG);
106 * Return dictinfo structure.
108 dibuf->di_nkeys = fcb->nkeys;
109 dibuf->di_recsize = fcb->maxreclen;
110 dibuf->di_idxsize = fcb->keys[0].k2_len;
111 dibuf->di_nrecords = fcb->nrecords;
113 /* Set msb of di_nkeys for variable length records. */
114 if (fcb->varflag == TRUE)
115 dibuf->di_nkeys |= DICTVARLENBIT;
120 * Return index information.
122 _iskey_itox(fcb->keys + number - 1, buffer);
125 _amseterrcode(&fab->errcode, ISOK);
127 /* XXX This fixes a core dump that occurs when isindexinfo is
128 * called on brand new tables
140 * Restore FCB from CNTL page.
152 isreclen = fab->minreclen; /* for variable length */
154 _seterr_errcode(&fab->errcode);
157 * This is a patch to conform with the VSX 3.0 test that checks
158 * that k_leng == 2 and k_type == 1 for index 1 if the ISAM file
159 * has no primary key. I suspect that these numbers are returned by
160 * C-ISAM and the author of VSX tests diligently checks them even
161 * though they have no meaning.
163 if (ret == ISOK && number == 1 && buffer->k_nparts == 0) {
165 buffer->k_type = INTTYPE;