1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000, 2005, 2006 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 #ifndef FILE_HANDLE_DEF_H
20 #define FILE_HANDLE_DEF_H
25 /* What a file handle refers to.
26 (Ordinarily only a single value is allowed, but fh_open()
27 and fh_parse() take a mask.) */
30 FH_REF_FILE = 001, /* Ordinary file (the most common case). */
31 FH_REF_INLINE = 002, /* The inline file. */
32 FH_REF_SCRATCH = 004 /* Temporary dataset. */
38 FH_MODE_TEXT, /* New-line delimited lines. */
39 FH_MODE_BINARY /* Fixed-length records. */
42 /* Properties of a file handle. */
45 enum fh_mode mode; /* File mode. */
46 size_t record_width; /* Length of fixed-format records. */
47 size_t tab_width; /* Tab width, 0=do not expand tabs. */
53 /* Creating file handles. */
54 struct file_handle *fh_create_file (const char *handle_name,
55 const char *file_name,
56 const struct fh_properties *);
57 struct file_handle *fh_create_scratch (const char *handle_name);
58 const struct fh_properties *fh_default_properties (void);
60 /* Delete file handle from global list. */
61 void fh_free (struct file_handle *);
63 /* Finding file handles. */
64 struct file_handle *fh_from_id (const char *handle_name);
65 struct file_handle *fh_from_file_name (const char *file_name);
66 struct file_handle *fh_inline_file (void);
68 /* Generic properties of file handles. */
69 const char *fh_get_id (const struct file_handle *);
70 const char *fh_get_name (const struct file_handle *);
71 enum fh_referent fh_get_referent (const struct file_handle *);
73 /* Properties of FH_REF_FILE file handles. */
74 const char *fh_get_file_name (const struct file_handle *);
75 enum fh_mode fh_get_mode (const struct file_handle *) ;
77 /* Properties of FH_REF_FILE and FH_REF_INLINE file handles. */
78 size_t fh_get_record_width (const struct file_handle *);
79 size_t fh_get_tab_width (const struct file_handle *);
81 /* Properties of FH_REF_SCRATCH file handles. */
82 struct scratch_handle *fh_get_scratch_handle (struct file_handle *);
83 void fh_set_scratch_handle (struct file_handle *, struct scratch_handle *);
85 /* Opening and closing file handles. */
86 void **fh_open (struct file_handle *, enum fh_referent mask,
87 const char *type, const char *mode);
88 int fh_close (struct file_handle *, const char *type, const char *mode);
89 bool fh_is_open (const struct file_handle *);
91 /* Default file handle for DATA LIST, REREAD, REPEATING DATA
93 struct file_handle *fh_get_default_handle (void);
94 void fh_set_default_handle (struct file_handle *);