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: isamdelrec.c /main/3 1995/10/23 11:34:30 rswiston $ */
29 static char sccsid[] = "@(#)isamdelrec.c 1.6 89/07/17 Copyr 1988 Sun Micro";
32 * Copyright (c) 1988 by Sun Microsystems, Inc.
38 * Description: _amdelrec()
39 * Delete record from ISAM file.
44 #include "isam_impl.h"
49 * _amdelrec(isfhandle, recnum, errcode)
51 * _amdelrec() deletes a record from ISAM file.
54 * isfhandle Handle of ISAM file
55 * recnum record number of the record to be deleted
58 * errcode error status of the operation
63 _amdelrec(Bytearray *isfhandle, Recno recnum, struct errcode *errcode)
66 char recbuf[ISMAXRECLEN];
74 * Get FCB corresponding to the isfhandle handle.
76 if ((fcb = _openfcb(isfhandle, errcode)) == NULL) {
81 rec_read = (fcb->varflag?_vlrec_read:_flrec_read);
82 rec_delete = (fcb->varflag?_vlrec_delete:_flrec_delete);
85 * Update information in FCB from CNTL page on the disk
87 (void)_isfcb_cntlpg_r2(fcb);
90 * We must read the record first to be able to delete keys.
92 if (rec_read(fcb, recbuf, recnum, &reclen) != ISOK) {
93 _amseterrcode(errcode, ENOREC);
97 if (rec_delete(fcb, recnum) != ISOK) {
98 _amseterrcode(errcode, ENOREC);
105 * Delete associated entries from all indexes.
107 _delkeys(fcb, recbuf, recnum);
109 _amseterrcode(errcode, ISOK);
117 * Update CNTL Page from the FCB.
119 (void)_isfcb_cntlpg_w2(fcb);
130 * Restore FCB from CNTL page.
132 if (fcb) (void)_isfcb_cntlpg_r2(fcb);
141 * Delete key entry from all indexes.
145 _delkeys(Fcb *fcb, char *record, Recno recnum)
147 int nkeys = fcb->nkeys;
150 for (i = 0; i < nkeys; i++) {
151 _del1key(fcb, fcb->keys + i, record, recnum);