Null set implemented.
[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.7  1995-09-06 10:35:44  adam
8  * Null set implemented.
9  *
10  * Revision 1.6  1995/09/05  11:43:24  adam
11  * Complete version of temporary sets. Not tested yet though.
12  *
13  * Revision 1.5  1995/09/04  12:33:56  adam
14  * Various cleanup. YAZ util used instead.
15  *
16  * Revision 1.4  1995/09/04  09:10:55  adam
17  * Minor changes.
18  *
19  * Revision 1.3  1994/11/22  13:15:37  quinn
20  * Simple
21  *
22  * Revision 1.2  1994/11/04  14:53:12  quinn
23  * Work
24  *
25  */
26
27 #include <stdio.h>
28 #include <rsisam.h>
29 #include <alexutil.h>
30
31 static rset_control *r_create(const struct rset_control *sel, void *parms);
32 static int r_open (rset_control *ct, int wflag);
33 static void r_close (rset_control *ct);
34 static void r_delete (rset_control *ct);
35 static void r_rewind (rset_control *ct);
36 static int r_count (rset_control *ct);
37 static int r_read (rset_control *ct, void *buf);
38 static int r_write (rset_control *ct, const void *buf);
39
40 static const rset_control control = 
41 {
42     "ISAM set type",
43     0,
44     r_create,
45     r_open,
46     r_close,
47     r_delete,
48     r_rewind,
49     r_count,
50     r_read,
51     r_write
52 };
53
54 const rset_control *rset_kind_isam = &control;
55
56 static rset_control *r_create(const struct rset_control *sel, void *parms)
57 {
58     rset_control *newct;
59     rset_isam_parms *pt = parms;
60
61     logf (LOG_DEBUG, "rsisam_create(%s)", sel->desc);
62     newct = xmalloc(sizeof(*newct));
63     memcpy(newct, sel, sizeof(*sel));
64     if (!(newct->buf = (char*) is_position(pt->is, pt->pos)))
65         return 0;
66     return newct;
67 }
68
69 static int r_open(rset_control *ct, int wflag)
70 {
71     logf (LOG_DEBUG, "risam_open");
72     if (wflag)
73     {
74         logf (LOG_FATAL, "ISAM set type is read-only");
75         return -1;
76     }
77     r_rewind(ct);
78     return 0;
79 }
80
81 static void r_close(rset_control *ct)
82 {
83     /* NOP */
84 }
85
86 static void r_delete(rset_control *ct)
87 {
88     logf (LOG_DEBUG, "rsisam_delete");
89     is_pt_free((ISPT) ct->buf);
90     xfree(ct);
91 }
92
93 static void r_rewind(rset_control *ct)
94 {
95     logf (LOG_DEBUG, "rsisam_rewind");
96     is_rewind((ISPT) ct->buf);
97 }
98
99 static int r_count (rset_control *ct)
100 {
101     return 0;
102 }
103
104 static int r_read (rset_control *ct, void *buf)
105 {
106     return is_readkey((ISPT) ct->buf, buf);
107 }
108
109 static int r_write (rset_control *ct, const void *buf)
110 {
111     logf (LOG_FATAL, "ISAM set type is read-only");
112     return -1;
113 }