1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-17 01:12:23 +02:00

Rename strPtr()/strPtrNull() to strZ()/strZNull().

We use the Z suffix in many functions to indicate that we are expecting a zero-terminated string so make this function conform to the pattern.

As a bonus the new name is a bit shorter, which is a good quality in a commonly-used function.
This commit is contained in:
David Steele
2020-07-30 07:49:06 -04:00
parent 039d314438
commit 3e9dce0d76
129 changed files with 1803 additions and 1844 deletions

View File

@ -12,10 +12,10 @@ With the exception of documentation code, no line of any code or test file shall
``` ```
// CORRECT - location of line break after first function parenthesis if line length is greater than 132 // CORRECT - location of line break after first function parenthesis if line length is greater than 132
StringList *removeList = infoBackupDataLabelList( StringList *removeList = infoBackupDataLabelList(
infoBackup, strNewFmt("^%s.*", strPtr(strLstGet(currentBackupList, fullIdx)))); infoBackup, strNewFmt("^%s.*", strZ(strLstGet(currentBackupList, fullIdx))));
// INCORRECT // INCORRECT
StringList *removeList = infoBackupDataLabelList(infoBackup, strNewFmt("^%s.*", strPtr(strLstGet(currentBackupList, StringList *removeList = infoBackupDataLabelList(infoBackup, strNewFmt("^%s.*", strZ(strLstGet(currentBackupList,
fullIdx)))); fullIdx))));
``` ```
If a conditional, then after a completed conditional, for example: If a conditional, then after a completed conditional, for example:

View File

@ -300,7 +300,7 @@ If configuration options are required then a string list with the command and op
``` ```
String *repoPath = strNewFmt("%s/repo", testPath()); // create a string defining the repo path on the test system String *repoPath = strNewFmt("%s/repo", testPath()); // create a string defining the repo path on the test system
StringList *argList = strLstNew(); // create an empty string list StringList *argList = strLstNew(); // create an empty string list
strLstAdd(argList, strNewFmt("--repo-path=%s/", strPtr(repoPath))); // add the --repo-path option as a formatted string strLstAdd(argList, strNewFmt("--repo-path=%s/", strZ(repoPath))); // add the --repo-path option as a formatted string
strLstAddZ(argList, "info"); // add the command strLstAddZ(argList, "info"); // add the command
harnessCfgLoad(cfgCmdExpire, argList); // load the command and option list into the test harness harnessCfgLoad(cfgCmdExpire, argList); // load the command and option list into the test harness
@ -326,8 +326,9 @@ Sometimes it is necessary to store a file to the test directory. The following d
``` ```
String *content = strNew("bad content"); String *content = strNew("bad content");
TEST_RESULT_VOID( TEST_RESULT_VOID(
storagePutP(storageNewWriteP(storageTest, strNewFmt("%s/backup/demo/backup.info", strPtr(repoPath))), storagePutP(
harnessInfoChecksum(content)), "store a corrupt backup.info file"); storageNewWriteP(storageTest, strNewFmt("%s/backup/demo/backup.info", strZ(repoPath))), harnessInfoChecksum(content)),
"store a corrupt backup.info file");
``` ```
**Testing a log message** **Testing a log message**

View File

@ -20,10 +20,10 @@
<code-block> <code-block>
// CORRECT - location of line break after first function parenthesis if line length is greater than 132 // CORRECT - location of line break after first function parenthesis if line length is greater than 132
StringList *removeList = infoBackupDataLabelList( StringList *removeList = infoBackupDataLabelList(
infoBackup, strNewFmt("^%s.*", strPtr(strLstGet(currentBackupList, fullIdx)))); infoBackup, strNewFmt("^%s.*", strZ(strLstGet(currentBackupList, fullIdx))));
// INCORRECT // INCORRECT
StringList *removeList = infoBackupDataLabelList(infoBackup, strNewFmt("^%s.*", strPtr(strLstGet(currentBackupList, StringList *removeList = infoBackupDataLabelList(infoBackup, strNewFmt("^%s.*", strZ(strLstGet(currentBackupList,
fullIdx)))); fullIdx))));
</code-block> </code-block>

View File

@ -334,7 +334,7 @@ if (testBegin("expireBackup()"))
<code-block> <code-block>
String *repoPath = strNewFmt("%s/repo", testPath()); // create a string defining the repo path on the test system String *repoPath = strNewFmt("%s/repo", testPath()); // create a string defining the repo path on the test system
StringList *argList = strLstNew(); // create an empty string list StringList *argList = strLstNew(); // create an empty string list
strLstAdd(argList, strNewFmt("--repo-path=%s/", strPtr(repoPath))); // add the --repo-path option as a formatted string strLstAdd(argList, strNewFmt("--repo-path=%s/", strZ(repoPath))); // add the --repo-path option as a formatted string
strLstAddZ(argList, "info"); // add the command strLstAddZ(argList, "info"); // add the command
harnessCfgLoad(cfgCmdExpire, argList); // load the command and option list into the test harness harnessCfgLoad(cfgCmdExpire, argList); // load the command and option list into the test harness
@ -358,8 +358,9 @@ TEST_RESULT_STR_Z(infoRender(), "No stanzas exist in the repository.\n", "text -
<code-block> <code-block>
String *content = strNew("bad content"); String *content = strNew("bad content");
TEST_RESULT_VOID( TEST_RESULT_VOID(
storagePutP(storageNewWriteP(storageTest, strNewFmt("%s/backup/demo/backup.info", strPtr(repoPath))), storagePutP(
harnessInfoChecksum(content)), "store a corrupt backup.info file"); storageNewWriteP(storageTest, strNewFmt("%s/backup/demo/backup.info", strZ(repoPath))), harnessInfoChecksum(content)),
"store a corrupt backup.info file");
</code-block> </code-block>
<p><b>Testing a log message</b></p> <p><b>Testing a log message</b></p>

View File

@ -62,8 +62,7 @@ archiveAsyncErrorClear(ArchiveMode archiveMode, const String *archiveFile)
ASSERT(archiveFile != NULL); ASSERT(archiveFile != NULL);
storageRemoveP( storageRemoveP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s" STATUS_EXT_ERROR, strZ(archiveFile)));
storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s" STATUS_EXT_ERROR, strPtr(archiveFile)));
storageRemoveP(storageSpoolWrite(), STRDEF(STORAGE_SPOOL_ARCHIVE_OUT "/" STATUS_FILE_GLOBAL_ERROR)); storageRemoveP(storageSpoolWrite(), STRDEF(STORAGE_SPOOL_ARCHIVE_OUT "/" STATUS_FILE_GLOBAL_ERROR));
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
@ -90,21 +89,21 @@ archiveAsyncStatus(ArchiveMode archiveMode, const String *walSegment, bool throw
const String *spoolQueue = archiveAsyncSpoolQueue(archiveMode); const String *spoolQueue = archiveAsyncSpoolQueue(archiveMode);
String *okFile = strNewFmt("%s" STATUS_EXT_OK, strPtr(walSegment)); String *okFile = strNewFmt("%s" STATUS_EXT_OK, strZ(walSegment));
bool okFileExists = storageExistsP(storageSpool(), strNewFmt("%s/%s", strPtr(spoolQueue), strPtr(okFile))); bool okFileExists = storageExistsP(storageSpool(), strNewFmt("%s/%s", strZ(spoolQueue), strZ(okFile)));
// If the ok file does not exist then check to see if a file-specific or global error exists // If the ok file does not exist then check to see if a file-specific or global error exists
if (!okFileExists) if (!okFileExists)
{ {
// Check for a file-specific error first // Check for a file-specific error first
errorFile = strNewFmt("%s" STATUS_EXT_ERROR, strPtr(walSegment)); errorFile = strNewFmt("%s" STATUS_EXT_ERROR, strZ(walSegment));
errorFileExists = storageExistsP(storageSpool(), strNewFmt("%s/%s", strPtr(spoolQueue), strPtr(errorFile))); errorFileExists = storageExistsP(storageSpool(), strNewFmt("%s/%s", strZ(spoolQueue), strZ(errorFile)));
// If that doesn't exist then check for a global error // If that doesn't exist then check for a global error
if (!errorFileExists) if (!errorFileExists)
{ {
errorFile = STATUS_FILE_GLOBAL_ERROR_STR; errorFile = STATUS_FILE_GLOBAL_ERROR_STR;
errorFileExists = storageExistsP(storageSpool(), strNewFmt("%s/%s", strPtr(spoolQueue), strPtr(errorFile))); errorFileExists = storageExistsP(storageSpool(), strNewFmt("%s/%s", strZ(spoolQueue), strZ(errorFile)));
} }
} }
@ -115,7 +114,7 @@ archiveAsyncStatus(ArchiveMode archiveMode, const String *walSegment, bool throw
const String *statusFile = okFileExists ? okFile: errorFile; const String *statusFile = okFileExists ? okFile: errorFile;
String *content = strNewBuf( String *content = strNewBuf(
storageGetP(storageNewReadP(storageSpool(), strNewFmt("%s/%s", strPtr(spoolQueue), strPtr(statusFile))))); storageGetP(storageNewReadP(storageSpool(), strNewFmt("%s/%s", strZ(spoolQueue), strZ(statusFile)))));
// Get the code and message if the file has content // Get the code and message if the file has content
int code = 0; int code = 0;
@ -124,18 +123,18 @@ archiveAsyncStatus(ArchiveMode archiveMode, const String *walSegment, bool throw
if (strSize(content) != 0) if (strSize(content) != 0)
{ {
// Find the line feed after the error code -- should be the first one // Find the line feed after the error code -- should be the first one
const char *linefeedPtr = strchr(strPtr(content), '\n'); const char *linefeedPtr = strchr(strZ(content), '\n');
// Error if linefeed not found // Error if linefeed not found
if (linefeedPtr == NULL) if (linefeedPtr == NULL)
THROW_FMT(FormatError, "%s content must have at least two lines", strPtr(statusFile)); THROW_FMT(FormatError, "%s content must have at least two lines", strZ(statusFile));
// Error if message is zero-length // Error if message is zero-length
if (strlen(linefeedPtr + 1) == 0) if (strlen(linefeedPtr + 1) == 0)
THROW_FMT(FormatError, "%s message must be > 0", strPtr(statusFile)); THROW_FMT(FormatError, "%s message must be > 0", strZ(statusFile));
// Get contents // Get contents
code = varIntForce(VARSTR(strNewN(strPtr(content), (size_t)(linefeedPtr - strPtr(content))))); code = varIntForce(VARSTR(strNewN(strZ(content), (size_t)(linefeedPtr - strZ(content)))));
message = strTrim(strNew(linefeedPtr + 1)); message = strTrim(strNew(linefeedPtr + 1));
} }
@ -149,11 +148,11 @@ archiveAsyncStatus(ArchiveMode archiveMode, const String *walSegment, bool throw
if (code != 0) if (code != 0)
{ {
message = strNewFmt( message = strNewFmt(
"WAL segment '%s' was not pushed due to error [%d] and was manually skipped: %s", strPtr(walSegment), "WAL segment '%s' was not pushed due to error [%d] and was manually skipped: %s", strZ(walSegment),
code, strPtr(message)); code, strZ(message));
} }
LOG_WARN(strPtr(message)); LOG_WARN(strZ(message));
} }
result = true; result = true;
@ -162,10 +161,10 @@ archiveAsyncStatus(ArchiveMode archiveMode, const String *walSegment, bool throw
{ {
// Error status files must have content // Error status files must have content
if (strSize(content) == 0) if (strSize(content) == 0)
THROW_FMT(AssertError, "status file '%s' has no content", strPtr(statusFile)); THROW_FMT(AssertError, "status file '%s' has no content", strZ(statusFile));
// Throw error using the code passed in the file // Throw error using the code passed in the file
THROW_CODE(code, strPtr(message)); THROW_CODE(code, strZ(message));
} }
} }
} }
@ -195,8 +194,8 @@ archiveAsyncStatusErrorWrite(ArchiveMode archiveMode, const String *walSegment,
storagePutP( storagePutP(
storageNewWriteP( storageNewWriteP(
storageSpoolWrite(), storageSpoolWrite(),
strNewFmt("%s/%s" STATUS_EXT_ERROR, strPtr(archiveAsyncSpoolQueue(archiveMode)), strPtr(errorFile))), strNewFmt("%s/%s" STATUS_EXT_ERROR, strZ(archiveAsyncSpoolQueue(archiveMode)), strZ(errorFile))),
BUFSTR(strNewFmt("%d\n%s", code, strPtr(message)))); BUFSTR(strNewFmt("%d\n%s", code, strZ(message))));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
@ -220,9 +219,8 @@ archiveAsyncStatusOkWrite(ArchiveMode archiveMode, const String *walSegment, con
// Write file // Write file
storagePutP( storagePutP(
storageNewWriteP( storageNewWriteP(
storageSpoolWrite(), storageSpoolWrite(), strNewFmt("%s/%s" STATUS_EXT_OK, strZ(archiveAsyncSpoolQueue(archiveMode)), strZ(walSegment))),
strNewFmt("%s/%s" STATUS_EXT_OK, strPtr(archiveAsyncSpoolQueue(archiveMode)), strPtr(walSegment))), warning == NULL ? NULL : BUFSTR(strNewFmt("0\n%s", strZ(warning))));
warning == NULL ? NULL : BUFSTR(strNewFmt("0\n%s", strPtr(warning))));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
@ -253,7 +251,7 @@ archiveAsyncExec(ArchiveMode archiveMode, const StringList *commandExec)
// Execute the binary. This statement will not return if it is successful. // Execute the binary. This statement will not return if it is successful.
THROW_ON_SYS_ERROR_FMT( THROW_ON_SYS_ERROR_FMT(
execvp(strPtr(strLstGet(commandExec, 0)), (char ** const)strLstPtr(commandExec)) == -1, ExecuteError, execvp(strZ(strLstGet(commandExec, 0)), (char ** const)strLstPtr(commandExec)) == -1, ExecuteError,
"unable to execute asynchronous '%s'", archiveMode == archiveModeGet ? CFGCMD_ARCHIVE_GET : CFGCMD_ARCHIVE_PUSH); "unable to execute asynchronous '%s'", archiveMode == archiveModeGet ? CFGCMD_ARCHIVE_GET : CFGCMD_ARCHIVE_PUSH);
} }
@ -319,7 +317,7 @@ walPath(const String *walFile, const String *pgPath, const String *command)
"option '" CFGOPT_PG1_PATH "' must be specified when relative wal paths are used\n" "option '" CFGOPT_PG1_PATH "' must be specified when relative wal paths are used\n"
"HINT: is %%f passed to %s instead of %%p?\n" "HINT: is %%f passed to %s instead of %%p?\n"
"HINT: PostgreSQL may pass relative paths even with %%p depending on the environment.", "HINT: PostgreSQL may pass relative paths even with %%p depending on the environment.",
strPtr(command)); strZ(command));
} }
// Get the working directory // Get the working directory
@ -330,7 +328,7 @@ walPath(const String *walFile, const String *pgPath, const String *command)
if (!strEqZ(pgPath, currentWorkDir)) if (!strEqZ(pgPath, currentWorkDir))
{ {
// If not we'll change the working directory to pgPath and see if that equals the working directory we got called with // If not we'll change the working directory to pgPath and see if that equals the working directory we got called with
THROW_ON_SYS_ERROR_FMT(chdir(strPtr(pgPath)) != 0, PathMissingError, "unable to chdir() to '%s'", strPtr(pgPath)); THROW_ON_SYS_ERROR_FMT(chdir(strZ(pgPath)) != 0, PathMissingError, "unable to chdir() to '%s'", strZ(pgPath));
// Get the new working directory // Get the new working directory
char newWorkDir[4096]; char newWorkDir[4096];
@ -339,10 +337,10 @@ walPath(const String *walFile, const String *pgPath, const String *command)
// Error if the new working directory is not equal to the original current working directory. This means that // Error if the new working directory is not equal to the original current working directory. This means that
// PostgreSQL and pgBackrest have a different idea about where the PostgreSQL data directory is located. // PostgreSQL and pgBackrest have a different idea about where the PostgreSQL data directory is located.
if (strcmp(currentWorkDir, newWorkDir) != 0) if (strcmp(currentWorkDir, newWorkDir) != 0)
THROW_FMT(AssertError, "working path '%s' is not the same path as '%s'", currentWorkDir, strPtr(pgPath)); THROW_FMT(AssertError, "working path '%s' is not the same path as '%s'", currentWorkDir, strZ(pgPath));
} }
result = strNewFmt("%s/%s", strPtr(pgPath), strPtr(walFile)); result = strNewFmt("%s/%s", strZ(pgPath), strZ(walFile));
} }
else else
result = strDup(walFile); result = strDup(walFile);
@ -401,9 +399,11 @@ walSegmentFind(const Storage *storage, const String *archiveId, const String *wa
{ {
// Get a list of all WAL segments that match // Get a list of all WAL segments that match
StringList *list = storageListP( StringList *list = storageListP(
storage, strNewFmt(STORAGE_REPO_ARCHIVE "/%s/%s", strPtr(archiveId), strPtr(strSubN(walSegment, 0, 16))), storage, strNewFmt(STORAGE_REPO_ARCHIVE "/%s/%s", strZ(archiveId), strZ(strSubN(walSegment, 0, 16))),
.expression = strNewFmt("^%s%s-[0-f]{40}" COMPRESS_TYPE_REGEXP "{0,1}$", strPtr(strSubN(walSegment, 0, 24)), .expression = strNewFmt(
walIsPartial(walSegment) ? WAL_SEGMENT_PARTIAL_EXT : ""), .nullOnMissing = true); "^%s%s-[0-f]{40}" COMPRESS_TYPE_REGEXP "{0,1}$", strZ(strSubN(walSegment, 0, 24)),
walIsPartial(walSegment) ? WAL_SEGMENT_PARTIAL_EXT : ""),
.nullOnMissing = true);
// If there are results // If there are results
if (list != NULL && strLstSize(list) > 0) if (list != NULL && strLstSize(list) > 0)
@ -415,7 +415,7 @@ walSegmentFind(const Storage *storage, const String *archiveId, const String *wa
ArchiveDuplicateError, ArchiveDuplicateError,
"duplicates found in archive for WAL segment %s: %s\n" "duplicates found in archive for WAL segment %s: %s\n"
"HINT: are multiple primaries archiving to this stanza?", "HINT: are multiple primaries archiving to this stanza?",
strPtr(walSegment), strPtr(strLstJoin(strLstSort(list, sortOrderAsc), ", "))); strZ(walSegment), strZ(strLstJoin(strLstSort(list, sortOrderAsc), ", ")));
} }
// Copy file name of WAL segment found into the prior context // Copy file name of WAL segment found into the prior context
@ -437,7 +437,7 @@ walSegmentFind(const Storage *storage, const String *archiveId, const String *wa
"WAL segment %s was not archived before the %" PRIu64 "ms timeout\n" "WAL segment %s was not archived before the %" PRIu64 "ms timeout\n"
"HINT: check the archive_command to ensure that all options are correct (especially --stanza).\n" "HINT: check the archive_command to ensure that all options are correct (especially --stanza).\n"
"HINT: check the PostgreSQL server log for errors.", "HINT: check the PostgreSQL server log for errors.",
strPtr(walSegment), timeout); strZ(walSegment), timeout);
} }
FUNCTION_LOG_RETURN(STRING, result); FUNCTION_LOG_RETURN(STRING, result);
@ -465,9 +465,9 @@ walSegmentNext(const String *walSegment, size_t walSegmentSize, unsigned int pgV
MEM_CONTEXT_TEMP_BEGIN() MEM_CONTEXT_TEMP_BEGIN()
{ {
timeline = (uint32_t)strtol(strPtr(strSubN(walSegment, 0, 8)), NULL, 16); timeline = (uint32_t)strtol(strZ(strSubN(walSegment, 0, 8)), NULL, 16);
major = (uint32_t)strtol(strPtr(strSubN(walSegment, 8, 8)), NULL, 16); major = (uint32_t)strtol(strZ(strSubN(walSegment, 8, 8)), NULL, 16);
minor = (uint32_t)strtol(strPtr(strSubN(walSegment, 16, 8)), NULL, 16); minor = (uint32_t)strtol(strZ(strSubN(walSegment, 16, 8)), NULL, 16);
// Increment minor and adjust major dir on overflow // Increment minor and adjust major dir on overflow
minor++; minor++;

View File

@ -71,14 +71,13 @@ archiveGetCheck(const String *archiveFile, CipherType cipherType, const String *
if (walSegmentFile != NULL) if (walSegmentFile != NULL)
{ {
archiveFileActual = strNewFmt("%s/%s", strPtr(strSubN(archiveFile, 0, 16)), strPtr(walSegmentFile)); archiveFileActual = strNewFmt("%s/%s", strZ(strSubN(archiveFile, 0, 16)), strZ(walSegmentFile));
break; break;
} }
} }
// Else if not a WAL segment, see if it exists in the archive dir // Else if not a WAL segment, see if it exists in the archive dir
else if ( else if (
storageExistsP( storageExistsP(storageRepo(), strNewFmt(STORAGE_REPO_ARCHIVE "/%s/%s", strZ(archiveId), strZ(archiveFile))))
storageRepo(), strNewFmt(STORAGE_REPO_ARCHIVE "/%s/%s", strPtr(archiveId), strPtr(archiveFile))))
{ {
archiveFileActual = archiveFile; archiveFileActual = archiveFile;
break; break;
@ -91,14 +90,14 @@ archiveGetCheck(const String *archiveFile, CipherType cipherType, const String *
{ {
THROW_FMT( THROW_FMT(
ArchiveMismatchError, "unable to retrieve the archive id for database version '%s' and system-id '%" PRIu64 "'", ArchiveMismatchError, "unable to retrieve the archive id for database version '%s' and system-id '%" PRIu64 "'",
strPtr(pgVersionToStr(controlInfo.version)), controlInfo.systemId); strZ(pgVersionToStr(controlInfo.version)), controlInfo.systemId);
} }
if (archiveFileActual != NULL) if (archiveFileActual != NULL)
{ {
MEM_CONTEXT_PRIOR_BEGIN() MEM_CONTEXT_PRIOR_BEGIN()
{ {
result.archiveFileActual = strNewFmt("%s/%s", strPtr(archiveId), strPtr(archiveFileActual)); result.archiveFileActual = strNewFmt("%s/%s", strZ(archiveId), strZ(archiveFileActual));
result.cipherPass = strDup(infoArchiveCipherPass(info)); result.cipherPass = strDup(infoArchiveCipherPass(info));
} }
MEM_CONTEXT_PRIOR_END(); MEM_CONTEXT_PRIOR_END();
@ -168,7 +167,7 @@ archiveGetFile(
// Copy the file // Copy the file
storageCopyP( storageCopyP(
storageNewReadP( storageNewReadP(
storageRepo(), strNewFmt(STORAGE_REPO_ARCHIVE "/%s", strPtr(archiveGetCheckResult.archiveFileActual)), storageRepo(), strNewFmt(STORAGE_REPO_ARCHIVE "/%s", strZ(archiveGetCheckResult.archiveFileActual)),
.compressible = compressible), .compressible = compressible),
destination); destination);

View File

@ -66,7 +66,7 @@ queueNeed(const String *walSegment, bool found, uint64_t queueSize, size_t walSe
storageListP(storageSpool(), STORAGE_SPOOL_ARCHIVE_IN_STR, .errorOnMissing = true), sortOrderAsc); storageListP(storageSpool(), STORAGE_SPOOL_ARCHIVE_IN_STR, .errorOnMissing = true), sortOrderAsc);
// Only preserve files that match the ideal queue. error/ok files are deleted so the async process can try again. // Only preserve files that match the ideal queue. error/ok files are deleted so the async process can try again.
RegExp *regExpPreserve = regExpNew(strNewFmt("^(%s)$", strPtr(strLstJoin(idealQueue, "|")))); RegExp *regExpPreserve = regExpNew(strNewFmt("^(%s)$", strZ(strLstJoin(idealQueue, "|"))));
// Build a list of WAL segments that are being kept so we can later make a list of what is needed // Build a list of WAL segments that are being kept so we can later make a list of what is needed
StringList *keepQueue = strLstNew(); StringList *keepQueue = strLstNew();
@ -82,7 +82,7 @@ queueNeed(const String *walSegment, bool found, uint64_t queueSize, size_t walSe
// Else delete it // Else delete it
else else
storageRemoveP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strPtr(file))); storageRemoveP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strZ(file)));
} }
// Generate a list of the WAL that are needed by removing kept WAL from the ideal queue // Generate a list of the WAL that are needed by removing kept WAL from the ideal queue
@ -152,20 +152,20 @@ cmdArchiveGet(void)
if (archiveAsyncStatus(archiveModeGet, walSegment, throwOnError)) if (archiveAsyncStatus(archiveModeGet, walSegment, throwOnError))
{ {
storageRemoveP( storageRemoveP(
storageSpoolWrite(), storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s" STATUS_EXT_OK, strZ(walSegment)),
strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s" STATUS_EXT_OK, strPtr(walSegment)), .errorOnMissing = true); .errorOnMissing = true);
break; break;
} }
// Check if the WAL segment is already in the queue // Check if the WAL segment is already in the queue
found = storageExistsP(storageSpool(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strPtr(walSegment))); found = storageExistsP(storageSpool(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strZ(walSegment)));
// If found then move the WAL segment to the destination directory // If found then move the WAL segment to the destination directory
if (found) if (found)
{ {
// Source is the WAL segment in the spool queue // Source is the WAL segment in the spool queue
StorageRead *source = storageNewReadP( StorageRead *source = storageNewReadP(
storageSpool(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strPtr(walSegment))); storageSpool(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strZ(walSegment)));
// A move will be attempted but if the spool queue and the WAL path are on different file systems then a copy // A move will be attempted but if the spool queue and the WAL path are on different file systems then a copy
// will be performed instead. // will be performed instead.
@ -266,9 +266,9 @@ cmdArchiveGet(void)
// Log whether or not the file was found // Log whether or not the file was found
if (result == 0) if (result == 0)
LOG_INFO_FMT("found %s in the archive", strPtr(walSegment)); LOG_INFO_FMT("found %s in the archive", strZ(walSegment));
else else
LOG_INFO_FMT("unable to find %s in the archive", strPtr(walSegment)); LOG_INFO_FMT("unable to find %s in the archive", strZ(walSegment));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
@ -329,10 +329,10 @@ cmdArchiveGetAsync(void)
LOG_INFO_FMT( LOG_INFO_FMT(
"get %u WAL file(s) from archive: %s%s", "get %u WAL file(s) from archive: %s%s",
strLstSize(jobData.walSegmentList), strPtr(strLstGet(jobData.walSegmentList, 0)), strLstSize(jobData.walSegmentList), strZ(strLstGet(jobData.walSegmentList, 0)),
strLstSize(jobData.walSegmentList) == 1 ? strLstSize(jobData.walSegmentList) == 1 ?
"" : "" :
strPtr(strNewFmt("...%s", strPtr(strLstGet(jobData.walSegmentList, strLstSize(jobData.walSegmentList) - 1))))); strZ(strNewFmt("...%s", strZ(strLstGet(jobData.walSegmentList, strLstSize(jobData.walSegmentList) - 1)))));
// Create the parallel executor // Create the parallel executor
ProtocolParallel *parallelExec = protocolParallelNew( ProtocolParallel *parallelExec = protocolParallelNew(
@ -359,12 +359,12 @@ cmdArchiveGetAsync(void)
// Get the archive file // Get the archive file
if (varIntForce(protocolParallelJobResult(job)) == 0) if (varIntForce(protocolParallelJobResult(job)) == 0)
{ {
LOG_DETAIL_PID_FMT(processId, "found %s in the archive", strPtr(walSegment)); LOG_DETAIL_PID_FMT(processId, "found %s in the archive", strZ(walSegment));
} }
// If it does not exist write an ok file to indicate that it was checked // If it does not exist write an ok file to indicate that it was checked
else else
{ {
LOG_DETAIL_PID_FMT(processId, "unable to find %s in the archive", strPtr(walSegment)); LOG_DETAIL_PID_FMT(processId, "unable to find %s in the archive", strZ(walSegment));
archiveAsyncStatusOkWrite(archiveModeGet, walSegment, NULL); archiveAsyncStatusOkWrite(archiveModeGet, walSegment, NULL);
} }
} }
@ -373,8 +373,8 @@ cmdArchiveGetAsync(void)
{ {
LOG_WARN_PID_FMT( LOG_WARN_PID_FMT(
processId, processId,
"could not get %s from the archive (will be retried): [%d] %s", strPtr(walSegment), "could not get %s from the archive (will be retried): [%d] %s", strZ(walSegment),
protocolParallelJobErrorCode(job), strPtr(protocolParallelJobErrorMessage(job))); protocolParallelJobErrorCode(job), strZ(protocolParallelJobErrorMessage(job)));
archiveAsyncStatusErrorWrite( archiveAsyncStatusErrorWrite(
archiveModeGet, walSegment, protocolParallelJobErrorCode(job), protocolParallelJobErrorMessage(job)); archiveModeGet, walSegment, protocolParallelJobErrorCode(job), protocolParallelJobErrorMessage(job));

View File

@ -45,7 +45,7 @@ archiveGetProtocol(const String *command, const VariantList *paramList, Protocol
server, server,
VARINT( VARINT(
archiveGetFile( archiveGetFile(
storageSpoolWrite(), walSegment, strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strPtr(walSegment)), true, storageSpoolWrite(), walSegment, strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strZ(walSegment)), true,
cipherType(cfgOptionStr(cfgOptRepoCipherType)), cfgOptionStrNull(cfgOptRepoCipherPass)))); cipherType(cfgOptionStr(cfgOptRepoCipherType)), cfgOptionStrNull(cfgOptRepoCipherPass))));
} }
else else

View File

@ -55,7 +55,7 @@ archivePushFile(
THROW_FMT( THROW_FMT(
ArchiveMismatchError, ArchiveMismatchError,
"WAL file '%s' version %s, system-id %" PRIu64 " do not match stanza version %s, system-id %" PRIu64, "WAL file '%s' version %s, system-id %" PRIu64 " do not match stanza version %s, system-id %" PRIu64,
strPtr(walSource), strPtr(pgVersionToStr(walInfo.version)), walInfo.systemId, strPtr(pgVersionToStr(pgVersion)), strZ(walSource), strZ(pgVersionToStr(walInfo.version)), walInfo.systemId, strZ(pgVersionToStr(pgVersion)),
pgSystemId); pgSystemId);
} }
} }
@ -89,16 +89,16 @@ archivePushFile(
result = strNewFmt( result = strNewFmt(
"WAL file '%s' already exists in the archive with the same checksum" "WAL file '%s' already exists in the archive with the same checksum"
"\nHINT: this is valid in some recovery scenarios but may also indicate a problem.", "\nHINT: this is valid in some recovery scenarios but may also indicate a problem.",
strPtr(archiveFile)); strZ(archiveFile));
} }
MEM_CONTEXT_PRIOR_END(); MEM_CONTEXT_PRIOR_END();
} }
else else
THROW_FMT(ArchiveDuplicateError, "WAL file '%s' already exists in the archive", strPtr(archiveFile)); THROW_FMT(ArchiveDuplicateError, "WAL file '%s' already exists in the archive", strZ(archiveFile));
} }
// Append the checksum to the archive destination // Append the checksum to the archive destination
strCatFmt(archiveDestination, "-%s", strPtr(walSegmentChecksum)); strCatFmt(archiveDestination, "-%s", strZ(walSegmentChecksum));
} }
// Only copy if the file was not found in the archive // Only copy if the file was not found in the archive
@ -130,7 +130,7 @@ archivePushFile(
storageCopyP( storageCopyP(
source, source,
storageNewWriteP( storageNewWriteP(
storageRepoWrite(), strNewFmt(STORAGE_REPO_ARCHIVE "/%s/%s", strPtr(archiveId), strPtr(archiveDestination)), storageRepoWrite(), strNewFmt(STORAGE_REPO_ARCHIVE "/%s/%s", strZ(archiveId), strZ(archiveDestination)),
.compressible = compressible)); .compressible = compressible));
} }
} }

View File

@ -42,7 +42,7 @@ archivePushDropWarning(const String *walFile, uint64_t queueMax)
FUNCTION_TEST_END(); FUNCTION_TEST_END();
FUNCTION_TEST_RETURN( FUNCTION_TEST_RETURN(
strNewFmt("dropped WAL file '%s' because archive queue exceeded %s", strPtr(walFile), strPtr(strSizeFormat(queueMax)))); strNewFmt("dropped WAL file '%s' because archive queue exceeded %s", strZ(walFile), strZ(strSizeFormat(queueMax))));
} }
/*********************************************************************************************************************************** /***********************************************************************************************************************************
@ -63,7 +63,7 @@ archivePushDrop(const String *walPath, const StringList *const processList)
for (unsigned int processIdx = 0; processIdx < strLstSize(processList); processIdx++) for (unsigned int processIdx = 0; processIdx < strLstSize(processList); processIdx++)
{ {
queueSize += storageInfoP( queueSize += storageInfoP(
storagePg(), strNewFmt("%s/%s", strPtr(walPath), strPtr(strLstGet(processList, processIdx)))).size; storagePg(), strNewFmt("%s/%s", strZ(walPath), strZ(strLstGet(processList, processIdx)))).size;
if (queueSize > queueMax) if (queueSize > queueMax)
{ {
@ -96,7 +96,7 @@ archivePushReadyList(const String *walPath)
// Read the ready files from the archive_status directory // Read the ready files from the archive_status directory
StringList *readyListRaw = strLstSort( StringList *readyListRaw = strLstSort(
storageListP( storageListP(
storagePg(), strNewFmt("%s/" PG_PATH_ARCHIVE_STATUS, strPtr(walPath)), storagePg(), strNewFmt("%s/" PG_PATH_ARCHIVE_STATUS, strZ(walPath)),
.expression = STRDEF("\\" STATUS_EXT_READY "$"), .errorOnMissing = true), .expression = STRDEF("\\" STATUS_EXT_READY "$"), .errorOnMissing = true),
sortOrderAsc); sortOrderAsc);
@ -154,7 +154,7 @@ archivePushProcessList(const String *walPath)
else else
{ {
storageRemoveP( storageRemoveP(
storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s", strPtr(statusFile)), .errorOnMissing = true); storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s", strZ(statusFile)), .errorOnMissing = true);
} }
} }
@ -168,7 +168,7 @@ archivePushProcessList(const String *walPath)
{ {
storageRemoveP( storageRemoveP(
storageSpoolWrite(), storageSpoolWrite(),
strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s" STATUS_EXT_OK, strPtr(strLstGet(okRemoveList, okRemoveIdx))), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s" STATUS_EXT_OK, strZ(strLstGet(okRemoveList, okRemoveIdx))),
.errorOnMissing = true); .errorOnMissing = true);
} }
@ -231,7 +231,7 @@ archivePushCheck(bool pgPathSet, CipherType cipherType, const String *cipherPass
ArchiveMismatchError, ArchiveMismatchError,
"PostgreSQL version %s, system-id %" PRIu64 " do not match stanza version %s, system-id %" PRIu64 "PostgreSQL version %s, system-id %" PRIu64 " do not match stanza version %s, system-id %" PRIu64
"\nHINT: are you archiving to the correct stanza?", "\nHINT: are you archiving to the correct stanza?",
strPtr(pgVersionToStr(controlInfo.version)), controlInfo.systemId, strPtr(pgVersionToStr(archiveInfo.version)), strZ(pgVersionToStr(controlInfo.version)), controlInfo.systemId, strZ(pgVersionToStr(archiveInfo.version)),
archiveInfo.systemId); archiveInfo.systemId);
} }
} }
@ -336,11 +336,11 @@ cmdArchivePush(void)
{ {
THROW_FMT( THROW_FMT(
ArchiveTimeoutError, "unable to push WAL file '%s' to the archive asynchronously after %lg second(s)", ArchiveTimeoutError, "unable to push WAL file '%s' to the archive asynchronously after %lg second(s)",
strPtr(archiveFile), cfgOptionDbl(cfgOptArchiveTimeout)); strZ(archiveFile), cfgOptionDbl(cfgOptArchiveTimeout));
} }
// Log success // Log success
LOG_INFO_FMT("pushed WAL file '%s' to the archive asynchronously", strPtr(archiveFile)); LOG_INFO_FMT("pushed WAL file '%s' to the archive asynchronously", strZ(archiveFile));
} }
else else
{ {
@ -356,7 +356,7 @@ cmdArchivePush(void)
if (cfgOptionTest(cfgOptArchivePushQueueMax) && if (cfgOptionTest(cfgOptArchivePushQueueMax) &&
archivePushDrop(strPath(walFile), archivePushReadyList(strPath(walFile)))) archivePushDrop(strPath(walFile), archivePushReadyList(strPath(walFile))))
{ {
LOG_WARN(strPtr(archivePushDropWarning(archiveFile, cfgOptionUInt64(cfgOptArchivePushQueueMax)))); LOG_WARN(strZ(archivePushDropWarning(archiveFile, cfgOptionUInt64(cfgOptArchivePushQueueMax))));
} }
// Else push the file // Else push the file
else else
@ -369,10 +369,10 @@ cmdArchivePush(void)
// If a warning was returned then log it // If a warning was returned then log it
if (warning != NULL) if (warning != NULL)
LOG_WARN(strPtr(warning)); LOG_WARN(strZ(warning));
// Log success // Log success
LOG_INFO_FMT("pushed WAL file '%s' to the archive", strPtr(archiveFile)); LOG_INFO_FMT("pushed WAL file '%s' to the archive", strZ(archiveFile));
} }
} }
} }
@ -412,7 +412,7 @@ static ProtocolParallelJob *archivePushAsyncCallback(void *data, unsigned int cl
jobData->walFileIdx++; jobData->walFileIdx++;
ProtocolCommand *command = protocolCommandNew(PROTOCOL_COMMAND_ARCHIVE_PUSH_STR); ProtocolCommand *command = protocolCommandNew(PROTOCOL_COMMAND_ARCHIVE_PUSH_STR);
protocolCommandParamAdd(command, VARSTR(strNewFmt("%s/%s", strPtr(jobData->walPath), strPtr(walFile)))); protocolCommandParamAdd(command, VARSTR(strNewFmt("%s/%s", strZ(jobData->walPath), strZ(walFile))));
protocolCommandParamAdd(command, VARSTR(jobData->archiveInfo.archiveId)); protocolCommandParamAdd(command, VARSTR(jobData->archiveInfo.archiveId));
protocolCommandParamAdd(command, VARUINT(jobData->archiveInfo.pgVersion)); protocolCommandParamAdd(command, VARUINT(jobData->archiveInfo.pgVersion));
protocolCommandParamAdd(command, VARUINT64(jobData->archiveInfo.pgSystemId)); protocolCommandParamAdd(command, VARUINT64(jobData->archiveInfo.pgSystemId));
@ -466,9 +466,9 @@ cmdArchivePushAsync(void)
THROW(AssertError, "no WAL files to process"); THROW(AssertError, "no WAL files to process");
LOG_INFO_FMT( LOG_INFO_FMT(
"push %u WAL file(s) to archive: %s%s", strLstSize(jobData.walFileList), strPtr(strLstGet(jobData.walFileList, 0)), "push %u WAL file(s) to archive: %s%s", strLstSize(jobData.walFileList), strZ(strLstGet(jobData.walFileList, 0)),
strLstSize(jobData.walFileList) == 1 ? strLstSize(jobData.walFileList) == 1 ?
"" : strPtr(strNewFmt("...%s", strPtr(strLstGet(jobData.walFileList, strLstSize(jobData.walFileList) - 1))))); "" : strZ(strNewFmt("...%s", strZ(strLstGet(jobData.walFileList, strLstSize(jobData.walFileList) - 1)))));
// Drop files if queue max has been exceeded // Drop files if queue max has been exceeded
if (cfgOptionTest(cfgOptArchivePushQueueMax) && archivePushDrop(jobData.walPath, jobData.walFileList)) if (cfgOptionTest(cfgOptArchivePushQueueMax) && archivePushDrop(jobData.walPath, jobData.walFileList))
@ -479,7 +479,7 @@ cmdArchivePushAsync(void)
const String *warning = archivePushDropWarning(walFile, cfgOptionUInt64(cfgOptArchivePushQueueMax)); const String *warning = archivePushDropWarning(walFile, cfgOptionUInt64(cfgOptArchivePushQueueMax));
archiveAsyncStatusOkWrite(archiveModePush, walFile, warning); archiveAsyncStatusOkWrite(archiveModePush, walFile, warning);
LOG_WARN(strPtr(warning)); LOG_WARN(strZ(warning));
} }
} }
// Else continue processing // Else continue processing
@ -519,7 +519,7 @@ cmdArchivePushAsync(void)
// The job was successful // The job was successful
if (protocolParallelJobErrorCode(job) == 0) if (protocolParallelJobErrorCode(job) == 0)
{ {
LOG_DETAIL_PID_FMT(processId, "pushed WAL file '%s' to the archive", strPtr(walFile)); LOG_DETAIL_PID_FMT(processId, "pushed WAL file '%s' to the archive", strZ(walFile));
archiveAsyncStatusOkWrite(archiveModePush, walFile, varStr(protocolParallelJobResult(job))); archiveAsyncStatusOkWrite(archiveModePush, walFile, varStr(protocolParallelJobResult(job)));
} }
// Else the job errored // Else the job errored
@ -527,8 +527,8 @@ cmdArchivePushAsync(void)
{ {
LOG_WARN_PID_FMT( LOG_WARN_PID_FMT(
processId, processId,
"could not push WAL file '%s' to the archive (will be retried): [%d] %s", strPtr(walFile), "could not push WAL file '%s' to the archive (will be retried): [%d] %s", strZ(walFile),
protocolParallelJobErrorCode(job), strPtr(protocolParallelJobErrorMessage(job))); protocolParallelJobErrorCode(job), strZ(protocolParallelJobErrorMessage(job)));
archiveAsyncStatusErrorWrite( archiveAsyncStatusErrorWrite(
archiveModePush, walFile, protocolParallelJobErrorCode(job), protocolParallelJobErrorMessage(job)); archiveModePush, walFile, protocolParallelJobErrorCode(job), protocolParallelJobErrorMessage(job));

View File

@ -114,11 +114,11 @@ backupLabelCreate(BackupType type, const String *backupLabelPrior, time_t timest
const StringList *historyList = strLstSort( const StringList *historyList = strLstSort(
storageListP( storageListP(
storageRepo(), storageRepo(),
strNewFmt(STORAGE_REPO_BACKUP "/" BACKUP_PATH_HISTORY "/%s", strPtr(strLstGet(historyYearList, 0))), strNewFmt(STORAGE_REPO_BACKUP "/" BACKUP_PATH_HISTORY "/%s", strZ(strLstGet(historyYearList, 0))),
.expression = strNewFmt( .expression = strNewFmt(
"%s\\.manifest\\.%s$", "%s\\.manifest\\.%s$",
strPtr(backupRegExpP(.full = true, .differential = true, .incremental = true, .noAnchorEnd = true)), strZ(backupRegExpP(.full = true, .differential = true, .incremental = true, .noAnchorEnd = true)),
strPtr(compressTypeStr(compressTypeGz)))), strZ(compressTypeStr(compressTypeGz)))),
sortOrderDesc); sortOrderDesc);
if (strLstSize(historyList) > 0) if (strLstSize(historyList) > 0)
@ -147,7 +147,7 @@ backupLabelCreate(BackupType type, const String *backupLabelPrior, time_t timest
"new backup label '%s' is not later than latest backup label '%s'\n" "new backup label '%s' is not later than latest backup label '%s'\n"
"HINT: has the timezone changed?\n" "HINT: has the timezone changed?\n"
"HINT: is there clock skew?", "HINT: is there clock skew?",
strPtr(result), strPtr(backupLabelLatest)); strZ(result), strZ(backupLabelLatest));
} }
// If adding a second worked then sleep the remainder of the current second so we don't start early // If adding a second worked then sleep the remainder of the current second so we don't start early
@ -211,7 +211,7 @@ backupInit(const InfoBackup *infoBackup)
{ {
THROW_FMT( THROW_FMT(
ConfigError, "option '" CFGOPT_BACKUP_STANDBY "' not valid for " PG_NAME " < %s", ConfigError, "option '" CFGOPT_BACKUP_STANDBY "' not valid for " PG_NAME " < %s",
strPtr(pgVersionToStr(PG_VERSION_BACKUP_STANDBY))); strZ(pgVersionToStr(PG_VERSION_BACKUP_STANDBY)));
} }
// Don't allow backup from standby when offline // Don't allow backup from standby when offline
@ -258,8 +258,8 @@ backupInit(const InfoBackup *infoBackup)
THROW_FMT( THROW_FMT(
BackupMismatchError, BackupMismatchError,
PG_NAME " version %s, system-id %" PRIu64 " do not match stanza version %s, system-id %" PRIu64 "\n" PG_NAME " version %s, system-id %" PRIu64 " do not match stanza version %s, system-id %" PRIu64 "\n"
"HINT: is this the correct stanza?", strPtr(pgVersionToStr(pgControl.version)), pgControl.systemId, "HINT: is this the correct stanza?", strZ(pgVersionToStr(pgControl.version)), pgControl.systemId,
strPtr(pgVersionToStr(infoPg.version)), infoPg.systemId); strZ(pgVersionToStr(infoPg.version)), infoPg.systemId);
} }
// Only allow stop auto in PostgreSQL >= 9.3 and <= 9.5 // Only allow stop auto in PostgreSQL >= 9.3 and <= 9.5
@ -382,21 +382,21 @@ backupBuildIncrPrior(const InfoBackup *infoBackup)
if (backupLabelPrior != NULL) if (backupLabelPrior != NULL)
{ {
result = manifestLoadFile( result = manifestLoadFile(
storageRepo(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strPtr(backupLabelPrior)), storageRepo(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strZ(backupLabelPrior)),
cipherType(cfgOptionStr(cfgOptRepoCipherType)), infoPgCipherPass(infoBackupPg(infoBackup))); cipherType(cfgOptionStr(cfgOptRepoCipherType)), infoPgCipherPass(infoBackupPg(infoBackup)));
const ManifestData *manifestPriorData = manifestData(result); const ManifestData *manifestPriorData = manifestData(result);
LOG_INFO_FMT( LOG_INFO_FMT(
"last backup label = %s, version = %s", strPtr(manifestData(result)->backupLabel), "last backup label = %s, version = %s", strZ(manifestData(result)->backupLabel),
strPtr(manifestData(result)->backrestVersion)); strZ(manifestData(result)->backrestVersion));
// Warn if compress-type option changed // Warn if compress-type option changed
if (compressTypeEnum(cfgOptionStr(cfgOptCompressType)) != manifestPriorData->backupOptionCompressType) if (compressTypeEnum(cfgOptionStr(cfgOptCompressType)) != manifestPriorData->backupOptionCompressType)
{ {
LOG_WARN_FMT( LOG_WARN_FMT(
"%s backup cannot alter " CFGOPT_COMPRESS_TYPE " option to '%s', reset to value in %s", "%s backup cannot alter " CFGOPT_COMPRESS_TYPE " option to '%s', reset to value in %s",
strPtr(cfgOptionStr(cfgOptType)), strZ(cfgOptionStr(cfgOptType)), strZ(compressTypeStr(compressTypeEnum(cfgOptionStr(cfgOptCompressType)))),
strPtr(compressTypeStr(compressTypeEnum(cfgOptionStr(cfgOptCompressType)))), strPtr(backupLabelPrior)); strZ(backupLabelPrior));
// Set the compression type back to whatever was in the prior backup. This is not strictly needed since we // Set the compression type back to whatever was in the prior backup. This is not strictly needed since we
// could store compression type on a per file basis, but it seems simplest and safest for now. // could store compression type on a per file basis, but it seems simplest and safest for now.
@ -420,8 +420,8 @@ backupBuildIncrPrior(const InfoBackup *infoBackup)
{ {
LOG_WARN_FMT( LOG_WARN_FMT(
"%s backup cannot alter hardlink option to '%s', reset to value in %s", "%s backup cannot alter hardlink option to '%s', reset to value in %s",
strPtr(cfgOptionStr(cfgOptType)), cvtBoolToConstZ(cfgOptionBool(cfgOptRepoHardlink)), strZ(cfgOptionStr(cfgOptType)), cvtBoolToConstZ(cfgOptionBool(cfgOptRepoHardlink)),
strPtr(backupLabelPrior)); strZ(backupLabelPrior));
cfgOptionSet(cfgOptRepoHardlink, cfgSourceParam, VARBOOL(manifestPriorData->backupOptionHardLink)); cfgOptionSet(cfgOptRepoHardlink, cfgSourceParam, VARBOOL(manifestPriorData->backupOptionHardLink));
} }
@ -442,8 +442,8 @@ backupBuildIncrPrior(const InfoBackup *infoBackup)
{ {
LOG_WARN_FMT( LOG_WARN_FMT(
"%s backup cannot alter '" CFGOPT_CHECKSUM_PAGE "' option to '%s', reset to '%s' from %s", "%s backup cannot alter '" CFGOPT_CHECKSUM_PAGE "' option to '%s', reset to '%s' from %s",
strPtr(cfgOptionStr(cfgOptType)), cvtBoolToConstZ(cfgOptionBool(cfgOptChecksumPage)), strZ(cfgOptionStr(cfgOptType)), cvtBoolToConstZ(cfgOptionBool(cfgOptChecksumPage)),
cvtBoolToConstZ(checksumPagePrior), strPtr(manifestData(result)->backupLabel)); cvtBoolToConstZ(checksumPagePrior), strZ(manifestData(result)->backupLabel));
} }
cfgOptionSet(cfgOptChecksumPage, cfgSourceParam, VARBOOL(checksumPagePrior)); cfgOptionSet(cfgOptChecksumPage, cfgSourceParam, VARBOOL(checksumPagePrior));
@ -453,7 +453,7 @@ backupBuildIncrPrior(const InfoBackup *infoBackup)
} }
else else
{ {
LOG_WARN_FMT("no prior backup exists, %s backup has been changed to full", strPtr(cfgOptionStr(cfgOptType))); LOG_WARN_FMT("no prior backup exists, %s backup has been changed to full", strZ(cfgOptionStr(cfgOptType)));
cfgOptionSet(cfgOptType, cfgSourceParam, VARSTR(backupTypeStr(backupTypeFull))); cfgOptionSet(cfgOptType, cfgSourceParam, VARSTR(backupTypeStr(backupTypeFull)));
} }
} }
@ -544,10 +544,10 @@ void backupResumeCallback(void *data, const StorageInfo *info)
// Build the name used to lookup files in the manifest // Build the name used to lookup files in the manifest
const String *manifestName = resumeData->manifestParentName != NULL ? const String *manifestName = resumeData->manifestParentName != NULL ?
strNewFmt("%s/%s", strPtr(resumeData->manifestParentName), strPtr(info->name)) : info->name; strNewFmt("%s/%s", strZ(resumeData->manifestParentName), strZ(info->name)) : info->name;
// Build the backup path used to remove files/links/paths that are invalid // Build the backup path used to remove files/links/paths that are invalid
const String *backupPath = strNewFmt("%s/%s", strPtr(resumeData->backupPath), strPtr(info->name)); const String *backupPath = strNewFmt("%s/%s", strZ(resumeData->backupPath), strZ(info->name));
// Process file types // Process file types
switch (info->type) switch (info->type)
@ -559,7 +559,7 @@ void backupResumeCallback(void *data, const StorageInfo *info)
// If the path was not found in the new manifest then remove it // If the path was not found in the new manifest then remove it
if (manifestPathFindDefault(resumeData->manifest, manifestName, NULL) == NULL) if (manifestPathFindDefault(resumeData->manifest, manifestName, NULL) == NULL)
{ {
LOG_DETAIL_FMT("remove path '%s' from resumed backup", strPtr(storagePathP(storageRepo(), backupPath))); LOG_DETAIL_FMT("remove path '%s' from resumed backup", strZ(storagePathP(storageRepo(), backupPath)));
storagePathRemoveP(storageRepoWrite(), backupPath, .recurse = true); storagePathRemoveP(storageRepoWrite(), backupPath, .recurse = true);
} }
// Else recurse into the path // Else recurse into the path
@ -622,7 +622,7 @@ void backupResumeCallback(void *data, const StorageInfo *info)
if (removeReason != NULL) if (removeReason != NULL)
{ {
LOG_DETAIL_FMT( LOG_DETAIL_FMT(
"remove file '%s' from resumed backup (%s)", strPtr(storagePathP(storageRepo(), backupPath)), removeReason); "remove file '%s' from resumed backup (%s)", strZ(storagePathP(storageRepo(), backupPath)), removeReason);
storageRemoveP(storageRepoWrite(), backupPath); storageRemoveP(storageRepoWrite(), backupPath);
} }
@ -642,7 +642,7 @@ void backupResumeCallback(void *data, const StorageInfo *info)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
case storageTypeSpecial: case storageTypeSpecial:
{ {
LOG_WARN_FMT("remove special file '%s' from resumed backup", strPtr(storagePathP(storageRepo(), backupPath))); LOG_WARN_FMT("remove special file '%s' from resumed backup", strZ(storagePathP(storageRepo(), backupPath)));
storageRemoveP(storageRepoWrite(), backupPath); storageRemoveP(storageRepoWrite(), backupPath);
break; break;
} }
@ -676,10 +676,10 @@ backupResumeFind(const Manifest *manifest, const String *cipherPassBackup)
if (strLstSize(backupList) > 0) if (strLstSize(backupList) > 0)
{ {
const String *backupLabel = strLstGet(backupList, 0); const String *backupLabel = strLstGet(backupList, 0);
const String *manifestFile = strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strPtr(backupLabel)); const String *manifestFile = strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strZ(backupLabel));
// Resumable backups have a copy of the manifest but no main // Resumable backups have a copy of the manifest but no main
if (storageExistsP(storageRepo(), strNewFmt("%s" INFO_COPY_EXT, strPtr(manifestFile))) && if (storageExistsP(storageRepo(), strNewFmt("%s" INFO_COPY_EXT, strZ(manifestFile))) &&
!storageExistsP(storageRepo(), manifestFile)) !storageExistsP(storageRepo(), manifestFile))
{ {
bool usable = false; bool usable = false;
@ -690,7 +690,7 @@ backupResumeFind(const Manifest *manifest, const String *cipherPassBackup)
// then the backup will be considered unusable and a resume will not be attempted. // then the backup will be considered unusable and a resume will not be attempted.
if (cfgOptionBool(cfgOptResume)) if (cfgOptionBool(cfgOptResume))
{ {
reason = strNewFmt("unable to read %s" INFO_COPY_EXT, strPtr(manifestFile)); reason = strNewFmt("unable to read %s" INFO_COPY_EXT, strZ(manifestFile));
TRY_BEGIN() TRY_BEGIN()
{ {
@ -704,31 +704,31 @@ backupResumeFind(const Manifest *manifest, const String *cipherPassBackup)
{ {
reason = strNewFmt( reason = strNewFmt(
"new " PROJECT_NAME " version '%s' does not match resumable " PROJECT_NAME " version '%s'", "new " PROJECT_NAME " version '%s' does not match resumable " PROJECT_NAME " version '%s'",
strPtr(manifestData(manifest)->backrestVersion), strPtr(manifestResumeData->backrestVersion)); strZ(manifestData(manifest)->backrestVersion), strZ(manifestResumeData->backrestVersion));
} }
// Check backup type because new backup label must be the same type as resume backup label // Check backup type because new backup label must be the same type as resume backup label
else if (manifestResumeData->backupType != backupType(cfgOptionStr(cfgOptType))) else if (manifestResumeData->backupType != backupType(cfgOptionStr(cfgOptType)))
{ {
reason = strNewFmt( reason = strNewFmt(
"new backup type '%s' does not match resumable backup type '%s'", strPtr(cfgOptionStr(cfgOptType)), "new backup type '%s' does not match resumable backup type '%s'", strZ(cfgOptionStr(cfgOptType)),
strPtr(backupTypeStr(manifestResumeData->backupType))); strZ(backupTypeStr(manifestResumeData->backupType)));
} }
// Check prior backup label ??? Do we really care about the prior backup label? // Check prior backup label ??? Do we really care about the prior backup label?
else if (!strEq(manifestResumeData->backupLabelPrior, manifestData(manifest)->backupLabelPrior)) else if (!strEq(manifestResumeData->backupLabelPrior, manifestData(manifest)->backupLabelPrior))
{ {
reason = strNewFmt( reason = strNewFmt(
"new prior backup label '%s' does not match resumable prior backup label '%s'", "new prior backup label '%s' does not match resumable prior backup label '%s'",
manifestResumeData->backupLabelPrior ? strPtr(manifestResumeData->backupLabelPrior) : "<undef>", manifestResumeData->backupLabelPrior ? strZ(manifestResumeData->backupLabelPrior) : "<undef>",
manifestData(manifest)->backupLabelPrior ? manifestData(manifest)->backupLabelPrior ?
strPtr(manifestData(manifest)->backupLabelPrior) : "<undef>"); strZ(manifestData(manifest)->backupLabelPrior) : "<undef>");
} }
// Check compression. Compression can't be changed between backups so resume won't work either. // Check compression. Compression can't be changed between backups so resume won't work either.
else if (manifestResumeData->backupOptionCompressType != compressTypeEnum(cfgOptionStr(cfgOptCompressType))) else if (manifestResumeData->backupOptionCompressType != compressTypeEnum(cfgOptionStr(cfgOptCompressType)))
{ {
reason = strNewFmt( reason = strNewFmt(
"new compression '%s' does not match resumable compression '%s'", "new compression '%s' does not match resumable compression '%s'",
strPtr(compressTypeStr(compressTypeEnum(cfgOptionStr(cfgOptCompressType)))), strZ(compressTypeStr(compressTypeEnum(cfgOptionStr(cfgOptCompressType)))),
strPtr(compressTypeStr(manifestResumeData->backupOptionCompressType))); strZ(compressTypeStr(manifestResumeData->backupOptionCompressType)));
} }
else else
usable = true; usable = true;
@ -747,10 +747,10 @@ backupResumeFind(const Manifest *manifest, const String *cipherPassBackup)
// Else warn and remove the unusable backup // Else warn and remove the unusable backup
else else
{ {
LOG_WARN_FMT("backup '%s' cannot be resumed: %s", strPtr(backupLabel), strPtr(reason)); LOG_WARN_FMT("backup '%s' cannot be resumed: %s", strZ(backupLabel), strZ(reason));
storagePathRemoveP( storagePathRemoveP(
storageRepoWrite(), strNewFmt(STORAGE_REPO_BACKUP "/%s", strPtr(backupLabel)), .recurse = true); storageRepoWrite(), strNewFmt(STORAGE_REPO_BACKUP "/%s", strZ(backupLabel)), .recurse = true);
} }
} }
} }
@ -787,7 +787,7 @@ backupResume(Manifest *manifest, const String *cipherPassBackup)
LOG_WARN_FMT( LOG_WARN_FMT(
"resumable backup %s of same type exists -- remove invalid files and resume", "resumable backup %s of same type exists -- remove invalid files and resume",
strPtr(manifestData(manifest)->backupLabel)); strZ(manifestData(manifest)->backupLabel));
// If resuming a full backup then copy cipher subpass since it was used to encrypt the resumable files // If resuming a full backup then copy cipher subpass since it was used to encrypt the resumable files
if (manifestData(manifest)->backupType == backupTypeFull) if (manifestData(manifest)->backupType == backupTypeFull)
@ -800,7 +800,7 @@ backupResume(Manifest *manifest, const String *cipherPassBackup)
.manifestResume = manifestResume, .manifestResume = manifestResume,
.compressType = compressTypeEnum(cfgOptionStr(cfgOptCompressType)), .compressType = compressTypeEnum(cfgOptionStr(cfgOptCompressType)),
.delta = cfgOptionBool(cfgOptDelta), .delta = cfgOptionBool(cfgOptDelta),
.backupPath = strNewFmt(STORAGE_REPO_BACKUP "/%s", strPtr(manifestData(manifest)->backupLabel)), .backupPath = strNewFmt(STORAGE_REPO_BACKUP "/%s", strZ(manifestData(manifest)->backupLabel)),
}; };
storageInfoListP(storageRepo(), resumeData.backupPath, backupResumeCallback, &resumeData, .sortOrder = sortOrderAsc); storageInfoListP(storageRepo(), resumeData.backupPath, backupResumeCallback, &resumeData, .sortOrder = sortOrderAsc);
@ -884,14 +884,14 @@ backupStart(BackupData *backupData)
} }
MEM_CONTEXT_PRIOR_END(); MEM_CONTEXT_PRIOR_END();
LOG_INFO_FMT("backup start archive = %s, lsn = %s", strPtr(result.walSegmentName), strPtr(result.lsn)); LOG_INFO_FMT("backup start archive = %s, lsn = %s", strZ(result.walSegmentName), strZ(result.lsn));
// Wait for replay on the standby to catch up // Wait for replay on the standby to catch up
if (cfgOptionBool(cfgOptBackupStandby)) if (cfgOptionBool(cfgOptBackupStandby))
{ {
LOG_INFO_FMT("wait for replay on the standby to reach %s", strPtr(result.lsn)); LOG_INFO_FMT("wait for replay on the standby to reach %s", strZ(result.lsn));
dbReplayWait(backupData->dbStandby, result.lsn, (TimeMSec)(cfgOptionDbl(cfgOptArchiveTimeout) * MSEC_PER_SEC)); dbReplayWait(backupData->dbStandby, result.lsn, (TimeMSec)(cfgOptionDbl(cfgOptArchiveTimeout) * MSEC_PER_SEC));
LOG_INFO_FMT("replay on the standby reached %s", strPtr(result.lsn)); LOG_INFO_FMT("replay on the standby reached %s", strZ(result.lsn));
// The standby db object won't be used anymore so free it // The standby db object won't be used anymore so free it
dbFree(backupData->dbStandby); dbFree(backupData->dbStandby);
@ -927,14 +927,14 @@ backupFilePut(BackupData *backupData, Manifest *manifest, const String *name, ti
MEM_CONTEXT_TEMP_BEGIN() MEM_CONTEXT_TEMP_BEGIN()
{ {
// Create file // Create file
const String *manifestName = strNewFmt(MANIFEST_TARGET_PGDATA "/%s", strPtr(name)); const String *manifestName = strNewFmt(MANIFEST_TARGET_PGDATA "/%s", strZ(name));
CompressType compressType = compressTypeEnum(cfgOptionStr(cfgOptCompressType)); CompressType compressType = compressTypeEnum(cfgOptionStr(cfgOptCompressType));
StorageWrite *write = storageNewWriteP( StorageWrite *write = storageNewWriteP(
storageRepoWrite(), storageRepoWrite(),
strNewFmt( strNewFmt(
STORAGE_REPO_BACKUP "/%s/%s%s", strPtr(manifestData(manifest)->backupLabel), strPtr(manifestName), STORAGE_REPO_BACKUP "/%s/%s%s", strZ(manifestData(manifest)->backupLabel), strZ(manifestName),
strPtr(compressExtStr(compressType))), strZ(compressExtStr(compressType))),
.compressible = true); .compressible = true);
IoFilterGroup *filterGroup = ioWriteFilterGroup(storageWriteIo(write)); IoFilterGroup *filterGroup = ioWriteFilterGroup(storageWriteIo(write));
@ -976,12 +976,12 @@ backupFilePut(BackupData *backupData, Manifest *manifest, const String *name, ti
}; };
memcpy( memcpy(
file.checksumSha1, strPtr(varStr(ioFilterGroupResult(filterGroup, CRYPTO_HASH_FILTER_TYPE_STR))), file.checksumSha1, strZ(varStr(ioFilterGroupResult(filterGroup, CRYPTO_HASH_FILTER_TYPE_STR))),
HASH_TYPE_SHA1_SIZE_HEX + 1); HASH_TYPE_SHA1_SIZE_HEX + 1);
manifestFileAdd(manifest, &file); manifestFileAdd(manifest, &file);
LOG_DETAIL_FMT("wrote '%s' file returned from pg_stop_backup()", strPtr(name)); LOG_DETAIL_FMT("wrote '%s' file returned from pg_stop_backup()", strZ(name));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
} }
@ -1031,7 +1031,7 @@ backupStop(BackupData *backupData, Manifest *manifest)
} }
MEM_CONTEXT_PRIOR_END(); MEM_CONTEXT_PRIOR_END();
LOG_INFO_FMT("backup stop archive = %s, lsn = %s", strPtr(result.walSegmentName), strPtr(result.lsn)); LOG_INFO_FMT("backup stop archive = %s, lsn = %s", strZ(result.walSegmentName), strZ(result.lsn));
// Save files returned by stop backup // Save files returned by stop backup
backupFilePut(backupData, manifest, STRDEF(PG_FILE_BACKUPLABEL), result.timestamp, dbBackupStopResult.backupLabel); backupFilePut(backupData, manifest, STRDEF(PG_FILE_BACKUPLABEL), result.timestamp, dbBackupStopResult.backupLabel);
@ -1087,32 +1087,32 @@ backupJobResult(
sizeCopied += copySize; sizeCopied += copySize;
// Create log file name // Create log file name
const String *fileLog = host == NULL ? fileName : strNewFmt("%s:%s", strPtr(host), strPtr(fileName)); const String *fileLog = host == NULL ? fileName : strNewFmt("%s:%s", strZ(host), strZ(fileName));
// Format log strings // Format log strings
const String *const logProgress = const String *const logProgress =
strNewFmt( strNewFmt(
"%s, %" PRIu64 "%%", strPtr(strSizeFormat(copySize)), sizeTotal == 0 ? 100 : sizeCopied * 100 / sizeTotal); "%s, %" PRIu64 "%%", strZ(strSizeFormat(copySize)), sizeTotal == 0 ? 100 : sizeCopied * 100 / sizeTotal);
const String *const logChecksum = copySize != 0 ? strNewFmt(" checksum %s", strPtr(copyChecksum)) : EMPTY_STR; const String *const logChecksum = copySize != 0 ? strNewFmt(" checksum %s", strZ(copyChecksum)) : EMPTY_STR;
// If the file is in a prior backup and nothing changed, just log it // If the file is in a prior backup and nothing changed, just log it
if (copyResult == backupCopyResultNoOp) if (copyResult == backupCopyResultNoOp)
{ {
LOG_DETAIL_PID_FMT( LOG_DETAIL_PID_FMT(
processId, "match file from prior backup %s (%s)%s", strPtr(fileLog), strPtr(logProgress), strPtr(logChecksum)); processId, "match file from prior backup %s (%s)%s", strZ(fileLog), strZ(logProgress), strZ(logChecksum));
} }
// Else if the repo matched the expect checksum, just log it // Else if the repo matched the expect checksum, just log it
else if (copyResult == backupCopyResultChecksum) else if (copyResult == backupCopyResultChecksum)
{ {
LOG_DETAIL_PID_FMT( LOG_DETAIL_PID_FMT(
processId, "checksum resumed file %s (%s)%s", strPtr(fileLog), strPtr(logProgress), strPtr(logChecksum)); processId, "checksum resumed file %s (%s)%s", strZ(fileLog), strZ(logProgress), strZ(logChecksum));
} }
// Else if the file was removed during backup add it to the list of files to be removed from the manifest when the // Else if the file was removed during backup add it to the list of files to be removed from the manifest when the
// backup is complete. It can't be removed right now because that will invalidate the pointers that are being used for // backup is complete. It can't be removed right now because that will invalidate the pointers that are being used for
// processing. // processing.
else if (copyResult == backupCopyResultSkip) else if (copyResult == backupCopyResultSkip)
{ {
LOG_DETAIL_PID_FMT(processId, "skip file removed by database %s", strPtr(fileLog)); LOG_DETAIL_PID_FMT(processId, "skip file removed by database %s", strZ(fileLog));
strLstAdd(fileRemove, file->name); strLstAdd(fileRemove, file->name);
} }
// Else file was copied so update manifest // Else file was copied so update manifest
@ -1128,11 +1128,10 @@ backupJobResult(
" continue but this may be an issue unless the resumed backup path in the repository is known to be" " continue but this may be an issue unless the resumed backup path in the repository is known to be"
" corrupted.\n" " corrupted.\n"
"NOTE: this does not indicate a problem with the PostgreSQL page checksums.", "NOTE: this does not indicate a problem with the PostgreSQL page checksums.",
strPtr(file->name), file->checksumSha1); strZ(file->name), file->checksumSha1);
} }
LOG_INFO_PID_FMT( LOG_INFO_PID_FMT(processId, "backup file %s (%s)%s", strZ(fileLog), strZ(logProgress), strZ(logChecksum));
processId, "backup file %s (%s)%s", strPtr(fileLog), strPtr(logProgress), strPtr(logChecksum));
// If the file had page checksums calculated during the copy // If the file had page checksums calculated during the copy
ASSERT((!file->checksumPage && checksumPageResult == NULL) || (file->checksumPage && checksumPageResult != NULL)); ASSERT((!file->checksumPage && checksumPageResult == NULL) || (file->checksumPage && checksumPageResult != NULL));
@ -1154,7 +1153,7 @@ backupJobResult(
// ??? Update formatting after migration // ??? Update formatting after migration
LOG_WARN_FMT( LOG_WARN_FMT(
"page misalignment in file %s: file size %" PRIu64 " is not divisible by page size %u", "page misalignment in file %s: file size %" PRIu64 " is not divisible by page size %u",
strPtr(fileLog), copySize, PG_PAGE_SIZE_DEFAULT); strZ(fileLog), copySize, PG_PAGE_SIZE_DEFAULT);
} }
else else
{ {
@ -1199,15 +1198,15 @@ backupJobResult(
// ??? Update formatting after migration // ??? Update formatting after migration
LOG_WARN_FMT( LOG_WARN_FMT(
"invalid page checksum%s found in file %s at page%s %s", strPtr(plural), strPtr(fileLog), "invalid page checksum%s found in file %s at page%s %s", strZ(plural), strZ(fileLog), strZ(plural),
strPtr(plural), strPtr(error)); strZ(error));
} }
} }
} }
// Update file info and remove any reference to the file's existence in a prior backup // Update file info and remove any reference to the file's existence in a prior backup
manifestFileUpdate( manifestFileUpdate(
manifest, file->name, copySize, repoSize, strPtr(copyChecksum), VARSTR(NULL), file->checksumPage, manifest, file->name, copySize, repoSize, strZ(copyChecksum), VARSTR(NULL), file->checksumPage,
checksumPageError, checksumPageErrorList); checksumPageError, checksumPageErrorList);
} }
} }
@ -1218,7 +1217,7 @@ backupJobResult(
} }
// Else the job errored // Else the job errored
else else
THROW_CODE(protocolParallelJobErrorCode(job), strPtr(protocolParallelJobErrorMessage(job))); THROW_CODE(protocolParallelJobErrorCode(job), strZ(protocolParallelJobErrorMessage(job)));
FUNCTION_LOG_RETURN(UINT64, sizeCopied); FUNCTION_LOG_RETURN(UINT64, sizeCopied);
} }
@ -1243,7 +1242,7 @@ backupManifestSaveCopy(Manifest *const manifest, const String *cipherPassBackup)
storageNewWriteP( storageNewWriteP(
storageRepoWrite(), storageRepoWrite(),
strNewFmt( strNewFmt(
STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE INFO_COPY_EXT, strPtr(manifestData(manifest)->backupLabel)))); STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE INFO_COPY_EXT, strZ(manifestData(manifest)->backupLabel))));
// Add encryption filter if required // Add encryption filter if required
cipherBlockFilterGroupAdd( cipherBlockFilterGroupAdd(
@ -1309,7 +1308,7 @@ backupProcessQueue(Manifest *manifest, List **queueList)
const ManifestTarget *target = manifestTarget(manifest, targetIdx); const ManifestTarget *target = manifestTarget(manifest, targetIdx);
if (target->tablespaceId != 0) if (target->tablespaceId != 0)
strLstAdd(targetList, strNewFmt("%s/", strPtr(target->name))); strLstAdd(targetList, strNewFmt("%s/", strZ(target->name)));
} }
// Generate the processing queues (there is always at least one) // Generate the processing queues (there is always at least one)
@ -1527,7 +1526,7 @@ backupProcess(BackupData *backupData, Manifest *manifest, const String *lsnStart
// Get backup info // Get backup info
const BackupType backupType = manifestData(manifest)->backupType; const BackupType backupType = manifestData(manifest)->backupType;
const String *const backupLabel = manifestData(manifest)->backupLabel; const String *const backupLabel = manifestData(manifest)->backupLabel;
const String *const backupPathExp = strNewFmt(STORAGE_REPO_BACKUP "/%s", strPtr(backupLabel)); const String *const backupPathExp = strNewFmt(STORAGE_REPO_BACKUP "/%s", strZ(backupLabel));
bool hardLink = cfgOptionBool(cfgOptRepoHardlink) && storageFeature(storageRepoWrite(), storageFeatureHardLink); bool hardLink = cfgOptionBool(cfgOptRepoHardlink) && storageFeature(storageRepoWrite(), storageFeatureHardLink);
bool backupStandby = cfgOptionBool(cfgOptBackupStandby); bool backupStandby = cfgOptionBool(cfgOptBackupStandby);
@ -1543,7 +1542,7 @@ backupProcess(BackupData *backupData, Manifest *manifest, const String *lsnStart
{ {
storagePathCreateP( storagePathCreateP(
storageRepoWrite(), storageRepoWrite(),
strNewFmt("%s/%s", strPtr(backupPathExp), strPtr(manifestPath(manifest, pathIdx)->name))); strNewFmt("%s/%s", strZ(backupPathExp), strZ(manifestPath(manifest, pathIdx)->name)));
} }
} }
@ -1558,13 +1557,13 @@ backupProcess(BackupData *backupData, Manifest *manifest, const String *lsnStart
{ {
const String *const link = storagePathP( const String *const link = storagePathP(
storageRepo(), storageRepo(),
strNewFmt("%s/" MANIFEST_TARGET_PGDATA "/%s", strPtr(backupPathExp), strPtr(target->name))); strNewFmt("%s/" MANIFEST_TARGET_PGDATA "/%s", strZ(backupPathExp), strZ(target->name)));
const String *const linkDestination = strNewFmt( const String *const linkDestination = strNewFmt(
"../../" MANIFEST_TARGET_PGTBLSPC "/%u", target->tablespaceId); "../../" MANIFEST_TARGET_PGTBLSPC "/%u", target->tablespaceId);
THROW_ON_SYS_ERROR_FMT( THROW_ON_SYS_ERROR_FMT(
symlink(strPtr(linkDestination), strPtr(link)) == -1, FileOpenError, symlink(strZ(linkDestination), strZ(link)) == -1, FileOpenError,
"unable to create symlink '%s' to '%s'", strPtr(link), strPtr(linkDestination)); "unable to create symlink '%s' to '%s'", strZ(link), strZ(linkDestination));
} }
} }
} }
@ -1660,7 +1659,7 @@ backupProcess(BackupData *backupData, Manifest *manifest, const String *lsnStart
manifestFileRemove(manifest, strLstGet(fileRemove, fileRemoveIdx)); manifestFileRemove(manifest, strLstGet(fileRemove, fileRemoveIdx));
// Log references or create hardlinks for all files // Log references or create hardlinks for all files
const char *const compressExt = strPtr(compressExtStr(jobData.compressType)); const char *const compressExt = strZ(compressExtStr(jobData.compressType));
for (unsigned int fileIdx = 0; fileIdx < manifestFileTotal(manifest); fileIdx++) for (unsigned int fileIdx = 0; fileIdx < manifestFileTotal(manifest); fileIdx++)
{ {
@ -1673,22 +1672,22 @@ backupProcess(BackupData *backupData, Manifest *manifest, const String *lsnStart
// If hardlinking is enabled then create a hardlink for files that have not changed since the last backup // If hardlinking is enabled then create a hardlink for files that have not changed since the last backup
if (hardLink) if (hardLink)
{ {
LOG_DETAIL_FMT("hardlink %s to %s", strPtr(file->name), strPtr(file->reference)); LOG_DETAIL_FMT("hardlink %s to %s", strZ(file->name), strZ(file->reference));
const String *const linkName = storagePathP( const String *const linkName = storagePathP(
storageRepo(), strNewFmt("%s/%s%s", strPtr(backupPathExp), strPtr(file->name), compressExt)); storageRepo(), strNewFmt("%s/%s%s", strZ(backupPathExp), strZ(file->name), compressExt));
const String *const linkDestination = storagePathP( const String *const linkDestination = storagePathP(
storageRepo(), storageRepo(),
strNewFmt(STORAGE_REPO_BACKUP "/%s/%s%s", strPtr(file->reference), strPtr(file->name), compressExt)); strNewFmt(STORAGE_REPO_BACKUP "/%s/%s%s", strZ(file->reference), strZ(file->name), compressExt));
THROW_ON_SYS_ERROR_FMT( THROW_ON_SYS_ERROR_FMT(
link(strPtr(linkDestination), strPtr(linkName)) == -1, FileOpenError, link(strZ(linkDestination), strZ(linkName)) == -1, FileOpenError,
"unable to create hardlink '%s' to '%s'", strPtr(linkName), strPtr(linkDestination)); "unable to create hardlink '%s' to '%s'", strZ(linkName), strZ(linkDestination));
} }
// Else log the reference. With delta, it is possible that references may have been removed if a file needed to be // Else log the reference. With delta, it is possible that references may have been removed if a file needed to be
// recopied. // recopied.
else else
LOG_DETAIL_FMT("reference %s to %s", strPtr(file->name), strPtr(file->reference)); LOG_DETAIL_FMT("reference %s to %s", strZ(file->name), strZ(file->reference));
} }
} }
@ -1697,14 +1696,14 @@ backupProcess(BackupData *backupData, Manifest *manifest, const String *lsnStart
{ {
for (unsigned int pathIdx = 0; pathIdx < manifestPathTotal(manifest); pathIdx++) for (unsigned int pathIdx = 0; pathIdx < manifestPathTotal(manifest); pathIdx++)
{ {
const String *const path = strNewFmt("%s/%s", strPtr(backupPathExp), strPtr(manifestPath(manifest, pathIdx)->name)); const String *const path = strNewFmt("%s/%s", strZ(backupPathExp), strZ(manifestPath(manifest, pathIdx)->name));
if (backupType == backupTypeFull || hardLink || storagePathExistsP(storageRepo(), path)) if (backupType == backupTypeFull || hardLink || storagePathExistsP(storageRepo(), path))
storagePathSyncP(storageRepoWrite(), path); storagePathSyncP(storageRepoWrite(), path);
} }
} }
LOG_INFO_FMT("%s backup size = %s", strPtr(backupTypeStr(backupType)), strPtr(strSizeFormat(sizeTotal))); LOG_INFO_FMT("%s backup size = %s", strZ(backupTypeStr(backupType)), strZ(strSizeFormat(sizeTotal)));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
@ -1732,13 +1731,13 @@ backupArchiveCheckCopy(Manifest *manifest, unsigned int walSegmentSize, const St
{ {
MEM_CONTEXT_TEMP_BEGIN() MEM_CONTEXT_TEMP_BEGIN()
{ {
unsigned int timeline = cvtZToUIntBase(strPtr(strSubN(manifestData(manifest)->archiveStart, 0, 8)), 16); unsigned int timeline = cvtZToUIntBase(strZ(strSubN(manifestData(manifest)->archiveStart, 0, 8)), 16);
uint64_t lsnStart = pgLsnFromStr(manifestData(manifest)->lsnStart); uint64_t lsnStart = pgLsnFromStr(manifestData(manifest)->lsnStart);
uint64_t lsnStop = pgLsnFromStr(manifestData(manifest)->lsnStop); uint64_t lsnStop = pgLsnFromStr(manifestData(manifest)->lsnStop);
LOG_INFO_FMT( LOG_INFO_FMT(
"check archive for segment(s) %s:%s", strPtr(pgLsnToWalSegment(timeline, lsnStart, walSegmentSize)), "check archive for segment(s) %s:%s", strZ(pgLsnToWalSegment(timeline, lsnStart, walSegmentSize)),
strPtr(pgLsnToWalSegment(timeline, lsnStop, walSegmentSize))); strZ(pgLsnToWalSegment(timeline, lsnStop, walSegmentSize)));
// Save the backup manifest before getting archive logs in case of failure // Save the backup manifest before getting archive logs in case of failure
backupManifestSaveCopy(manifest, cipherPassBackup); backupManifestSaveCopy(manifest, cipherPassBackup);
@ -1771,7 +1770,7 @@ backupArchiveCheckCopy(Manifest *manifest, unsigned int walSegmentSize, const St
// Open the archive file // Open the archive file
StorageRead *read = storageNewReadP( StorageRead *read = storageNewReadP(
storageRepo(), strNewFmt(STORAGE_REPO_ARCHIVE "/%s/%s", strPtr(archiveId), strPtr(archiveFile))); storageRepo(), strNewFmt(STORAGE_REPO_ARCHIVE "/%s/%s", strZ(archiveId), strZ(archiveFile)));
IoFilterGroup *filterGroup = ioReadFilterGroup(storageReadIo(read)); IoFilterGroup *filterGroup = ioReadFilterGroup(storageReadIo(read));
// Decrypt with archive key if encrypted // Decrypt with archive key if encrypted
@ -1799,15 +1798,15 @@ backupArchiveCheckCopy(Manifest *manifest, unsigned int walSegmentSize, const St
// Copy the file // Copy the file
const String *manifestName = strNewFmt( const String *manifestName = strNewFmt(
MANIFEST_TARGET_PGDATA "/%s/%s", strPtr(pgWalPath(manifestData(manifest)->pgVersion)), strPtr(walSegment)); MANIFEST_TARGET_PGDATA "/%s/%s", strZ(pgWalPath(manifestData(manifest)->pgVersion)), strZ(walSegment));
storageCopyP( storageCopyP(
read, read,
storageNewWriteP( storageNewWriteP(
storageRepoWrite(), storageRepoWrite(),
strNewFmt( strNewFmt(
STORAGE_REPO_BACKUP "/%s/%s%s", strPtr(manifestData(manifest)->backupLabel), strPtr(manifestName), STORAGE_REPO_BACKUP "/%s/%s%s", strZ(manifestData(manifest)->backupLabel), strZ(manifestName),
strPtr(compressExtStr(compressTypeEnum(cfgOptionStr(cfgOptCompressType))))))); strZ(compressExtStr(compressTypeEnum(cfgOptionStr(cfgOptCompressType)))))));
// Add to manifest // Add to manifest
ManifestFile file = ManifestFile file =
@ -1822,7 +1821,7 @@ backupArchiveCheckCopy(Manifest *manifest, unsigned int walSegmentSize, const St
.timestamp = manifestData(manifest)->backupTimestampStop, .timestamp = manifestData(manifest)->backupTimestampStop,
}; };
memcpy(file.checksumSha1, strPtr(strSubN(archiveFile, 25, 40)), HASH_TYPE_SHA1_SIZE_HEX + 1); memcpy(file.checksumSha1, strZ(strSubN(archiveFile, 25, 40)), HASH_TYPE_SHA1_SIZE_HEX + 1);
manifestFileAdd(manifest, &file); manifestFileAdd(manifest, &file);
} }
@ -1859,16 +1858,16 @@ backupComplete(InfoBackup *const infoBackup, Manifest *const manifest)
storageCopy( storageCopy(
storageNewReadP( storageNewReadP(
storageRepo(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE INFO_COPY_EXT, strPtr(backupLabel))), storageRepo(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE INFO_COPY_EXT, strZ(backupLabel))),
storageNewWriteP( storageNewWriteP(
storageRepoWrite(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strPtr(backupLabel)))); storageRepoWrite(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strZ(backupLabel))));
// Copy a compressed version of the manifest to history. If the repo is encrypted then the passphrase to open the manifest // Copy a compressed version of the manifest to history. If the repo is encrypted then the passphrase to open the manifest
// is required. We can't just do a straight copy since the destination needs to be compressed and that must happen before // is required. We can't just do a straight copy since the destination needs to be compressed and that must happen before
// encryption in order to be efficient. Compression will always be gz for compatibility and since it is always available. // encryption in order to be efficient. Compression will always be gz for compatibility and since it is always available.
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
StorageRead *manifestRead = storageNewReadP( StorageRead *manifestRead = storageNewReadP(
storageRepo(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strPtr(backupLabel))); storageRepo(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strZ(backupLabel)));
cipherBlockFilterGroupAdd( cipherBlockFilterGroupAdd(
ioReadFilterGroup(storageReadIo(manifestRead)), cipherType(cfgOptionStr(cfgOptRepoCipherType)), cipherModeDecrypt, ioReadFilterGroup(storageReadIo(manifestRead)), cipherType(cfgOptionStr(cfgOptRepoCipherType)), cipherModeDecrypt,
@ -1877,8 +1876,8 @@ backupComplete(InfoBackup *const infoBackup, Manifest *const manifest)
StorageWrite *manifestWrite = storageNewWriteP( StorageWrite *manifestWrite = storageNewWriteP(
storageRepoWrite(), storageRepoWrite(),
strNewFmt( strNewFmt(
STORAGE_REPO_BACKUP "/" BACKUP_PATH_HISTORY "/%s/%s.manifest%s", strPtr(strSubN(backupLabel, 0, 4)), STORAGE_REPO_BACKUP "/" BACKUP_PATH_HISTORY "/%s/%s.manifest%s", strZ(strSubN(backupLabel, 0, 4)),
strPtr(backupLabel), strPtr(compressExtStr(compressTypeGz)))); strZ(backupLabel), strZ(compressExtStr(compressTypeGz))));
ioFilterGroupAdd(ioWriteFilterGroup(storageWriteIo(manifestWrite)), compressFilter(compressTypeGz, 9)); ioFilterGroupAdd(ioWriteFilterGroup(storageWriteIo(manifestWrite)), compressFilter(compressTypeGz, 9));
@ -1997,7 +1996,7 @@ cmdBackup(void)
backupArchiveCheckCopy(manifest, backupData->walSegmentSize, cipherPassBackup); backupArchiveCheckCopy(manifest, backupData->walSegmentSize, cipherPassBackup);
// Complete the backup // Complete the backup
LOG_INFO_FMT("new backup label = %s", strPtr(manifestData(manifest)->backupLabel)); LOG_INFO_FMT("new backup label = %s", strZ(manifestData(manifest)->backupLabel));
backupComplete(infoBackup, manifest); backupComplete(infoBackup, manifest);
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();

View File

@ -104,7 +104,7 @@ backupType(const String *type)
else if (strEq(type, BACKUP_TYPE_INCR_STR)) else if (strEq(type, BACKUP_TYPE_INCR_STR))
result = backupTypeIncr; result = backupTypeIncr;
else else
THROW_FMT(AssertError, "invalid backup type '%s'", strPtr(type)); THROW_FMT(AssertError, "invalid backup type '%s'", strZ(type));
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -164,8 +164,8 @@ backupLinkLatest(const String *backupLabel)
if (storageFeature(storageRepoWrite(), storageFeatureSymLink)) if (storageFeature(storageRepoWrite(), storageFeatureSymLink))
{ {
THROW_ON_SYS_ERROR_FMT( THROW_ON_SYS_ERROR_FMT(
symlink(strPtr(backupLabel), strPtr(latestLink)) == -1, FileOpenError, symlink(strZ(backupLabel), strZ(latestLink)) == -1, FileOpenError, "unable to create symlink '%s' to '%s'",
"unable to create symlink '%s' to '%s'", strPtr(latestLink), strPtr(backupLabel)); strZ(latestLink), strZ(backupLabel));
} }
// Sync backup path if required // Sync backup path if required

View File

@ -30,7 +30,7 @@ segmentNumber(const String *pgFile)
FUNCTION_TEST_END(); FUNCTION_TEST_END();
// Determine which segment number this is by checking for a numeric extension. No extension means segment 0. // Determine which segment number this is by checking for a numeric extension. No extension means segment 0.
FUNCTION_TEST_RETURN(regExpMatchOne(STRDEF("\\.[0-9]+$"), pgFile) ? cvtZToUInt(strrchr(strPtr(pgFile), '.') + 1) : 0); FUNCTION_TEST_RETURN(regExpMatchOne(STRDEF("\\.[0-9]+$"), pgFile) ? cvtZToUInt(strrchr(strZ(pgFile), '.') + 1) : 0);
} }
/**********************************************************************************************************************************/ /**********************************************************************************************************************************/
@ -71,7 +71,7 @@ backupFile(
{ {
// Generate complete repo path and add compression extension if needed // Generate complete repo path and add compression extension if needed
const String *repoPathFile = strNewFmt( const String *repoPathFile = strNewFmt(
STORAGE_REPO_BACKUP "/%s/%s%s", strPtr(backupLabel), strPtr(repoFile), strPtr(compressExtStr(repoFileCompressType))); STORAGE_REPO_BACKUP "/%s/%s%s", strZ(backupLabel), strZ(repoFile), strZ(compressExtStr(repoFileCompressType)));
// If checksum is defined then the file needs to be checked. If delta option then check the DB and possibly the repo, else // If checksum is defined then the file needs to be checked. If delta option then check the DB and possibly the repo, else
// just check the repo. // just check the repo.

View File

@ -136,9 +136,8 @@ checkPrimary(const DbGetResult dbGroup)
const String *walSegmentFile = walSegmentFind(storageRepo(), archiveId, walSegment, archiveTimeout); const String *walSegmentFile = walSegmentFind(storageRepo(), archiveId, walSegment, archiveTimeout);
LOG_INFO_FMT( LOG_INFO_FMT(
"WAL segment %s successfully archived to '%s'", strPtr(walSegment), "WAL segment %s successfully archived to '%s'", strZ(walSegment),
strPtr(storagePathP(storageRepo(), strNewFmt(STORAGE_REPO_ARCHIVE "/%s/%s", strPtr(archiveId), strZ(storagePathP(storageRepo(), strNewFmt(STORAGE_REPO_ARCHIVE "/%s/%s", strZ(archiveId), strZ(walSegmentFile)))));
strPtr(walSegmentFile)))));
} }
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();

View File

@ -27,14 +27,14 @@ checkArchiveCommand(const String *archiveCommand)
bool result = archiveCommand != NULL; bool result = archiveCommand != NULL;
if (result && strstr(strPtr(archiveCommand), PROJECT_BIN) == NULL) if (result && strstr(strZ(archiveCommand), PROJECT_BIN) == NULL)
result = false; result = false;
if (!result) if (!result)
{ {
THROW_FMT( THROW_FMT(
ArchiveCommandInvalidError, "archive_command '%s' must contain %s", (archiveCommand != NULL ? strPtr(archiveCommand) ArchiveCommandInvalidError, "archive_command '%s' must contain %s",
: "[" NULL_Z "]"), PROJECT_BIN); archiveCommand != NULL ? strZ(archiveCommand) : "[" NULL_Z "]", PROJECT_BIN);
} }
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
@ -66,8 +66,8 @@ checkDbConfig(const unsigned int pgVersion, const unsigned int dbIdx, const Db *
THROW_FMT( THROW_FMT(
DbMismatchError, "version '%s' and path '%s' queried from cluster do not match version '%s' and '%s' read from '%s/" DbMismatchError, "version '%s' and path '%s' queried from cluster do not match version '%s' and '%s' read from '%s/"
PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL "'\nHINT: the %s and %s settings likely reference different clusters.", PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL "'\nHINT: the %s and %s settings likely reference different clusters.",
strPtr(pgVersionToStr(dbVersion)), strPtr(dbPath), strPtr(pgVersionToStr(pgVersion)), strPtr(cfgOptionStr(pgPath)), strZ(pgVersionToStr(dbVersion)), strZ(dbPath), strZ(pgVersionToStr(pgVersion)), strZ(cfgOptionStr(pgPath)),
strPtr(cfgOptionStr(pgPath)), cfgOptionName(pgPath), cfgOptionName(cfgOptPgPort + (dbIdx - 1))); strZ(cfgOptionStr(pgPath)), cfgOptionName(pgPath), cfgOptionName(cfgOptPgPort + (dbIdx - 1)));
} }
// Check archive configuration if option is valid for the command and set // Check archive configuration if option is valid for the command and set
@ -115,8 +115,8 @@ checkStanzaInfo(const InfoPgData *archiveInfo, const InfoPgData *backupInfo)
"archive: id = %u, version = %s, system-id = %" PRIu64 "\n" "archive: id = %u, version = %s, system-id = %" PRIu64 "\n"
"backup : id = %u, version = %s, system-id = %" PRIu64 "\n" "backup : id = %u, version = %s, system-id = %" PRIu64 "\n"
"HINT: this may be a symptom of repository corruption!", "HINT: this may be a symptom of repository corruption!",
archiveInfo->id, strPtr(pgVersionToStr(archiveInfo->version)), archiveInfo->systemId, backupInfo->id, archiveInfo->id, strZ(pgVersionToStr(archiveInfo->version)), archiveInfo->systemId, backupInfo->id,
strPtr(pgVersionToStr(backupInfo->version)), backupInfo->systemId); strZ(pgVersionToStr(backupInfo->version)), backupInfo->systemId);
} }
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();

View File

@ -47,7 +47,7 @@ cmdBegin(bool logOption)
MEM_CONTEXT_TEMP_BEGIN() MEM_CONTEXT_TEMP_BEGIN()
{ {
// Basic info on command start // Basic info on command start
String *info = strNewFmt("%s command begin", strPtr(cfgCommandRoleName())); String *info = strNewFmt("%s command begin", strZ(cfgCommandRoleName()));
if (logOption) if (logOption)
{ {
@ -70,8 +70,8 @@ cmdBegin(bool logOption)
if (commandParamIdx != 0) if (commandParamIdx != 0)
strCatFmt(info, ", "); strCatFmt(info, ", ");
if (strchr(strPtr(commandParam), ' ') != NULL) if (strchr(strZ(commandParam), ' ') != NULL)
commandParam = strNewFmt("\"%s\"", strPtr(commandParam)); commandParam = strNewFmt("\"%s\"", strZ(commandParam));
strCat(info, commandParam); strCat(info, commandParam);
} }
@ -123,8 +123,8 @@ cmdBegin(bool logOption)
strLstAdd( strLstAdd(
valueList, valueList,
strNewFmt( strNewFmt(
"%s=%s", strPtr(varStr(varLstGet(keyList, keyIdx))), "%s=%s", strZ(varStr(varLstGet(keyList, keyIdx))),
strPtr(varStrForce(kvGet(optionKv, varLstGet(keyList, keyIdx)))))); strZ(varStrForce(kvGet(optionKv, varLstGet(keyList, keyIdx))))));
} }
} }
// Generate values for list options // Generate values for list options
@ -146,17 +146,17 @@ cmdBegin(bool logOption)
strCatFmt(info, " --%s", cfgOptionName(optionId)); strCatFmt(info, " --%s", cfgOptionName(optionId));
if (strchr(strPtr(value), ' ') != NULL) if (strchr(strZ(value), ' ') != NULL)
value = strNewFmt("\"%s\"", strPtr(value)); value = strNewFmt("\"%s\"", strZ(value));
strCatFmt(info, "=%s", strPtr(value)); strCatFmt(info, "=%s", strZ(value));
} }
} }
} }
} }
} }
LOG(cfgLogLevelDefault(), 0, strPtr(info)); LOG(cfgLogLevelDefault(), 0, strZ(info));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
} }
@ -184,22 +184,22 @@ cmdEnd(int code, const String *errorMessage)
String *sckClientStat = sckClientStatStr(); String *sckClientStat = sckClientStatStr();
if (sckClientStat != NULL) if (sckClientStat != NULL)
LOG_DETAIL(strPtr(sckClientStat)); LOG_DETAIL(strZ(sckClientStat));
// Log tls statistics // Log tls statistics
String *tlsClientStat = tlsClientStatStr(); String *tlsClientStat = tlsClientStatStr();
if (tlsClientStat != NULL) if (tlsClientStat != NULL)
LOG_DETAIL(strPtr(tlsClientStat)); LOG_DETAIL(strZ(tlsClientStat));
// Log http statistics // Log http statistics
String *httpClientStat = httpClientStatStr(); String *httpClientStat = httpClientStatStr();
if (httpClientStat != NULL) if (httpClientStat != NULL)
LOG_INFO(strPtr(httpClientStat)); LOG_INFO(strZ(httpClientStat));
// Basic info on command end // Basic info on command end
String *info = strNewFmt("%s command end: ", strPtr(cfgCommandRoleName())); String *info = strNewFmt("%s command end: ", strZ(cfgCommandRoleName()));
if (errorMessage == NULL) if (errorMessage == NULL)
{ {
@ -211,7 +211,7 @@ cmdEnd(int code, const String *errorMessage)
else else
strCat(info, errorMessage); strCat(info, errorMessage);
LOG(cfgLogLevelDefault(), 0, strPtr(info)); LOG(cfgLogLevelDefault(), 0, strZ(info));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
} }

View File

@ -16,8 +16,7 @@ lockStopFileName(const String *stanza)
FUNCTION_TEST_PARAM(STRING, stanza); FUNCTION_TEST_PARAM(STRING, stanza);
FUNCTION_TEST_END(); FUNCTION_TEST_END();
String *result = strNewFmt( String *result = strNewFmt("%s/%s" STOP_FILE_EXT, strZ(cfgOptionStr(cfgOptLockPath)), stanza != NULL ? strZ(stanza) : "all");
"%s/%s" STOP_FILE_EXT, strPtr(cfgOptionStr(cfgOptLockPath)), stanza != NULL ? strPtr(stanza) : "all");
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -34,7 +33,7 @@ lockStopTest(void)
if (cfgOptionTest(cfgOptStanza)) if (cfgOptionTest(cfgOptStanza))
{ {
if (storageExistsP(storageLocal(), lockStopFileName(cfgOptionStr(cfgOptStanza)))) if (storageExistsP(storageLocal(), lockStopFileName(cfgOptionStr(cfgOptStanza))))
THROW_FMT(StopError, "stop file exists for stanza %s", strPtr(cfgOptionStr(cfgOptStanza))); THROW_FMT(StopError, "stop file exists for stanza %s", strZ(cfgOptionStr(cfgOptStanza)));
} }
// Check all stanzas // Check all stanzas

View File

@ -28,8 +28,9 @@ cmdStart(void)
} }
else else
{ {
LOG_WARN_FMT("stop file does not exist%s", LOG_WARN_FMT(
(cfgOptionTest(cfgOptStanza) ? strPtr(strNewFmt(" for stanza %s", strPtr(cfgOptionStr(cfgOptStanza)))) : "")); "stop file does not exist%s",
(cfgOptionTest(cfgOptStanza) ? strZ(strNewFmt(" for stanza %s", strZ(cfgOptionStr(cfgOptStanza)))) : ""));
} }
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();

View File

@ -37,8 +37,8 @@ cmdStop(void)
// Create the stop file with Read/Write and Create only - do not use Truncate // Create the stop file with Read/Write and Create only - do not use Truncate
int fileHandle = -1; int fileHandle = -1;
THROW_ON_SYS_ERROR_FMT( THROW_ON_SYS_ERROR_FMT(
((fileHandle = open(strPtr(stopFile), O_WRONLY | O_CREAT, STORAGE_MODE_FILE_DEFAULT)) == -1), FileOpenError, ((fileHandle = open(strZ(stopFile), O_WRONLY | O_CREAT, STORAGE_MODE_FILE_DEFAULT)) == -1), FileOpenError,
"unable to open stop file '%s'", strPtr(stopFile)); "unable to open stop file '%s'", strZ(stopFile));
// Close the file // Close the file
close(fileHandle); close(fileHandle);
@ -53,16 +53,16 @@ cmdStop(void)
// Find each lock file and send term signals to the processes // Find each lock file and send term signals to the processes
for (unsigned int lockPathFileIdx = 0; lockPathFileIdx < strLstSize(lockPathFileList); lockPathFileIdx++) for (unsigned int lockPathFileIdx = 0; lockPathFileIdx < strLstSize(lockPathFileList); lockPathFileIdx++)
{ {
String *lockFile = strNewFmt("%s/%s", strPtr(lockPath), strPtr(strLstGet(lockPathFileList, lockPathFileIdx))); String *lockFile = strNewFmt("%s/%s", strZ(lockPath), strZ(strLstGet(lockPathFileList, lockPathFileIdx)));
// Skip any file that is not a lock file // Skip any file that is not a lock file
if (!strEndsWithZ(lockFile, LOCK_FILE_EXT)) if (!strEndsWithZ(lockFile, LOCK_FILE_EXT))
continue; continue;
// If we cannot open the lock file for any reason then warn and continue to next file // If we cannot open the lock file for any reason then warn and continue to next file
if ((fileHandle = open(strPtr(lockFile), O_RDONLY, 0)) == -1) if ((fileHandle = open(strZ(lockFile), O_RDONLY, 0)) == -1)
{ {
LOG_WARN_FMT( "unable to open lock file %s", strPtr(lockFile)); LOG_WARN_FMT( "unable to open lock file %s", strZ(lockFile));
continue; continue;
} }
@ -70,7 +70,7 @@ cmdStop(void)
// the lock file so remove it now // the lock file so remove it now
if (flock(fileHandle, LOCK_EX | LOCK_NB) == 0) if (flock(fileHandle, LOCK_EX | LOCK_NB) == 0)
{ {
unlink(strPtr(lockFile)); unlink(strZ(lockFile));
close(fileHandle); close(fileHandle);
continue; continue;
} }
@ -83,14 +83,14 @@ cmdStop(void)
// If the process id is defined then assume this is a valid lock file // If the process id is defined then assume this is a valid lock file
if (processId != NULL && strSize(processId) > 0) if (processId != NULL && strSize(processId) > 0)
{ {
if (kill(cvtZToInt(strPtr(processId)), SIGTERM) != 0) if (kill(cvtZToInt(strZ(processId)), SIGTERM) != 0)
LOG_WARN_FMT("unable to send term signal to process %s", strPtr(processId)); LOG_WARN_FMT("unable to send term signal to process %s", strZ(processId));
else else
LOG_INFO_FMT("sent term signal to process %s", strPtr(processId)); LOG_INFO_FMT("sent term signal to process %s", strZ(processId));
} }
else else
{ {
unlink(strPtr(lockFile)); unlink(strZ(lockFile));
close(fileHandle); close(fileHandle);
} }
} }
@ -100,7 +100,7 @@ cmdStop(void)
{ {
LOG_WARN_FMT( LOG_WARN_FMT(
"stop file already exists for %s", "stop file already exists for %s",
cfgOptionTest(cfgOptStanza) ? strPtr(strNewFmt("stanza %s", strPtr(cfgOptionStr(cfgOptStanza)))) : "all stanzas"); cfgOptionTest(cfgOptStanza) ? strZ(strNewFmt("stanza %s", strZ(cfgOptionStr(cfgOptStanza)))) : "all stanzas");
} }
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();

View File

@ -34,8 +34,8 @@ archiveIdComparator(const void *item1, const void *item2)
{ {
StringList *archiveSort1 = strLstNewSplitZ(*(String **)item1, "-"); StringList *archiveSort1 = strLstNewSplitZ(*(String **)item1, "-");
StringList *archiveSort2 = strLstNewSplitZ(*(String **)item2, "-"); StringList *archiveSort2 = strLstNewSplitZ(*(String **)item2, "-");
int int1 = atoi(strPtr(strLstGet(archiveSort1, 1))); int int1 = atoi(strZ(strLstGet(archiveSort1, 1)));
int int2 = atoi(strPtr(strLstGet(archiveSort2, 1))); int int2 = atoi(strZ(strLstGet(archiveSort2, 1)));
return (int1 - int2); return (int1 - int2);
} }
@ -79,10 +79,10 @@ expireBackup(InfoBackup *infoBackup, const String *backupLabel)
{ {
// Remove the manifest files to invalidate the backup // Remove the manifest files to invalidate the backup
storageRemoveP( storageRemoveP(
storageRepoWrite(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strPtr(removeBackupLabel))); storageRepoWrite(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strZ(removeBackupLabel)));
storageRemoveP( storageRemoveP(
storageRepoWrite(), storageRepoWrite(),
strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE INFO_COPY_EXT, strPtr(removeBackupLabel))); strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE INFO_COPY_EXT, strZ(removeBackupLabel)));
} }
// Remove the backup from the info object // Remove the backup from the info object
@ -119,14 +119,14 @@ expireAdhocBackup(InfoBackup *infoBackup, const String *backupLabel)
// If the label format is invalid, then error // If the label format is invalid, then error
if (!regExpMatchOne(backupRegExpP(.full = true, .differential = true, .incremental = true), backupLabel)) if (!regExpMatchOne(backupRegExpP(.full = true, .differential = true, .incremental = true), backupLabel))
{ {
THROW_FMT(OptionInvalidValueError, "'%s' is not a valid backup label format", strPtr(backupLabel)); THROW_FMT(OptionInvalidValueError, "'%s' is not a valid backup label format", strZ(backupLabel));
} }
// If the label is not a current backup then notify user and exit // If the label is not a current backup then notify user and exit
if (infoBackupDataByLabel(infoBackup, backupLabel) == NULL) if (infoBackupDataByLabel(infoBackup, backupLabel) == NULL)
{ {
LOG_WARN_FMT( LOG_WARN_FMT(
"backup %s does not exist\nHINT: run the info command and confirm the backup is listed", strPtr(backupLabel)); "backup %s does not exist\nHINT: run the info command and confirm the backup is listed", strZ(backupLabel));
} }
else else
{ {
@ -143,7 +143,7 @@ expireAdhocBackup(InfoBackup *infoBackup, const String *backupLabel)
{ {
THROW_FMT( THROW_FMT(
BackupSetInvalidError, "full backup %s cannot be expired until another full backup has been created", BackupSetInvalidError, "full backup %s cannot be expired until another full backup has been created",
strPtr(backupLabel)); strZ(backupLabel));
} }
} }
@ -167,7 +167,7 @@ expireAdhocBackup(InfoBackup *infoBackup, const String *backupLabel)
LOG_WARN_FMT( LOG_WARN_FMT(
"expiring latest backup %s - the ability to perform point-in-time-recovery (PITR) may be affected\n" "expiring latest backup %s - the ability to perform point-in-time-recovery (PITR) may be affected\n"
"HINT: non-default settings for '%s'/'%s' (even in prior expires) can cause gaps in the WAL.", "HINT: non-default settings for '%s'/'%s' (even in prior expires) can cause gaps in the WAL.",
strPtr(latestBackup), cfgOptionName(cfgOptRepoRetentionArchive), cfgOptionName(cfgOptRepoRetentionArchiveType)); strZ(latestBackup), cfgOptionName(cfgOptRepoRetentionArchive), cfgOptionName(cfgOptRepoRetentionArchiveType));
// Adhoc expire is never performed through backup command so only check to determine if dry-run has been set or not // Adhoc expire is never performed through backup command so only check to determine if dry-run has been set or not
if (!cfgOptionBool(cfgOptDryRun)) if (!cfgOptionBool(cfgOptDryRun))
@ -177,7 +177,7 @@ expireAdhocBackup(InfoBackup *infoBackup, const String *backupLabel)
result = strLstSize(backupExpired); result = strLstSize(backupExpired);
// Log the expired backup list (prepend "set:" if there were any dependents that were also expired) // Log the expired backup list (prepend "set:" if there were any dependents that were also expired)
LOG_INFO_FMT("expire adhoc backup %s%s", (result > 1 ? "set: " : ""), strPtr(strLstJoin(backupExpired, ", "))); LOG_INFO_FMT("expire adhoc backup %s%s", (result > 1 ? "set: " : ""), strZ(strLstJoin(backupExpired, ", ")));
} }
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
@ -228,7 +228,7 @@ expireDiffBackup(InfoBackup *infoBackup)
// Log the expired backups. If there is more than one backup, then prepend "set:" // Log the expired backups. If there is more than one backup, then prepend "set:"
LOG_INFO_FMT( LOG_INFO_FMT(
"expire diff backup %s%s", (strLstSize(backupExpired) > 1 ? "set: " : ""), "expire diff backup %s%s", (strLstSize(backupExpired) > 1 ? "set: " : ""),
strPtr(strLstJoin(backupExpired, ", "))); strZ(strLstJoin(backupExpired, ", ")));
} }
} }
} }
@ -276,7 +276,7 @@ expireFullBackup(InfoBackup *infoBackup)
// Log the expired backups. If there is more than one backup, then prepend "set:" // Log the expired backups. If there is more than one backup, then prepend "set:"
LOG_INFO_FMT( LOG_INFO_FMT(
"expire full backup %s%s", (strLstSize(backupExpired) > 1 ? "set: " : ""), "expire full backup %s%s", (strLstSize(backupExpired) > 1 ? "set: " : ""),
strPtr(strLstJoin(backupExpired, ", "))); strZ(strLstJoin(backupExpired, ", ")));
} }
} }
} }
@ -344,7 +344,7 @@ expireTimeBasedBackup(InfoBackup *infoBackup, const time_t minTimestamp)
// Log the expired backups. If there is more than one backup, then prepend "set:" // Log the expired backups. If there is more than one backup, then prepend "set:"
LOG_INFO_FMT( LOG_INFO_FMT(
"expire time-based backup %s%s", (strLstSize(backupExpired) > 1 ? "set: " : ""), "expire time-based backup %s%s", (strLstSize(backupExpired) > 1 ? "set: " : ""),
strPtr(strLstJoin(backupExpired, ", "))); strZ(strLstJoin(backupExpired, ", ")));
} }
if (strEqZ(cfgOptionStr(cfgOptRepoRetentionArchiveType), CFGOPTVAL_TMP_REPO_RETENTION_ARCHIVE_TYPE_FULL) && if (strEqZ(cfgOptionStr(cfgOptRepoRetentionArchiveType), CFGOPTVAL_TMP_REPO_RETENTION_ARCHIVE_TYPE_FULL) &&
@ -370,8 +370,8 @@ logExpire(ArchiveExpired *archiveExpire, String *archiveId)
{ {
// Force out any remaining message // Force out any remaining message
LOG_DETAIL_FMT( LOG_DETAIL_FMT(
"remove archive: archiveId = %s, start = %s, stop = %s", strPtr(archiveId), strPtr(archiveExpire->start), "remove archive: archiveId = %s, start = %s, stop = %s", strZ(archiveId), strZ(archiveExpire->start),
strPtr(archiveExpire->stop)); strZ(archiveExpire->stop));
archiveExpire->start = NULL; archiveExpire->start = NULL;
} }
@ -404,9 +404,9 @@ removeExpiredArchive(InfoBackup *infoBackup, bool timeBasedFullRetention)
// Only notify user if not time-based retention // Only notify user if not time-based retention
if (!timeBasedFullRetention) if (!timeBasedFullRetention)
LOG_INFO_FMT("option '%s' is not set %s", cfgOptionName(cfgOptRepoRetentionArchive), strPtr(msg)); LOG_INFO_FMT("option '%s' is not set %s", cfgOptionName(cfgOptRepoRetentionArchive), strZ(msg));
else else
LOG_INFO_FMT("time-based archive retention not met %s", strPtr(msg)); LOG_INFO_FMT("time-based archive retention not met %s", strZ(msg));
} }
else else
{ {
@ -497,7 +497,7 @@ removeExpiredArchive(InfoBackup *infoBackup, bool timeBasedFullRetention)
continue; continue;
StringList *archiveSplit = strLstNewSplitZ(archiveId, "-"); StringList *archiveSplit = strLstNewSplitZ(archiveId, "-");
unsigned int archivePgId = cvtZToUInt(strPtr(strLstGet(archiveSplit, 1))); unsigned int archivePgId = cvtZToUInt(strZ(strLstGet(archiveSplit, 1)));
// From the global list of backups to retain, create a list of backups, oldest to newest, associated with // From the global list of backups to retain, create a list of backups, oldest to newest, associated with
// this archiveId (e.g. 9.4-1), e.g. If globalBackupRetention has 4F, 3F, 2F, 1F then // this archiveId (e.g. 9.4-1), e.g. If globalBackupRetention has 4F, 3F, 2F, 1F then
@ -527,9 +527,9 @@ removeExpiredArchive(InfoBackup *infoBackup, bool timeBasedFullRetention)
if (currentPg.id != archivePgId) if (currentPg.id != archivePgId)
{ {
String *fullPath = storagePathP( String *fullPath = storagePathP(
storageRepo(), strNewFmt(STORAGE_REPO_ARCHIVE "/%s", strPtr(archiveId))); storageRepo(), strNewFmt(STORAGE_REPO_ARCHIVE "/%s", strZ(archiveId)));
LOG_INFO_FMT("remove archive path: %s", strPtr(fullPath)); LOG_INFO_FMT("remove archive path: %s", strZ(fullPath));
// Execute the real expiration and deletion only if the dry-run option is disabled // Execute the real expiration and deletion only if the dry-run option is disabled
if (!cfgOptionValid(cfgOptDryRun) || !cfgOptionBool(cfgOptDryRun)) if (!cfgOptionValid(cfgOptDryRun) || !cfgOptionBool(cfgOptDryRun))
@ -622,9 +622,8 @@ removeExpiredArchive(InfoBackup *infoBackup, bool timeBasedFullRetention)
LOG_DETAIL_FMT( LOG_DETAIL_FMT(
"archive retention on backup %s, archiveId = %s, start = %s%s", "archive retention on backup %s, archiveId = %s, start = %s%s",
strPtr(backupData->backupLabel), strPtr(archiveId), strPtr(archiveRange.start), strZ(backupData->backupLabel), strZ(archiveId), strZ(archiveRange.start),
archiveRange.stop != NULL ? archiveRange.stop != NULL ? strZ(strNewFmt(", stop = %s", strZ(archiveRange.stop))) : "");
strPtr(strNewFmt(", stop = %s", strPtr(archiveRange.stop))) : "");
// Add the archive range to the list // Add the archive range to the list
lstAdd(archiveRangeList, &archiveRange); lstAdd(archiveRangeList, &archiveRange);
@ -635,7 +634,7 @@ removeExpiredArchive(InfoBackup *infoBackup, bool timeBasedFullRetention)
StringList *walPathList = StringList *walPathList =
strLstSort( strLstSort(
storageListP( storageListP(
storageRepo(), strNewFmt(STORAGE_REPO_ARCHIVE "/%s", strPtr(archiveId)), storageRepo(), strNewFmt(STORAGE_REPO_ARCHIVE "/%s", strZ(archiveId)),
.expression = STRDEF(WAL_SEGMENT_DIR_REGEXP)), .expression = STRDEF(WAL_SEGMENT_DIR_REGEXP)),
sortOrderAsc); sortOrderAsc);
@ -665,7 +664,7 @@ removeExpiredArchive(InfoBackup *infoBackup, bool timeBasedFullRetention)
{ {
storagePathRemoveP( storagePathRemoveP(
storageRepoWrite(), storageRepoWrite(),
strNewFmt(STORAGE_REPO_ARCHIVE "/%s/%s", strPtr(archiveId), strPtr(walPath)), strNewFmt(STORAGE_REPO_ARCHIVE "/%s/%s", strZ(archiveId), strZ(walPath)),
.recurse = true); .recurse = true);
} }
@ -683,7 +682,7 @@ removeExpiredArchive(InfoBackup *infoBackup, bool timeBasedFullRetention)
strLstSort( strLstSort(
storageListP( storageListP(
storageRepo(), storageRepo(),
strNewFmt(STORAGE_REPO_ARCHIVE "/%s/%s", strPtr(archiveId), strPtr(walPath)), strNewFmt(STORAGE_REPO_ARCHIVE "/%s/%s", strZ(archiveId), strZ(walPath)),
.expression = STRDEF("^[0-F]{24}.*$")), .expression = STRDEF("^[0-F]{24}.*$")),
sortOrderAsc); sortOrderAsc);
@ -715,8 +714,8 @@ removeExpiredArchive(InfoBackup *infoBackup, bool timeBasedFullRetention)
storageRemoveP( storageRemoveP(
storageRepoWrite(), storageRepoWrite(),
strNewFmt( strNewFmt(
STORAGE_REPO_ARCHIVE "/%s/%s/%s", strPtr(archiveId), strPtr(walPath), STORAGE_REPO_ARCHIVE "/%s/%s/%s", strZ(archiveId), strZ(walPath),
strPtr(walSubPath))); strZ(walSubPath)));
} }
// Track that this archive was removed // Track that this archive was removed
@ -734,7 +733,7 @@ removeExpiredArchive(InfoBackup *infoBackup, bool timeBasedFullRetention)
// Log if no archive was expired // Log if no archive was expired
if (archiveExpire.total == 0) if (archiveExpire.total == 0)
{ {
LOG_DETAIL_FMT("no archive to remove, archiveId = %s", strPtr(archiveId)); LOG_DETAIL_FMT("no archive to remove, archiveId = %s", strZ(archiveId));
} }
// Log if there is more to log // Log if there is more to log
else else
@ -780,8 +779,8 @@ removeExpiredBackup(InfoBackup *infoBackup, const String *adhocBackupLabel)
if (adhocBackupLabel != NULL) if (adhocBackupLabel != NULL)
{ {
String *manifestFileName = strNewFmt( String *manifestFileName = strNewFmt(
STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strPtr(strLstGet(backupList, backupIdx))); STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strZ(strLstGet(backupList, backupIdx)));
String *manifestCopyFileName = strNewFmt("%s" INFO_COPY_EXT, strPtr(manifestFileName)); String *manifestCopyFileName = strNewFmt("%s" INFO_COPY_EXT, strZ(manifestFileName));
// If the latest backup is resumable (has a backup.manifest.copy but no backup.manifest) // If the latest backup is resumable (has a backup.manifest.copy but no backup.manifest)
if (!storageExistsP(storageRepo(), manifestFileName) && storageExistsP(storageRepo(), manifestCopyFileName)) if (!storageExistsP(storageRepo(), manifestFileName) && storageExistsP(storageRepo(), manifestCopyFileName))
@ -810,13 +809,13 @@ removeExpiredBackup(InfoBackup *infoBackup, const String *adhocBackupLabel)
{ {
if (!strLstExists(currentBackupList, strLstGet(backupList, backupIdx))) if (!strLstExists(currentBackupList, strLstGet(backupList, backupIdx)))
{ {
LOG_INFO_FMT("remove expired backup %s", strPtr(strLstGet(backupList, backupIdx))); LOG_INFO_FMT("remove expired backup %s", strZ(strLstGet(backupList, backupIdx)));
// Execute the real expiration and deletion only if the dry-run mode is disabled // Execute the real expiration and deletion only if the dry-run mode is disabled
if (!cfgOptionValid(cfgOptDryRun) || !cfgOptionBool(cfgOptDryRun)) if (!cfgOptionValid(cfgOptDryRun) || !cfgOptionBool(cfgOptDryRun))
{ {
storagePathRemoveP( storagePathRemoveP(
storageRepoWrite(), strNewFmt(STORAGE_REPO_BACKUP "/%s", strPtr(strLstGet(backupList, backupIdx))), storageRepoWrite(), strNewFmt(STORAGE_REPO_BACKUP "/%s", strZ(strLstGet(backupList, backupIdx))),
.recurse = true); .recurse = true);
} }
} }

View File

@ -104,8 +104,8 @@ helpRenderValue(const Variant *value)
strCatZ(resultTemp, ", "); strCatZ(resultTemp, ", ");
strCatFmt( strCatFmt(
resultTemp, "%s=%s", strPtr(varStr(varLstGet(keyList, keyIdx))), resultTemp, "%s=%s", strZ(varStr(varLstGet(keyList, keyIdx))),
strPtr(varStrForce(kvGet(optionKv, varLstGet(keyList, keyIdx))))); strZ(varStrForce(kvGet(optionKv, varLstGet(keyList, keyIdx)))));
} }
result = resultTemp; result = resultTemp;
@ -121,7 +121,7 @@ helpRenderValue(const Variant *value)
if (listIdx != 0) if (listIdx != 0)
strCatZ(resultTemp, ", "); strCatZ(resultTemp, ", ");
strCatFmt(resultTemp, "%s", strPtr(varStr(varLstGet(list, listIdx)))); strCatFmt(resultTemp, "%s", strZ(varStr(varLstGet(list, listIdx))));
} }
result = resultTemp; result = resultTemp;
@ -181,7 +181,7 @@ helpRender(void)
strCatFmt( strCatFmt(
result, " %s%*s%s\n", cfgCommandName(commandId), result, " %s%*s%s\n", cfgCommandName(commandId),
(int)(commandSizeMax - strlen(cfgCommandName(commandId)) + 2), "", (int)(commandSizeMax - strlen(cfgCommandName(commandId)) + 2), "",
strPtr( strZ(
helpRenderText( helpRenderText(
STR(cfgDefCommandHelpSummary(cfgCommandDefIdFromId(commandId))), commandSizeMax + 6, false, STR(cfgDefCommandHelpSummary(cfgCommandDefIdFromId(commandId))), commandSizeMax + 6, false,
CONSOLE_WIDTH))); CONSOLE_WIDTH)));
@ -210,8 +210,8 @@ helpRender(void)
"%s\n" "%s\n"
"\n" "\n"
"%s\n", "%s\n",
strPtr(helpRenderText(STR(cfgDefCommandHelpSummary(commandDefId)), 0, true, CONSOLE_WIDTH)), strZ(helpRenderText(STR(cfgDefCommandHelpSummary(commandDefId)), 0, true, CONSOLE_WIDTH)),
strPtr(helpRenderText(STR(cfgDefCommandHelpDescription(commandDefId)), 0, true, CONSOLE_WIDTH))); strZ(helpRenderText(STR(cfgDefCommandHelpDescription(commandDefId)), 0, true, CONSOLE_WIDTH)));
// Construct key/value of sections and options // Construct key/value of sections and options
KeyValue *optionKv = kvNew(); KeyValue *optionKv = kvNew();
@ -247,7 +247,7 @@ helpRender(void)
{ {
const String *section = strLstGet(sectionList, sectionIdx); const String *section = strLstGet(sectionList, sectionIdx);
strCatFmt(result, "\n%s Options:\n\n", strPtr(strFirstUpper(strDup(section)))); strCatFmt(result, "\n%s Options:\n\n", strZ(strFirstUpper(strDup(section))));
// Output options // Output options
VariantList *optionList = kvGetList(optionKv, VARSTR(section)); VariantList *optionList = kvGetList(optionKv, VARSTR(section));
@ -274,14 +274,14 @@ helpRender(void)
strCatZ(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>" : strZ(value));
if (defaultValue != NULL) if (defaultValue != NULL)
{ {
if (value != NULL) if (value != NULL)
strCatZ(summary, ", "); strCatZ(summary, ", ");
strCatFmt(summary, "default=%s", strPtr(defaultValue)); strCatFmt(summary, "default=%s", strZ(defaultValue));
} }
strCatZ(summary, "]"); strCatZ(summary, "]");
@ -291,7 +291,7 @@ helpRender(void)
strCatFmt( strCatFmt(
result, " --%s%*s%s\n", result, " --%s%*s%s\n",
cfgDefOptionName(optionDefId), (int)(optionSizeMax - strlen(cfgDefOptionName(optionDefId)) + 2), "", cfgDefOptionName(optionDefId), (int)(optionSizeMax - strlen(cfgDefOptionName(optionDefId)) + 2), "",
strPtr(helpRenderText(summary, optionSizeMax + 6, false, CONSOLE_WIDTH))); strZ(helpRenderText(summary, optionSizeMax + 6, false, CONSOLE_WIDTH)));
} }
} }
@ -307,7 +307,7 @@ helpRender(void)
THROW(ParamInvalidError, "only one option allowed for option help"); THROW(ParamInvalidError, "only one option allowed for option help");
// Ensure the option is valid // Ensure the option is valid
const char *optionName = strPtr(strLstGet(cfgCommandParam(), 0)); const char *optionName = strZ(strLstGet(cfgCommandParam(), 0));
ConfigOption optionId = cfgOptionId(optionName); ConfigOption optionId = cfgOptionId(optionName);
if (cfgOptionId(optionName) == -1) if (cfgOptionId(optionName) == -1)
@ -329,8 +329,8 @@ helpRender(void)
"\n" "\n"
"%s\n", "%s\n",
optionName, optionName,
strPtr(helpRenderText(STR(cfgDefOptionHelpSummary(commandDefId, optionDefId)), 0, true, CONSOLE_WIDTH)), strZ(helpRenderText(STR(cfgDefOptionHelpSummary(commandDefId, optionDefId)), 0, true, CONSOLE_WIDTH)),
strPtr(helpRenderText(STR(cfgDefOptionHelpDescription(commandDefId, optionDefId)), 0, true, CONSOLE_WIDTH))); strZ(helpRenderText(STR(cfgDefOptionHelpDescription(commandDefId, optionDefId)), 0, true, CONSOLE_WIDTH)));
// Ouput current and default values if they exist // Ouput current and default values if they exist
const String *defaultValue = helpRenderValue(cfgOptionDefault(optionId)); const String *defaultValue = helpRenderValue(cfgOptionDefault(optionId));
@ -344,10 +344,10 @@ helpRender(void)
strCat(result, LF_STR); 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>" : strZ(value));
if (defaultValue != NULL) if (defaultValue != NULL)
strCatFmt(result, "default: %s\n", strPtr(defaultValue)); strCatFmt(result, "default: %s\n", strZ(defaultValue));
} }
// Output alternate name (call it deprecated so the user will know not to use it) // Output alternate name (call it deprecated so the user will know not to use it)
@ -358,7 +358,7 @@ helpRender(void)
// If there is more help available output a message to let the user know // If there is more help available output a message to let the user know
if (more != NULL) if (more != NULL)
strCatFmt(result, "\nUse '" PROJECT_BIN " help %s' for more information.\n", strPtr(more)); strCatFmt(result, "\nUse '" PROJECT_BIN " help %s' for more information.\n", strZ(more));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();

View File

@ -135,7 +135,7 @@ archiveDbList(const String *stanza, const InfoPgData *pgData, VariantList *archi
// If there is no match, an error will be thrown. // If there is no match, an error will be thrown.
const String *archiveId = infoArchiveIdHistoryMatch(info, pgData->id, pgData->version, pgData->systemId); const String *archiveId = infoArchiveIdHistoryMatch(info, pgData->id, pgData->version, pgData->systemId);
String *archivePath = strNewFmt(STORAGE_PATH_ARCHIVE "/%s/%s", strPtr(stanza), strPtr(archiveId)); String *archivePath = strNewFmt(STORAGE_PATH_ARCHIVE "/%s/%s", strZ(stanza), strZ(archiveId));
String *archiveStart = NULL; String *archiveStart = NULL;
String *archiveStop = NULL; String *archiveStop = NULL;
Variant *archiveInfo = varNewKv(kvNew()); Variant *archiveInfo = varNewKv(kvNew());
@ -151,7 +151,7 @@ archiveDbList(const String *stanza, const InfoPgData *pgData, VariantList *archi
{ {
// Get a list of all WAL in this WAL dir // Get a list of all WAL in this WAL dir
StringList *list = storageListP( StringList *list = storageListP(
storageRepo(), strNewFmt("%s/%s", strPtr(archivePath), strPtr(strLstGet(walDir, idx))), storageRepo(), strNewFmt("%s/%s", strZ(archivePath), strZ(strLstGet(walDir, idx))),
.expression = WAL_SEGMENT_FILE_REGEXP_STR); .expression = WAL_SEGMENT_FILE_REGEXP_STR);
// If wal segments are found, get the oldest one as the archive start // If wal segments are found, get the oldest one as the archive start
@ -169,7 +169,7 @@ archiveDbList(const String *stanza, const InfoPgData *pgData, VariantList *archi
{ {
// Get a list of all WAL in this WAL dir // Get a list of all WAL in this WAL dir
StringList *list = storageListP( StringList *list = storageListP(
storageRepo(), strNewFmt("%s/%s", strPtr(archivePath), strPtr(strLstGet(walDir, idx))), storageRepo(), strNewFmt("%s/%s", strZ(archivePath), strZ(strLstGet(walDir, idx))),
.expression = WAL_SEGMENT_FILE_REGEXP_STR); .expression = WAL_SEGMENT_FILE_REGEXP_STR);
// If wal segments are found, get the newest one as the archive stop // If wal segments are found, get the newest one as the archive stop
@ -279,7 +279,7 @@ backupList(VariantList *backupSection, InfoBackup *info, const String *backupLab
{ {
// Load the manifest file // Load the manifest file
const Manifest *manifest = manifestLoadFile( const Manifest *manifest = manifestLoadFile(
storageRepo(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strPtr(backupLabel)), storageRepo(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strZ(backupLabel)),
cipherType(cfgOptionStr(cfgOptRepoCipherType)), infoPgCipherPass(infoBackupPg(info))); cipherType(cfgOptionStr(cfgOptRepoCipherType)), infoPgCipherPass(infoBackupPg(info)));
// Get the list of databases in this backup // Get the list of databases in this backup
@ -325,8 +325,8 @@ backupList(VariantList *backupSection, InfoBackup *info, const String *backupLab
{ {
kvPut(varKv(link), KEY_NAME_VAR, varNewStr(target->file)); kvPut(varKv(link), KEY_NAME_VAR, varNewStr(target->file));
kvPut( kvPut(
varKv(link), KEY_DESTINATION_VAR, varNewStr(strNewFmt("%s/%s", strPtr(target->path), varKv(link), KEY_DESTINATION_VAR, varNewStr(strNewFmt("%s/%s", strZ(target->path),
strPtr(target->file)))); strZ(target->file))));
varLstAdd(linkSection, link); varLstAdd(linkSection, link);
} }
else else
@ -395,7 +395,7 @@ stanzaInfoList(const String *stanza, StringList *stanzaList, const String *backu
{ {
// Attempt to load the backup info file // Attempt to load the backup info file
info = infoBackupLoadFile( info = infoBackupLoadFile(
storageRepo(), strNewFmt(STORAGE_PATH_BACKUP "/%s/%s", strPtr(stanzaListName), INFO_BACKUP_FILE), storageRepo(), strNewFmt(STORAGE_PATH_BACKUP "/%s/%s", strZ(stanzaListName), INFO_BACKUP_FILE),
cipherType(cfgOptionStr(cfgOptRepoCipherType)), cfgOptionStrNull(cfgOptRepoCipherPass)); cipherType(cfgOptionStr(cfgOptRepoCipherType)), cfgOptionStrNull(cfgOptRepoCipherPass));
} }
CATCH(FileMissingError) CATCH(FileMissingError)
@ -442,7 +442,7 @@ stanzaInfoList(const String *stanza, StringList *stanzaList, const String *backu
// Get the archive info for the DB from the archive.info file // Get the archive info for the DB from the archive.info file
InfoArchive *info = infoArchiveLoadFile( InfoArchive *info = infoArchiveLoadFile(
storageRepo(), strNewFmt(STORAGE_PATH_ARCHIVE "/%s/%s", strPtr(stanzaListName), INFO_ARCHIVE_FILE), storageRepo(), strNewFmt(STORAGE_PATH_ARCHIVE "/%s/%s", strZ(stanzaListName), INFO_ARCHIVE_FILE),
cipherType(cfgOptionStr(cfgOptRepoCipherType)), cfgOptionStrNull(cfgOptRepoCipherPass)); cipherType(cfgOptionStr(cfgOptRepoCipherType)), cfgOptionStrNull(cfgOptRepoCipherPass));
archiveDbList(stanzaListName, &pgData, archiveSection, info, (pgIdx == 0 ? true : false)); archiveDbList(stanzaListName, &pgData, archiveSection, info, (pgIdx == 0 ? true : false));
} }
@ -564,14 +564,14 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
{ {
strCatFmt( strCatFmt(
archiveResult, "\n wal archive min/max (%s): ", archiveResult, "\n wal archive min/max (%s): ",
strPtr(varStr(kvGet(archiveInfo, DB_KEY_ID_VAR)))); strZ(varStr(kvGet(archiveInfo, DB_KEY_ID_VAR))));
// Get the archive min/max if there are any archives for the database // Get the archive min/max if there are any archives for the database
if (kvGet(archiveInfo, ARCHIVE_KEY_MIN_VAR) != NULL) if (kvGet(archiveInfo, ARCHIVE_KEY_MIN_VAR) != NULL)
{ {
strCatFmt( strCatFmt(
archiveResult, "%s/%s\n", strPtr(varStr(kvGet(archiveInfo, ARCHIVE_KEY_MIN_VAR))), archiveResult, "%s/%s\n", strZ(varStr(kvGet(archiveInfo, ARCHIVE_KEY_MIN_VAR))),
strPtr(varStr(kvGet(archiveInfo, ARCHIVE_KEY_MAX_VAR)))); strZ(varStr(kvGet(archiveInfo, ARCHIVE_KEY_MAX_VAR))));
} }
else else
strCatZ(archiveResult, "none present\n"); strCatZ(archiveResult, "none present\n");
@ -594,8 +594,8 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
if (backupDbId == dbId) if (backupDbId == dbId)
{ {
strCatFmt( strCatFmt(
backupResult, "\n %s backup: %s\n", strPtr(varStr(kvGet(backupInfo, BACKUP_KEY_TYPE_VAR))), backupResult, "\n %s backup: %s\n", strZ(varStr(kvGet(backupInfo, BACKUP_KEY_TYPE_VAR))),
strPtr(varStr(kvGet(backupInfo, BACKUP_KEY_LABEL_VAR)))); strZ(varStr(kvGet(backupInfo, BACKUP_KEY_LABEL_VAR))));
KeyValue *timestampInfo = varKv(kvGet(backupInfo, BACKUP_KEY_TIMESTAMP_VAR)); KeyValue *timestampInfo = varKv(kvGet(backupInfo, BACKUP_KEY_TIMESTAMP_VAR));
@ -617,8 +617,9 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
if (kvGet(archiveBackupInfo, KEY_START_VAR) != NULL && if (kvGet(archiveBackupInfo, KEY_START_VAR) != NULL &&
kvGet(archiveBackupInfo, KEY_STOP_VAR) != NULL) kvGet(archiveBackupInfo, KEY_STOP_VAR) != NULL)
{ {
strCatFmt(backupResult, "%s / %s\n", strPtr(varStr(kvGet(archiveBackupInfo, KEY_START_VAR))), strCatFmt(
strPtr(varStr(kvGet(archiveBackupInfo, KEY_STOP_VAR)))); backupResult, "%s / %s\n", strZ(varStr(kvGet(archiveBackupInfo, KEY_START_VAR))),
strZ(varStr(kvGet(archiveBackupInfo, KEY_STOP_VAR))));
} }
else else
strCatZ(backupResult, "n/a\n"); strCatZ(backupResult, "n/a\n");
@ -627,20 +628,20 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
strCatFmt( strCatFmt(
backupResult, " database size: %s, backup size: %s\n", backupResult, " database size: %s, backup size: %s\n",
strPtr(strSizeFormat(varUInt64Force(kvGet(info, KEY_SIZE_VAR)))), strZ(strSizeFormat(varUInt64Force(kvGet(info, KEY_SIZE_VAR)))),
strPtr(strSizeFormat(varUInt64Force(kvGet(info, KEY_DELTA_VAR))))); strZ(strSizeFormat(varUInt64Force(kvGet(info, KEY_DELTA_VAR)))));
KeyValue *repoInfo = varKv(kvGet(info, INFO_KEY_REPOSITORY_VAR)); KeyValue *repoInfo = varKv(kvGet(info, INFO_KEY_REPOSITORY_VAR));
strCatFmt( strCatFmt(
backupResult, " repository size: %s, repository backup size: %s\n", backupResult, " repository size: %s, repository backup size: %s\n",
strPtr(strSizeFormat(varUInt64Force(kvGet(repoInfo, KEY_SIZE_VAR)))), strZ(strSizeFormat(varUInt64Force(kvGet(repoInfo, KEY_SIZE_VAR)))),
strPtr(strSizeFormat(varUInt64Force(kvGet(repoInfo, KEY_DELTA_VAR))))); strZ(strSizeFormat(varUInt64Force(kvGet(repoInfo, KEY_DELTA_VAR)))));
if (kvGet(backupInfo, BACKUP_KEY_REFERENCE_VAR) != NULL) if (kvGet(backupInfo, BACKUP_KEY_REFERENCE_VAR) != NULL)
{ {
StringList *referenceList = strLstNewVarLst(varVarLst(kvGet(backupInfo, BACKUP_KEY_REFERENCE_VAR))); StringList *referenceList = strLstNewVarLst(varVarLst(kvGet(backupInfo, BACKUP_KEY_REFERENCE_VAR)));
strCatFmt(backupResult, " backup reference list: %s\n", strPtr(strLstJoin(referenceList, ", "))); strCatFmt(backupResult, " backup reference list: %s\n", strZ(strLstJoin(referenceList, ", ")));
} }
if (kvGet(backupInfo, BACKUP_KEY_DATABASE_REF_VAR) != NULL) if (kvGet(backupInfo, BACKUP_KEY_DATABASE_REF_VAR) != NULL)
@ -656,8 +657,8 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
{ {
KeyValue *db = varKv(varLstGet(dbSection, dbIdx)); KeyValue *db = varKv(varLstGet(dbSection, dbIdx));
strCatFmt( strCatFmt(
backupResult, " %s (%s)", strPtr(varStr(kvGet(db, KEY_NAME_VAR))), backupResult, " %s (%s)", strZ(varStr(kvGet(db, KEY_NAME_VAR))),
strPtr(varStrForce(kvGet(db, KEY_OID_VAR)))); strZ(varStrForce(kvGet(db, KEY_OID_VAR))));
if (dbIdx != varLstSize(dbSection) - 1) if (dbIdx != varLstSize(dbSection) - 1)
strCatZ(backupResult, ","); strCatZ(backupResult, ",");
@ -677,8 +678,8 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
KeyValue *link = varKv(varLstGet(linkSection, linkIdx)); KeyValue *link = varKv(varLstGet(linkSection, linkIdx));
strCatFmt( strCatFmt(
backupResult, " %s => %s", strPtr(varStr(kvGet(link, KEY_NAME_VAR))), backupResult, " %s => %s", strZ(varStr(kvGet(link, KEY_NAME_VAR))),
strPtr(varStr(kvGet(link, KEY_DESTINATION_VAR)))); strZ(varStr(kvGet(link, KEY_DESTINATION_VAR))));
if (linkIdx != varLstSize(linkSection) - 1) if (linkIdx != varLstSize(linkSection) - 1)
strCat(backupResult, LF_STR); strCat(backupResult, LF_STR);
@ -697,9 +698,9 @@ formatTextDb(const KeyValue *stanzaInfo, String *resultStr, const String *backup
KeyValue *tablespace = varKv(varLstGet(tablespaceSection, tblIdx)); KeyValue *tablespace = varKv(varLstGet(tablespaceSection, tblIdx));
strCatFmt( strCatFmt(
backupResult, " %s (%s) => %s", strPtr(varStr(kvGet(tablespace, KEY_NAME_VAR))), backupResult, " %s (%s) => %s", strZ(varStr(kvGet(tablespace, KEY_NAME_VAR))),
strPtr(varStrForce(kvGet(tablespace, KEY_OID_VAR))), strZ(varStrForce(kvGet(tablespace, KEY_OID_VAR))),
strPtr(varStr(kvGet(tablespace, KEY_DESTINATION_VAR)))); strZ(varStr(kvGet(tablespace, KEY_DESTINATION_VAR))));
if (tblIdx != varLstSize(tablespaceSection) - 1) if (tblIdx != varLstSize(tablespaceSection) - 1)
strCat(backupResult, LF_STR); strCat(backupResult, LF_STR);
@ -753,11 +754,11 @@ infoRender(void)
if (!strEq(cfgOptionStr(cfgOptOutput), CFGOPTVAL_INFO_OUTPUT_TEXT_STR)) if (!strEq(cfgOptionStr(cfgOptOutput), CFGOPTVAL_INFO_OUTPUT_TEXT_STR))
THROW(ConfigError, "option 'set' is currently only valid for text output"); THROW(ConfigError, "option 'set' is currently only valid for text output");
if (!storageExistsP(storageRepo(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strPtr(backupLabel)))) if (!storageExistsP(storageRepo(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strZ(backupLabel))))
{ {
THROW_FMT( THROW_FMT(
FileMissingError, "manifest does not exist for backup '%s'\n" FileMissingError, "manifest does not exist for backup '%s'\n"
"HINT: is the backup listed when running the info command with --stanza option only?", strPtr(backupLabel)); "HINT: is the backup listed when running the info command with --stanza option only?", strZ(backupLabel));
} }
} }
@ -786,7 +787,7 @@ infoRender(void)
// Stanza name and status // Stanza name and status
strCatFmt( strCatFmt(
resultStr, "stanza: %s\n status: ", strPtr(varStr(kvGet(stanzaInfo, KEY_NAME_VAR)))); resultStr, "stanza: %s\n status: ", strZ(varStr(kvGet(stanzaInfo, KEY_NAME_VAR))));
// If an error has occurred, provide the information that is available and move onto next stanza // If an error has occurred, provide the information that is available and move onto next stanza
KeyValue *stanzaStatus = varKv(kvGet(stanzaInfo, STANZA_KEY_STATUS_VAR)); KeyValue *stanzaStatus = varKv(kvGet(stanzaInfo, STANZA_KEY_STATUS_VAR));
@ -803,21 +804,21 @@ infoRender(void)
{ {
strCatFmt( strCatFmt(
resultStr, "%s (%s, %s)\n", INFO_STANZA_STATUS_ERROR, resultStr, "%s (%s, %s)\n", INFO_STANZA_STATUS_ERROR,
strPtr(varStr(kvGet(stanzaStatus, STATUS_KEY_MESSAGE_VAR))), strZ(varStr(kvGet(stanzaStatus, STATUS_KEY_MESSAGE_VAR))),
strPtr(INFO_STANZA_STATUS_MESSAGE_LOCK_BACKUP_STR)); strZ(INFO_STANZA_STATUS_MESSAGE_LOCK_BACKUP_STR));
} }
else else
{ {
strCatFmt( strCatFmt(
resultStr, "%s (%s)\n", INFO_STANZA_STATUS_ERROR, resultStr, "%s (%s)\n", INFO_STANZA_STATUS_ERROR,
strPtr(varStr(kvGet(stanzaStatus, STATUS_KEY_MESSAGE_VAR)))); strZ(varStr(kvGet(stanzaStatus, STATUS_KEY_MESSAGE_VAR))));
} }
if (statusCode == INFO_STANZA_STATUS_CODE_MISSING_STANZA_DATA || if (statusCode == INFO_STANZA_STATUS_CODE_MISSING_STANZA_DATA ||
statusCode == INFO_STANZA_STATUS_CODE_NO_BACKUP) statusCode == INFO_STANZA_STATUS_CODE_NO_BACKUP)
{ {
strCatFmt( strCatFmt(
resultStr, " cipher: %s\n", strPtr(varStr(kvGet(stanzaInfo, STANZA_KEY_CIPHER_VAR)))); resultStr, " cipher: %s\n", strZ(varStr(kvGet(stanzaInfo, STANZA_KEY_CIPHER_VAR))));
// If there is a backup.info file but no backups, then process the archive info // If there is a backup.info file but no backups, then process the archive info
if (statusCode == INFO_STANZA_STATUS_CODE_NO_BACKUP) if (statusCode == INFO_STANZA_STATUS_CODE_NO_BACKUP)
@ -832,15 +833,15 @@ infoRender(void)
if (varBool(kvGet(backupLockKv, STATUS_KEY_LOCK_BACKUP_HELD_VAR))) if (varBool(kvGet(backupLockKv, STATUS_KEY_LOCK_BACKUP_HELD_VAR)))
{ {
strCatFmt( strCatFmt(
resultStr, "%s (%s)\n", INFO_STANZA_STATUS_OK, strPtr(INFO_STANZA_STATUS_MESSAGE_LOCK_BACKUP_STR)); resultStr, "%s (%s)\n", INFO_STANZA_STATUS_OK, strZ(INFO_STANZA_STATUS_MESSAGE_LOCK_BACKUP_STR));
} }
else else
strCatFmt(resultStr, "%s\n", INFO_STANZA_STATUS_OK); strCatFmt(resultStr, "%s\n", INFO_STANZA_STATUS_OK);
} }
// Cipher // Cipher
strCatFmt(resultStr, " cipher: %s\n", strCatFmt(
strPtr(varStr(kvGet(stanzaInfo, STANZA_KEY_CIPHER_VAR)))); resultStr, " cipher: %s\n", strZ(varStr(kvGet(stanzaInfo, STANZA_KEY_CIPHER_VAR))));
formatTextDb(stanzaInfo, resultStr, backupLabel); formatTextDb(stanzaInfo, resultStr, backupLabel);
} }

View File

@ -47,8 +47,8 @@ storageGetProcess(IoWrite *destination)
if (!strBeginsWith(file, cfgOptionStr(cfgOptRepoPath))) if (!strBeginsWith(file, cfgOptionStr(cfgOptRepoPath)))
{ {
THROW_FMT( THROW_FMT(
OptionInvalidValueError, "absolute path '%s' is not in base path '%s'", strPtr(file), OptionInvalidValueError, "absolute path '%s' is not in base path '%s'", strZ(file),
strPtr(cfgOptionStr(cfgOptRepoPath))); strZ(cfgOptionStr(cfgOptRepoPath)));
} }
// Get the relative part of the file // Get the relative part of the file
@ -95,7 +95,7 @@ storageGetProcess(IoWrite *destination)
{ {
THROW_FMT( THROW_FMT(
OptionInvalidValueError, "stanza name '%s' given in option doesn't match the given path", OptionInvalidValueError, "stanza name '%s' given in option doesn't match the given path",
strPtr(cfgOptionStr(cfgOptStanza))); strZ(cfgOptionStr(cfgOptStanza)));
} }
// Archive path // Archive path
@ -107,7 +107,7 @@ storageGetProcess(IoWrite *destination)
if (!strEndsWithZ(file, INFO_ARCHIVE_FILE) && !strEndsWithZ(file, INFO_ARCHIVE_FILE INFO_COPY_EXT)) if (!strEndsWithZ(file, INFO_ARCHIVE_FILE) && !strEndsWithZ(file, INFO_ARCHIVE_FILE INFO_COPY_EXT))
{ {
InfoArchive *info = infoArchiveLoadFile( InfoArchive *info = infoArchiveLoadFile(
storageRepo(), strNewFmt(STORAGE_PATH_ARCHIVE "/%s/%s", strPtr(stanza), INFO_ARCHIVE_FILE), storageRepo(), strNewFmt(STORAGE_PATH_ARCHIVE "/%s/%s", strZ(stanza), INFO_ARCHIVE_FILE),
repoCipherType, cipherPass); repoCipherType, cipherPass);
cipherPass = infoArchiveCipherPass(info); cipherPass = infoArchiveCipherPass(info);
} }
@ -122,7 +122,7 @@ storageGetProcess(IoWrite *destination)
{ {
// Find the backup passphrase // Find the backup passphrase
InfoBackup *info = infoBackupLoadFile( InfoBackup *info = infoBackupLoadFile(
storageRepo(), strNewFmt(STORAGE_PATH_BACKUP "/%s/%s", strPtr(stanza), INFO_BACKUP_FILE), storageRepo(), strNewFmt(STORAGE_PATH_BACKUP "/%s/%s", strZ(stanza), INFO_BACKUP_FILE),
repoCipherType, cipherPass); repoCipherType, cipherPass);
cipherPass = infoBackupCipherPass(info); cipherPass = infoBackupCipherPass(info);
@ -132,8 +132,8 @@ storageGetProcess(IoWrite *destination)
!strEndsWithZ(file, BACKUP_MANIFEST_FILE INFO_COPY_EXT)) !strEndsWithZ(file, BACKUP_MANIFEST_FILE INFO_COPY_EXT))
{ {
const Manifest *manifest = manifestLoadFile( const Manifest *manifest = manifestLoadFile(
storageRepo(), strNewFmt(STORAGE_PATH_BACKUP "/%s/%s/%s", strPtr(stanza), storageRepo(), strNewFmt(STORAGE_PATH_BACKUP "/%s/%s/%s", strZ(stanza),
strPtr(strLstGet(filePathSplitLst, 2)), BACKUP_MANIFEST_FILE), repoCipherType, cipherPass); strZ(strLstGet(filePathSplitLst, 2)), BACKUP_MANIFEST_FILE), repoCipherType, cipherPass);
cipherPass = manifestCipherSubPass(manifest); cipherPass = manifestCipherSubPass(manifest);
} }
} }
@ -143,7 +143,7 @@ storageGetProcess(IoWrite *destination)
// Error when unable to determine cipher passphrase // Error when unable to determine cipher passphrase
if (cipherPass == NULL) if (cipherPass == NULL)
THROW_FMT(OptionInvalidValueError, "unable to determine cipher passphrase for '%s'", strPtr(file)); THROW_FMT(OptionInvalidValueError, "unable to determine cipher passphrase for '%s'", strZ(file));
// Add encryption filter // Add encryption filter
cipherBlockFilterGroupAdd(ioReadFilterGroup(source), repoCipherType, cipherModeDecrypt, cipherPass); cipherBlockFilterGroupAdd(ioReadFilterGroup(source), repoCipherType, cipherModeDecrypt, cipherPass);

View File

@ -91,7 +91,7 @@ storageListRenderCallback(void *data, const StorageInfo *info)
} }
if (info->type == storageTypeLink) if (info->type == storageTypeLink)
ioWriteStr(listData->write, strNewFmt(",\"destination\":%s", strPtr(jsonFromStr(info->linkDestination)))); ioWriteStr(listData->write, strNewFmt(",\"destination\":%s", strZ(jsonFromStr(info->linkDestination))));
ioWrite(listData->write, BRACER_BUF); ioWrite(listData->write, BRACER_BUF);
} }

View File

@ -98,9 +98,9 @@ restoreFile(
{ {
THROW_ON_SYS_ERROR_FMT( THROW_ON_SYS_ERROR_FMT(
utime( utime(
strPtr(storagePathP(storagePg(), pgFile)), strZ(storagePathP(storagePg(), pgFile)),
&((struct utimbuf){.actime = pgFileModified, .modtime = pgFileModified})) == -1, &((struct utimbuf){.actime = pgFileModified, .modtime = pgFileModified})) == -1,
FileInfoError, "unable to set time for '%s'", strPtr(storagePathP(storagePg(), pgFile))); FileInfoError, "unable to set time for '%s'", strZ(storagePathP(storagePg(), pgFile)));
} }
result = false; result = false;
@ -128,7 +128,7 @@ restoreFile(
{ {
THROW_ON_SYS_ERROR_FMT( THROW_ON_SYS_ERROR_FMT(
ftruncate(ioWriteHandle(storageWriteIo(pgFileWrite)), (off_t)pgFileSize) == -1, FileWriteError, ftruncate(ioWriteHandle(storageWriteIo(pgFileWrite)), (off_t)pgFileSize) == -1, FileWriteError,
"unable to truncate '%s'", strPtr(pgFile)); "unable to truncate '%s'", strZ(pgFile));
// Report the file as not copied // Report the file as not copied
result = false; result = false;
@ -166,8 +166,8 @@ restoreFile(
storageNewReadP( storageNewReadP(
storageRepo(), storageRepo(),
strNewFmt( strNewFmt(
STORAGE_REPO_BACKUP "/%s/%s%s", strPtr(repoFileReference), strPtr(repoFile), STORAGE_REPO_BACKUP "/%s/%s%s", strZ(repoFileReference), strZ(repoFile),
strPtr(compressExtStr(repoFileCompressType))), strZ(compressExtStr(repoFileCompressType))),
.compressible = compressible), .compressible = compressible),
pgFileWrite); pgFileWrite);
@ -176,8 +176,8 @@ restoreFile(
{ {
THROW_FMT( THROW_FMT(
ChecksumError, ChecksumError,
"error restoring '%s': actual checksum '%s' does not match expected checksum '%s'", strPtr(pgFile), "error restoring '%s': actual checksum '%s' does not match expected checksum '%s'", strZ(pgFile),
strPtr(varStr(ioFilterGroupResult(filterGroup, CRYPTO_HASH_FILTER_TYPE_STR))), strPtr(pgFileChecksum)); strZ(varStr(ioFilterGroupResult(filterGroup, CRYPTO_HASH_FILTER_TYPE_STR))), strZ(pgFileChecksum));
} }
} }
} }

View File

@ -46,7 +46,7 @@ restoreProtocol(const String *command, const VariantList *paramList, ProtocolSer
varStr(varLstGet(paramList, 0)), varStr(varLstGet(paramList, 1)), varStr(varLstGet(paramList, 0)), varStr(varLstGet(paramList, 1)),
(CompressType)varUIntForce(varLstGet(paramList, 2)), varStr(varLstGet(paramList, 3)), (CompressType)varUIntForce(varLstGet(paramList, 2)), varStr(varLstGet(paramList, 3)),
varStr(varLstGet(paramList, 4)), varBoolForce(varLstGet(paramList, 5)), varUInt64(varLstGet(paramList, 6)), varStr(varLstGet(paramList, 4)), varBoolForce(varLstGet(paramList, 5)), varUInt64(varLstGet(paramList, 6)),
(time_t)varInt64Force(varLstGet(paramList, 7)), cvtZToUIntBase(strPtr(varStr(varLstGet(paramList, 8))), 8), (time_t)varInt64Force(varLstGet(paramList, 7)), cvtZToUIntBase(strZ(varStr(varLstGet(paramList, 8))), 8),
varStr(varLstGet(paramList, 9)), varStr(varLstGet(paramList, 10)), varStr(varLstGet(paramList, 9)), varStr(varLstGet(paramList, 10)),
(time_t)varInt64Force(varLstGet(paramList, 11)), varBoolForce(varLstGet(paramList, 12)), (time_t)varInt64Force(varLstGet(paramList, 11)), varBoolForce(varLstGet(paramList, 12)),
varBoolForce(varLstGet(paramList, 13)), varStr(varLstGet(paramList, 14))))); varBoolForce(varLstGet(paramList, 13)), varStr(varLstGet(paramList, 14)))));

View File

@ -75,7 +75,7 @@ restorePathValidate(void)
// The PGDATA directory must exist // The PGDATA directory must exist
// ??? We should remove this requirement in a separate commit. What's the harm in creating the dir assuming we have perms? // ??? We should remove this requirement in a separate commit. What's the harm in creating the dir assuming we have perms?
if (!storagePathExistsP(storagePg(), NULL)) if (!storagePathExistsP(storagePg(), NULL))
THROW_FMT(PathMissingError, "$PGDATA directory '%s' does not exist", strPtr(cfgOptionStr(cfgOptPgPath))); THROW_FMT(PathMissingError, "$PGDATA directory '%s' does not exist", strZ(cfgOptionStr(cfgOptPgPath)));
// PostgreSQL must not be running // PostgreSQL must not be running
if (storageExistsP(storagePg(), PG_FILE_POSTMASTERPID_STR)) if (storageExistsP(storagePg(), PG_FILE_POSTMASTERPID_STR))
@ -85,7 +85,7 @@ restorePathValidate(void)
"unable to restore while PostgreSQL is running\n" "unable to restore while PostgreSQL is running\n"
"HINT: presence of '" PG_FILE_POSTMASTERPID "' in '%s' indicates PostgreSQL is running.\n" "HINT: presence of '" PG_FILE_POSTMASTERPID "' in '%s' indicates PostgreSQL is running.\n"
"HINT: remove '" PG_FILE_POSTMASTERPID "' only if PostgreSQL is not running.", "HINT: remove '" PG_FILE_POSTMASTERPID "' only if PostgreSQL is not running.",
strPtr(cfgOptionStr(cfgOptPgPath))); strZ(cfgOptionStr(cfgOptPgPath)));
} }
// If the restore will be destructive attempt to verify that PGDATA looks like a valid PostgreSQL directory // If the restore will be destructive attempt to verify that PGDATA looks like a valid PostgreSQL directory
@ -96,7 +96,7 @@ restorePathValidate(void)
"--delta or --force specified but unable to find '" PG_FILE_PGVERSION "' or '" BACKUP_MANIFEST_FILE "' in '%s' to" "--delta or --force specified but unable to find '" PG_FILE_PGVERSION "' or '" BACKUP_MANIFEST_FILE "' in '%s' to"
" confirm that this is a valid $PGDATA directory. --delta and --force have been disabled and if any files" " confirm that this is a valid $PGDATA directory. --delta and --force have been disabled and if any files"
" exist in the destination directories the restore will be aborted.", " exist in the destination directories the restore will be aborted.",
strPtr(cfgOptionStr(cfgOptPgPath))); strZ(cfgOptionStr(cfgOptPgPath)));
// Disable delta and force so restore will fail if the directories are not empty // Disable delta and force so restore will fail if the directories are not empty
cfgOptionSet(cfgOptDelta, cfgSourceDefault, VARBOOL(false)); cfgOptionSet(cfgOptDelta, cfgSourceDefault, VARBOOL(false));
@ -137,12 +137,12 @@ getEpoch(const String *targetTime)
// Strip off the date and time and put the remainder into another string // Strip off the date and time and put the remainder into another string
String *datetime = strSubN(targetTime, 0, 19); String *datetime = strSubN(targetTime, 0, 19);
int dtYear = cvtZToInt(strPtr(strSubN(datetime, 0, 4))); int dtYear = cvtZToInt(strZ(strSubN(datetime, 0, 4)));
int dtMonth = cvtZToInt(strPtr(strSubN(datetime, 5, 2))); int dtMonth = cvtZToInt(strZ(strSubN(datetime, 5, 2)));
int dtDay = cvtZToInt(strPtr(strSubN(datetime, 8, 2))); int dtDay = cvtZToInt(strZ(strSubN(datetime, 8, 2)));
int dtHour = cvtZToInt(strPtr(strSubN(datetime, 11, 2))); int dtHour = cvtZToInt(strZ(strSubN(datetime, 11, 2)));
int dtMinute = cvtZToInt(strPtr(strSubN(datetime, 14, 2))); int dtMinute = cvtZToInt(strZ(strSubN(datetime, 14, 2)));
int dtSecond = cvtZToInt(strPtr(strSubN(datetime, 17, 2))); int dtSecond = cvtZToInt(strZ(strSubN(datetime, 17, 2)));
// Confirm date and time parts are valid // Confirm date and time parts are valid
datePartsValid(dtYear, dtMonth, dtDay); datePartsValid(dtYear, dtMonth, dtDay);
@ -162,13 +162,13 @@ getEpoch(const String *targetTime)
String *timezoneOffset = strSub(timeTargetZone, (size_t)idxSign); String *timezoneOffset = strSub(timeTargetZone, (size_t)idxSign);
// Include the sign with the hour // Include the sign with the hour
int tzHour = cvtZToInt(strPtr(strSubN(timezoneOffset, 0, 3))); int tzHour = cvtZToInt(strZ(strSubN(timezoneOffset, 0, 3)));
int tzMinute = 0; int tzMinute = 0;
// If minutes are included in timezone offset then extract the minutes based on whether a colon separates them from // If minutes are included in timezone offset then extract the minutes based on whether a colon separates them from
// the hour // the hour
if (strSize(timezoneOffset) > 3) if (strSize(timezoneOffset) > 3)
tzMinute = cvtZToInt(strPtr(strSubN(timezoneOffset, 3 + (strChr(timezoneOffset, ':') == -1 ? 0 : 1), 2))); tzMinute = cvtZToInt(strZ(strSubN(timezoneOffset, 3 + (strChr(timezoneOffset, ':') == -1 ? 0 : 1), 2)));
result = epochFromParts(dtYear, dtMonth, dtDay, dtHour, dtMinute, dtSecond, tzOffsetSeconds(tzHour, tzMinute)); result = epochFromParts(dtYear, dtMonth, dtDay, dtHour, dtMinute, dtSecond, tzOffsetSeconds(tzHour, tzMinute));
} }
@ -189,7 +189,7 @@ getEpoch(const String *targetTime)
"automatic backup set selection cannot be performed with provided time '%s', latest backup set will be used" "automatic backup set selection cannot be performed with provided time '%s', latest backup set will be used"
"\nHINT: time format must be YYYY-MM-DD HH:MM:SS with optional msec and optional timezone (+/- HH or HHMM or HH:MM)" "\nHINT: time format must be YYYY-MM-DD HH:MM:SS with optional msec and optional timezone (+/- HH or HHMM or HH:MM)"
" - if timezone is omitted, local time is assumed (for UTC use +00)", " - if timezone is omitted, local time is assumed (for UTC use +00)",
strPtr(targetTime)); strZ(targetTime));
} }
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
@ -249,7 +249,7 @@ restoreBackupSet(InfoBackup *infoBackup)
{ {
LOG_WARN_FMT( LOG_WARN_FMT(
"unable to find backup set with stop time less than '%s', latest backup set will be used", "unable to find backup set with stop time less than '%s', latest backup set will be used",
strPtr(cfgOptionStr(cfgOptTarget))); strZ(cfgOptionStr(cfgOptTarget)));
} }
} }
} }
@ -274,7 +274,7 @@ restoreBackupSet(InfoBackup *infoBackup)
} }
if (!found) if (!found)
THROW_FMT(BackupSetInvalidError, "backup set %s is not valid", strPtr(backupSet)); THROW_FMT(BackupSetInvalidError, "backup set %s is not valid", strZ(backupSet));
} }
MEM_CONTEXT_PRIOR_BEGIN() MEM_CONTEXT_PRIOR_BEGIN()
@ -316,7 +316,7 @@ restoreManifestValidate(Manifest *manifest, const String *backupSet)
FormatError, FormatError,
"requested backup '%s' and manifest label '%s' do not match\n" "requested backup '%s' and manifest label '%s' do not match\n"
"HINT: this indicates some sort of corruption (at the very least paths have been renamed).", "HINT: this indicates some sort of corruption (at the very least paths have been renamed).",
strPtr(backupSet), strPtr(data->backupLabel)); strZ(backupSet), strZ(data->backupLabel));
} }
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
@ -345,7 +345,7 @@ restoreManifestMap(Manifest *manifest)
if (!strEq(targetBase->path, pgPath)) if (!strEq(targetBase->path, pgPath))
{ {
LOG_INFO_FMT("remap data directory to '%s'", strPtr(pgPath)); LOG_INFO_FMT("remap data directory to '%s'", strZ(pgPath));
manifestTargetUpdate(manifest, targetBase->name, pgPath, NULL); manifestTargetUpdate(manifest, targetBase->name, pgPath, NULL);
} }
@ -389,7 +389,7 @@ restoreManifestMap(Manifest *manifest)
{ {
THROW_FMT( THROW_FMT(
TablespaceMapError, "tablespace remapped by name '%s' and id %u with different paths", TablespaceMapError, "tablespace remapped by name '%s' and id %u with different paths",
strPtr(target->tablespaceName), target->tablespaceId); strZ(target->tablespaceName), target->tablespaceId);
} }
// Else set the path by name // Else set the path by name
else if (tablespacePathByName != NULL) else if (tablespacePathByName != NULL)
@ -403,15 +403,15 @@ restoreManifestMap(Manifest *manifest)
// If not individual mapping check if all tablespaces are being remapped // If not individual mapping check if all tablespaces are being remapped
if (tablespacePath == NULL && tablespaceMapAllPath != NULL) if (tablespacePath == NULL && tablespaceMapAllPath != NULL)
tablespacePath = strNewFmt("%s/%s", strPtr(tablespaceMapAllPath), strPtr(target->tablespaceName)); tablespacePath = strNewFmt("%s/%s", strZ(tablespaceMapAllPath), strZ(target->tablespaceName));
// Remap tablespace if a mapping was found // Remap tablespace if a mapping was found
if (tablespacePath != NULL) if (tablespacePath != NULL)
{ {
LOG_INFO_FMT("map tablespace '%s' to '%s'", strPtr(target->name), strPtr(tablespacePath)); LOG_INFO_FMT("map tablespace '%s' to '%s'", strZ(target->name), strZ(tablespacePath));
manifestTargetUpdate(manifest, target->name, tablespacePath, NULL); manifestTargetUpdate(manifest, target->name, tablespacePath, NULL);
manifestLinkUpdate(manifest, strNewFmt(MANIFEST_TARGET_PGDATA "/%s", strPtr(target->name)), tablespacePath); manifestLinkUpdate(manifest, strNewFmt(MANIFEST_TARGET_PGDATA "/%s", strZ(target->name)), tablespacePath);
} }
} }
} }
@ -427,7 +427,7 @@ restoreManifestMap(Manifest *manifest)
const String *tablespace = varStr(varLstGet(tablespaceMapList, tablespaceMapIdx)); const String *tablespace = varStr(varLstGet(tablespaceMapList, tablespaceMapIdx));
if (!strLstExists(tablespaceRemapped, tablespace)) if (!strLstExists(tablespaceRemapped, tablespace))
THROW_FMT(TablespaceMapError, "unable to remap invalid tablespace '%s'", strPtr(tablespace)); THROW_FMT(TablespaceMapError, "unable to remap invalid tablespace '%s'", strZ(tablespace));
} }
} }
@ -456,7 +456,7 @@ restoreManifestMap(Manifest *manifest)
// Remap link if a mapping was found // Remap link if a mapping was found
if (linkPath != NULL) if (linkPath != NULL)
{ {
LOG_INFO_FMT("map link '%s' to '%s'", strPtr(link), strPtr(linkPath)); LOG_INFO_FMT("map link '%s' to '%s'", strZ(link), strZ(linkPath));
manifestLinkUpdate(manifest, target->name, linkPath); manifestLinkUpdate(manifest, target->name, linkPath);
// If the link is a file separate the file name from the path to update the target // If the link is a file separate the file name from the path to update the target
@ -469,8 +469,8 @@ restoreManifestMap(Manifest *manifest)
if (strSize(strPath(linkPath)) == 0) if (strSize(strPath(linkPath)) == 0)
{ {
THROW_FMT( THROW_FMT(
LinkMapError, "'%s' is not long enough to be the destination for file link '%s'", strPtr(linkPath), LinkMapError, "'%s' is not long enough to be the destination for file link '%s'", strZ(linkPath),
strPtr(link)); strZ(link));
} }
linkFile = strBase(linkPath); linkFile = strBase(linkPath);
@ -486,12 +486,11 @@ restoreManifestMap(Manifest *manifest)
else if (!linkAll) else if (!linkAll)
{ {
if (target->file != NULL) if (target->file != NULL)
LOG_WARN_FMT("file link '%s' will be restored as a file at the same location", strPtr(link)); LOG_WARN_FMT("file link '%s' will be restored as a file at the same location", strZ(link));
else else
{ {
LOG_WARN_FMT( LOG_WARN_FMT(
"contents of directory link '%s' will be restored in a directory at the same location", "contents of directory link '%s' will be restored in a directory at the same location", strZ(link));
strPtr(link));
} }
manifestLinkRemove(manifest, target->name); manifestLinkRemove(manifest, target->name);
@ -512,7 +511,7 @@ restoreManifestMap(Manifest *manifest)
const String *link = varStr(varLstGet(linkMapList, linkMapIdx)); const String *link = varStr(varLstGet(linkMapList, linkMapIdx));
if (!strLstExists(linkRemapped, link)) if (!strLstExists(linkRemapped, link))
THROW_FMT(LinkMapError, "unable to remap invalid link '%s'", strPtr(link)); THROW_FMT(LinkMapError, "unable to remap invalid link '%s'", strZ(link));
} }
} }
} }
@ -572,7 +571,7 @@ Check ownership of items in the manifest
const String *owner = strLstGet(type##List, ownerIdx); \ const String *owner = strLstGet(type##List, ownerIdx); \
\ \
if (type##Name() == NULL || !strEq(type##Name(), owner)) \ if (type##Name() == NULL || !strEq(type##Name(), owner)) \
LOG_WARN_FMT("unknown " #type " '%s' in backup manifest mapped to current " #type, strPtr(owner)); \ LOG_WARN_FMT("unknown " #type " '%s' in backup manifest mapped to current " #type, strZ(owner)); \
} \ } \
} \ } \
while (0) while (0)
@ -616,10 +615,10 @@ restoreManifestOwner(Manifest *manifest)
if (userNull || groupNull) if (userNull || groupNull)
{ {
if (userNull) if (userNull)
LOG_WARN_FMT("unknown user in backup manifest mapped to '%s'", strPtr(pathInfo.user)); LOG_WARN_FMT("unknown user in backup manifest mapped to '%s'", strZ(pathInfo.user));
if (groupNull) if (groupNull)
LOG_WARN_FMT("unknown group in backup manifest mapped to '%s'", strPtr(pathInfo.group)); LOG_WARN_FMT("unknown group in backup manifest mapped to '%s'", strZ(pathInfo.group));
MEM_CONTEXT_PRIOR_BEGIN() MEM_CONTEXT_PRIOR_BEGIN()
{ {
@ -708,11 +707,11 @@ restoreCleanOwnership(
{ {
// If this is a newly created file/link/path then there's no need to log updated permissions // If this is a newly created file/link/path then there's no need to log updated permissions
if (!new) if (!new)
LOG_DETAIL_FMT("update ownership for '%s'", strPtr(pgPath)); LOG_DETAIL_FMT("update ownership for '%s'", strZ(pgPath));
THROW_ON_SYS_ERROR_FMT( THROW_ON_SYS_ERROR_FMT(
lchown(strPtr(pgPath), expectedUserId, expectedGroupId) == -1, FileOwnerError, "unable to set ownership for '%s'", lchown(strZ(pgPath), expectedUserId, expectedGroupId) == -1, FileOwnerError, "unable to set ownership for '%s'",
strPtr(pgPath)); strZ(pgPath));
} }
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
@ -734,10 +733,10 @@ restoreCleanMode(const String *pgPath, mode_t manifestMode, const StorageInfo *i
// Update mode if not as expected // Update mode if not as expected
if (manifestMode != info->mode) if (manifestMode != info->mode)
{ {
LOG_DETAIL_FMT("update mode for '%s' to %04o", strPtr(pgPath), manifestMode); LOG_DETAIL_FMT("update mode for '%s' to %04o", strZ(pgPath), manifestMode);
THROW_ON_SYS_ERROR_FMT( THROW_ON_SYS_ERROR_FMT(
chmod(strPtr(pgPath), manifestMode) == -1, FileOwnerError, "unable to set mode for '%s'", strPtr(pgPath)); chmod(strZ(pgPath), manifestMode) == -1, FileOwnerError, "unable to set mode for '%s'", strZ(pgPath));
} }
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
@ -778,14 +777,14 @@ restoreCleanInfoListCallback(void *data, const StorageInfo *info)
PathNotEmptyError, PathNotEmptyError,
"unable to restore to path '%s' because it contains files\n" "unable to restore to path '%s' because it contains files\n"
"HINT: try using --delta if this is what you intended.", "HINT: try using --delta if this is what you intended.",
strPtr(cleanData->targetPath)); strZ(cleanData->targetPath));
} }
// Construct the name used to find this file/link/path in the manifest // Construct the name used to find this file/link/path in the manifest
const String *manifestName = strNewFmt("%s/%s", strPtr(cleanData->targetName), strPtr(info->name)); const String *manifestName = strNewFmt("%s/%s", strZ(cleanData->targetName), strZ(info->name));
// Construct the path of this file/link/path in the PostgreSQL data directory // Construct the path of this file/link/path in the PostgreSQL data directory
const String *pgPath = strNewFmt("%s/%s", strPtr(cleanData->targetPath), strPtr(info->name)); const String *pgPath = strNewFmt("%s/%s", strZ(cleanData->targetPath), strZ(info->name));
switch (info->type) switch (info->type)
{ {
@ -800,7 +799,7 @@ restoreCleanInfoListCallback(void *data, const StorageInfo *info)
} }
else else
{ {
LOG_DETAIL_FMT("remove invalid file '%s'", strPtr(pgPath)); LOG_DETAIL_FMT("remove invalid file '%s'", strZ(pgPath));
storageRemoveP(storageLocalWrite(), pgPath, .errorOnMissing = true); storageRemoveP(storageLocalWrite(), pgPath, .errorOnMissing = true);
} }
@ -815,7 +814,7 @@ restoreCleanInfoListCallback(void *data, const StorageInfo *info)
{ {
if (!strEq(manifestLink->destination, info->linkDestination)) if (!strEq(manifestLink->destination, info->linkDestination))
{ {
LOG_DETAIL_FMT("remove link '%s' because destination changed", strPtr(pgPath)); LOG_DETAIL_FMT("remove link '%s' because destination changed", strZ(pgPath));
storageRemoveP(storageLocalWrite(), pgPath, .errorOnMissing = true); storageRemoveP(storageLocalWrite(), pgPath, .errorOnMissing = true);
} }
else else
@ -823,7 +822,7 @@ restoreCleanInfoListCallback(void *data, const StorageInfo *info)
} }
else else
{ {
LOG_DETAIL_FMT("remove invalid link '%s'", strPtr(pgPath)); LOG_DETAIL_FMT("remove invalid link '%s'", strZ(pgPath));
storageRemoveP(storageLocalWrite(), pgPath, .errorOnMissing = true); storageRemoveP(storageLocalWrite(), pgPath, .errorOnMissing = true);
} }
@ -842,8 +841,8 @@ restoreCleanInfoListCallback(void *data, const StorageInfo *info)
// Recurse into the path // Recurse into the path
RestoreCleanCallbackData cleanDataSub = *cleanData; RestoreCleanCallbackData cleanDataSub = *cleanData;
cleanDataSub.targetName = strNewFmt("%s/%s", strPtr(cleanData->targetName), strPtr(info->name)); cleanDataSub.targetName = strNewFmt("%s/%s", strZ(cleanData->targetName), strZ(info->name));
cleanDataSub.targetPath = strNewFmt("%s/%s", strPtr(cleanData->targetPath), strPtr(info->name)); cleanDataSub.targetPath = strNewFmt("%s/%s", strZ(cleanData->targetPath), strZ(info->name));
cleanDataSub.basePath = false; cleanDataSub.basePath = false;
storageInfoListP( storageInfoListP(
@ -852,7 +851,7 @@ restoreCleanInfoListCallback(void *data, const StorageInfo *info)
} }
else else
{ {
LOG_DETAIL_FMT("remove invalid path '%s'", strPtr(pgPath)); LOG_DETAIL_FMT("remove invalid path '%s'", strZ(pgPath));
storagePathRemoveP(storageLocalWrite(), pgPath, .errorOnMissing = true, .recurse = true); storagePathRemoveP(storageLocalWrite(), pgPath, .errorOnMissing = true, .recurse = true);
} }
@ -862,7 +861,7 @@ restoreCleanInfoListCallback(void *data, const StorageInfo *info)
// Special file types cannot exist in the manifest so just delete them // Special file types cannot exist in the manifest so just delete them
case storageTypeSpecial: case storageTypeSpecial:
{ {
LOG_DETAIL_FMT("remove special file '%s'", strPtr(pgPath)); LOG_DETAIL_FMT("remove special file '%s'", strZ(pgPath));
storageRemoveP(storageLocalWrite(), pgPath, .errorOnMissing = true); storageRemoveP(storageLocalWrite(), pgPath, .errorOnMissing = true);
break; break;
} }
@ -934,8 +933,8 @@ restoreCleanBuild(Manifest *manifest)
// Only PostgreSQL >= 9.0 has tablespace indentifiers // Only PostgreSQL >= 9.0 has tablespace indentifiers
if (tablespaceId != NULL) if (tablespaceId != NULL)
{ {
cleanData->targetName = strNewFmt("%s/%s", strPtr(cleanData->targetName), strPtr(tablespaceId)); cleanData->targetName = strNewFmt("%s/%s", strZ(cleanData->targetName), strZ(tablespaceId));
cleanData->targetPath = strNewFmt("%s/%s", strPtr(cleanData->targetPath), strPtr(tablespaceId)); cleanData->targetPath = strNewFmt("%s/%s", strZ(cleanData->targetPath), strZ(tablespaceId));
} }
} }
@ -945,7 +944,7 @@ restoreCleanBuild(Manifest *manifest)
// Don't log check for the same path twice. There can be multiple links to files in the same path, but logging it more // Don't log check for the same path twice. There can be multiple links to files in the same path, but logging it more
// than once makes the logs noisy and looks like a bug. // than once makes the logs noisy and looks like a bug.
if (!strLstExists(pathChecked, cleanData->targetPath)) if (!strLstExists(pathChecked, cleanData->targetPath))
LOG_DETAIL_FMT("check '%s' exists", strPtr(cleanData->targetPath)); LOG_DETAIL_FMT("check '%s' exists", strZ(cleanData->targetPath));
StorageInfo info = storageInfoP(storageLocal(), cleanData->targetPath, .ignoreMissing = true, .followLink = true); StorageInfo info = storageInfoP(storageLocal(), cleanData->targetPath, .ignoreMissing = true, .followLink = true);
strLstAdd(pathChecked, cleanData->targetPath); strLstAdd(pathChecked, cleanData->targetPath);
@ -956,13 +955,13 @@ restoreCleanBuild(Manifest *manifest)
if (!userRoot() && userId() != info.userId) if (!userRoot() && userId() != info.userId)
{ {
THROW_FMT( THROW_FMT(
PathOpenError, "unable to restore to path '%s' not owned by current user", strPtr(cleanData->targetPath)); PathOpenError, "unable to restore to path '%s' not owned by current user", strZ(cleanData->targetPath));
} }
if ((info.mode & 0700) != 0700) if ((info.mode & 0700) != 0700)
{ {
THROW_FMT( THROW_FMT(
PathOpenError, "unable to restore to path '%s' without rwx permissions", strPtr(cleanData->targetPath)); PathOpenError, "unable to restore to path '%s' without rwx permissions", strZ(cleanData->targetPath));
} }
// If not a delta restore then check that the directories are empty, or if a file link, that the file doesn't exist // If not a delta restore then check that the directories are empty, or if a file link, that the file doesn't exist
@ -976,7 +975,7 @@ restoreCleanBuild(Manifest *manifest)
} }
else else
{ {
const String *file = strNewFmt("%s/%s", strPtr(cleanData->targetPath), strPtr(cleanData->target->file)); const String *file = strNewFmt("%s/%s", strZ(cleanData->targetPath), strZ(cleanData->target->file));
if (storageExistsP(storageLocal(), file)) if (storageExistsP(storageLocal(), file))
{ {
@ -984,7 +983,7 @@ restoreCleanBuild(Manifest *manifest)
FileExistsError, FileExistsError,
"unable to restore file '%s' because it already exists\n" "unable to restore file '%s' because it already exists\n"
"HINT: try using --delta if this is what you intended.", "HINT: try using --delta if this is what you intended.",
strPtr(file)); strZ(file));
} }
} }
@ -1040,7 +1039,7 @@ restoreCleanBuild(Manifest *manifest)
// Only log when doing a delta restore because otherwise the targets should be empty. We'll still run the clean // Only log when doing a delta restore because otherwise the targets should be empty. We'll still run the clean
// to fix permissions/ownership on the target paths. // to fix permissions/ownership on the target paths.
if (delta) if (delta)
LOG_INFO_FMT("remove invalid files/links/paths from '%s'", strPtr(cleanData->targetPath)); LOG_INFO_FMT("remove invalid files/links/paths from '%s'", strZ(cleanData->targetPath));
// Check target ownership/permissions // Check target ownership/permissions
const ManifestPath *manifestPath = manifestPathFind(cleanData->manifest, cleanData->targetName); const ManifestPath *manifestPath = manifestPathFind(cleanData->manifest, cleanData->targetName);
@ -1091,7 +1090,7 @@ restoreCleanBuild(Manifest *manifest)
const ManifestLink *link = manifestLinkFindDefault( const ManifestLink *link = manifestLinkFindDefault(
manifest, manifest,
strBeginsWith(path->name, MANIFEST_TARGET_PGTBLSPC_STR) ? strBeginsWith(path->name, MANIFEST_TARGET_PGTBLSPC_STR) ?
strNewFmt(MANIFEST_TARGET_PGDATA "/%s", strPtr(path->name)) : path->name, strNewFmt(MANIFEST_TARGET_PGDATA "/%s", strZ(path->name)) : path->name,
NULL); NULL);
if (link != NULL) if (link != NULL)
@ -1102,11 +1101,11 @@ restoreCleanBuild(Manifest *manifest)
// Create the link if it is missing. If it exists it should already have the correct ownership and destination. // Create the link if it is missing. If it exists it should already have the correct ownership and destination.
if (!linkInfo.exists) if (!linkInfo.exists)
{ {
LOG_DETAIL_FMT("create symlink '%s' to '%s'", strPtr(pgPath), strPtr(link->destination)); LOG_DETAIL_FMT("create symlink '%s' to '%s'", strZ(pgPath), strZ(link->destination));
THROW_ON_SYS_ERROR_FMT( THROW_ON_SYS_ERROR_FMT(
symlink(strPtr(link->destination), strPtr(pgPath)) == -1, FileOpenError, symlink(strZ(link->destination), strZ(pgPath)) == -1, FileOpenError,
"unable to create symlink '%s' to '%s'", strPtr(pgPath), strPtr(link->destination)); "unable to create symlink '%s' to '%s'", strZ(pgPath), strZ(link->destination));
restoreCleanOwnership(pgPath, link->user, link->group, userId(), groupId(), true); restoreCleanOwnership(pgPath, link->user, link->group, userId(), groupId(), true);
} }
} }
@ -1119,7 +1118,7 @@ restoreCleanBuild(Manifest *manifest)
// Create the path if it is missing If it exists it should already have the correct ownership and mode. // Create the path if it is missing If it exists it should already have the correct ownership and mode.
if (!pathInfo.exists) if (!pathInfo.exists)
{ {
LOG_DETAIL_FMT("create path '%s'", strPtr(pgPath)); LOG_DETAIL_FMT("create path '%s'", strZ(pgPath));
storagePathCreateP(storagePgWrite(), pgPath, .mode = path->mode, .noParentCreate = true, .errorOnExists = true); storagePathCreateP(storagePgWrite(), pgPath, .mode = path->mode, .noParentCreate = true, .errorOnExists = true);
restoreCleanOwnership(storagePathP(storagePg(), pgPath), path->user, path->group, userId(), groupId(), true); restoreCleanOwnership(storagePathP(storagePg(), pgPath), path->user, path->group, userId(), groupId(), true);
@ -1139,11 +1138,11 @@ restoreCleanBuild(Manifest *manifest)
// Create the link if it is missing. If it exists it should already have the correct ownership and destination. // Create the link if it is missing. If it exists it should already have the correct ownership and destination.
if (!linkInfo.exists) if (!linkInfo.exists)
{ {
LOG_DETAIL_FMT("create symlink '%s' to '%s'", strPtr(pgPath), strPtr(link->destination)); LOG_DETAIL_FMT("create symlink '%s' to '%s'", strZ(pgPath), strZ(link->destination));
THROW_ON_SYS_ERROR_FMT( THROW_ON_SYS_ERROR_FMT(
symlink(strPtr(link->destination), strPtr(pgPath)) == -1, FileOpenError, symlink(strZ(link->destination), strZ(pgPath)) == -1, FileOpenError,
"unable to create symlink '%s' to '%s'", strPtr(pgPath), strPtr(link->destination)); "unable to create symlink '%s' to '%s'", strZ(pgPath), strZ(link->destination));
restoreCleanOwnership(pgPath, link->user, link->group, userId(), groupId(), true); restoreCleanOwnership(pgPath, link->user, link->group, userId(), groupId(), true);
} }
} }
@ -1184,7 +1183,7 @@ restoreSelectiveExpression(Manifest *manifest)
else else
{ {
tablespaceRegExp = regExpNew( tablespaceRegExp = regExpNew(
strNewFmt("^" MANIFEST_TARGET_PGTBLSPC "/[0-9]+/%s/[0-9]+/" PG_FILE_PGVERSION, strPtr(tablespaceId))); strNewFmt("^" MANIFEST_TARGET_PGTBLSPC "/[0-9]+/%s/[0-9]+/" PG_FILE_PGVERSION, strZ(tablespaceId)));
} }
// Generate a list of databases in base or in a tablespace // Generate a list of databases in base or in a tablespace
@ -1205,7 +1204,7 @@ restoreSelectiveExpression(Manifest *manifest)
THROW(FormatError, "no databases found for selective restore\nHINT: is this a valid cluster?"); THROW(FormatError, "no databases found for selective restore\nHINT: is this a valid cluster?");
// Log databases found // Log databases found
LOG_DETAIL_FMT("databases found for selective restore (%s)", strPtr(strLstJoin(dbList, ", "))); LOG_DETAIL_FMT("databases found for selective restore (%s)", strZ(strLstJoin(dbList, ", ")));
// Remove included databases from the list // Remove included databases from the list
const StringList *includeList = strLstNewVarLst(cfgOptionLst(cfgOptDbInclude)); const StringList *includeList = strLstNewVarLst(cfgOptionLst(cfgOptDbInclude));
@ -1220,14 +1219,14 @@ restoreSelectiveExpression(Manifest *manifest)
const ManifestDb *db = manifestDbFindDefault(manifest, includeDb, NULL); const ManifestDb *db = manifestDbFindDefault(manifest, includeDb, NULL);
if (db == NULL || !strLstExists(dbList, varStrForce(VARUINT(db->id)))) if (db == NULL || !strLstExists(dbList, varStrForce(VARUINT(db->id))))
THROW_FMT(DbMissingError, "database to include '%s' does not exist", strPtr(includeDb)); THROW_FMT(DbMissingError, "database to include '%s' does not exist", strZ(includeDb));
// Set the include db to the id if the name mapping was successful // Set the include db to the id if the name mapping was successful
includeDb = varStrForce(VARUINT(db->id)); includeDb = varStrForce(VARUINT(db->id));
} }
// Error if the db is a system db // Error if the db is a system db
if (cvtZToUInt64(strPtr(includeDb)) < PG_USER_OBJECT_MIN_ID) if (cvtZToUInt64(strZ(includeDb)) < PG_USER_OBJECT_MIN_ID)
THROW(DbInvalidError, "system databases (template0, postgres, etc.) are included by default"); THROW(DbInvalidError, "system databases (template0, postgres, etc.) are included by default");
// Remove from list of DBs to zero // Remove from list of DBs to zero
@ -1243,7 +1242,7 @@ restoreSelectiveExpression(Manifest *manifest)
const String *db = strLstGet(dbList, dbIdx); const String *db = strLstGet(dbList, dbIdx);
// Only user created databases can be zeroed, never system databases // Only user created databases can be zeroed, never system databases
if (cvtZToUInt64(strPtr(db)) >= PG_USER_OBJECT_MIN_ID) if (cvtZToUInt64(strZ(db)) >= PG_USER_OBJECT_MIN_ID)
{ {
// Create expression string or append | // Create expression string or append |
if (expression == NULL) if (expression == NULL)
@ -1252,7 +1251,7 @@ restoreSelectiveExpression(Manifest *manifest)
strCatZ(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/)", strZ(db));
// Filter files in tablespace directories // Filter files in tablespace directories
for (unsigned int targetIdx = 0; targetIdx < manifestTargetTotal(manifest); targetIdx++) for (unsigned int targetIdx = 0; targetIdx < manifestTargetTotal(manifest); targetIdx++)
@ -1262,9 +1261,9 @@ restoreSelectiveExpression(Manifest *manifest)
if (target->tablespaceId != 0) if (target->tablespaceId != 0)
{ {
if (tablespaceId == NULL) if (tablespaceId == NULL)
strCatFmt(expression, "|(^%s/%s/)", strPtr(target->name), strPtr(db)); strCatFmt(expression, "|(^%s/%s/)", strZ(target->name), strZ(db));
else else
strCatFmt(expression, "|(^%s/%s/%s/)", strPtr(target->name), strPtr(tablespaceId), strPtr(db)); strCatFmt(expression, "|(^%s/%s/%s/)", strZ(target->name), strZ(tablespaceId), strZ(db));
} }
} }
} }
@ -1349,8 +1348,8 @@ restoreRecoveryOption(unsigned int pgVersion)
result, VARSTRZ(RESTORE_COMMAND), result, VARSTRZ(RESTORE_COMMAND),
VARSTR( VARSTR(
strNewFmt( strNewFmt(
"%s %s %%f \"%%p\"", strPtr(cfgExe()), "%s %s %%f \"%%p\"", strZ(cfgExe()),
strPtr(strLstJoin(cfgExecParam(cfgCmdArchiveGet, cfgCmdRoleDefault, optionReplace, true, true), " "))))); strZ(strLstJoin(cfgExecParam(cfgCmdArchiveGet, cfgCmdRoleDefault, optionReplace, true, true), " ")))));
} }
// If recovery type is immediate // If recovery type is immediate
@ -1370,7 +1369,7 @@ restoreRecoveryOption(unsigned int pgVersion)
{ {
// Write the recovery target // Write the recovery target
kvPut( kvPut(
result, VARSTR(strNewFmt(RECOVERY_TARGET "_%s", strPtr(cfgOptionStr(cfgOptType)))), result, VARSTR(strNewFmt(RECOVERY_TARGET "_%s", strZ(cfgOptionStr(cfgOptType)))),
VARSTR(cfgOptionStr(cfgOptTarget))); VARSTR(cfgOptionStr(cfgOptTarget)));
// Write recovery_target_inclusive // Write recovery_target_inclusive
@ -1399,7 +1398,7 @@ restoreRecoveryOption(unsigned int pgVersion)
THROW_FMT( THROW_FMT(
OptionInvalidError, OptionInvalidError,
CFGOPT_TARGET_ACTION "=" RECOVERY_TARGET_ACTION_SHUTDOWN " is only available in PostgreSQL >= %s", CFGOPT_TARGET_ACTION "=" RECOVERY_TARGET_ACTION_SHUTDOWN " is only available in PostgreSQL >= %s",
strPtr(pgVersionToStr(PG_VERSION_RECOVERY_TARGET_ACTION))); strZ(pgVersionToStr(PG_VERSION_RECOVERY_TARGET_ACTION)));
} }
kvPut(result, VARSTRZ(PAUSE_AT_RECOVERY_TARGET), VARSTR(FALSE_STR)); kvPut(result, VARSTRZ(PAUSE_AT_RECOVERY_TARGET), VARSTR(FALSE_STR));
@ -1409,7 +1408,7 @@ restoreRecoveryOption(unsigned int pgVersion)
{ {
THROW_FMT( THROW_FMT(
OptionInvalidError, CFGOPT_TARGET_ACTION " option is only available in PostgreSQL >= %s", OptionInvalidError, CFGOPT_TARGET_ACTION " option is only available in PostgreSQL >= %s",
strPtr(pgVersionToStr(PG_VERSION_RECOVERY_TARGET_PAUSE))); strZ(pgVersionToStr(PG_VERSION_RECOVERY_TARGET_PAUSE)));
} }
} }
} }
@ -1439,7 +1438,7 @@ restoreRecoveryConf(unsigned int pgVersion, const String *restoreLabel)
MEM_CONTEXT_TEMP_BEGIN() MEM_CONTEXT_TEMP_BEGIN()
{ {
result = strNewFmt("# Recovery settings generated by " PROJECT_NAME " restore on %s\n", strPtr(restoreLabel)); result = strNewFmt("# Recovery settings generated by " PROJECT_NAME " restore on %s\n", strZ(restoreLabel));
// Output all recovery options // Output all recovery options
KeyValue *optionKv = restoreRecoveryOption(pgVersion); KeyValue *optionKv = restoreRecoveryOption(pgVersion);
@ -1448,7 +1447,7 @@ restoreRecoveryConf(unsigned int pgVersion, const String *restoreLabel)
for (unsigned int optionKeyIdx = 0; optionKeyIdx < varLstSize(optionKeyList); optionKeyIdx++) for (unsigned int optionKeyIdx = 0; optionKeyIdx < varLstSize(optionKeyList); optionKeyIdx++)
{ {
const Variant *optionKey = varLstGet(optionKeyList, optionKeyIdx); const Variant *optionKey = varLstGet(optionKeyList, optionKeyIdx);
strCatFmt(result, "%s = '%s'\n", strPtr(varStr(optionKey)), strPtr(varStr(kvGet(optionKv, optionKey)))); strCatFmt(result, "%s = '%s'\n", strZ(varStr(optionKey)), strZ(varStr(kvGet(optionKv, optionKey))));
} }
// Move to prior context // Move to prior context
@ -1476,7 +1475,7 @@ restoreRecoveryWriteConf(const Manifest *manifest, unsigned int pgVersion, const
// Only write recovery.conf if recovery type != none // Only write recovery.conf if recovery type != none
if (!strEq(cfgOptionStr(cfgOptType), RECOVERY_TYPE_NONE_STR)) if (!strEq(cfgOptionStr(cfgOptType), RECOVERY_TYPE_NONE_STR))
{ {
LOG_INFO_FMT("write %s", strPtr(storagePathP(storagePg(), PG_FILE_RECOVERYCONF_STR))); LOG_INFO_FMT("write %s", strZ(storagePathP(storagePg(), PG_FILE_RECOVERYCONF_STR)));
// Use the data directory to set permissions and ownership for recovery file // Use the data directory to set permissions and ownership for recovery file
const ManifestPath *dataPath = manifestPathFind(manifest, MANIFEST_TARGET_PGDATA_STR); const ManifestPath *dataPath = manifestPathFind(manifest, MANIFEST_TARGET_PGDATA_STR);
@ -1540,7 +1539,7 @@ restoreRecoveryWriteAutoConf(unsigned int pgVersion, const String *restoreLabel)
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 # ", strZ(restoreLabel));
strCat(content, line); strCat(content, line);
} }
@ -1578,16 +1577,16 @@ restoreRecoveryWriteAutoConf(unsigned int pgVersion, const String *restoreLabel)
"'" STANDBY_MODE "' setting is not valid for " PG_NAME " >= %s\n" "'" STANDBY_MODE "' setting is not valid for " PG_NAME " >= %s\n"
"HINT: use --" CFGOPT_TYPE "=" RECOVERY_TYPE_STANDBY " instead of --" CFGOPT_RECOVERY_OPTION "=" "HINT: use --" CFGOPT_TYPE "=" RECOVERY_TYPE_STANDBY " instead of --" CFGOPT_RECOVERY_OPTION "="
STANDBY_MODE "=on.", STANDBY_MODE "=on.",
strPtr(pgVersionToStr(PG_VERSION_RECOVERY_GUC))); strZ(pgVersionToStr(PG_VERSION_RECOVERY_GUC)));
} }
} }
} }
strCatFmt(content, "%s", strPtr(restoreRecoveryConf(pgVersion, restoreLabel))); strCatFmt(content, "%s", strZ(restoreRecoveryConf(pgVersion, restoreLabel)));
} }
LOG_INFO_FMT( LOG_INFO_FMT(
"write %s%s", autoConf == NULL ? "" : "updated ", strPtr(storagePathP(storagePg(), PG_FILE_POSTGRESQLAUTOCONF_STR))); "write %s%s", autoConf == NULL ? "" : "updated ", strZ(storagePathP(storagePg(), PG_FILE_POSTGRESQLAUTOCONF_STR)));
// Use the data directory to set permissions and ownership for recovery file // Use the data directory to set permissions and ownership for recovery file
const StorageInfo dataPath = storageInfoP(storagePg(), NULL); const StorageInfo dataPath = storageInfoP(storagePg(), NULL);
@ -1645,7 +1644,7 @@ restoreRecoveryWrite(const Manifest *manifest)
{ {
LOG_WARN_FMT( LOG_WARN_FMT(
"recovery type is " RECOVERY_TYPE_PRESERVE " but recovery file does not exist at '%s'", "recovery type is " RECOVERY_TYPE_PRESERVE " but recovery file does not exist at '%s'",
strPtr(storagePathP(storagePg(), recoveryFile))); strZ(storagePathP(storagePg(), recoveryFile)));
} }
} }
// Else write recovery file // Else write recovery file
@ -1720,7 +1719,7 @@ restoreProcessQueue(Manifest *manifest, List **queueList)
const ManifestTarget *target = manifestTarget(manifest, targetIdx); const ManifestTarget *target = manifestTarget(manifest, targetIdx);
if (target->tablespaceId != 0) if (target->tablespaceId != 0)
strLstAdd(targetList, strNewFmt("%s/", strPtr(target->name))); strLstAdd(targetList, strNewFmt("%s/", strZ(target->name)));
} }
// Generate the processing queues // Generate the processing queues
@ -1803,10 +1802,10 @@ restoreFilePgPath(const Manifest *manifest, const String *manifestName)
ASSERT(manifest != NULL); ASSERT(manifest != NULL);
ASSERT(manifestName != NULL); ASSERT(manifestName != NULL);
String *result = strNewFmt("%s/%s", strPtr(manifestTargetBase(manifest)->path), strPtr(manifestPathPg(manifestName))); String *result = strNewFmt("%s/%s", strZ(manifestTargetBase(manifest)->path), strZ(manifestPathPg(manifestName)));
if (strEq(manifestName, STRDEF(MANIFEST_TARGET_PGDATA "/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL))) if (strEq(manifestName, STRDEF(MANIFEST_TARGET_PGDATA "/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL)))
result = strNewFmt("%s." STORAGE_FILE_TEMP_EXT, strPtr(result)); result = strNewFmt("%s." STORAGE_FILE_TEMP_EXT, strZ(result));
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -1840,7 +1839,7 @@ restoreJobResult(const Manifest *manifest, ProtocolParallelJob *job, RegExp *zer
strCatZ(log, " zeroed"); strCatZ(log, " zeroed");
// Add filename // Add filename
strCatFmt(log, " file %s", strPtr(restoreFilePgPath(manifest, file->name))); strCatFmt(log, " file %s", strZ(restoreFilePgPath(manifest, file->name)));
// 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)
@ -1872,13 +1871,13 @@ restoreJobResult(const Manifest *manifest, ProtocolParallelJob *job, RegExp *zer
// Add size and percent complete // Add size and percent complete
sizeRestored += file->size; sizeRestored += file->size;
strCatFmt(log, " (%s, %" PRIu64 "%%)", strPtr(strSizeFormat(file->size)), sizeRestored * 100 / sizeTotal); strCatFmt(log, " (%s, %" PRIu64 "%%)", strZ(strSizeFormat(file->size)), sizeRestored * 100 / sizeTotal);
// If not zero-length add the checksum // If not zero-length add the checksum
if (file->size != 0 && !zeroed) if (file->size != 0 && !zeroed)
strCatFmt(log, " checksum %s", file->checksumSha1); strCatFmt(log, " checksum %s", file->checksumSha1);
LOG_PID(copy ? logLevelInfo : logLevelDetail, protocolParallelJobProcessId(job), 0, strPtr(log)); LOG_PID(copy ? logLevelInfo : logLevelDetail, protocolParallelJobProcessId(job), 0, strZ(log));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
@ -1887,7 +1886,7 @@ restoreJobResult(const Manifest *manifest, ProtocolParallelJob *job, RegExp *zer
} }
// Else the job errored // Else the job errored
else else
THROW_CODE(protocolParallelJobErrorCode(job), strPtr(protocolParallelJobErrorMessage(job))); THROW_CODE(protocolParallelJobErrorCode(job), strZ(protocolParallelJobErrorMessage(job)));
FUNCTION_LOG_RETURN(UINT64, sizeRestored); FUNCTION_LOG_RETURN(UINT64, sizeRestored);
} }
@ -2026,7 +2025,7 @@ cmdRestore(void)
RestoreJobData jobData = {0}; RestoreJobData jobData = {0};
jobData.manifest = manifestLoadFile( jobData.manifest = manifestLoadFile(
storageRepo(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strPtr(backupSet)), storageRepo(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strZ(backupSet)),
cipherType(cfgOptionStr(cfgOptRepoCipherType)), infoPgCipherPass(infoBackupPg(infoBackup))); cipherType(cfgOptionStr(cfgOptRepoCipherType)), infoPgCipherPass(infoBackupPg(infoBackup)));
// Validate manifest. Don't use strict mode because we'd rather ignore problems that won't affect a restore. // Validate manifest. Don't use strict mode because we'd rather ignore problems that won't affect a restore.
@ -2039,7 +2038,7 @@ cmdRestore(void)
restoreManifestValidate(jobData.manifest, backupSet); restoreManifestValidate(jobData.manifest, backupSet);
// Log the backup set to restore // Log the backup set to restore
LOG_INFO_FMT("restore backup set %s", strPtr(backupSet)); LOG_INFO_FMT("restore backup set %s", strZ(backupSet));
// Map manifest // Map manifest
restoreManifestMap(jobData.manifest); restoreManifestMap(jobData.manifest);
@ -2111,7 +2110,7 @@ cmdRestore(void)
strLstAdd(pathSynced, pgPath); strLstAdd(pathSynced, pgPath);
// Sync the path // Sync the path
LOG_DETAIL_FMT("sync path '%s'", strPtr(pgPath)); LOG_DETAIL_FMT("sync path '%s'", strZ(pgPath));
storagePathSyncP(storageLocalWrite(), pgPath); storagePathSyncP(storageLocalWrite(), pgPath);
} }
} }
@ -2132,7 +2131,7 @@ cmdRestore(void)
const String *pgPath = storagePathP(storagePg(), manifestPathPg(manifestName)); const String *pgPath = storagePathP(storagePg(), manifestPathPg(manifestName));
LOG_DETAIL_FMT("sync path '%s'", strPtr(pgPath)); LOG_DETAIL_FMT("sync path '%s'", strZ(pgPath));
storagePathSyncP(storagePgWrite(), pgPath); storagePathSyncP(storagePgWrite(), pgPath);
} }
@ -2151,7 +2150,7 @@ cmdRestore(void)
LOG_WARN("backup does not contain '" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL "' -- cluster will not start"); LOG_WARN("backup does not contain '" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL "' -- cluster will not start");
// Sync global path // Sync global path
LOG_DETAIL_FMT("sync path '%s'", strPtr(storagePathP(storagePg(), PG_PATH_GLOBAL_STR))); LOG_DETAIL_FMT("sync path '%s'", strZ(storagePathP(storagePg(), PG_PATH_GLOBAL_STR)));
storagePathSyncP(storagePgWrite(), PG_PATH_GLOBAL_STR); storagePathSyncP(storagePgWrite(), PG_PATH_GLOBAL_STR);
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();

View File

@ -123,7 +123,7 @@ cmdStanzaCreate(void)
// If no files copied, then the stanza was already valid // If no files copied, then the stanza was already valid
if (sourceFile == NULL) if (sourceFile == NULL)
LOG_INFO_FMT("stanza '%s' already exists and is valid", strPtr(cfgOptionStr(cfgOptStanza))); LOG_INFO_FMT("stanza '%s' already exists and is valid", strZ(cfgOptionStr(cfgOptStanza)));
} }
// Else if both .info and corresponding .copy file are missing for one but not the other, then error // Else if both .info and corresponding .copy file are missing for one but not the other, then error
else else

View File

@ -41,10 +41,10 @@ manifestDelete(const Storage *storageRepoWriteStanza)
for (unsigned int idx = 0; idx < strLstSize(backupList); idx++) for (unsigned int idx = 0; idx < strLstSize(backupList); idx++)
{ {
storageRemoveP( storageRemoveP(
storageRepoWriteStanza, strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strPtr(strLstGet(backupList, idx)))); storageRepoWriteStanza, strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strZ(strLstGet(backupList, idx))));
storageRemoveP( storageRemoveP(
storageRepoWriteStanza, storageRepoWriteStanza,
strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE INFO_COPY_EXT, strPtr(strLstGet(backupList, idx)))); strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE INFO_COPY_EXT, strZ(strLstGet(backupList, idx))));
} }
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
@ -79,7 +79,7 @@ stanzaDelete(const Storage *storageRepoWriteStanza, const StringList *archiveLis
THROW_FMT( THROW_FMT(
FileMissingError, "stop file does not exist for stanza '%s'\n" FileMissingError, "stop file does not exist for stanza '%s'\n"
"HINT: has the pgbackrest stop command been run on this server for this stanza?", "HINT: has the pgbackrest stop command been run on this server for this stanza?",
strPtr(cfgOptionStr(cfgOptStanza))); strZ(cfgOptionStr(cfgOptStanza)));
} }
// If a force has not been issued and Postgres is running, then error // If a force has not been issued and Postgres is running, then error
@ -88,7 +88,7 @@ stanzaDelete(const Storage *storageRepoWriteStanza, const StringList *archiveLis
THROW_FMT( THROW_FMT(
PgRunningError, PG_FILE_POSTMASTERPID " exists - looks like " PG_NAME " is running. " PgRunningError, PG_FILE_POSTMASTERPID " exists - looks like " PG_NAME " is running. "
"To delete stanza '%s', shut down " PG_NAME " for stanza '%s' and try again, or use --force.", "To delete stanza '%s', shut down " PG_NAME " for stanza '%s' and try again, or use --force.",
strPtr(cfgOptionStr(cfgOptStanza)), strPtr(cfgOptionStr(cfgOptStanza))); strZ(cfgOptionStr(cfgOptStanza)), strZ(cfgOptionStr(cfgOptStanza)));
} }
// Delete the archive info files // Delete the archive info files

View File

@ -92,7 +92,7 @@ cmdStanzaUpgrade(void)
} }
if (!(infoArchiveUpgrade || infoBackupUpgrade)) if (!(infoArchiveUpgrade || infoBackupUpgrade))
LOG_INFO_FMT("stanza '%s' is already up to date", strPtr(cfgOptionStr(cfgOptStanza))); LOG_INFO_FMT("stanza '%s' is already up to date", strZ(cfgOptionStr(cfgOptStanza)));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();

View File

@ -120,7 +120,7 @@ compressTypeEnum(const String *type)
} }
if (result == COMPRESS_LIST_SIZE) if (result == COMPRESS_LIST_SIZE)
THROW_FMT(AssertError, "invalid compression type '%s'", strPtr(type)); THROW_FMT(AssertError, "invalid compression type '%s'", strZ(type));
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -136,11 +136,7 @@ compressTypePresent(CompressType type)
ASSERT(type < COMPRESS_LIST_SIZE); ASSERT(type < COMPRESS_LIST_SIZE);
if (type != compressTypeNone && compressHelperLocal[type].compressNew == NULL) if (type != compressTypeNone && compressHelperLocal[type].compressNew == NULL)
{ THROW_FMT(OptionInvalidValueError, PROJECT_NAME " not compiled with %s support", strZ(compressHelperLocal[type].type));
THROW_FMT(
OptionInvalidValueError, PROJECT_NAME " not compiled with %s support",
strPtr(compressHelperLocal[type].type));
}
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
} }
@ -298,7 +294,7 @@ compressExtStrip(const String *file, CompressType type)
ASSERT(file != NULL); ASSERT(file != NULL);
if (!strEndsWith(file, compressExtStr(type))) if (!strEndsWith(file, compressExtStr(type)))
THROW_FMT(FormatError, "'%s' must have '%s' extension", strPtr(file), strPtr(compressExtStr(type))); THROW_FMT(FormatError, "'%s' must have '%s' extension", strZ(file), strZ(compressExtStr(type)));
FUNCTION_TEST_RETURN(strSubN(file, 0, strSize(file) - strSize(compressExtStr(type)))); FUNCTION_TEST_RETURN(strSubN(file, 0, strSize(file) - strSize(compressExtStr(type))));
} }

View File

@ -399,21 +399,21 @@ cipherBlockNew(CipherMode mode, CipherType cipherType, const Buffer *pass, const
// Lookup cipher by name. This means the ciphers passed in must exactly match a name expected by OpenSSL. This is a good // Lookup cipher by name. This means the ciphers passed in must exactly match a name expected by OpenSSL. This is a good
// thing since the name required by the openssl command-line tool will match what is used by pgBackRest. // thing since the name required by the openssl command-line tool will match what is used by pgBackRest.
const EVP_CIPHER *cipher = EVP_get_cipherbyname(strPtr(cipherTypeName(cipherType))); const EVP_CIPHER *cipher = EVP_get_cipherbyname(strZ(cipherTypeName(cipherType)));
if (!cipher) if (!cipher)
THROW_FMT(AssertError, "unable to load cipher '%s'", strPtr(cipherTypeName(cipherType))); THROW_FMT(AssertError, "unable to load cipher '%s'", strZ(cipherTypeName(cipherType)));
// Lookup digest. If not defined it will be set to sha1. // Lookup digest. If not defined it will be set to sha1.
const EVP_MD *digest = NULL; const EVP_MD *digest = NULL;
if (digestName) if (digestName)
digest = EVP_get_digestbyname(strPtr(digestName)); digest = EVP_get_digestbyname(strZ(digestName));
else else
digest = EVP_sha1(); digest = EVP_sha1();
if (!digest) if (!digest)
THROW_FMT(AssertError, "unable to load digest '%s'", strPtr(digestName)); THROW_FMT(AssertError, "unable to load digest '%s'", strZ(digestName));
// Allocate memory to hold process state // Allocate memory to hold process state
IoFilter *this = NULL; IoFilter *this = NULL;

View File

@ -69,7 +69,7 @@ cipherType(const String *name)
if (strEq(name, CIPHER_TYPE_AES_256_CBC_STR)) if (strEq(name, CIPHER_TYPE_AES_256_CBC_STR))
result = cipherTypeAes256Cbc; result = cipherTypeAes256Cbc;
else if (!strEq(name, CIPHER_TYPE_NONE_STR)) else if (!strEq(name, CIPHER_TYPE_NONE_STR))
THROW_FMT(AssertError, "invalid cipher name '%s'", strPtr(name)); THROW_FMT(AssertError, "invalid cipher name '%s'", strZ(name));
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }

View File

@ -193,8 +193,8 @@ cryptoHashNew(const String *type)
else else
{ {
// Lookup digest // Lookup digest
if ((driver->hashType = EVP_get_digestbyname(strPtr(type))) == NULL) if ((driver->hashType = EVP_get_digestbyname(strZ(type))) == NULL)
THROW_FMT(AssertError, "unable to load hash '%s'", strPtr(type)); THROW_FMT(AssertError, "unable to load hash '%s'", strZ(type));
// Create context // Create context
cryptoError((driver->hashContext = EVP_MD_CTX_create()) == NULL, "unable to create hash context"); cryptoError((driver->hashContext = EVP_MD_CTX_create()) == NULL, "unable to create hash context");
@ -275,7 +275,7 @@ cryptoHmacOne(const String *type, const Buffer *key, const Buffer *message)
// Init crypto subsystem // Init crypto subsystem
cryptoInit(); cryptoInit();
const EVP_MD *hashType = EVP_get_digestbyname(strPtr(type)); const EVP_MD *hashType = EVP_get_digestbyname(strZ(type));
ASSERT(hashType != NULL); ASSERT(hashType != NULL);
// Allocate a buffer to hold the hmac // Allocate a buffer to hold the hmac

View File

@ -98,7 +98,7 @@ OBJECT_DEFINE_FREE_RESOURCE_BEGIN(EXEC, LOG, logLevelTrace)
// If the process did not exit then error -- else we may end up with a collection of zombie processes // If the process did not exit then error -- else we may end up with a collection of zombie processes
if (processResult == 0) if (processResult == 0)
THROW_FMT(ExecuteError, "%s did not exit when expected", strPtr(this->name)); THROW_FMT(ExecuteError, "%s did not exit when expected", strZ(this->name));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
} }
@ -175,18 +175,18 @@ execCheck(Exec *this)
if (WIFEXITED(processStatus)) if (WIFEXITED(processStatus))
{ {
// Get data from stderr to help diagnose the problem // Get data from stderr to help diagnose the problem
IoRead *ioReadError = ioHandleReadNew(strNewFmt("%s error", strPtr(this->name)), this->handleError, 0); IoRead *ioReadError = ioHandleReadNew(strNewFmt("%s error", strZ(this->name)), this->handleError, 0);
ioReadOpen(ioReadError); ioReadOpen(ioReadError);
String *errorStr = strTrim(strNewBuf(ioReadBuf(ioReadError))); String *errorStr = strTrim(strNewBuf(ioReadBuf(ioReadError)));
// Throw the error with as much information as is available // Throw the error with as much information as is available
THROWP_FMT( THROWP_FMT(
errorTypeFromCode(WEXITSTATUS(processStatus)), "%s terminated unexpectedly [%d]%s%s", strPtr(this->name), errorTypeFromCode(WEXITSTATUS(processStatus)), "%s terminated unexpectedly [%d]%s%s", strZ(this->name),
WEXITSTATUS(processStatus), strSize(errorStr) > 0 ? ": " : "", strSize(errorStr) > 0 ? strPtr(errorStr) : ""); WEXITSTATUS(processStatus), strSize(errorStr) > 0 ? ": " : "", strSize(errorStr) > 0 ? strZ(errorStr) : "");
} }
// If the process did not exit normally then it must have been a signal // If the process did not exit normally then it must have been a signal
THROW_FMT(ExecuteError, "%s terminated unexpectedly on signal %d", strPtr(this->name), WTERMSIG(processStatus)); THROW_FMT(ExecuteError, "%s terminated unexpectedly on signal %d", strZ(this->name), WTERMSIG(processStatus));
} }
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
@ -333,11 +333,11 @@ execOpen(Exec *this)
PIPE_DUP2(pipeError, 1, STDERR_FILENO); PIPE_DUP2(pipeError, 1, STDERR_FILENO);
// Execute the binary. This statement will not return if it is successful // Execute the binary. This statement will not return if it is successful
execvp(strPtr(this->command), (char ** const)strLstPtr(this->param)); execvp(strZ(this->command), (char ** const)strLstPtr(this->param));
// If we got here then there was an error. We can't use a throw as we normally would because we have already shutdown // If we got here then there was an error. We can't use a throw as we normally would because we have already shutdown
// logging and we don't want to execute exit paths that might free parent resources which we still have references to. // logging and we don't want to execute exit paths that might free parent resources which we still have references to.
fprintf(stderr, "unable to execute '%s': [%d] %s\n", strPtr(this->command), errno, strerror(errno)); fprintf(stderr, "unable to execute '%s': [%d] %s\n", strZ(this->command), errno, strerror(errno));
exit(errorTypeCode(&ExecuteError)); exit(errorTypeCode(&ExecuteError));
} }
@ -352,8 +352,8 @@ execOpen(Exec *this)
this->handleError = pipeError[0]; this->handleError = pipeError[0];
// Assign handles to io interfaces // Assign handles to io interfaces
this->ioReadHandle = ioHandleReadNew(strNewFmt("%s read", strPtr(this->name)), this->handleRead, this->timeout); this->ioReadHandle = ioHandleReadNew(strNewFmt("%s read", strZ(this->name)), this->handleRead, this->timeout);
this->ioWriteHandle = ioHandleWriteNew(strNewFmt("%s write", strPtr(this->name)), this->handleWrite); this->ioWriteHandle = ioHandleWriteNew(strNewFmt("%s write", strZ(this->name)), this->handleWrite);
ioWriteOpen(this->ioWriteHandle); ioWriteOpen(this->ioWriteHandle);
// Create wrapper interfaces that check process state // Create wrapper interfaces that check process state

View File

@ -78,7 +78,7 @@ iniGetInternal(const Ini *this, const String *section, const String *key, bool r
// If value is null and required then error // If value is null and required then error
if (result == NULL && required) if (result == NULL && required)
THROW_FMT(FormatError, "section '%s', key '%s' does not exist", strPtr(section), strPtr(key)); THROW_FMT(FormatError, "section '%s', key '%s' does not exist", strZ(section), strZ(key));
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -251,7 +251,7 @@ iniParse(Ini *this, const String *content)
{ {
// Get next line // Get next line
const String *line = strTrim(strLstGet(lines, lineIdx)); const String *line = strTrim(strLstGet(lines, lineIdx));
const char *linePtr = strPtr(line); const char *linePtr = strZ(line);
// Only interested in lines that are not blank or comments // Only interested in lines that are not blank or comments
if (strSize(line) > 0 && linePtr[0] != '#') if (strSize(line) > 0 && linePtr[0] != '#')
@ -358,7 +358,7 @@ iniLoad(
do do
{ {
const String *line = strTrim(ioReadLineParam(read, true)); const String *line = strTrim(ioReadLineParam(read, true));
const char *linePtr = strPtr(line); const char *linePtr = strZ(line);
// Only interested in lines that are not blank or comments // Only interested in lines that are not blank or comments
if (strSize(line) > 0 && linePtr[0] != '#') if (strSize(line) > 0 && linePtr[0] != '#')

View File

@ -226,5 +226,5 @@ ioFilterType(const IoFilter *this)
String * String *
ioFilterToLog(const IoFilter *this) ioFilterToLog(const IoFilter *this)
{ {
return strNewFmt("{type: %s}", strPtr(this->type)); return strNewFmt("{type: %s}", strZ(this->type));
} }

View File

@ -72,16 +72,16 @@ ioHandleRead(THIS_VOID, Buffer *buffer, bool block)
// Determine if there is data to be read // Determine if there is data to be read
int result = select(this->handle + 1, &selectSet, NULL, NULL, &timeoutSelect); int result = select(this->handle + 1, &selectSet, NULL, NULL, &timeoutSelect);
THROW_ON_SYS_ERROR_FMT(result == -1, FileReadError, "unable to select from %s", strPtr(this->name)); THROW_ON_SYS_ERROR_FMT(result == -1, FileReadError, "unable to select from %s", strZ(this->name));
// If no data read after time allotted then error // If no data read after time allotted then error
if (!result) if (!result)
THROW_FMT(FileReadError, "unable to read data from %s after %" PRIu64 "ms", strPtr(this->name), this->timeout); THROW_FMT(FileReadError, "unable to read data from %s after %" PRIu64 "ms", strZ(this->name), this->timeout);
// Read and handle errors // Read and handle errors
THROW_ON_SYS_ERROR_FMT( THROW_ON_SYS_ERROR_FMT(
(actualBytes = read(this->handle, bufRemainsPtr(buffer), bufRemains(buffer))) == -1, FileReadError, (actualBytes = read(this->handle, bufRemainsPtr(buffer), bufRemains(buffer))) == -1, FileReadError,
"unable to read from %s", strPtr(this->name)); "unable to read from %s", strZ(this->name));
// Update amount of buffer used // Update amount of buffer used
bufUsedInc(buffer, (size_t)actualBytes); bufUsedInc(buffer, (size_t)actualBytes);

View File

@ -47,8 +47,7 @@ ioHandleWrite(THIS_VOID, const Buffer *buffer)
ASSERT(buffer != NULL); ASSERT(buffer != NULL);
THROW_ON_SYS_ERROR_FMT( THROW_ON_SYS_ERROR_FMT(
write(this->handle, bufPtrConst(buffer), bufUsed(buffer)) == -1, FileWriteError, write(this->handle, bufPtrConst(buffer), bufUsed(buffer)) == -1, FileWriteError, "unable to write to %s", strZ(this->name));
"unable to write to %s", strPtr(this->name));
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
@ -109,7 +108,7 @@ ioHandleWriteOneStr(int handle, const String *string)
ASSERT(string != NULL); ASSERT(string != NULL);
if (write(handle, strPtr(string), strSize(string)) != (int)strSize(string)) if (write(handle, strZ(string), strSize(string)) != (int)strSize(string))
THROW_SYS_ERROR(FileWriteError, "unable to write to handle"); THROW_SYS_ERROR(FileWriteError, "unable to write to handle");
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();

View File

@ -28,7 +28,7 @@ httpDateToTime(const String *lastModified)
MEM_CONTEXT_TEMP_BEGIN() MEM_CONTEXT_TEMP_BEGIN()
{ {
// Find the month // Find the month
const char *month = strPtr(strSubN(lastModified, 8, 3)); const char *month = strZ(strSubN(lastModified, 8, 3));
unsigned int monthIdx = 0; unsigned int monthIdx = 0;
for (; monthIdx < sizeof(httpCommonMonthList) / sizeof(char *); monthIdx++) for (; monthIdx < sizeof(httpCommonMonthList) / sizeof(char *); monthIdx++)
@ -42,9 +42,9 @@ httpDateToTime(const String *lastModified)
// Convert to time_t // Convert to time_t
result = epochFromParts( result = epochFromParts(
cvtZToInt(strPtr(strSubN(lastModified, 12, 4))), (int)monthIdx + 1, cvtZToInt(strPtr(strSubN(lastModified, 5, 2))), cvtZToInt(strZ(strSubN(lastModified, 12, 4))), (int)monthIdx + 1, cvtZToInt(strZ(strSubN(lastModified, 5, 2))),
cvtZToInt(strPtr(strSubN(lastModified, 17, 2))), cvtZToInt(strPtr(strSubN(lastModified, 20, 2))), cvtZToInt(strZ(strSubN(lastModified, 17, 2))), cvtZToInt(strZ(strSubN(lastModified, 20, 2))),
cvtZToInt(strPtr(strSubN(lastModified, 23, 2))), 0); cvtZToInt(strZ(strSubN(lastModified, 23, 2))), 0);
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
@ -87,17 +87,17 @@ httpUriDecode(const String *uri)
// Iterate all characters in the string // Iterate all characters in the string
for (unsigned uriIdx = 0; uriIdx < strSize(uri); uriIdx++) for (unsigned uriIdx = 0; uriIdx < strSize(uri); uriIdx++)
{ {
char uriChar = strPtr(uri)[uriIdx]; char uriChar = strZ(uri)[uriIdx];
// Convert escaped characters // Convert escaped characters
if (uriChar == '%') if (uriChar == '%')
{ {
// Sequence must be exactly three characters (% and two hex digits) // Sequence must be exactly three characters (% and two hex digits)
if (strSize(uri) - uriIdx < 3) if (strSize(uri) - uriIdx < 3)
THROW_FMT(FormatError, "invalid escape sequence length in '%s'", strPtr(uri)); THROW_FMT(FormatError, "invalid escape sequence length in '%s'", strZ(uri));
// Convert hex digits // Convert hex digits
uriChar = (char)cvtZToUIntBase(strPtr(strSubN(uri, uriIdx + 1, 2)), 16); uriChar = (char)cvtZToUIntBase(strZ(strSubN(uri, uriIdx + 1, 2)), 16);
// Skip to next character or escape // Skip to next character or escape
uriIdx += 2; uriIdx += 2;
@ -131,7 +131,7 @@ httpUriEncode(const String *uri, bool path)
// Iterate all characters in the string // Iterate all characters in the string
for (unsigned uriIdx = 0; uriIdx < strSize(uri); uriIdx++) for (unsigned uriIdx = 0; uriIdx < strSize(uri); uriIdx++)
{ {
char uriChar = strPtr(uri)[uriIdx]; char uriChar = strZ(uri)[uriIdx];
// These characters are reproduced verbatim // These characters are reproduced verbatim
if ((uriChar >= 'A' && uriChar <= 'Z') || (uriChar >= 'a' && uriChar <= 'z') || (uriChar >= '0' && uriChar <= '9') || if ((uriChar >= 'A' && uriChar <= 'Z') || (uriChar >= 'a' && uriChar <= 'z') || (uriChar >= '0' && uriChar <= '9') ||

View File

@ -105,7 +105,7 @@ httpHeaderAdd(HttpHeader *this, const String *key, const String *value)
{ {
String *valueAppend = strDup(varStr(valueVar)); String *valueAppend = strDup(varStr(valueVar));
strCatZ(valueAppend, ", "); strCatZ(valueAppend, ", ");
strCatZ(valueAppend, strPtr(value)); strCatZ(valueAppend, strZ(value));
kvPut(this->kv, keyVar, VARSTR(valueAppend)); kvPut(this->kv, keyVar, VARSTR(valueAppend));
} }
@ -196,9 +196,9 @@ httpHeaderToLog(const HttpHeader *this)
strCatZ(result, ", "); strCatZ(result, ", ");
if (httpHeaderRedact(this, key)) if (httpHeaderRedact(this, key))
strCatFmt(result, "%s: <redacted>", strPtr(key)); strCatFmt(result, "%s: <redacted>", strZ(key));
else else
strCatFmt(result, "%s: '%s'", strPtr(key), strPtr(httpHeaderGet(this, key))); strCatFmt(result, "%s: '%s'", strZ(key), strZ(httpHeaderGet(this, key)));
} }
strCatZ(result, "}"); strCatZ(result, "}");

View File

@ -89,8 +89,8 @@ httpQueryNewStr(const String *query)
if (strLstSize(keyValue) != 2) if (strLstSize(keyValue) != 2)
{ {
THROW_FMT( THROW_FMT(
FormatError, "invalid key/value '%s' in query '%s'", strPtr(strLstGet(keyValueList, keyValueIdx)), FormatError, "invalid key/value '%s' in query '%s'", strZ(strLstGet(keyValueList, keyValueIdx)),
strPtr(query)); strZ(query));
} }
httpQueryAdd(this, httpUriDecode(strLstGet(keyValue, 0)), httpUriDecode(strLstGet(keyValue, 1))); httpQueryAdd(this, httpUriDecode(strLstGet(keyValue, 0)), httpUriDecode(strLstGet(keyValue, 1)));
@ -152,7 +152,7 @@ httpQueryAdd(HttpQuery *this, const String *key, const String *value)
const Variant *keyVar = VARSTR(key); const Variant *keyVar = VARSTR(key);
if (kvGet(this->kv, keyVar) != NULL) if (kvGet(this->kv, keyVar) != NULL)
THROW_FMT(AssertError, "key '%s' already exists", strPtr(key)); THROW_FMT(AssertError, "key '%s' already exists", strZ(key));
// Store the key // Store the key
kvPut(this->kv, keyVar, VARSTR(value)); kvPut(this->kv, keyVar, VARSTR(value));
@ -284,9 +284,9 @@ httpQueryRender(const HttpQuery *this, HttpQueryRenderParam param)
strCatZ(result, "&"); strCatZ(result, "&");
strCatFmt( strCatFmt(
result, "%s=%s", strPtr(key), result, "%s=%s", strZ(key),
param.redact && httpQueryRedact(this, key) ? param.redact && httpQueryRedact(this, key) ?
"<redacted>" : strPtr(httpUriEncode(httpQueryGet(this, key), false))); "<redacted>" : strZ(httpUriEncode(httpQueryGet(this, key), false)));
} }
} }
} }
@ -310,12 +310,12 @@ httpQueryToLog(const HttpQuery *this)
if (strSize(result) != 1) if (strSize(result) != 1)
strCatZ(result, ", "); strCatZ(result, ", ");
strCatFmt(result, "%s: ", strPtr(key)); strCatFmt(result, "%s: ", strZ(key));
if (httpQueryRedact(this, key)) if (httpQueryRedact(this, key))
strCatZ(result, "<redacted>"); strCatZ(result, "<redacted>");
else else
strCatFmt(result, "'%s'", strPtr(httpQueryGet(this, key))); strCatFmt(result, "'%s'", strZ(httpQueryGet(this, key)));
} }
strCatZ(result, "}"); strCatZ(result, "}");

View File

@ -103,8 +103,8 @@ httpRequestProcess(HttpRequest *this, bool waitForResponse, bool contentCache)
// Format the request // Format the request
String *requestStr = String *requestStr =
strNewFmt( strNewFmt(
"%s %s%s%s " HTTP_VERSION CRLF_Z, strPtr(this->verb), strPtr(httpUriEncode(this->uri, true)), "%s %s%s%s " HTTP_VERSION CRLF_Z, strZ(this->verb), strZ(httpUriEncode(this->uri, true)),
this->query == NULL ? "" : "?", this->query == NULL ? "" : strPtr(httpQueryRenderP(this->query))); this->query == NULL ? "" : "?", this->query == NULL ? "" : strZ(httpQueryRenderP(this->query)));
// Add headers // Add headers
const StringList *headerList = httpHeaderList(this->header); const StringList *headerList = httpHeaderList(this->header);
@ -113,8 +113,7 @@ httpRequestProcess(HttpRequest *this, bool waitForResponse, bool contentCache)
{ {
const String *headerKey = strLstGet(headerList, headerIdx); const String *headerKey = strLstGet(headerList, headerIdx);
strCatFmt( strCatFmt(requestStr, "%s:%s" CRLF_Z, strZ(headerKey), strZ(httpHeaderGet(this->header, headerKey)));
requestStr, "%s:%s" CRLF_Z, strPtr(headerKey), strPtr(httpHeaderGet(this->header, headerKey)));
} }
// Add blank line to end of headers and write the request as a buffer so secrets do not show up in logs // Add blank line to end of headers and write the request as a buffer so secrets do not show up in logs
@ -142,7 +141,7 @@ httpRequestProcess(HttpRequest *this, bool waitForResponse, bool contentCache)
// looks valid. There are a few errors that might be permanently fatal but they are rare and it seems best // looks valid. There are a few errors that might be permanently fatal but they are rare and it seems best
// not to try and pick and choose errors in this class to retry. // not to try and pick and choose errors in this class to retry.
if (httpResponseCode(result) / 100 == HTTP_RESPONSE_CODE_RETRY_CLASS) if (httpResponseCode(result) / 100 == HTTP_RESPONSE_CODE_RETRY_CLASS)
THROW_FMT(ServiceError, "[%u] %s", httpResponseCode(result), strPtr(httpResponseReason(result))); THROW_FMT(ServiceError, "[%u] %s", httpResponseCode(result), strZ(httpResponseReason(result)));
// Move response to outer temp context // Move response to outer temp context
httpResponseMove(result, memContextPrior()); httpResponseMove(result, memContextPrior());
@ -248,15 +247,15 @@ httpRequestError(const HttpRequest *this, HttpResponse *response)
// Add reason when present // Add reason when present
if (strSize(httpResponseReason(response)) > 0) if (strSize(httpResponseReason(response)) > 0)
strCatFmt(error, " (%s)", strPtr(httpResponseReason(response))); strCatFmt(error, " (%s)", strZ(httpResponseReason(response)));
// Output uri/query // Output uri/query
strCatZ(error, ":\n*** URI/Query ***:"); strCatZ(error, ":\n*** URI/Query ***:");
strCatFmt(error, "\n%s", strPtr(httpUriEncode(this->uri, true))); strCatFmt(error, "\n%s", strZ(httpUriEncode(this->uri, true)));
if (this->query != NULL) if (this->query != NULL)
strCatFmt(error, "?%s", strPtr(httpQueryRenderP(this->query, .redact = true))); strCatFmt(error, "?%s", strZ(httpQueryRenderP(this->query, .redact = true)));
// Output request headers // Output request headers
const StringList *requestHeaderList = httpHeaderList(this->header); const StringList *requestHeaderList = httpHeaderList(this->header);
@ -270,8 +269,8 @@ httpRequestError(const HttpRequest *this, HttpResponse *response)
const String *key = strLstGet(requestHeaderList, requestHeaderIdx); const String *key = strLstGet(requestHeaderList, requestHeaderIdx);
strCatFmt( strCatFmt(
error, "\n%s: %s", strPtr(key), error, "\n%s: %s", strZ(key),
httpHeaderRedact(this->header, key) ? "<redacted>" : strPtr(httpHeaderGet(this->header, key))); httpHeaderRedact(this->header, key) ? "<redacted>" : strZ(httpHeaderGet(this->header, key)));
} }
} }
@ -286,7 +285,7 @@ httpRequestError(const HttpRequest *this, HttpResponse *response)
for (unsigned int responseHeaderIdx = 0; responseHeaderIdx < strLstSize(responseHeaderList); responseHeaderIdx++) for (unsigned int responseHeaderIdx = 0; responseHeaderIdx < strLstSize(responseHeaderList); responseHeaderIdx++)
{ {
const String *key = strLstGet(responseHeaderList, responseHeaderIdx); const String *key = strLstGet(responseHeaderList, responseHeaderIdx);
strCatFmt(error, "\n%s: %s", strPtr(key), strPtr(httpHeaderGet(responseHeader, key))); strCatFmt(error, "\n%s: %s", strZ(key), strZ(httpHeaderGet(responseHeader, key)));
} }
} }
@ -297,7 +296,7 @@ httpRequestError(const HttpRequest *this, HttpResponse *response)
strCat(error, strNewBuf(httpResponseContent(response))); strCat(error, strNewBuf(httpResponseContent(response)));
} }
THROW(ProtocolError, strPtr(error)); THROW(ProtocolError, strZ(error));
} }
/**********************************************************************************************************************************/ /**********************************************************************************************************************************/
@ -305,7 +304,7 @@ String *
httpRequestToLog(const HttpRequest *this) httpRequestToLog(const HttpRequest *this)
{ {
return strNewFmt( return strNewFmt(
"{verb: %s, uri: %s, query: %s, header: %s, contentSize: %zu}", "{verb: %s, uri: %s, query: %s, header: %s, contentSize: %zu}", strZ(this->verb), strZ(this->uri),
strPtr(this->verb), strPtr(this->uri), this->query == NULL ? "null" : strPtr(httpQueryToLog(this->query)), this->query == NULL ? "null" : strZ(httpQueryToLog(this->query)), strZ(httpHeaderToLog(this->header)),
strPtr(httpHeaderToLog(this->header)), this->content == NULL ? 0 : bufUsed(this->content)); this->content == NULL ? 0 : bufUsed(this->content));
} }

View File

@ -132,7 +132,7 @@ httpResponseRead(THIS_VOID, Buffer *buffer, bool block)
if (this->contentChunked && this->contentRemaining == 0) if (this->contentChunked && this->contentRemaining == 0)
{ {
// Read length of next chunk // Read length of next chunk
this->contentRemaining = cvtZToUInt64Base(strPtr(strTrim(ioReadLine(rawRead))), 16); this->contentRemaining = cvtZToUInt64Base(strZ(strTrim(ioReadLine(rawRead))), 16);
// If content remaining is still zero then eof // If content remaining is still zero then eof
if (this->contentRemaining == 0) if (this->contentRemaining == 0)
@ -236,17 +236,17 @@ httpResponseNew(HttpSession *session, const String *verb, bool contentCache)
// Check status ends with a CR and remove it to make error formatting easier and more accurate // Check status ends with a CR and remove it to make error formatting easier and more accurate
if (!strEndsWith(status, CR_STR)) if (!strEndsWith(status, CR_STR))
THROW_FMT(FormatError, "HTTP response status '%s' should be CR-terminated", strPtr(status)); THROW_FMT(FormatError, "HTTP response status '%s' should be CR-terminated", strZ(status));
status = strSubN(status, 0, strSize(status) - 1); status = strSubN(status, 0, strSize(status) - 1);
// Check status is at least the minimum required length to avoid harder to interpret errors later on // Check status is at least the minimum required length to avoid harder to interpret errors later on
if (strSize(status) < sizeof(HTTP_VERSION) + 4) if (strSize(status) < sizeof(HTTP_VERSION) + 4)
THROW_FMT(FormatError, "HTTP response '%s' has invalid length", strPtr(strTrim(status))); THROW_FMT(FormatError, "HTTP response '%s' has invalid length", strZ(strTrim(status)));
// Check status starts with the correct http version // Check status starts with the correct http version
if (!strBeginsWith(status, HTTP_VERSION_STR)) if (!strBeginsWith(status, HTTP_VERSION_STR))
THROW_FMT(FormatError, "HTTP version of response '%s' must be " HTTP_VERSION, strPtr(status)); THROW_FMT(FormatError, "HTTP version of response '%s' must be " HTTP_VERSION, strZ(status));
// Read status code // Read status code
status = strSub(status, sizeof(HTTP_VERSION)); status = strSub(status, sizeof(HTTP_VERSION));
@ -254,9 +254,9 @@ httpResponseNew(HttpSession *session, const String *verb, bool contentCache)
int spacePos = strChr(status, ' '); int spacePos = strChr(status, ' ');
if (spacePos != 3) if (spacePos != 3)
THROW_FMT(FormatError, "response status '%s' must have a space after the status code", strPtr(status)); THROW_FMT(FormatError, "response status '%s' must have a space after the status code", strZ(status));
this->code = cvtZToUInt(strPtr(strSubN(status, 0, (size_t)spacePos))); this->code = cvtZToUInt(strZ(strSubN(status, 0, (size_t)spacePos)));
// Read reason phrase. A missing reason phrase will be represented as an empty string. // Read reason phrase. A missing reason phrase will be represented as an empty string.
MEM_CONTEXT_BEGIN(this->memContext) MEM_CONTEXT_BEGIN(this->memContext)
@ -279,7 +279,7 @@ httpResponseNew(HttpSession *session, const String *verb, bool contentCache)
int colonPos = strChr(header, ':'); int colonPos = strChr(header, ':');
if (colonPos < 0) if (colonPos < 0)
THROW_FMT(FormatError, "header '%s' missing colon", strPtr(strTrim(header))); THROW_FMT(FormatError, "header '%s' missing colon", strZ(strTrim(header)));
String *headerKey = strLower(strTrim(strSubN(header, 0, (size_t)colonPos))); String *headerKey = strLower(strTrim(strSubN(header, 0, (size_t)colonPos)));
String *headerValue = strTrim(strSub(header, (size_t)colonPos + 1)); String *headerValue = strTrim(strSub(header, (size_t)colonPos + 1));
@ -303,7 +303,7 @@ httpResponseNew(HttpSession *session, const String *verb, bool contentCache)
// Read content size // Read content size
if (strEq(headerKey, HTTP_HEADER_CONTENT_LENGTH_STR)) if (strEq(headerKey, HTTP_HEADER_CONTENT_LENGTH_STR))
{ {
this->contentSize = cvtZToUInt64(strPtr(headerValue)); this->contentSize = cvtZToUInt64(strZ(headerValue));
this->contentRemaining = this->contentSize; this->contentRemaining = this->contentSize;
} }
@ -409,7 +409,7 @@ httpResponseToLog(const HttpResponse *this)
return strNewFmt( return strNewFmt(
"{code: %u, reason: %s, header: %s, contentChunked: %s, contentSize: %" PRIu64 ", contentRemaining: %" PRIu64 "{code: %u, reason: %s, header: %s, contentChunked: %s, contentSize: %" PRIu64 ", contentRemaining: %" PRIu64
", closeOnContentEof: %s, contentExists: %s, contentEof: %s, contentCached: %s}", ", closeOnContentEof: %s, contentExists: %s, contentEof: %s, contentCached: %s}",
this->code, strPtr(this->reason), strPtr(httpHeaderToLog(this->header)), this->code, strZ(this->reason), strZ(httpHeaderToLog(this->header)), cvtBoolToConstZ(this->contentChunked),
cvtBoolToConstZ(this->contentChunked), this->contentSize, this->contentRemaining, cvtBoolToConstZ(this->closeOnContentEof), this->contentSize, this->contentRemaining, cvtBoolToConstZ(this->closeOnContentEof), cvtBoolToConstZ(this->contentExists),
cvtBoolToConstZ(this->contentExists), cvtBoolToConstZ(this->contentEof), cvtBoolToConstZ(this->content != NULL)); cvtBoolToConstZ(this->contentEof), cvtBoolToConstZ(this->content != NULL));
} }

View File

@ -112,10 +112,10 @@ sckClientOpen(SocketClient *this)
struct addrinfo *hostAddress; struct addrinfo *hostAddress;
int resultAddr; int resultAddr;
if ((resultAddr = getaddrinfo(strPtr(this->host), port, &hints, &hostAddress)) != 0) if ((resultAddr = getaddrinfo(strZ(this->host), port, &hints, &hostAddress)) != 0)
{ {
THROW_FMT( THROW_FMT(
HostConnectError, "unable to get address for '%s': [%d] %s", strPtr(this->host), resultAddr, HostConnectError, "unable to get address for '%s': [%d] %s", strZ(this->host), resultAddr,
gai_strerror(resultAddr)); gai_strerror(resultAddr));
} }
@ -190,5 +190,5 @@ sckClientStatStr(void)
String * String *
sckClientToLog(const SocketClient *this) sckClientToLog(const SocketClient *this)
{ {
return strNewFmt("{host: %s, port: %u, timeout: %" PRIu64 "}", strPtr(this->host), this->port, this->timeout); return strNewFmt("{host: %s, port: %u, timeout: %" PRIu64 "}", strZ(this->host), this->port, this->timeout);
} }

View File

@ -169,7 +169,7 @@ sckConnect(int fd, const String *host, unsigned int port, const struct addrinfo
{ {
// Wait for write-ready // Wait for write-ready
if (!sckReadyWrite(fd, timeout)) if (!sckReadyWrite(fd, timeout))
THROW_FMT(HostConnectError, "timeout connecting to '%s:%u'", strPtr(host), port); THROW_FMT(HostConnectError, "timeout connecting to '%s:%u'", strZ(host), port);
// Check for success or error. If the connection was successful this will set errNo to 0. // Check for success or error. If the connection was successful this will set errNo to 0.
socklen_t errNoLen = sizeof(errNo); socklen_t errNoLen = sizeof(errNo);
@ -180,7 +180,7 @@ sckConnect(int fd, const String *host, unsigned int port, const struct addrinfo
// Throw error if it is still set // Throw error if it is still set
if (errNo != 0) if (errNo != 0)
THROW_SYS_ERROR_CODE_FMT(errNo, HostConnectError, "unable to connect to '%s:%u'", strPtr(host), port); THROW_SYS_ERROR_CODE_FMT(errNo, HostConnectError, "unable to connect to '%s:%u'", strZ(host), port);
} }
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();

View File

@ -93,7 +93,7 @@ sckSessionReadyRead(SocketSession *this)
if (!sckReadyRead(this->fd, this->timeout)) if (!sckReadyRead(this->fd, this->timeout))
{ {
THROW_FMT( THROW_FMT(
ProtocolError, "timeout after %" PRIu64 "ms waiting for read from '%s:%u'", this->timeout, strPtr(this->host), ProtocolError, "timeout after %" PRIu64 "ms waiting for read from '%s:%u'", this->timeout, strZ(this->host),
this->port); this->port);
} }
@ -112,8 +112,7 @@ sckSessionReadyWrite(SocketSession *this)
if (!sckReadyWrite(this->fd, this->timeout)) if (!sckReadyWrite(this->fd, this->timeout))
{ {
THROW_FMT( THROW_FMT(
ProtocolError, "timeout after %" PRIu64 "ms waiting for write to '%s:%u'", this->timeout, strPtr(this->host), ProtocolError, "timeout after %" PRIu64 "ms waiting for write to '%s:%u'", this->timeout, strZ(this->host), this->port);
this->port);
} }
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
@ -125,5 +124,5 @@ sckSessionToLog(const SocketSession *this)
{ {
return strNewFmt( return strNewFmt(
"{type: %s, fd %d, host: %s, port: %u, timeout: %" PRIu64 "}", this->type == sckSessionTypeClient ? "client" : "server", "{type: %s, fd %d, host: %s, port: %u, timeout: %" PRIu64 "}", this->type == sckSessionTypeClient ? "client" : "server",
this->fd, strPtr(this->host), this->port, this->timeout); this->fd, strZ(this->host), this->port, this->timeout);
} }

View File

@ -104,7 +104,7 @@ tlsClientNew(SocketClient *socket, TimeMSec timeout, bool verifyPeer, const Stri
if (caFile != NULL || caPath != NULL) // {vm_covered} if (caFile != NULL || caPath != NULL) // {vm_covered}
{ {
cryptoError( // {vm_covered} cryptoError( // {vm_covered}
SSL_CTX_load_verify_locations(this->context, strPtrNull(caFile), strPtrNull(caPath)) != 1, // {vm_covered} SSL_CTX_load_verify_locations(this->context, strZNull(caFile), strZNull(caPath)) != 1, // {vm_covered}
"unable to set user-defined CA certificate location"); // {vm_covered} "unable to set user-defined CA certificate location"); // {vm_covered}
} }
// Else use the defaults // Else use the defaults
@ -160,13 +160,13 @@ tlsClientHostVerifyName(const String *host, const String *name)
ASSERT(name != NULL); ASSERT(name != NULL);
// Reject embedded nulls in certificate common or alternative name to prevent attacks like CVE-2009-4034 // Reject embedded nulls in certificate common or alternative name to prevent attacks like CVE-2009-4034
if (strlen(strPtr(name)) != strSize(name)) if (strlen(strZ(name)) != strSize(name))
THROW(CryptoError, "TLS certificate name contains embedded null"); THROW(CryptoError, "TLS certificate name contains embedded null");
bool result = false; bool result = false;
// Try an exact match // Try an exact match
if (strcasecmp(strPtr(name), strPtr(host)) == 0) // {vm_covered} if (strcasecmp(strZ(name), strZ(host)) == 0) // {vm_covered}
{ {
result = true; // {vm_covered} result = true; // {vm_covered}
} }
@ -180,9 +180,9 @@ tlsClientHostVerifyName(const String *host, const String *name)
// //
// This is roughly in line with RFC2818, but contrary to what most browsers appear to be implementing (point 3 being the // This is roughly in line with RFC2818, but contrary to what most browsers appear to be implementing (point 3 being the
// difference) // difference)
else if (strPtr(name)[0] == '*' && strPtr(name)[1] == '.' && strSize(name) > 2 && // {vm_covered} else if (strZ(name)[0] == '*' && strZ(name)[1] == '.' && strSize(name) > 2 && // {vm_covered}
strSize(name) < strSize(host) && // {vm_covered} strSize(name) < strSize(host) && // {vm_covered}
strcasecmp(strPtr(name) + 1, strPtr(host) + strSize(host) - strSize(name) + 1) == 0 && // {vm_covered} strcasecmp(strZ(name) + 1, strZ(host) + strSize(host) - strSize(name) + 1) == 0 && // {vm_covered}
strChr(host, '.') >= (int)(strSize(host) - strSize(name))) // {vm_covered} strChr(host, '.') >= (int)(strSize(host) - strSize(name))) // {vm_covered}
{ {
result = true; // {vm_covered} result = true; // {vm_covered}
@ -292,7 +292,7 @@ tlsClientOpen(TlsClient *this)
// Set server host name used for validation // Set server host name used for validation
cryptoError( cryptoError(
SSL_set_tlsext_host_name(session, strPtr(sckClientHost(this->socketClient))) != 1, SSL_set_tlsext_host_name(session, strZ(sckClientHost(this->socketClient))) != 1,
"unable to set TLS host name"); "unable to set TLS host name");
// Create the TLS session // Create the TLS session
@ -333,7 +333,7 @@ tlsClientOpen(TlsClient *this)
{ {
THROW_FMT( // {vm_covered} THROW_FMT( // {vm_covered}
CryptoError, "unable to verify certificate presented by '%s:%u': [%ld] %s", // {vm_covered} CryptoError, "unable to verify certificate presented by '%s:%u': [%ld] %s", // {vm_covered}
strPtr(sckClientHost(this->socketClient)), sckClientPort(this->socketClient), verifyResult, // {vm_covered} strZ(sckClientHost(this->socketClient)), sckClientPort(this->socketClient), verifyResult, // {vm_covered}
X509_verify_cert_error_string(verifyResult)); // {vm_covered} X509_verify_cert_error_string(verifyResult)); // {vm_covered}
} }
@ -347,7 +347,7 @@ tlsClientOpen(TlsClient *this)
THROW_FMT( // {vm_covered} THROW_FMT( // {vm_covered}
CryptoError, // {vm_covered} CryptoError, // {vm_covered}
"unable to find hostname '%s' in certificate common name or subject alternative names", // {vm_covered} "unable to find hostname '%s' in certificate common name or subject alternative names", // {vm_covered}
strPtr(sckClientHost(this->socketClient))); // {vm_covered} strZ(sckClientHost(this->socketClient))); // {vm_covered}
} }
} }

View File

@ -59,7 +59,7 @@ lockAcquireFile(const String *lockFile, TimeMSec lockTimeout, bool failOnNoLock)
do do
{ {
// Attempt to open the file // Attempt to open the file
if ((result = open(strPtr(lockFile), O_WRONLY | O_CREAT, STORAGE_MODE_FILE_DEFAULT)) == -1) if ((result = open(strZ(lockFile), O_WRONLY | O_CREAT, STORAGE_MODE_FILE_DEFAULT)) == -1)
{ {
// Save the error for reporting outside the loop // Save the error for reporting outside the loop
errNo = errno; errNo = errno;
@ -100,13 +100,12 @@ lockAcquireFile(const String *lockFile, TimeMSec lockTimeout, bool failOnNoLock)
else if (errNo == EACCES) else if (errNo == EACCES)
{ {
errorHint = strNewFmt( errorHint = strNewFmt(
"\nHINT: does the user running " PROJECT_NAME " have permissions on the '%s' file?", "\nHINT: does the user running " PROJECT_NAME " have permissions on the '%s' file?", strZ(lockFile));
strPtr(lockFile));
} }
THROW_FMT( THROW_FMT(
LockAcquireError, "unable to acquire lock on file '%s': %s%s", LockAcquireError, "unable to acquire lock on file '%s': %s%s", strZ(lockFile), strerror(errNo),
strPtr(lockFile), strerror(errNo), errorHint == NULL ? "" : strPtr(errorHint)); errorHint == NULL ? "" : strZ(errorHint));
} }
} }
else else
@ -186,7 +185,7 @@ lockAcquire(const String *lockPath, const String *stanza, LockType lockType, Tim
for (LockType lockIdx = lockMin; lockIdx <= lockMax; lockIdx++) for (LockType lockIdx = lockMin; lockIdx <= lockMax; lockIdx++)
{ {
lockFile[lockIdx] = strNewFmt("%s/%s-%s" LOCK_FILE_EXT, strPtr(lockPath), strPtr(stanza), lockTypeName[lockIdx]); lockFile[lockIdx] = strNewFmt("%s/%s-%s" LOCK_FILE_EXT, strZ(lockPath), strZ(stanza), lockTypeName[lockIdx]);
lockHandle[lockIdx] = lockAcquireFile(lockFile[lockIdx], lockTimeout, failOnNoLock); lockHandle[lockIdx] = lockAcquireFile(lockFile[lockIdx], lockTimeout, failOnNoLock);

View File

@ -81,7 +81,7 @@ regExpNew(const String *expression)
// Compile the regexp and process errors // Compile the regexp and process errors
int result = 0; int result = 0;
if ((result = regcomp(&this->regExp, strPtr(expression), REG_EXTENDED)) != 0) if ((result = regcomp(&this->regExp, strZ(expression), REG_EXTENDED)) != 0)
{ {
memFree(this); memFree(this);
regExpError(result); regExpError(result);
@ -109,7 +109,7 @@ regExpMatch(RegExp *this, const String *string)
// Test for a match // Test for a match
regmatch_t matchPtr; regmatch_t matchPtr;
int result = regexec(&this->regExp, strPtr(string), 1, &matchPtr, 0); int result = regexec(&this->regExp, strZ(string), 1, &matchPtr, 0);
// Check for an error // Check for an error
regExpErrorCheck(result); regExpErrorCheck(result);
@ -117,7 +117,7 @@ regExpMatch(RegExp *this, const String *string)
// Store match results // Store match results
if (result == 0) if (result == 0)
{ {
this->matchPtr = strPtr(string) + matchPtr.rm_so; this->matchPtr = strZ(string) + matchPtr.rm_so;
this->matchSize = (size_t)(matchPtr.rm_eo - matchPtr.rm_so); this->matchSize = (size_t)(matchPtr.rm_eo - matchPtr.rm_so);
} }
// Else reset match results // Else reset match results
@ -208,9 +208,9 @@ regExpPrefix(const String *expression)
String *result = NULL; String *result = NULL;
// Only generate prefix if expression is defined and has a beginning anchor // Only generate prefix if expression is defined and has a beginning anchor
if (expression != NULL && strPtr(expression)[0] == '^') if (expression != NULL && strZ(expression)[0] == '^')
{ {
const char *expressionZ = strPtr(expression); const char *expressionZ = strZ(expression);
size_t expressionSize = strSize(expression); size_t expressionSize = strSize(expression);
unsigned int expressionIdx = 1; unsigned int expressionIdx = 1;

View File

@ -355,7 +355,7 @@ bufToLog(const Buffer *this)
{ {
String *result = strNewFmt( String *result = strNewFmt(
"{used: %zu, size: %zu%s", this->used, this->size, "{used: %zu, size: %zu%s", this->used, this->size,
this->sizeLimit ? strPtr(strNewFmt(", sizeAlloc: %zu}", this->sizeAlloc)) : "}"); this->sizeLimit ? strZ(strNewFmt(", sizeAlloc: %zu}", this->sizeAlloc)) : "}");
return result; return result;
} }

View File

@ -159,7 +159,7 @@ By convention all buffer constant identifiers are appended with _BUF.
// Create a buffer constant inline from a String // Create a buffer constant inline from a String
#define BUFSTR(string) \ #define BUFSTR(string) \
BUF((unsigned char *)strPtr(string), strSize(string)) BUF((unsigned char *)strZ(string), strSize(string))
// Create a buffer constant inline from a constant zero-terminated string // Create a buffer constant inline from a constant zero-terminated string
#define BUFSTRDEF(stringdef) \ #define BUFSTRDEF(stringdef) \

View File

@ -68,14 +68,14 @@ jsonToBool(const String *json)
FUNCTION_TEST_END(); FUNCTION_TEST_END();
unsigned int jsonPos = 0; unsigned int jsonPos = 0;
jsonConsumeWhiteSpace(strPtr(json), &jsonPos); jsonConsumeWhiteSpace(strZ(json), &jsonPos);
bool result = jsonToBoolInternal(strPtr(json), &jsonPos); bool result = jsonToBoolInternal(strZ(json), &jsonPos);
jsonConsumeWhiteSpace(strPtr(json), &jsonPos); jsonConsumeWhiteSpace(strZ(json), &jsonPos);
if (jsonPos != strSize(json)) if (jsonPos != strSize(json))
THROW_FMT(JsonFormatError, "unexpected characters after boolean at '%s'", strPtr(json) + jsonPos); THROW_FMT(JsonFormatError, "unexpected characters after boolean at '%s'", strZ(json) + jsonPos);
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -117,9 +117,9 @@ jsonToNumberInternal(const char *json, unsigned int *jsonPos)
MEM_CONTEXT_PRIOR_BEGIN() MEM_CONTEXT_PRIOR_BEGIN()
{ {
if (intSigned) if (intSigned)
result = varNewInt64(cvtZToInt64(strPtr(resultStr))); result = varNewInt64(cvtZToInt64(strZ(resultStr)));
else else
result = varNewUInt64(cvtZToUInt64(strPtr(resultStr))); result = varNewUInt64(cvtZToUInt64(strZ(resultStr)));
} }
MEM_CONTEXT_PRIOR_END(); MEM_CONTEXT_PRIOR_END();
} }
@ -136,14 +136,14 @@ jsonToNumber(const String *json)
FUNCTION_TEST_END(); FUNCTION_TEST_END();
unsigned int jsonPos = 0; unsigned int jsonPos = 0;
jsonConsumeWhiteSpace(strPtr(json), &jsonPos); jsonConsumeWhiteSpace(strZ(json), &jsonPos);
Variant *result = jsonToNumberInternal(strPtr(json), &jsonPos); Variant *result = jsonToNumberInternal(strZ(json), &jsonPos);
jsonConsumeWhiteSpace(strPtr(json), &jsonPos); jsonConsumeWhiteSpace(strZ(json), &jsonPos);
if (jsonPos != strSize(json)) if (jsonPos != strSize(json))
THROW_FMT(JsonFormatError, "unexpected characters after number at '%s'", strPtr(json) + jsonPos); THROW_FMT(JsonFormatError, "unexpected characters after number at '%s'", strZ(json) + jsonPos);
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -329,19 +329,19 @@ jsonToStr(const String *json)
FUNCTION_TEST_END(); FUNCTION_TEST_END();
unsigned int jsonPos = 0; unsigned int jsonPos = 0;
jsonConsumeWhiteSpace(strPtr(json), &jsonPos); jsonConsumeWhiteSpace(strZ(json), &jsonPos);
String *result = NULL; String *result = NULL;
if (strncmp(strPtr(json), NULL_Z, 4) == 0) if (strncmp(strZ(json), NULL_Z, 4) == 0)
jsonPos += 4; jsonPos += 4;
else else
result = jsonToStrInternal(strPtr(json), &jsonPos); result = jsonToStrInternal(strZ(json), &jsonPos);
jsonConsumeWhiteSpace(strPtr(json), &jsonPos); jsonConsumeWhiteSpace(strZ(json), &jsonPos);
if (jsonPos != strSize(json)) if (jsonPos != strSize(json))
THROW_FMT(JsonFormatError, "unexpected characters after string at '%s'", strPtr(json) + jsonPos); THROW_FMT(JsonFormatError, "unexpected characters after string at '%s'", strZ(json) + jsonPos);
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -406,17 +406,17 @@ jsonToKv(const String *json)
FUNCTION_TEST_END(); FUNCTION_TEST_END();
unsigned int jsonPos = 0; unsigned int jsonPos = 0;
jsonConsumeWhiteSpace(strPtr(json), &jsonPos); jsonConsumeWhiteSpace(strZ(json), &jsonPos);
if (strPtr(json)[jsonPos] != '{') if (strZ(json)[jsonPos] != '{')
THROW_FMT(JsonFormatError, "expected '{' at '%s'", strPtr(json) + jsonPos); THROW_FMT(JsonFormatError, "expected '{' at '%s'", strZ(json) + jsonPos);
KeyValue *result = jsonToKvInternal(strPtr(json), &jsonPos); KeyValue *result = jsonToKvInternal(strZ(json), &jsonPos);
jsonConsumeWhiteSpace(strPtr(json), &jsonPos); jsonConsumeWhiteSpace(strZ(json), &jsonPos);
if (jsonPos != strSize(json)) if (jsonPos != strSize(json))
THROW_FMT(JsonFormatError, "unexpected characters after object at '%s'", strPtr(json) + jsonPos); THROW_FMT(JsonFormatError, "unexpected characters after object at '%s'", strZ(json) + jsonPos);
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -481,14 +481,14 @@ jsonToVarLst(const String *json)
FUNCTION_TEST_END(); FUNCTION_TEST_END();
unsigned int jsonPos = 0; unsigned int jsonPos = 0;
jsonConsumeWhiteSpace(strPtr(json), &jsonPos); jsonConsumeWhiteSpace(strZ(json), &jsonPos);
VariantList *result = jsonToVarLstInternal(strPtr(json), &jsonPos); VariantList *result = jsonToVarLstInternal(strZ(json), &jsonPos);
jsonConsumeWhiteSpace(strPtr(json), &jsonPos); jsonConsumeWhiteSpace(strZ(json), &jsonPos);
if (jsonPos != strSize(json)) if (jsonPos != strSize(json))
THROW_FMT(JsonFormatError, "unexpected characters after array at '%s'", strPtr(json) + jsonPos); THROW_FMT(JsonFormatError, "unexpected characters after array at '%s'", strZ(json) + jsonPos);
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -581,13 +581,13 @@ jsonToVar(const String *json)
FUNCTION_LOG_PARAM(STRING, json); FUNCTION_LOG_PARAM(STRING, json);
FUNCTION_LOG_END(); FUNCTION_LOG_END();
const char *jsonPtr = strPtr(json); const char *jsonPtr = strZ(json);
unsigned int jsonPos = 0; unsigned int jsonPos = 0;
Variant *result = jsonToVarInternal(jsonPtr, &jsonPos); Variant *result = jsonToVarInternal(jsonPtr, &jsonPos);
if (jsonPos != strSize(json)) if (jsonPos != strSize(json))
THROW_FMT(JsonFormatError, "unexpected characters after JSON at '%s'", strPtr(json) + jsonPos); THROW_FMT(JsonFormatError, "unexpected characters after JSON at '%s'", strZ(json) + jsonPos);
FUNCTION_LOG_RETURN(VARIANT, result); FUNCTION_LOG_RETURN(VARIANT, result);
} }
@ -683,7 +683,7 @@ jsonFromStrInternal(String *json, const String *string)
for (unsigned int stringIdx = 0; stringIdx < strSize(string); stringIdx++) for (unsigned int stringIdx = 0; stringIdx < strSize(string); stringIdx++)
{ {
char stringChr = strPtr(string)[stringIdx]; char stringChr = strZ(string)[stringIdx];
switch (stringChr) switch (stringChr)
{ {
@ -754,7 +754,7 @@ jsonFromStrInternal(String *json, const String *string)
{ {
// If escape string is zero size then start it // If escape string is zero size then start it
if (noEscapeSize == 0) if (noEscapeSize == 0)
noEscape = strPtr(string) + stringIdx; noEscape = strZ(string) + stringIdx;
noEscapeSize++; noEscapeSize++;
break; break;
@ -813,7 +813,7 @@ jsonFromKvInternal(const KeyValue *kv)
strCatZ(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\":", strZ(key));
// NULL value // NULL value
if (value == NULL) if (value == NULL)

View File

@ -235,7 +235,7 @@ strBeginsWith(const String *this, const String *beginsWith)
ASSERT(this != NULL); ASSERT(this != NULL);
ASSERT(beginsWith != NULL); ASSERT(beginsWith != NULL);
FUNCTION_TEST_RETURN(strBeginsWithZ(this, strPtr(beginsWith))); FUNCTION_TEST_RETURN(strBeginsWithZ(this, strZ(beginsWith)));
} }
bool bool
@ -253,7 +253,7 @@ strBeginsWithZ(const String *this, const char *beginsWith)
unsigned int beginsWithSize = (unsigned int)strlen(beginsWith); unsigned int beginsWithSize = (unsigned int)strlen(beginsWith);
if (this->size >= beginsWithSize) if (this->size >= beginsWithSize)
result = strncmp(strPtr(this), beginsWith, beginsWithSize) == 0; result = strncmp(strZ(this), beginsWith, beginsWithSize) == 0;
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -303,7 +303,7 @@ strCat(String *this, const String *cat)
ASSERT(this != NULL); ASSERT(this != NULL);
ASSERT(cat != NULL); ASSERT(cat != NULL);
FUNCTION_TEST_RETURN(strCatZN(this, strPtr(cat), strSize(cat))); FUNCTION_TEST_RETURN(strCatZN(this, strZ(cat), strSize(cat)));
} }
String * String *
@ -422,7 +422,7 @@ strCmp(const String *this, const String *compare)
FUNCTION_TEST_END(); FUNCTION_TEST_END();
if (this != NULL && compare != NULL) if (this != NULL && compare != NULL)
FUNCTION_TEST_RETURN(strcmp(strPtr(this), strPtr(compare))); FUNCTION_TEST_RETURN(strcmp(strZ(this), strZ(compare)));
else if (this == NULL) else if (this == NULL)
{ {
if (compare == NULL) if (compare == NULL)
@ -456,7 +456,7 @@ strDup(const String *this)
String *result = NULL; String *result = NULL;
if (this != NULL) if (this != NULL)
result = strNew(strPtr(this)); result = strNew(strZ(this));
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -484,7 +484,7 @@ strEndsWith(const String *this, const String *endsWith)
ASSERT(this != NULL); ASSERT(this != NULL);
ASSERT(endsWith != NULL); ASSERT(endsWith != NULL);
FUNCTION_TEST_RETURN(strEndsWithZ(this, strPtr(endsWith))); FUNCTION_TEST_RETURN(strEndsWithZ(this, strZ(endsWith)));
} }
bool bool
@ -502,7 +502,7 @@ strEndsWithZ(const String *this, const char *endsWith)
unsigned int endsWithSize = (unsigned int)strlen(endsWith); unsigned int endsWithSize = (unsigned int)strlen(endsWith);
if (this->size >= endsWithSize) if (this->size >= endsWithSize)
result = strcmp(strPtr(this) + (this->size - endsWithSize), endsWith) == 0; result = strcmp(strZ(this) + (this->size - endsWithSize), endsWith) == 0;
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -524,7 +524,7 @@ strEq(const String *this, const String *compare)
if (this != NULL && compare != NULL) if (this != NULL && compare != NULL)
{ {
if (this->size == compare->size) if (this->size == compare->size)
result = strcmp(strPtr(this), strPtr(compare)) == 0; result = strcmp(strZ(this), strZ(compare)) == 0;
} }
else else
result = this == NULL && compare == NULL; result = this == NULL && compare == NULL;
@ -543,7 +543,7 @@ strEqZ(const String *this, const char *compare)
ASSERT(this != NULL); ASSERT(this != NULL);
ASSERT(compare != NULL); ASSERT(compare != NULL);
FUNCTION_TEST_RETURN(strcmp(strPtr(this), compare) == 0); FUNCTION_TEST_RETURN(strcmp(strZ(this), compare) == 0);
} }
/**********************************************************************************************************************************/ /**********************************************************************************************************************************/
@ -659,7 +659,7 @@ strPathAbsolute(const String *this, const String *base)
// Base must be absolute to start // Base must be absolute to start
if (!strBeginsWith(base, FSLASH_STR)) if (!strBeginsWith(base, FSLASH_STR))
THROW_FMT(AssertError, "base path '%s' is not absolute", strPtr(base)); THROW_FMT(AssertError, "base path '%s' is not absolute", strZ(base));
MEM_CONTEXT_TEMP_BEGIN() MEM_CONTEXT_TEMP_BEGIN()
{ {
@ -680,7 +680,7 @@ strPathAbsolute(const String *this, const String *base)
break; break;
} }
THROW_FMT(AssertError, "'%s' is not a valid relative path", strPtr(this)); THROW_FMT(AssertError, "'%s' is not a valid relative path", strZ(this));
} }
if (strEq(pathPart, DOTDOT_STR)) if (strEq(pathPart, DOTDOT_STR))
@ -688,10 +688,7 @@ strPathAbsolute(const String *this, const String *base)
const String *basePart = strLstGet(baseList, strLstSize(baseList) - 1); const String *basePart = strLstGet(baseList, strLstSize(baseList) - 1);
if (strSize(basePart) == 0) if (strSize(basePart) == 0)
{ THROW_FMT(AssertError, "relative path '%s' goes back too far in base path '%s'", strZ(this), strZ(base));
THROW_FMT(
AssertError, "relative path '%s' goes back too far in base path '%s'", strPtr(this), strPtr(base));
}
strLstRemoveIdx(baseList, strLstSize(baseList) - 1); strLstRemoveIdx(baseList, strLstSize(baseList) - 1);
} }
@ -714,15 +711,15 @@ strPathAbsolute(const String *this, const String *base)
} }
// There should not be any stray .. or // in the final result // There should not be any stray .. or // in the final result
if (strstr(strPtr(result), "/..") != NULL || strstr(strPtr(result), "//") != NULL) if (strstr(strZ(result), "/..") != NULL || strstr(strZ(result), "//") != NULL)
THROW_FMT(AssertError, "result path '%s' is not absolute", strPtr(result)); THROW_FMT(AssertError, "result path '%s' is not absolute", strZ(result));
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
/**********************************************************************************************************************************/ /**********************************************************************************************************************************/
const char * const char *
strPtrNull(const String *this) strZNull(const String *this)
{ {
FUNCTION_TEST_BEGIN(); FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(STRING, this); FUNCTION_TEST_PARAM(STRING, this);
@ -743,7 +740,7 @@ strQuote(const String *this, const String *quote)
ASSERT(this != NULL); ASSERT(this != NULL);
ASSERT(quote != NULL); ASSERT(quote != NULL);
FUNCTION_TEST_RETURN(strQuoteZ(this, strPtr(quote))); FUNCTION_TEST_RETURN(strQuoteZ(this, strZ(quote)));
} }
String * String *
@ -757,7 +754,7 @@ strQuoteZ(const String *this, const char *quote)
ASSERT(this != NULL); ASSERT(this != NULL);
ASSERT(quote != NULL); ASSERT(quote != NULL);
FUNCTION_TEST_RETURN(strNewFmt("%s%s%s", quote, strPtr(this), quote)); FUNCTION_TEST_RETURN(strNewFmt("%s%s%s", quote, strZ(this), quote));
} }
/**********************************************************************************************************************************/ /**********************************************************************************************************************************/
@ -925,7 +922,7 @@ size_t strObjToLog(const void *object, StrObjToLogFormat formatFunc, char *buffe
MEM_CONTEXT_TEMP_BEGIN() MEM_CONTEXT_TEMP_BEGIN()
{ {
result = (size_t)snprintf(buffer, bufferSize, "%s", object == NULL ? NULL_Z : strPtr(formatFunc(object))); result = (size_t)snprintf(buffer, bufferSize, "%s", object == NULL ? NULL_Z : strZ(formatFunc(object)));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
@ -936,7 +933,7 @@ size_t strObjToLog(const void *object, StrObjToLogFormat formatFunc, char *buffe
String * String *
strToLog(const String *this) strToLog(const String *this)
{ {
return this == NULL ? strDup(NULL_STR) : strNewFmt("{\"%s\"}", strPtr(this)); return this == NULL ? strDup(NULL_STR) : strNewFmt("{\"%s\"}", strZ(this));
} }
/**********************************************************************************************************************************/ /**********************************************************************************************************************************/

View File

@ -136,15 +136,15 @@ String *strPath(const String *this);
// Combine with a base path to get an absolute path // Combine with a base path to get an absolute path
String *strPathAbsolute(const String *this, const String *base); String *strPathAbsolute(const String *this, const String *base);
// Pointer to zero-terminated string. strPtrNull() returns NULL when the String is NULL. // Pointer to zero-terminated string. strZNull() returns NULL when the String is NULL.
__attribute__((always_inline)) static inline const char * __attribute__((always_inline)) static inline const char *
strPtr(const String *this) strZ(const String *this)
{ {
ASSERT_INLINE(this != NULL); ASSERT_INLINE(this != NULL);
return ((const StringConst *)this)->buffer; return ((const StringConst *)this)->buffer;
} }
const char *strPtrNull(const String *this); const char *strZNull(const String *this);
// Quote a string // Quote a string
String *strQuote(const String *this, const String *quote); String *strQuote(const String *this, const String *quote);

View File

@ -67,7 +67,7 @@ strLstNewSplit(const String *string, const String *delimiter)
ASSERT(string != NULL); ASSERT(string != NULL);
ASSERT(delimiter != NULL); ASSERT(delimiter != NULL);
FUNCTION_TEST_RETURN(strLstNewSplitZ(string, strPtr(delimiter))); FUNCTION_TEST_RETURN(strLstNewSplitZ(string, strZ(delimiter)));
} }
StringList * StringList *
@ -85,7 +85,7 @@ strLstNewSplitZ(const String *string, const char *delimiter)
StringList *this = strLstNew(); StringList *this = strLstNew();
// Base points to the beginning of the string that is being searched // Base points to the beginning of the string that is being searched
const char *stringBase = strPtr(string); const char *stringBase = strZ(string);
// Match points to the next delimiter match that has been found // Match points to the next delimiter match that has been found
const char *stringMatch = NULL; const char *stringMatch = NULL;
@ -127,7 +127,7 @@ strLstNewSplitSize(const String *string, const String *delimiter, size_t size)
ASSERT(string != NULL); ASSERT(string != NULL);
ASSERT(delimiter != NULL); ASSERT(delimiter != NULL);
FUNCTION_TEST_RETURN(strLstNewSplitSizeZ(string, strPtr(delimiter), size)); FUNCTION_TEST_RETURN(strLstNewSplitSizeZ(string, strZ(delimiter), size));
} }
StringList * StringList *
@ -146,7 +146,7 @@ strLstNewSplitSizeZ(const String *string, const char *delimiter, size_t size)
StringList *this = strLstNew(); StringList *this = strLstNew();
// Base points to the beginning of the string that is being searched // Base points to the beginning of the string that is being searched
const char *stringBase = strPtr(string); const char *stringBase = strZ(string);
// Match points to the next delimiter match that has been found // Match points to the next delimiter match that has been found
const char *stringMatchLast = NULL; const char *stringMatchLast = NULL;
@ -435,7 +435,7 @@ strLstJoinQuote(const StringList *this, const char *separator, const char *quote
if (strLstGet(this, listIdx) == NULL) if (strLstGet(this, listIdx) == NULL)
strCatZ(join, "[NULL]"); strCatZ(join, "[NULL]");
else else
strCatFmt(join, "%s%s%s", quote, strPtr(strLstGet(this, listIdx)), quote); strCatFmt(join, "%s%s%s", quote, strZ(strLstGet(this, listIdx)), quote);
} }
FUNCTION_TEST_RETURN(join); FUNCTION_TEST_RETURN(join);
@ -535,7 +535,7 @@ strLstPtr(const StringList *this)
if (strLstGet(this, listIdx) == NULL) if (strLstGet(this, listIdx) == NULL)
list[listIdx] = NULL; list[listIdx] = NULL;
else else
list[listIdx] = strPtr(strLstGet(this, listIdx)); list[listIdx] = strZ(strLstGet(this, listIdx));
} }
list[strLstSize(this)] = NULL; list[strLstSize(this)] = NULL;
@ -618,7 +618,7 @@ strLstComparatorSet(StringList *this, ListComparator *comparator)
String * String *
strLstToLog(const StringList *this) strLstToLog(const StringList *this)
{ {
return strNewFmt("{[%s]}", strPtr(strLstJoinQuote(this, ", ", "\""))); return strNewFmt("{[%s]}", strZ(strLstJoinQuote(this, ", ", "\"")));
} }
/**********************************************************************************************************************************/ /**********************************************************************************************************************************/

View File

@ -351,7 +351,7 @@ varBoolForce(const Variant *this)
}; };
// Search for the string // Search for the string
const char *string = strPtr(varStr(this)); const char *string = strZ(varStr(this));
unsigned int boolIdx; unsigned int boolIdx;
for (boolIdx = 0; boolIdx < sizeof(boolString) / sizeof(char *); boolIdx++) for (boolIdx = 0; boolIdx < sizeof(boolString) / sizeof(char *); boolIdx++)
@ -457,7 +457,7 @@ varDblForce(const Variant *this)
case varTypeString: case varTypeString:
{ {
result = cvtZToDouble(strPtr(varStr(this))); result = cvtZToDouble(strZ(varStr(this)));
break; break;
} }
@ -556,7 +556,7 @@ varIntForce(const Variant *this)
case varTypeString: case varTypeString:
{ {
result = cvtZToInt(strPtr(varStr(this))); result = cvtZToInt(strZ(varStr(this)));
break; break;
} }
@ -663,7 +663,7 @@ varInt64Force(const Variant *this)
case varTypeString: case varTypeString:
{ {
result = cvtZToInt64(strPtr(varStr(this))); result = cvtZToInt64(strZ(varStr(this)));
break; break;
} }
@ -811,7 +811,7 @@ varUIntForce(const Variant *this)
case varTypeString: case varTypeString:
{ {
result = cvtZToUInt(strPtr(varStr(this))); result = cvtZToUInt(strZ(varStr(this)));
break; break;
} }
@ -912,7 +912,7 @@ varUInt64Force(const Variant *this)
case varTypeString: case varTypeString:
{ {
result = cvtZToUInt64(strPtr(varStr(this))); result = cvtZToUInt64(strZ(varStr(this)));
break; break;
} }
@ -1183,7 +1183,7 @@ varToLog(const Variant *this)
case varTypeUInt: case varTypeUInt:
case varTypeUInt64: case varTypeUInt64:
{ {
result = strNewFmt("{%s}", strPtr(varStrForce(this))); result = strNewFmt("{%s}", strZ(varStrForce(this)));
break; break;
} }
} }

View File

@ -12,7 +12,7 @@ old context and then back. Below is a simplified example:
MEM_CONTEXT_PRIOR_BEGIN() <--- switch to old context so creation of the variant from the string is in old context MEM_CONTEXT_PRIOR_BEGIN() <--- switch to old context so creation of the variant from the string is in old context
{ {
result = varNewUInt64(cvtZToUInt64(strPtr(resultStr))); <--- recreates variant from the string in the old context. result = varNewUInt64(cvtZToUInt64(strZ(resultStr))); <--- recreates variant from the string in the old context.
} }
MEM_CONTEXT_PRIOR_END(); <--- switch back to the temporary context MEM_CONTEXT_PRIOR_END(); <--- switch back to the temporary context
} }

View File

@ -159,7 +159,7 @@ xmlNodeAdd(XmlNode *this, const String *name)
ASSERT(this != NULL); ASSERT(this != NULL);
ASSERT(name != NULL); ASSERT(name != NULL);
XmlNode *result = xmlNodeNew(xmlNewNode(NULL, BAD_CAST strPtr(name))); XmlNode *result = xmlNodeNew(xmlNewNode(NULL, BAD_CAST strZ(name)));
xmlAddChild(this->node, result->node); xmlAddChild(this->node, result->node);
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
@ -202,7 +202,7 @@ xmlNodeAttribute(const XmlNode *this, const String *name)
ASSERT(name != NULL); ASSERT(name != NULL);
String *result = NULL; String *result = NULL;
xmlChar *value = xmlGetProp(this->node, (unsigned char *)strPtr(name)); xmlChar *value = xmlGetProp(this->node, (unsigned char *)strZ(name));
if (value != NULL) if (value != NULL)
{ {
@ -244,7 +244,7 @@ xmlNodeContentSet(XmlNode *this, const String *content)
ASSERT(this != NULL); ASSERT(this != NULL);
ASSERT(content != NULL); ASSERT(content != NULL);
xmlAddChild(this->node, xmlNewText(BAD_CAST strPtr(content))); xmlAddChild(this->node, xmlNewText(BAD_CAST strZ(content)));
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
} }
@ -303,7 +303,7 @@ xmlNodeChildN(const XmlNode *this, const String *name, unsigned int index, bool
} }
if (child == NULL && errorOnMissing) if (child == NULL && errorOnMissing)
THROW_FMT(FormatError, "unable to find child '%s':%u in node '%s'", strPtr(name), index, this->node->name); THROW_FMT(FormatError, "unable to find child '%s':%u in node '%s'", strZ(name), index, this->node->name);
FUNCTION_TEST_RETURN(child); FUNCTION_TEST_RETURN(child);
} }
@ -394,7 +394,7 @@ xmlDocumentNew(const String *rootName)
// Set callback to ensure xml document is freed // Set callback to ensure xml document is freed
memContextCallbackSet(this->memContext, xmlDocumentFreeResource, this); memContextCallbackSet(this->memContext, xmlDocumentFreeResource, this);
this->root = xmlNodeNew(xmlNewNode(NULL, BAD_CAST strPtr(rootName))); this->root = xmlNodeNew(xmlNewNode(NULL, BAD_CAST strZ(rootName)));
xmlDocSetRootElement(this->xml, this->root->node); xmlDocSetRootElement(this->xml, this->root->node);
} }
MEM_CONTEXT_NEW_END(); MEM_CONTEXT_NEW_END();

View File

@ -81,7 +81,7 @@ groupIdFromName(const String *groupName)
if (groupName != NULL) if (groupName != NULL)
{ {
struct group *groupData = getgrnam(strPtr(groupName)); struct group *groupData = getgrnam(strZ(groupName));
if (groupData != NULL) if (groupData != NULL)
FUNCTION_TEST_RETURN(groupData->gr_gid); FUNCTION_TEST_RETURN(groupData->gr_gid);
@ -132,7 +132,7 @@ userIdFromName(const String *userName)
if (userName != NULL) if (userName != NULL)
{ {
struct passwd *userData = getpwnam(strPtr(userName)); struct passwd *userData = getpwnam(strZ(userName));
if (userData != NULL) if (userData != NULL)
FUNCTION_TEST_RETURN(userData->pw_uid); FUNCTION_TEST_RETURN(userData->pw_uid);

View File

@ -247,7 +247,7 @@ cfgCommandRoleNameParam(ConfigCommand commandId, ConfigCommandRole commandRoleId
String *result = strNew(cfgCommandName(commandId)); String *result = strNew(cfgCommandName(commandId));
if (commandRoleId != cfgCmdRoleDefault) if (commandRoleId != cfgCmdRoleDefault)
strCatFmt(result, "%s%s", strPtr(separator), strPtr(cfgCommandRoleStr(commandRoleId))); strCatFmt(result, "%s%s", strZ(separator), strZ(cfgCommandRoleStr(commandRoleId)));
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -317,7 +317,7 @@ cfgCommandRoleEnum(const String *commandRole)
else if (strEq(commandRole, CONFIG_COMMAND_ROLE_REMOTE_STR)) else if (strEq(commandRole, CONFIG_COMMAND_ROLE_REMOTE_STR))
FUNCTION_TEST_RETURN(cfgCmdRoleRemote); FUNCTION_TEST_RETURN(cfgCmdRoleRemote);
THROW_FMT(CommandInvalidError, "invalid command role '%s'", strPtr(commandRole)); THROW_FMT(CommandInvalidError, "invalid command role '%s'", strZ(commandRole));
} }
const String * const String *
@ -616,7 +616,7 @@ cfgOptionHostPort(ConfigOption optionId, unsigned int *port)
OptionInvalidError, OptionInvalidError,
"'%s' is not valid for option '%s'" "'%s' is not valid for option '%s'"
"\nHINT: is more than one port specified?", "\nHINT: is more than one port specified?",
strPtr(host), cfgOptionName(optionId)); strZ(host), cfgOptionName(optionId));
} }
// Set the host // Set the host
@ -629,7 +629,7 @@ cfgOptionHostPort(ConfigOption optionId, unsigned int *port)
// Set the port and error if it is not a positive integer // Set the port and error if it is not a positive integer
TRY_BEGIN() TRY_BEGIN()
{ {
*port = cvtZToUInt(strPtr(strLstGet(hostPart, 1))); *port = cvtZToUInt(strZ(strLstGet(hostPart, 1)));
} }
CATCH(FormatError) CATCH(FormatError)
{ {
@ -637,7 +637,7 @@ cfgOptionHostPort(ConfigOption optionId, unsigned int *port)
OptionInvalidError, OptionInvalidError,
"'%s' is not valid for option '%s'" "'%s' is not valid for option '%s'"
"\nHINT: port is not a positive integer.", "\nHINT: port is not a positive integer.",
strPtr(host), cfgOptionName(optionId)); strZ(host), cfgOptionName(optionId));
} }
TRY_END(); TRY_END();
} }

View File

@ -96,8 +96,8 @@ cfgExecParam(ConfigCommand commandId, ConfigCommandRole commandRoleId, const Key
strLstAdd( strLstAdd(
valueList, valueList,
strNewFmt( strNewFmt(
"%s=%s", strPtr(varStr(varLstGet(keyList, keyIdx))), "%s=%s", strZ(varStr(varLstGet(keyList, keyIdx))),
strPtr(varStrForce(kvGet(optionKv, varLstGet(keyList, keyIdx)))))); strZ(varStrForce(kvGet(optionKv, varLstGet(keyList, keyIdx))))));
} }
} }
else if (varType(value) == varTypeVariantList) else if (varType(value) == varTypeVariantList)
@ -116,10 +116,10 @@ cfgExecParam(ConfigCommand commandId, ConfigCommandRole commandRoleId, const Key
{ {
const String *value = strLstGet(valueList, valueListIdx); const String *value = strLstGet(valueList, valueListIdx);
if (quote && strchr(strPtr(value), ' ') != NULL) if (quote && strchr(strZ(value), ' ') != NULL)
value = strNewFmt("\"%s\"", strPtr(value)); value = strNewFmt("\"%s\"", strZ(value));
strLstAdd(result, strNewFmt("--%s=%s", cfgOptionName(optionId), strPtr(value))); strLstAdd(result, strNewFmt("--%s=%s", cfgOptionName(optionId), strZ(value)));
} }
} }
} }

View File

@ -35,15 +35,15 @@ cfgLoadLogSetting(void)
unsigned int logProcessMax = 1; unsigned int logProcessMax = 1;
if (cfgOptionValid(cfgOptLogLevelConsole)) if (cfgOptionValid(cfgOptLogLevelConsole))
logLevelConsole = logLevelEnum(strPtr(cfgOptionStr(cfgOptLogLevelConsole))); logLevelConsole = logLevelEnum(strZ(cfgOptionStr(cfgOptLogLevelConsole)));
if (cfgOptionValid(cfgOptLogLevelStderr)) if (cfgOptionValid(cfgOptLogLevelStderr))
{ {
logLevelStdErr = logLevelEnum(strPtr(cfgOptionStr(cfgOptLogLevelStderr))); logLevelStdErr = logLevelEnum(strZ(cfgOptionStr(cfgOptLogLevelStderr)));
} }
if (cfgOptionValid(cfgOptLogLevelFile)) if (cfgOptionValid(cfgOptLogLevelFile))
logLevelFile = logLevelEnum(strPtr(cfgOptionStr(cfgOptLogLevelFile))); logLevelFile = logLevelEnum(strZ(cfgOptionStr(cfgOptLogLevelFile)));
if (cfgOptionValid(cfgOptLogTimestamp)) if (cfgOptionValid(cfgOptLogTimestamp))
logTimestamp = cfgOptionBool(cfgOptLogTimestamp); logTimestamp = cfgOptionBool(cfgOptLogTimestamp);
@ -104,8 +104,8 @@ cfgLoadUpdateOption(void)
OptionInvalidValueError, OptionInvalidValueError,
"'%s' is not valid for '" CFGOPT_PROTOCOL_TIMEOUT "' option\nHINT '" CFGOPT_PROTOCOL_TIMEOUT "' option (%s)" "'%s' is not valid for '" CFGOPT_PROTOCOL_TIMEOUT "' option\nHINT '" CFGOPT_PROTOCOL_TIMEOUT "' option (%s)"
" should be greater than '" CFGOPT_DB_TIMEOUT "' option (%s).", " should be greater than '" CFGOPT_DB_TIMEOUT "' option (%s).",
strPtr(varStrForce(cfgOption(cfgOptProtocolTimeout))), strPtr(varStrForce(cfgOption(cfgOptProtocolTimeout))), strZ(varStrForce(cfgOption(cfgOptProtocolTimeout))), strZ(varStrForce(cfgOption(cfgOptProtocolTimeout))),
strPtr(varStrForce(cfgOption(cfgOptDbTimeout)))); strZ(varStrForce(cfgOption(cfgOptDbTimeout))));
} }
} }
@ -146,7 +146,7 @@ cfgLoadUpdateOption(void)
"option '%s' is not set for '%s=%s', the repository may run out of space" "option '%s' is not set for '%s=%s', the repository may run out of space"
"\nHINT: to retain full backups indefinitely (without warning), set option '%s' to the maximum.", "\nHINT: to retain full backups indefinitely (without warning), set option '%s' to the maximum.",
cfgOptionName(cfgOptRepoRetentionFull + optionIdx), cfgOptionName(cfgOptRepoRetentionFullType + optionIdx), cfgOptionName(cfgOptRepoRetentionFull + optionIdx), cfgOptionName(cfgOptRepoRetentionFullType + optionIdx),
strPtr(cfgOptionStr(cfgOptRepoRetentionFullType + optionIdx)), strZ(cfgOptionStr(cfgOptRepoRetentionFullType + optionIdx)),
cfgOptionName(cfgOptRepoRetentionFull + optionIdx)); cfgOptionName(cfgOptRepoRetentionFull + optionIdx));
} }
} }
@ -162,7 +162,7 @@ cfgLoadUpdateOption(void)
const String *msgArchiveOff = strNewFmt( const String *msgArchiveOff = strNewFmt(
"WAL segments will not be expired: option '" CFGOPT_REPO1_RETENTION_ARCHIVE_TYPE "=%s' but", "WAL segments will not be expired: option '" CFGOPT_REPO1_RETENTION_ARCHIVE_TYPE "=%s' but",
strPtr(archiveRetentionType)); strZ(archiveRetentionType));
// If the archive retention is not explicitly set then determine what it should be defaulted to // If the archive retention is not explicitly set then determine what it should be defaulted to
if (!cfgOptionTest(cfgOptRepoRetentionArchive + optionIdx)) if (!cfgOptionTest(cfgOptRepoRetentionArchive + optionIdx))
@ -189,7 +189,8 @@ cfgLoadUpdateOption(void)
} }
else else
{ {
LOG_WARN_FMT("%s neither option '%s' nor option '%s' is set", strPtr(msgArchiveOff), LOG_WARN_FMT(
"%s neither option '%s' nor option '%s' is set", strZ(msgArchiveOff),
cfgOptionName(cfgOptRepoRetentionArchive + optionIdx), cfgOptionName(cfgOptRepoRetentionArchive + optionIdx),
cfgOptionName(cfgOptRepoRetentionDiff + optionIdx)); cfgOptionName(cfgOptRepoRetentionDiff + optionIdx));
} }
@ -198,7 +199,8 @@ cfgLoadUpdateOption(void)
{ {
CHECK(strEqZ(archiveRetentionType, CFGOPTVAL_TMP_REPO_RETENTION_ARCHIVE_TYPE_INCR)); CHECK(strEqZ(archiveRetentionType, CFGOPTVAL_TMP_REPO_RETENTION_ARCHIVE_TYPE_INCR));
LOG_WARN_FMT("%s option '%s' is not set", strPtr(msgArchiveOff), LOG_WARN_FMT(
"%s option '%s' is not set", strZ(msgArchiveOff),
cfgOptionName(cfgOptRepoRetentionArchive + optionIdx)); cfgOptionName(cfgOptRepoRetentionArchive + optionIdx));
} }
} }
@ -231,7 +233,7 @@ cfgLoadUpdateOption(void)
"\nHINT: RFC-2818 forbids dots in wildcard matches." "\nHINT: RFC-2818 forbids dots in wildcard matches."
"\nHINT: TLS/SSL verification cannot proceed with this bucket name." "\nHINT: TLS/SSL verification cannot proceed with this bucket name."
"\nHINT: remove dots from the bucket name.", "\nHINT: remove dots from the bucket name.",
strPtr(cfgOptionStr(cfgOptRepoS3Bucket))); strZ(cfgOptionStr(cfgOptRepoS3Bucket)));
} }
// Check/update compress-type if compress is valid. There should be no references to the compress option outside this block. // Check/update compress-type if compress is valid. There should be no references to the compress option outside this block.
@ -282,8 +284,8 @@ cfgLoadLogFile(void)
{ {
// Construct log filename prefix // Construct log filename prefix
String *logFile = strNewFmt( String *logFile = strNewFmt(
"%s/%s-%s", strPtr(cfgOptionStr(cfgOptLogPath)), "%s/%s-%s", strZ(cfgOptionStr(cfgOptLogPath)),
cfgOptionTest(cfgOptStanza) ? strPtr(cfgOptionStr(cfgOptStanza)): "all", cfgCommandName(cfgCommand())); cfgOptionTest(cfgOptStanza) ? strZ(cfgOptionStr(cfgOptStanza)): "all", cfgCommandName(cfgCommand()));
// ??? Append async for local/remote archive async commands. It would be good to find a more generic way to do this in // ??? Append async for local/remote archive async commands. It would be good to find a more generic way to do this in
// case the async role is added to more commands. // case the async role is added to more commands.
@ -295,7 +297,7 @@ cfgLoadLogFile(void)
// Add command role if it is not default // Add command role if it is not default
if (cfgCommandRole() != cfgCmdRoleDefault) if (cfgCommandRole() != cfgCmdRoleDefault)
strCatFmt(logFile, "-%s", strPtr(cfgCommandRoleStr(cfgCommandRole()))); strCatFmt(logFile, "-%s", strZ(cfgCommandRoleStr(cfgCommandRole())));
// Add process id if local or remote role // Add process id if local or remote role
if (cfgCommandRole() == cfgCmdRoleLocal || cfgCommandRole() == cfgCmdRoleRemote) if (cfgCommandRole() == cfgCmdRoleLocal || cfgCommandRole() == cfgCmdRoleRemote)
@ -305,7 +307,7 @@ cfgLoadLogFile(void)
strCatZ(logFile, ".log"); strCatZ(logFile, ".log");
// Attempt to open log file // Attempt to open log file
if (!logFileSet(strPtr(logFile))) if (!logFileSet(strZ(logFile)))
cfgOptionSet(cfgOptLogLevelFile, cfgSourceParam, varNewStrZ("off")); cfgOptionSet(cfgOptLogLevelFile, cfgSourceParam, varNewStrZ("off"));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();

View File

@ -93,7 +93,7 @@ optionFind(const String *option)
while (optionList[optionIdx].name != NULL) while (optionList[optionIdx].name != NULL)
{ {
if (strcmp(strPtr(option), optionList[optionIdx].name) == 0) if (strcmp(strZ(option), optionList[optionIdx].name) == 0)
break; break;
optionIdx++; optionIdx++;
@ -176,7 +176,7 @@ convertToByte(String **value, double *valueDbl)
if (regExpMatchOne(STRDEF("^[0-9]+(kb|k|mb|m|gb|g|tb|t|pb|p|b)*$"), result)) if (regExpMatchOne(STRDEF("^[0-9]+(kb|k|mb|m|gb|g|tb|t|pb|p|b)*$"), result))
{ {
// Get the character array and size // Get the character array and size
const char *strArray = strPtr(result); const char *strArray = strZ(result);
size_t size = strSize(result); size_t size = strSize(result);
int chrPos = -1; int chrPos = -1;
@ -215,7 +215,7 @@ convertToByte(String **value, double *valueDbl)
*value = result; *value = result;
} }
else else
THROW_FMT(FormatError, "value '%s' is not valid", strPtr(*value)); THROW_FMT(FormatError, "value '%s' is not valid", strZ(*value));
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
@ -316,9 +316,9 @@ cfgFileLoad( // NOTE: Pas
if (optionList[cfgOptConfigPath].found) if (optionList[cfgOptConfigPath].found)
{ {
optConfigDefault = optConfigDefault =
strNewFmt("%s/%s", strPtr(strLstGet(optionList[cfgOptConfigPath].valueList, 0)), strBaseZ(optConfigDefault)); strNewFmt("%s/%s", strZ(strLstGet(optionList[cfgOptConfigPath].valueList, 0)), strBaseZ(optConfigDefault));
optConfigIncludePathDefault = optConfigIncludePathDefault =
strNewFmt("%s/%s", strPtr(strLstGet(optionList[cfgOptConfigPath].valueList, 0)), PGBACKREST_CONFIG_INCLUDE_PATH); strNewFmt("%s/%s", strZ(strLstGet(optionList[cfgOptConfigPath].valueList, 0)), PGBACKREST_CONFIG_INCLUDE_PATH);
} }
// If the --no-config option was passed then do not load the config file // If the --no-config option was passed then do not load the config file
@ -400,7 +400,7 @@ cfgFileLoad( // NOTE: Pas
&result, &result,
storageGetP( storageGetP(
storageNewReadP( storageNewReadP(
storageLocal(), strNewFmt("%s/%s", strPtr(configIncludePath), strPtr(strLstGet(list, listIdx))), storageLocal(), strNewFmt("%s/%s", strZ(configIncludePath), strZ(strLstGet(list, listIdx))),
.ignoreMissing = true))); .ignoreMissing = true)));
} }
} }
@ -472,7 +472,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
if (strLstSize(commandPart) == 2) if (strLstSize(commandPart) == 2)
{ {
// Get command id // Get command id
commandId = cfgCommandId(strPtr(strLstGet(commandPart, 0)), false); commandId = cfgCommandId(strZ(strLstGet(commandPart, 0)), false);
// If command id is valid then get command role id // If command id is valid then get command role id
if (commandId != cfgCmdNone) if (commandId != cfgCmdNone)
@ -651,19 +651,19 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
// Warn if the option not found // Warn if the option not found
if (optionList[optionIdx].name == NULL) if (optionList[optionIdx].name == NULL)
{ {
LOG_WARN_FMT("environment contains invalid option '%s'", strPtr(key)); LOG_WARN_FMT("environment contains invalid option '%s'", strZ(key));
continue; continue;
} }
// Warn if negate option found in env // Warn if negate option found in env
else if (optionList[optionIdx].val & PARSE_NEGATE_FLAG) else if (optionList[optionIdx].val & PARSE_NEGATE_FLAG)
{ {
LOG_WARN_FMT("environment contains invalid negate option '%s'", strPtr(key)); LOG_WARN_FMT("environment contains invalid negate option '%s'", strZ(key));
continue; continue;
} }
// Warn if reset option found in env // Warn if reset option found in env
else if (optionList[optionIdx].val & PARSE_RESET_FLAG) else if (optionList[optionIdx].val & PARSE_RESET_FLAG)
{ {
LOG_WARN_FMT("environment contains invalid reset option '%s'", strPtr(key)); LOG_WARN_FMT("environment contains invalid reset option '%s'", strZ(key));
continue; continue;
} }
@ -675,7 +675,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
continue; continue;
if (strSize(value) == 0) if (strSize(value) == 0)
THROW_FMT(OptionInvalidValueError, "environment variable '%s' must have a value", strPtr(key)); THROW_FMT(OptionInvalidValueError, "environment variable '%s' must have a value", strZ(key));
// Continue if the option has already been specified on the command line // Continue if the option has already been specified on the command line
if (parseOptionList[optionId].found) if (parseOptionList[optionId].found)
@ -690,7 +690,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
if (strEqZ(value, "n")) if (strEqZ(value, "n"))
parseOptionList[optionId].negate = true; parseOptionList[optionId].negate = true;
else if (!strEqZ(value, "y")) else if (!strEqZ(value, "y"))
THROW_FMT(OptionInvalidValueError, "environment boolean option '%s' must be 'y' or 'n'", strPtr(key)); THROW_FMT(OptionInvalidValueError, "environment boolean option '%s' must be 'y' or 'n'", strZ(key));
} }
// Else split list/hash into separate values // Else split list/hash into separate values
else if (cfgDefOptionMulti(optionDefId)) else if (cfgDefOptionMulti(optionDefId))
@ -729,7 +729,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
if (stanza != NULL) if (stanza != NULL)
{ {
strLstAdd(sectionList, strNewFmt("%s:%s", strPtr(stanza), cfgCommandName(cfgCommand()))); strLstAdd(sectionList, strNewFmt("%s:%s", strZ(stanza), cfgCommandName(cfgCommand())));
strLstAdd(sectionList, stanza); strLstAdd(sectionList, stanza);
} }
@ -754,19 +754,19 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
// Warn if the option not found // Warn if the option not found
if (optionList[optionIdx].name == NULL) if (optionList[optionIdx].name == NULL)
{ {
LOG_WARN_FMT("configuration file contains invalid option '%s'", strPtr(key)); LOG_WARN_FMT("configuration file contains invalid option '%s'", strZ(key));
continue; continue;
} }
// Warn if negate option found in config // Warn if negate option found in config
else if (optionList[optionIdx].val & PARSE_NEGATE_FLAG) else if (optionList[optionIdx].val & PARSE_NEGATE_FLAG)
{ {
LOG_WARN_FMT("configuration file contains negate option '%s'", strPtr(key)); LOG_WARN_FMT("configuration file contains negate option '%s'", strZ(key));
continue; continue;
} }
// Warn if reset option found in config // Warn if reset option found in config
else if (optionList[optionIdx].val & PARSE_RESET_FLAG) else if (optionList[optionIdx].val & PARSE_RESET_FLAG)
{ {
LOG_WARN_FMT("configuration file contains reset option '%s'", strPtr(key)); LOG_WARN_FMT("configuration file contains reset option '%s'", strZ(key));
continue; continue;
} }
@ -776,7 +776,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
/// Warn if this option should be command-line only /// Warn if this option should be command-line only
if (cfgDefOptionSection(optionDefId) == cfgDefSectionCommandLine) if (cfgDefOptionSection(optionDefId) == cfgDefSectionCommandLine)
{ {
LOG_WARN_FMT("configuration file contains command-line only option '%s'", strPtr(key)); LOG_WARN_FMT("configuration file contains command-line only option '%s'", strZ(key));
continue; continue;
} }
@ -788,7 +788,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
{ {
THROW_FMT( THROW_FMT(
OptionInvalidError, "configuration file contains duplicate options ('%s', '%s') in section '[%s]'", OptionInvalidError, "configuration file contains duplicate options ('%s', '%s') in section '[%s]'",
strPtr(key), strPtr(varStr(optionFoundName)), strPtr(section)); strZ(key), strZ(varStr(optionFoundName)), strZ(section));
} }
else else
kvPut(optionFound, optionFoundKey, VARSTR(key)); kvPut(optionFound, optionFoundKey, VARSTR(key));
@ -800,8 +800,8 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
if (sectionIdx % 2 == 0) if (sectionIdx % 2 == 0)
{ {
LOG_WARN_FMT( LOG_WARN_FMT(
"configuration file contains option '%s' invalid for section '%s'", strPtr(key), "configuration file contains option '%s' invalid for section '%s'", strZ(key),
strPtr(section)); strZ(section));
continue; continue;
} }
@ -813,8 +813,8 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
strBeginsWithZ(section, CFGDEF_SECTION_GLOBAL)) strBeginsWithZ(section, CFGDEF_SECTION_GLOBAL))
{ {
LOG_WARN_FMT( LOG_WARN_FMT(
"configuration file contains stanza-only option '%s' in global section '%s'", strPtr(key), "configuration file contains stanza-only option '%s' in global section '%s'", strZ(key),
strPtr(section)); strZ(section));
continue; continue;
} }
@ -842,8 +842,8 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
if (strSize(value) == 0) if (strSize(value) == 0)
{ {
THROW_FMT( THROW_FMT(
OptionInvalidValueError, "section '%s', key '%s' must have a value", strPtr(section), OptionInvalidValueError, "section '%s', key '%s' must have a value", strZ(section),
strPtr(key)); strZ(key));
} }
if (cfgDefOptionType(optionDefId) == cfgDefOptTypeBoolean) if (cfgDefOptionType(optionDefId) == cfgDefOptTypeBoolean)
@ -851,7 +851,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
if (strEqZ(value, "n")) if (strEqZ(value, "n"))
parseOptionList[optionId].negate = true; parseOptionList[optionId].negate = true;
else if (!strEqZ(value, "y")) else if (!strEqZ(value, "y"))
THROW_FMT(OptionInvalidValueError, "boolean option '%s' must be 'y' or 'n'", strPtr(key)); THROW_FMT(OptionInvalidValueError, "boolean option '%s' must be 'y' or 'n'", strZ(key));
} }
// Else add the string value // Else add the string value
else else
@ -944,7 +944,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
// If a depend list exists, make sure the value is in the list // If a depend list exists, make sure the value is in the list
else if (cfgDefOptionDependValueTotal(commandDefId, optionDefId) > 0) else if (cfgDefOptionDependValueTotal(commandDefId, optionDefId) > 0)
{ {
dependResolved = cfgDefOptionDependValueValid(commandDefId, optionDefId, strPtr(varStr(dependValue))); dependResolved = cfgDefOptionDependValueValid(commandDefId, optionDefId, strZ(varStr(dependValue)));
// If depend not resolved and option value is set on the command-line then error. It's OK to have // If depend not resolved and option value is set on the command-line then error. It's OK to have
// unresolved options in the config file because they may be there for another command. For instance, // unresolved options in the config file because they may be there for another command. For instance,
@ -981,17 +981,17 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
const String *errorValue = EMPTY_STR; const String *errorValue = EMPTY_STR;
if (strLstSize(dependValueList) == 1) if (strLstSize(dependValueList) == 1)
errorValue = strNewFmt(" = %s", strPtr(strLstGet(dependValueList, 0))); errorValue = strNewFmt(" = %s", strZ(strLstGet(dependValueList, 0)));
else if (strLstSize(dependValueList) > 1) else if (strLstSize(dependValueList) > 1)
errorValue = strNewFmt(" in (%s)", strPtr(strLstJoin(dependValueList, ", "))); errorValue = strNewFmt(" in (%s)", strZ(strLstJoin(dependValueList, ", ")));
// Throw the error // Throw the error
THROW( THROW(
OptionInvalidError, OptionInvalidError,
strPtr( strZ(
strNewFmt( strNewFmt(
"option '%s' not valid without option '%s'%s", cfgOptionName(optionId), "option '%s' not valid without option '%s'%s", cfgOptionName(optionId),
strPtr(dependOptionName), strPtr(errorValue)))); strZ(dependOptionName), strZ(errorValue))));
} }
} }
} }
@ -1013,14 +1013,14 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
for (unsigned int listIdx = 0; listIdx < strLstSize(parseOption->valueList); listIdx++) for (unsigned int listIdx = 0; listIdx < strLstSize(parseOption->valueList); listIdx++)
{ {
const char *pair = strPtr(strLstGet(parseOption->valueList, listIdx)); const char *pair = strZ(strLstGet(parseOption->valueList, listIdx));
const char *equal = strchr(pair, '='); const char *equal = strchr(pair, '=');
if (equal == NULL) if (equal == NULL)
{ {
THROW_FMT( THROW_FMT(
OptionInvalidError, "key/value '%s' not valid for '%s' option", OptionInvalidError, "key/value '%s' not valid for '%s' option",
strPtr(strLstGet(parseOption->valueList, listIdx)), cfgOptionName(optionId)); strZ(strLstGet(parseOption->valueList, listIdx)), cfgOptionName(optionId));
} }
kvPut(keyValue, VARSTR(strNewN(pair, (size_t)(equal - pair))), VARSTRZ(equal + 1)); kvPut(keyValue, VARSTR(strNewN(pair, (size_t)(equal - pair))), VARSTRZ(equal + 1));
@ -1059,7 +1059,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
CATCH_ANY() CATCH_ANY()
{ {
THROW_FMT( THROW_FMT(
OptionInvalidValueError, "'%s' is not valid for '%s' option", strPtr(value), OptionInvalidValueError, "'%s' is not valid for '%s' option", strZ(value),
cfgOptionName(optionId)); cfgOptionName(optionId));
} }
TRY_END(); TRY_END();
@ -1070,7 +1070,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
valueDbl > cfgDefOptionAllowRangeMax(commandDefId, optionDefId))) valueDbl > cfgDefOptionAllowRangeMax(commandDefId, optionDefId)))
{ {
THROW_FMT( THROW_FMT(
OptionInvalidValueError, "'%s' is out of range for '%s' option", strPtr(value), OptionInvalidValueError, "'%s' is out of range for '%s' option", strZ(value),
cfgOptionName(optionId)); cfgOptionName(optionId));
} }
} }
@ -1081,7 +1081,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
if (strSize(value) == 0) if (strSize(value) == 0)
{ {
THROW_FMT( THROW_FMT(
OptionInvalidValueError, "'%s' must be >= 1 character for '%s' option", strPtr(value), OptionInvalidValueError, "'%s' must be >= 1 character for '%s' option", strZ(value),
cfgOptionName(optionId)); cfgOptionName(optionId));
} }
@ -1089,15 +1089,15 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
if (!strBeginsWithZ(value, "/")) if (!strBeginsWithZ(value, "/"))
{ {
THROW_FMT( THROW_FMT(
OptionInvalidValueError, "'%s' must begin with / for '%s' option", strPtr(value), OptionInvalidValueError, "'%s' must begin with / for '%s' option", strZ(value),
cfgOptionName(optionId)); cfgOptionName(optionId));
} }
// Make sure there are no occurrences of // // Make sure there are no occurrences of //
if (strstr(strPtr(value), "//") != NULL) if (strstr(strZ(value), "//") != NULL)
{ {
THROW_FMT( THROW_FMT(
OptionInvalidValueError, "'%s' cannot contain // for '%s' option", strPtr(value), OptionInvalidValueError, "'%s' cannot contain // for '%s' option", strZ(value),
cfgOptionName(optionId)); cfgOptionName(optionId));
} }
@ -1108,10 +1108,10 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
// If the option has an allow list then check it // If the option has an allow list then check it
if (cfgDefOptionAllowList(commandDefId, optionDefId) && if (cfgDefOptionAllowList(commandDefId, optionDefId) &&
!cfgDefOptionAllowListValueValid(commandDefId, optionDefId, strPtr(value))) !cfgDefOptionAllowListValueValid(commandDefId, optionDefId, strZ(value)))
{ {
THROW_FMT( THROW_FMT(
OptionInvalidValueError, "'%s' is not allowed for '%s' option", strPtr(value), OptionInvalidValueError, "'%s' is not allowed for '%s' option", strZ(value),
cfgOptionName(optionId)); cfgOptionName(optionId));
} }

View File

@ -37,7 +37,7 @@ configProtocol(const String *command, const VariantList *paramList, ProtocolServ
VariantList *optionList = varLstNew(); VariantList *optionList = varLstNew();
for (unsigned int optionIdx = 0; optionIdx < varLstSize(paramList); optionIdx++) for (unsigned int optionIdx = 0; optionIdx < varLstSize(paramList); optionIdx++)
varLstAdd(optionList, varDup(cfgOption(cfgOptionId(strPtr(varStr(varLstGet(paramList, optionIdx))))))); varLstAdd(optionList, varDup(cfgOption(cfgOptionId(strZ(varStr(varLstGet(paramList, optionIdx)))))));
protocolServerResponse(server, varNewVarLst(optionList)); protocolServerResponse(server, varNewVarLst(optionList));
} }

View File

@ -235,7 +235,7 @@ dbOpen(Db *this)
// Set application name to help identify the backup session // Set application name to help identify the backup session
if (this->pgVersion >= PG_VERSION_APPLICATION_NAME) if (this->pgVersion >= PG_VERSION_APPLICATION_NAME)
dbExec(this, strNewFmt("set application_name = '%s'", strPtr(this->applicationName))); dbExec(this, strNewFmt("set application_name = '%s'", strZ(this->applicationName)));
// There is no need to have parallelism enabled in a backup session. In particular, 9.6 marks pg_stop_backup() as // There is no need to have parallelism enabled in a backup session. In particular, 9.6 marks pg_stop_backup() as
// parallel-safe but an error will be thrown if pg_stop_backup() is run in a worker. // parallel-safe but an error will be thrown if pg_stop_backup() is run in a worker.
@ -262,7 +262,7 @@ dbBackupStartQuery(unsigned int pgVersion, bool startFast)
"select lsn::text as lsn,\n" "select lsn::text as lsn,\n"
" pg_catalog.pg_%sfile_name(lsn)::text as wal_segment_name\n" " pg_catalog.pg_%sfile_name(lsn)::text as wal_segment_name\n"
" from pg_catalog.pg_start_backup('" PROJECT_NAME " backup started at ' || current_timestamp", " from pg_catalog.pg_start_backup('" PROJECT_NAME " backup started at ' || current_timestamp",
strPtr(pgWalName(pgVersion))); strZ(pgWalName(pgVersion)));
// Start backup after immediate checkpoint // Start backup after immediate checkpoint
if (startFast) if (startFast)
@ -361,7 +361,7 @@ dbBackupStopQuery(unsigned int pgVersion)
String *result = strNewFmt( String *result = strNewFmt(
"select lsn::text as lsn,\n" "select lsn::text as lsn,\n"
" pg_catalog.pg_%sfile_name(lsn)::text as wal_segment_name", " pg_catalog.pg_%sfile_name(lsn)::text as wal_segment_name",
strPtr(pgWalName(pgVersion))); strZ(pgWalName(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)
@ -493,9 +493,9 @@ dbReplayWait(Db *this, const String *targetLsn, TimeMSec timeout)
// Loop until lsn has been reached or timeout // Loop until lsn has been reached or timeout
Wait *wait = waitNew(timeout); Wait *wait = waitNew(timeout);
bool targetReached = false; bool targetReached = false;
const char *lsnName = strPtr(pgLsnName(dbPgVersion(this))); const char *lsnName = strZ(pgLsnName(dbPgVersion(this)));
const String *replayLsnFunction = strNewFmt( const String *replayLsnFunction = strNewFmt(
"pg_catalog.pg_last_%s_replay_%s()", strPtr(pgWalName(dbPgVersion(this))), lsnName); "pg_catalog.pg_last_%s_replay_%s()", strZ(pgWalName(dbPgVersion(this))), lsnName);
const String *replayLsn = NULL; const String *replayLsn = NULL;
do do
@ -504,21 +504,22 @@ dbReplayWait(Db *this, const String *targetLsn, TimeMSec timeout)
String *query = strNewFmt( String *query = strNewFmt(
"select replayLsn::text,\n" "select replayLsn::text,\n"
" (replayLsn > '%s')::bool as targetReached", " (replayLsn > '%s')::bool as targetReached",
strPtr(targetLsn)); strZ(targetLsn));
if (replayLsn != NULL) if (replayLsn != NULL)
{ {
strCatFmt( strCatFmt(
query, query,
",\n" ",\n"
" (replayLsn > '%s')::bool as replayProgress", strPtr(replayLsn)); " (replayLsn > '%s')::bool as replayProgress",
strZ(replayLsn));
} }
strCatFmt( strCatFmt(
query, query,
"\n" "\n"
" from %s as replayLsn", " from %s as replayLsn",
strPtr(replayLsnFunction)); strZ(replayLsnFunction));
// Execute the query and get replayLsn // Execute the query and get replayLsn
VariantList *row = dbQueryRow(this, query); VariantList *row = dbQueryRow(this, query);
@ -532,7 +533,7 @@ dbReplayWait(Db *this, const String *targetLsn, TimeMSec timeout)
ArchiveTimeoutError, ArchiveTimeoutError,
"unable to query replay lsn on the standby using '%s'\n" "unable to query replay lsn on the standby using '%s'\n"
"HINT: Is this a standby?", "HINT: Is this a standby?",
strPtr(replayLsnFunction)); strZ(replayLsnFunction));
} }
targetReached = varBool(varLstGet(row, 1)); targetReached = varBool(varLstGet(row, 1));
@ -549,8 +550,8 @@ dbReplayWait(Db *this, const String *targetLsn, TimeMSec timeout)
if (!targetReached) if (!targetReached)
{ {
THROW_FMT( THROW_FMT(
ArchiveTimeoutError, "timeout before standby replayed to %s - only reached %s", strPtr(targetLsn), ArchiveTimeoutError, "timeout before standby replayed to %s - only reached %s", strZ(targetLsn),
strPtr(replayLsn)); strZ(replayLsn));
} }
// Perform a checkpoint // Perform a checkpoint
@ -568,7 +569,7 @@ dbReplayWait(Db *this, const String *targetLsn, TimeMSec timeout)
"select (checkpoint_%s > '%s')::bool as targetReached,\n" "select (checkpoint_%s > '%s')::bool as targetReached,\n"
" checkpoint_%s::text as checkpointLsn\n" " checkpoint_%s::text as checkpointLsn\n"
" from pg_catalog.pg_control_checkpoint()", " from pg_catalog.pg_control_checkpoint()",
lsnName, strPtr(targetLsn), lsnName); lsnName, strZ(targetLsn), lsnName);
// Execute query // Execute query
VariantList *row = dbQueryRow(this, query); VariantList *row = dbQueryRow(this, query);
@ -579,7 +580,7 @@ dbReplayWait(Db *this, const String *targetLsn, TimeMSec timeout)
THROW_FMT( THROW_FMT(
ArchiveTimeoutError, ArchiveTimeoutError,
"the checkpoint lsn %s is less than the target lsn %s even though the replay lsn is %s", "the checkpoint lsn %s is less than the target lsn %s even though the replay lsn is %s",
strPtr(varStr(varLstGet(row, 1))), strPtr(targetLsn), strPtr(replayLsn)); strZ(varStr(varLstGet(row, 1))), strZ(targetLsn), strZ(replayLsn));
} }
} }
} }
@ -631,7 +632,7 @@ dbWalSwitch(Db *this)
dbQueryColumn(this, STRDEF("select pg_catalog.pg_create_restore_point('" PROJECT_NAME " Archive Check')::text")); dbQueryColumn(this, STRDEF("select pg_catalog.pg_create_restore_point('" PROJECT_NAME " Archive Check')::text"));
// Request a WAL segment switch // Request a WAL segment switch
const char *walName = strPtr(pgWalName(this->pgVersion)); const char *walName = strZ(pgWalName(this->pgVersion));
const String *walFileName = varStr( const String *walFileName = varStr(
dbQueryColumn(this, strNewFmt("select pg_catalog.pg_%sfile_name(pg_catalog.pg_switch_%s())::text", walName, walName))); dbQueryColumn(this, strNewFmt("select pg_catalog.pg_%sfile_name(pg_catalog.pg_switch_%s())::text", walName, walName)));
@ -704,6 +705,6 @@ String *
dbToLog(const Db *this) dbToLog(const Db *this)
{ {
return strNewFmt( return strNewFmt(
"{client: %s, remoteClient: %s}", this->client == NULL ? NULL_Z : strPtr(pgClientToLog(this->client)), "{client: %s, remoteClient: %s}", this->client == NULL ? NULL_Z : strZ(pgClientToLog(this->client)),
this->remoteClient == NULL ? NULL_Z : strPtr(protocolClientToLog(this->remoteClient))); this->remoteClient == NULL ? NULL_Z : strZ(protocolClientToLog(this->remoteClient)));
} }

View File

@ -210,7 +210,7 @@ infoLoadCallback(void *data, const String *section, const String *key, const Str
if (strEq(key, INFO_KEY_FORMAT_STR)) if (strEq(key, INFO_KEY_FORMAT_STR))
{ {
if (jsonToUInt(value) != REPOSITORY_FORMAT) if (jsonToUInt(value) != REPOSITORY_FORMAT)
THROW_FMT(FormatError, "expected format %d but found %d", REPOSITORY_FORMAT, cvtZToInt(strPtr(value))); THROW_FMT(FormatError, "expected format %d but found %d", REPOSITORY_FORMAT, cvtZToInt(strZ(value)));
} }
// Store pgBackRest version // Store pgBackRest version
else if (strEq(key, INFO_KEY_VERSION_STR)) else if (strEq(key, INFO_KEY_VERSION_STR))
@ -301,12 +301,12 @@ infoNewLoad(IoRead *read, InfoLoadNewCallback *callbackFunction, void *callbackD
const String *checksumActual = varStr(ioFilterResult(data.checksumActual)); const String *checksumActual = varStr(ioFilterResult(data.checksumActual));
if (data.checksumExpected == NULL) if (data.checksumExpected == NULL)
THROW_FMT(ChecksumError, "invalid checksum, actual '%s' but no checksum found", strPtr(checksumActual)); THROW_FMT(ChecksumError, "invalid checksum, actual '%s' but no checksum found", strZ(checksumActual));
else if (!strEq(data.checksumExpected, checksumActual)) else if (!strEq(data.checksumExpected, checksumActual))
{ {
THROW_FMT( THROW_FMT(
ChecksumError, "invalid checksum, actual '%s' but expected '%s'", strPtr(checksumActual), ChecksumError, "invalid checksum, actual '%s' but expected '%s'", strZ(checksumActual),
strPtr(data.checksumExpected)); strZ(data.checksumExpected));
} }
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
@ -525,7 +525,7 @@ infoLoad(const String *error, InfoLoadCallback *callbackFunction, void *callback
if (loadErrorType == NULL) if (loadErrorType == NULL)
{ {
loadErrorType = errorType(); loadErrorType = errorType();
loadErrorMessage = strNewFmt("%s:", strPtr(error)); loadErrorMessage = strNewFmt("%s:", strZ(error));
} }
// Else if the error type is different // Else if the error type is different
else if (loadErrorType != errorType()) else if (loadErrorType != errorType())
@ -552,7 +552,7 @@ infoLoad(const String *error, InfoLoadCallback *callbackFunction, void *callback
// Error when no file was loaded // Error when no file was loaded
if (!loaded) if (!loaded)
THROWP(loadErrorType, strPtr(loadErrorMessage)); THROWP(loadErrorType, strZ(loadErrorMessage));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();

View File

@ -157,7 +157,7 @@ infoArchiveIdHistoryMatch(
THROW_FMT( THROW_FMT(
ArchiveMismatchError, ArchiveMismatchError,
"unable to retrieve the archive id for database version '%s' and system-id '%" PRIu64 "'", "unable to retrieve the archive id for database version '%s' and system-id '%" PRIu64 "'",
strPtr(pgVersionToStr(pgVersion)), pgSystemId); strZ(pgVersionToStr(pgVersion)), pgSystemId);
} }
FUNCTION_LOG_RETURN(STRING, archiveId); FUNCTION_LOG_RETURN(STRING, archiveId);
@ -269,7 +269,7 @@ infoArchiveLoadFileCallback(void *data, unsigned int try)
if (try < 2) if (try < 2)
{ {
// Construct filename based on try // Construct filename based on try
const String *fileName = try == 0 ? loadData->fileName : strNewFmt("%s" INFO_COPY_EXT, strPtr(loadData->fileName)); const String *fileName = try == 0 ? loadData->fileName : strNewFmt("%s" INFO_COPY_EXT, strZ(loadData->fileName));
// Attempt to load the file // Attempt to load the file
IoRead *read = storageReadIo(storageNewReadP(loadData->storage, fileName)); IoRead *read = storageReadIo(storageNewReadP(loadData->storage, fileName));
@ -311,7 +311,7 @@ infoArchiveLoadFile(const Storage *storage, const String *fileName, CipherType c
MEM_CONTEXT_TEMP_BEGIN() MEM_CONTEXT_TEMP_BEGIN()
{ {
const char *fileNamePath = strPtr(storagePathP(storage, fileName)); const char *fileNamePath = strZ(storagePathP(storage, fileName));
TRY_BEGIN() TRY_BEGIN()
{ {
@ -363,8 +363,7 @@ infoArchiveSaveFile(
infoArchiveSave(infoArchive, write); infoArchiveSave(infoArchive, write);
// Make a copy of the file // Make a copy of the file
storageCopy( storageCopy(storageNewReadP(storage, fileName), storageNewWriteP(storage, strNewFmt("%s" INFO_COPY_EXT, strZ(fileName))));
storageNewReadP(storage, fileName), storageNewWriteP(storage, strNewFmt("%s" INFO_COPY_EXT, strPtr(fileName))));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();

View File

@ -148,7 +148,7 @@ infoBackupLoadCallback(void *data, const String *section, const String *key, con
.backupInfoSize = varUInt64(kvGet(backupKv, INFO_BACKUP_KEY_BACKUP_INFO_SIZE_VAR)), .backupInfoSize = varUInt64(kvGet(backupKv, INFO_BACKUP_KEY_BACKUP_INFO_SIZE_VAR)),
.backupInfoSizeDelta = varUInt64(kvGet(backupKv, INFO_BACKUP_KEY_BACKUP_INFO_SIZE_DELTA_VAR)), .backupInfoSizeDelta = varUInt64(kvGet(backupKv, INFO_BACKUP_KEY_BACKUP_INFO_SIZE_DELTA_VAR)),
.backupLabel = strDup(key), .backupLabel = strDup(key),
.backupPgId = cvtZToUInt(strPtr(varStrForce(kvGet(backupKv, INFO_KEY_DB_ID_VAR)))), .backupPgId = cvtZToUInt(strZ(varStrForce(kvGet(backupKv, INFO_KEY_DB_ID_VAR)))),
// When reading timestamps, read as uint64 to ensure always positive value (guarantee no backups before 1970) // When reading timestamps, read as uint64 to ensure always positive value (guarantee no backups before 1970)
.backupTimestampStart = (time_t)varUInt64(kvGet(backupKv, INFO_BACKUP_KEY_BACKUP_TIMESTAMP_START_VAR)), .backupTimestampStart = (time_t)varUInt64(kvGet(backupKv, INFO_BACKUP_KEY_BACKUP_TIMESTAMP_START_VAR)),
@ -579,7 +579,7 @@ infoBackupLoadFileCallback(void *data, unsigned int try)
if (try < 2) if (try < 2)
{ {
// Construct filename based on try // Construct filename based on try
const String *fileName = try == 0 ? loadData->fileName : strNewFmt("%s" INFO_COPY_EXT, strPtr(loadData->fileName)); const String *fileName = try == 0 ? loadData->fileName : strNewFmt("%s" INFO_COPY_EXT, strZ(loadData->fileName));
// Attempt to load the file // Attempt to load the file
IoRead *read = storageReadIo(storageNewReadP(loadData->storage, fileName)); IoRead *read = storageReadIo(storageNewReadP(loadData->storage, fileName));
@ -621,7 +621,7 @@ infoBackupLoadFile(const Storage *storage, const String *fileName, CipherType ci
MEM_CONTEXT_TEMP_BEGIN() MEM_CONTEXT_TEMP_BEGIN()
{ {
const char *fileNamePath = strPtr(storagePathP(storage, fileName)); const char *fileNamePath = strZ(storagePathP(storage, fileName));
TRY_BEGIN() TRY_BEGIN()
{ {
@ -677,7 +677,7 @@ infoBackupLoadFileReconstruct(const Storage *storage, const String *fileName, Ci
for (unsigned int backupCurrIdx = 0; backupCurrIdx < strLstSize(backupCurrentList); backupCurrIdx++) for (unsigned int backupCurrIdx = 0; backupCurrIdx < strLstSize(backupCurrentList); backupCurrIdx++)
{ {
String *backupLabel = strLstGet(backupCurrentList, backupCurrIdx); String *backupLabel = strLstGet(backupCurrentList, backupCurrIdx);
String *manifestFileName = strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strPtr(backupLabel)); String *manifestFileName = strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strZ(backupLabel));
// If the manifest does not exist on disk and this backup has not already been deleted from the current list in the // If the manifest does not exist on disk and this backup has not already been deleted from the current list in the
// infoBackup object, then remove it and its dependencies // infoBackup object, then remove it and its dependencies
@ -689,7 +689,7 @@ infoBackupLoadFileReconstruct(const Storage *storage, const String *fileName, Ci
{ {
String *removeBackup = strLstGet(backupList, backupIdx); String *removeBackup = strLstGet(backupList, backupIdx);
LOG_WARN_FMT("backup '%s' missing manifest removed from " INFO_BACKUP_FILE, strPtr(removeBackup)); LOG_WARN_FMT("backup '%s' missing manifest removed from " INFO_BACKUP_FILE, strZ(removeBackup));
infoBackupDataDelete(infoBackup, removeBackup); infoBackupDataDelete(infoBackup, removeBackup);
} }
@ -707,7 +707,7 @@ infoBackupLoadFileReconstruct(const Storage *storage, const String *fileName, Ci
// If it does not exist in the list of current backups, then if it is valid, add it // If it does not exist in the list of current backups, then if it is valid, add it
if (!strLstExists(backupCurrentList, backupLabel)) if (!strLstExists(backupCurrentList, backupLabel))
{ {
String *manifestFileName = strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strPtr(backupLabel)); String *manifestFileName = strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strZ(backupLabel));
// Check if a completed backup exists (backup.manifest only - ignore .copy) // Check if a completed backup exists (backup.manifest only - ignore .copy)
if (storageExistsP(storage, manifestFileName)) if (storageExistsP(storage, manifestFileName))
@ -730,7 +730,7 @@ infoBackupLoadFileReconstruct(const Storage *storage, const String *fileName, Ci
(manData->backupLabelPrior == NULL || (manData->backupLabelPrior == NULL ||
infoBackupDataByLabel(infoBackup, manData->backupLabelPrior) != NULL)) infoBackupDataByLabel(infoBackup, manData->backupLabelPrior) != NULL))
{ {
LOG_WARN_FMT("backup '%s' found in repository added to " INFO_BACKUP_FILE, strPtr(backupLabel)); LOG_WARN_FMT("backup '%s' found in repository added to " INFO_BACKUP_FILE, strZ(backupLabel));
infoBackupDataAdd(infoBackup, manifest); infoBackupDataAdd(infoBackup, manifest);
found = true; found = true;
break; break;
@ -738,7 +738,7 @@ infoBackupLoadFileReconstruct(const Storage *storage, const String *fileName, Ci
} }
if (!found) if (!found)
LOG_WARN_FMT("invalid backup '%s' cannot be added to current backups", strPtr(manData->backupLabel)); LOG_WARN_FMT("invalid backup '%s' cannot be added to current backups", strZ(manData->backupLabel));
} }
} }
} }
@ -774,8 +774,7 @@ infoBackupSaveFile(
infoBackupSave(infoBackup, write); infoBackupSave(infoBackup, write);
// Make a copy of the file // Make a copy of the file
storageCopy( storageCopy(storageNewReadP(storage, fileName), storageNewWriteP(storage, strNewFmt("%s" INFO_COPY_EXT, strZ(fileName))));
storageNewReadP(storage, fileName), storageNewWriteP(storage, strNewFmt("%s" INFO_COPY_EXT, strPtr(fileName))));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
@ -786,5 +785,5 @@ infoBackupSaveFile(
String * String *
infoBackupDataToLog(const InfoBackupData *this) infoBackupDataToLog(const InfoBackupData *this)
{ {
return strNewFmt("{label: %s, pgId: %u}", strPtr(this->backupLabel), this->backupPgId); return strNewFmt("{label: %s, pgId: %u}", strZ(this->backupLabel), this->backupPgId);
} }

View File

@ -132,7 +132,7 @@ infoPgLoadCallback(void *data, const String *section, const String *key, const S
// Get db values that are common to all info files // Get db values that are common to all info files
InfoPgData infoPgData = InfoPgData infoPgData =
{ {
.id = cvtZToUInt(strPtr(key)), .id = cvtZToUInt(strZ(key)),
.version = pgVersionFromStr(varStr(kvGet(pgDataKv, INFO_KEY_DB_VERSION_VAR))), .version = pgVersionFromStr(varStr(kvGet(pgDataKv, INFO_KEY_DB_VERSION_VAR))),
// This is different in archive.info due to a typo that can't be fixed without a format version bump // This is different in archive.info due to a typo that can't be fixed without a format version bump
@ -386,7 +386,7 @@ infoPgArchiveId(const InfoPg *this, unsigned int pgDataIdx)
InfoPgData pgData = infoPgData(this, pgDataIdx); InfoPgData pgData = infoPgData(this, pgDataIdx);
FUNCTION_LOG_RETURN(STRING, strNewFmt("%s-%u", strPtr(pgVersionToStr(pgData.version)), pgData.id)); FUNCTION_LOG_RETURN(STRING, strNewFmt("%s-%u", strZ(pgVersionToStr(pgData.version)), pgData.id));
} }
/**********************************************************************************************************************************/ /**********************************************************************************************************************************/

View File

@ -443,14 +443,14 @@ manifestBuildCallback(void *data, const StorageInfo *info)
unsigned int pgVersion = buildData.manifest->data.pgVersion; unsigned int pgVersion = buildData.manifest->data.pgVersion;
// Contruct the name used to identify this file/link/path in the manifest // Contruct the name used to identify this file/link/path in the manifest
const String *manifestName = strNewFmt("%s/%s", strPtr(buildData.manifestParentName), strPtr(info->name)); const String *manifestName = strNewFmt("%s/%s", strZ(buildData.manifestParentName), strZ(info->name));
// Skip excluded files/links/paths // Skip excluded files/links/paths
if (buildData.excludeSingle != NULL && strLstExists(buildData.excludeSingle, manifestName)) if (buildData.excludeSingle != NULL && strLstExists(buildData.excludeSingle, manifestName))
{ {
LOG_INFO_FMT( LOG_INFO_FMT(
"exclude '%s/%s' from backup using '%s' exclusion", strPtr(buildData.pgPath), strPtr(info->name), "exclude '%s/%s' from backup using '%s' exclusion", strZ(buildData.pgPath), strZ(info->name),
strPtr(strSub(manifestName, sizeof(MANIFEST_TARGET_PGDATA)))); strZ(strSub(manifestName, sizeof(MANIFEST_TARGET_PGDATA))));
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
return; return;
@ -468,7 +468,7 @@ manifestBuildCallback(void *data, const StorageInfo *info)
{ {
THROW_FMT( THROW_FMT(
LinkExpectedError, "'%s' is not a symlink - " MANIFEST_TARGET_PGTBLSPC " should contain only symlinks", LinkExpectedError, "'%s' is not a symlink - " MANIFEST_TARGET_PGTBLSPC " should contain only symlinks",
strPtr(manifestName)); strZ(manifestName));
} }
// Add path to manifest // Add path to manifest
@ -486,8 +486,8 @@ manifestBuildCallback(void *data, const StorageInfo *info)
if (buildData.excludeContent != NULL && strLstExists(buildData.excludeContent, manifestName)) if (buildData.excludeContent != NULL && strLstExists(buildData.excludeContent, manifestName))
{ {
LOG_INFO_FMT( LOG_INFO_FMT(
"exclude contents of '%s/%s' from backup using '%s/' exclusion", strPtr(buildData.pgPath), strPtr(info->name), "exclude contents of '%s/%s' from backup using '%s/' exclusion", strZ(buildData.pgPath), strZ(info->name),
strPtr(strSub(manifestName, sizeof(MANIFEST_TARGET_PGDATA)))); strZ(strSub(manifestName, sizeof(MANIFEST_TARGET_PGDATA))));
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
return; return;
@ -558,7 +558,7 @@ manifestBuildCallback(void *data, const StorageInfo *info)
// Recurse into the path // Recurse into the path
ManifestBuildData buildDataSub = buildData; ManifestBuildData buildDataSub = buildData;
buildDataSub.manifestParentName = manifestName; buildDataSub.manifestParentName = manifestName;
buildDataSub.pgPath = strNewFmt("%s/%s", strPtr(buildData.pgPath), strPtr(info->name)); buildDataSub.pgPath = strNewFmt("%s/%s", strZ(buildData.pgPath), strZ(info->name));
if (buildData.dbPathExp != NULL) if (buildData.dbPathExp != NULL)
buildDataSub.dbPath = regExpMatch(buildData.dbPathExp, manifestName); buildDataSub.dbPath = regExpMatch(buildData.dbPathExp, manifestName);
@ -578,7 +578,7 @@ manifestBuildCallback(void *data, const StorageInfo *info)
{ {
THROW_FMT( THROW_FMT(
LinkExpectedError, "'%s' is not a symlink - " MANIFEST_TARGET_PGTBLSPC " should contain only symlinks", LinkExpectedError, "'%s' is not a symlink - " MANIFEST_TARGET_PGTBLSPC " should contain only symlinks",
strPtr(manifestName)); strZ(manifestName));
} }
// Skip pg_internal.init since it is recreated on startup. It's also possible, (though unlikely) that a temp file with // Skip pg_internal.init since it is recreated on startup. It's also possible, (though unlikely) that a temp file with
@ -676,8 +676,8 @@ manifestBuildCallback(void *data, const StorageInfo *info)
if (linkedCheck.exists && linkedCheck.type == storageTypeLink) if (linkedCheck.exists && linkedCheck.type == storageTypeLink)
{ {
THROW_FMT( THROW_FMT(
LinkDestinationError, "link '%s/%s' cannot reference another link '%s'", strPtr(buildData.pgPath), LinkDestinationError, "link '%s/%s' cannot reference another link '%s'", strZ(buildData.pgPath),
strPtr(info->name), strPtr(linkDestinationAbsolute)); strZ(info->name), strZ(linkDestinationAbsolute));
} }
// Initialize link and target // Initialize link and target
@ -707,7 +707,7 @@ manifestBuildCallback(void *data, const StorageInfo *info)
// Identify this target as a tablespace // Identify this target as a tablespace
target.name = manifestName; target.name = manifestName;
target.tablespaceId = cvtZToUInt(strPtr(info->name)); target.tablespaceId = cvtZToUInt(strZ(info->name));
// Look for this tablespace in the provided list (list may be null for off-line backup) // Look for this tablespace in the provided list (list may be null for off-line backup)
if (buildData.tablespaceList != NULL) if (buildData.tablespaceList != NULL)
@ -734,7 +734,7 @@ manifestBuildCallback(void *data, const StorageInfo *info)
// If no tablespace name was found then create one // If no tablespace name was found then create one
if (target.tablespaceName == NULL) if (target.tablespaceName == NULL)
target.tablespaceName = strNewFmt("ts%s", strPtr(info->name)); target.tablespaceName = strNewFmt("ts%s", strZ(info->name));
// Add a dummy pg_tblspc path entry if it does not already exist. This entry will be ignored by restore but it is // Add a dummy pg_tblspc path entry if it does not already exist. This entry will be ignored by restore but it is
// part of the original manifest format so we need to have it. // part of the original manifest format so we need to have it.
@ -773,8 +773,8 @@ manifestBuildCallback(void *data, const StorageInfo *info)
// Update build structure to reflect the path added above and the tablespace id // Update build structure to reflect the path added above and the tablespace id
buildData.manifestParentName = manifestName; buildData.manifestParentName = manifestName;
manifestName = strNewFmt("%s/%s", strPtr(manifestName), strPtr(buildData.tablespaceId)); manifestName = strNewFmt("%s/%s", strZ(manifestName), strZ(buildData.tablespaceId));
buildData.pgPath = strNewFmt("%s/%s", strPtr(buildData.pgPath), strPtr(info->name)); buildData.pgPath = strNewFmt("%s/%s", strZ(buildData.pgPath), strZ(info->name));
linkName = buildData.tablespaceId; linkName = buildData.tablespaceId;
} }
// If no tablespace id then parent manifest name is the tablespace directory // If no tablespace id then parent manifest name is the tablespace directory
@ -783,7 +783,7 @@ manifestBuildCallback(void *data, const StorageInfo *info)
} }
// Add info about the linked file/path // Add info about the linked file/path
const String *linkPgPath = strNewFmt("%s/%s", strPtr(buildData.pgPath), strPtr(linkName)); const String *linkPgPath = strNewFmt("%s/%s", strZ(buildData.pgPath), strZ(linkName));
StorageInfo linkedInfo = storageInfoP( StorageInfo linkedInfo = storageInfoP(
buildData.storagePg, linkPgPath, .followLink = true, .ignoreMissing = true); buildData.storagePg, linkPgPath, .followLink = true, .ignoreMissing = true);
linkedInfo.name = linkName; linkedInfo.name = linkName;
@ -834,7 +834,7 @@ manifestBuildCallback(void *data, const StorageInfo *info)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
case storageTypeSpecial: case storageTypeSpecial:
{ {
LOG_WARN_FMT("exclude special file '%s/%s' from backup", strPtr(buildData.pgPath), strPtr(info->name)); LOG_WARN_FMT("exclude special file '%s/%s' from backup", strZ(buildData.pgPath), strZ(info->name));
break; break;
} }
} }
@ -888,7 +888,7 @@ manifestNewBuild(
.checksumPage = checksumPage, .checksumPage = checksumPage,
.tablespaceList = tablespaceList, .tablespaceList = tablespaceList,
.manifestParentName = MANIFEST_TARGET_PGDATA_STR, .manifestParentName = MANIFEST_TARGET_PGDATA_STR,
.manifestWalName = strNewFmt(MANIFEST_TARGET_PGDATA "/%s", strPtr(pgWalPath(pgVersion))), .manifestWalName = strNewFmt(MANIFEST_TARGET_PGDATA "/%s", strZ(pgWalPath(pgVersion))),
.pgPath = storagePathP(storagePg, NULL), .pgPath = storagePathP(storagePg, NULL),
}; };
@ -900,7 +900,7 @@ manifestNewBuild(
ASSERT(buildData.tablespaceId != NULL); ASSERT(buildData.tablespaceId != NULL);
// Expression to identify database paths // Expression to identify database paths
buildData.dbPathExp = regExpNew(strNewFmt("^" DB_PATH_EXP "$", strPtr(buildData.tablespaceId))); buildData.dbPathExp = regExpNew(strNewFmt("^" DB_PATH_EXP "$", strZ(buildData.tablespaceId)));
// Expression to find temp relations // Expression to find temp relations
buildData.tempRelationExp = regExpNew(STRDEF("^t[0-9]+_" RELATION_EXP "$")); buildData.tempRelationExp = regExpNew(STRDEF("^t[0-9]+_" RELATION_EXP "$"));
@ -912,7 +912,7 @@ manifestNewBuild(
strNewFmt( strNewFmt(
"^((" MANIFEST_TARGET_PGDATA "/(" PG_PATH_BASE "|" PG_PATH_GLOBAL "|%s|" PG_PATH_PGMULTIXACT "))|" "^((" MANIFEST_TARGET_PGDATA "/(" PG_PATH_BASE "|" PG_PATH_GLOBAL "|%s|" PG_PATH_PGMULTIXACT "))|"
MANIFEST_TARGET_PGTBLSPC ")/", MANIFEST_TARGET_PGTBLSPC ")/",
strPtr(pgXactPath(pgVersion)))); strZ(pgXactPath(pgVersion))));
// Build list of exclusions // Build list of exclusions
// --------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------
@ -920,7 +920,7 @@ manifestNewBuild(
{ {
for (unsigned int excludeIdx = 0; excludeIdx < strLstSize(excludeList); excludeIdx++) for (unsigned int excludeIdx = 0; excludeIdx < strLstSize(excludeList); excludeIdx++)
{ {
const String *exclude = strNewFmt(MANIFEST_TARGET_PGDATA "/%s", strPtr(strLstGet(excludeList, excludeIdx))); const String *exclude = strNewFmt(MANIFEST_TARGET_PGDATA "/%s", strZ(strLstGet(excludeList, excludeIdx)));
// If the exclusions refers to the contents of a path // If the exclusions refers to the contents of a path
if (strEndsWithZ(exclude, "/")) if (strEndsWithZ(exclude, "/"))
@ -980,7 +980,7 @@ manifestNewBuild(
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
if (pgVersion >= PG_VERSION_91) if (pgVersion >= PG_VERSION_91)
{ {
RegExp *relationExp = regExpNew(strNewFmt("^" DB_PATH_EXP "/" RELATION_EXP "$", strPtr(buildData.tablespaceId))); RegExp *relationExp = regExpNew(strNewFmt("^" DB_PATH_EXP "/" RELATION_EXP "$", strZ(buildData.tablespaceId)));
unsigned int fileIdx = 0; unsigned int fileIdx = 0;
const String *lastRelationFileId = NULL; const String *lastRelationFileId = NULL;
bool lastRelationFileIdUnlogged = false; bool lastRelationFileIdUnlogged = false;
@ -998,7 +998,7 @@ manifestNewBuild(
// Strip off the numeric part of the relation // Strip off the numeric part of the relation
for (unsigned int nameIdx = 0; nameIdx < strSize(fileName); nameIdx++) for (unsigned int nameIdx = 0; nameIdx < strSize(fileName); nameIdx++)
{ {
char nameChr = strPtr(fileName)[nameIdx]; char nameChr = strZ(fileName)[nameIdx];
if (!isdigit(nameChr)) if (!isdigit(nameChr))
break; break;
@ -1010,8 +1010,7 @@ manifestNewBuild(
if (lastRelationFileId == NULL || !strEq(lastRelationFileId, relationFileId)) if (lastRelationFileId == NULL || !strEq(lastRelationFileId, relationFileId))
{ {
// Determine if the relation is unlogged // Determine if the relation is unlogged
const String *relationInit = strNewFmt( const String *relationInit = strNewFmt("%s/%s_init", strZ(strPath(file->name)), strZ(relationFileId));
"%s/%s_init", strPtr(strPath(file->name)), strPtr(relationFileId));
lastRelationFileId = relationFileId; lastRelationFileId = relationFileId;
lastRelationFileIdUnlogged = manifestFileFindDefault(this, relationInit, NULL) != NULL; lastRelationFileIdUnlogged = manifestFileFindDefault(this, relationInit, NULL) != NULL;
} }
@ -1078,7 +1077,7 @@ manifestBuildValidate(Manifest *this, bool delta, time_t copyStart, CompressType
if (file->timestamp > copyStart) if (file->timestamp > copyStart)
{ {
LOG_WARN_FMT( LOG_WARN_FMT(
"file '%s' has timestamp in the future, enabling delta checksum", strPtr(manifestPathPg(file->name))); "file '%s' has timestamp in the future, enabling delta checksum", strZ(manifestPathPg(file->name)));
this->data.backupOptionDelta = BOOL_TRUE_VAR; this->data.backupOptionDelta = BOOL_TRUE_VAR;
break; break;
@ -1127,7 +1126,7 @@ manifestBuildIncr(Manifest *this, const Manifest *manifestPrior, BackupType type
LOG_WARN_FMT( LOG_WARN_FMT(
"a timeline switch has occurred since the %s backup, enabling delta checksum\n" "a timeline switch has occurred since the %s backup, enabling delta checksum\n"
"HINT: this is normal after restoring from backup or promoting a standby.", "HINT: this is normal after restoring from backup or promoting a standby.",
strPtr(manifestData(manifestPrior)->backupLabel)); strZ(manifestData(manifestPrior)->backupLabel));
this->data.backupOptionDelta = BOOL_TRUE_VAR; this->data.backupOptionDelta = BOOL_TRUE_VAR;
} }
@ -1136,7 +1135,7 @@ manifestBuildIncr(Manifest *this, const Manifest *manifestPrior, BackupType type
{ {
LOG_WARN_FMT( LOG_WARN_FMT(
"the online option has changed since the %s backup, enabling delta checksum", "the online option has changed since the %s backup, enabling delta checksum",
strPtr(manifestData(manifestPrior)->backupLabel)); strZ(manifestData(manifestPrior)->backupLabel));
this->data.backupOptionDelta = BOOL_TRUE_VAR; this->data.backupOptionDelta = BOOL_TRUE_VAR;
} }
@ -1158,7 +1157,7 @@ manifestBuildIncr(Manifest *this, const Manifest *manifestPrior, BackupType type
{ {
LOG_WARN_FMT( LOG_WARN_FMT(
"file '%s' has timestamp earlier than prior backup, enabling delta checksum", "file '%s' has timestamp earlier than prior backup, enabling delta checksum",
strPtr(manifestPathPg(file->name))); strZ(manifestPathPg(file->name)));
this->data.backupOptionDelta = BOOL_TRUE_VAR; this->data.backupOptionDelta = BOOL_TRUE_VAR;
break; break;
@ -1169,7 +1168,7 @@ manifestBuildIncr(Manifest *this, const Manifest *manifestPrior, BackupType type
{ {
LOG_WARN_FMT( LOG_WARN_FMT(
"file '%s' has same timestamp as prior but different size, enabling delta checksum", "file '%s' has same timestamp as prior but different size, enabling delta checksum",
strPtr(manifestPathPg(file->name))); strZ(manifestPathPg(file->name)));
this->data.backupOptionDelta = BOOL_TRUE_VAR; this->data.backupOptionDelta = BOOL_TRUE_VAR;
break; break;
@ -1385,7 +1384,7 @@ manifestLoadCallback(void *callbackData, const String *section, const String *ke
const Variant *timestamp = kvGet(fileKv, MANIFEST_KEY_TIMESTAMP_VAR); const Variant *timestamp = kvGet(fileKv, MANIFEST_KEY_TIMESTAMP_VAR);
if (timestamp == NULL) if (timestamp == NULL)
THROW_FMT(FormatError, "missing timestamp for file '%s'", strPtr(key)); THROW_FMT(FormatError, "missing timestamp for file '%s'", strZ(key));
file.timestamp = (time_t)varUInt64(timestamp); file.timestamp = (time_t)varUInt64(timestamp);
@ -1395,7 +1394,7 @@ manifestLoadCallback(void *callbackData, const String *section, const String *ke
const Variant *size = kvGet(fileKv, MANIFEST_KEY_SIZE_VAR); const Variant *size = kvGet(fileKv, MANIFEST_KEY_SIZE_VAR);
if (size == NULL) if (size == NULL)
THROW_FMT(FormatError, "missing size for file '%s'", strPtr(key)); THROW_FMT(FormatError, "missing size for file '%s'", strZ(key));
file.size = varUInt64(size); file.size = varUInt64(size);
@ -1411,10 +1410,7 @@ manifestLoadCallback(void *callbackData, const String *section, const String *ke
// Else if the key exists then load it. The key might not exist if this is a partial save that was done during the // Else if the key exists then load it. The key might not exist if this is a partial save that was done during the
// backup to preserve checksums for already backed up files. // backup to preserve checksums for already backed up files.
else if (kvKeyExists(fileKv, MANIFEST_KEY_CHECKSUM_VAR)) else if (kvKeyExists(fileKv, MANIFEST_KEY_CHECKSUM_VAR))
{ memcpy(file.checksumSha1, strZ(varStr(kvGet(fileKv, MANIFEST_KEY_CHECKSUM_VAR))), HASH_TYPE_SHA1_SIZE_HEX + 1);
memcpy(
file.checksumSha1, strPtr(varStr(kvGet(fileKv, MANIFEST_KEY_CHECKSUM_VAR))), HASH_TYPE_SHA1_SIZE_HEX + 1);
}
const Variant *checksumPage = kvGetDefault(fileKv, MANIFEST_KEY_CHECKSUM_PAGE_VAR, NULL); const Variant *checksumPage = kvGetDefault(fileKv, MANIFEST_KEY_CHECKSUM_PAGE_VAR, NULL);
@ -1438,7 +1434,7 @@ manifestLoadCallback(void *callbackData, const String *section, const String *ke
if (kvKeyExists(fileKv, MANIFEST_KEY_MODE_VAR)) if (kvKeyExists(fileKv, MANIFEST_KEY_MODE_VAR))
{ {
valueFound.mode = true; valueFound.mode = true;
file.mode = cvtZToMode(strPtr(varStr(kvGet(fileKv, MANIFEST_KEY_MODE_VAR)))); file.mode = cvtZToMode(strZ(varStr(kvGet(fileKv, MANIFEST_KEY_MODE_VAR))));
} }
if (kvKeyExists(fileKv, MANIFEST_KEY_PRIMARY_VAR)) if (kvKeyExists(fileKv, MANIFEST_KEY_PRIMARY_VAR))
@ -1482,7 +1478,7 @@ manifestLoadCallback(void *callbackData, const String *section, const String *ke
if (kvKeyExists(pathKv, MANIFEST_KEY_MODE_VAR)) if (kvKeyExists(pathKv, MANIFEST_KEY_MODE_VAR))
{ {
valueFound.mode = true; valueFound.mode = true;
path.mode = cvtZToMode(strPtr(varStr(kvGet(pathKv, MANIFEST_KEY_MODE_VAR)))); path.mode = cvtZToMode(strZ(varStr(kvGet(pathKv, MANIFEST_KEY_MODE_VAR))));
} }
if (kvKeyExists(pathKv, MANIFEST_KEY_USER_VAR)) if (kvKeyExists(pathKv, MANIFEST_KEY_USER_VAR))
@ -1538,7 +1534,7 @@ manifestLoadCallback(void *callbackData, const String *section, const String *ke
if (strEq(key, MANIFEST_KEY_GROUP_STR)) if (strEq(key, MANIFEST_KEY_GROUP_STR))
loadData->fileGroupDefault = manifestOwnerDefaultGet(value); loadData->fileGroupDefault = manifestOwnerDefaultGet(value);
else if (strEq(key, MANIFEST_KEY_MODE_STR)) else if (strEq(key, MANIFEST_KEY_MODE_STR))
loadData->fileModeDefault = cvtZToMode(strPtr(jsonToStr(value))); loadData->fileModeDefault = cvtZToMode(strZ(jsonToStr(value)));
else if (strEq(key, MANIFEST_KEY_PRIMARY_STR)) else if (strEq(key, MANIFEST_KEY_PRIMARY_STR))
loadData->filePrimaryDefault = jsonToBool(value); loadData->filePrimaryDefault = jsonToBool(value);
else if (strEq(key, MANIFEST_KEY_USER_STR)) else if (strEq(key, MANIFEST_KEY_USER_STR))
@ -1555,7 +1551,7 @@ manifestLoadCallback(void *callbackData, const String *section, const String *ke
if (strEq(key, MANIFEST_KEY_GROUP_STR)) if (strEq(key, MANIFEST_KEY_GROUP_STR))
loadData->pathGroupDefault = manifestOwnerDefaultGet(value); loadData->pathGroupDefault = manifestOwnerDefaultGet(value);
else if (strEq(key, MANIFEST_KEY_MODE_STR)) else if (strEq(key, MANIFEST_KEY_MODE_STR))
loadData->pathModeDefault = cvtZToMode(strPtr(jsonToStr(value))); loadData->pathModeDefault = cvtZToMode(strZ(jsonToStr(value)));
else if (strEq(key, MANIFEST_KEY_USER_STR)) else if (strEq(key, MANIFEST_KEY_USER_STR))
loadData->pathUserDefault = manifestOwnerDefaultGet(value); loadData->pathUserDefault = manifestOwnerDefaultGet(value);
} }
@ -1588,8 +1584,7 @@ manifestLoadCallback(void *callbackData, const String *section, const String *ke
.name = key, .name = key,
.file = varStr(kvGetDefault(targetKv, MANIFEST_KEY_FILE_VAR, NULL)), .file = varStr(kvGetDefault(targetKv, MANIFEST_KEY_FILE_VAR, NULL)),
.path = varStr(kvGet(targetKv, MANIFEST_KEY_PATH_VAR)), .path = varStr(kvGet(targetKv, MANIFEST_KEY_PATH_VAR)),
.tablespaceId = .tablespaceId = cvtZToUInt(strZ(varStr(kvGetDefault(targetKv, MANIFEST_KEY_TABLESPACE_ID_VAR, VARSTRDEF("0"))))),
cvtZToUInt(strPtr(varStr(kvGetDefault(targetKv, MANIFEST_KEY_TABLESPACE_ID_VAR, VARSTRDEF("0"))))),
.tablespaceName = varStr(kvGetDefault(targetKv, MANIFEST_KEY_TABLESPACE_NAME_VAR, NULL)), .tablespaceName = varStr(kvGetDefault(targetKv, MANIFEST_KEY_TABLESPACE_NAME_VAR, NULL)),
.type = strEq(targetType, MANIFEST_TARGET_TYPE_PATH_STR) ? manifestTargetTypePath : manifestTargetTypeLink, .type = strEq(targetType, MANIFEST_TARGET_TYPE_PATH_STR) ? manifestTargetTypePath : manifestTargetTypeLink,
}; };
@ -2322,24 +2317,24 @@ manifestValidate(Manifest *this, bool strict)
// All files must have a checksum // All files must have a checksum
if (file->checksumSha1[0] == '\0') if (file->checksumSha1[0] == '\0')
strCatFmt(error, "\nmissing checksum for file '%s'", strPtr(file->name)); strCatFmt(error, "\nmissing checksum for file '%s'", strZ(file->name));
// These are strict checks to be performed only after a backup and before the final manifest save // These are strict checks to be performed only after a backup and before the final manifest save
if (strict) if (strict)
{ {
// Zero-length files must have a specific checksum // Zero-length files must have a specific checksum
if (file->size == 0 && !strEqZ(HASH_TYPE_SHA1_ZERO_STR, file->checksumSha1)) if (file->size == 0 && !strEqZ(HASH_TYPE_SHA1_ZERO_STR, file->checksumSha1))
strCatFmt(error, "\ninvalid checksum '%s' for zero size file '%s'", file->checksumSha1, strPtr(file->name)); strCatFmt(error, "\ninvalid checksum '%s' for zero size file '%s'", file->checksumSha1, strZ(file->name));
// Non-zero size files must have non-zero repo size // Non-zero size files must have non-zero repo size
if (file->sizeRepo == 0 && file->size != 0) if (file->sizeRepo == 0 && file->size != 0)
strCatFmt(error, "\nrepo size must be > 0 for file '%s'", strPtr(file->name)); strCatFmt(error, "\nrepo size must be > 0 for file '%s'", strZ(file->name));
} }
} }
// Throw exception when there are errors // Throw exception when there are errors
if (strSize(error) > 0) if (strSize(error) > 0)
THROW_FMT(FormatError, "manifest validation failed:%s", strPtr(error)); THROW_FMT(FormatError, "manifest validation failed:%s", strZ(error));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
@ -2368,13 +2363,13 @@ manifestLinkCheck(const Manifest *this)
{ {
// Check that the link is not inside the base data path // Check that the link is not inside the base data path
if (strBeginsWith( if (strBeginsWith(
strNewFmt("%s/", strPtr(manifestTargetPath(this, link1))), strNewFmt("%s/", strZ(manifestTargetPath(this, link1))),
strNewFmt("%s/", strPtr(manifestTargetPath(this, base))))) strNewFmt("%s/", strZ(manifestTargetPath(this, base)))))
{ {
THROW_FMT( THROW_FMT(
LinkDestinationError, LinkDestinationError,
"link '%s' destination '%s' is in PGDATA", "link '%s' destination '%s' is in PGDATA",
strPtr(manifestPathPg(link1->name)), strPtr(manifestTargetPath(this, link1))); strZ(manifestPathPg(link1->name)), strZ(manifestTargetPath(this, link1)));
} }
// Check that no link is a subpath of another link // Check that no link is a subpath of another link
@ -2392,14 +2387,14 @@ manifestLinkCheck(const Manifest *this)
continue; continue;
if (strBeginsWith( if (strBeginsWith(
strNewFmt("%s/", strPtr(manifestTargetPath(this, link1))), strNewFmt("%s/", strZ(manifestTargetPath(this, link1))),
strNewFmt("%s/", strPtr(manifestTargetPath(this, link2))))) strNewFmt("%s/", strZ(manifestTargetPath(this, link2)))))
{ {
THROW_FMT( THROW_FMT(
LinkDestinationError, LinkDestinationError,
"link '%s' (%s) destination is a subdirectory of or the same directory as link '%s' (%s)", "link '%s' (%s) destination is a subdirectory of or the same directory as link '%s' (%s)",
strPtr(manifestPathPg(link1->name)), strPtr(manifestTargetPath(this, link1)), strZ(manifestPathPg(link1->name)), strZ(manifestTargetPath(this, link1)),
strPtr(manifestPathPg(link2->name)), strPtr(manifestTargetPath(this, link2))); strZ(manifestPathPg(link2->name)), strZ(manifestTargetPath(this, link2)));
} }
} }
} }
@ -2439,7 +2434,7 @@ manifestDbFind(const Manifest *this, const String *name)
const ManifestDb *result = lstFind(this->dbList, &name); const ManifestDb *result = lstFind(this->dbList, &name);
if (result == NULL) if (result == NULL)
THROW_FMT(AssertError, "unable to find '%s' in manifest db list", strPtr(name)); THROW_FMT(AssertError, "unable to find '%s' in manifest db list", strZ(name));
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -2502,7 +2497,7 @@ manifestFileFind(const Manifest *this, const String *name)
const ManifestFile *result = lstFind(this->fileList, &name); const ManifestFile *result = lstFind(this->fileList, &name);
if (result == NULL) if (result == NULL)
THROW_FMT(AssertError, "unable to find '%s' in manifest file list", strPtr(name)); THROW_FMT(AssertError, "unable to find '%s' in manifest file list", strZ(name));
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -2535,7 +2530,7 @@ manifestFileRemove(const Manifest *this, const String *name)
ASSERT(name != NULL); ASSERT(name != NULL);
if (!lstRemove(this->fileList, &name)) if (!lstRemove(this->fileList, &name))
THROW_FMT(AssertError, "unable to remove '%s' from manifest file list", strPtr(name)); THROW_FMT(AssertError, "unable to remove '%s' from manifest file list", strZ(name));
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
} }
@ -2636,7 +2631,7 @@ manifestLinkFind(const Manifest *this, const String *name)
const ManifestLink *result = lstFind(this->linkList, &name); const ManifestLink *result = lstFind(this->linkList, &name);
if (result == NULL) if (result == NULL)
THROW_FMT(AssertError, "unable to find '%s' in manifest link list", strPtr(name)); THROW_FMT(AssertError, "unable to find '%s' in manifest link list", strZ(name));
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -2669,7 +2664,7 @@ manifestLinkRemove(const Manifest *this, const String *name)
ASSERT(name != NULL); ASSERT(name != NULL);
if (!lstRemove(this->linkList, &name)) if (!lstRemove(this->linkList, &name))
THROW_FMT(AssertError, "unable to remove '%s' from manifest link list", strPtr(name)); THROW_FMT(AssertError, "unable to remove '%s' from manifest link list", strZ(name));
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
} }
@ -2741,7 +2736,7 @@ manifestPathFind(const Manifest *this, const String *name)
const ManifestPath *result = lstFind(this->pathList, &name); const ManifestPath *result = lstFind(this->pathList, &name);
if (result == NULL) if (result == NULL)
THROW_FMT(AssertError, "unable to find '%s' in manifest path list", strPtr(name)); THROW_FMT(AssertError, "unable to find '%s' in manifest path list", strZ(name));
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -2774,7 +2769,7 @@ manifestPathPg(const String *manifestPath)
// If something in pg_data/ // If something in pg_data/
if (strBeginsWith(manifestPath, STRDEF(MANIFEST_TARGET_PGDATA "/"))) if (strBeginsWith(manifestPath, STRDEF(MANIFEST_TARGET_PGDATA "/")))
{ {
FUNCTION_TEST_RETURN(strNew(strPtr(manifestPath) + sizeof(MANIFEST_TARGET_PGDATA))); FUNCTION_TEST_RETURN(strNew(strZ(manifestPath) + sizeof(MANIFEST_TARGET_PGDATA)));
} }
// Else not pg_data (this is faster since the length of everything else will be different than pg_data) // Else not pg_data (this is faster since the length of everything else will be different than pg_data)
else if (!strEq(manifestPath, MANIFEST_TARGET_PGDATA_STR)) else if (!strEq(manifestPath, MANIFEST_TARGET_PGDATA_STR))
@ -2843,7 +2838,7 @@ manifestTargetFind(const Manifest *this, const String *name)
const ManifestTarget *result = lstFind(this->targetList, &name); const ManifestTarget *result = lstFind(this->targetList, &name);
if (result == NULL) if (result == NULL)
THROW_FMT(AssertError, "unable to find '%s' in manifest target list", strPtr(name)); THROW_FMT(AssertError, "unable to find '%s' in manifest target list", strZ(name));
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -2898,7 +2893,7 @@ manifestTargetRemove(const Manifest *this, const String *name)
ASSERT(name != NULL); ASSERT(name != NULL);
if (!lstRemove(this->targetList, &name)) if (!lstRemove(this->targetList, &name))
THROW_FMT(AssertError, "unable to remove '%s' from manifest target list", strPtr(name)); THROW_FMT(AssertError, "unable to remove '%s' from manifest target list", strZ(name));
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
} }
@ -3034,7 +3029,7 @@ manifestLoadFileCallback(void *data, unsigned int try)
if (try < 2) if (try < 2)
{ {
// Construct filename based on try // Construct filename based on try
const String *fileName = try == 0 ? loadData->fileName : strNewFmt("%s" INFO_COPY_EXT, strPtr(loadData->fileName)); const String *fileName = try == 0 ? loadData->fileName : strNewFmt("%s" INFO_COPY_EXT, strZ(loadData->fileName));
// Attempt to load the file // Attempt to load the file
IoRead *read = storageReadIo(storageNewReadP(loadData->storage, fileName)); IoRead *read = storageReadIo(storageNewReadP(loadData->storage, fileName));
@ -3076,7 +3071,7 @@ manifestLoadFile(const Storage *storage, const String *fileName, CipherType ciph
MEM_CONTEXT_TEMP_BEGIN() MEM_CONTEXT_TEMP_BEGIN()
{ {
const char *fileNamePath = strPtr(storagePathP(storage, fileName)); const char *fileNamePath = strZ(storagePathP(storage, fileName));
infoLoad( infoLoad(
strNewFmt("unable to load backup manifest file '%s' or '%s" INFO_COPY_EXT "'", fileNamePath, fileNamePath), strNewFmt("unable to load backup manifest file '%s' or '%s" INFO_COPY_EXT "'", fileNamePath, fileNamePath),

View File

@ -103,7 +103,7 @@ pgClientEscape(const String *string)
// Iterate all characters in the string // Iterate all characters in the string
for (unsigned stringIdx = 0; stringIdx < strSize(string); stringIdx++) for (unsigned stringIdx = 0; stringIdx < strSize(string); stringIdx++)
{ {
char stringChar = strPtr(string)[stringIdx]; char stringChar = strZ(string)[stringIdx];
// These characters are escaped // These characters are escaped
if (stringChar == '\'' || stringChar == '\\') if (stringChar == '\'' || stringChar == '\\')
@ -131,18 +131,18 @@ pgClientOpen(PgClient *this)
MEM_CONTEXT_TEMP_BEGIN() MEM_CONTEXT_TEMP_BEGIN()
{ {
// Base connection string // Base connection string
String *connInfo = strNewFmt("dbname=%s port=%u", strPtr(pgClientEscape(this->database)), this->port); String *connInfo = strNewFmt("dbname=%s port=%u", strZ(pgClientEscape(this->database)), this->port);
// Add user if specified // Add user if specified
if (this->user != NULL) if (this->user != NULL)
strCatFmt(connInfo, " user=%s", strPtr(pgClientEscape(this->user))); strCatFmt(connInfo, " user=%s", strZ(pgClientEscape(this->user)));
// Add host if specified // Add host if specified
if (this->host != NULL) if (this->host != NULL)
strCatFmt(connInfo, " host=%s", strPtr(pgClientEscape(this->host))); strCatFmt(connInfo, " host=%s", strZ(pgClientEscape(this->host)));
// Make the connection // Make the connection
this->connection = PQconnectdb(strPtr(connInfo)); this->connection = PQconnectdb(strZ(connInfo));
// Set a callback to shutdown the connection // Set a callback to shutdown the connection
memContextCallbackSet(this->memContext, pgClientFreeResource, this); memContextCallbackSet(this->memContext, pgClientFreeResource, this);
@ -151,8 +151,8 @@ pgClientOpen(PgClient *this)
if (PQstatus(this->connection) != CONNECTION_OK) if (PQstatus(this->connection) != CONNECTION_OK)
{ {
THROW_FMT( THROW_FMT(
DbConnectError, "unable to connect to '%s': %s", strPtr(connInfo), DbConnectError, "unable to connect to '%s': %s", strZ(connInfo),
strPtr(strTrim(strNew(PQerrorMessage(this->connection))))); strZ(strTrim(strNew(PQerrorMessage(this->connection)))));
} }
// Set notice and warning processor // Set notice and warning processor
@ -181,11 +181,11 @@ pgClientQuery(PgClient *this, const String *query)
MEM_CONTEXT_TEMP_BEGIN() MEM_CONTEXT_TEMP_BEGIN()
{ {
// Send the query without waiting for results so we can timeout if needed // Send the query without waiting for results so we can timeout if needed
if (!PQsendQuery(this->connection, strPtr(query))) if (!PQsendQuery(this->connection, strZ(query)))
{ {
THROW_FMT( THROW_FMT(
DbQueryError, "unable to send query '%s': %s", strPtr(query), DbQueryError, "unable to send query '%s': %s", strZ(query),
strPtr(strTrim(strNew(PQerrorMessage(this->connection))))); strZ(strTrim(strNew(PQerrorMessage(this->connection)))));
} }
// Wait for a result // Wait for a result
@ -210,7 +210,7 @@ pgClientQuery(PgClient *this, const String *query)
char error[256]; char error[256];
if (!PQcancel(cancel, error, sizeof(error))) if (!PQcancel(cancel, error, sizeof(error)))
THROW_FMT(DbQueryError, "unable to cancel query '%s': %s", strPtr(query), strPtr(strTrim(strNew(error)))); THROW_FMT(DbQueryError, "unable to cancel query '%s': %s", strZ(query), strZ(strTrim(strNew(error))));
} }
FINALLY() FINALLY()
{ {
@ -226,7 +226,7 @@ pgClientQuery(PgClient *this, const String *query)
{ {
// Throw timeout error if cancelled // Throw timeout error if cancelled
if (busy) if (busy)
THROW_FMT(DbQueryError, "query '%s' timed out after %" PRIu64 "ms", strPtr(query), this->queryTimeout); THROW_FMT(DbQueryError, "query '%s' timed out after %" PRIu64 "ms", strZ(query), this->queryTimeout);
// If this was a command that returned no results then we are done // If this was a command that returned no results then we are done
int resultStatus = PQresultStatus(pgResult); int resultStatus = PQresultStatus(pgResult);
@ -237,8 +237,8 @@ pgClientQuery(PgClient *this, const String *query)
if (resultStatus != PGRES_TUPLES_OK) if (resultStatus != PGRES_TUPLES_OK)
{ {
THROW_FMT( THROW_FMT(
DbQueryError, "unable to execute query '%s': %s", strPtr(query), DbQueryError, "unable to execute query '%s': %s", strZ(query),
strPtr(strTrim(strNew(PQresultErrorMessage(pgResult))))); strZ(strTrim(strNew(PQresultErrorMessage(pgResult)))));
} }
// Fetch row and column values // Fetch row and column values
@ -305,7 +305,7 @@ pgClientQuery(PgClient *this, const String *query)
{ {
THROW_FMT( THROW_FMT(
FormatError, "unable to parse type %u in column %d for query '%s'", FormatError, "unable to parse type %u in column %d for query '%s'",
columnType[columnIdx], columnIdx, strPtr(query)); columnType[columnIdx], columnIdx, strZ(query));
} }
} }
} }
@ -359,6 +359,6 @@ String *
pgClientToLog(const PgClient *this) pgClientToLog(const PgClient *this)
{ {
return strNewFmt( return strNewFmt(
"{host: %s, port: %u, database: %s, user: %s, queryTimeout %" PRIu64 "}", strPtr(strToLog(this->host)), this->port, "{host: %s, port: %u, database: %s, user: %s, queryTimeout %" PRIu64 "}", strZ(strToLog(this->host)), this->port,
strPtr(strToLog(this->database)), strPtr(strToLog(this->user)), this->queryTimeout); strZ(strToLog(this->database)), strZ(strToLog(this->user)), this->queryTimeout);
} }

View File

@ -589,7 +589,7 @@ pgTablespaceId(unsigned int pgVersion)
MEM_CONTEXT_PRIOR_BEGIN() MEM_CONTEXT_PRIOR_BEGIN()
{ {
result = strNewFmt("PG_%s_%u", strPtr(pgVersionStr), pgCatalogVersion(pgVersion)); result = strNewFmt("PG_%s_%u", strZ(pgVersionStr), pgCatalogVersion(pgVersion));
} }
MEM_CONTEXT_PRIOR_END(); MEM_CONTEXT_PRIOR_END();
} }
@ -615,7 +615,7 @@ pgLsnFromStr(const String *lsn)
CHECK(strLstSize(lsnPart) == 2); CHECK(strLstSize(lsnPart) == 2);
result = (cvtZToUInt64Base(strPtr(strLstGet(lsnPart, 0)), 16) << 32) + cvtZToUInt64Base(strPtr(strLstGet(lsnPart, 1)), 16); result = (cvtZToUInt64Base(strZ(strLstGet(lsnPart, 0)), 16) << 32) + cvtZToUInt64Base(strZ(strLstGet(lsnPart, 1)), 16);
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
@ -659,8 +659,8 @@ pgLsnFromWalSegment(const String *walSegment, unsigned int walSegmentSize)
ASSERT(walSegmentSize > 0); ASSERT(walSegmentSize > 0);
FUNCTION_TEST_RETURN( FUNCTION_TEST_RETURN(
(cvtZToUInt64Base(strPtr(strSubN(walSegment, 8, 8)), 16) << 32) + (cvtZToUInt64Base(strZ(strSubN(walSegment, 8, 8)), 16) << 32) +
(cvtZToUInt64Base(strPtr(strSubN(walSegment, 16, 8)), 16) * walSegmentSize)); (cvtZToUInt64Base(strZ(strSubN(walSegment, 16, 8)), 16) * walSegmentSize));
} }
/**********************************************************************************************************************************/ /**********************************************************************************************************************************/
@ -837,7 +837,7 @@ pgVersionFromStr(const String *version)
{ {
// If format is not number.number (9.4) or number only (10) then error // If format is not number.number (9.4) or number only (10) then error
if (!regExpMatchOne(STRDEF("^[0-9]+[.]*[0-9]+$"), version)) if (!regExpMatchOne(STRDEF("^[0-9]+[.]*[0-9]+$"), version))
THROW_FMT(AssertError, "version %s format is invalid", strPtr(version)); THROW_FMT(AssertError, "version %s format is invalid", strZ(version));
// If there is a dot set the major and minor versions, else just the major // If there is a dot set the major and minor versions, else just the major
int idxStart = strChr(version, '.'); int idxStart = strChr(version, '.');
@ -846,11 +846,11 @@ pgVersionFromStr(const String *version)
if (idxStart != -1) if (idxStart != -1)
{ {
major = cvtZToUInt(strPtr(strSubN(version, 0, (size_t)idxStart))); major = cvtZToUInt(strZ(strSubN(version, 0, (size_t)idxStart)));
minor = cvtZToUInt(strPtr(strSub(version, (size_t)idxStart + 1))); minor = cvtZToUInt(strZ(strSub(version, (size_t)idxStart + 1)));
} }
else else
major = cvtZToUInt(strPtr(version)); major = cvtZToUInt(strZ(version));
// No check to see if valid/supported PG version is on purpose // No check to see if valid/supported PG version is on purpose
result = major * 10000 + minor * 100; result = major * 10000 + minor * 100;

View File

@ -83,7 +83,7 @@ protocolClientNew(const String *name, const String *service, IoRead *read, IoWri
{ {
.memContext = memContextCurrent(), .memContext = memContextCurrent(),
.name = strDup(name), .name = strDup(name),
.errorPrefix = strNewFmt("raised from %s", strPtr(name)), .errorPrefix = strNewFmt("raised from %s", strZ(name)),
.read = read, .read = read,
.write = write, .write = write,
.keepAliveTime = timeMSec(), .keepAliveTime = timeMSec(),
@ -110,16 +110,16 @@ protocolClientNew(const String *name, const String *service, IoRead *read, IoWri
const Variant *actualValue = kvGet(greetingKv, VARSTR(expectedKey)); const Variant *actualValue = kvGet(greetingKv, VARSTR(expectedKey));
if (actualValue == NULL) if (actualValue == NULL)
THROW_FMT(ProtocolError, "unable to find greeting key '%s'", strPtr(expectedKey)); THROW_FMT(ProtocolError, "unable to find greeting key '%s'", strZ(expectedKey));
if (varType(actualValue) != varTypeString) if (varType(actualValue) != varTypeString)
THROW_FMT(ProtocolError, "greeting key '%s' must be string type", strPtr(expectedKey)); THROW_FMT(ProtocolError, "greeting key '%s' must be string type", strZ(expectedKey));
if (!strEq(varStr(actualValue), expectedValue)) if (!strEq(varStr(actualValue), expectedValue))
{ {
THROW_FMT( THROW_FMT(
ProtocolError, "expected value '%s' for greeting key '%s' but got '%s'", strPtr(expectedValue), ProtocolError, "expected value '%s' for greeting key '%s' but got '%s'", strZ(expectedValue),
strPtr(expectedKey), strPtr(varStr(actualValue))); strZ(expectedKey), strZ(varStr(actualValue)));
} }
} }
} }
@ -161,7 +161,7 @@ protocolClientProcessError(ProtocolClient *this, KeyValue *errorKv)
// Required part of the message // Required part of the message
String *throwMessage = strNewFmt( String *throwMessage = strNewFmt(
"%s: %s", strPtr(this->errorPrefix), message == NULL ? "no details available" : strPtr(message)); "%s: %s", strZ(this->errorPrefix), message == NULL ? "no details available" : strZ(message));
// Add stack trace if the error is an assertion or debug-level logging is enabled // Add stack trace if the error is an assertion or debug-level logging is enabled
if (type == &AssertError || logAny(logLevelDebug)) if (type == &AssertError || logAny(logLevelDebug))
@ -172,7 +172,7 @@ protocolClientProcessError(ProtocolClient *this, KeyValue *errorKv)
strCat(throwMessage, stack == NULL ? STRDEF("no stack trace available") : stack); strCat(throwMessage, stack == NULL ? STRDEF("no stack trace available") : stack);
} }
THROWP(type, strPtr(throwMessage)); THROWP(type, strZ(throwMessage));
} }
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
@ -300,7 +300,7 @@ protocolClientReadLine(ProtocolClient *this)
{ {
THROW(FormatError, "unexpected empty line"); THROW(FormatError, "unexpected empty line");
} }
else if (strPtr(result)[0] == '{') else if (strZ(result)[0] == '{')
{ {
KeyValue *responseKv = varKv(jsonToVar(result)); KeyValue *responseKv = varKv(jsonToVar(result));
@ -310,8 +310,8 @@ protocolClientReadLine(ProtocolClient *this)
// If not an error then there is probably a protocol bug // If not an error then there is probably a protocol bug
THROW(FormatError, "expected error but got output"); THROW(FormatError, "expected error but got output");
} }
else if (strPtr(result)[0] != '.') else if (strZ(result)[0] != '.')
THROW_FMT(FormatError, "invalid prefix in '%s'", strPtr(result)); THROW_FMT(FormatError, "invalid prefix in '%s'", strZ(result));
MEM_CONTEXT_PRIOR_BEGIN() MEM_CONTEXT_PRIOR_BEGIN()
{ {
@ -354,5 +354,5 @@ protocolClientIoWrite(const ProtocolClient *this)
String * String *
protocolClientToLog(const ProtocolClient *this) protocolClientToLog(const ProtocolClient *this)
{ {
return strNewFmt("{name: %s}", strPtr(this->name)); return strNewFmt("{name: %s}", strZ(this->name));
} }

View File

@ -116,5 +116,5 @@ protocolCommandJson(const ProtocolCommand *this)
String * String *
protocolCommandToLog(const ProtocolCommand *this) protocolCommandToLog(const ProtocolCommand *this)
{ {
return strNewFmt("{command: %s}", strPtr(this->command)); return strNewFmt("{command: %s}", strZ(this->command));
} }

View File

@ -315,8 +315,8 @@ protocolRemoteParam(ProtocolStorageType protocolStorageType, unsigned int protoc
strLstAdd( strLstAdd(
result, result,
strNewFmt( strNewFmt(
"%s@%s", strPtr(cfgOptionStr(isRepo ? cfgOptRepoHostUser : cfgOptPgHostUser + hostIdx)), "%s@%s", strZ(cfgOptionStr(isRepo ? cfgOptRepoHostUser : cfgOptPgHostUser + hostIdx)),
strPtr(cfgOptionStr(isRepo ? cfgOptRepoHost : cfgOptPgHost + hostIdx)))); strZ(cfgOptionStr(isRepo ? cfgOptRepoHost : cfgOptPgHost + hostIdx))));
// Option replacements // Option replacements
KeyValue *optionReplace = kvNew(); KeyValue *optionReplace = kvNew();
@ -509,13 +509,13 @@ protocolRemoteGet(ProtocolStorageType protocolStorageType, unsigned int hostId)
// Execute the protocol command // Execute the protocol command
protocolHelperClient->exec = execNew( protocolHelperClient->exec = execNew(
cfgOptionStr(cfgOptCmdSsh), protocolRemoteParam(protocolStorageType, protocolId, hostId - 1), cfgOptionStr(cfgOptCmdSsh), protocolRemoteParam(protocolStorageType, protocolId, hostId - 1),
strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u process on '%s'", protocolId, strPtr(cfgOptionStr(optHost))), strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u process on '%s'", protocolId, strZ(cfgOptionStr(optHost))),
(TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * 1000)); (TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * 1000));
execOpen(protocolHelperClient->exec); execOpen(protocolHelperClient->exec);
// Create protocol object // Create protocol object
protocolHelperClient->client = protocolClientNew( protocolHelperClient->client = protocolClientNew(
strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u protocol on '%s'", protocolId, strPtr(cfgOptionStr(optHost))), strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u protocol on '%s'", protocolId, strZ(cfgOptionStr(optHost))),
PROTOCOL_SERVICE_REMOTE_STR, execIoRead(protocolHelperClient->exec), execIoWrite(protocolHelperClient->exec)); PROTOCOL_SERVICE_REMOTE_STR, execIoRead(protocolHelperClient->exec), execIoWrite(protocolHelperClient->exec));
// Get cipher options from the remote if none are locally configured // Get cipher options from the remote if none are locally configured
@ -594,7 +594,7 @@ protocolStorageTypeEnum(const String *type)
else if (strEq(type, PROTOCOL_REMOTE_TYPE_REPO_STR)) else if (strEq(type, PROTOCOL_REMOTE_TYPE_REPO_STR))
FUNCTION_TEST_RETURN(protocolStorageTypeRepo); FUNCTION_TEST_RETURN(protocolStorageTypeRepo);
THROW_FMT(AssertError, "invalid protocol storage type '%s'", strPtr(type)); THROW_FMT(AssertError, "invalid protocol storage type '%s'", strZ(type));
} }
const String * const String *

View File

@ -267,6 +267,6 @@ protocolParallelJobToLog(const ProtocolParallelJob *this)
{ {
return strNewFmt( return strNewFmt(
"{state: %s, key: %s, command: %s, code: %d, message: %s, result: %s}", protocolParallelJobToConstZ(this->state), "{state: %s, key: %s, command: %s, code: %d, message: %s, result: %s}", protocolParallelJobToConstZ(this->state),
strPtr(varToLog(this->key)), strPtr(protocolCommandToLog(this->command)), this->code, strPtr(strToLog(this->message)), strZ(varToLog(this->key)), strZ(protocolCommandToLog(this->command)), this->code, strZ(strToLog(this->message)),
strPtr(varToLog(this->result))); strZ(varToLog(this->result)));
} }

View File

@ -217,7 +217,7 @@ protocolServerProcess(ProtocolServer *this, const VariantList *retryInterval)
else if (strEq(command, PROTOCOL_COMMAND_EXIT_STR)) else if (strEq(command, PROTOCOL_COMMAND_EXIT_STR))
exit = true; exit = true;
else else
THROW_FMT(ProtocolError, "invalid command '%s'", strPtr(command)); THROW_FMT(ProtocolError, "invalid command '%s'", strZ(command));
} }
// Send keep alives to remotes. When a local process is doing work that does not involve the remote it is important // Send keep alives to remotes. When a local process is doing work that does not involve the remote it is important
@ -313,5 +313,5 @@ protocolServerIoWrite(const ProtocolServer *this)
String * String *
protocolServerToLog(const ProtocolServer *this) protocolServerToLog(const ProtocolServer *this)
{ {
return strNewFmt("{name: %s}", strPtr(this->name)); return strNewFmt("{name: %s}", strZ(this->name));
} }

View File

@ -69,7 +69,7 @@ storageReadAzureOpen(THIS_VOID)
} }
// Else error unless ignore missing // Else error unless ignore missing
else if (!this->interface.ignoreMissing) else if (!this->interface.ignoreMissing)
THROW_FMT(FileMissingError, "unable to open '%s': No such file or directory", strPtr(this->interface.name)); THROW_FMT(FileMissingError, "unable to open '%s': No such file or directory", strZ(this->interface.name));
FUNCTION_LOG_RETURN(BOOL, result); FUNCTION_LOG_RETURN(BOOL, result);
} }

View File

@ -132,7 +132,7 @@ storageAzureAuth(
if (!strBeginsWithZ(headerKey, "x-ms-")) if (!strBeginsWithZ(headerKey, "x-ms-"))
continue; continue;
strCatFmt(headerCanonical, "%s:%s\n", strPtr(headerKey), strPtr(httpHeaderGet(httpHeader, headerKey))); strCatFmt(headerCanonical, "%s:%s\n", strZ(headerKey), strZ(httpHeaderGet(httpHeader, headerKey)));
} }
// Generate canonical query // Generate canonical query
@ -147,7 +147,7 @@ storageAzureAuth(
{ {
const String *queryKey = strLstGet(queryKeyList, queryKeyIdx); const String *queryKey = strLstGet(queryKeyList, queryKeyIdx);
strCatFmt(queryCanonical, "\n%s:%s", strPtr(queryKey), strPtr(httpQueryGet(query, queryKey))); strCatFmt(queryCanonical, "\n%s:%s", strZ(queryKey), strZ(httpQueryGet(query, queryKey)));
} }
} }
@ -171,12 +171,12 @@ storageAzureAuth(
"%s" // Canonicalized headers "%s" // Canonicalized headers
"/%s%s" // Canonicalized account/uri "/%s%s" // Canonicalized account/uri
"%s", // Canonicalized query "%s", // Canonicalized query
strPtr(verb), strEq(contentLength, ZERO_STR) ? "" : strPtr(contentLength), contentMd5 == NULL ? "" : strPtr(contentMd5), strZ(verb), strEq(contentLength, ZERO_STR) ? "" : strZ(contentLength), contentMd5 == NULL ? "" : strZ(contentMd5),
strPtr(dateTime), strPtr(headerCanonical), strPtr(this->account), strPtr(uri), strPtr(queryCanonical)); strZ(dateTime), strZ(headerCanonical), strZ(this->account), strZ(uri), strZ(queryCanonical));
// Generate authorization header // Generate authorization header
Buffer *keyBin = bufNew(decodeToBinSize(encodeBase64, strPtr(this->sharedKey))); Buffer *keyBin = bufNew(decodeToBinSize(encodeBase64, strZ(this->sharedKey)));
decodeToBin(encodeBase64, strPtr(this->sharedKey), bufPtr(keyBin)); decodeToBin(encodeBase64, strZ(this->sharedKey), bufPtr(keyBin));
bufUsedSet(keyBin, bufSize(keyBin)); bufUsedSet(keyBin, bufSize(keyBin));
char authHmacBase64[45]; char authHmacBase64[45];
@ -185,7 +185,7 @@ storageAzureAuth(
HASH_TYPE_SHA256_SIZE, authHmacBase64); HASH_TYPE_SHA256_SIZE, authHmacBase64);
httpHeaderPut( httpHeaderPut(
httpHeader, HTTP_HEADER_AUTHORIZATION_STR, strNewFmt("SharedKey %s:%s", strPtr(this->account), authHmacBase64)); httpHeader, HTTP_HEADER_AUTHORIZATION_STR, strNewFmt("SharedKey %s:%s", strZ(this->account), authHmacBase64));
} }
// SAS authentication // SAS authentication
else else
@ -219,7 +219,7 @@ storageAzureRequestAsync(StorageAzure *this, const String *verb, StorageAzureReq
MEM_CONTEXT_TEMP_BEGIN() MEM_CONTEXT_TEMP_BEGIN()
{ {
// Prepend uri prefix // Prepend uri prefix
param.uri = param.uri == NULL ? this->uriPrefix : strNewFmt("%s%s", strPtr(this->uriPrefix), strPtr(param.uri)); param.uri = param.uri == NULL ? this->uriPrefix : strNewFmt("%s%s", strZ(this->uriPrefix), strZ(param.uri));
// Create header list and add content length // Create header list and add content length
HttpHeader *requestHeader = param.header == NULL ? HttpHeader *requestHeader = param.header == NULL ?
@ -343,7 +343,7 @@ storageAzureListInternal(
if (strSize(path) == 1) if (strSize(path) == 1)
basePrefix = EMPTY_STR; basePrefix = EMPTY_STR;
else else
basePrefix = strNewFmt("%s/", strPtr(strSub(path, 1))); basePrefix = strNewFmt("%s/", strZ(strSub(path, 1)));
// Get the expression prefix when possible to limit initial results // Get the expression prefix when possible to limit initial results
const String *expressionPrefix = regExpPrefix(expression); const String *expressionPrefix = regExpPrefix(expression);
@ -358,7 +358,7 @@ storageAzureListInternal(
if (strEmpty(basePrefix)) if (strEmpty(basePrefix))
queryPrefix = expressionPrefix; queryPrefix = expressionPrefix;
else else
queryPrefix = strNewFmt("%s%s", strPtr(basePrefix), strPtr(expressionPrefix)); queryPrefix = strNewFmt("%s%s", strZ(basePrefix), strZ(expressionPrefix));
} }
// Loop as long as a continuation token returned // Loop as long as a continuation token returned
@ -469,7 +469,7 @@ storageAzureInfo(THIS_VOID, const String *file, StorageInfoLevel level, StorageI
if (result.level >= storageInfoLevelBasic && result.exists) if (result.level >= storageInfoLevelBasic && result.exists)
{ {
result.type = storageTypeFile; result.type = storageTypeFile;
result.size = cvtZToUInt64(strPtr(httpHeaderGet(httpResponseHeader(httpResponse), HTTP_HEADER_CONTENT_LENGTH_STR))); result.size = cvtZToUInt64(strZ(httpHeaderGet(httpResponseHeader(httpResponse), HTTP_HEADER_CONTENT_LENGTH_STR)));
result.timeModified = httpDateToTime(httpHeaderGet(httpResponseHeader(httpResponse), HTTP_HEADER_LAST_MODIFIED_STR)); result.timeModified = httpDateToTime(httpHeaderGet(httpResponseHeader(httpResponse), HTTP_HEADER_LAST_MODIFIED_STR));
} }
@ -517,7 +517,7 @@ storageAzureInfoListCallback(StorageAzure *this, void *callbackData, const Strin
{ {
ASSERT(xml != NULL); ASSERT(xml != NULL);
info.size = cvtZToUInt64(strPtr(xmlNodeContent(xmlNodeChild(xml, AZURE_XML_TAG_CONTENT_LENGTH_STR, true)))); info.size = cvtZToUInt64(strZ(xmlNodeContent(xmlNodeChild(xml, AZURE_XML_TAG_CONTENT_LENGTH_STR, true))));
info.timeModified = httpDateToTime(xmlNodeContent(xmlNodeChild(xml, AZURE_XML_TAG_LAST_MODIFIED_STR, true))); info.timeModified = httpDateToTime(xmlNodeContent(xmlNodeChild(xml, AZURE_XML_TAG_LAST_MODIFIED_STR, true)));
} }
} }
@ -623,7 +623,7 @@ storageAzurePathRemoveCallback(StorageAzure *this, void *callbackData, const Str
if (type == storageTypeFile) if (type == storageTypeFile)
{ {
StorageAzurePathRemoveData *data = (StorageAzurePathRemoveData *)callbackData; StorageAzurePathRemoveData *data = (StorageAzurePathRemoveData *)callbackData;
storageInterfaceRemoveP(this, strNewFmt("%s/%s", strEq(data->path, FSLASH_STR) ? "" : strPtr(data->path), strPtr(name))); storageInterfaceRemoveP(this, strNewFmt("%s/%s", strEq(data->path, FSLASH_STR) ? "" : strZ(data->path), strZ(name)));
} }
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
@ -728,9 +728,8 @@ storageAzureNew(
.container = strDup(container), .container = strDup(container),
.account = strDup(account), .account = strDup(account),
.blockSize = blockSize, .blockSize = blockSize,
.host = host == NULL ? strNewFmt("%s." AZURE_BLOB_HOST, strPtr(account)) : host, .host = host == NULL ? strNewFmt("%s." AZURE_BLOB_HOST, strZ(account)) : host,
.uriPrefix = host == NULL ? .uriPrefix = host == NULL ? strNewFmt("/%s", strZ(container)) : strNewFmt("/%s/%s", strZ(account), strZ(container)),
strNewFmt("/%s", strPtr(container)) : strNewFmt("/%s/%s", strPtr(account), strPtr(container)),
}; };
// Store shared key or parse sas query // Store shared key or parse sas query

View File

@ -295,7 +295,7 @@ storageRepoPathExpression(const String *expression, const String *path)
{ {
// Construct the base path // Construct the base path
if (storageHelper.stanza != NULL) if (storageHelper.stanza != NULL)
result = strNewFmt(STORAGE_PATH_ARCHIVE "/%s", strPtr(storageHelper.stanza)); result = strNewFmt(STORAGE_PATH_ARCHIVE "/%s", strZ(storageHelper.stanza));
else else
result = strNew(STORAGE_PATH_ARCHIVE); result = strNew(STORAGE_PATH_ARCHIVE);
@ -306,25 +306,25 @@ storageRepoPathExpression(const String *expression, const String *path)
String *file = strLstSize(pathSplit) == 2 ? strLstGet(pathSplit, 1) : NULL; String *file = strLstSize(pathSplit) == 2 ? strLstGet(pathSplit, 1) : NULL;
if (file != NULL && regExpMatch(storageHelper.walRegExp, file)) if (file != NULL && regExpMatch(storageHelper.walRegExp, file))
strCatFmt(result, "/%s/%s/%s", strPtr(strLstGet(pathSplit, 0)), strPtr(strSubN(file, 0, 16)), strPtr(file)); strCatFmt(result, "/%s/%s/%s", strZ(strLstGet(pathSplit, 0)), strZ(strSubN(file, 0, 16)), strZ(file));
else else
strCatFmt(result, "/%s", strPtr(path)); strCatFmt(result, "/%s", strZ(path));
} }
} }
else if (strEq(expression, STORAGE_REPO_BACKUP_STR)) else if (strEq(expression, STORAGE_REPO_BACKUP_STR))
{ {
// Construct the base path // Construct the base path
if (storageHelper.stanza != NULL) if (storageHelper.stanza != NULL)
result = strNewFmt(STORAGE_PATH_BACKUP "/%s", strPtr(storageHelper.stanza)); result = strNewFmt(STORAGE_PATH_BACKUP "/%s", strZ(storageHelper.stanza));
else else
result = strNew(STORAGE_PATH_BACKUP); result = strNew(STORAGE_PATH_BACKUP);
// Append subpath if provided // Append subpath if provided
if (path != NULL) if (path != NULL)
strCatFmt(result, "/%s", strPtr(path)); strCatFmt(result, "/%s", strZ(path));
} }
else else
THROW_FMT(AssertError, "invalid expression '%s'", strPtr(expression)); THROW_FMT(AssertError, "invalid expression '%s'", strZ(expression));
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -397,7 +397,7 @@ storageRepoGet(const String *type, bool write)
cfgOptionBool(cfgOptRepoS3VerifyTls), cfgOptionStrNull(cfgOptRepoS3CaFile), cfgOptionStrNull(cfgOptRepoS3CaPath)); cfgOptionBool(cfgOptRepoS3VerifyTls), cfgOptionStrNull(cfgOptRepoS3CaFile), cfgOptionStrNull(cfgOptRepoS3CaPath));
} }
else else
THROW_FMT(AssertError, "invalid storage type '%s'", strPtr(type)); THROW_FMT(AssertError, "invalid storage type '%s'", strZ(type));
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
@ -468,19 +468,19 @@ storageSpoolPathExpression(const String *expression, const String *path)
if (strEqZ(expression, STORAGE_SPOOL_ARCHIVE_IN)) if (strEqZ(expression, STORAGE_SPOOL_ARCHIVE_IN))
{ {
if (path == NULL) if (path == NULL)
result = strNewFmt(STORAGE_PATH_ARCHIVE "/%s/in", strPtr(storageHelper.stanza)); result = strNewFmt(STORAGE_PATH_ARCHIVE "/%s/in", strZ(storageHelper.stanza));
else else
result = strNewFmt(STORAGE_PATH_ARCHIVE "/%s/in/%s", strPtr(storageHelper.stanza), strPtr(path)); result = strNewFmt(STORAGE_PATH_ARCHIVE "/%s/in/%s", strZ(storageHelper.stanza), strZ(path));
} }
else if (strEqZ(expression, STORAGE_SPOOL_ARCHIVE_OUT)) else if (strEqZ(expression, STORAGE_SPOOL_ARCHIVE_OUT))
{ {
if (path == NULL) if (path == NULL)
result = strNewFmt(STORAGE_PATH_ARCHIVE "/%s/out", strPtr(storageHelper.stanza)); result = strNewFmt(STORAGE_PATH_ARCHIVE "/%s/out", strZ(storageHelper.stanza));
else else
result = strNewFmt(STORAGE_PATH_ARCHIVE "/%s/out/%s", strPtr(storageHelper.stanza), strPtr(path)); result = strNewFmt(STORAGE_PATH_ARCHIVE "/%s/out/%s", strZ(storageHelper.stanza), strZ(path));
} }
else else
THROW_FMT(AssertError, "invalid expression '%s'", strPtr(expression)); THROW_FMT(AssertError, "invalid expression '%s'", strZ(expression));
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }

View File

@ -47,7 +47,7 @@ Close the file handle
OBJECT_DEFINE_FREE_RESOURCE_BEGIN(STORAGE_READ_POSIX, LOG, logLevelTrace) OBJECT_DEFINE_FREE_RESOURCE_BEGIN(STORAGE_READ_POSIX, LOG, logLevelTrace)
{ {
if (this->handle != -1) if (this->handle != -1)
THROW_ON_SYS_ERROR_FMT(close(this->handle) == -1, FileCloseError, STORAGE_ERROR_READ_CLOSE, strPtr(this->interface.name)); THROW_ON_SYS_ERROR_FMT(close(this->handle) == -1, FileCloseError, STORAGE_ERROR_READ_CLOSE, strZ(this->interface.name));
} }
OBJECT_DEFINE_FREE_RESOURCE_END(LOG); OBJECT_DEFINE_FREE_RESOURCE_END(LOG);
@ -69,7 +69,7 @@ storageReadPosixOpen(THIS_VOID)
bool result = false; bool result = false;
// Open the file // Open the file
this->handle = open(strPtr(this->interface.name), O_RDONLY, 0); this->handle = open(strZ(this->interface.name), O_RDONLY, 0);
// Handle errors // Handle errors
if (this->handle == -1) if (this->handle == -1)
@ -77,10 +77,10 @@ storageReadPosixOpen(THIS_VOID)
if (errno == ENOENT) // {vm_covered} if (errno == ENOENT) // {vm_covered}
{ {
if (!this->interface.ignoreMissing) if (!this->interface.ignoreMissing)
THROW_FMT(FileMissingError, STORAGE_ERROR_READ_MISSING, strPtr(this->interface.name)); THROW_FMT(FileMissingError, STORAGE_ERROR_READ_MISSING, strZ(this->interface.name));
} }
else else
THROW_SYS_ERROR_FMT(FileOpenError, STORAGE_ERROR_READ_OPEN, strPtr(this->interface.name)); // {vm_covered} THROW_SYS_ERROR_FMT(FileOpenError, STORAGE_ERROR_READ_OPEN, strZ(this->interface.name)); // {vm_covered}
} }
// On success set free callback to ensure file handle is freed // On success set free callback to ensure file handle is freed
if (this->handle != -1) if (this->handle != -1)
@ -125,7 +125,7 @@ storageReadPosix(THIS_VOID, Buffer *buffer, bool block)
// Error occurred during read // Error occurred during read
if (actualBytes == -1) if (actualBytes == -1)
THROW_SYS_ERROR_FMT(FileReadError, "unable to read '%s'", strPtr(this->interface.name)); THROW_SYS_ERROR_FMT(FileReadError, "unable to read '%s'", strZ(this->interface.name));
// Update amount of buffer used // Update amount of buffer used
bufUsedInc(buffer, (size_t)actualBytes); bufUsedInc(buffer, (size_t)actualBytes);

View File

@ -63,10 +63,10 @@ storagePosixInfo(THIS_VOID, const String *file, StorageInfoLevel level, StorageI
// Stat the file to check if it exists // Stat the file to check if it exists
struct stat statFile; struct stat statFile;
if ((param.followLink ? stat(strPtr(file), &statFile) : lstat(strPtr(file), &statFile)) == -1) if ((param.followLink ? stat(strZ(file), &statFile) : lstat(strZ(file), &statFile)) == -1)
{ {
if (errno != ENOENT) // {vm_covered} if (errno != ENOENT) // {vm_covered}
THROW_SYS_ERROR_FMT(FileOpenError, STORAGE_ERROR_INFO, strPtr(file)); // {vm_covered} THROW_SYS_ERROR_FMT(FileOpenError, STORAGE_ERROR_INFO, strZ(file)); // {vm_covered}
} }
// On success the file exists // On success the file exists
else else
@ -106,8 +106,8 @@ storagePosixInfo(THIS_VOID, const String *file, StorageInfoLevel level, StorageI
ssize_t linkDestinationSize = 0; ssize_t linkDestinationSize = 0;
THROW_ON_SYS_ERROR_FMT( THROW_ON_SYS_ERROR_FMT(
(linkDestinationSize = readlink(strPtr(file), linkDestination, sizeof(linkDestination) - 1)) == -1, (linkDestinationSize = readlink(strZ(file), linkDestination, sizeof(linkDestination) - 1)) == -1,
FileReadError, "unable to get destination for link '%s'", strPtr(file)); FileReadError, "unable to get destination for link '%s'", strZ(file));
result.linkDestination = strNewN(linkDestination, (size_t)linkDestinationSize); result.linkDestination = strNewN(linkDestination, (size_t)linkDestinationSize);
} }
@ -141,7 +141,7 @@ storagePosixInfoListEntry(
ASSERT(callback != NULL); ASSERT(callback != NULL);
StorageInfo storageInfo = storageInterfaceInfoP( StorageInfo storageInfo = storageInterfaceInfoP(
this, strEq(name, DOT_STR) ? strDup(path) : strNewFmt("%s/%s", strPtr(path), strPtr(name)), level); this, strEq(name, DOT_STR) ? strDup(path) : strNewFmt("%s/%s", strZ(path), strZ(name)), level);
if (storageInfo.exists) if (storageInfo.exists)
{ {
@ -175,13 +175,13 @@ storagePosixInfoList(
bool result = false; bool result = false;
// Open the directory for read // Open the directory for read
DIR *dir = opendir(strPtr(path)); DIR *dir = opendir(strZ(path));
// If the directory could not be opened process errors and report missing directories // If the directory could not be opened process errors and report missing directories
if (dir == NULL) if (dir == NULL)
{ {
if (errno != ENOENT) // {vm_covered} if (errno != ENOENT) // {vm_covered}
THROW_SYS_ERROR_FMT(PathOpenError, STORAGE_ERROR_LIST_INFO, strPtr(path)); // {vm_covered} THROW_SYS_ERROR_FMT(PathOpenError, STORAGE_ERROR_LIST_INFO, strZ(path)); // {vm_covered}
} }
else else
{ {
@ -258,19 +258,19 @@ storagePosixMove(THIS_VOID, StorageRead *source, StorageWrite *destination, Stor
const String *destinationPath = strPath(destinationFile); const String *destinationPath = strPath(destinationFile);
// Attempt to move the file // Attempt to move the file
if (rename(strPtr(sourceFile), strPtr(destinationFile)) == -1) if (rename(strZ(sourceFile), strZ(destinationFile)) == -1)
{ {
// Determine which file/path is missing // Determine which file/path is missing
if (errno == ENOENT) if (errno == ENOENT)
{ {
// Check if the source is missing. Rename does not follow links so there is no need to set followLink. // Check if the source is missing. Rename does not follow links so there is no need to set followLink.
if (!storageInterfaceInfoP(this, sourceFile, storageInfoLevelExists).exists) if (!storageInterfaceInfoP(this, sourceFile, storageInfoLevelExists).exists)
THROW_SYS_ERROR_FMT(FileMissingError, "unable to move missing source '%s'", strPtr(sourceFile)); THROW_SYS_ERROR_FMT(FileMissingError, "unable to move missing source '%s'", strZ(sourceFile));
if (!storageWriteCreatePath(destination)) if (!storageWriteCreatePath(destination))
{ {
THROW_SYS_ERROR_FMT( THROW_SYS_ERROR_FMT(
PathMissingError, "unable to move '%s' to missing path '%s'", strPtr(sourceFile), strPtr(destinationPath)); PathMissingError, "unable to move '%s' to missing path '%s'", strZ(sourceFile), strZ(destinationPath));
} }
storageInterfacePathCreateP(this, destinationPath, false, false, storageWriteModePath(destination)); storageInterfacePathCreateP(this, destinationPath, false, false, storageWriteModePath(destination));
@ -284,7 +284,7 @@ storagePosixMove(THIS_VOID, StorageRead *source, StorageWrite *destination, Stor
else else
{ {
THROW_SYS_ERROR_FMT( // {vm_covered} THROW_SYS_ERROR_FMT( // {vm_covered}
FileMoveError, "unable to move '%s' to '%s'", strPtr(sourceFile), strPtr(destinationFile)); // {vm_covered} FileMoveError, "unable to move '%s' to '%s'", strZ(sourceFile), strZ(destinationFile)); // {vm_covered}
} }
} }
// Sync paths on success // Sync paths on success
@ -374,7 +374,7 @@ storagePosixPathCreate(
ASSERT(path != NULL); ASSERT(path != NULL);
// Attempt to create the directory // Attempt to create the directory
if (mkdir(strPtr(path), mode) == -1) if (mkdir(strZ(path), mode) == -1)
{ {
// If the parent path does not exist then create it if allowed // If the parent path does not exist then create it if allowed
if (errno == ENOENT && !noParentCreate) if (errno == ENOENT && !noParentCreate)
@ -384,7 +384,7 @@ storagePosixPathCreate(
} }
// Ignore path exists if allowed // Ignore path exists if allowed
else if (errno != EEXIST || errorOnExists) else if (errno != EEXIST || errorOnExists)
THROW_SYS_ERROR_FMT(PathCreateError, "unable to create path '%s'", strPtr(path)); THROW_SYS_ERROR_FMT(PathCreateError, "unable to create path '%s'", strZ(path));
} }
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
@ -411,10 +411,10 @@ storagePosixPathRemoveCallback(void *callbackData, const StorageInfo *info)
if (!strEqZ(info->name, ".")) if (!strEqZ(info->name, "."))
{ {
StoragePosixPathRemoveData *data = callbackData; StoragePosixPathRemoveData *data = callbackData;
String *file = strNewFmt("%s/%s", strPtr(data->path), strPtr(info->name)); String *file = strNewFmt("%s/%s", strZ(data->path), strZ(info->name));
// Rather than stat the file to discover what type it is, just try to unlink it and see what happens // Rather than stat the file to discover what type it is, just try to unlink it and see what happens
if (unlink(strPtr(file)) == -1) // {vm_covered} if (unlink(strZ(file)) == -1) // {vm_covered}
{ {
// These errors indicate that the entry is actually a path so we'll try to delete it that way // These errors indicate that the entry is actually a path so we'll try to delete it that way
if (errno == EPERM || errno == EISDIR) // {uncovered_branch - no EPERM on tested systems} if (errno == EPERM || errno == EISDIR) // {uncovered_branch - no EPERM on tested systems}
@ -423,7 +423,7 @@ storagePosixPathRemoveCallback(void *callbackData, const StorageInfo *info)
} }
// Else error // Else error
else else
THROW_SYS_ERROR_FMT(PathRemoveError, STORAGE_ERROR_PATH_REMOVE_FILE, strPtr(file)); // {vm_covered} THROW_SYS_ERROR_FMT(PathRemoveError, STORAGE_ERROR_PATH_REMOVE_FILE, strZ(file)); // {vm_covered}
} }
} }
@ -463,10 +463,10 @@ storagePosixPathRemove(THIS_VOID, const String *path, bool recurse, StorageInter
} }
// Delete the path // Delete the path
if (rmdir(strPtr(path)) == -1) if (rmdir(strZ(path)) == -1)
{ {
if (errno != ENOENT) // {vm_covered} if (errno != ENOENT) // {vm_covered}
THROW_SYS_ERROR_FMT(PathRemoveError, STORAGE_ERROR_PATH_REMOVE, strPtr(path)); // {vm_covered} THROW_SYS_ERROR_FMT(PathRemoveError, STORAGE_ERROR_PATH_REMOVE, strZ(path)); // {vm_covered}
// Path does not exist // Path does not exist
result = false; result = false;
@ -493,15 +493,15 @@ storagePosixPathSync(THIS_VOID, const String *path, StorageInterfacePathSyncPara
ASSERT(path != NULL); ASSERT(path != NULL);
// Open directory and handle errors // Open directory and handle errors
int handle = open(strPtr(path), O_RDONLY, 0); int handle = open(strZ(path), O_RDONLY, 0);
// Handle errors // Handle errors
if (handle == -1) if (handle == -1)
{ {
if (errno == ENOENT) // {vm_covered} if (errno == ENOENT) // {vm_covered}
THROW_FMT(PathMissingError, STORAGE_ERROR_PATH_SYNC_MISSING, strPtr(path)); THROW_FMT(PathMissingError, STORAGE_ERROR_PATH_SYNC_MISSING, strZ(path));
else else
THROW_SYS_ERROR_FMT(PathOpenError, STORAGE_ERROR_PATH_SYNC_OPEN, strPtr(path)); // {vm_covered} THROW_SYS_ERROR_FMT(PathOpenError, STORAGE_ERROR_PATH_SYNC_OPEN, strZ(path)); // {vm_covered}
} }
else else
{ {
@ -513,10 +513,10 @@ storagePosixPathSync(THIS_VOID, const String *path, StorageInterfacePathSyncPara
// Close the handle to free resources but don't check for failure // Close the handle to free resources but don't check for failure
close(handle); close(handle);
THROW_SYS_ERROR_CODE_FMT(errNo, PathSyncError, STORAGE_ERROR_PATH_SYNC, strPtr(path)); THROW_SYS_ERROR_CODE_FMT(errNo, PathSyncError, STORAGE_ERROR_PATH_SYNC, strZ(path));
} }
THROW_ON_SYS_ERROR_FMT(close(handle) == -1, PathCloseError, STORAGE_ERROR_PATH_SYNC_CLOSE, strPtr(path)); THROW_ON_SYS_ERROR_FMT(close(handle) == -1, PathCloseError, STORAGE_ERROR_PATH_SYNC_CLOSE, strZ(path));
} }
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
@ -538,10 +538,10 @@ storagePosixRemove(THIS_VOID, const String *file, StorageInterfaceRemoveParam pa
ASSERT(file != NULL); ASSERT(file != NULL);
// Attempt to unlink the file // Attempt to unlink the file
if (unlink(strPtr(file)) == -1) if (unlink(strZ(file)) == -1)
{ {
if (param.errorOnMissing || errno != ENOENT) // {vm_covered} if (param.errorOnMissing || errno != ENOENT) // {vm_covered}
THROW_SYS_ERROR_FMT(FileRemoveError, "unable to remove '%s'", strPtr(file)); // {vm_covered} THROW_SYS_ERROR_FMT(FileRemoveError, "unable to remove '%s'", strZ(file)); // {vm_covered}
} }
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();

View File

@ -56,7 +56,7 @@ Close file handle
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
OBJECT_DEFINE_FREE_RESOURCE_BEGIN(STORAGE_WRITE_POSIX, LOG, logLevelTrace) OBJECT_DEFINE_FREE_RESOURCE_BEGIN(STORAGE_WRITE_POSIX, LOG, logLevelTrace)
{ {
THROW_ON_SYS_ERROR_FMT(close(this->handle) == -1, FileCloseError, STORAGE_ERROR_WRITE_CLOSE, strPtr(this->nameTmp)); THROW_ON_SYS_ERROR_FMT(close(this->handle) == -1, FileCloseError, STORAGE_ERROR_WRITE_CLOSE, strZ(this->nameTmp));
} }
OBJECT_DEFINE_FREE_RESOURCE_END(LOG); OBJECT_DEFINE_FREE_RESOURCE_END(LOG);
@ -76,7 +76,7 @@ storageWritePosixOpen(THIS_VOID)
ASSERT(this->handle == -1); ASSERT(this->handle == -1);
// Open the file // Open the file
this->handle = open(strPtr(this->nameTmp), FILE_OPEN_FLAGS, this->interface.modeFile); this->handle = open(strZ(this->nameTmp), FILE_OPEN_FLAGS, this->interface.modeFile);
// Attempt to create the path if it is missing // Attempt to create the path if it is missing
if (this->handle == -1 && errno == ENOENT && this->interface.createPath) // {vm_covered} if (this->handle == -1 && errno == ENOENT && this->interface.createPath) // {vm_covered}
@ -85,16 +85,16 @@ storageWritePosixOpen(THIS_VOID)
storageInterfacePathCreateP(this->storage, this->path, false, false, this->interface.modePath); storageInterfacePathCreateP(this->storage, this->path, false, false, this->interface.modePath);
// Open file again // Open file again
this->handle = open(strPtr(this->nameTmp), FILE_OPEN_FLAGS, this->interface.modeFile); this->handle = open(strZ(this->nameTmp), FILE_OPEN_FLAGS, this->interface.modeFile);
} }
// Handle errors // Handle errors
if (this->handle == -1) if (this->handle == -1)
{ {
if (errno == ENOENT) // {vm_covered} if (errno == ENOENT) // {vm_covered}
THROW_FMT(FileMissingError, STORAGE_ERROR_WRITE_MISSING, strPtr(this->interface.name)); THROW_FMT(FileMissingError, STORAGE_ERROR_WRITE_MISSING, strZ(this->interface.name));
else else
THROW_SYS_ERROR_FMT(FileOpenError, STORAGE_ERROR_WRITE_OPEN, strPtr(this->interface.name)); // {vm_covered} THROW_SYS_ERROR_FMT(FileOpenError, STORAGE_ERROR_WRITE_OPEN, strZ(this->interface.name)); // {vm_covered}
} }
// Set free callback to ensure file handle is freed // Set free callback to ensure file handle is freed
@ -114,8 +114,8 @@ storageWritePosixOpen(THIS_VOID)
updateGroupId = (gid_t)-1; updateGroupId = (gid_t)-1;
THROW_ON_SYS_ERROR_FMT( THROW_ON_SYS_ERROR_FMT(
chown(strPtr(this->nameTmp), updateUserId, updateGroupId) == -1, chown(strZ(this->nameTmp), updateUserId, updateGroupId) == -1, FileOwnerError, "unable to set ownership for '%s'",
FileOwnerError, "unable to set ownership for '%s'", strPtr(this->nameTmp)); strZ(this->nameTmp));
} }
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
@ -140,7 +140,7 @@ storageWritePosix(THIS_VOID, const Buffer *buffer)
// Write the data // Write the data
if (write(this->handle, bufPtrConst(buffer), bufUsed(buffer)) != (ssize_t)bufUsed(buffer)) if (write(this->handle, bufPtrConst(buffer), bufUsed(buffer)) != (ssize_t)bufUsed(buffer))
THROW_SYS_ERROR_FMT(FileWriteError, "unable to write '%s'", strPtr(this->nameTmp)); THROW_SYS_ERROR_FMT(FileWriteError, "unable to write '%s'", strZ(this->nameTmp));
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
@ -164,11 +164,11 @@ storageWritePosixClose(THIS_VOID)
{ {
// Sync the file // Sync the file
if (this->interface.syncFile) if (this->interface.syncFile)
THROW_ON_SYS_ERROR_FMT(fsync(this->handle) == -1, FileSyncError, STORAGE_ERROR_WRITE_SYNC, strPtr(this->nameTmp)); THROW_ON_SYS_ERROR_FMT(fsync(this->handle) == -1, FileSyncError, STORAGE_ERROR_WRITE_SYNC, strZ(this->nameTmp));
// Close the file // Close the file
memContextCallbackClear(this->memContext); memContextCallbackClear(this->memContext);
THROW_ON_SYS_ERROR_FMT(close(this->handle) == -1, FileCloseError, STORAGE_ERROR_WRITE_CLOSE, strPtr(this->nameTmp)); THROW_ON_SYS_ERROR_FMT(close(this->handle) == -1, FileCloseError, STORAGE_ERROR_WRITE_CLOSE, strZ(this->nameTmp));
this->handle = -1; this->handle = -1;
// Update modified time // Update modified time
@ -176,19 +176,16 @@ storageWritePosixClose(THIS_VOID)
{ {
THROW_ON_SYS_ERROR_FMT( THROW_ON_SYS_ERROR_FMT(
utime( utime(
strPtr(this->nameTmp), strZ(this->nameTmp),
&((struct utimbuf){.actime = this->interface.timeModified, .modtime = this->interface.timeModified})) == -1, &((struct utimbuf){.actime = this->interface.timeModified, .modtime = this->interface.timeModified})) == -1,
FileInfoError, "unable to set time for '%s'", strPtr(this->nameTmp)); FileInfoError, "unable to set time for '%s'", strZ(this->nameTmp));
} }
// Rename from temp file // Rename from temp file
if (this->interface.atomic) if (this->interface.atomic)
{ {
if (rename(strPtr(this->nameTmp), strPtr(this->interface.name)) == -1) if (rename(strZ(this->nameTmp), strZ(this->interface.name)) == -1)
{ THROW_SYS_ERROR_FMT(FileMoveError, "unable to move '%s' to '%s'", strZ(this->nameTmp), strZ(this->interface.name));
THROW_SYS_ERROR_FMT(
FileMoveError, "unable to move '%s' to '%s'", strPtr(this->nameTmp), strPtr(this->interface.name));
}
} }
// Sync the path // Sync the path
@ -279,7 +276,7 @@ storageWritePosixNew(
}; };
// Create temp file name // Create temp file name
driver->nameTmp = atomic ? strNewFmt("%s." STORAGE_FILE_TEMP_EXT, strPtr(name)) : driver->interface.name; driver->nameTmp = atomic ? strNewFmt("%s." STORAGE_FILE_TEMP_EXT, strZ(name)) : driver->interface.name;
this = storageWriteNew(driver, &driver->interface); this = storageWriteNew(driver, &driver->interface);
} }

View File

@ -128,6 +128,6 @@ String *
storageReadToLog(const StorageRead *this) storageReadToLog(const StorageRead *this)
{ {
return strNewFmt( return strNewFmt(
"{type: %s, name: %s, ignoreMissing: %s}", strPtr(this->interface->type), strPtr(strToLog(this->interface->name)), "{type: %s, name: %s, ignoreMissing: %s}", strZ(this->interface->type), strZ(strToLog(this->interface->name)),
cvtBoolToConstZ(this->interface->ignoreMissing)); cvtBoolToConstZ(this->interface->ignoreMissing));
} }

View File

@ -83,7 +83,7 @@ storageRemoteFilterGroup(IoFilterGroup *filterGroup, const Variant *filterList)
else if (strEq(filterKey, SIZE_FILTER_TYPE_STR)) else if (strEq(filterKey, SIZE_FILTER_TYPE_STR))
ioFilterGroupAdd(filterGroup, ioSizeNew()); ioFilterGroupAdd(filterGroup, ioSizeNew());
else else
THROW_FMT(AssertError, "unable to add filter '%s'", strPtr(filterKey)); THROW_FMT(AssertError, "unable to add filter '%s'", strZ(filterKey));
} }
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
@ -400,7 +400,7 @@ storageRemoteProtocolBlockSize(const String *message)
// Validate the header block size message // Validate the header block size message
if (!regExpMatch(storageRemoteProtocolLocal.blockRegExp, message)) if (!regExpMatch(storageRemoteProtocolLocal.blockRegExp, message))
THROW_FMT(ProtocolError, "'%s' is not a valid block size message", strPtr(message)); THROW_FMT(ProtocolError, "'%s' is not a valid block size message", strZ(message));
FUNCTION_LOG_RETURN(SSIZE, (ssize_t)cvtZToInt(strPtr(message) + sizeof(PROTOCOL_BLOCK_HEADER) - 1)); FUNCTION_LOG_RETURN(SSIZE, (ssize_t)cvtZToInt(strZ(message) + sizeof(PROTOCOL_BLOCK_HEADER) - 1));
} }

View File

@ -65,7 +65,7 @@ storageRemoteInfoParse(ProtocolClient *client, StorageInfo *info)
FUNCTION_TEST_PARAM(STORAGE_INFO, info); FUNCTION_TEST_PARAM(STORAGE_INFO, info);
FUNCTION_TEST_END(); FUNCTION_TEST_END();
info->type = storageRemoteInfoParseType(strPtr(protocolClientReadLine(client))[0]); info->type = storageRemoteInfoParseType(strZ(protocolClientReadLine(client))[0]);
info->timeModified = (time_t)jsonToUInt64(protocolClientReadLine(client)); info->timeModified = (time_t)jsonToUInt64(protocolClientReadLine(client));
if (info->type == storageTypeFile) if (info->type == storageTypeFile)

View File

@ -69,7 +69,7 @@ storageReadS3Open(THIS_VOID)
} }
// Else error unless ignore missing // Else error unless ignore missing
else if (!this->interface.ignoreMissing) else if (!this->interface.ignoreMissing)
THROW_FMT(FileMissingError, "unable to open '%s': No such file or directory", strPtr(this->interface.name)); THROW_FMT(FileMissingError, "unable to open '%s': No such file or directory", strZ(this->interface.name));
FUNCTION_LOG_RETURN(BOOL, result); FUNCTION_LOG_RETURN(BOOL, result);
} }

View File

@ -168,7 +168,7 @@ storageS3Auth(
String *signedHeaders = NULL; String *signedHeaders = NULL;
String *canonicalRequest = strNewFmt( String *canonicalRequest = strNewFmt(
"%s\n%s\n%s\n", strPtr(verb), strPtr(uri), query == NULL ? "" : strPtr(httpQueryRenderP(query))); "%s\n%s\n%s\n", strZ(verb), strZ(uri), query == NULL ? "" : strZ(httpQueryRenderP(query)));
for (unsigned int headerIdx = 0; headerIdx < strLstSize(headerList); headerIdx++) for (unsigned int headerIdx = 0; headerIdx < strLstSize(headerList); headerIdx++)
{ {
@ -179,20 +179,20 @@ storageS3Auth(
if (strEq(headerKeyLower, HTTP_HEADER_AUTHORIZATION_STR)) if (strEq(headerKeyLower, HTTP_HEADER_AUTHORIZATION_STR))
continue; continue;
strCatFmt(canonicalRequest, "%s:%s\n", strPtr(headerKeyLower), strPtr(httpHeaderGet(httpHeader, headerKey))); strCatFmt(canonicalRequest, "%s:%s\n", strZ(headerKeyLower), strZ(httpHeaderGet(httpHeader, headerKey)));
if (signedHeaders == NULL) if (signedHeaders == NULL)
signedHeaders = strDup(headerKeyLower); signedHeaders = strDup(headerKeyLower);
else else
strCatFmt(signedHeaders, ";%s", strPtr(headerKeyLower)); strCatFmt(signedHeaders, ";%s", strZ(headerKeyLower));
} }
strCatFmt(canonicalRequest, "\n%s\n%s", strPtr(signedHeaders), strPtr(payloadHash)); strCatFmt(canonicalRequest, "\n%s\n%s", strZ(signedHeaders), strZ(payloadHash));
// Generate string to sign // Generate string to sign
const String *stringToSign = strNewFmt( const String *stringToSign = strNewFmt(
AWS4_HMAC_SHA256 "\n%s\n%s/%s/" S3 "/" AWS4_REQUEST "\n%s", strPtr(dateTime), strPtr(date), strPtr(this->region), AWS4_HMAC_SHA256 "\n%s\n%s/%s/" S3 "/" AWS4_REQUEST "\n%s", strZ(dateTime), strZ(date), strZ(this->region),
strPtr(bufHex(cryptoHashOne(HASH_TYPE_SHA256_STR, BUFSTR(canonicalRequest))))); strZ(bufHex(cryptoHashOne(HASH_TYPE_SHA256_STR, BUFSTR(canonicalRequest)))));
// Generate signing key. This key only needs to be regenerated every seven days but we'll do it once a day to keep the // Generate signing key. This key only needs to be regenerated every seven days but we'll do it once a day to keep the
// logic simple. It's a relatively expensive operation so we'd rather not do it for every request. // logic simple. It's a relatively expensive operation so we'd rather not do it for every request.
@ -200,7 +200,7 @@ storageS3Auth(
if (!strEq(date, this->signingKeyDate)) if (!strEq(date, this->signingKeyDate))
{ {
const Buffer *dateKey = cryptoHmacOne( const Buffer *dateKey = cryptoHmacOne(
HASH_TYPE_SHA256_STR, BUFSTR(strNewFmt(AWS4 "%s", strPtr(this->secretAccessKey))), BUFSTR(date)); HASH_TYPE_SHA256_STR, BUFSTR(strNewFmt(AWS4 "%s", strZ(this->secretAccessKey))), BUFSTR(date));
const Buffer *regionKey = cryptoHmacOne(HASH_TYPE_SHA256_STR, dateKey, BUFSTR(this->region)); const Buffer *regionKey = cryptoHmacOne(HASH_TYPE_SHA256_STR, dateKey, BUFSTR(this->region));
const Buffer *serviceKey = cryptoHmacOne(HASH_TYPE_SHA256_STR, regionKey, S3_BUF); const Buffer *serviceKey = cryptoHmacOne(HASH_TYPE_SHA256_STR, regionKey, S3_BUF);
@ -216,8 +216,8 @@ storageS3Auth(
// Generate authorization header // Generate authorization header
const String *authorization = strNewFmt( const String *authorization = strNewFmt(
AWS4_HMAC_SHA256 " Credential=%s/%s/%s/" S3 "/" AWS4_REQUEST ",SignedHeaders=%s,Signature=%s", AWS4_HMAC_SHA256 " Credential=%s/%s/%s/" S3 "/" AWS4_REQUEST ",SignedHeaders=%s,Signature=%s",
strPtr(this->accessKey), strPtr(date), strPtr(this->region), strPtr(signedHeaders), strZ(this->accessKey), strZ(date), strZ(this->region), strZ(signedHeaders),
strPtr(bufHex(cryptoHmacOne(HASH_TYPE_SHA256_STR, this->signingKey, BUFSTR(stringToSign))))); strZ(bufHex(cryptoHmacOne(HASH_TYPE_SHA256_STR, this->signingKey, BUFSTR(stringToSign)))));
httpHeaderPut(httpHeader, HTTP_HEADER_AUTHORIZATION_STR, authorization); httpHeaderPut(httpHeader, HTTP_HEADER_AUTHORIZATION_STR, authorization);
} }
@ -265,7 +265,7 @@ storageS3RequestAsync(StorageS3 *this, const String *verb, const String *uri, St
// When using path-style URIs the bucket name needs to be prepended // When using path-style URIs the bucket name needs to be prepended
if (this->uriStyle == storageS3UriStylePath) if (this->uriStyle == storageS3UriStylePath)
uri = strNewFmt("/%s%s", strPtr(this->bucket), strPtr(uri)); uri = strNewFmt("/%s%s", strZ(this->bucket), strZ(uri));
// Generate authorization header // Generate authorization header
storageS3Auth( storageS3Auth(
@ -367,7 +367,7 @@ storageS3ListInternal(
if (strSize(path) == 1) if (strSize(path) == 1)
basePrefix = EMPTY_STR; basePrefix = EMPTY_STR;
else else
basePrefix = strNewFmt("%s/", strPtr(strSub(path, 1))); basePrefix = strNewFmt("%s/", strZ(strSub(path, 1)));
// Get the expression prefix when possible to limit initial results // Get the expression prefix when possible to limit initial results
const String *expressionPrefix = regExpPrefix(expression); const String *expressionPrefix = regExpPrefix(expression);
@ -382,7 +382,7 @@ storageS3ListInternal(
if (strEmpty(basePrefix)) if (strEmpty(basePrefix))
queryPrefix = expressionPrefix; queryPrefix = expressionPrefix;
else else
queryPrefix = strNewFmt("%s%s", strPtr(basePrefix), strPtr(expressionPrefix)); queryPrefix = strNewFmt("%s%s", strZ(basePrefix), strZ(expressionPrefix));
} }
// Loop as long as a continuation token returned // Loop as long as a continuation token returned
@ -490,7 +490,7 @@ storageS3Info(THIS_VOID, const String *file, StorageInfoLevel level, StorageInte
const HttpHeader *httpHeader = httpResponseHeader(httpResponse); const HttpHeader *httpHeader = httpResponseHeader(httpResponse);
result.type = storageTypeFile; result.type = storageTypeFile;
result.size = cvtZToUInt64(strPtr(httpHeaderGet(httpHeader, HTTP_HEADER_CONTENT_LENGTH_STR))); result.size = cvtZToUInt64(strZ(httpHeaderGet(httpHeader, HTTP_HEADER_CONTENT_LENGTH_STR)));
result.timeModified = httpDateToTime(httpHeaderGet(httpHeader, HTTP_HEADER_LAST_MODIFIED_STR)); result.timeModified = httpDateToTime(httpHeaderGet(httpHeader, HTTP_HEADER_LAST_MODIFIED_STR));
} }
@ -516,9 +516,9 @@ storageS3CvtTime(const String *time)
FUNCTION_TEST_RETURN( FUNCTION_TEST_RETURN(
epochFromParts( epochFromParts(
cvtZToInt(strPtr(strSubN(time, 0, 4))), cvtZToInt(strPtr(strSubN(time, 5, 2))), cvtZToInt(strZ(strSubN(time, 0, 4))), cvtZToInt(strZ(strSubN(time, 5, 2))),
cvtZToInt(strPtr(strSubN(time, 8, 2))), cvtZToInt(strPtr(strSubN(time, 11, 2))), cvtZToInt(strZ(strSubN(time, 8, 2))), cvtZToInt(strZ(strSubN(time, 11, 2))),
cvtZToInt(strPtr(strSubN(time, 14, 2))), cvtZToInt(strPtr(strSubN(time, 17, 2))), 0)); cvtZToInt(strZ(strSubN(time, 14, 2))), cvtZToInt(strZ(strSubN(time, 17, 2))), 0));
} }
static void static void
@ -554,7 +554,7 @@ storageS3InfoListCallback(StorageS3 *this, void *callbackData, const String *nam
{ {
ASSERT(xml != NULL); ASSERT(xml != NULL);
info.size = cvtZToUInt64(strPtr(xmlNodeContent(xmlNodeChild(xml, S3_XML_TAG_SIZE_STR, true)))); info.size = cvtZToUInt64(strZ(xmlNodeContent(xmlNodeChild(xml, S3_XML_TAG_SIZE_STR, true))));
info.timeModified = storageS3CvtTime(xmlNodeContent(xmlNodeChild(xml, S3_XML_TAG_LAST_MODIFIED_STR, true))); info.timeModified = storageS3CvtTime(xmlNodeContent(xmlNodeChild(xml, S3_XML_TAG_LAST_MODIFIED_STR, true)));
} }
} }
@ -670,9 +670,9 @@ storageS3PathRemoveInternal(StorageS3 *this, XmlDocument *request)
THROW_FMT( THROW_FMT(
FileRemoveError, STORAGE_ERROR_PATH_REMOVE_FILE ": [%s] %s", FileRemoveError, STORAGE_ERROR_PATH_REMOVE_FILE ": [%s] %s",
strPtr(xmlNodeContent(xmlNodeChild(error, S3_XML_TAG_KEY_STR, true))), strZ(xmlNodeContent(xmlNodeChild(error, S3_XML_TAG_KEY_STR, true))),
strPtr(xmlNodeContent(xmlNodeChild(error, S3_XML_TAG_CODE_STR, true))), strZ(xmlNodeContent(xmlNodeChild(error, S3_XML_TAG_CODE_STR, true))),
strPtr(xmlNodeContent(xmlNodeChild(error, S3_XML_TAG_MESSAGE_STR, true)))); strZ(xmlNodeContent(xmlNodeChild(error, S3_XML_TAG_MESSAGE_STR, true))));
} }
} }
@ -845,7 +845,7 @@ storageS3New(
.deleteMax = deleteMax, .deleteMax = deleteMax,
.uriStyle = uriStyle, .uriStyle = uriStyle,
.bucketEndpoint = uriStyle == storageS3UriStyleHost ? .bucketEndpoint = uriStyle == storageS3UriStyleHost ?
strNewFmt("%s.%s", strPtr(bucket), strPtr(endPoint)) : strDup(endPoint), strNewFmt("%s.%s", strZ(bucket), strZ(endPoint)) : strDup(endPoint),
.port = port, .port = port,
// Force the signing key to be generated on the first run // Force the signing key to be generated on the first run

View File

@ -53,7 +53,7 @@ storageNew(
FUNCTION_LOG_END(); FUNCTION_LOG_END();
ASSERT(type != NULL); ASSERT(type != NULL);
ASSERT(strSize(path) >= 1 && strPtr(path)[0] == '/'); ASSERT(strSize(path) >= 1 && strZ(path)[0] == '/');
ASSERT(driver != NULL); ASSERT(driver != NULL);
ASSERT(interface.info != NULL); ASSERT(interface.info != NULL);
ASSERT(interface.infoList != NULL); ASSERT(interface.infoList != NULL);
@ -197,10 +197,7 @@ storageGet(StorageRead *file, StorageGetParam param)
// If an exact read make sure the size is as expected // If an exact read make sure the size is as expected
if (bufUsed(result) != param.exactSize) if (bufUsed(result) != param.exactSize)
{ THROW_FMT(FileReadError, "unable to read %zu byte(s) from '%s'", param.exactSize, strZ(storageReadName(file)));
THROW_FMT(
FileReadError, "unable to read %zu byte(s) from '%s'", param.exactSize, strPtr(storageReadName(file)));
}
} }
// Else read entire file // Else read entire file
else else
@ -263,7 +260,7 @@ storageInfo(const Storage *this, const String *fileExp, StorageInfoParam param)
// Error if the file missing and not ignoring // Error if the file missing and not ignoring
if (!result.exists && !param.ignoreMissing) if (!result.exists && !param.ignoreMissing)
THROW_SYS_ERROR_FMT(FileOpenError, STORAGE_ERROR_INFO_MISSING, strPtr(file)); THROW_SYS_ERROR_FMT(FileOpenError, STORAGE_ERROR_INFO_MISSING, strZ(file));
// Dup the strings into the prior context // Dup the strings into the prior context
MEM_CONTEXT_PRIOR_BEGIN() MEM_CONTEXT_PRIOR_BEGIN()
@ -410,7 +407,7 @@ storageInfoListCallback(void *data, const StorageInfo *info)
StorageInfo infoUpdate = *info; StorageInfo infoUpdate = *info;
if (listData->subPath != NULL) if (listData->subPath != NULL)
infoUpdate.name = strNewFmt("%s/%s", strPtr(listData->subPath), strPtr(infoUpdate.name)); infoUpdate.name = strNewFmt("%s/%s", strZ(listData->subPath), strZ(infoUpdate.name));
// Is this file a match? // Is this file a match?
bool match = listData->expression == NULL || regExpMatch(listData->regExp, infoUpdate.name); bool match = listData->expression == NULL || regExpMatch(listData->regExp, infoUpdate.name);
@ -426,7 +423,7 @@ storageInfoListCallback(void *data, const StorageInfo *info)
data.subPath = infoUpdate.name; data.subPath = infoUpdate.name;
storageInfoListSort( storageInfoListSort(
data.storage, strNewFmt("%s/%s", strPtr(data.path), strPtr(data.subPath)), infoUpdate.level, data.expression, data.storage, strNewFmt("%s/%s", strZ(data.path), strZ(data.subPath)), infoUpdate.level, data.expression,
data.sortOrder, storageInfoListCallback, &data); data.sortOrder, storageInfoListCallback, &data);
} }
@ -493,7 +490,7 @@ storageInfoList(
result = storageInfoListSort(this, path, param.level, NULL, param.sortOrder, callback, callbackData); result = storageInfoListSort(this, path, param.level, NULL, param.sortOrder, callback, callbackData);
if (!result && param.errorOnMissing) if (!result && param.errorOnMissing)
THROW_FMT(PathMissingError, STORAGE_ERROR_LIST_INFO_MISSING, strPtr(path)); THROW_FMT(PathMissingError, STORAGE_ERROR_LIST_INFO_MISSING, strZ(path));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
@ -692,15 +689,15 @@ storagePath(const Storage *this, const String *pathExp, StoragePathParam param)
else else
{ {
// If the path expression is absolute then use it as is // If the path expression is absolute then use it as is
if ((strPtr(pathExp))[0] == '/') if ((strZ(pathExp))[0] == '/')
{ {
// Make sure the base storage path is contained within the path expression // Make sure the base storage path is contained within the path expression
if (!strEqZ(this->path, "/")) if (!strEqZ(this->path, "/"))
{ {
if (!param.noEnforce && (!strBeginsWith(pathExp, this->path) || if (!param.noEnforce && (!strBeginsWith(pathExp, this->path) ||
!(strSize(pathExp) == strSize(this->path) || *(strPtr(pathExp) + strSize(this->path)) == '/'))) !(strSize(pathExp) == strSize(this->path) || *(strZ(pathExp) + strSize(this->path)) == '/')))
{ {
THROW_FMT(AssertError, "absolute path '%s' is not in base path '%s'", strPtr(pathExp), strPtr(this->path)); THROW_FMT(AssertError, "absolute path '%s' is not in base path '%s'", strZ(pathExp), strZ(this->path));
} }
} }
@ -713,20 +710,20 @@ storagePath(const Storage *this, const String *pathExp, StoragePathParam param)
String *pathEvaluated = NULL; String *pathEvaluated = NULL;
// Check if there is a path expression that needs to be evaluated // Check if there is a path expression that needs to be evaluated
if ((strPtr(pathExp))[0] == '<') if ((strZ(pathExp))[0] == '<')
{ {
if (this->pathExpressionFunction == NULL) if (this->pathExpressionFunction == NULL)
THROW_FMT(AssertError, "expression '%s' not valid without callback function", strPtr(pathExp)); THROW_FMT(AssertError, "expression '%s' not valid without callback function", strZ(pathExp));
// Get position of the expression end // Get position of the expression end
char *end = strchr(strPtr(pathExp), '>'); char *end = strchr(strZ(pathExp), '>');
// Error if end is not found // Error if end is not found
if (end == NULL) if (end == NULL)
THROW_FMT(AssertError, "end > not found in path expression '%s'", strPtr(pathExp)); THROW_FMT(AssertError, "end > not found in path expression '%s'", strZ(pathExp));
// Create a string from the expression // Create a string from the expression
String *expression = strNewN(strPtr(pathExp), (size_t)(end - strPtr(pathExp) + 1)); String *expression = strNewN(strZ(pathExp), (size_t)(end - strZ(pathExp) + 1));
// Create a string from the path if there is anything left after the expression // Create a string from the path if there is anything left after the expression
String *path = NULL; String *path = NULL;
@ -735,11 +732,11 @@ storagePath(const Storage *this, const String *pathExp, StoragePathParam param)
{ {
// Error if path separator is not found // Error if path separator is not found
if (end[1] != '/') if (end[1] != '/')
THROW_FMT(AssertError, "'/' should separate expression and path '%s'", strPtr(pathExp)); THROW_FMT(AssertError, "'/' should separate expression and path '%s'", strZ(pathExp));
// Only create path if there is something after the path separator // Only create path if there is something after the path separator
if (end[2] == 0) if (end[2] == 0)
THROW_FMT(AssertError, "path '%s' should not end in '/'", strPtr(pathExp)); THROW_FMT(AssertError, "path '%s' should not end in '/'", strZ(pathExp));
path = strNew(end + 2); path = strNew(end + 2);
} }
@ -749,7 +746,7 @@ storagePath(const Storage *this, const String *pathExp, StoragePathParam param)
// Evaluated path cannot be NULL // Evaluated path cannot be NULL
if (pathEvaluated == NULL) if (pathEvaluated == NULL)
THROW_FMT(AssertError, "evaluated path '%s' cannot be null", strPtr(pathExp)); THROW_FMT(AssertError, "evaluated path '%s' cannot be null", strZ(pathExp));
// Assign evaluated path to path // Assign evaluated path to path
pathExp = pathEvaluated; pathExp = pathEvaluated;
@ -760,9 +757,9 @@ storagePath(const Storage *this, const String *pathExp, StoragePathParam param)
} }
if (strEqZ(this->path, "/")) if (strEqZ(this->path, "/"))
result = strNewFmt("/%s", strPtr(pathExp)); result = strNewFmt("/%s", strZ(pathExp));
else else
result = strNewFmt("%s/%s", strPtr(this->path), strPtr(pathExp)); result = strNewFmt("%s/%s", strZ(this->path), strZ(pathExp));
strFree(pathEvaluated); strFree(pathEvaluated);
} }
@ -844,7 +841,7 @@ storagePathRemove(const Storage *this, const String *pathExp, StoragePathRemoveP
// Call driver function // Call driver function
if (!storageInterfacePathRemoveP(this->driver, path, param.recurse) && param.errorOnMissing) if (!storageInterfacePathRemoveP(this->driver, path, param.recurse) && param.errorOnMissing)
{ {
THROW_FMT(PathRemoveError, STORAGE_ERROR_PATH_REMOVE_MISSING, strPtr(path)); THROW_FMT(PathRemoveError, STORAGE_ERROR_PATH_REMOVE_MISSING, strZ(path));
} }
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
@ -978,5 +975,5 @@ String *
storageToLog(const Storage *this) storageToLog(const Storage *this)
{ {
return strNewFmt( return strNewFmt(
"{type: %s, path: %s, write: %s}", strPtr(this->type), strPtr(strToLog(this->path)), cvtBoolToConstZ(this->write)); "{type: %s, path: %s, write: %s}", strZ(this->type), strZ(strToLog(this->path)), cvtBoolToConstZ(this->write));
} }

View File

@ -182,7 +182,7 @@ storageWriteToLog(const StorageWrite *this)
{ {
return strNewFmt( return strNewFmt(
"{type: %s, name: %s, modeFile: %04o, modePath: %04o, createPath: %s, syncFile: %s, syncPath: %s, atomic: %s}", "{type: %s, name: %s, modeFile: %04o, modePath: %04o, createPath: %s, syncFile: %s, syncPath: %s, atomic: %s}",
strPtr(storageWriteType(this)), strPtr(strToLog(storageWriteName(this))), storageWriteModeFile(this), strZ(storageWriteType(this)), strZ(strToLog(storageWriteName(this))), storageWriteModeFile(this),
storageWriteModePath(this), cvtBoolToConstZ(storageWriteCreatePath(this)), cvtBoolToConstZ(storageWriteSyncFile(this)), storageWriteModePath(this), cvtBoolToConstZ(storageWriteCreatePath(this)), cvtBoolToConstZ(storageWriteSyncFile(this)),
cvtBoolToConstZ(storageWriteSyncPath(this)), cvtBoolToConstZ(storageWriteAtomic(this))); cvtBoolToConstZ(storageWriteSyncPath(this)), cvtBoolToConstZ(storageWriteAtomic(this)));
} }

View File

@ -118,5 +118,5 @@ void
harnessInfoLoadNewCallback(void *callbackData, const String *section, const String *key, const String *value) harnessInfoLoadNewCallback(void *callbackData, const String *section, const String *key, const String *value)
{ {
if (callbackData != NULL) if (callbackData != NULL)
strCatFmt((String *)callbackData, "[%s] %s=%s\n", strPtr(section), strPtr(key), strPtr(value)); strCatFmt((String *)callbackData, "[%s] %s=%s\n", strZ(section), strZ(key), strZ(value));
} }

View File

@ -295,18 +295,18 @@ hrnLogReplace(void)
{ {
THROW_FMT( THROW_FMT(
AssertError, "unable to find sub expression '%s' in '%s' extracted with expresion '%s'", AssertError, "unable to find sub expression '%s' in '%s' extracted with expresion '%s'",
strPtr(logReplace->expressionSub), strPtr(match), strPtr(logReplace->expression)); strZ(logReplace->expressionSub), strZ(match), strZ(logReplace->expression));
} }
// Find beginning of match // Find beginning of match
begin += regExpMatchPtr(logReplace->regExpSub) - strPtr(match); begin += regExpMatchPtr(logReplace->regExpSub) - strZ(match);
// Get the match // Get the match
match = regExpMatchStr(logReplace->regExpSub); match = regExpMatchStr(logReplace->regExpSub);
} }
// Build replacement string. If versioned then append the version number. // Build replacement string. If versioned then append the version number.
String *replace = strNewFmt("[%s", strPtr(logReplace->replacement)); String *replace = strNewFmt("[%s", strZ(logReplace->replacement));
if (logReplace->version) if (logReplace->version)
{ {
@ -332,7 +332,7 @@ hrnLogReplace(void)
// Move data from end of string enough to make room for the replacement and copy replacement // Move data from end of string enough to make room for the replacement and copy replacement
memmove(end + diff, end, strlen(end) + 1); memmove(end + diff, end, strlen(end) + 1);
memcpy(begin, strPtr(replace), strSize(replace)); memcpy(begin, strZ(replace), strSize(replace));
} }
} }
} }

View File

@ -83,7 +83,7 @@ harnessPqScriptRun(const char *function, const VariantList *param, HarnessPq *pa
// Ensure script has not ended // Ensure script has not ended
if (harnessPqScriptDone) if (harnessPqScriptDone)
{ {
snprintf(harnessPqScriptError, sizeof(harnessPqScriptError), "pq script ended before %s (%s)", function, strPtr(paramStr)); snprintf(harnessPqScriptError, sizeof(harnessPqScriptError), "pq script ended before %s (%s)", function, strZ(paramStr));
TEST_LOG_FMT(PQ_ERROR_PREFIX ": %s", harnessPqScriptError); TEST_LOG_FMT(PQ_ERROR_PREFIX ": %s", harnessPqScriptError);
harnessPqScriptFail = true; harnessPqScriptFail = true;
@ -99,7 +99,7 @@ harnessPqScriptRun(const char *function, const VariantList *param, HarnessPq *pa
{ {
snprintf( snprintf(
harnessPqScriptError, sizeof(harnessPqScriptError), "pq script [%u] expected function %s (%s) but got %s (%s)", harnessPqScriptError, sizeof(harnessPqScriptError), "pq script [%u] expected function %s (%s) but got %s (%s)",
harnessPqScriptIdx, result->function, result->param == NULL ? "" : result->param, function, strPtr(paramStr)); harnessPqScriptIdx, result->function, result->param == NULL ? "" : result->param, function, strZ(paramStr));
TEST_LOG_FMT(PQ_ERROR_PREFIX ": %s", harnessPqScriptError); TEST_LOG_FMT(PQ_ERROR_PREFIX ": %s", harnessPqScriptError);
harnessPqScriptFail = true; harnessPqScriptFail = true;
@ -113,7 +113,7 @@ harnessPqScriptRun(const char *function, const VariantList *param, HarnessPq *pa
{ {
snprintf( snprintf(
harnessPqScriptError, sizeof(harnessPqScriptError), "pq script [%u] function '%s', expects param '%s' but got '%s'", harnessPqScriptError, sizeof(harnessPqScriptError), "pq script [%u] function '%s', expects param '%s' but got '%s'",
harnessPqScriptIdx, result->function, result->param ? result->param : "NULL", param ? strPtr(paramStr) : "NULL"); harnessPqScriptIdx, result->function, result->param ? result->param : "NULL", param ? strZ(paramStr) : "NULL");
TEST_LOG_FMT(PQ_ERROR_PREFIX ": %s", harnessPqScriptError); TEST_LOG_FMT(PQ_ERROR_PREFIX ": %s", harnessPqScriptError);
harnessPqScriptFail = true; harnessPqScriptFail = true;

View File

@ -91,7 +91,7 @@ Macros for defining groups of functions that implement various queries and comma
#define HRNPQ_MACRO_SET_APPLICATION_NAME(sessionParam) \ #define HRNPQ_MACRO_SET_APPLICATION_NAME(sessionParam) \
{.session = sessionParam, .function = HRNPQ_SENDQUERY, \ {.session = sessionParam, .function = HRNPQ_SENDQUERY, \
.param = strPtr(strNewFmt("[\"set application_name = '" PROJECT_NAME " [%s]'\"]", cfgCommandName(cfgCommand()))), \ .param = strZ(strNewFmt("[\"set application_name = '" PROJECT_NAME " [%s]'\"]", cfgCommandName(cfgCommand()))), \
.resultInt = 1}, \ .resultInt = 1}, \
{.session = sessionParam, .function = HRNPQ_CONSUMEINPUT}, \ {.session = sessionParam, .function = HRNPQ_CONSUMEINPUT}, \
{.session = sessionParam, .function = HRNPQ_ISBUSY}, \ {.session = sessionParam, .function = HRNPQ_ISBUSY}, \
@ -165,7 +165,7 @@ Macros for defining groups of functions that implement various queries and comma
{.session = sessionParam, .function = HRNPQ_NFIELDS, .resultInt = 1}, \ {.session = sessionParam, .function = HRNPQ_NFIELDS, .resultInt = 1}, \
{.session = sessionParam, .function = HRNPQ_FTYPE, .param = "[0]", .resultInt = HRNPQ_TYPE_INT}, \ {.session = sessionParam, .function = HRNPQ_FTYPE, .param = "[0]", .resultInt = HRNPQ_TYPE_INT}, \
{.session = sessionParam, .function = HRNPQ_GETVALUE, .param = "[0,0]", \ {.session = sessionParam, .function = HRNPQ_GETVALUE, .param = "[0,0]", \
.resultZ = strPtr(strNewFmt("%" PRId64, (int64_t)(timeParam)))}, \ .resultZ = strZ(strNewFmt("%" PRId64, (int64_t)(timeParam)))}, \
{.session = sessionParam, .function = HRNPQ_CLEAR}, \ {.session = sessionParam, .function = HRNPQ_CLEAR}, \
{.session = sessionParam, .function = HRNPQ_GETRESULT, .resultNull = true} {.session = sessionParam, .function = HRNPQ_GETRESULT, .resultNull = true}
@ -223,7 +223,7 @@ Macros for defining groups of functions that implement various queries and comma
#define HRNPQ_MACRO_START_BACKUP_84_95(sessionParam, startFastParam, lsnParam, walSegmentNameParam) \ #define HRNPQ_MACRO_START_BACKUP_84_95(sessionParam, startFastParam, lsnParam, walSegmentNameParam) \
{.session = sessionParam, \ {.session = sessionParam, \
.function = HRNPQ_SENDQUERY, \ .function = HRNPQ_SENDQUERY, \
.param = strPtr(strNewFmt( \ .param = strZ(strNewFmt( \
"[\"select lsn::text as lsn,\\n" \ "[\"select lsn::text as lsn,\\n" \
" pg_catalog.pg_xlogfile_name(lsn)::text as wal_segment_name\\n" \ " pg_catalog.pg_xlogfile_name(lsn)::text as wal_segment_name\\n" \
" from pg_catalog.pg_start_backup('pgBackRest backup started at ' || current_timestamp, %s) as lsn\"]", \ " from pg_catalog.pg_start_backup('pgBackRest backup started at ' || current_timestamp, %s) as lsn\"]", \
@ -245,7 +245,7 @@ Macros for defining groups of functions that implement various queries and comma
#define HRNPQ_MACRO_START_BACKUP_96(sessionParam, startFastParam, lsnParam, walSegmentNameParam) \ #define HRNPQ_MACRO_START_BACKUP_96(sessionParam, startFastParam, lsnParam, walSegmentNameParam) \
{.session = sessionParam, \ {.session = sessionParam, \
.function = HRNPQ_SENDQUERY, \ .function = HRNPQ_SENDQUERY, \
.param = strPtr(strNewFmt( \ .param = strZ(strNewFmt( \
"[\"select lsn::text as lsn,\\n" \ "[\"select lsn::text as lsn,\\n" \
" pg_catalog.pg_xlogfile_name(lsn)::text as wal_segment_name\\n" \ " pg_catalog.pg_xlogfile_name(lsn)::text as wal_segment_name\\n" \
" from pg_catalog.pg_start_backup('pgBackRest backup started at ' || current_timestamp, %s, false) as lsn\"]", \ " from pg_catalog.pg_start_backup('pgBackRest backup started at ' || current_timestamp, %s, false) as lsn\"]", \
@ -267,7 +267,7 @@ Macros for defining groups of functions that implement various queries and comma
#define HRNPQ_MACRO_START_BACKUP_GE_10(sessionParam, startFastParam, lsnParam, walSegmentNameParam) \ #define HRNPQ_MACRO_START_BACKUP_GE_10(sessionParam, startFastParam, lsnParam, walSegmentNameParam) \
{.session = sessionParam, \ {.session = sessionParam, \
.function = HRNPQ_SENDQUERY, \ .function = HRNPQ_SENDQUERY, \
.param = strPtr(strNewFmt( \ .param = strZ(strNewFmt( \
"[\"select lsn::text as lsn,\\n" \ "[\"select lsn::text as lsn,\\n" \
" pg_catalog.pg_walfile_name(lsn)::text as wal_segment_name\\n" \ " pg_catalog.pg_walfile_name(lsn)::text as wal_segment_name\\n" \
" from pg_catalog.pg_start_backup('pgBackRest backup started at ' || current_timestamp, %s, false) as lsn\"]", \ " from pg_catalog.pg_start_backup('pgBackRest backup started at ' || current_timestamp, %s, false) as lsn\"]", \
@ -410,7 +410,7 @@ Macros for defining groups of functions that implement various queries and comma
{.session = sessionParam, .function = HRNPQ_NFIELDS, .resultInt = 2}, \ {.session = sessionParam, .function = HRNPQ_NFIELDS, .resultInt = 2}, \
{.session = sessionParam, .function = HRNPQ_FTYPE, .param = "[0]", .resultInt = HRNPQ_TYPE_INT}, \ {.session = sessionParam, .function = HRNPQ_FTYPE, .param = "[0]", .resultInt = HRNPQ_TYPE_INT}, \
{.session = sessionParam, .function = HRNPQ_FTYPE, .param = "[1]", .resultInt = HRNPQ_TYPE_TEXT}, \ {.session = sessionParam, .function = HRNPQ_FTYPE, .param = "[1]", .resultInt = HRNPQ_TYPE_TEXT}, \
{.session = sessionParam, .function = HRNPQ_GETVALUE, .param = "[0,0]", .resultZ = strPtr(strNewFmt("%d", id1Param))}, \ {.session = sessionParam, .function = HRNPQ_GETVALUE, .param = "[0,0]", .resultZ = strZ(strNewFmt("%d", id1Param))}, \
{.session = sessionParam, .function = HRNPQ_GETVALUE, .param = "[0,1]", .resultZ = name1Param}, \ {.session = sessionParam, .function = HRNPQ_GETVALUE, .param = "[0,1]", .resultZ = name1Param}, \
{.session = sessionParam, .function = HRNPQ_CLEAR}, \ {.session = sessionParam, .function = HRNPQ_CLEAR}, \
{.session = sessionParam, .function = HRNPQ_GETRESULT, .resultNull = true} {.session = sessionParam, .function = HRNPQ_GETRESULT, .resultNull = true}
@ -428,7 +428,7 @@ Macros for defining groups of functions that implement various queries and comma
sessionParam, walNameParam, lsnNameParam, targetLsnParam, targetReachedParam, replayLsnParam) \ sessionParam, walNameParam, lsnNameParam, targetLsnParam, targetReachedParam, replayLsnParam) \
{.session = sessionParam, \ {.session = sessionParam, \
.function = HRNPQ_SENDQUERY, \ .function = HRNPQ_SENDQUERY, \
.param = strPtr(strNewFmt( \ .param = strZ(strNewFmt( \
"[\"select replayLsn::text,\\n" \ "[\"select replayLsn::text,\\n" \
" (replayLsn > '%s')::bool as targetReached\\n" \ " (replayLsn > '%s')::bool as targetReached\\n" \
" from pg_catalog.pg_last_" walNameParam "_replay_" lsnNameParam "() as replayLsn\"]", targetLsnParam)), \ " from pg_catalog.pg_last_" walNameParam "_replay_" lsnNameParam "() as replayLsn\"]", targetLsnParam)), \
@ -455,7 +455,7 @@ Macros for defining groups of functions that implement various queries and comma
#define HRNPQ_MACRO_CHECKPOINT_TARGET_REACHED(sessionParam, lsnNameParam, targetLsnParam, targetReachedParam, checkpointLsnParam) \ #define HRNPQ_MACRO_CHECKPOINT_TARGET_REACHED(sessionParam, lsnNameParam, targetLsnParam, targetReachedParam, checkpointLsnParam) \
{.session = sessionParam, \ {.session = sessionParam, \
.function = HRNPQ_SENDQUERY, \ .function = HRNPQ_SENDQUERY, \
.param = strPtr(strNewFmt( \ .param = strZ(strNewFmt( \
"[\"select (checkpoint_" lsnNameParam " > '%s')::bool as targetReached,\\n" \ "[\"select (checkpoint_" lsnNameParam " > '%s')::bool as targetReached,\\n" \
" checkpoint_" lsnNameParam "::text as checkpointLsn\\n" \ " checkpoint_" lsnNameParam "::text as checkpointLsn\\n" \
" from pg_catalog.pg_control_checkpoint()\"]", targetLsnParam)), \ " from pg_catalog.pg_control_checkpoint()\"]", targetLsnParam)), \

View File

@ -71,7 +71,7 @@ hrnStorageInfoListCallback(void *callbackData, const StorageInfo *info)
if (data->rootPathOmit && info->type == storageTypePath && strEq(info->name, DOT_STR)) if (data->rootPathOmit && info->type == storageTypePath && strEq(info->name, DOT_STR))
return; return;
strCatFmt(data->content, "%s {", strPtr(info->name)); strCatFmt(data->content, "%s {", strZ(info->name));
if (info->level > storageInfoLevelExists) if (info->level > storageInfoLevelExists)
{ {
@ -93,7 +93,7 @@ hrnStorageInfoListCallback(void *callbackData, const StorageInfo *info)
StorageRead *read = storageNewReadP( StorageRead *read = storageNewReadP(
data->storage, data->storage,
data->path != NULL ? strNewFmt("%s/%s", strPtr(data->path), strPtr(info->name)) : info->name); data->path != NULL ? strNewFmt("%s/%s", strZ(data->path), strZ(info->name)) : info->name);
ioFilterGroupAdd(ioReadFilterGroup(storageReadIo(read)), decompressFilter(compressTypeGz)); ioFilterGroupAdd(ioReadFilterGroup(storageReadIo(read)), decompressFilter(compressTypeGz));
size = bufUsed(storageGetP(read)); size = bufUsed(storageGetP(read));
} }
@ -106,7 +106,7 @@ hrnStorageInfoListCallback(void *callbackData, const StorageInfo *info)
case storageTypeLink: case storageTypeLink:
{ {
strCatFmt(data->content, "link, d=%s", strPtr(info->linkDestination)); strCatFmt(data->content, "link, d=%s", strZ(info->linkDestination));
break; break;
} }
@ -145,7 +145,7 @@ hrnStorageInfoListCallback(void *callbackData, const StorageInfo *info)
{ {
if (info->user != NULL) if (info->user != NULL)
{ {
strCatFmt(data->content, ", u=%s", strPtr(info->user)); strCatFmt(data->content, ", u=%s", strZ(info->user));
} }
else else
{ {
@ -157,7 +157,7 @@ hrnStorageInfoListCallback(void *callbackData, const StorageInfo *info)
{ {
if (info->group != NULL) if (info->group != NULL)
{ {
strCatFmt(data->content, ", g=%s", strPtr(info->group)); strCatFmt(data->content, ", g=%s", strZ(info->group));
} }
else else
{ {

View File

@ -239,15 +239,15 @@ Macros to compare results of common data types
TEST_RESULT_Z_PARAM(statement, expected, harnessTestResultOperationNe, __VA_ARGS__); TEST_RESULT_Z_PARAM(statement, expected, harnessTestResultOperationNe, __VA_ARGS__);
#define TEST_RESULT_STR(statement, resultExpected, ...) \ #define TEST_RESULT_STR(statement, resultExpected, ...) \
TEST_RESULT_Z(strPtrNull(statement), strPtrNull(resultExpected), __VA_ARGS__); TEST_RESULT_Z(strZNull(statement), strZNull(resultExpected), __VA_ARGS__);
#define TEST_RESULT_STR_Z(statement, resultExpected, ...) \ #define TEST_RESULT_STR_Z(statement, resultExpected, ...) \
TEST_RESULT_Z(strPtrNull(statement), resultExpected, __VA_ARGS__); TEST_RESULT_Z(strZNull(statement), resultExpected, __VA_ARGS__);
#define TEST_RESULT_STR_KEYRPL(statement, resultExpected, ...) \ #define TEST_RESULT_STR_KEYRPL(statement, resultExpected, ...) \
TEST_RESULT_Z(strPtrNull(statement), hrnReplaceKey(strPtr(resultExpected)), __VA_ARGS__); TEST_RESULT_Z(strZNull(statement), hrnReplaceKey(strZ(resultExpected)), __VA_ARGS__);
#define TEST_RESULT_STR_Z_KEYRPL(statement, resultExpected, ...) \ #define TEST_RESULT_STR_Z_KEYRPL(statement, resultExpected, ...) \
TEST_RESULT_Z(strPtrNull(statement), hrnReplaceKey(resultExpected), __VA_ARGS__); TEST_RESULT_Z(strZNull(statement), hrnReplaceKey(resultExpected), __VA_ARGS__);
#define TEST_RESULT_Z_STR(statement, resultExpected, ...) \ #define TEST_RESULT_Z_STR(statement, resultExpected, ...) \
TEST_RESULT_Z(statement, strPtrNull(resultExpected), __VA_ARGS__); TEST_RESULT_Z(statement, strZNull(resultExpected), __VA_ARGS__);
#define TEST_RESULT_UINT_PARAM(statement, expected, operation, ...) \ #define TEST_RESULT_UINT_PARAM(statement, expected, operation, ...) \
do \ do \

View File

@ -233,10 +233,9 @@ void hrnTlsServerRunParam(IoRead *read, const String *certificate, const String
// Configure the context by setting key and cert // Configure the context by setting key and cert
cryptoError( cryptoError(
SSL_CTX_use_certificate_file(serverContext, strPtr(certificate), SSL_FILETYPE_PEM) <= 0, SSL_CTX_use_certificate_file(serverContext, strZ(certificate), SSL_FILETYPE_PEM) <= 0, "unable to load server certificate");
"unable to load server certificate");
cryptoError( cryptoError(
SSL_CTX_use_PrivateKey_file(serverContext, strPtr(key), SSL_FILETYPE_PEM) <= 0, "unable to load server private key"); SSL_CTX_use_PrivateKey_file(serverContext, strZ(key), SSL_FILETYPE_PEM) <= 0, "unable to load server private key");
// Create the socket // Create the socket
int serverSocket; int serverSocket;
@ -340,13 +339,13 @@ void hrnTlsServerRunParam(IoRead *read, const String *certificate, const String
for (unsigned int actualIdx = 0; actualIdx < strSize(actual); actualIdx++) for (unsigned int actualIdx = 0; actualIdx < strSize(actual); actualIdx++)
{ {
if (strPtr(expected)[actualIdx] == '?') if (strZ(expected)[actualIdx] == '?')
((char *)strPtr(actual))[actualIdx] = '?'; ((char *)strZ(actual))[actualIdx] = '?';
} }
// Error if actual does not match expected // Error if actual does not match expected
if (!strEq(actual, expected)) if (!strEq(actual, expected))
THROW_FMT(AssertError, "server expected '%s' but got '%s'", strPtr(expected), strPtr(actual)); THROW_FMT(AssertError, "server expected '%s' but got '%s'", strZ(expected), strZ(actual));
break; break;
} }

View File

@ -37,16 +37,16 @@ testRun(void)
TEST_RESULT_BOOL(archiveAsyncStatus(archiveModeGet, segment, false), false, "directory and status file not present"); TEST_RESULT_BOOL(archiveAsyncStatus(archiveModeGet, segment, false), false, "directory and status file not present");
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
mkdir(strPtr(strNewFmt("%s/archive", testPath())), 0750); mkdir(strZ(strNewFmt("%s/archive", testPath())), 0750);
mkdir(strPtr(strNewFmt("%s/archive/db", testPath())), 0750); mkdir(strZ(strNewFmt("%s/archive/db", testPath())), 0750);
mkdir(strPtr(strNewFmt("%s/archive/db/out", testPath())), 0750); mkdir(strZ(strNewFmt("%s/archive/db/out", testPath())), 0750);
TEST_RESULT_BOOL(archiveAsyncStatus(archiveModePush, segment, false), false, "status file not present"); TEST_RESULT_BOOL(archiveAsyncStatus(archiveModePush, segment, false), false, "status file not present");
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("clear archive file errors"); TEST_TITLE("clear archive file errors");
const String *errorSegment = strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.error", strPtr(segment)); const String *errorSegment = strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.error", strZ(segment));
const String *errorGlobal = strNew(STORAGE_SPOOL_ARCHIVE_OUT "/global.error"); const String *errorGlobal = strNew(STORAGE_SPOOL_ARCHIVE_OUT "/global.error");
storagePutP(storageNewWriteP(storageSpoolWrite(), errorSegment), NULL); storagePutP(storageNewWriteP(storageSpoolWrite(), errorSegment), NULL);
@ -59,53 +59,53 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
storagePutP( storagePutP(
storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))), storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strZ(segment))),
BUFSTRDEF(BOGUS_STR)); BUFSTRDEF(BOGUS_STR));
TEST_ERROR( TEST_ERROR(
archiveAsyncStatus(archiveModePush, segment, false), FormatError, archiveAsyncStatus(archiveModePush, segment, false), FormatError,
"000000010000000100000001.ok content must have at least two lines"); "000000010000000100000001.ok content must have at least two lines");
storagePutP( storagePutP(
storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))), storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strZ(segment))),
BUFSTRDEF(BOGUS_STR "\n")); BUFSTRDEF(BOGUS_STR "\n"));
TEST_ERROR( TEST_ERROR(
archiveAsyncStatus(archiveModePush, segment, false), FormatError, "000000010000000100000001.ok message must be > 0"); archiveAsyncStatus(archiveModePush, segment, false), FormatError, "000000010000000100000001.ok message must be > 0");
storagePutP( storagePutP(
storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))), storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strZ(segment))),
BUFSTRDEF(BOGUS_STR "\nmessage")); BUFSTRDEF(BOGUS_STR "\nmessage"));
TEST_ERROR( TEST_ERROR(
archiveAsyncStatus(archiveModePush, segment, false), FormatError, "unable to convert base 10 string 'BOGUS' to int"); archiveAsyncStatus(archiveModePush, segment, false), FormatError, "unable to convert base 10 string 'BOGUS' to int");
storagePutP(storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))), NULL); storagePutP(storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strZ(segment))), NULL);
TEST_RESULT_BOOL(archiveAsyncStatus(archiveModePush, segment, false), true, "ok file"); TEST_RESULT_BOOL(archiveAsyncStatus(archiveModePush, segment, false), true, "ok file");
storagePutP( storagePutP(
storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))), storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strZ(segment))),
BUFSTRDEF("0\nwarning")); BUFSTRDEF("0\nwarning"));
TEST_RESULT_BOOL(archiveAsyncStatus(archiveModePush, segment, false), true, "ok file with warning"); TEST_RESULT_BOOL(archiveAsyncStatus(archiveModePush, segment, false), true, "ok file with warning");
harnessLogResult("P00 WARN: warning"); harnessLogResult("P00 WARN: warning");
storagePutP( storagePutP(
storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))), storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strZ(segment))),
BUFSTRDEF("25\nerror")); BUFSTRDEF("25\nerror"));
TEST_RESULT_BOOL(archiveAsyncStatus(archiveModePush, segment, false), true, "error status renamed to ok"); TEST_RESULT_BOOL(archiveAsyncStatus(archiveModePush, segment, false), true, "error status renamed to ok");
harnessLogResult( harnessLogResult(
"P00 WARN: WAL segment '000000010000000100000001' was not pushed due to error [25] and was manually skipped: error"); "P00 WARN: WAL segment '000000010000000100000001' was not pushed due to error [25] and was manually skipped: error");
TEST_RESULT_VOID( TEST_RESULT_VOID(
storageRemoveP( storageRemoveP(
storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment)), .errorOnMissing = true), storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strZ(segment)), .errorOnMissing = true),
"remove ok"); "remove ok");
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
storagePutP( storagePutP(
storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.error", strPtr(segment))), bufNew(0)); storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.error", strZ(segment))), bufNew(0));
TEST_ERROR( TEST_ERROR(
archiveAsyncStatus(archiveModePush, segment, true), AssertError, archiveAsyncStatus(archiveModePush, segment, true), AssertError,
"status file '000000010000000100000001.error' has no content"); "status file '000000010000000100000001.error' has no content");
storagePutP( storagePutP(
storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.error", strPtr(segment))), storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.error", strZ(segment))),
BUFSTRDEF("25\nmessage")); BUFSTRDEF("25\nmessage"));
TEST_ERROR(archiveAsyncStatus(archiveModePush, segment, true), AssertError, "message"); TEST_ERROR(archiveAsyncStatus(archiveModePush, segment, true), AssertError, "message");
@ -191,23 +191,21 @@ testRun(void)
TEST_RESULT_STR_Z(walPath(strNew("/absolute/path"), pgPath, strNew("test")), "/absolute/path", "absolute path"); TEST_RESULT_STR_Z(walPath(strNew("/absolute/path"), pgPath, strNew("test")), "/absolute/path", "absolute path");
THROW_ON_SYS_ERROR(chdir(strPtr(pgPath)) != 0, PathMissingError, "unable to chdir()"); THROW_ON_SYS_ERROR(chdir(strZ(pgPath)) != 0, PathMissingError, "unable to chdir()");
TEST_RESULT_STR( TEST_RESULT_STR(
walPath(strNew("relative/path"), pgPath, strNew("test")), strNewFmt("%s/relative/path", strPtr(pgPath)), walPath(strNew("relative/path"), pgPath, strNew("test")), strNewFmt("%s/relative/path", strZ(pgPath)),
"relative path"); "relative path");
const String *pgPathLink = storagePathP(storageTest, STRDEF("pg-link")); const String *pgPathLink = storagePathP(storageTest, STRDEF("pg-link"));
THROW_ON_SYS_ERROR_FMT( THROW_ON_SYS_ERROR_FMT(
symlink(strPtr(pgPath), strPtr(pgPathLink)) == -1, FileOpenError, symlink(strZ(pgPath), strZ(pgPathLink)) == -1, FileOpenError, "unable to create symlink '%s' to '%s'", strZ(pgPath),
"unable to create symlink '%s' to '%s'", strPtr(pgPath), strPtr(pgPathLink)); strZ(pgPathLink));
THROW_ON_SYS_ERROR(chdir(strPtr(pgPath)) != 0, PathMissingError, "unable to chdir()"); THROW_ON_SYS_ERROR(chdir(strZ(pgPath)) != 0, PathMissingError, "unable to chdir()");
TEST_RESULT_STR( TEST_RESULT_STR(
walPath(strNew("relative/path"), pgPathLink, strNew("test")), strNewFmt("%s/relative/path", strPtr(pgPathLink)), walPath(strNew("relative/path"), pgPathLink, strNew("test")), strNewFmt("%s/relative/path", strZ(pgPathLink)),
"relative path"); "relative path");
THROW_ON_SYS_ERROR(chdir("/") != 0, PathMissingError, "unable to chdir()"); THROW_ON_SYS_ERROR(chdir("/") != 0, PathMissingError, "unable to chdir()");
TEST_ERROR( TEST_ERROR(
walPath(strNew("relative/path"), pgPathLink, strNew("test")), AssertError, walPath(strNew("relative/path"), pgPathLink, strNew("test")), AssertError,

View File

@ -234,7 +234,7 @@ testRun(void)
archiveGetProtocol(PROTOCOL_COMMAND_ARCHIVE_GET_STR, paramList, server), true, "protocol archive get"); archiveGetProtocol(PROTOCOL_COMMAND_ARCHIVE_GET_STR, paramList, server), true, "protocol archive get");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{\"out\":0}\n", "check result"); TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{\"out\":0}\n", "check result");
TEST_RESULT_BOOL( TEST_RESULT_BOOL(
storageExistsP(storageTest, strNewFmt("spool/archive/test1/in/%s", strPtr(archiveFile))), true, " check exists"); storageExistsP(storageTest, strNewFmt("spool/archive/test1/in/%s", strZ(archiveFile))), true, " check exists");
bufUsedSet(serverWrite, 0); bufUsedSet(serverWrite, 0);
@ -577,9 +577,9 @@ testRun(void)
"HINT: has a stanza-create been performed?\n" "HINT: has a stanza-create been performed?\n"
"HINT: use --no-archive-check to disable archive checks during backup if you have an alternate archiving" "HINT: use --no-archive-check to disable archive checks during backup if you have an alternate archiving"
" scheme.", " scheme.",
strPtr(cfgOptionStr(cfgOptRepoPath)), strPtr(cfgOptionStr(cfgOptRepoPath)), strZ(cfgOptionStr(cfgOptRepoPath)), strZ(cfgOptionStr(cfgOptRepoPath)),
strPtr(strNewFmt("%s/archive/test1/archive.info", strPtr(cfgOptionStr(cfgOptRepoPath)))), strZ(strNewFmt("%s/archive/test1/archive.info", strZ(cfgOptionStr(cfgOptRepoPath)))),
strPtr(strNewFmt("%s/archive/test1/archive.info.copy", strPtr(cfgOptionStr(cfgOptRepoPath))))); strZ(strNewFmt("%s/archive/test1/archive.info.copy", strZ(cfgOptionStr(cfgOptRepoPath)))));
} }
HARNESS_FORK_CHILD_END(); HARNESS_FORK_CHILD_END();
} }
@ -607,9 +607,9 @@ testRun(void)
"HINT: has a stanza-create been performed?\n" "HINT: has a stanza-create been performed?\n"
"HINT: use --no-archive-check to disable archive checks during backup if you have an alternate archiving" "HINT: use --no-archive-check to disable archive checks during backup if you have an alternate archiving"
" scheme.", " scheme.",
strPtr(cfgOptionStr(cfgOptRepoPath)), strPtr(cfgOptionStr(cfgOptRepoPath)), strZ(cfgOptionStr(cfgOptRepoPath)), strZ(cfgOptionStr(cfgOptRepoPath)),
strPtr(strNewFmt("%s/archive/test1/archive.info", strPtr(cfgOptionStr(cfgOptRepoPath)))), strZ(strNewFmt("%s/archive/test1/archive.info", strZ(cfgOptionStr(cfgOptRepoPath)))),
strPtr(strNewFmt("%s/archive/test1/archive.info.copy", strPtr(cfgOptionStr(cfgOptRepoPath))))); strZ(strNewFmt("%s/archive/test1/archive.info.copy", strZ(cfgOptionStr(cfgOptRepoPath)))));
} }
HARNESS_FORK_CHILD_END(); HARNESS_FORK_CHILD_END();
} }
@ -623,7 +623,7 @@ testRun(void)
strLstAddZ(argList, "pg_wal/RECOVERYXLOG"); strLstAddZ(argList, "pg_wal/RECOVERYXLOG");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)); harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
THROW_ON_SYS_ERROR(chdir(strPtr(cfgOptionStr(cfgOptPgPath))) != 0, PathMissingError, "unable to chdir()"); THROW_ON_SYS_ERROR(chdir(strZ(cfgOptionStr(cfgOptPgPath))) != 0, PathMissingError, "unable to chdir()");
HARNESS_FORK_BEGIN() HARNESS_FORK_BEGIN()
{ {
@ -639,8 +639,7 @@ testRun(void)
// Check for missing WAL // Check for missing WAL
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
storagePutP( storagePutP(storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s.ok", strZ(walSegment))), NULL);
storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s.ok", strPtr(walSegment))), NULL);
HARNESS_FORK_BEGIN() HARNESS_FORK_BEGIN()
{ {
@ -655,13 +654,13 @@ testRun(void)
harnessLogResult("P01 INFO: unable to find 000000010000000100000001 in the archive"); harnessLogResult("P01 INFO: unable to find 000000010000000100000001 in the archive");
TEST_RESULT_BOOL( TEST_RESULT_BOOL(
storageExistsP(storageSpool(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s.ok", strPtr(walSegment))), false, storageExistsP(storageSpool(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s.ok", strZ(walSegment))), false,
"check OK file was removed"); "check OK file was removed");
// Write out a WAL segment for success // Write out a WAL segment for success
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
storagePutP( storagePutP(
storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strPtr(walSegment))), storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strZ(walSegment))),
BUFSTRDEF("SHOULD-BE-A-REAL-WAL-FILE")); BUFSTRDEF("SHOULD-BE-A-REAL-WAL-FILE"));
HARNESS_FORK_BEGIN() HARNESS_FORK_BEGIN()
@ -677,7 +676,7 @@ testRun(void)
TEST_RESULT_VOID(harnessLogResult("P01 INFO: found 000000010000000100000001 in the archive"), "check log"); TEST_RESULT_VOID(harnessLogResult("P01 INFO: found 000000010000000100000001 in the archive"), "check log");
TEST_RESULT_BOOL( TEST_RESULT_BOOL(
storageExistsP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strPtr(walSegment))), false, storageExistsP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strZ(walSegment))), false,
"check WAL segment was removed from source"); "check WAL segment was removed from source");
TEST_RESULT_BOOL(storageExistsP(storageTest, walFile), true, "check WAL segment was moved to destination"); TEST_RESULT_BOOL(storageExistsP(storageTest, walFile), true, "check WAL segment was moved to destination");
storageRemoveP(storageTest, walFile, .errorOnMissing = true); storageRemoveP(storageTest, walFile, .errorOnMissing = true);
@ -690,10 +689,10 @@ testRun(void)
String *walSegment2 = strNew("000000010000000100000002"); String *walSegment2 = strNew("000000010000000100000002");
storagePutP( storagePutP(
storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strPtr(walSegment))), storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strZ(walSegment))),
BUFSTRDEF("SHOULD-BE-A-REAL-WAL-FILE")); BUFSTRDEF("SHOULD-BE-A-REAL-WAL-FILE"));
storagePutP( storagePutP(
storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strPtr(walSegment2))), storageNewWriteP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strZ(walSegment2))),
BUFSTRDEF("SHOULD-BE-A-REAL-WAL-FILE")); BUFSTRDEF("SHOULD-BE-A-REAL-WAL-FILE"));
HARNESS_FORK_BEGIN() HARNESS_FORK_BEGIN()

Some files were not shown because too many files have changed in this diff Show More