Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef PRINT_H
00009 #define PRINT_H
00010
00011 #include "libpq-fe.h"
00012
00013
00014 enum printFormat
00015 {
00016 PRINT_NOTHING = 0,
00017 PRINT_UNALIGNED,
00018 PRINT_ALIGNED,
00019 PRINT_WRAPPED,
00020 PRINT_HTML,
00021 PRINT_LATEX,
00022 PRINT_LATEX_LONGTABLE,
00023 PRINT_TROFF_MS
00024
00025 };
00026
00027 typedef struct printTextLineFormat
00028 {
00029
00030 const char *hrule;
00031 const char *leftvrule;
00032 const char *midvrule;
00033 const char *rightvrule;
00034 } printTextLineFormat;
00035
00036 typedef enum printTextRule
00037 {
00038
00039 PRINT_RULE_TOP,
00040 PRINT_RULE_MIDDLE,
00041 PRINT_RULE_BOTTOM,
00042 PRINT_RULE_DATA
00043 } printTextRule;
00044
00045 typedef enum printTextLineWrap
00046 {
00047
00048 PRINT_LINE_WRAP_NONE,
00049 PRINT_LINE_WRAP_WRAP,
00050 PRINT_LINE_WRAP_NEWLINE
00051 } printTextLineWrap;
00052
00053 typedef struct printTextFormat
00054 {
00055
00056 const char *name;
00057 printTextLineFormat lrule[4];
00058 const char *midvrule_nl;
00059 const char *midvrule_wrap;
00060 const char *midvrule_blank;
00061 const char *header_nl_left;
00062 const char *header_nl_right;
00063 const char *nl_left;
00064 const char *nl_right;
00065 const char *wrap_left;
00066 const char *wrap_right;
00067 bool wrap_right_border;
00068
00069 } printTextFormat;
00070
00071 struct separator
00072 {
00073 char *separator;
00074 bool separator_zero;
00075 };
00076
00077 typedef struct printTableOpt
00078 {
00079 enum printFormat format;
00080 unsigned short int expanded;
00081
00082 unsigned short int border;
00083
00084 unsigned short int pager;
00085
00086 bool tuples_only;
00087 bool start_table;
00088 bool stop_table;
00089 bool default_footer;
00090 unsigned long prior_records;
00091 const printTextFormat *line_style;
00092 struct separator fieldSep;
00093 struct separator recordSep;
00094 bool numericLocale;
00095
00096 char *tableAttr;
00097 int encoding;
00098 int env_columns;
00099 int columns;
00100 } printTableOpt;
00101
00102
00103
00104
00105
00106
00107
00108
00109 typedef struct printTableFooter
00110 {
00111 char *data;
00112 struct printTableFooter *next;
00113 } printTableFooter;
00114
00115
00116
00117
00118
00119 typedef struct printTableContent
00120 {
00121 const printTableOpt *opt;
00122 const char *title;
00123 int ncolumns;
00124 int nrows;
00125 const char **headers;
00126 const char **header;
00127 const char **cells;
00128
00129 const char **cell;
00130 long cellsadded;
00131 bool *cellmustfree;
00132 printTableFooter *footers;
00133 printTableFooter *footer;
00134 char *aligns;
00135
00136 char *align;
00137 } printTableContent;
00138
00139 typedef struct printQueryOpt
00140 {
00141 printTableOpt topt;
00142 char *nullPrint;
00143 bool quote;
00144 char *title;
00145 char **footers;
00146 bool translate_header;
00147 const bool *translate_columns;
00148
00149 } printQueryOpt;
00150
00151
00152 extern const printTextFormat pg_asciiformat;
00153 extern const printTextFormat pg_asciiformat_old;
00154 extern const printTextFormat pg_utf8format;
00155
00156
00157 extern FILE *PageOutput(int lines, unsigned short int pager);
00158 extern void ClosePager(FILE *pagerpipe);
00159
00160 extern void html_escaped_print(const char *in, FILE *fout);
00161
00162 extern void printTableInit(printTableContent *const content,
00163 const printTableOpt *opt, const char *title,
00164 const int ncolumns, const int nrows);
00165 extern void printTableAddHeader(printTableContent *const content,
00166 char *header, const bool translate, const char align);
00167 extern void printTableAddCell(printTableContent *const content,
00168 char *cell, const bool translate, const bool mustfree);
00169 extern void printTableAddFooter(printTableContent *const content,
00170 const char *footer);
00171 extern void printTableSetFooter(printTableContent *const content,
00172 const char *footer);
00173 extern void printTableCleanup(printTableContent *const content);
00174 extern void printTable(const printTableContent *cont, FILE *fout, FILE *flog);
00175 extern void printQuery(const PGresult *result, const printQueryOpt *opt,
00176 FILE *fout, FILE *flog);
00177
00178 extern void setDecimalLocale(void);
00179 extern const printTextFormat *get_line_style(const printTableOpt *opt);
00180
00181 #ifndef __CYGWIN__
00182 #define DEFAULT_PAGER "more"
00183 #else
00184 #define DEFAULT_PAGER "less"
00185 #endif
00186
00187 #endif