GDB (API)
/home/stan/gdb/src/gdb/ui-file.h
Go to the documentation of this file.
00001 /* UI_FILE - a generic STDIO like output stream.
00002    Copyright (C) 1999-2013 Free Software Foundation, Inc.
00003 
00004    This file is part of GDB.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 3 of the License, or
00009    (at your option) any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00018 
00019 #ifndef UI_FILE_H
00020 #define UI_FILE_H
00021 
00022 struct obstack;
00023 struct ui_file;
00024 
00025 /* Create a generic ui_file object with null methods.  */
00026 
00027 extern struct ui_file *ui_file_new (void);
00028 
00029 /* Override methods used by specific implementations of a UI_FILE
00030    object.  */
00031 
00032 typedef void (ui_file_flush_ftype) (struct ui_file *stream);
00033 extern void set_ui_file_flush (struct ui_file *stream,
00034                                ui_file_flush_ftype *flush);
00035 
00036 /* NOTE: Both fputs and write methods are available.  Default
00037    implementations that mapping one onto the other are included.  */
00038 typedef void (ui_file_write_ftype) (struct ui_file *stream,
00039                                     const char *buf, long length_buf);
00040 extern void set_ui_file_write (struct ui_file *stream,
00041                                ui_file_write_ftype *fputs);
00042 
00043 typedef void (ui_file_fputs_ftype) (const char *, struct ui_file *stream);
00044 extern void set_ui_file_fputs (struct ui_file *stream,
00045                                ui_file_fputs_ftype *fputs);
00046 
00047 /* This version of "write" is safe for use in signal handlers.
00048    It's not guaranteed that all existing output will have been
00049    flushed first.
00050    Implementations are also free to ignore some or all of the request.
00051    fputs_async is not provided as the async versions are rarely used,
00052    no point in having both for a rarely used interface.  */
00053 typedef void (ui_file_write_async_safe_ftype)
00054   (struct ui_file *stream, const char *buf, long length_buf);
00055 extern void set_ui_file_write_async_safe
00056   (struct ui_file *stream, ui_file_write_async_safe_ftype *write_async_safe);
00057 
00058 typedef long (ui_file_read_ftype) (struct ui_file *stream,
00059                                    char *buf, long length_buf);
00060 extern void set_ui_file_read (struct ui_file *stream,
00061                               ui_file_read_ftype *fread);
00062 
00063 typedef int (ui_file_isatty_ftype) (struct ui_file *stream);
00064 extern void set_ui_file_isatty (struct ui_file *stream,
00065                                 ui_file_isatty_ftype *isatty);
00066 
00067 typedef void (ui_file_rewind_ftype) (struct ui_file *stream);
00068 extern void set_ui_file_rewind (struct ui_file *stream,
00069                                 ui_file_rewind_ftype *rewind);
00070 
00071 typedef void (ui_file_put_method_ftype) (void *object, const char *buffer,
00072                                          long length_buffer);
00073 typedef void (ui_file_put_ftype) (struct ui_file *stream,
00074                                   ui_file_put_method_ftype *method,
00075                                   void *context);
00076 extern void set_ui_file_put (struct ui_file *stream, ui_file_put_ftype *put);
00077 
00078 typedef void (ui_file_delete_ftype) (struct ui_file * stream);
00079 extern void set_ui_file_data (struct ui_file *stream, void *data,
00080                               ui_file_delete_ftype *delete);
00081 
00082 typedef int (ui_file_fseek_ftype) (struct ui_file *stream, long offset,
00083                                    int whence);
00084 extern void set_ui_file_fseek (struct ui_file *stream,
00085                                ui_file_fseek_ftype *fseek_ptr);
00086 
00087 extern void *ui_file_data (struct ui_file *file);
00088 
00089 
00090 extern void gdb_flush (struct ui_file *);
00091 
00092 extern void ui_file_delete (struct ui_file *stream);
00093 
00094 extern void ui_file_rewind (struct ui_file *stream);
00095 
00096 extern int ui_file_isatty (struct ui_file *);
00097 
00098 extern void ui_file_write (struct ui_file *file, const char *buf,
00099                            long length_buf);
00100 
00101 extern void ui_file_write_async_safe (struct ui_file *file, const char *buf,
00102                                       long length_buf);
00103 
00104 /* NOTE: copies left to right.  */
00105 extern void ui_file_put (struct ui_file *src,
00106                          ui_file_put_method_ftype *write, void *dest);
00107 
00108 /* Returns a freshly allocated buffer containing the entire contents
00109    of FILE (as determined by ui_file_put()) with a NUL character
00110    appended.  LENGTH, if not NULL, is set to the size of the buffer
00111    minus that appended NUL.  */
00112 extern char *ui_file_xstrdup (struct ui_file *file, long *length);
00113 
00114 /* Similar to ui_file_xstrdup, but return a new string allocated on
00115    OBSTACK.  */
00116 extern char *ui_file_obsavestring (struct ui_file *file,
00117                                    struct obstack *obstack, long *length);
00118 
00119 extern long ui_file_read (struct ui_file *file, char *buf, long length_buf);
00120 
00121 extern int ui_file_fseek (struct ui_file *file, long offset, int whence);
00122 
00123 /* Create/open a memory based file.  Can be used as a scratch buffer
00124    for collecting output.  */
00125 extern struct ui_file *mem_fileopen (void);
00126 
00127 
00128 
00129 /* Open/create a STDIO based UI_FILE using the already open FILE.  */
00130 extern struct ui_file *stdio_fileopen (FILE *file);
00131 
00132 /* Create a ui_file from stderr.  */
00133 extern struct ui_file *stderr_fileopen (void);
00134 
00135 
00136 /* Open NAME returning an STDIO based UI_FILE.  */
00137 extern struct ui_file *gdb_fopen (const char *name, const char *mode);
00138 
00139 /* Create a file which writes to both ONE and TWO.  CLOSE_ONE
00140    and CLOSE_TWO indicate whether the original files should be
00141    closed when the new file is closed.  */
00142 extern struct ui_file *tee_file_new (struct ui_file *one,
00143                                      int close_one,
00144                                      struct ui_file *two,
00145                                      int close_two);
00146 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines