]> granicus.if.org Git - postgresql/blob - src/bin/psql/print.h
Add psql \pset numericsep to allow output numbers like 100,000.0 or
[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.26 2005/07/10 03:46:13 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       *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
48                                                                  * command? */
49 } printTableOpt;
50
51
52 /*
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.)
62 */
63 void printTable(const char *title, const char *const * headers,
64                    const char *const * cells, const char *const * footers,
65                    const char *align,
66                    const printTableOpt *opt, FILE *fout, FILE *flog);
67
68
69
70 typedef struct _printQueryOpt
71 {
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
77                                                                  * rows)") */
78         bool            default_footer; /* print default footer if footers==NULL */
79 } printQueryOpt;
80
81 /*
82  * Use this to print query results
83  *
84  * It calls the printTable above with all the things set straight.
85  */
86 void            printQuery(const PGresult *result, const printQueryOpt *opt,
87                                            FILE *fout, FILE *flog);
88
89 #ifndef __CYGWIN__
90 #define DEFAULT_PAGER "more"
91 #else
92 #define DEFAULT_PAGER "less"
93 #endif
94
95 #endif   /* PRINT_H */