1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000,2005 Free Software Foundation, Inc.
3 Written by Ben Pfaff <blp@gnu.org>.
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 #ifndef FILE_HANDLE_DEF_H
21 #define FILE_HANDLE_DEF_H
28 MODE_TEXT, /* New-line delimited lines. */
29 MODE_BINARY /* Fixed-length records. */
32 struct file_handle *create_file_handle_with_defaults (const char *handle_name,
33 const char *filename);
35 struct file_handle *create_file_handle (const char *handle_name,
37 enum file_handle_mode mode,
45 get_handle_with_name (const char *handle_name) ;
48 get_handle_for_filename (const char *filename);
50 const char *handle_get_name (const struct file_handle *handle);
52 /* Returns the name of the file associated with HANDLE. */
53 const char *handle_get_filename (const struct file_handle *handle) ;
57 /* Returns the mode of HANDLE. */
58 enum file_handle_mode handle_get_mode (const struct file_handle *handle) ;
60 /* Returns the width of a logical record on HANDLE. */
61 size_t handle_get_record_width (const struct file_handle *handle);
64 /* Returns the number of characters per tab stop for HANDLE, or
65 zero if tabs are not to be expanded. Applicable only to
67 size_t handle_get_tab_width (const struct file_handle *handle);
71 void destroy_file_handle(void *fh_, void *aux UNUSED);
74 /* Tries to open handle H with the given TYPE and MODE.
76 TYPE is the sort of file, e.g. "system file". Only one given
77 type of access is allowed on a given file handle at once.
79 MODE combines the read or write mode with the sharing mode.
80 The first character is 'r' for read, 'w' for write. The
81 second character is 's' to permit sharing, 'e' to require
84 Returns the address of a void * that the caller can use for
85 data specific to the file handle if successful, or a null
86 pointer on failure. For exclusive access modes the void *
87 will always be a null pointer at return. In shared access
88 modes the void * will necessarily be null only if no other
91 If successful, a reference to type is retained, so it should
92 probably be a string literal. */
94 void ** fh_open (struct file_handle *h, const char *type, const char *mode) ;