8879bd665af05842ee04752cf23de081fdad45d7
[idzebra-moved-to-github.git] / rset / rsisam.c
1 /*
2  * Copyright (C) 1994, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: rsisam.c,v $
7  * Revision 1.2  1994-11-04 14:53:12  quinn
8  * Work
9  *
10  */
11
12 /* TODO: Memory management */
13
14 #include <rsisam.h>
15 #include <util.h>
16
17 rset_control *r_create(const struct rset_control *sel, void *parms);
18 static int r_open(rset_control *ct, int wflag);
19 static void r_close(rset_control *ct);
20 static void r_delete(rset_control *ct);
21 static void r_rewind(rset_control *ct);
22 static int r_count(rset_control *ct);
23 static int r_read();
24 static int r_write();
25
26 static const rset_control control = 
27 {
28     "ISAM set type",
29     0,
30     r_create,
31     r_open,
32     r_close,
33     r_delete,
34     r_rewind,
35     r_count,
36     r_read,
37     r_write
38 };
39
40 const rset_control *rset_kind_isam = &control;
41
42 rset_control *r_create(const struct rset_control *sel, void *parms)
43 {
44     rset_control *newct;
45     rset_isam_parms *pt = parms;
46
47     newct = xmalloc(sizeof(*newct));
48     if (!(newct->buf = (char*) is_position(pt->is, pt->pos)))
49         return 0;
50     return newct;
51 }
52
53 static int r_open(rset_control *ct, int wflag)
54 {
55     if (wflag)
56     {
57         log(LOG_FATAL, "ISAM set type is read-only");
58         return -1;
59     }
60     r_rewind(ct);
61     return 0;
62 }
63
64 static void r_close(rset_control *ct)
65 {
66     /* NOP */
67 }
68
69 static void r_delete(rset_control *ct)
70 {
71     is_pt_free((ISPT) ct->buf);
72     xfree(ct);
73 }
74
75 static void r_rewind(rset_control *ct)
76 {
77     is_rewind((ISPT) ct->buf);
78 }
79
80 static int r_count(rset_control *ct)
81 {return 0;}
82
83 static int r_read()
84 {return 0;}
85
86 static int r_write()
87 {
88     log(LOG_FATAL, "ISAM set type is read-only");
89     return -1;
90 }