2011-11-23 Thomas Klein <th.r.klein@web.de>
[deliverable/binutils-gdb.git] / gdb / ui-file.h
CommitLineData
d9fcf2fb 1/* UI_FILE - a generic STDIO like output stream.
7b6bb8da 2 Copyright (C) 1999, 2000, 2007, 2008, 2009, 2010, 2011
4c38e0a4 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
94af9270 23struct obstack;
d9fcf2fb
JM
24struct ui_file;
25
581e13c1 26/* Create a generic ui_file object with null methods. */
d9fcf2fb
JM
27
28extern struct ui_file *ui_file_new (void);
29
30/* Override methods used by specific implementations of a UI_FILE
581e13c1 31 object. */
d9fcf2fb 32
3e43a32a
MS
33typedef void (ui_file_flush_ftype) (struct ui_file *stream);
34extern void set_ui_file_flush (struct ui_file *stream,
35 ui_file_flush_ftype *flush);
d9fcf2fb 36
581e13c1
MS
37/* NOTE: Both fputs and write methods are available. Default
38 implementations that mapping one onto the other are included. */
3e43a32a
MS
39typedef void (ui_file_write_ftype) (struct ui_file *stream,
40 const char *buf, long length_buf);
41extern void set_ui_file_write (struct ui_file *stream,
42 ui_file_write_ftype *fputs);
43
44typedef void (ui_file_fputs_ftype) (const char *, struct ui_file *stream);
45extern void set_ui_file_fputs (struct ui_file *stream,
46 ui_file_fputs_ftype *fputs);
47
01124a23
DE
48/* This version of "write" is safe for use in signal handlers.
49 It's not guaranteed that all existing output will have been
50 flushed first.
51 Implementations are also free to ignore some or all of the request.
52 fputs_async is not provided as the async versions are rarely used,
53 no point in having both for a rarely used interface. */
54typedef void (ui_file_write_async_safe_ftype)
55 (struct ui_file *stream, const char *buf, long length_buf);
56extern void set_ui_file_write_async_safe
57 (struct ui_file *stream, ui_file_write_async_safe_ftype *write_async_safe);
58
3e43a32a
MS
59typedef long (ui_file_read_ftype) (struct ui_file *stream,
60 char *buf, long length_buf);
61extern void set_ui_file_read (struct ui_file *stream,
62 ui_file_read_ftype *fread);
63
64typedef int (ui_file_isatty_ftype) (struct ui_file *stream);
65extern void set_ui_file_isatty (struct ui_file *stream,
66 ui_file_isatty_ftype *isatty);
67
68typedef void (ui_file_rewind_ftype) (struct ui_file *stream);
69extern void set_ui_file_rewind (struct ui_file *stream,
70 ui_file_rewind_ftype *rewind);
71
72typedef void (ui_file_put_method_ftype) (void *object, const char *buffer,
73 long length_buffer);
74typedef void (ui_file_put_ftype) (struct ui_file *stream,
75 ui_file_put_method_ftype *method,
76 void *context);
77extern void set_ui_file_put (struct ui_file *stream, ui_file_put_ftype *put);
d9fcf2fb
JM
78
79typedef void (ui_file_delete_ftype) (struct ui_file * stream);
3e43a32a
MS
80extern void set_ui_file_data (struct ui_file *stream, void *data,
81 ui_file_delete_ftype *delete);
d9fcf2fb
JM
82
83extern void *ui_file_data (struct ui_file *file);
84
85
86extern void gdb_flush (struct ui_file *);
87
88extern void ui_file_delete (struct ui_file *stream);
89
90extern void ui_file_rewind (struct ui_file *stream);
91
92extern int ui_file_isatty (struct ui_file *);
93
3e43a32a
MS
94extern void ui_file_write (struct ui_file *file, const char *buf,
95 long length_buf);
d9fcf2fb 96
01124a23
DE
97extern void ui_file_write_async_safe (struct ui_file *file, const char *buf,
98 long length_buf);
99
581e13c1 100/* NOTE: copies left to right. */
3e43a32a
MS
101extern void ui_file_put (struct ui_file *src,
102 ui_file_put_method_ftype *write, void *dest);
d9fcf2fb
JM
103
104/* Returns a freshly allocated buffer containing the entire contents
105 of FILE (as determined by ui_file_put()) with a NUL character
759ef836 106 appended. LENGTH, if not NULL, is set to the size of the buffer
581e13c1 107 minus that appended NUL. */
d9fcf2fb
JM
108extern char *ui_file_xstrdup (struct ui_file *file, long *length);
109
94af9270
KS
110/* Similar to ui_file_xstrdup, but return a new string allocated on
111 OBSTACK. */
112extern char *ui_file_obsavestring (struct ui_file *file,
113 struct obstack *obstack, long *length);
d9fcf2fb 114
449092f6
CV
115extern long ui_file_read (struct ui_file *file, char *buf, long length_buf);
116
581e13c1
MS
117/* Create/open a memory based file. Can be used as a scratch buffer
118 for collecting output. */
d9fcf2fb
JM
119extern struct ui_file *mem_fileopen (void);
120
121
122
766062f6 123/* Open/create a STDIO based UI_FILE using the already open FILE. */
d9fcf2fb
JM
124extern struct ui_file *stdio_fileopen (FILE *file);
125
581e13c1 126/* Open NAME returning an STDIO based UI_FILE. */
d9fcf2fb
JM
127extern struct ui_file *gdb_fopen (char *name, char *mode);
128
e4c242d9
DJ
129/* Create a file which writes to both ONE and TWO. CLOSE_ONE
130 and CLOSE_TWO indicate whether the original files should be
131 closed when the new file is closed. */
132struct ui_file *tee_file_new (struct ui_file *one,
133 int close_one,
134 struct ui_file *two,
135 int close_two);
d9fcf2fb 136#endif
This page took 1.105642 seconds and 4 git commands to generate.