| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #ifndef PRINT_H |
| #define PRINT_H |
|
|
| #include <signal.h> |
|
|
| #include "libpq-fe.h" |
|
|
|
|
| |
| #ifndef __CYGWIN__ |
| #define DEFAULT_PAGER "more" |
| #else |
| #define DEFAULT_PAGER "less" |
| #endif |
|
|
| enum printFormat |
| { |
| PRINT_NOTHING = 0, |
| PRINT_ALIGNED, |
| PRINT_ASCIIDOC, |
| PRINT_CSV, |
| PRINT_HTML, |
| PRINT_LATEX, |
| PRINT_LATEX_LONGTABLE, |
| PRINT_TROFF_MS, |
| PRINT_UNALIGNED, |
| PRINT_WRAPPED |
| |
| }; |
|
|
| typedef struct printTextLineFormat |
| { |
| |
| const char *hrule; |
| const char *leftvrule; |
| const char *midvrule; |
| const char *rightvrule; |
| } printTextLineFormat; |
|
|
| typedef enum printTextRule |
| { |
| |
| PRINT_RULE_TOP, |
| PRINT_RULE_MIDDLE, |
| PRINT_RULE_BOTTOM, |
| PRINT_RULE_DATA |
| } printTextRule; |
|
|
| typedef enum printTextLineWrap |
| { |
| |
| PRINT_LINE_WRAP_NONE, |
| PRINT_LINE_WRAP_WRAP, |
| PRINT_LINE_WRAP_NEWLINE |
| } printTextLineWrap; |
|
|
| typedef enum printXheaderWidthType |
| { |
| |
| PRINT_XHEADER_FULL, |
| |
| PRINT_XHEADER_COLUMN, |
| |
| PRINT_XHEADER_PAGE, |
| |
| PRINT_XHEADER_EXACT_WIDTH, |
| } printXheaderWidthType; |
|
|
| typedef struct printTextFormat |
| { |
| |
| const char *name; |
| printTextLineFormat lrule[4]; |
| const char *midvrule_nl; |
| const char *midvrule_wrap; |
| const char *midvrule_blank; |
| const char *header_nl_left; |
| const char *header_nl_right; |
| const char *nl_left; |
| const char *nl_right; |
| const char *wrap_left; |
| const char *wrap_right; |
| bool wrap_right_border; |
| |
| } printTextFormat; |
|
|
| typedef enum unicode_linestyle |
| { |
| UNICODE_LINESTYLE_SINGLE = 0, |
| UNICODE_LINESTYLE_DOUBLE |
| } unicode_linestyle; |
|
|
| struct separator |
| { |
| char *separator; |
| bool separator_zero; |
| }; |
|
|
| typedef struct printTableOpt |
| { |
| enum printFormat format; |
| unsigned short int expanded; |
| |
| printXheaderWidthType expanded_header_width_type; |
| |
| int expanded_header_exact_width; |
| |
| unsigned short int border; |
| |
| unsigned short int pager; |
| |
| int pager_min_lines; |
| |
| bool tuples_only; |
| bool start_table; |
| bool stop_table; |
| bool default_footer; |
| unsigned long prior_records; |
| const printTextFormat *line_style; |
| struct separator fieldSep; |
| struct separator recordSep; |
| char csvFieldSep[2]; |
| bool numericLocale; |
| |
| char *tableAttr; |
| int encoding; |
| int env_columns; |
| int columns; |
| unicode_linestyle unicode_border_linestyle; |
| unicode_linestyle unicode_column_linestyle; |
| unicode_linestyle unicode_header_linestyle; |
| } printTableOpt; |
|
|
| |
| |
| |
| |
| |
| |
| |
| typedef struct printTableFooter |
| { |
| char *data; |
| struct printTableFooter *next; |
| } printTableFooter; |
|
|
| |
| |
| |
| |
| typedef struct printTableContent |
| { |
| const printTableOpt *opt; |
| const char *title; |
| int ncolumns; |
| int nrows; |
| const char **headers; |
| const char **header; |
| const char **cells; |
| |
| const char **cell; |
| long cellsadded; |
| bool *cellmustfree; |
| printTableFooter *footers; |
| printTableFooter *footer; |
| char *aligns; |
| |
| char *align; |
| } printTableContent; |
|
|
| typedef struct printQueryOpt |
| { |
| printTableOpt topt; |
| char *nullPrint; |
| char *title; |
| char **footers; |
| bool translate_header; |
| const bool *translate_columns; |
| |
| int n_translate_columns; |
| } printQueryOpt; |
|
|
|
|
| extern PGDLLIMPORT volatile sig_atomic_t cancel_pressed; |
|
|
| extern PGDLLIMPORT const printTextFormat pg_asciiformat; |
| extern PGDLLIMPORT const printTextFormat pg_asciiformat_old; |
| extern PGDLLIMPORT printTextFormat pg_utf8format; |
| |
|
|
|
|
| extern void disable_sigpipe_trap(void); |
| extern void restore_sigpipe_trap(void); |
| extern void set_sigpipe_trap_state(bool ignore); |
|
|
| extern FILE *PageOutput(int lines, const printTableOpt *topt); |
| extern void ClosePager(FILE *pagerpipe); |
|
|
| extern void html_escaped_print(const char *in, FILE *fout); |
|
|
| extern void printTableInit(printTableContent *const content, |
| const printTableOpt *opt, const char *title, |
| const int ncolumns, const int nrows); |
| extern void printTableAddHeader(printTableContent *const content, |
| char *header, const bool translate, const char align); |
| extern void printTableAddCell(printTableContent *const content, |
| char *cell, const bool translate, const bool mustfree); |
| extern void printTableAddFooter(printTableContent *const content, |
| const char *footer); |
| extern void printTableSetFooter(printTableContent *const content, |
| const char *footer); |
| extern void printTableCleanup(printTableContent *const content); |
| extern void printTable(const printTableContent *cont, |
| FILE *fout, bool is_pager, FILE *flog); |
| extern void printQuery(const PGresult *result, const printQueryOpt *opt, |
| FILE *fout, bool is_pager, FILE *flog); |
|
|
| extern char column_type_alignment(Oid); |
|
|
| extern void setDecimalLocale(void); |
| extern const printTextFormat *get_line_style(const printTableOpt *opt); |
| extern void refresh_utf8format(const printTableOpt *opt); |
|
|
| #endif |
|
|