/[pspp]/pspp/src/file-handle.q
ViewVC logotype

Diff of /pspp/src/file-handle.q

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by blp, Mon Nov 15 09:51:22 2004 UTC revision 1.12 by jmd, Fri Jan 21 11:59:39 2005 UTC
# Line 30  Line 30 
30  #include "error.h"  #include "error.h"
31  #include "magic.h"  #include "magic.h"
32  #include "var.h"  #include "var.h"
33    #include "linked-list.h"
34    
35  /* (headers) */  /* (headers) */
36    
37  /* File handle. */  /* File handle. */
# Line 215  create_file_handle (const char *handle_n Line 217  create_file_handle (const char *handle_n
217    return handle;    return handle;
218  }  }
219    
220    void
221    destroy_file_handle(struct file_handle *fh, void *aux UNUSED)
222    {
223      free (fh->name);
224      free (fh->filename);
225      fn_free_identity (fh->identity);
226      free (fh);
227    }
228    
229  static const char *  static const char *
230  mode_name (const char *mode)  mode_name (const char *mode)
231  {  {
# Line 304  fh_close (struct file_handle *h, const c Line 315  fh_close (struct file_handle *h, const c
315    return h->open_cnt;    return h->open_cnt;
316  }  }
317    
318    
319    static struct linked_list *handle_list;
320    
321    
322  /* Parses a file handle name, which may be a filename as a string or  /* Parses a file handle name, which may be a filename as a string or
323     a file handle name as an identifier.  Returns the file handle or     a file handle name as an identifier.  Returns the file handle or
324     NULL on failure. */     NULL on failure. */
# Line 330  fh_parse (void) Line 345  fh_parse (void)
345        char *handle_name = xmalloc (strlen (filename) + 3);        char *handle_name = xmalloc (strlen (filename) + 3);
346        sprintf (handle_name, "\"%s\"", filename);        sprintf (handle_name, "\"%s\"", filename);
347        handle = create_file_handle (handle_name, filename);        handle = create_file_handle (handle_name, filename);
348          ll_push_front(handle_list, handle);
349        free (handle_name);        free (handle_name);
350      }      }
351    
352    lex_get ();    lex_get ();
353    
354    
355    return handle;    return handle;
356  }  }
357    
# Line 386  handle_get_tab_width (const struct file_ Line 403  handle_get_tab_width (const struct file_
403    return handle->tab_width;    return handle->tab_width;
404  }  }
405    
406    
407    void
408    fh_init(void)
409    {
410      handle_list = ll_create(destroy_file_handle,0);
411    }
412    
413    void
414    fh_done(void)
415    {
416      assert(handle_list);
417      
418      ll_destroy(handle_list);
419      handle_list = 0;
420    }
421    
422    
423  /*  /*
424     Local variables:     Local variables:
425     mode: c     mode: c

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26