2 * file - file I/O routines callable by users
4 * Copyright (C) 1999 David I. Bell and Landon Curt Noll
6 * Primary author: David I. Bell
8 * Calc is open software; you can redistribute it and/or modify it under
9 * the terms of the version 2.1 of the GNU Lesser General Public License
10 * as published by the Free Software Foundation.
12 * Calc is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
15 * Public License for more details.
17 * A copy of version 2.1 of the GNU Lesser General Public License is
18 * distributed with calc under the filename COPYING-LGPL. You should have
19 * received a copy with calc; if not, write to Free Software Foundation, Inc.
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
26 * Under source code control: 1996/05/24 05:55:58
27 * File existed as early as: 1996
29 * chongo <was here> /\oo/\ http://www.isthe.com/chongo/
30 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
34 #if !defined(__FILE_H__)
38 #if defined(CALC_SRC) /* if we are building from the calc source tree */
39 # include "calc/have_fpos.h"
41 # include <calc/have_fpos.h>
46 * Definition of opened files.
49 FILEID id; /* id to identify this file */
50 FILE *fp; /* real file structure for I/O */
51 dev_t dev; /* file device */
52 ino_t inode; /* file inode */
53 char *name; /* file name */
54 BOOL reading; /* TRUE if opened for reading */
55 BOOL writing; /* TRUE if opened for writing */
56 char action; /* most recent use for 'r', 'w' or 0 */
57 char mode[sizeof("rb+")];/* open mode */
62 * fgetpos/fsetpos vs fseek/ftell interface
64 * f_seek_set(FILE *stream, FILEPOS *loc)
65 * Seek loc bytes from the beginning of the open file, stream.
67 * f_tell(FILE *stream, FILEPOS *loc)
68 * Set loc to bytes from the beinning of the open file, stream.
70 * We assume that if your system does not have fgetpos/fsetpos,
71 * then it will have a FILEPOS that is a scalar type (e.g., long).
72 * Some obscure systems without fgetpos/fsetpos may not have a simple
73 * scalar type. In these cases the f_tell macro below will fail.
75 #if defined(HAVE_FPOS)
77 #define f_seek_set(stream, loc) fsetpos((FILE*)(stream), (FILEPOS*)(loc))
78 #define f_tell(stream, loc) fgetpos((FILE*)(stream), (FILEPOS*)(loc))
82 #define f_seek_set(stream, loc) \
83 fseek((FILE*)(stream), *(FILEPOS*)(loc), SEEK_SET)
84 #define f_tell(stream, loc) (*((FILEPOS*)(loc)) = ftell((FILE*)(stream)))
92 extern FILEIO * findid(FILEID id, int writable);
93 extern int fgetposid(FILEID id, FILEPOS *ptr);
94 extern int fsetposid(FILEID id, FILEPOS *ptr);
95 extern int get_open_siz(FILE *fp, ZVALUE *res);
96 extern char* findfname(FILEID);
99 #endif /* !__FILE_H__ */