70#define MAX_PROMPT_SIZE 256
75 const char *prompt_string =
"? ";
76 static size_t last_prompt1_width = 0;
98 destination[0] =
'\0';
100 for (p = prompt_string;
101 *p && strlen(destination) <
sizeof(destination) - 1;
104 memset(
buf, 0,
sizeof(
buf));
120 ((var = getenv(
"PGDATABASE")) && strcmp(var,
PQdb(
pset.
db)) == 0))
131 Min(last_prompt1_width,
sizeof(
buf) - 1));
146 buf[strcspn(
buf,
".")] =
'\0';
287 int cmdend = strcspn(p + 1,
"`");
288 char *file =
pnstrdup(p + 1, cmdend);
292 fd = popen(file,
"r");
295 if (fgets(
buf,
sizeof(
buf),
fd) == NULL)
311 int nameend = strcspn(p + 1,
":");
325#if defined(USE_READLINE) && defined(RL_PROMPT_START_IGNORE)
332 buf[0] = (*p ==
'[') ? RL_PROMPT_START_IGNORE : RL_PROMPT_END_IGNORE;
354 strlcat(destination,
buf,
sizeof(destination));
360 char *p = destination;
361 char *end = p + strlen(p);
364 last_prompt1_width = 0;
367#if defined(USE_READLINE) && defined(RL_PROMPT_START_IGNORE)
368 if (*p == RL_PROMPT_START_IGNORE)
373 else if (*p == RL_PROMPT_END_IGNORE)
393 last_prompt1_width = 0;
394 else if (chwidth > 0)
395 last_prompt1_width += chwidth;
const char * session_username(void)
#define unconstify(underlying_type, expr)
bool conditional_active(ConditionalStack cstack)
char * PQdb(const PGconn *conn)
char * PQport(const PGconn *conn)
PGTransactionStatusType PQtransactionStatus(const PGconn *conn)
char * PQhost(const PGconn *conn)
char * PQservice(const PGconn *conn)
int PQbackendPID(const PGconn *conn)
char * PQuser(const PGconn *conn)
PGpipelineStatus PQpipelineStatus(const PGconn *conn)
int PQmblen(const char *s, int encoding)
int PQdsplen(const char *s, int encoding)
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)
char * get_prompt(promptStatus_t status, ConditionalStack cstack)
enum _promptStatus promptStatus_t
int pg_strip_crlf(char *str)
const char * GetVariable(VariableSpace space, const char *name)