switch (status)
{ case PROMPT_READY:
prompt_string = pset.prompt1; break;
case PROMPT_CONTINUE: case PROMPT_SINGLEQUOTE: case PROMPT_DOUBLEQUOTE: case PROMPT_DOLLARQUOTE: case PROMPT_COMMENT: case PROMPT_PAREN:
prompt_string = pset.prompt2; break;
case PROMPT_COPY:
prompt_string = pset.prompt3; break;
}
destination[0] = '\0';
for (p = prompt_string;
*p && strlen(destination) < sizeof(destination) - 1;
p++)
{
memset(buf, 0, sizeof(buf)); if (esc)
{ switch (*p)
{ /* Current database */ case'/': if (pset.db)
strlcpy(buf, PQdb(pset.db), sizeof(buf)); break; case'~': if (pset.db)
{ constchar *var;
/* Whitespace of the same width as the last PROMPT1 */ case'w': if (pset.db)
memset(buf, ' ',
Min(last_prompt1_width, sizeof(buf) - 1)); break;
/* DB server hostname (long/short) */ case'M': case'm': if (pset.db)
{ constchar *host = PQhost(pset.db);
/* INET socket */ if (host && host[0] && !is_unixsock_path(host))
{
strlcpy(buf, host, sizeof(buf)); if (*p == 'm')
buf[strcspn(buf, ".")] = '\0';
} /* UNIX socket */ else
{ if (!host
|| strcmp(host, DEFAULT_PGSOCKET_DIR) == 0
|| *p == 'm')
strlcpy(buf, "[local]", sizeof(buf)); else
snprintf(buf, sizeof(buf), "[local:%s]", host);
}
} break; /* DB server port number */ case'>': if (pset.db && PQport(pset.db))
strlcpy(buf, PQport(pset.db), sizeof(buf)); break; /* DB server user name */ case'n': if (pset.db)
strlcpy(buf, session_username(), sizeof(buf)); break; /* service name */ case's':
{ constchar *service_name = GetVariable(pset.vars, "SERVICE");
if (service_name)
strlcpy(buf, service_name, sizeof(buf));
} break; /* backend pid */ case'p': if (pset.db)
{ int pid = PQbackendPID(pset.db);
if (pid)
snprintf(buf, sizeof(buf), "%d", pid);
} break; /* pipeline status */ case'P': if (pset.db)
{
PGpipelineStatus status = PQpipelineStatus(pset.db);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.