96abbe2a45540daa427576c423fac43ae31363ef
[oweals/cde.git] / cde / lib / tt / mini_isam / isdelrec.c
1 /*%%  (c) Copyright 1993, 1994 Hewlett-Packard Company                   */
2 /*%%  (c) Copyright 1993, 1994 International Business Machines Corp.     */
3 /*%%  (c) Copyright 1993, 1994 Sun Microsystems, Inc.                    */
4 /*%%  (c) Copyright 1993, 1994 Novell, Inc.                              */
5 /*%%  $XConsortium: isdelrec.c /main/3 1995/10/23 11:37:39 rswiston $                                                    */
6 #ifndef lint
7 static char sccsid[] = "@(#)isdelrec.c 1.8 89/07/17 Copyr 1988 Sun Micro";
8 #endif
9 /*
10  * Copyright (c) 1988 by Sun Microsystems, Inc.
11  */
12
13 /*
14  * isdelrec.c
15  *
16  * Description:
17  *      Delete a record in ISAM file. 
18  */
19
20
21 #include "isam_impl.h"
22 #include <sys/time.h>
23
24 /*
25  * err =  isdelrec(isfd, recnum)
26  *
27  * Isdelete() deletes a record from ISAM file. The record is identified 
28  * by its record number. All indexes of the ISAM file are updated.
29  *
30  * Current record position is not changed.
31  * isrecnum is set to recnum.
32  *
33  *
34  * Returns 0 if successful, or -1 of any error.
35  *
36  * Errors:
37  *      ELOCKED The file has been locked by another process.
38  *      ENOTOPEN isfd does not correspond to an open ISAM file, or the
39  *              ISAM file was not opened with ISINOUT mode.
40  *      ENOREC  Record with record number recnum does not exist.
41  */
42
43 int 
44 isdelrec(isfd, recnum)
45     int                 isfd;
46     long                recnum;
47 {
48     int                 _amdelrec();
49     register Fab        *fab;
50     int                 ret;
51
52     /*
53      * Get File Access Block.
54      */
55     if ((fab = _isfd_find(isfd)) == NULL) {
56         _setiserrno2(ENOTOPEN, '9', '0');
57         return (ISERROR);
58     }
59
60     /*
61      * Check that the open mode was ISINOUT.
62      */
63     if (fab->openmode != OM_INOUT) {
64         _setiserrno2(ENOTOPEN, '9', '0');
65         return (ISERROR);
66     }
67
68     if ((ret = _amdelrec(&fab->isfhandle, recnum, &fab->errcode)) == ISOK) {
69         isrecnum = recnum;                   /* Set isrecnum */
70     }
71
72     _seterr_errcode(&fab->errcode);
73
74     return (ret);                            /* Successful write */
75 }