More work on temp sets. is_open member removed.
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 4 Sep 1995 15:20:13 +0000 (15:20 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 4 Sep 1995 15:20:13 +0000 (15:20 +0000)
include/rset.h
include/rstemp.h
rset/rset.c
rset/rstemp.c

index 0df127c..69496a3 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: rset.h,v $
- * Revision 1.4  1995-09-04 09:09:52  adam
+ * Revision 1.5  1995-09-04 15:20:13  adam
+ * More work on temp sets. is_open member removed.
+ *
+ * Revision 1.4  1995/09/04  09:09:52  adam
  * String arg in dict lookup is const.
  * Minor changes.
  *
 #ifndef RSET_H
 #define RSET_H
 
+#include <stdlib.h>
+
 typedef struct rset_control
 {
     char *desc; /* text description of set type (for debugging) */
-    char *buf;  /* state data stored by subsystem */
+    void *buf;  /* state data stored by subsystem */
     struct rset_control *(*f_create)(const struct rset_control *sel, void *parms);
     int (*f_open)(struct rset_control *ct, int wflag);
     void (*f_close)(struct rset_control *ct);
@@ -38,7 +43,6 @@ typedef struct rset_control
 
 typedef struct rset
 {
-    int is_open;
     rset_control *control;
 } rset, *RSET;
 
index 141d163..6fffa85 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: rstemp.h,v $
- * Revision 1.1  1994-11-04 13:21:23  quinn
+ * Revision 1.2  1995-09-04 15:20:13  adam
+ * More work on temp sets. is_open member removed.
+ *
+ * Revision 1.1  1994/11/04  13:21:23  quinn
  * Working.
  *
  */
@@ -16,4 +19,9 @@
 
 extern const rset_control *rset_kind_temp;
 
+typedef struct rset_temp_parms
+{
+    int     key_size;
+} rset_temp_parms;
+
 #endif
index 18b26f7..2b5e57f 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: rset.c,v $
- * Revision 1.2  1995-09-04 12:33:56  adam
+ * Revision 1.3  1995-09-04 15:20:39  adam
+ * More work on temp sets. is_open member removed.
+ *
+ * Revision 1.2  1995/09/04  12:33:56  adam
  * Various cleanup. YAZ util used instead.
  *
  * Revision 1.1  1994/11/04  13:21:28  quinn
@@ -12,8 +15,6 @@
  *
  */
 
-/* TODO: mem management */
-
 #include <stdio.h>
 #include <alexutil.h>
 
@@ -31,8 +32,7 @@ RSET rset_create(const rset_control *sel, void *parms)
 
 void rset_delete(RSET rs)
 {
-    if (rs->is_open)
-       rset_close(rs);
+    rset_close(rs);
     (*rs->control->f_delete)(rs->control);
     xfree(rs);
 }
index 282c625..34dd152 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: rstemp.c,v $
- * Revision 1.2  1995-09-04 09:10:56  adam
+ * Revision 1.3  1995-09-04 15:20:40  adam
+ * More work on temp sets. is_open member removed.
+ *
+ * Revision 1.2  1995/09/04  09:10:56  adam
  * Minor changes.
  *
  * Revision 1.1  1994/11/04  13:21:30  quinn
@@ -12,6 +15,9 @@
  *
  */
 
+#include <stdio.h>
+
+#include <alexutil.h>
 #include <rstemp.h>
 
 static struct rset_control *r_create(const struct rset_control *sel, 
@@ -40,11 +46,48 @@ static const rset_control control =
 
 const rset_control *rset_kind_temp = &control;
 
-static struct rset_control *r_create(const struct rset_control *sel, void *parms)
-{}
+struct rset_temp_private {
+    int     fd;
+    char   *fname;
+    size_t  key_size;
+    char   *buf_mem;
+    size_t  buf_size;
+    size_t  pos_end;
+    size_t  pos_cur;
+    size_t  pos_buf;
+};
+
+static struct rset_control *r_create(const struct rset_control *sel,
+                                     void *parms)
+{
+    rset_control *newct;
+    rset_temp_parms *temp_parms = parms;
+    struct rset_temp_private *info;
+    
+    logf (LOG_DEBUG, "ritemp_create(%s)", sel->desc);
+    newct = xmalloc(sizeof(*newct));
+    memcpy(newct, sel, sizeof(*sel));
+    newct->buf = xmalloc (sizeof(struct rset_temp_private));
+    info = newct->buf;
+
+    info->fd = -1;
+    info->fname = NULL;
+    info->key_size = temp_parms->key_size;
+    info->buf_size = 1024;
+    info->buf_mem = xmalloc (info->buf_size);
+    info->pos_cur = 0;
+    info->pos_end = 0;
+    info->pos_buf = 0;
+
+    return newct;
+}
 
 static int r_open(struct rset_control *ct, int wflag)
-{}
+{
+    struct rset_temp_private *info = ct->buf;
+    info->pos_cur = 0;
+    info->pos_buf = 0;
+}
 
 static void r_close(struct rset_control *ct)
 {}