mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-12 10:04:14 +02:00
Add strCatZ().
strCat() did not follow our convention of appending Z to functions that accept zero-terminated strings rather than String objects. Add strCatZ() to accept zero-terminated strings and update strCat() to accept String objects. Use LF_STR where appropriate but don't use other String constants because they do not improve readability.
This commit is contained in:
parent
dab00e2010
commit
45d9b03136
@ -1176,7 +1176,7 @@ backupJobResult(
|
|||||||
|
|
||||||
// Add a comma if this is not the first item
|
// Add a comma if this is not the first item
|
||||||
if (errorIdx != 0)
|
if (errorIdx != 0)
|
||||||
strCat(error, ", ");
|
strCatZ(error, ", ");
|
||||||
|
|
||||||
// If an error range
|
// If an error range
|
||||||
if (varType(errorItem) == varTypeVariantList)
|
if (varType(errorItem) == varTypeVariantList)
|
||||||
|
@ -44,21 +44,21 @@ backupRegExp(BackupRegExpParam param)
|
|||||||
// If full requested then diff/incr is optional
|
// If full requested then diff/incr is optional
|
||||||
if (param.full)
|
if (param.full)
|
||||||
{
|
{
|
||||||
strCat(result, "(\\_");
|
strCatZ(result, "(\\_");
|
||||||
}
|
}
|
||||||
// Else diff/incr is required
|
// Else diff/incr is required
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strCat(result, "\\_");
|
strCatZ(result, "\\_");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append date/time regexp for diff/incr
|
// Append date/time regexp for diff/incr
|
||||||
strCat(result, DATE_TIME_REGEX);
|
strCatZ(result, DATE_TIME_REGEX);
|
||||||
|
|
||||||
// Filter on both diff/incr
|
// Filter on both diff/incr
|
||||||
if (param.differential && param.incremental)
|
if (param.differential && param.incremental)
|
||||||
{
|
{
|
||||||
strCat(result, "(D|I)");
|
strCatZ(result, "(D|I)");
|
||||||
}
|
}
|
||||||
// Else just diff
|
// Else just diff
|
||||||
else if (param.differential)
|
else if (param.differential)
|
||||||
@ -74,13 +74,13 @@ backupRegExp(BackupRegExpParam param)
|
|||||||
// If full requested then diff/incr is optional
|
// If full requested then diff/incr is optional
|
||||||
if (param.full)
|
if (param.full)
|
||||||
{
|
{
|
||||||
strCat(result, "){0,1}");
|
strCatZ(result, "){0,1}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append the end anchor
|
// Append the end anchor
|
||||||
if (!param.noAnchorEnd)
|
if (!param.noAnchorEnd)
|
||||||
strCat(result, "$");
|
strCatZ(result, "$");
|
||||||
|
|
||||||
FUNCTION_LOG_RETURN(STRING, result);
|
FUNCTION_LOG_RETURN(STRING, result);
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ cmdBegin(bool logOption)
|
|||||||
if (strchr(strPtr(commandParam), ' ') != NULL)
|
if (strchr(strPtr(commandParam), ' ') != NULL)
|
||||||
commandParam = strNewFmt("\"%s\"", strPtr(commandParam));
|
commandParam = strNewFmt("\"%s\"", strPtr(commandParam));
|
||||||
|
|
||||||
strCat(info, strPtr(commandParam));
|
strCat(info, commandParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
strCatFmt(info, "]");
|
strCatFmt(info, "]");
|
||||||
@ -203,13 +203,13 @@ cmdEnd(int code, const String *errorMessage)
|
|||||||
|
|
||||||
if (errorMessage == NULL)
|
if (errorMessage == NULL)
|
||||||
{
|
{
|
||||||
strCat(info, "completed successfully");
|
strCatZ(info, "completed successfully");
|
||||||
|
|
||||||
if (cfgOptionValid(cfgOptLogTimestamp) && cfgOptionBool(cfgOptLogTimestamp))
|
if (cfgOptionValid(cfgOptLogTimestamp) && cfgOptionBool(cfgOptLogTimestamp))
|
||||||
strCatFmt(info, " (%" PRIu64 "ms)", timeMSec() - timeBegin);
|
strCatFmt(info, " (%" PRIu64 "ms)", timeMSec() - timeBegin);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
strCat(info, strPtr(errorMessage));
|
strCat(info, errorMessage);
|
||||||
|
|
||||||
LOG(cfgLogLevelDefault(), 0, strPtr(info));
|
LOG(cfgLogLevelDefault(), 0, strPtr(info));
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ helpRenderText(const String *text, size_t indent, bool indentFirst, size_t lengt
|
|||||||
{
|
{
|
||||||
// Add LF if there is already content
|
// Add LF if there is already content
|
||||||
if (strSize(result) != 0)
|
if (strSize(result) != 0)
|
||||||
strCat(result, "\n");
|
strCat(result, LF_STR);
|
||||||
|
|
||||||
// Split the paragraph into lines that don't exceed the line length
|
// Split the paragraph into lines that don't exceed the line length
|
||||||
StringList *partList = strLstNewSplitSizeZ(strLstGet(lineList, lineIdx), " ", length - indent);
|
StringList *partList = strLstNewSplitSizeZ(strLstGet(lineList, lineIdx), " ", length - indent);
|
||||||
@ -56,14 +56,14 @@ helpRenderText(const String *text, size_t indent, bool indentFirst, size_t lengt
|
|||||||
if (partIdx != 0 || indentFirst)
|
if (partIdx != 0 || indentFirst)
|
||||||
{
|
{
|
||||||
if (partIdx != 0)
|
if (partIdx != 0)
|
||||||
strCat(result, "\n");
|
strCat(result, LF_STR);
|
||||||
|
|
||||||
if (strSize(strLstGet(partList, partIdx)))
|
if (strSize(strLstGet(partList, partIdx)))
|
||||||
strCatFmt(result, "%*s", (int)indent, "");
|
strCatFmt(result, "%*s", (int)indent, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the line
|
// Add the line
|
||||||
strCat(result, strPtr(strLstGet(partList, partIdx)));
|
strCat(result, strLstGet(partList, partIdx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ helpRenderValue(const Variant *value)
|
|||||||
for (unsigned int keyIdx = 0; keyIdx < varLstSize(keyList); keyIdx++)
|
for (unsigned int keyIdx = 0; keyIdx < varLstSize(keyList); keyIdx++)
|
||||||
{
|
{
|
||||||
if (keyIdx != 0)
|
if (keyIdx != 0)
|
||||||
strCat(resultTemp, ", ");
|
strCatZ(resultTemp, ", ");
|
||||||
|
|
||||||
strCatFmt(
|
strCatFmt(
|
||||||
resultTemp, "%s=%s", strPtr(varStr(varLstGet(keyList, keyIdx))),
|
resultTemp, "%s=%s", strPtr(varStr(varLstGet(keyList, keyIdx))),
|
||||||
@ -119,7 +119,7 @@ helpRenderValue(const Variant *value)
|
|||||||
for (unsigned int listIdx = 0; listIdx < varLstSize(list); listIdx++)
|
for (unsigned int listIdx = 0; listIdx < varLstSize(list); listIdx++)
|
||||||
{
|
{
|
||||||
if (listIdx != 0)
|
if (listIdx != 0)
|
||||||
strCat(resultTemp, ", ");
|
strCatZ(resultTemp, ", ");
|
||||||
|
|
||||||
strCatFmt(resultTemp, "%s", strPtr(varStr(varLstGet(list, listIdx))));
|
strCatFmt(resultTemp, "%s", strPtr(varStr(varLstGet(list, listIdx))));
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ helpRender(void)
|
|||||||
// Display general help
|
// Display general help
|
||||||
if (cfgCommand() == cfgCmdHelp || cfgCommand() == cfgCmdNone)
|
if (cfgCommand() == cfgCmdHelp || cfgCommand() == cfgCmdNone)
|
||||||
{
|
{
|
||||||
strCat(
|
strCatZ(
|
||||||
result,
|
result,
|
||||||
" - General help\n"
|
" - General help\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -271,7 +271,7 @@ helpRender(void)
|
|||||||
|
|
||||||
if (value != NULL || defaultValue != NULL)
|
if (value != NULL || defaultValue != NULL)
|
||||||
{
|
{
|
||||||
strCat(summary, " [");
|
strCatZ(summary, " [");
|
||||||
|
|
||||||
if (value != NULL)
|
if (value != NULL)
|
||||||
strCatFmt(summary, "current=%s", cfgDefOptionSecure(optionDefId) ? "<redacted>" : strPtr(value));
|
strCatFmt(summary, "current=%s", cfgDefOptionSecure(optionDefId) ? "<redacted>" : strPtr(value));
|
||||||
@ -279,12 +279,12 @@ helpRender(void)
|
|||||||
if (defaultValue != NULL)
|
if (defaultValue != NULL)
|
||||||
{
|
{
|
||||||
if (value != NULL)
|
if (value != NULL)
|
||||||
strCat(summary, ", ");
|
strCatZ(summary, ", ");
|
||||||
|
|
||||||
strCatFmt(summary, "default=%s", strPtr(defaultValue));
|
strCatFmt(summary, "default=%s", strPtr(defaultValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
strCat(summary, "]");
|
strCatZ(summary, "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output option help
|
// Output option help
|
||||||
@ -341,7 +341,7 @@ helpRender(void)
|
|||||||
|
|
||||||
if (value != NULL || defaultValue != NULL)
|
if (value != NULL || defaultValue != NULL)
|
||||||
{
|
{
|
||||||
strCat(result, "\n");
|
strCat(result, LF_STR);
|
||||||
|
|
||||||
if (value != NULL)
|
if (value != NULL)
|
||||||
strCatFmt(result, "current: %s\n", cfgDefOptionSecure(optionDefId) ? "<redacted>" : strPtr(value));
|
strCatFmt(result, "current: %s\n", cfgDefOptionSecure(optionDefId) ? "<redacted>" : strPtr(value));
|
||||||
|
@ -549,7 +549,7 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
|
|||||||
|
|
||||||
// List is ordered so 0 is always the current DB index
|
// List is ordered so 0 is always the current DB index
|
||||||
if (dbIdx == varLstSize(dbSection) - 1)
|
if (dbIdx == varLstSize(dbSection) - 1)
|
||||||
strCat(resultStr, "\n db (current)");
|
strCatZ(resultStr, "\n db (current)");
|
||||||
|
|
||||||
// Get the min/max archive information for the database
|
// Get the min/max archive information for the database
|
||||||
String *archiveResult = strNew("");
|
String *archiveResult = strNew("");
|
||||||
@ -574,7 +574,7 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
|
|||||||
strPtr(varStr(kvGet(archiveInfo, ARCHIVE_KEY_MAX_VAR))));
|
strPtr(varStr(kvGet(archiveInfo, ARCHIVE_KEY_MAX_VAR))));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
strCat(archiveResult, "none present\n");
|
strCatZ(archiveResult, "none present\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -610,7 +610,7 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
|
|||||||
|
|
||||||
strCatFmt(
|
strCatFmt(
|
||||||
backupResult, " timestamp start/stop: %s / %s\n", timeBufferStart, timeBufferStop);
|
backupResult, " timestamp start/stop: %s / %s\n", timeBufferStart, timeBufferStop);
|
||||||
strCat(backupResult, " wal start/stop: ");
|
strCatZ(backupResult, " wal start/stop: ");
|
||||||
|
|
||||||
KeyValue *archiveBackupInfo = varKv(kvGet(backupInfo, KEY_ARCHIVE_VAR));
|
KeyValue *archiveBackupInfo = varKv(kvGet(backupInfo, KEY_ARCHIVE_VAR));
|
||||||
|
|
||||||
@ -621,7 +621,7 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
|
|||||||
strPtr(varStr(kvGet(archiveBackupInfo, KEY_STOP_VAR))));
|
strPtr(varStr(kvGet(archiveBackupInfo, KEY_STOP_VAR))));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
strCat(backupResult, "n/a\n");
|
strCatZ(backupResult, "n/a\n");
|
||||||
|
|
||||||
KeyValue *info = varKv(kvGet(backupInfo, BACKUP_KEY_INFO_VAR));
|
KeyValue *info = varKv(kvGet(backupInfo, BACKUP_KEY_INFO_VAR));
|
||||||
|
|
||||||
@ -646,10 +646,10 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
|
|||||||
if (kvGet(backupInfo, BACKUP_KEY_DATABASE_REF_VAR) != NULL)
|
if (kvGet(backupInfo, BACKUP_KEY_DATABASE_REF_VAR) != NULL)
|
||||||
{
|
{
|
||||||
VariantList *dbSection = kvGetList(backupInfo, BACKUP_KEY_DATABASE_REF_VAR);
|
VariantList *dbSection = kvGetList(backupInfo, BACKUP_KEY_DATABASE_REF_VAR);
|
||||||
strCat(backupResult, " database list:");
|
strCatZ(backupResult, " database list:");
|
||||||
|
|
||||||
if (varLstSize(dbSection) == 0)
|
if (varLstSize(dbSection) == 0)
|
||||||
strCat(backupResult, " none\n");
|
strCatZ(backupResult, " none\n");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (unsigned int dbIdx = 0; dbIdx < varLstSize(dbSection); dbIdx++)
|
for (unsigned int dbIdx = 0; dbIdx < varLstSize(dbSection); dbIdx++)
|
||||||
@ -660,16 +660,17 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
|
|||||||
strPtr(varStrForce(kvGet(db, KEY_OID_VAR))));
|
strPtr(varStrForce(kvGet(db, KEY_OID_VAR))));
|
||||||
|
|
||||||
if (dbIdx != varLstSize(dbSection) - 1)
|
if (dbIdx != varLstSize(dbSection) - 1)
|
||||||
strCat(backupResult, ",");
|
strCatZ(backupResult, ",");
|
||||||
}
|
}
|
||||||
strCat(backupResult, "\n");
|
|
||||||
|
strCat(backupResult, LF_STR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kvGet(backupInfo, BACKUP_KEY_LINK_VAR) != NULL)
|
if (kvGet(backupInfo, BACKUP_KEY_LINK_VAR) != NULL)
|
||||||
{
|
{
|
||||||
VariantList *linkSection = kvGetList(backupInfo, BACKUP_KEY_LINK_VAR);
|
VariantList *linkSection = kvGetList(backupInfo, BACKUP_KEY_LINK_VAR);
|
||||||
strCat(backupResult, " symlinks:\n");
|
strCatZ(backupResult, " symlinks:\n");
|
||||||
|
|
||||||
for (unsigned int linkIdx = 0; linkIdx < varLstSize(linkSection); linkIdx++)
|
for (unsigned int linkIdx = 0; linkIdx < varLstSize(linkSection); linkIdx++)
|
||||||
{
|
{
|
||||||
@ -680,16 +681,16 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
|
|||||||
strPtr(varStr(kvGet(link, KEY_DESTINATION_VAR))));
|
strPtr(varStr(kvGet(link, KEY_DESTINATION_VAR))));
|
||||||
|
|
||||||
if (linkIdx != varLstSize(linkSection) - 1)
|
if (linkIdx != varLstSize(linkSection) - 1)
|
||||||
strCat(backupResult, "\n");
|
strCat(backupResult, LF_STR);
|
||||||
}
|
}
|
||||||
|
|
||||||
strCat(backupResult, "\n");
|
strCat(backupResult, LF_STR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kvGet(backupInfo, BACKUP_KEY_TABLESPACE_VAR) != NULL)
|
if (kvGet(backupInfo, BACKUP_KEY_TABLESPACE_VAR) != NULL)
|
||||||
{
|
{
|
||||||
VariantList *tablespaceSection = kvGetList(backupInfo, BACKUP_KEY_TABLESPACE_VAR);
|
VariantList *tablespaceSection = kvGetList(backupInfo, BACKUP_KEY_TABLESPACE_VAR);
|
||||||
strCat(backupResult, " tablespaces:\n");
|
strCatZ(backupResult, " tablespaces:\n");
|
||||||
|
|
||||||
for (unsigned int tblIdx = 0; tblIdx < varLstSize(tablespaceSection); tblIdx++)
|
for (unsigned int tblIdx = 0; tblIdx < varLstSize(tablespaceSection); tblIdx++)
|
||||||
{
|
{
|
||||||
@ -701,10 +702,10 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
|
|||||||
strPtr(varStr(kvGet(tablespace, KEY_DESTINATION_VAR))));
|
strPtr(varStr(kvGet(tablespace, KEY_DESTINATION_VAR))));
|
||||||
|
|
||||||
if (tblIdx != varLstSize(tablespaceSection) - 1)
|
if (tblIdx != varLstSize(tablespaceSection) - 1)
|
||||||
strCat(backupResult, "\n");
|
strCat(backupResult, LF_STR);
|
||||||
}
|
}
|
||||||
|
|
||||||
strCat(backupResult, "\n");
|
strCat(backupResult, LF_STR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -713,13 +714,13 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
|
|||||||
if (strSize(archiveResult) > 0 || strSize(backupResult) > 0)
|
if (strSize(archiveResult) > 0 || strSize(backupResult) > 0)
|
||||||
{
|
{
|
||||||
if (dbIdx != varLstSize(dbSection) - 1)
|
if (dbIdx != varLstSize(dbSection) - 1)
|
||||||
strCat(resultStr, "\n db (prior)");
|
strCatZ(resultStr, "\n db (prior)");
|
||||||
|
|
||||||
if (strSize(archiveResult) > 0)
|
if (strSize(archiveResult) > 0)
|
||||||
strCat(resultStr, strPtr(archiveResult));
|
strCat(resultStr, archiveResult);
|
||||||
|
|
||||||
if (strSize(backupResult) > 0)
|
if (strSize(backupResult) > 0)
|
||||||
strCat(resultStr, strPtr(backupResult));
|
strCat(resultStr, backupResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FUNCTION_TEST_RETURN_VOID();
|
FUNCTION_TEST_RETURN_VOID();
|
||||||
|
@ -1249,7 +1249,7 @@ restoreSelectiveExpression(Manifest *manifest)
|
|||||||
if (expression == NULL)
|
if (expression == NULL)
|
||||||
expression = strNew("");
|
expression = strNew("");
|
||||||
else
|
else
|
||||||
strCat(expression, "|");
|
strCatZ(expression, "|");
|
||||||
|
|
||||||
// Filter files in base directory
|
// Filter files in base directory
|
||||||
strCatFmt(expression, "(^" MANIFEST_TARGET_PGDATA "/" PG_PATH_BASE "/%s/)", strPtr(db));
|
strCatFmt(expression, "(^" MANIFEST_TARGET_PGDATA "/" PG_PATH_BASE "/%s/)", strPtr(db));
|
||||||
@ -1535,21 +1535,21 @@ restoreRecoveryWriteAutoConf(unsigned int pgVersion, const String *restoreLabel)
|
|||||||
for (unsigned int contentIdx = 0; contentIdx < strLstSize(contentList); contentIdx++)
|
for (unsigned int contentIdx = 0; contentIdx < strLstSize(contentList); contentIdx++)
|
||||||
{
|
{
|
||||||
if (contentIdx != 0)
|
if (contentIdx != 0)
|
||||||
strCat(content, "\n");
|
strCat(content, LF_STR);
|
||||||
|
|
||||||
const String *line = strLstGet(contentList, contentIdx);
|
const String *line = strLstGet(contentList, contentIdx);
|
||||||
|
|
||||||
if (regExpMatch(recoveryExp, line))
|
if (regExpMatch(recoveryExp, line))
|
||||||
strCatFmt(content, "# Removed by " PROJECT_NAME " restore on %s # ", strPtr(restoreLabel));
|
strCatFmt(content, "# Removed by " PROJECT_NAME " restore on %s # ", strPtr(restoreLabel));
|
||||||
|
|
||||||
strCat(content, strPtr(line));
|
strCat(content, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If settings will be appended then format the file so a blank line will be between old and new settings
|
// If settings will be appended then format the file so a blank line will be between old and new settings
|
||||||
if (!strEq(cfgOptionStr(cfgOptType), RECOVERY_TYPE_NONE_STR))
|
if (!strEq(cfgOptionStr(cfgOptType), RECOVERY_TYPE_NONE_STR))
|
||||||
{
|
{
|
||||||
strTrim(content);
|
strTrim(content);
|
||||||
strCat(content, "\n\n");
|
strCatZ(content, "\n\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1837,7 +1837,7 @@ restoreJobResult(const Manifest *manifest, ProtocolParallelJob *job, RegExp *zer
|
|||||||
|
|
||||||
// Note if file was zeroed (i.e. selective restore)
|
// Note if file was zeroed (i.e. selective restore)
|
||||||
if (zeroed)
|
if (zeroed)
|
||||||
strCat(log, " zeroed");
|
strCatZ(log, " zeroed");
|
||||||
|
|
||||||
// Add filename
|
// Add filename
|
||||||
strCatFmt(log, " file %s", strPtr(restoreFilePgPath(manifest, file->name)));
|
strCatFmt(log, " file %s", strPtr(restoreFilePgPath(manifest, file->name)));
|
||||||
@ -1845,7 +1845,7 @@ restoreJobResult(const Manifest *manifest, ProtocolParallelJob *job, RegExp *zer
|
|||||||
// If not copied and not zeroed add details to explain why it was not copied
|
// If not copied and not zeroed add details to explain why it was not copied
|
||||||
if (!copy && !zeroed)
|
if (!copy && !zeroed)
|
||||||
{
|
{
|
||||||
strCat(log, " - ");
|
strCatZ(log, " - ");
|
||||||
|
|
||||||
// On force we match on size and modification time
|
// On force we match on size and modification time
|
||||||
if (cfgOptionBool(cfgOptForce))
|
if (cfgOptionBool(cfgOptForce))
|
||||||
@ -1857,16 +1857,16 @@ restoreJobResult(const Manifest *manifest, ProtocolParallelJob *job, RegExp *zer
|
|||||||
// Else a checksum delta or file is zero-length
|
// Else a checksum delta or file is zero-length
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strCat(log, "exists and ");
|
strCatZ(log, "exists and ");
|
||||||
|
|
||||||
// No need to copy zero-length files
|
// No need to copy zero-length files
|
||||||
if (file->size == 0)
|
if (file->size == 0)
|
||||||
{
|
{
|
||||||
strCat(log, "is zero size");
|
strCatZ(log, "is zero size");
|
||||||
}
|
}
|
||||||
// The file matched the manifest checksum so did not need to be copied
|
// The file matched the manifest checksum so did not need to be copied
|
||||||
else
|
else
|
||||||
strCat(log, "matches backup");
|
strCatZ(log, "matches backup");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ compressExtCat(String *file, CompressType type)
|
|||||||
|
|
||||||
ASSERT(file != NULL);
|
ASSERT(file != NULL);
|
||||||
|
|
||||||
strCat(file, strPtr(compressExtStr(type)));
|
strCat(file, compressExtStr(type));
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN_VOID();
|
FUNCTION_TEST_RETURN_VOID();
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ exitSafe(int result, bool error, SignalType signalType)
|
|||||||
|
|
||||||
// Terminate from a child
|
// Terminate from a child
|
||||||
if (signalType == signalTypeNone)
|
if (signalType == signalTypeNone)
|
||||||
strCat(errorMessage, "from child process");
|
strCatZ(errorMessage, "from child process");
|
||||||
// Else terminated directly
|
// Else terminated directly
|
||||||
else
|
else
|
||||||
strCatFmt(errorMessage, "[SIG%s]", exitSignalName(signalType));
|
strCatFmt(errorMessage, "[SIG%s]", exitSignalName(signalType));
|
||||||
|
@ -104,8 +104,8 @@ httpHeaderAdd(HttpHeader *this, const String *key, const String *value)
|
|||||||
MEM_CONTEXT_TEMP_BEGIN()
|
MEM_CONTEXT_TEMP_BEGIN()
|
||||||
{
|
{
|
||||||
String *valueAppend = strDup(varStr(valueVar));
|
String *valueAppend = strDup(varStr(valueVar));
|
||||||
strCat(valueAppend, ", ");
|
strCatZ(valueAppend, ", ");
|
||||||
strCat(valueAppend, strPtr(value));
|
strCatZ(valueAppend, strPtr(value));
|
||||||
|
|
||||||
kvPut(this->kv, keyVar, VARSTR(valueAppend));
|
kvPut(this->kv, keyVar, VARSTR(valueAppend));
|
||||||
}
|
}
|
||||||
@ -193,7 +193,7 @@ httpHeaderToLog(const HttpHeader *this)
|
|||||||
const String *key = strLstGet(keyList, keyIdx);
|
const String *key = strLstGet(keyList, keyIdx);
|
||||||
|
|
||||||
if (strSize(result) != 1)
|
if (strSize(result) != 1)
|
||||||
strCat(result, ", ");
|
strCatZ(result, ", ");
|
||||||
|
|
||||||
if (httpHeaderRedact(this, key))
|
if (httpHeaderRedact(this, key))
|
||||||
strCatFmt(result, "%s: <redacted>", strPtr(key));
|
strCatFmt(result, "%s: <redacted>", strPtr(key));
|
||||||
@ -201,7 +201,7 @@ httpHeaderToLog(const HttpHeader *this)
|
|||||||
strCatFmt(result, "%s: '%s'", strPtr(key), strPtr(httpHeaderGet(this, key)));
|
strCatFmt(result, "%s: '%s'", strPtr(key), strPtr(httpHeaderGet(this, key)));
|
||||||
}
|
}
|
||||||
|
|
||||||
strCat(result, "}");
|
strCatZ(result, "}");
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ httpQueryRender(const HttpQuery *this)
|
|||||||
for (unsigned int keyIdx = 0; keyIdx < strLstSize(keyList); keyIdx++)
|
for (unsigned int keyIdx = 0; keyIdx < strLstSize(keyList); keyIdx++)
|
||||||
{
|
{
|
||||||
if (strSize(result) != 0)
|
if (strSize(result) != 0)
|
||||||
strCat(result, "&");
|
strCatZ(result, "&");
|
||||||
|
|
||||||
strCatFmt(
|
strCatFmt(
|
||||||
result, "%s=%s", strPtr(strLstGet(keyList, keyIdx)),
|
result, "%s=%s", strPtr(strLstGet(keyList, keyIdx)),
|
||||||
@ -167,14 +167,14 @@ httpQueryToLog(const HttpQuery *this)
|
|||||||
for (unsigned int keyIdx = 0; keyIdx < strLstSize(keyList); keyIdx++)
|
for (unsigned int keyIdx = 0; keyIdx < strLstSize(keyList); keyIdx++)
|
||||||
{
|
{
|
||||||
if (strSize(result) != 1)
|
if (strSize(result) != 1)
|
||||||
strCat(result, ", ");
|
strCatZ(result, ", ");
|
||||||
|
|
||||||
strCatFmt(
|
strCatFmt(
|
||||||
result, "%s: '%s'", strPtr(strLstGet(keyList, keyIdx)),
|
result, "%s: '%s'", strPtr(strLstGet(keyList, keyIdx)),
|
||||||
strPtr(httpQueryGet(this, strLstGet(keyList, keyIdx))));
|
strPtr(httpQueryGet(this, strLstGet(keyList, keyIdx))));
|
||||||
}
|
}
|
||||||
|
|
||||||
strCat(result, "}");
|
strCatZ(result, "}");
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -466,7 +466,7 @@ bufToLog(const Buffer *this)
|
|||||||
if (this->limitSet)
|
if (this->limitSet)
|
||||||
strCatFmt(result, "%zu}", this->limit);
|
strCatFmt(result, "%zu}", this->limit);
|
||||||
else
|
else
|
||||||
strCat(result, "<off>}");
|
strCatZ(result, "<off>}");
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -665,7 +665,7 @@ jsonFromStrInternal(String *json, const String *string)
|
|||||||
// If string is null
|
// If string is null
|
||||||
if (string == NULL)
|
if (string == NULL)
|
||||||
{
|
{
|
||||||
strCat(json, NULL_Z);
|
strCat(json, NULL_STR);
|
||||||
}
|
}
|
||||||
// Else escape and output string
|
// Else escape and output string
|
||||||
else
|
else
|
||||||
@ -701,43 +701,43 @@ jsonFromStrInternal(String *json, const String *string)
|
|||||||
{
|
{
|
||||||
case '"':
|
case '"':
|
||||||
{
|
{
|
||||||
strCat(json, "\\\"");
|
strCatZ(json, "\\\"");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '\\':
|
case '\\':
|
||||||
{
|
{
|
||||||
strCat(json, "\\\\");
|
strCatZ(json, "\\\\");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '\n':
|
case '\n':
|
||||||
{
|
{
|
||||||
strCat(json, "\\n");
|
strCatZ(json, "\\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '\r':
|
case '\r':
|
||||||
{
|
{
|
||||||
strCat(json, "\\r");
|
strCatZ(json, "\\r");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '\t':
|
case '\t':
|
||||||
{
|
{
|
||||||
strCat(json, "\\t");
|
strCatZ(json, "\\t");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '\b':
|
case '\b':
|
||||||
{
|
{
|
||||||
strCat(json, "\\b");
|
strCatZ(json, "\\b");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '\f':
|
case '\f':
|
||||||
{
|
{
|
||||||
strCat(json, "\\f");
|
strCatZ(json, "\\f");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -805,21 +805,21 @@ jsonFromKvInternal(const KeyValue *kv)
|
|||||||
|
|
||||||
// If going to add another key, prepend a comma
|
// If going to add another key, prepend a comma
|
||||||
if (keyIdx > 0)
|
if (keyIdx > 0)
|
||||||
strCat(result, ",");
|
strCatZ(result, ",");
|
||||||
|
|
||||||
// Keys are always strings in the output, so add starting quote and colon.
|
// Keys are always strings in the output, so add starting quote and colon.
|
||||||
strCatFmt(result, "\"%s\":", strPtr(key));
|
strCatFmt(result, "\"%s\":", strPtr(key));
|
||||||
|
|
||||||
// NULL value
|
// NULL value
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
strCat(result, NULL_Z);
|
strCat(result, NULL_STR);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (varType(value))
|
switch (varType(value))
|
||||||
{
|
{
|
||||||
case varTypeKeyValue:
|
case varTypeKeyValue:
|
||||||
{
|
{
|
||||||
strCat(result, strPtr(jsonFromKvInternal(kvDup(varKv(value)))));
|
strCat(result, jsonFromKvInternal(kvDup(varKv(value))));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,12 +827,12 @@ jsonFromKvInternal(const KeyValue *kv)
|
|||||||
{
|
{
|
||||||
// If the array is empty, then do not add formatting, else process the array.
|
// If the array is empty, then do not add formatting, else process the array.
|
||||||
if (varVarLst(value) == NULL)
|
if (varVarLst(value) == NULL)
|
||||||
strCat(result, NULL_Z);
|
strCat(result, NULL_STR);
|
||||||
else if (varLstSize(varVarLst(value)) == 0)
|
else if (varLstSize(varVarLst(value)) == 0)
|
||||||
strCat(result, "[]");
|
strCatZ(result, "[]");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strCat(result, "[");
|
strCatZ(result, "[");
|
||||||
|
|
||||||
for (unsigned int arrayIdx = 0; arrayIdx < varLstSize(varVarLst(value)); arrayIdx++)
|
for (unsigned int arrayIdx = 0; arrayIdx < varLstSize(varVarLst(value)); arrayIdx++)
|
||||||
{
|
{
|
||||||
@ -840,12 +840,12 @@ jsonFromKvInternal(const KeyValue *kv)
|
|||||||
|
|
||||||
// If going to add another element, add a comma
|
// If going to add another element, add a comma
|
||||||
if (arrayIdx > 0)
|
if (arrayIdx > 0)
|
||||||
strCat(result, ",");
|
strCatZ(result, ",");
|
||||||
|
|
||||||
// If array value is null
|
// If array value is null
|
||||||
if (arrayValue == NULL)
|
if (arrayValue == NULL)
|
||||||
{
|
{
|
||||||
strCat(result, NULL_Z);
|
strCat(result, NULL_STR);
|
||||||
}
|
}
|
||||||
// If the type is a string, add leading and trailing double quotes
|
// If the type is a string, add leading and trailing double quotes
|
||||||
else if (varType(arrayValue) == varTypeString)
|
else if (varType(arrayValue) == varTypeString)
|
||||||
@ -854,18 +854,18 @@ jsonFromKvInternal(const KeyValue *kv)
|
|||||||
}
|
}
|
||||||
else if (varType(arrayValue) == varTypeKeyValue)
|
else if (varType(arrayValue) == varTypeKeyValue)
|
||||||
{
|
{
|
||||||
strCat(result, strPtr(jsonFromKvInternal(kvDup(varKv(arrayValue)))));
|
strCat(result, jsonFromKvInternal(kvDup(varKv(arrayValue))));
|
||||||
}
|
}
|
||||||
else if (varType(arrayValue) == varTypeVariantList)
|
else if (varType(arrayValue) == varTypeVariantList)
|
||||||
{
|
{
|
||||||
strCat(result, strPtr(jsonFromVar(arrayValue)));
|
strCat(result, jsonFromVar(arrayValue));
|
||||||
}
|
}
|
||||||
// Numeric, Boolean or other type
|
// Numeric, Boolean or other type
|
||||||
else
|
else
|
||||||
strCat(result, strPtr(varStrForce(arrayValue)));
|
strCat(result, varStrForce(arrayValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
strCat(result, "]");
|
strCatZ(result, "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -880,14 +880,14 @@ jsonFromKvInternal(const KeyValue *kv)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
strCat(result, strPtr(varStrForce(value)));
|
strCat(result, varStrForce(value));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = strCat(result, "}");
|
result = strCatZ(result, "}");
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -946,19 +946,19 @@ jsonFromVar(const Variant *var)
|
|||||||
// If VariantList then process each item in the array. Currently the list must be KeyValue types.
|
// If VariantList then process each item in the array. Currently the list must be KeyValue types.
|
||||||
if (var == NULL)
|
if (var == NULL)
|
||||||
{
|
{
|
||||||
strCat(jsonStr, strPtr(NULL_STR));
|
strCat(jsonStr, NULL_STR);
|
||||||
}
|
}
|
||||||
else if (varType(var) == varTypeBool)
|
else if (varType(var) == varTypeBool)
|
||||||
{
|
{
|
||||||
strCat(jsonStr, strPtr(jsonFromBool(varBool(var))));
|
strCat(jsonStr, jsonFromBool(varBool(var)));
|
||||||
}
|
}
|
||||||
else if (varType(var) == varTypeUInt)
|
else if (varType(var) == varTypeUInt)
|
||||||
{
|
{
|
||||||
strCat(jsonStr, strPtr(jsonFromUInt(varUInt(var))));
|
strCat(jsonStr, jsonFromUInt(varUInt(var)));
|
||||||
}
|
}
|
||||||
else if (varType(var) == varTypeUInt64)
|
else if (varType(var) == varTypeUInt64)
|
||||||
{
|
{
|
||||||
strCat(jsonStr, strPtr(jsonFromUInt64(varUInt64(var))));
|
strCat(jsonStr, jsonFromUInt64(varUInt64(var)));
|
||||||
}
|
}
|
||||||
else if (varType(var) == varTypeString)
|
else if (varType(var) == varTypeString)
|
||||||
{
|
{
|
||||||
@ -971,63 +971,63 @@ jsonFromVar(const Variant *var)
|
|||||||
// If not an empty array
|
// If not an empty array
|
||||||
if (varLstSize(vl) > 0)
|
if (varLstSize(vl) > 0)
|
||||||
{
|
{
|
||||||
strCat(jsonStr, "[");
|
strCatZ(jsonStr, "[");
|
||||||
|
|
||||||
// Currently only KeyValue and String lists are supported
|
// Currently only KeyValue and String lists are supported
|
||||||
for (unsigned int vlIdx = 0; vlIdx < varLstSize(vl); vlIdx++)
|
for (unsigned int vlIdx = 0; vlIdx < varLstSize(vl); vlIdx++)
|
||||||
{
|
{
|
||||||
// If going to add another key, append a comma
|
// If going to add another key, append a comma
|
||||||
if (vlIdx > 0)
|
if (vlIdx > 0)
|
||||||
strCat(jsonStr, ",");
|
strCatZ(jsonStr, ",");
|
||||||
|
|
||||||
Variant *varSub = varLstGet(vl, vlIdx);
|
Variant *varSub = varLstGet(vl, vlIdx);
|
||||||
|
|
||||||
if (varSub == NULL)
|
if (varSub == NULL)
|
||||||
{
|
{
|
||||||
strCat(jsonStr, NULL_Z);
|
strCat(jsonStr, NULL_STR);
|
||||||
}
|
}
|
||||||
else if (varType(varSub) == varTypeBool)
|
else if (varType(varSub) == varTypeBool)
|
||||||
{
|
{
|
||||||
strCat(jsonStr, strPtr(jsonFromBool(varBool(varSub))));
|
strCat(jsonStr, jsonFromBool(varBool(varSub)));
|
||||||
}
|
}
|
||||||
else if (varType(varSub) == varTypeKeyValue)
|
else if (varType(varSub) == varTypeKeyValue)
|
||||||
{
|
{
|
||||||
strCat(jsonStr, strPtr(jsonFromKvInternal(varKv(varSub))));
|
strCat(jsonStr, jsonFromKvInternal(varKv(varSub)));
|
||||||
}
|
}
|
||||||
else if (varType(varSub) == varTypeVariantList)
|
else if (varType(varSub) == varTypeVariantList)
|
||||||
{
|
{
|
||||||
strCat(jsonStr, strPtr(jsonFromVar(varSub)));
|
strCat(jsonStr, jsonFromVar(varSub));
|
||||||
}
|
}
|
||||||
else if (varType(varSub) == varTypeInt)
|
else if (varType(varSub) == varTypeInt)
|
||||||
{
|
{
|
||||||
strCat(jsonStr, strPtr(jsonFromInt(varInt(varSub))));
|
strCat(jsonStr, jsonFromInt(varInt(varSub)));
|
||||||
}
|
}
|
||||||
else if (varType(varSub) == varTypeInt64)
|
else if (varType(varSub) == varTypeInt64)
|
||||||
{
|
{
|
||||||
strCat(jsonStr, strPtr(jsonFromInt64(varInt64(varSub))));
|
strCat(jsonStr, jsonFromInt64(varInt64(varSub)));
|
||||||
}
|
}
|
||||||
else if (varType(varSub) == varTypeUInt)
|
else if (varType(varSub) == varTypeUInt)
|
||||||
{
|
{
|
||||||
strCat(jsonStr, strPtr(jsonFromUInt(varUInt(varSub))));
|
strCat(jsonStr, jsonFromUInt(varUInt(varSub)));
|
||||||
}
|
}
|
||||||
else if (varType(varSub) == varTypeUInt64)
|
else if (varType(varSub) == varTypeUInt64)
|
||||||
{
|
{
|
||||||
strCat(jsonStr, strPtr(jsonFromUInt64(varUInt64(varSub))));
|
strCat(jsonStr, jsonFromUInt64(varUInt64(varSub)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
jsonFromStrInternal(jsonStr, varStr(varSub));
|
jsonFromStrInternal(jsonStr, varStr(varSub));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the array
|
// Close the array
|
||||||
strCat(jsonStr, "]");
|
strCatZ(jsonStr, "]");
|
||||||
}
|
}
|
||||||
// Else empty array
|
// Else empty array
|
||||||
else
|
else
|
||||||
strCat(jsonStr, "[]");
|
strCatZ(jsonStr, "[]");
|
||||||
}
|
}
|
||||||
else if (varType(var) == varTypeKeyValue)
|
else if (varType(var) == varTypeKeyValue)
|
||||||
{
|
{
|
||||||
strCat(jsonStr, strPtr(jsonFromKvInternal(varKv(var))));
|
strCat(jsonStr, jsonFromKvInternal(varKv(var)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
THROW(JsonFormatError, "variant type is invalid");
|
THROW(JsonFormatError, "variant type is invalid");
|
||||||
|
@ -280,7 +280,21 @@ strResize(String *this, size_t requested)
|
|||||||
|
|
||||||
/**********************************************************************************************************************************/
|
/**********************************************************************************************************************************/
|
||||||
String *
|
String *
|
||||||
strCat(String *this, const char *cat)
|
strCat(String *this, const String *cat)
|
||||||
|
{
|
||||||
|
FUNCTION_TEST_BEGIN();
|
||||||
|
FUNCTION_TEST_PARAM(STRING, this);
|
||||||
|
FUNCTION_TEST_PARAM(STRING, cat);
|
||||||
|
FUNCTION_TEST_END();
|
||||||
|
|
||||||
|
ASSERT(this != NULL);
|
||||||
|
ASSERT(cat != NULL);
|
||||||
|
|
||||||
|
FUNCTION_TEST_RETURN(strCatZN(this, strPtr(cat), strSize(cat)));
|
||||||
|
}
|
||||||
|
|
||||||
|
String *
|
||||||
|
strCatZ(String *this, const char *cat)
|
||||||
{
|
{
|
||||||
FUNCTION_TEST_BEGIN();
|
FUNCTION_TEST_BEGIN();
|
||||||
FUNCTION_TEST_PARAM(STRING, this);
|
FUNCTION_TEST_PARAM(STRING, this);
|
||||||
|
@ -84,8 +84,9 @@ String *strBase(const String *this);
|
|||||||
bool strBeginsWith(const String *this, const String *beginsWith);
|
bool strBeginsWith(const String *this, const String *beginsWith);
|
||||||
bool strBeginsWithZ(const String *this, const char *beginsWith);
|
bool strBeginsWithZ(const String *this, const char *beginsWith);
|
||||||
|
|
||||||
// Append a string
|
// Append a string or zero-terminated string
|
||||||
String *strCat(String *this, const char *cat);
|
String *strCat(String *this, const String *cat);
|
||||||
|
String *strCatZ(String *this, const char *cat);
|
||||||
|
|
||||||
// Append a character
|
// Append a character
|
||||||
String *strCatChr(String *this, char cat);
|
String *strCatChr(String *this, char cat);
|
||||||
|
@ -440,10 +440,10 @@ strLstJoinQuote(const StringList *this, const char *separator, const char *quote
|
|||||||
for (unsigned int listIdx = 0; listIdx < strLstSize(this); listIdx++)
|
for (unsigned int listIdx = 0; listIdx < strLstSize(this); listIdx++)
|
||||||
{
|
{
|
||||||
if (listIdx != 0)
|
if (listIdx != 0)
|
||||||
strCat(join, separator);
|
strCatZ(join, separator);
|
||||||
|
|
||||||
if (strLstGet(this, listIdx) == NULL)
|
if (strLstGet(this, listIdx) == NULL)
|
||||||
strCat(join, "[NULL]");
|
strCatZ(join, "[NULL]");
|
||||||
else
|
else
|
||||||
strCatFmt(join, "%s%s%s", quote, strPtr(strLstGet(this, listIdx)), quote);
|
strCatFmt(join, "%s%s%s", quote, strPtr(strLstGet(this, listIdx)), quote);
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ cfgLoadLogFile(void)
|
|||||||
strCatFmt(logFile, "-%03u", cfgOptionUInt(cfgOptProcess));
|
strCatFmt(logFile, "-%03u", cfgOptionUInt(cfgOptProcess));
|
||||||
|
|
||||||
// Add extension
|
// Add extension
|
||||||
strCat(logFile, ".log");
|
strCatZ(logFile, ".log");
|
||||||
|
|
||||||
// Attempt to open log file
|
// Attempt to open log file
|
||||||
if (!logFileSet(strPtr(logFile)))
|
if (!logFileSet(strPtr(logFile)))
|
||||||
|
@ -273,8 +273,8 @@ cfgFileLoadPart(String **config, const Buffer *configPart)
|
|||||||
else
|
else
|
||||||
|
|
||||||
// Add the config part to the result config file
|
// Add the config part to the result config file
|
||||||
strCat(*config, "\n");
|
strCat(*config, LF_STR);
|
||||||
strCat(*config, strPtr(configPartStr));
|
strCat(*config, configPartStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ dbBackupStopQuery(unsigned int pgVersion)
|
|||||||
// For PostgreSQL >= 9.6 the backup label and tablespace map are returned from pg_stop_backup
|
// For PostgreSQL >= 9.6 the backup label and tablespace map are returned from pg_stop_backup
|
||||||
if (pgVersion >= PG_VERSION_96)
|
if (pgVersion >= PG_VERSION_96)
|
||||||
{
|
{
|
||||||
strCat(
|
strCatZ(
|
||||||
result,
|
result,
|
||||||
",\n"
|
",\n"
|
||||||
" labelfile::text as backuplabel_file,\n"
|
" labelfile::text as backuplabel_file,\n"
|
||||||
@ -368,7 +368,7 @@ dbBackupStopQuery(unsigned int pgVersion)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build stop backup function
|
// Build stop backup function
|
||||||
strCat(
|
strCatZ(
|
||||||
result,
|
result,
|
||||||
"\n"
|
"\n"
|
||||||
" from pg_catalog.pg_stop_backup(");
|
" from pg_catalog.pg_stop_backup(");
|
||||||
|
@ -2866,9 +2866,9 @@ manifestTargetPath(const Manifest *this, const ManifestTarget *target)
|
|||||||
String *pgPath = strPath(manifestPathPg(target->name));
|
String *pgPath = strPath(manifestPathPg(target->name));
|
||||||
|
|
||||||
if (strSize(pgPath) != 0)
|
if (strSize(pgPath) != 0)
|
||||||
strCat(pgPath, "/");
|
strCatZ(pgPath, "/");
|
||||||
|
|
||||||
strCat(pgPath, strPtr(target->path));
|
strCat(pgPath, target->path);
|
||||||
|
|
||||||
MEM_CONTEXT_PRIOR_BEGIN()
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
{
|
{
|
||||||
|
@ -168,8 +168,8 @@ protocolClientProcessError(ProtocolClient *this, KeyValue *errorKv)
|
|||||||
{
|
{
|
||||||
const String *stack = varStr(kvGet(errorKv, VARSTR(PROTOCOL_ERROR_STACK_STR)));
|
const String *stack = varStr(kvGet(errorKv, VARSTR(PROTOCOL_ERROR_STACK_STR)));
|
||||||
|
|
||||||
strCat(throwMessage, "\n");
|
strCat(throwMessage, LF_STR);
|
||||||
strCat(throwMessage, stack == NULL ? "no stack trace available" : strPtr(stack));
|
strCat(throwMessage, stack == NULL ? STRDEF("no stack trace available") : stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
THROWP(type, strPtr(throwMessage));
|
THROWP(type, strPtr(throwMessage));
|
||||||
|
@ -333,7 +333,7 @@ storageS3Request(
|
|||||||
strPtr(httpClientResponseMessage(httpClient)));
|
strPtr(httpClientResponseMessage(httpClient)));
|
||||||
|
|
||||||
// Output uri/query
|
// Output uri/query
|
||||||
strCat(error, "\n*** URI/Query ***:");
|
strCatZ(error, "\n*** URI/Query ***:");
|
||||||
|
|
||||||
strCatFmt(error, "\n%s", strPtr(httpUriEncode(uri, true)));
|
strCatFmt(error, "\n%s", strPtr(httpUriEncode(uri, true)));
|
||||||
|
|
||||||
@ -343,7 +343,7 @@ storageS3Request(
|
|||||||
// Output request headers
|
// Output request headers
|
||||||
const StringList *requestHeaderList = httpHeaderList(requestHeader);
|
const StringList *requestHeaderList = httpHeaderList(requestHeader);
|
||||||
|
|
||||||
strCat(error, "\n*** Request Headers ***:");
|
strCatZ(error, "\n*** Request Headers ***:");
|
||||||
|
|
||||||
for (unsigned int requestHeaderIdx = 0; requestHeaderIdx < strLstSize(requestHeaderList); requestHeaderIdx++)
|
for (unsigned int requestHeaderIdx = 0; requestHeaderIdx < strLstSize(requestHeaderList); requestHeaderIdx++)
|
||||||
{
|
{
|
||||||
@ -361,7 +361,7 @@ storageS3Request(
|
|||||||
|
|
||||||
if (strLstSize(responseHeaderList) > 0)
|
if (strLstSize(responseHeaderList) > 0)
|
||||||
{
|
{
|
||||||
strCat(error, "\n*** Response Headers ***:");
|
strCatZ(error, "\n*** Response Headers ***:");
|
||||||
|
|
||||||
for (unsigned int responseHeaderIdx = 0; responseHeaderIdx < strLstSize(responseHeaderList);
|
for (unsigned int responseHeaderIdx = 0; responseHeaderIdx < strLstSize(responseHeaderList);
|
||||||
responseHeaderIdx++)
|
responseHeaderIdx++)
|
||||||
|
@ -321,7 +321,7 @@ hrnLogReplace(void)
|
|||||||
strCatFmt(replace, "-%u", index + 1);
|
strCatFmt(replace, "-%u", index + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
strCat(replace, "]");
|
strCatZ(replace, "]");
|
||||||
|
|
||||||
// Find end of match and calculate size difference from replacement
|
// Find end of match and calculate size difference from replacement
|
||||||
char *end = begin + strSize(match);
|
char *end = begin + strSize(match);
|
||||||
|
@ -27,7 +27,7 @@ hrnStorageInfoListCallback(void *callbackData, const StorageInfo *info)
|
|||||||
{
|
{
|
||||||
case storageTypeFile:
|
case storageTypeFile:
|
||||||
{
|
{
|
||||||
strCat(data->content, "file");
|
strCatZ(data->content, "file");
|
||||||
|
|
||||||
if (info->level >= storageInfoLevelBasic && !data->sizeOmit)
|
if (info->level >= storageInfoLevelBasic && !data->sizeOmit)
|
||||||
{
|
{
|
||||||
@ -60,13 +60,13 @@ hrnStorageInfoListCallback(void *callbackData, const StorageInfo *info)
|
|||||||
|
|
||||||
case storageTypePath:
|
case storageTypePath:
|
||||||
{
|
{
|
||||||
strCat(data->content, "path");
|
strCatZ(data->content, "path");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case storageTypeSpecial:
|
case storageTypeSpecial:
|
||||||
{
|
{
|
||||||
strCat(data->content, "special");
|
strCatZ(data->content, "special");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,5 +115,5 @@ hrnStorageInfoListCallback(void *callbackData, const StorageInfo *info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strCat(data->content, "}\n");
|
strCatZ(data->content, "}\n");
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ testBackupValidateCallback(void *callbackData, const StorageInfo *info)
|
|||||||
{
|
{
|
||||||
case storageTypeFile:
|
case storageTypeFile:
|
||||||
{
|
{
|
||||||
strCat(data->content, "file");
|
strCatZ(data->content, "file");
|
||||||
|
|
||||||
// Calculate checksum/size and decompress if needed
|
// Calculate checksum/size and decompress if needed
|
||||||
// ---------------------------------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------------------------------
|
||||||
@ -129,7 +129,7 @@ testBackupValidateCallback(void *callbackData, const StorageInfo *info)
|
|||||||
|
|
||||||
case storageTypePath:
|
case storageTypePath:
|
||||||
{
|
{
|
||||||
strCat(data->content, "path");
|
strCatZ(data->content, "path");
|
||||||
|
|
||||||
// Check against the manifest
|
// Check against the manifest
|
||||||
// ---------------------------------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------------------------------
|
||||||
@ -156,7 +156,7 @@ testBackupValidateCallback(void *callbackData, const StorageInfo *info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strCat(data->content, "}\n");
|
strCatZ(data->content, "}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static String *
|
static String *
|
||||||
|
@ -55,7 +55,7 @@ archiveExpectList(const unsigned int start, unsigned int end, const char *majorW
|
|||||||
wal = strNewFmt("%s000000%u-9baedd24b61aa15305732ac678c4e2c102435a09", majorWal, i);
|
wal = strNewFmt("%s000000%u-9baedd24b61aa15305732ac678c4e2c102435a09", majorWal, i);
|
||||||
|
|
||||||
if (strSize(result) == 0)
|
if (strSize(result) == 0)
|
||||||
strCat(result, strPtr(wal));
|
strCat(result, wal);
|
||||||
else
|
else
|
||||||
strCatFmt(result, ", %s", strPtr(wal));
|
strCatFmt(result, ", %s", strPtr(wal));
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ testRun(void)
|
|||||||
String *string = strNew("XXXX");
|
String *string = strNew("XXXX");
|
||||||
String *string2 = strNew("ZZZZ");
|
String *string2 = strNew("ZZZZ");
|
||||||
|
|
||||||
TEST_RESULT_STR_Z(strCat(string, "YYYY"), "XXXXYYYY", "cat string");
|
TEST_RESULT_STR_Z(strCat(string, STRDEF("YYYY")), "XXXXYYYY", "cat string");
|
||||||
TEST_RESULT_UINT(string->extra, 60, "check extra");
|
TEST_RESULT_UINT(string->extra, 60, "check extra");
|
||||||
TEST_RESULT_STR_Z(strCatFmt(string, "%05d", 777), "XXXXYYYY00777", "cat formatted string");
|
TEST_RESULT_STR_Z(strCatFmt(string, "%05d", 777), "XXXXYYYY00777", "cat formatted string");
|
||||||
TEST_RESULT_UINT(string->extra, 55, "check extra");
|
TEST_RESULT_UINT(string->extra, 55, "check extra");
|
||||||
@ -239,7 +239,7 @@ testRun(void)
|
|||||||
TEST_ERROR(strTrunc(val, -1), AssertError, "assertion 'idx >= 0 && (size_t)idx <= this->size' failed");
|
TEST_ERROR(strTrunc(val, -1), AssertError, "assertion 'idx >= 0 && (size_t)idx <= this->size' failed");
|
||||||
|
|
||||||
TEST_RESULT_STR_Z(strTrunc(val, strChr(val, 'd')), "abc", "simple string truncated");
|
TEST_RESULT_STR_Z(strTrunc(val, strChr(val, 'd')), "abc", "simple string truncated");
|
||||||
strCat(val, "\r\n to end");
|
strCatZ(val, "\r\n to end");
|
||||||
TEST_RESULT_STR_Z(strTrunc(val, strChr(val, 'n')), "abc\r\n to e", "complex string truncated");
|
TEST_RESULT_STR_Z(strTrunc(val, strChr(val, 'n')), "abc\r\n to e", "complex string truncated");
|
||||||
TEST_RESULT_STR_Z(strTrunc(val, strChr(val, 'a')), "", "complete string truncated - empty string");
|
TEST_RESULT_STR_Z(strTrunc(val, strChr(val, 'a')), "", "complete string truncated - empty string");
|
||||||
|
|
||||||
|
@ -513,76 +513,76 @@ testRun(void)
|
|||||||
TEST_ERROR(sizeQualifierToMultiplier('w'), AssertError, "'w' is not a valid size qualifier");
|
TEST_ERROR(sizeQualifierToMultiplier('w'), AssertError, "'w' is not a valid size qualifier");
|
||||||
TEST_ERROR(convertToByte(&value, &valueDbl), FormatError, "value '10.0' is not valid");
|
TEST_ERROR(convertToByte(&value, &valueDbl), FormatError, "value '10.0' is not valid");
|
||||||
strTrunc(value, strChr(value, '.'));
|
strTrunc(value, strChr(value, '.'));
|
||||||
strCat(value, "K2");
|
strCatZ(value, "K2");
|
||||||
TEST_ERROR(convertToByte(&value, &valueDbl), FormatError, "value '10K2' is not valid");
|
TEST_ERROR(convertToByte(&value, &valueDbl), FormatError, "value '10K2' is not valid");
|
||||||
strTrunc(value, strChr(value, '1'));
|
strTrunc(value, strChr(value, '1'));
|
||||||
strCat(value, "ab");
|
strCatZ(value, "ab");
|
||||||
TEST_ERROR(convertToByte(&value, &valueDbl), FormatError, "value 'ab' is not valid");
|
TEST_ERROR(convertToByte(&value, &valueDbl), FormatError, "value 'ab' is not valid");
|
||||||
|
|
||||||
strTrunc(value, strChr(value, 'a'));
|
strTrunc(value, strChr(value, 'a'));
|
||||||
strCat(value, "10");
|
strCatZ(value, "10");
|
||||||
convertToByte(&value, &valueDbl);
|
convertToByte(&value, &valueDbl);
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 10, "valueDbl no character identifier - straight to bytes");
|
TEST_RESULT_DOUBLE(valueDbl, 10, "valueDbl no character identifier - straight to bytes");
|
||||||
TEST_RESULT_STR_Z(value, "10", "value no character identifier - straight to bytes");
|
TEST_RESULT_STR_Z(value, "10", "value no character identifier - straight to bytes");
|
||||||
|
|
||||||
strCat(value, "B");
|
strCatZ(value, "B");
|
||||||
convertToByte(&value, &valueDbl);
|
convertToByte(&value, &valueDbl);
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 10, "valueDbl B to bytes");
|
TEST_RESULT_DOUBLE(valueDbl, 10, "valueDbl B to bytes");
|
||||||
TEST_RESULT_STR_Z(value, "10", "value B to bytes");
|
TEST_RESULT_STR_Z(value, "10", "value B to bytes");
|
||||||
|
|
||||||
strCat(value, "Kb");
|
strCatZ(value, "Kb");
|
||||||
convertToByte(&value, &valueDbl);
|
convertToByte(&value, &valueDbl);
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 10240, "valueDbl KB to bytes");
|
TEST_RESULT_DOUBLE(valueDbl, 10240, "valueDbl KB to bytes");
|
||||||
TEST_RESULT_STR_Z(value, "10240", "value KB to bytes");
|
TEST_RESULT_STR_Z(value, "10240", "value KB to bytes");
|
||||||
|
|
||||||
strTrunc(value, strChr(value, '2'));
|
strTrunc(value, strChr(value, '2'));
|
||||||
strCat(value, "k");
|
strCatZ(value, "k");
|
||||||
convertToByte(&value, &valueDbl);
|
convertToByte(&value, &valueDbl);
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 10240, "valueDbl k to bytes");
|
TEST_RESULT_DOUBLE(valueDbl, 10240, "valueDbl k to bytes");
|
||||||
TEST_RESULT_STR_Z(value, "10240", "value k to bytes");
|
TEST_RESULT_STR_Z(value, "10240", "value k to bytes");
|
||||||
|
|
||||||
strCat(value, "pB");
|
strCatZ(value, "pB");
|
||||||
convertToByte(&value, &valueDbl);
|
convertToByte(&value, &valueDbl);
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 11529215046068469760U, "valueDbl Pb to bytes");
|
TEST_RESULT_DOUBLE(valueDbl, 11529215046068469760U, "valueDbl Pb to bytes");
|
||||||
TEST_RESULT_STR_Z(value, "11529215046068469760", "value Pb to bytes");
|
TEST_RESULT_STR_Z(value, "11529215046068469760", "value Pb to bytes");
|
||||||
|
|
||||||
strTrunc(value, strChr(value, '5'));
|
strTrunc(value, strChr(value, '5'));
|
||||||
strCat(value, "GB");
|
strCatZ(value, "GB");
|
||||||
convertToByte(&value, &valueDbl);
|
convertToByte(&value, &valueDbl);
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 11811160064U, "valueDbl GB to bytes");
|
TEST_RESULT_DOUBLE(valueDbl, 11811160064U, "valueDbl GB to bytes");
|
||||||
TEST_RESULT_STR_Z(value, "11811160064", "value GB to bytes");
|
TEST_RESULT_STR_Z(value, "11811160064", "value GB to bytes");
|
||||||
|
|
||||||
strTrunc(value, strChr(value, '8'));
|
strTrunc(value, strChr(value, '8'));
|
||||||
strCat(value, "g");
|
strCatZ(value, "g");
|
||||||
convertToByte(&value, &valueDbl);
|
convertToByte(&value, &valueDbl);
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 11811160064U, "valueDbl g to bytes");
|
TEST_RESULT_DOUBLE(valueDbl, 11811160064U, "valueDbl g to bytes");
|
||||||
TEST_RESULT_STR_Z(value, "11811160064", "value g to bytes");
|
TEST_RESULT_STR_Z(value, "11811160064", "value g to bytes");
|
||||||
|
|
||||||
strTrunc(value, strChr(value, '8'));
|
strTrunc(value, strChr(value, '8'));
|
||||||
strCat(value, "T");
|
strCatZ(value, "T");
|
||||||
convertToByte(&value, &valueDbl);
|
convertToByte(&value, &valueDbl);
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 12094627905536U, "valueDbl T to bytes");
|
TEST_RESULT_DOUBLE(valueDbl, 12094627905536U, "valueDbl T to bytes");
|
||||||
TEST_RESULT_STR_Z(value, "12094627905536", "value T to bytes");
|
TEST_RESULT_STR_Z(value, "12094627905536", "value T to bytes");
|
||||||
|
|
||||||
strTrunc(value, strChr(value, '0'));
|
strTrunc(value, strChr(value, '0'));
|
||||||
strCat(value, "tb");
|
strCatZ(value, "tb");
|
||||||
convertToByte(&value, &valueDbl);
|
convertToByte(&value, &valueDbl);
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 13194139533312U, "valueDbl tb to bytes");
|
TEST_RESULT_DOUBLE(valueDbl, 13194139533312U, "valueDbl tb to bytes");
|
||||||
TEST_RESULT_STR_Z(value, "13194139533312", "value tb to bytes");
|
TEST_RESULT_STR_Z(value, "13194139533312", "value tb to bytes");
|
||||||
|
|
||||||
strTrunc(value, strChr(value, '3'));
|
strTrunc(value, strChr(value, '3'));
|
||||||
strCat(value, "0m");
|
strCatZ(value, "0m");
|
||||||
convertToByte(&value, &valueDbl);
|
convertToByte(&value, &valueDbl);
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 10485760, "valueDbl m to bytes");
|
TEST_RESULT_DOUBLE(valueDbl, 10485760, "valueDbl m to bytes");
|
||||||
TEST_RESULT_STR_Z(value, "10485760", "value m to bytes");
|
TEST_RESULT_STR_Z(value, "10485760", "value m to bytes");
|
||||||
|
|
||||||
strCat(value, "mb");
|
strCatZ(value, "mb");
|
||||||
convertToByte(&value, &valueDbl);
|
convertToByte(&value, &valueDbl);
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 10995116277760U, "valueDbl mb to bytes");
|
TEST_RESULT_DOUBLE(valueDbl, 10995116277760U, "valueDbl mb to bytes");
|
||||||
TEST_RESULT_STR_Z(value, "10995116277760", "value mb to bytes");
|
TEST_RESULT_STR_Z(value, "10995116277760", "value mb to bytes");
|
||||||
|
|
||||||
strTrunc(value, strChr(value, '0'));
|
strTrunc(value, strChr(value, '0'));
|
||||||
strCat(value, "99999999999999999999p");
|
strCatZ(value, "99999999999999999999p");
|
||||||
convertToByte(&value, &valueDbl);
|
convertToByte(&value, &valueDbl);
|
||||||
TEST_RESULT_STR_Z(value, "225179981368524800000000000000000000", "value really large to bytes");
|
TEST_RESULT_STR_Z(value, "225179981368524800000000000000000000", "value really large to bytes");
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ testRun(void)
|
|||||||
for (unsigned int linkIdx = 0; linkIdx < 1; linkIdx++)
|
for (unsigned int linkIdx = 0; linkIdx < 1; linkIdx++)
|
||||||
strCatFmt(manifestStr, "pg_data/pg_stat%u={\"path\":\"../pg_stat\",\"type\":\"link\"}\n", linkIdx);
|
strCatFmt(manifestStr, "pg_data/pg_stat%u={\"path\":\"../pg_stat\",\"type\":\"link\"}\n", linkIdx);
|
||||||
|
|
||||||
strCat(
|
strCatZ(
|
||||||
manifestStr,
|
manifestStr,
|
||||||
"\n"
|
"\n"
|
||||||
"[target:file]\n");
|
"[target:file]\n");
|
||||||
@ -180,7 +180,7 @@ testRun(void)
|
|||||||
16384 + fileIdx);
|
16384 + fileIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
strCat(
|
strCatZ(
|
||||||
manifestStr,
|
manifestStr,
|
||||||
"\n"
|
"\n"
|
||||||
"[target:file:default]\n"
|
"[target:file:default]\n"
|
||||||
|
@ -39,7 +39,7 @@ testRequest(Storage *s3, const char *verb, const char *uri, TestRequestParam par
|
|||||||
verb, uri);
|
verb, uri);
|
||||||
|
|
||||||
if (param.content != NULL)
|
if (param.content != NULL)
|
||||||
strCat(request, "content-md5;");
|
strCatZ(request, "content-md5;");
|
||||||
|
|
||||||
strCatFmt(
|
strCatFmt(
|
||||||
request,
|
request,
|
||||||
@ -72,7 +72,7 @@ testRequest(Storage *s3, const char *verb, const char *uri, TestRequestParam par
|
|||||||
|
|
||||||
// Add content
|
// Add content
|
||||||
if (param.content != NULL)
|
if (param.content != NULL)
|
||||||
strCat(request, param.content);
|
strCatZ(request, param.content);
|
||||||
|
|
||||||
hrnTlsServerExpect(request);
|
hrnTlsServerExpect(request);
|
||||||
}
|
}
|
||||||
@ -105,19 +105,19 @@ testResponse(TestResponseParam param)
|
|||||||
{
|
{
|
||||||
case 200:
|
case 200:
|
||||||
{
|
{
|
||||||
strCat(response, "OK");
|
strCatZ(response, "OK");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 403:
|
case 403:
|
||||||
{
|
{
|
||||||
strCat(response, "Forbidden");
|
strCatZ(response, "Forbidden");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// End header
|
// End header
|
||||||
strCat(response, "\r\n");
|
strCatZ(response, "\r\n");
|
||||||
|
|
||||||
// Headers
|
// Headers
|
||||||
if (param.header != NULL)
|
if (param.header != NULL)
|
||||||
@ -134,7 +134,7 @@ testResponse(TestResponseParam param)
|
|||||||
strlen(param.content), param.content);
|
strlen(param.content), param.content);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
strCat(response, "\r\n");
|
strCatZ(response, "\r\n");
|
||||||
|
|
||||||
hrnTlsServerReply(response);
|
hrnTlsServerReply(response);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user