198944Sobrien/* Output generating routines for GDB. 298944Sobrien Copyright 1999, 2000, 2001 Free Software Foundation, Inc. 398944Sobrien Contributed by Cygnus Solutions. 498944Sobrien Written by Fernando Nasser for Cygnus. 598944Sobrien 698944Sobrien This file is part of GDB. 798944Sobrien 898944Sobrien This program is free software; you can redistribute it and/or modify 998944Sobrien it under the terms of the GNU General Public License as published by 1098944Sobrien the Free Software Foundation; either version 2 of the License, or 1198944Sobrien (at your option) any later version. 1298944Sobrien 1398944Sobrien This program is distributed in the hope that it will be useful, 1498944Sobrien but WITHOUT ANY WARRANTY; without even the implied warranty of 1598944Sobrien MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1698944Sobrien GNU General Public License for more details. 1798944Sobrien 1898944Sobrien You should have received a copy of the GNU General Public License 1998944Sobrien along with this program; if not, write to the Free Software 2098944Sobrien Foundation, Inc., 59 Temple Place - Suite 330, 2198944Sobrien Boston, MA 02111-1307, USA. */ 2298944Sobrien 2398944Sobrien#ifndef UI_OUT_H 2498944Sobrien#define UI_OUT_H 1 2598944Sobrien 2698944Sobrien/* The ui_out structure */ 2798944Sobrien 2898944Sobrienstruct ui_out; 2998944Sobrienstruct ui_out_data; 30130803Smarcelstruct ui_file; 3198944Sobrien 3298944Sobrien/* the current ui_out */ 3398944Sobrien 3498944Sobrien/* FIXME: This should not be a global but something passed down from main.c 3598944Sobrien or top.c */ 3698944Sobrienextern struct ui_out *uiout; 3798944Sobrien 3898944Sobrien/* alignment enum */ 3998944Sobrienenum ui_align 4098944Sobrien { 4198944Sobrien ui_left = -1, 4298944Sobrien ui_center, 4398944Sobrien ui_right, 4498944Sobrien ui_noalign 4598944Sobrien }; 4698944Sobrien 4798944Sobrien/* flags enum */ 4898944Sobrienenum ui_flags 4998944Sobrien { 5098944Sobrien ui_from_tty = 1, 5198944Sobrien ui_source_list = 2 5298944Sobrien }; 5398944Sobrien 5498944Sobrien 5598944Sobrien/* The ui_out stream structure. */ 5698944Sobrien/* NOTE: cagney/2000-02-01: The ui_stream object can be subsumed by 5798944Sobrien the more generic ui_file object. */ 5898944Sobrien 5998944Sobrienstruct ui_stream 6098944Sobrien { 6198944Sobrien struct ui_out *uiout; 6298944Sobrien struct ui_file *stream; 6398944Sobrien }; 6498944Sobrien 6598944Sobrien 6698944Sobrien/* Prototypes for ui-out API. */ 6798944Sobrien 6898944Sobrien/* A result is a recursive data structure consisting of lists and 6998944Sobrien tuples. */ 7098944Sobrien 7198944Sobrienenum ui_out_type 7298944Sobrien { 7398944Sobrien ui_out_type_tuple, 7498944Sobrien ui_out_type_list 7598944Sobrien }; 7698944Sobrien 7798944Sobrienextern void ui_out_begin (struct ui_out *uiout, 7898944Sobrien enum ui_out_type level_type, 7998944Sobrien const char *id); 8098944Sobrien 8198944Sobrienextern void ui_out_end (struct ui_out *uiout, enum ui_out_type type); 8298944Sobrien 8398944Sobrienextern struct cleanup *ui_out_begin_cleanup_end (struct ui_out *uiout, 8498944Sobrien enum ui_out_type level_type, 8598944Sobrien const char *id); 8698944Sobrien 8798944Sobrien/* A table can be considered a special tuple/list combination with the 8898944Sobrien implied structure: ``table = { hdr = { header, ... } , body = [ { 8998944Sobrien field, ... }, ... ] }''. If NR_ROWS is negative then there is at 9098944Sobrien least one row. */ 9198944Sobrienextern void ui_out_table_header (struct ui_out *uiout, int width, 9298944Sobrien enum ui_align align, const char *col_name, 9398944Sobrien const char *colhdr); 9498944Sobrien 9598944Sobrienextern void ui_out_table_body (struct ui_out *uiout); 9698944Sobrien 97130803Smarcelextern struct cleanup *make_cleanup_ui_out_table_begin_end (struct ui_out *ui_out, 98130803Smarcel int nr_cols, 99130803Smarcel int nr_rows, 100130803Smarcel const char *tblid); 10198944Sobrien/* Compatibility wrappers. */ 10298944Sobrien 10398944Sobrienextern struct cleanup *make_cleanup_ui_out_list_begin_end (struct ui_out *uiout, 10498944Sobrien const char *id); 10598944Sobrien 10698944Sobrienextern struct cleanup *make_cleanup_ui_out_tuple_begin_end (struct ui_out *uiout, 10798944Sobrien const char *id); 10898944Sobrien 10998944Sobrienextern void ui_out_field_int (struct ui_out *uiout, const char *fldname, 11098944Sobrien int value); 11198944Sobrien 112130803Smarcelextern void ui_out_field_fmt_int (struct ui_out *uiout, int width, 113130803Smarcel enum ui_align align, const char *fldname, 114130803Smarcel int value); 115130803Smarcel 11698944Sobrienextern void ui_out_field_core_addr (struct ui_out *uiout, const char *fldname, 11798944Sobrien CORE_ADDR address); 11898944Sobrien 11998944Sobrienextern void ui_out_field_string (struct ui_out * uiout, const char *fldname, 12098944Sobrien const char *string); 12198944Sobrien 12298944Sobrienextern void ui_out_field_stream (struct ui_out *uiout, const char *fldname, 12398944Sobrien struct ui_stream *buf); 12498944Sobrien 12598944Sobrienextern void ui_out_field_fmt (struct ui_out *uiout, const char *fldname, 12698944Sobrien const char *format, ...); 12798944Sobrien 12898944Sobrienextern void ui_out_field_skip (struct ui_out *uiout, const char *fldname); 12998944Sobrien 13098944Sobrienextern void ui_out_spaces (struct ui_out *uiout, int numspaces); 13198944Sobrien 13298944Sobrienextern void ui_out_text (struct ui_out *uiout, const char *string); 13398944Sobrien 13498944Sobrienextern void ui_out_message (struct ui_out *uiout, int verbosity, 13598944Sobrien const char *format, ...); 13698944Sobrien 13798944Sobrienextern struct ui_stream *ui_out_stream_new (struct ui_out *uiout); 13898944Sobrien 13998944Sobrienextern void ui_out_stream_delete (struct ui_stream *buf); 14098944Sobrien 14198944Sobrienstruct cleanup *make_cleanup_ui_out_stream_delete (struct ui_stream *buf); 14298944Sobrien 14398944Sobrienextern void ui_out_wrap_hint (struct ui_out *uiout, char *identstring); 14498944Sobrien 14598944Sobrienextern void ui_out_flush (struct ui_out *uiout); 14698944Sobrien 14798944Sobrienextern void ui_out_get_field_separator (struct ui_out *uiout); 14898944Sobrien 14998944Sobrienextern int ui_out_set_flags (struct ui_out *uiout, int mask); 15098944Sobrien 15198944Sobrienextern int ui_out_clear_flags (struct ui_out *uiout, int mask); 15298944Sobrien 15398944Sobrienextern int ui_out_get_verblvl (struct ui_out *uiout); 15498944Sobrien 15598944Sobrienextern int ui_out_test_flags (struct ui_out *uiout, int mask); 15698944Sobrien 15798944Sobrien#if 0 15898944Sobrienextern void ui_out_result_begin (struct ui_out *uiout, char *class); 15998944Sobrien 16098944Sobrienextern void ui_out_result_end (struct ui_out *uiout); 16198944Sobrien 16298944Sobrienextern void ui_out_info_begin (struct ui_out *uiout, char *class); 16398944Sobrien 16498944Sobrienextern void ui_out_info_end (struct ui_out *uiout); 16598944Sobrien 16698944Sobrienextern void ui_out_notify_begin (struct ui_out *uiout, char *class); 16798944Sobrien 16898944Sobrienextern void ui_out_notify_end (struct ui_out *uiout); 16998944Sobrien 17098944Sobrienextern void ui_out_error_begin (struct ui_out *uiout, char *class); 17198944Sobrien 17298944Sobrienextern void ui_out_error_end (struct ui_out *uiout); 17398944Sobrien#endif 17498944Sobrien 17598944Sobrien#if 0 17698944Sobrienextern void gdb_error (struct ui_out *uiout, int severity, char *format, ...); 17798944Sobrien 17898944Sobrienextern void gdb_query (struct ui_out *uiout, int qflags, char *qprompt); 17998944Sobrien#endif 18098944Sobrien 18198944Sobrien/* HACK: Code in GDB is currently checking to see the type of ui_out 18298944Sobrien builder when determining which output to produce. This function is 18398944Sobrien a hack to encapsulate that test. Once GDB manages to separate the 18498944Sobrien CLI/MI from the core of GDB the problem should just go away .... */ 18598944Sobrien 18698944Sobrienextern int ui_out_is_mi_like_p (struct ui_out *uiout); 18798944Sobrien 18898944Sobrien/* From here on we have things that are only needed by implementation 18998944Sobrien routines and main.c. We should pehaps have a separate file for that, 19098944Sobrien like a ui-out-impl.h file */ 19198944Sobrien 19298944Sobrien/* User Interface Output Implementation Function Table */ 19398944Sobrien 19498944Sobrien/* Type definition of all implementation functions. */ 19598944Sobrien 19698944Sobrientypedef void (table_begin_ftype) (struct ui_out * uiout, 19798944Sobrien int nbrofcols, int nr_rows, 19898944Sobrien const char *tblid); 19998944Sobrientypedef void (table_body_ftype) (struct ui_out * uiout); 20098944Sobrientypedef void (table_end_ftype) (struct ui_out * uiout); 20198944Sobrientypedef void (table_header_ftype) (struct ui_out * uiout, int width, 20298944Sobrien enum ui_align align, const char *col_name, 20398944Sobrien const char *colhdr); 20498944Sobrien/* Note: level 0 is the top-level so LEVEL is always greater than 20598944Sobrien zero. */ 20698944Sobrientypedef void (ui_out_begin_ftype) (struct ui_out *uiout, 20798944Sobrien enum ui_out_type type, 20898944Sobrien int level, const char *id); 20998944Sobrientypedef void (ui_out_end_ftype) (struct ui_out *uiout, 21098944Sobrien enum ui_out_type type, 21198944Sobrien int level); 21298944Sobrientypedef void (field_int_ftype) (struct ui_out * uiout, int fldno, int width, 21398944Sobrien enum ui_align align, 21498944Sobrien const char *fldname, int value); 21598944Sobrientypedef void (field_skip_ftype) (struct ui_out * uiout, int fldno, int width, 21698944Sobrien enum ui_align align, 21798944Sobrien const char *fldname); 21898944Sobrientypedef void (field_string_ftype) (struct ui_out * uiout, int fldno, int width, 21998944Sobrien enum ui_align align, 22098944Sobrien const char *fldname, 22198944Sobrien const char *string); 22298944Sobrientypedef void (field_fmt_ftype) (struct ui_out * uiout, int fldno, int width, 22398944Sobrien enum ui_align align, 22498944Sobrien const char *fldname, 22598944Sobrien const char *format, 22698944Sobrien va_list args); 22798944Sobrientypedef void (spaces_ftype) (struct ui_out * uiout, int numspaces); 22898944Sobrientypedef void (text_ftype) (struct ui_out * uiout, 22998944Sobrien const char *string); 23098944Sobrientypedef void (message_ftype) (struct ui_out * uiout, int verbosity, 23198944Sobrien const char *format, va_list args); 23298944Sobrientypedef void (wrap_hint_ftype) (struct ui_out * uiout, char *identstring); 23398944Sobrientypedef void (flush_ftype) (struct ui_out * uiout); 234130803Smarceltypedef int (redirect_ftype) (struct ui_out * uiout, 235130803Smarcel struct ui_file * outstream); 23698944Sobrien 23798944Sobrien/* ui-out-impl */ 23898944Sobrien 23998944Sobrien/* IMPORTANT: If you change this structure, make sure to change the default 24098944Sobrien initialization in ui-out.c */ 24198944Sobrien 24298944Sobrienstruct ui_out_impl 24398944Sobrien { 24498944Sobrien table_begin_ftype *table_begin; 24598944Sobrien table_body_ftype *table_body; 24698944Sobrien table_end_ftype *table_end; 24798944Sobrien table_header_ftype *table_header; 24898944Sobrien ui_out_begin_ftype *begin; 24998944Sobrien ui_out_end_ftype *end; 25098944Sobrien field_int_ftype *field_int; 25198944Sobrien field_skip_ftype *field_skip; 25298944Sobrien field_string_ftype *field_string; 25398944Sobrien field_fmt_ftype *field_fmt; 25498944Sobrien spaces_ftype *spaces; 25598944Sobrien text_ftype *text; 25698944Sobrien message_ftype *message; 25798944Sobrien wrap_hint_ftype *wrap_hint; 25898944Sobrien flush_ftype *flush; 259130803Smarcel redirect_ftype *redirect; 26098944Sobrien int is_mi_like_p; 26198944Sobrien }; 26298944Sobrien 26398944Sobrienextern struct ui_out_data *ui_out_data (struct ui_out *uiout); 26498944Sobrien 26598944Sobrien 26698944Sobrien/* Create a ui_out object */ 26798944Sobrien 26898944Sobrienextern struct ui_out *ui_out_new (struct ui_out_impl *impl, 26998944Sobrien struct ui_out_data *data, 27098944Sobrien int flags); 27198944Sobrien 272130803Smarcel/* Redirect the ouptut of a ui_out object temporarily. */ 273130803Smarcel 274130803Smarcelextern int ui_out_redirect (struct ui_out *uiout, struct ui_file *outstream); 275130803Smarcel 27698944Sobrien#endif /* UI_OUT_H */ 277