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.23 2005/06/09 15:27:27 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 *tableAttr; /* attributes for HTML <table ...> */
44 int encoding; /* character encoding */
49 * Use this to print just any table in the supported formats.
50 * - title is just any string (NULL is fine)
51 * - headers is the column headings (NULL ptr terminated). It must be given and
52 * complete since the column count is generated from this.
53 * - cells are the data cells to be printed. Now you know why the correct
54 * column count is important
55 * - footers are lines to be printed below the table
56 * - align is an 'l' or an 'r' for every column, if the output format needs it.
57 * (You must specify this long enough. Otherwise anything could happen.)
59 void printTable(const char *title, const char *const * headers,
60 const char *const * cells, const char *const * footers,
62 const printTableOpt *opt, FILE *fout);
66 typedef struct _printQueryOpt
68 printTableOpt topt; /* the options above */
69 char *nullPrint; /* how to print null entities */
70 bool quote; /* quote all values as much as possible */
71 char *title; /* override title */
72 char **footers; /* override footer (default is "(xx
74 bool default_footer; /* print default footer if footers==NULL */
78 * Use this to print query results
80 * It calls the printTable above with all the things set straight.
82 void printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout);
85 #define DEFAULT_PAGER "more"
87 #define DEFAULT_PAGER "less"