Categorical value cache added
[pspp-builds.git] / src / file-handle-def.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 1997-9, 2000,2005 Free Software Foundation, Inc.
3    Written by Ben Pfaff <blp@gnu.org>.
4
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.
9
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.
14
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
18    02110-1301, USA. */
19
20 #ifndef FILE_HANDLE_DEF_H
21 #define FILE_HANDLE_DEF_H
22
23 #include <config.h>
24
25 /* File modes. */
26 enum file_handle_mode
27   {
28     MODE_TEXT,                  /* New-line delimited lines. */
29     MODE_BINARY                 /* Fixed-length records. */
30   };
31
32 struct file_handle *create_file_handle_with_defaults (const char *handle_name, 
33                                                       const char *filename);
34
35 struct file_handle *create_file_handle (const char *handle_name, 
36                                         const char *filename,
37                                         enum file_handle_mode mode,
38                                         size_t length,
39                                         size_t tab_width
40                                         );
41
42
43
44 struct file_handle *
45 get_handle_with_name (const char *handle_name) ;
46
47 struct file_handle *
48 get_handle_for_filename (const char *filename);
49
50 const char *handle_get_name (const struct file_handle *handle);
51
52 /* Returns the name of the file associated with HANDLE. */
53 const char *handle_get_filename (const struct file_handle *handle) ;
54
55
56
57 /* Returns the mode of HANDLE. */
58 enum file_handle_mode handle_get_mode (const struct file_handle *handle) ;
59
60 /* Returns the width of a logical record on HANDLE. */
61 size_t handle_get_record_width (const struct file_handle *handle);
62
63
64 /* Returns the number of characters per tab stop for HANDLE, or
65    zero if tabs are not to be expanded.  Applicable only to
66    MODE_TEXT files. */
67 size_t handle_get_tab_width (const struct file_handle *handle);
68
69
70
71 void destroy_file_handle(void *fh_, void *aux UNUSED);
72
73
74 /* Tries to open handle H with the given TYPE and MODE.
75
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.
78
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
82    exclusive access.
83
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
89    sharers are active.
90
91    If successful, a reference to type is retained, so it should
92    probably be a string literal. */
93
94 void ** fh_open (struct file_handle *h, const char *type, const char *mode) ;
95
96
97 #endif