Definition at line 66 of file prompt.c.
68 #define MAX_PROMPT_SIZE 256
73 const char *prompt_string =
"? ";
74 static size_t last_prompt1_width = 0;
96 destination[0] =
'\0';
98 for (p = prompt_string;
99 *p && strlen(destination) <
sizeof(destination) - 1;
102 memset(
buf, 0,
sizeof(
buf));
118 ((var = getenv(
"PGDATABASE")) && strcmp(var,
PQdb(
pset.
db)) == 0))
129 Min(last_prompt1_width,
sizeof(
buf) - 1));
144 buf[strcspn(
buf,
".")] =
'\0';
267 int cmdend = strcspn(p + 1,
"`");
268 char *file =
pnstrdup(p + 1, cmdend);
272 fd = popen(file,
"r");
275 if (fgets(
buf,
sizeof(
buf),
fd) == NULL)
291 int nameend = strcspn(p + 1,
":");
305 #if defined(USE_READLINE) && defined(RL_PROMPT_START_IGNORE)
312 buf[0] = (*p ==
'[') ? RL_PROMPT_START_IGNORE : RL_PROMPT_END_IGNORE;
334 strlcat(destination,
buf,
sizeof(destination));
340 char *p = destination;
341 char *end = p + strlen(p);
344 last_prompt1_width = 0;
347 #if defined(USE_READLINE) && defined(RL_PROMPT_START_IGNORE)
348 if (*p == RL_PROMPT_START_IGNORE)
353 else if (*p == RL_PROMPT_END_IGNORE)
373 last_prompt1_width = 0;
374 else if (chwidth > 0)
375 last_prompt1_width += chwidth;
const char * session_username(void)
#define unconstify(underlying_type, expr)
bool conditional_active(ConditionalStack cstack)
char * PQhost(const PGconn *conn)
char * PQdb(const PGconn *conn)
PGTransactionStatusType PQtransactionStatus(const PGconn *conn)
char * PQuser(const PGconn *conn)
int PQbackendPID(const PGconn *conn)
char * PQport(const PGconn *conn)
int PQmblen(const char *s, int encoding)
int PQdsplen(const char *s, int encoding)
static void const char fflush(stdout)
char * pnstrdup(const char *in, Size len)
#define DEFAULT_PGSOCKET_DIR
static bool is_superuser(Archive *fout)
size_t strlcat(char *dst, const char *src, size_t siz)
size_t strlcpy(char *dst, const char *src, size_t siz)
static bool is_unixsock_path(const char *path)
static int fd(const char *x, int i)
int pg_strip_crlf(char *str)
const char * GetVariable(VariableSpace space, const char *name)
References buf, conditional_active(), _psqlSettings::db, DEFAULT_PGSOCKET_DIR, _psqlSettings::encoding, fd(), fflush(), free, GetVariable(), is_superuser(), is_unixsock_path(), MAX_PROMPT_SIZE, Min, name, pg_strip_crlf(), pnstrdup(), PQbackendPID(), PQdb(), PQdsplen(), PQhost(), PQmblen(), PQport(), PQTRANS_ACTIVE, PQTRANS_IDLE, PQTRANS_INERROR, PQTRANS_INTRANS, PQtransactionStatus(), PQuser(), _psqlSettings::prompt1, _psqlSettings::prompt2, _psqlSettings::prompt3, PROMPT_COMMENT, PROMPT_CONTINUE, PROMPT_COPY, PROMPT_DOLLARQUOTE, PROMPT_DOUBLEQUOTE, PROMPT_PAREN, PROMPT_READY, PROMPT_SINGLEQUOTE, pset, session_username(), _psqlSettings::singleline, snprintf, _psqlSettings::stmt_lineno, strlcat(), strlcpy(), UINT64_FORMAT, unconstify, val, and _psqlSettings::vars.
Referenced by handleCopyIn(), and MainLoop().