]> granicus.if.org Git - postgresql/blob - src/bin/psql/print.h
I've created a patch which adds support for troff "-ms" output to
[postgresql] / src / bin / psql / print.h
1 /*
2  * psql - the PostgreSQL interactive terminal
3  *
4  * Copyright (c) 2000-2005, PostgreSQL Global Development Group
5  *
6  * $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.23 2005/06/09 15:27:27 momjian Exp $
7  */
8 #ifndef PRINT_H
9 #define PRINT_H
10
11 #include "libpq-fe.h"
12
13
14 extern FILE *PageOutput(int lines, unsigned short int pager);
15
16 extern void html_escaped_print(const char *in, FILE *fout);
17
18 enum printFormat
19 {
20         PRINT_NOTHING = 0,                      /* to make sure someone initializes this */
21         PRINT_UNALIGNED,
22         PRINT_ALIGNED,
23         PRINT_HTML,
24         PRINT_LATEX,
25         PRINT_TROFF_MS
26         /* add your favourite output format here ... */
27 };
28
29
30 typedef struct _printTableOpt
31 {
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
42                                                                  * mode */
43         char       *tableAttr;          /* attributes for HTML <table ...> */
44         int                     encoding;               /* character encoding */
45 } printTableOpt;
46
47
48 /*
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.)
58 */
59 void printTable(const char *title, const char *const * headers,
60                    const char *const * cells, const char *const * footers,
61                    const char *align,
62                    const printTableOpt *opt, FILE *fout);
63
64
65
66 typedef struct _printQueryOpt
67 {
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
73                                                                  * rows)") */
74         bool            default_footer; /* print default footer if footers==NULL */
75 } printQueryOpt;
76
77 /*
78  * Use this to print query results
79  *
80  * It calls the printTable above with all the things set straight.
81  */
82 void            printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout);
83
84 #ifndef __CYGWIN__
85 #define DEFAULT_PAGER "more"
86 #else
87 #define DEFAULT_PAGER "less"
88 #endif
89
90 #endif   /* PRINT_H */