* gdb/fileio.h: New file.
[deliverable/binutils-gdb.git] / gdb / ui-file.h
CommitLineData
d9fcf2fb 1/* UI_FILE - a generic STDIO like output stream.
b6ba6518 2 Copyright 1999, 2000 Free Software Foundation, Inc.
d9fcf2fb
JM
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21#ifndef UI_FILE_H
22#define UI_FILE_H
23
24struct ui_file;
25
26/* Create a generic ui_file object with null methods. */
27
28extern struct ui_file *ui_file_new (void);
29
30/* Override methods used by specific implementations of a UI_FILE
31 object. */
32
33typedef void (ui_file_flush_ftype) (struct ui_file * stream);
34extern void set_ui_file_flush (struct ui_file *stream, ui_file_flush_ftype * flush);
35
36/* NOTE: Both fputs and write methods are available. Default
37 implementations that mapping one onto the other are included. */
38typedef void (ui_file_write_ftype) (struct ui_file * stream, const char *buf, long length_buf);
39extern void set_ui_file_write (struct ui_file *stream, ui_file_write_ftype *fputs);
40
41typedef void (ui_file_fputs_ftype) (const char *, struct ui_file * stream);
42extern void set_ui_file_fputs (struct ui_file *stream, ui_file_fputs_ftype * fputs);
43
44typedef int (ui_file_isatty_ftype) (struct ui_file * stream);
45extern void set_ui_file_isatty (struct ui_file *stream, ui_file_isatty_ftype * isatty);
46
47typedef void (ui_file_rewind_ftype) (struct ui_file * stream);
48extern void set_ui_file_rewind (struct ui_file *stream, ui_file_rewind_ftype * rewind);
49
50typedef void (ui_file_put_method_ftype) (void *object, const char *buffer, long length_buffer);
51typedef void (ui_file_put_ftype) (struct ui_file *stream, ui_file_put_method_ftype * method, void *context);
52extern void set_ui_file_put (struct ui_file *stream, ui_file_put_ftype * put);
53
54typedef void (ui_file_delete_ftype) (struct ui_file * stream);
55extern void set_ui_file_data (struct ui_file *stream, void *data, ui_file_delete_ftype * delete);
56
57extern void *ui_file_data (struct ui_file *file);
58
59
60extern void gdb_flush (struct ui_file *);
61
62extern void ui_file_delete (struct ui_file *stream);
63
64extern void ui_file_rewind (struct ui_file *stream);
65
66extern int ui_file_isatty (struct ui_file *);
67
68extern void ui_file_write (struct ui_file *file, const char *buf, long length_buf);
69
70/* NOTE: copies left to right */
71extern void ui_file_put (struct ui_file *src, ui_file_put_method_ftype *write, void *dest);
72
73/* Returns a freshly allocated buffer containing the entire contents
74 of FILE (as determined by ui_file_put()) with a NUL character
75 appended. LENGTH is set to the size of the buffer minus that
76 appended NUL. */
77extern char *ui_file_xstrdup (struct ui_file *file, long *length);
78
79
80
81/* Create/open a memory based file. Can be used as a scratch buffer
82 for collecting output. */
83extern struct ui_file *mem_fileopen (void);
84
85
86
87/* Open/create a an STDIO based UI_FILE using the already open FILE. */
88extern struct ui_file *stdio_fileopen (FILE *file);
89
90/* Open NAME returning an STDIO based UI_FILE. */
91extern struct ui_file *gdb_fopen (char *name, char *mode);
92
e4c242d9
DJ
93/* Create a file which writes to both ONE and TWO. CLOSE_ONE
94 and CLOSE_TWO indicate whether the original files should be
95 closed when the new file is closed. */
96struct ui_file *tee_file_new (struct ui_file *one,
97 int close_one,
98 struct ui_file *two,
99 int close_two);
d9fcf2fb 100#endif
This page took 0.42519 seconds and 4 git commands to generate.