More work on temp sets. is_open member removed.
[idzebra-moved-to-github.git] / rset / rstemp.c
1 /*
2  * Copyright (C) 1994, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: rstemp.c,v $
7  * Revision 1.3  1995-09-04 15:20:40  adam
8  * More work on temp sets. is_open member removed.
9  *
10  * Revision 1.2  1995/09/04  09:10:56  adam
11  * Minor changes.
12  *
13  * Revision 1.1  1994/11/04  13:21:30  quinn
14  * Working.
15  *
16  */
17
18 #include <stdio.h>
19
20 #include <alexutil.h>
21 #include <rstemp.h>
22
23 static struct rset_control *r_create(const struct rset_control *sel, 
24                                      void *parms);
25 static int r_open(struct rset_control *ct, int wflag);
26 static void r_close(struct rset_control *ct);
27 static void r_delete(struct rset_control *ct);
28 static void r_rewind(struct rset_control *ct);
29 static int r_count(struct rset_control *ct);
30 static int r_read();
31 static int r_write();
32
33 static const rset_control control = 
34 {
35     "Temporary set",
36     0,
37     r_create,
38     r_open,
39     r_close,
40     r_delete,
41     r_rewind,
42     r_count,
43     r_read,
44     r_write
45 };
46
47 const rset_control *rset_kind_temp = &control;
48
49 struct rset_temp_private {
50     int     fd;
51     char   *fname;
52     size_t  key_size;
53     char   *buf_mem;
54     size_t  buf_size;
55     size_t  pos_end;
56     size_t  pos_cur;
57     size_t  pos_buf;
58 };
59
60 static struct rset_control *r_create(const struct rset_control *sel,
61                                      void *parms)
62 {
63     rset_control *newct;
64     rset_temp_parms *temp_parms = parms;
65     struct rset_temp_private *info;
66     
67     logf (LOG_DEBUG, "ritemp_create(%s)", sel->desc);
68     newct = xmalloc(sizeof(*newct));
69     memcpy(newct, sel, sizeof(*sel));
70     newct->buf = xmalloc (sizeof(struct rset_temp_private));
71     info = newct->buf;
72
73     info->fd = -1;
74     info->fname = NULL;
75     info->key_size = temp_parms->key_size;
76     info->buf_size = 1024;
77     info->buf_mem = xmalloc (info->buf_size);
78     info->pos_cur = 0;
79     info->pos_end = 0;
80     info->pos_buf = 0;
81
82     return newct;
83 }
84
85 static int r_open(struct rset_control *ct, int wflag)
86 {
87     struct rset_temp_private *info = ct->buf;
88     info->pos_cur = 0;
89     info->pos_buf = 0;
90 }
91
92 static void r_close(struct rset_control *ct)
93 {}
94
95 static void r_delete(struct rset_control *ct)
96 {}
97
98 static void r_rewind(struct rset_control *ct)
99 {}
100
101 static int r_count(struct rset_control *ct)
102 {}
103
104 static int r_read()
105 {}
106
107 static int r_write()
108 {}