2 * psql - the PostgreSQL interactive terminal
4 * Copyright (c) 2000-2005, PostgreSQL Global Development Group
6 * $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.26 2005/07/10 03:46:13 momjian Exp $
14 extern FILE *PageOutput(int lines, unsigned short int pager);
16 extern void html_escaped_print(const char *in, FILE *fout);
20 PRINT_NOTHING = 0, /* to make sure someone initializes this */
26 /* add your favourite output format here ... */
30 typedef struct _printTableOpt
32 enum printFormat format; /* one of the above */
33 bool expanded; /* expanded/vertical output (if supported
34 * by output format) */
35 unsigned short int pager; /* use pager for output (if to stdout and
36 * stdout is a tty) 0=off 1=on 2=always */
37 bool tuples_only; /* don't output headers, row counts, etc. */
38 unsigned short int border; /* Print a border around the table.
39 * 0=none, 1=dividing lines, 2=full */
40 char *fieldSep; /* field separator for unaligned text mode */
41 char *recordSep; /* record separator for unaligned text
43 char *numericSep; /* numeric units separator */
44 char *tableAttr; /* attributes for HTML <table ...> */
45 int encoding; /* character encoding */
46 bool normal_query; /* are we presenting the results of a
47 * "normal" query, or a slash
53 * Use this to print just any table in the supported formats.
54 * - title is just any string (NULL is fine)
55 * - headers is the column headings (NULL ptr terminated). It must be given and
56 * complete since the column count is generated from this.
57 * - cells are the data cells to be printed. Now you know why the correct
58 * column count is important
59 * - footers are lines to be printed below the table
60 * - align is an 'l' or an 'r' for every column, if the output format needs it.
61 * (You must specify this long enough. Otherwise anything could happen.)
63 void printTable(const char *title, const char *const * headers,
64 const char *const * cells, const char *const * footers,
66 const printTableOpt *opt, FILE *fout, FILE *flog);
70 typedef struct _printQueryOpt
72 printTableOpt topt; /* the options above */
73 char *nullPrint; /* how to print null entities */
74 bool quote; /* quote all values as much as possible */
75 char *title; /* override title */
76 char **footers; /* override footer (default is "(xx
78 bool default_footer; /* print default footer if footers==NULL */
82 * Use this to print query results
84 * It calls the printTable above with all the things set straight.
86 void printQuery(const PGresult *result, const printQueryOpt *opt,
87 FILE *fout, FILE *flog);
90 #define DEFAULT_PAGER "more"
92 #define DEFAULT_PAGER "less"