Remove "Written by Ben Pfaff <blp@gnu.org>" lines everywhere.
[pspp-builds.git] / src / data / storage-stream.c
index a758c5a1e021e66051778b320203c186b5c21805..469d668b63a3d77ab3efd07364943a8844b5823e 100644 (file)
@@ -1,6 +1,5 @@
 /* PSPP - computes sample statistics.
    Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
-   Written by Ben Pfaff <blp@gnu.org>.
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
 
 #include <data/storage-stream.h>
 
+#include <assert.h>
 #include <stdlib.h>
 
 #include <data/case-sink.h>
 #include <data/case-source.h>
 #include <data/case.h>
 #include <data/casefile.h> 
+#include <data/fastfile.h> 
 
 #include "xalloc.h"
 
@@ -45,7 +46,7 @@ storage_sink_open (struct case_sink *sink)
   struct storage_stream_info *info;
 
   sink->aux = info = xmalloc (sizeof *info);
-  info->casefile = casefile_create (sink->value_cnt);
+  info->casefile = fastfile_create (sink->value_cnt);
 }
 
 /* Destroys storage stream represented by INFO. */
@@ -121,7 +122,7 @@ storage_source_read (struct case_source *source,
   struct casereader *reader;
   bool ok = true;
 
-  for (reader = casefile_get_reader (info->casefile);
+  for (reader = casefile_get_reader (info->casefile, NULL);
        ok && casereader_read (reader, &casefile_case);
        case_destroy (&casefile_case))
     {
@@ -151,6 +152,7 @@ const struct case_source_class storage_source_class =
     storage_source_destroy,
   };
 
+/* Returns the casefile encapsulated by SOURCE. */
 struct casefile *
 storage_source_get_casefile (struct case_source *source) 
 {
@@ -160,13 +162,30 @@ storage_source_get_casefile (struct case_source *source)
   return info->casefile;
 }
 
+/* Destroys SOURCE and returns the casefile that it
+   encapsulated. */
+struct casefile *
+storage_source_decapsulate (struct case_source *source) 
+{
+  struct storage_stream_info *info = source->aux;
+  struct casefile *casefile;
+
+  assert (source->class == &storage_source_class);
+  casefile = info->casefile;
+  info->casefile = NULL;
+  free_case_source (source);
+  return casefile;
+}
+
+/* Creates and returns a new storage stream that encapsulates
+   CASEFILE. */
 struct case_source *
-storage_source_create (struct casefile *cf)
+storage_source_create (struct casefile *casefile)
 {
   struct storage_stream_info *info;
 
   info = xmalloc (sizeof *info);
-  info->casefile = cf;
+  info->casefile = casefile;
 
   return create_case_source (&storage_source_class, info);
 }