Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / lib / tt / mini_isam / isfab.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: isfab.c /main/3 1995/10/23 11:38:24 rswiston $                                                       */
6 #ifndef lint
7 static char sccsid[] = "@(#)isfab.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  * isfab.c
15  *
16  * Description:
17  *      The ISAM file access block functions.
18  *
19  */
20
21 #include "isam_impl.h"
22
23
24 /*
25  * fab = *fab_new(isfname, mode, varlen, minreclen, maxreclen)
26  *
27  * Fab_new() creates an File access block (fab object) that is used
28  * for all subsequent operations in this file. Return a pointer to 
29  * the fab object, or NULL in the case of an error.
30  */
31
32 Fab *
33 _fab_new(isfname, openmode,
34          varlen, minreclen, maxreclen)
35     char                *isfname;            /* Local path on the host */
36     enum openmode       openmode;
37     Bool                varlen;              /* 0/1 flag */
38     int                 minreclen, maxreclen;
39 {
40     register Fab        *fab;
41
42     /* Allocate memory for the fab object. */
43     fab = (Fab *) _ismalloc(sizeof(*fab));
44     memset((char *)fab, 0, sizeof(*fab));
45
46     if (fab == NULL) {
47       iserrno = EFATAL;
48       return (NULL);
49     }
50
51     /* Set fields in the fab objects. */
52     fab->openmode = openmode;
53     fab->varlength = varlen;
54     fab->minreclen = minreclen;
55     fab->maxreclen = maxreclen;
56     fab->isfname = _isallocstring(isfname);
57
58     if (fab->isfname == NULL) {
59       free((char *)fab);
60       iserrno = EFATAL;
61       return (NULL);
62     }
63
64     return (fab);
65 }
66
67 void
68 _fab_destroy(fab)
69     register Fab        *fab;
70 {
71     assert(fab != NULL);
72     assert(fab->isfname != NULL);
73
74     _isfreestring(fab->isfname);
75
76     _bytearr_free(&fab->isfhandle);
77     _bytearr_free(&fab->curpos);
78
79     free((char *)fab);
80 }