Rewrite expression code.
[pspp-builds.git] / src / file-handle.q
index 9c3a81a366a4bf5de31e657ba27e6a8ee6a8ae3b..00c3fefd76f910d4168130d0d7e38aabebec6682 100644 (file)
@@ -30,6 +30,8 @@
 #include "error.h"
 #include "magic.h"
 #include "var.h"
+#include "linked-list.h"
+
 /* (headers) */
 
 /* File handle. */
@@ -215,6 +217,16 @@ create_file_handle (const char *handle_name, const char *filename)
   return handle;
 }
 
+static void
+destroy_file_handle(void *fh_, void *aux UNUSED)
+{
+  struct file_handle *fh = fh_;
+  free (fh->name);
+  free (fh->filename);
+  fn_free_identity (fh->identity);
+  free (fh);
+}
+
 static const char *
 mode_name (const char *mode) 
 {
@@ -304,6 +316,10 @@ fh_close (struct file_handle *h, const char *type, const char *mode)
   return h->open_cnt;
 }
 
+
+static struct linked_list *handle_list;
+
+
 /* Parses a file handle name, which may be a filename as a string or
    a file handle name as an identifier.  Returns the file handle or
    NULL on failure. */
@@ -330,11 +346,13 @@ fh_parse (void)
       char *handle_name = xmalloc (strlen (filename) + 3);
       sprintf (handle_name, "\"%s\"", filename);
       handle = create_file_handle (handle_name, filename);
+      ll_push_front(handle_list, handle);
       free (handle_name);
     }
 
   lex_get ();
 
+
   return handle;
 }
 
@@ -386,6 +404,23 @@ handle_get_tab_width (const struct file_handle *handle)
   return handle->tab_width;
 }
 
+
+void 
+fh_init(void)
+{
+  handle_list = ll_create(destroy_file_handle,0);
+}
+
+void 
+fh_done(void)
+{
+  assert(handle_list);
+  
+  ll_destroy(handle_list);
+  handle_list = 0;
+}
+
+
 /*
    Local variables:
    mode: c