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