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 * Copyright (c) 1988 by Sun Microsystems, Inc.
35 * Description: _amdelrec()
36 * Delete record from ISAM file.
41 #include "isam_impl.h"
46 * _amdelrec(isfhandle, recnum, errcode)
48 * _amdelrec() deletes a record from ISAM file.
51 * isfhandle Handle of ISAM file
52 * recnum record number of the record to be deleted
55 * errcode error status of the operation
60 _amdelrec(Bytearray *isfhandle, Recno recnum, struct errcode *errcode)
63 char recbuf[ISMAXRECLEN];
71 * Get FCB corresponding to the isfhandle handle.
73 if ((fcb = _openfcb(isfhandle, errcode)) == NULL) {
78 rec_read = (fcb->varflag?_vlrec_read:_flrec_read);
79 rec_delete = (fcb->varflag?_vlrec_delete:_flrec_delete);
82 * Update information in FCB from CNTL page on the disk
84 (void)_isfcb_cntlpg_r2(fcb);
87 * We must read the record first to be able to delete keys.
89 if (rec_read(fcb, recbuf, recnum, &reclen) != ISOK) {
90 _amseterrcode(errcode, ENOREC);
94 if (rec_delete(fcb, recnum) != ISOK) {
95 _amseterrcode(errcode, ENOREC);
102 * Delete associated entries from all indexes.
104 _delkeys(fcb, recbuf, recnum);
106 _amseterrcode(errcode, ISOK);
114 * Update CNTL Page from the FCB.
116 (void)_isfcb_cntlpg_w2(fcb);
127 * Restore FCB from CNTL page.
129 if (fcb) (void)_isfcb_cntlpg_r2(fcb);
138 * Delete key entry from all indexes.
142 _delkeys(Fcb *fcb, char *record, Recno recnum)
144 int nkeys = fcb->nkeys;
147 for (i = 0; i < nkeys; i++) {
148 _del1key(fcb, fcb->keys + i, record, recnum);