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 librararies 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: isaddprimary.c /main/3 1995/10/23 11:33:35 rswiston $ */
29 static char sccsid[] = "@(#)isaddprimary.c 1.8 89/07/17 Copyr 1988 Sun Micro";
31 /* @(#)isaddprimary.c 1.7 93/09/07
32 * Copyright (c) 1988 by Sun Microsystems, Inc.
39 * Add secondary index to ISAM file
43 #include "isam_impl.h"
46 Static int _am_addprimary();
50 * err = isaddprimary(isfd, keydesc)
52 * Isaddprimary() is used to add primary index to ISAM file.
54 * This call is not part of the X/OPEN sprec.
57 * EBADKEY error in keydesc
58 * EDUPL there are duplicate keys and the keydesc does not allow
60 * EKEXISTS key with the same key descriptor already exists
61 * EKEXISTS the ISAM file already has a primary index.
62 * ENOTEXCL ISAM file is not open in exclusive mode
63 * ENOTOPEN the ISAM file is not open in ISINOUT mode.
64 * EACCES Cannot create index file because of UNIX error.
68 isaddprimary(isfd, keydesc)
70 struct keydesc *keydesc;
76 * Get File Access Block.
78 if ((fab = _isfd_find(isfd)) == NULL) {
79 _setiserrno2(ENOTOPEN, '9', '0');
84 * Check that the open mode was ISOUTPUT
86 if (fab->openmode != OM_INOUT) {
87 _setiserrno2(ENOTOPEN, '9', '0');
91 ret = _am_addprimary(fab, keydesc);
92 _seterr_errcode(&fab->errcode);
94 return (ret); /* Successful write */
97 Static int _am_addprimary(fab, keydesc)
99 struct keydesc *keydesc;
101 return (_amaddprimary(&fab->isfhandle, keydesc, &fab->errcode));