Debian Codegraph @

fp.h

raw
1 /**************************************************************************
2 * This program is Copyright (C) 1986-2002 by Jonathan Payne. JOVE is *
3 * provided by Jonathan and Jovehacks without charge and without *
4 * warranty. You may copy, modify, and/or distribute JOVE, provided that *
5 * this notice is included in all the source files and documentation. *
6 **************************************************************************/
7
8 #ifdef NO_JSTDOUT
9 extern void scr_putchar(char c); /* defined in win32.c */
10 # ifdef IBMPCDOS
11 # define flushscreen() { }
12 # else /* !IBMPCDOS */
13 extern void flushscreen(void);
14 # endif /* !IBMPCDOS */
15 #else /* !NO_JSTDOUT */
16 extern File *jstdout;
17 # define scr_putchar(c) f_putc((c), jstdout)
18 extern void flushscreen(void);
19 #endif /* !NO_JSTDOUT */
20
21 #define f_putc(c, fp) { while (--(fp)->f_cnt < 0) flushout(fp); *(fp)->f_ptr++ = (c); }
22 #define f_getc(fp) \
23 ((--(fp)->f_cnt < 0) ? f_filbuf(fp) : ZXRC(*(fp)->f_ptr++))
24 #define f_eof(fp) (((fp)->f_flags & F_EOF) != 0)
25
26 /* typedef struct FileStruct File in jove.h */
27
28 struct FileStruct {
29 int f_cnt, /* number of characters left in buffer */
30 f_bufsize, /* size of what f_base points to */
31 f_fd, /* fildes */
32 f_flags; /* various flags */
33 char *f_ptr, /* current offset */
34 *f_base; /* pointer to base */
35 char *f_name; /* name of open file */
36 };
37
38 #define F_READ 01
39 #define F_WRITE 02
40 #define F_APPEND 04
41 #define F_MODE(x) ((x)&07)
42 #define F_EOF 010
43 #define F_STRING 020
44 #define F_ERR 040
45 #define F_LOCKED 0100 /* don't close this file upon error */
46 #define F_MYBUF 0200 /* f_alloc allocated the buffer, so
47 f_close knows to free it up */
48 #define F_TELLALL 0400 /* whether to display info upon close */
49 #define F_READONLY 01000 /* file is read only */
50 #define F_LINETOOLONG 02000 /* read lines that are too long */
51
52 /* ScrBufSize is the size of the buffer for jstdout. It is also the
53 * number of characters to be output between checks for input, so
54 * it is meaningful even if jstdout isn't used. Its value is set by
55 * settout based on the baud rate of output (on systems with baud rates).
56 */
57 extern int ScrBufSize;
58
59 extern File
60 *f_open(const char *name, int flags, char *buffer, int buf_size),
61 *fd_open(const char *name, int flags, int fd, char *buffer, int bsize);
62
63 extern int
64 f_filbuf(File *fp);
65
66 #ifdef PIPEPROCS
67 extern size_t
68 f_readn(File *fp,char *addr,size_t n);
69 #endif
70
71 extern void
72 f_close(File *fp),
73 f_seek(File *fp, off_t offset),
74 f_toNL(File *fp),
75 flushout(File *fp),
76 fputnchar(char *s,int n,File *fp),
77 gc_openfiles(void),
78 putstr(const char *s);
79
80 extern jbool
81 f_gets(File *fp,char *buf,size_t max);