32#include <sys/termios.h>
42 const int i,
const int j,
const int fs_len,
53static void fill(
int length,
int max,
char filler,
FILE *fp);
150 if (
po->pager &&
fout == stdout && isatty(fileno(
stdin)) &&
151 isatty(fileno(stdout)))
188 - (
po->header != 0) * 2
206 if (!
po->expanded && (
po->align ||
po->html3))
216 else if (
po->header && !
po->html3)
244 if (
po->expanded &&
po->html3)
247 fprintf(
fout,
"<center><h2>%s</h2></center>\n",
po->caption);
251 "Query retrieved %d rows * %d fields"
261 "<table %s><caption align=\"top\">%d</caption>\n",
262 po->tableOpt ?
po->tableOpt :
"",
i);
273 if (
po->html3 &&
po->expanded)
276 if (!
po->expanded && (
po->align ||
po->html3))
284 "<table %s><caption align=\"top\">%s</caption>\n",
285 po->tableOpt ?
po->tableOpt :
"",
289 "<table %s><caption align=\"top\">"
290 "Retrieved %d rows * %d fields"
304 if (
po->header && !
po->html3)
307 if (
po->html3 && !
po->expanded)
342 const int i,
const int j,
const int fs_len,
358 if (
po->align ||
po->expanded)
379 if (!((
ch >=
'0' &&
ch <=
'9') ||
397 !(
ch >=
'0' &&
ch <=
'9'))
401 if (!
po->expanded && (
po->align ||
po->html3))
418 "<tr><td align=\"left\"><b>%s</b></td>"
419 "<td align=\"%s\">%s</td></tr>\n",
500 char *fs =
po->fieldSep;
512 char *fs =
po->fieldSep;
570 else if (
po->standard)
583 (
po->standard ?
" %-*s " :
"%-*s") :
584 (
po->standard ?
" %*s " :
"%*s"),
593 else if (
po->standard)
608 const char *fieldSep,
613#define DEFAULT_FIELD_SEP " "
621 if (fieldSep ==
NULL)
645 for (
i = 0;
i < nTuples;
i++)
678 for (
i = 0;
i < nTuples;
i++)
738 for (
i = 0;
i < width;
i++)
790 count = max - length;
#define fprintf(file, fmt, msg)
int PQmblenBounded(const char *s, int encoding)
void PQdisplayTuples(const PGresult *res, FILE *fp, int fillAlign, const char *fieldSep, int printHeader, int quiet)
static void fill(int length, int max, char filler, FILE *fp)
#define DEFAULT_FIELD_SEP
void PQprintTuples(const PGresult *res, FILE *fout, int PrintAttNames, int TerseOutput, int colWidth)
void PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
static char * do_header(FILE *fout, const PQprintOpt *po, const int nFields, int *fieldMax, const char **fieldNames, unsigned char *fieldNotNum, const int fs_len, const PGresult *res)
static bool do_field(const PQprintOpt *po, const PGresult *res, const int i, const int j, const int fs_len, char **fields, const int nFields, const char **fieldNames, unsigned char *fieldNotNum, int *fieldMax, const int fieldMaxLen, FILE *fout)
static void output_row(FILE *fout, const PQprintOpt *po, const int nFields, char **fields, unsigned char *fieldNotNum, int *fieldMax, char *border, const int row_index)
static bool pg_add_size_overflow(size_t a, size_t b, size_t *result)
void pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending, bool got_epipe)
int pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending)