1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Apply String constant macros where appropriate.

This may not be all the places where the macros can be useful but it's a good start.
This commit is contained in:
David Steele 2018-11-10 18:32:49 -05:00
parent 8f857a975e
commit 5e3b7cbe6e
27 changed files with 119 additions and 60 deletions

View File

@ -75,7 +75,7 @@
</release-item>
<release-item>
<p>Add <code>strCatChr()</code>and constant macros to <code>String</code> object.</p>
<p>Add <code>strCatChr()</code> and constant macros to <code>String</code> object.</p>
</release-item>
<release-item>

View File

@ -283,7 +283,7 @@ compress/gzipDecompress.o: compress/gzipDecompress.c common/debug.h common/error
config/config.o: config/config.c common/assert.h common/debug.h common/error.auto.h common/error.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.c config/config.auto.h config/config.h config/define.auto.h config/define.h
$(CC) $(CFLAGS) -c config/config.c -o config/config.o
config/define.o: config/define.c common/assert.h common/debug.h common/error.auto.h common/error.h common/logLevel.h common/stackTrace.h common/type/convert.h config/define.auto.c config/define.auto.h config/define.h
config/define.o: config/define.c common/assert.h common/debug.h common/error.auto.h common/error.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h config/define.auto.c config/define.auto.h config/define.h
$(CC) $(CFLAGS) -c config/define.c -o config/define.o
config/load.o: config/load.c command/command.h common/debug.h common/error.auto.h common/error.h common/io/io.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h config/parse.h

View File

@ -16,6 +16,12 @@ Archive Push Command
#include "storage/helper.h"
#include "storage/helper.h"
/***********************************************************************************************************************************
WAL segment constants
***********************************************************************************************************************************/
STRING_EXTERN(WAL_SEGMENT_REGEXP_STR, WAL_SEGMENT_REGEXP);
STRING_EXTERN(WAL_SEGMENT_PARTIAL_REGEXP_STR, WAL_SEGMENT_PARTIAL_REGEXP);
/***********************************************************************************************************************************
Check for ok/error status files in the spool in/out directory
***********************************************************************************************************************************/
@ -32,7 +38,7 @@ archiveAsyncStatus(ArchiveMode archiveMode, const String *walSegment, bool confe
MEM_CONTEXT_TEMP_BEGIN()
{
String *spoolQueue = strNew(archiveMode == archiveModeGet ? STORAGE_SPOOL_ARCHIVE_IN : STORAGE_SPOOL_ARCHIVE_OUT);
const String *spoolQueue = (archiveMode == archiveModeGet ? STORAGE_SPOOL_ARCHIVE_IN_STR : STORAGE_SPOOL_ARCHIVE_OUT_STR);
String *okFile = strNewFmt("%s.ok", strPtr(walSegment));
String *errorFile = strNewFmt("%s.error", strPtr(walSegment));
@ -148,7 +154,7 @@ walIsSegment(const String *walSegment)
{
MEM_CONTEXT_BEGIN(memContextTop())
{
regExpSegment = regExpNew(strNew(WAL_SEGMENT_PARTIAL_REGEXP));
regExpSegment = regExpNew(WAL_SEGMENT_PARTIAL_REGEXP_STR);
}
MEM_CONTEXT_END();
}

View File

@ -31,9 +31,11 @@ WAL segment constants
// Match on a WAL segment without checksum appended
#define WAL_SEGMENT_REGEXP WAL_SEGMENT_PREFIX_REGEXP "$"
STRING_DECLARE(WAL_SEGMENT_REGEXP_STR);
// Match on a WAL segment with partial allowed
#define WAL_SEGMENT_PARTIAL_REGEXP WAL_SEGMENT_PREFIX_REGEXP "(\\.partial){0,1}$"
STRING_DECLARE(WAL_SEGMENT_PARTIAL_REGEXP_STR);
// Defines the size of standard WAL segment name -- hopefully this won't change
#define WAL_SEGMENT_NAME_SIZE ((unsigned int)24)

View File

@ -35,7 +35,7 @@ archiveGetCheck(const String *archiveFile)
PgControl controlInfo = pgControlFromFile(cfgOptionStr(cfgOptPgPath));
// Attempt to load the archive info file
InfoArchive *info = infoArchiveNew(storageRepo(), strNew(STORAGE_REPO_ARCHIVE "/" INFO_ARCHIVE_FILE), false);
InfoArchive *info = infoArchiveNew(storageRepo(), STRING_CONST(STORAGE_REPO_ARCHIVE "/" INFO_ARCHIVE_FILE), false);
// Loop through the pg history in case the WAL we need is not in the most recent archive id
String *archiveId = NULL;

View File

@ -59,7 +59,7 @@ queueNeed(const String *walSegment, bool found, size_t queueSize, size_t walSegm
// Get the list of files actually in the queue
StringList *actualQueue = strLstSort(
storageListP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_IN), .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.
RegExp *regExpPreserve = regExpNew(strNewFmt("^(%s)$", strPtr(strLstJoin(idealQueue, "|"))));
@ -184,7 +184,7 @@ cmdArchiveGet(void)
// Get a list of WAL segments left in the queue
StringList *queue = storageListP(
storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_IN), .expression = strNew(WAL_SEGMENT_REGEXP));
storageSpool(), STORAGE_SPOOL_ARCHIVE_IN_STR, .expression = WAL_SEGMENT_REGEXP_STR);
if (strLstSize(queue) > 0)
{
@ -224,7 +224,7 @@ cmdArchiveGet(void)
PgControl pgControl = pgControlFromFile(cfgOptionStr(cfgOptPgPath));
// Create the queue
storagePathCreateNP(storageSpoolWrite(), strNew(STORAGE_SPOOL_ARCHIVE_IN));
storagePathCreateNP(storageSpoolWrite(), STORAGE_SPOOL_ARCHIVE_IN_STR);
// Clean the current queue using the list of WAL that we ideally want in the queue. queueNeed()
// will return the list of WAL needed to fill the queue and this will be passed to the async process.

View File

@ -72,27 +72,27 @@ helpRenderText(const String *text, size_t indent, bool indentFirst, size_t lengt
/***********************************************************************************************************************************
Helper function for helpRender() to output values as strings
***********************************************************************************************************************************/
static String *
static const String *
helpRenderValue(const Variant *value)
{
FUNCTION_DEBUG_BEGIN(logLevelTrace);
FUNCTION_DEBUG_PARAM(VARIANT, value);
FUNCTION_DEBUG_END();
String *result = NULL;
const String *result = NULL;
if (value != NULL)
{
if (varType(value) == varTypeBool)
{
if (varBool(value))
result = strNew("y");
result = Y_STR;
else
result = strNew("n");
result = N_STR;
}
else if (varType(value) == varTypeKeyValue)
{
result = strNew("");
String *resultTemp = strNew("");
const KeyValue *optionKv = varKv(value);
const VariantList *keyList = kvKeyList(optionKv);
@ -100,32 +100,36 @@ helpRenderValue(const Variant *value)
for (unsigned int keyIdx = 0; keyIdx < varLstSize(keyList); keyIdx++)
{
if (keyIdx != 0)
strCat(result, ", ");
strCat(resultTemp, ", ");
strCatFmt(
result, "%s=%s", strPtr(varStr(varLstGet(keyList, keyIdx))),
resultTemp, "%s=%s", strPtr(varStr(varLstGet(keyList, keyIdx))),
strPtr(varStrForce(kvGet(optionKv, varLstGet(keyList, keyIdx)))));
}
result = resultTemp;
}
else if (varType(value) == varTypeVariantList)
{
result = strNew("");
String *resultTemp = strNew("");
const VariantList *list = varVarLst(value);
for (unsigned int listIdx = 0; listIdx < varLstSize(list); listIdx++)
{
if (listIdx != 0)
strCat(result, ", ");
strCat(resultTemp, ", ");
strCatFmt(result, "%s", strPtr(varStr(varLstGet(list, listIdx))));
strCatFmt(resultTemp, "%s", strPtr(varStr(varLstGet(list, listIdx))));
}
result = resultTemp;
}
else
result = varStrForce(value);
}
FUNCTION_DEBUG_RESULT(STRING, result);
FUNCTION_DEBUG_RESULT(CONST_STRING, result);
}
/***********************************************************************************************************************************
@ -260,8 +264,8 @@ helpRender(void)
strlen(cfgDefOptionHelpSummary(commandDefId, optionDefId)) - 1));
// Ouput current and default values if they exist
String *defaultValue = helpRenderValue(cfgOptionDefault(optionId));
String *value = NULL;
const String *defaultValue = helpRenderValue(cfgOptionDefault(optionId));
const String *value = NULL;
if (cfgOptionSource(optionId) != cfgSourceDefault)
value = helpRenderValue(cfgOption(optionId));
@ -330,8 +334,8 @@ helpRender(void)
strPtr(helpRenderText(strNew(cfgDefOptionHelpDescription(commandDefId, optionDefId)), 0, true, CONSOLE_WIDTH)));
// Ouput current and default values if they exist
String *defaultValue = helpRenderValue(cfgOptionDefault(optionId));
String *value = NULL;
const String *defaultValue = helpRenderValue(cfgOptionDefault(optionId));
const String *value = NULL;
if (cfgOptionSource(optionId) != cfgSourceDefault)
value = helpRenderValue(cfgOption(optionId));

View File

@ -13,6 +13,7 @@ IO Buffer Filter
Filter type constant
***********************************************************************************************************************************/
#define BUFFER_FILTER_TYPE "buffer"
STRING_STATIC(BUFFER_FILTER_TYPE_STR, BUFFER_FILTER_TYPE);
/***********************************************************************************************************************************
Object type
@ -43,7 +44,7 @@ ioBufferNew(void)
// Create filter interface
this->filter = ioFilterNewP(
strNew(BUFFER_FILTER_TYPE), this, .inOut = (IoFilterInterfaceProcessInOut)ioBufferProcess,
BUFFER_FILTER_TYPE_STR, this, .inOut = (IoFilterInterfaceProcessInOut)ioBufferProcess,
.inputSame = (IoFilterInterfaceInputSame)ioBufferInputSame);
}
MEM_CONTEXT_NEW_END();

View File

@ -13,6 +13,7 @@ IO Size Filter
Filter type constant
***********************************************************************************************************************************/
#define SIZE_FILTER_TYPE "size"
STRING_STATIC(SIZE_FILTER_TYPE_STR, SIZE_FILTER_TYPE)
/***********************************************************************************************************************************
Object type
@ -42,7 +43,7 @@ ioSizeNew(void)
// Create filter interface
this->filter = ioFilterNewP(
strNew(SIZE_FILTER_TYPE), this, .in = (IoFilterInterfaceProcessIn)ioSizeProcess,
SIZE_FILTER_TYPE_STR, this, .in = (IoFilterInterfaceProcessIn)ioSizeProcess,
.result = (IoFilterInterfaceResult)ioSizeResult);
}
MEM_CONTEXT_NEW_END();

View File

@ -94,10 +94,10 @@ lockAcquireFile(const String *lockFile, TimeMSec lockTimeout, bool failOnNoLock)
// Error when requested
if (failOnNoLock)
{
String *errorHint = NULL;
const String *errorHint = NULL;
if (errNo == EWOULDBLOCK)
errorHint = strNew("\nHINT: is another " PGBACKREST_NAME " process running?");
errorHint = STRING_CONST("\nHINT: is another " PGBACKREST_NAME " process running?");
else if (errNo == EACCES)
{
errorHint = strNewFmt(

View File

@ -929,7 +929,7 @@ Convert variant to a zero-terminated string for logging
String *
varToLog(const Variant *this)
{
String *string = NULL;
const String *string = NULL;
switch (varType(this))
{
@ -941,13 +941,13 @@ varToLog(const Variant *this)
case varTypeKeyValue:
{
string = strNew("KeyValue");
string = STRING_CONST("KeyValue");
break;
}
case varTypeVariantList:
{
string = strNew("VariantList");
string = STRING_CONST("VariantList");
break;
}

View File

@ -16,6 +16,7 @@ Gzip Compress
Filter type constant
***********************************************************************************************************************************/
#define GZIP_COMPRESS_FILTER_TYPE "gzipCompress"
STRING_STATIC(GZIP_COMPRESS_FILTER_TYPE_STR, GZIP_COMPRESS_FILTER_TYPE);
/***********************************************************************************************************************************
Object type
@ -66,7 +67,7 @@ gzipCompressNew(int level, bool raw)
// Create filter interface
this->filter = ioFilterNewP(
strNew(GZIP_COMPRESS_FILTER_TYPE), this, .done = (IoFilterInterfaceDone)gzipCompressDone,
GZIP_COMPRESS_FILTER_TYPE_STR, this, .done = (IoFilterInterfaceDone)gzipCompressDone,
.inOut = (IoFilterInterfaceProcessInOut)gzipCompressProcess,
.inputSame = (IoFilterInterfaceInputSame)gzipCompressInputSame);
}

View File

@ -15,6 +15,7 @@ Gzip Decompress
Filter type constant
***********************************************************************************************************************************/
#define GZIP_DECOMPRESS_FILTER_TYPE "gzipDecompress"
STRING_STATIC(GZIP_DECOMPRESS_FILTER_TYPE_STR, GZIP_DECOMPRESS_FILTER_TYPE);
/***********************************************************************************************************************************
Object type
@ -57,7 +58,7 @@ gzipDecompressNew(bool raw)
// Create filter interface
this->filter = ioFilterNewP(
strNew(GZIP_DECOMPRESS_FILTER_TYPE), this, .done = (IoFilterInterfaceDone)gzipDecompressDone,
GZIP_DECOMPRESS_FILTER_TYPE_STR, this, .done = (IoFilterInterfaceDone)gzipDecompressDone,
.inOut = (IoFilterInterfaceProcessInOut)gzipDecompressProcess,
.inputSame = (IoFilterInterfaceInputSame)gzipDecompressInputSame);
}

View File

@ -10,6 +10,11 @@ Command and Option Configuration Definition
#include "common/error.h"
#include "config/define.h"
/***********************************************************************************************************************************
Define global section name
***********************************************************************************************************************************/
STRING_EXTERN(CFGDEF_SECTION_GLOBAL_STR, CFGDEF_SECTION_GLOBAL)
/***********************************************************************************************************************************
Map command names to ids and vice versa.
***********************************************************************************************************************************/

View File

@ -17,11 +17,13 @@ typedef enum
} ConfigDefSection;
#include "config/define.auto.h"
#include "common/type/string.h"
/***********************************************************************************************************************************
Define global section name
***********************************************************************************************************************************/
#define CFGDEF_SECTION_GLOBAL "global"
STRING_DECLARE(CFGDEF_SECTION_GLOBAL_STR)
/***********************************************************************************************************************************
Functions

View File

@ -22,6 +22,7 @@ Standard config file name and old default path and name
***********************************************************************************************************************************/
#define PGBACKREST_CONFIG_FILE PGBACKREST_BIN ".conf"
#define PGBACKREST_CONFIG_ORIG_PATH_FILE "/etc/" PGBACKREST_CONFIG_FILE
STRING_STATIC(PGBACKREST_CONFIG_ORIG_PATH_FILE_STR, PGBACKREST_CONFIG_FILE)
/***********************************************************************************************************************************
Prefix for environment variables
@ -108,7 +109,7 @@ convertToByte(String **value, double *valueDbl)
String *result = strLower(strDup(*value));
// Match the value against possible values
if (regExpMatchOne(strNew("^[0-9]+(kb|k|mb|m|gb|g|tb|t|pb|p|b)*$"), result))
if (regExpMatchOne(STRING_CONST("^[0-9]+(kb|k|mb|m|gb|g|tb|t|pb|p|b)*$"), result))
{
// Get the character array and size
const char *strArray = strPtr(result);
@ -315,7 +316,7 @@ cfgFileLoad( // NOTE: Pas
// Get a list of conf files from the specified path -error on missing directory if the option was passed on the command line
StringList *list = storageListP(
storageLocal(), configIncludePath, .expression = strNew(".+\\.conf$"), .errorOnMissing = configIncludeRequired);
storageLocal(), configIncludePath, .expression = STRING_CONST(".+\\.conf$"), .errorOnMissing = configIncludeRequired);
// If conf files are found, then add them to the config string
if (list != NULL && strLstSize(list) > 0)
@ -641,7 +642,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
String *configString = cfgFileLoad(parseOptionList,
strNew(cfgDefOptionDefault(commandDefId, cfgOptionDefIdFromId(cfgOptConfig))),
strNew(cfgDefOptionDefault(commandDefId, cfgOptionDefIdFromId(cfgOptConfigIncludePath))),
strNew(PGBACKREST_CONFIG_ORIG_PATH_FILE));
PGBACKREST_CONFIG_ORIG_PATH_FILE_STR);
if (configString != NULL)
{
@ -663,7 +664,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
}
strLstAdd(sectionList, strNewFmt(CFGDEF_SECTION_GLOBAL ":%s", cfgCommandName(cfgCommand())));
strLstAdd(sectionList, strNew(CFGDEF_SECTION_GLOBAL));
strLstAdd(sectionList, CFGDEF_SECTION_GLOBAL_STR);
// Loop through sections to search for options
for (unsigned int sectionIdx = 0; sectionIdx < strLstSize(sectionList); sectionIdx++)
@ -980,7 +981,8 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
String *value = strLstGet(parseOption->valueList, 0);
// If a numeric type check that the value is valid
if (optionDefType == cfgDefOptTypeInteger || optionDefType == cfgDefOptTypeFloat || optionDefType == cfgDefOptTypeSize)
if (optionDefType == cfgDefOptTypeInteger || optionDefType == cfgDefOptTypeFloat ||
optionDefType == cfgDefOptTypeSize)
{
double valueDbl = 0;

View File

@ -19,6 +19,14 @@ Cryptographic Hash
Filter type constant
***********************************************************************************************************************************/
#define CRYPTO_HASH_FILTER_TYPE "hash"
STRING_STATIC(CRYPTO_HASH_FILTER_TYPE_STR, CRYPTO_HASH_FILTER_TYPE);
/***********************************************************************************************************************************
Hash types
***********************************************************************************************************************************/
STRING_EXTERN(HASH_TYPE_MD5_STR, HASH_TYPE_MD5)
STRING_EXTERN(HASH_TYPE_SHA1_STR, HASH_TYPE_SHA1)
STRING_EXTERN(HASH_TYPE_SHA256_STR, HASH_TYPE_SHA256)
/***********************************************************************************************************************************
Object type
@ -72,7 +80,7 @@ cryptoHashNew(const String *type)
// Create filter interface
this->filter = ioFilterNewP(
strNew(CRYPTO_HASH_FILTER_TYPE), this, .in = (IoFilterInterfaceProcessIn)cryptoHashProcess,
CRYPTO_HASH_FILTER_TYPE_STR, this, .in = (IoFilterInterfaceProcessIn)cryptoHashProcess,
.result = (IoFilterInterfaceResult)cryptoHashResult);
}
MEM_CONTEXT_NEW_END();

View File

@ -18,8 +18,11 @@ typedef struct CryptoHash CryptoHash;
Hash types
***********************************************************************************************************************************/
#define HASH_TYPE_MD5 "md5"
STRING_DECLARE(HASH_TYPE_MD5_STR)
#define HASH_TYPE_SHA1 "sha1"
STRING_DECLARE(HASH_TYPE_SHA1_STR)
#define HASH_TYPE_SHA256 "sha256"
STRING_DECLARE(HASH_TYPE_SHA256_STR)
/***********************************************************************************************************************************
Constructor

View File

@ -19,9 +19,11 @@ Internal constants
***********************************************************************************************************************************/
#define INI_COPY_EXT ".copy"
#define INI_SECTION_BACKREST "backrest"
STRING_STATIC(INI_SECTION_BACKREST_STR, INI_SECTION_BACKREST)
#define INI_KEY_FORMAT "backrest-format"
#define INI_KEY_VERSION "backrest-version"
STRING_STATIC(INI_KEY_FORMAT_STR, INI_KEY_FORMAT)
#define INI_KEY_CHECKSUM "backrest-checksum"
STRING_STATIC(INI_KEY_CHECKSUM_STR, INI_KEY_CHECKSUM)
/***********************************************************************************************************************************
Object type
@ -45,7 +47,7 @@ infoHash(const Ini *ini)
FUNCTION_TEST_ASSERT(ini != NULL);
FUNCTION_TEST_END();
CryptoHash *result = cryptoHashNew(strNew(HASH_TYPE_SHA1));
CryptoHash *result = cryptoHashNew(HASH_TYPE_SHA1_STR);
MEM_CONTEXT_TEMP_BEGIN()
{
@ -77,8 +79,8 @@ infoHash(const Ini *ini)
String *key = strLstGet(keyList, keyIdx);
// Skip the backrest checksum in the file
if ((strEq(section, strNew(INI_SECTION_BACKREST)) && !strEq(key, strNew(INI_KEY_CHECKSUM))) ||
!strEq(section, strNew(INI_SECTION_BACKREST)))
if ((strEq(section, INI_SECTION_BACKREST_STR) && !strEq(key, INI_KEY_CHECKSUM_STR)) ||
!strEq(section, INI_SECTION_BACKREST_STR))
{
cryptoHashProcessC(result, (const unsigned char *)"\"", 1);
cryptoHashProcessStr(result, key);
@ -121,7 +123,7 @@ infoValidInternal(
MEM_CONTEXT_TEMP_BEGIN()
{
// Make sure the ini is valid by testing the checksum
String *infoChecksum = varStr(iniGet(this->ini, strNew(INI_SECTION_BACKREST), strNew(INI_KEY_CHECKSUM)));
String *infoChecksum = varStr(iniGet(this->ini, INI_SECTION_BACKREST_STR, INI_KEY_CHECKSUM_STR));
CryptoHash *hash = infoHash(this->ini);
@ -145,11 +147,12 @@ infoValidInternal(
}
// Make sure that the format is current, otherwise error
if (varIntForce(iniGet(this->ini, strNew(INI_SECTION_BACKREST), strNew(INI_KEY_FORMAT))) != PGBACKREST_FORMAT)
if (varIntForce(iniGet(this->ini, INI_SECTION_BACKREST_STR, INI_KEY_FORMAT_STR)) != PGBACKREST_FORMAT)
{
String *fmtMsg = strNewFmt("invalid format in '%s', expected %d but found %d",
strPtr(this->fileName), PGBACKREST_FORMAT, varIntForce(iniGet(this->ini, strNew(INI_SECTION_BACKREST),
strNew(INI_KEY_FORMAT))));
String *fmtMsg = strNewFmt(
"invalid format in '%s', expected %d but found %d",
strPtr(this->fileName), PGBACKREST_FORMAT,
varIntForce(iniGet(this->ini, INI_SECTION_BACKREST_STR, INI_KEY_FORMAT_STR)));
if (!ignoreError)
{

View File

@ -25,13 +25,19 @@ Internal constants
***********************************************************************************************************************************/
#define INFO_SECTION_DB "db"
#define INFO_SECTION_DB_HISTORY INFO_SECTION_DB ":history"
STRING_STATIC(INFO_SECTION_DB_HISTORY_STR, INFO_SECTION_DB_HISTORY)
#define INFO_SECTION_DB_MANIFEST "backup:" INFO_SECTION_DB
#define INFO_KEY_DB_ID "db-id"
STRING_STATIC(INFO_KEY_DB_ID_STR, INFO_KEY_DB_ID)
#define INFO_KEY_DB_CATALOG_VERSION "db-catalog-version"
STRING_STATIC(INFO_KEY_DB_CATALOG_VERSION_STR, INFO_KEY_DB_CATALOG_VERSION)
#define INFO_KEY_DB_CONTROL_VERSION "db-control-version"
STRING_STATIC(INFO_KEY_DB_CONTROL_VERSION_STR, INFO_KEY_DB_CONTROL_VERSION)
#define INFO_KEY_DB_SYSTEM_ID "db-system-id"
STRING_STATIC(INFO_KEY_DB_SYSTEM_ID_STR, INFO_KEY_DB_SYSTEM_ID)
#define INFO_KEY_DB_VERSION "db-version"
STRING_STATIC(INFO_KEY_DB_VERSION_STR, INFO_KEY_DB_VERSION)
/***********************************************************************************************************************************
Object type
@ -75,11 +81,11 @@ infoPgNew(const Storage *storage, const String *fileName, InfoPgType type)
MEM_CONTEXT_TEMP_BEGIN()
{
const Ini *infoPgIni = infoIni(this->info);
const String *pgHistorySection = strNew(INFO_SECTION_DB_HISTORY);
const String *pgHistorySection = INFO_SECTION_DB_HISTORY_STR;
const StringList *pgHistoryKey = iniSectionKeyList(infoPgIni, pgHistorySection);
const Variant *idKey = varNewStr(strNew(INFO_KEY_DB_ID));
const Variant *systemIdKey = varNewStr(strNew(INFO_KEY_DB_SYSTEM_ID));
const Variant *versionKey = varNewStr(strNew(INFO_KEY_DB_VERSION));
const Variant *idKey = varNewStr(INFO_KEY_DB_ID_STR);
const Variant *systemIdKey = varNewStr(INFO_KEY_DB_SYSTEM_ID_STR);
const Variant *versionKey = varNewStr(INFO_KEY_DB_VERSION_STR);
// History must include at least one item or the file is corrupt
ASSERT(strLstSize(pgHistoryKey) > 0);
@ -108,8 +114,8 @@ infoPgNew(const Storage *storage, const String *fileName, InfoPgType type)
// we must write them at least, even if we give up reading them.
if (type == infoPgBackup || type == infoPgManifest)
{
const Variant *catalogVersionKey = varNewStr(strNew(INFO_KEY_DB_CATALOG_VERSION));
const Variant *controlVersionKey = varNewStr(strNew(INFO_KEY_DB_CONTROL_VERSION));
const Variant *catalogVersionKey = varNewStr(INFO_KEY_DB_CATALOG_VERSION_STR);
const Variant *controlVersionKey = varNewStr(INFO_KEY_DB_CONTROL_VERSION_STR);
infoPgData.catalogVersion = (unsigned int)varUInt64Force(kvGet(pgDataKv, catalogVersionKey));
infoPgData.controlVersion = (unsigned int)varUInt64Force(kvGet(pgDataKv, controlVersionKey));

View File

@ -313,7 +313,7 @@ pgVersionFromStr(const String *version)
MEM_CONTEXT_TEMP_BEGIN()
{
// If format is not number.number (9.4) or number only (10) then error
if (!regExpMatchOne(strNew("^[0-9]+[.]*[0-9]+$"), version))
if (!regExpMatchOne(STRING_CONST("^[0-9]+[.]*[0-9]+$"), version))
THROW_FMT(AssertError, "version %s format is invalid", strPtr(version));
// If there is a dot set the major and minor versions, else just the major

View File

@ -56,7 +56,7 @@ storageDriverPosixFileReadNew(StorageDriverPosix *storage, const String *name, b
this->handle = -1;
this->interface = storageFileReadNewP(
strNew(STORAGE_DRIVER_POSIX_TYPE), this,
STORAGE_DRIVER_POSIX_TYPE_STR, this,
.ignoreMissing = (StorageFileReadInterfaceIgnoreMissing)storageDriverPosixFileReadIgnoreMissing,
.io = (StorageFileReadInterfaceIo)storageDriverPosixFileReadIo,
.name = (StorageFileReadInterfaceName)storageDriverPosixFileReadName);

View File

@ -77,7 +77,7 @@ storageDriverPosixFileWriteNew(
this->storage = storage;
this->interface = storageFileWriteNewP(
strNew(STORAGE_DRIVER_POSIX_TYPE), this, .atomic = (StorageFileWriteInterfaceAtomic)storageDriverPosixFileWriteAtomic,
STORAGE_DRIVER_POSIX_TYPE_STR, this, .atomic = (StorageFileWriteInterfaceAtomic)storageDriverPosixFileWriteAtomic,
.createPath = (StorageFileWriteInterfaceCreatePath)storageDriverPosixFileWriteCreatePath,
.io = (StorageFileWriteInterfaceIo)storageDriverPosixFileWriteIo,
.modeFile = (StorageFileWriteInterfaceModeFile)storageDriverPosixFileWriteModeFile,

View File

@ -20,6 +20,11 @@ Posix Storage Driver
#include "storage/driver/posix/storage.h"
#include "storage/driver/posix/common.h"
/***********************************************************************************************************************************
Driver type constant string
***********************************************************************************************************************************/
STRING_EXTERN(STORAGE_DRIVER_POSIX_TYPE_STR, STORAGE_DRIVER_POSIX_TYPE)
/***********************************************************************************************************************************
Object type
***********************************************************************************************************************************/
@ -55,7 +60,7 @@ storageDriverPosixNew(
this->memContext = MEM_CONTEXT_NEW();
this->interface = storageNewP(
strNew(STORAGE_DRIVER_POSIX_TYPE), path, modeFile, modePath, write, pathExpressionFunction, this,
STORAGE_DRIVER_POSIX_TYPE_STR, path, modeFile, modePath, write, pathExpressionFunction, this,
.exists = (StorageInterfaceExists)storageDriverPosixExists, .info = (StorageInterfaceInfo)storageDriverPosixInfo,
.list = (StorageInterfaceList)storageDriverPosixList, .move = (StorageInterfaceMove)storageDriverPosixMove,
.newRead = (StorageInterfaceNewRead)storageDriverPosixNewRead,

View File

@ -22,6 +22,7 @@ typedef struct StorageDriverPosix StorageDriverPosix;
Driver type constant
***********************************************************************************************************************************/
#define STORAGE_DRIVER_POSIX_TYPE "posix"
STRING_DECLARE(STORAGE_DRIVER_POSIX_TYPE_STR)
/***********************************************************************************************************************************
Constructor

View File

@ -10,6 +10,12 @@ Storage Helper
#include "storage/driver/posix/storage.h"
#include "storage/helper.h"
/***********************************************************************************************************************************
Storage path constants
***********************************************************************************************************************************/
STRING_EXTERN(STORAGE_SPOOL_ARCHIVE_IN_STR, STORAGE_SPOOL_ARCHIVE_IN);
STRING_EXTERN(STORAGE_SPOOL_ARCHIVE_OUT_STR, STORAGE_SPOOL_ARCHIVE_OUT);
/***********************************************************************************************************************************
Local variables
***********************************************************************************************************************************/
@ -88,7 +94,7 @@ storageLocal(void)
{
storageHelper.storageLocal = storageDriverPosixInterface(
storageDriverPosixNew(
strNew("/"), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, false, NULL));
FSLASH_STR, STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, false, NULL));
}
MEM_CONTEXT_END();
}
@ -114,7 +120,7 @@ storageLocalWrite(void)
{
storageHelper.storageLocalWrite = storageDriverPosixInterface(
storageDriverPosixNew(
strNew("/"), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL));
FSLASH_STR, STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL));
}
MEM_CONTEXT_END();
}
@ -204,7 +210,7 @@ storageRepo(void)
MEM_CONTEXT_BEGIN(storageHelper.memContext)
{
storageHelper.walRegExp = regExpNew(strNew("^[0-F]{24}"));
storageHelper.walRegExp = regExpNew(STRING_CONST("^[0-F]{24}"));
storageHelper.storageRepo = storageRepoGet(cfgOptionStr(cfgOptRepoType), false);
}
MEM_CONTEXT_END();

View File

@ -10,7 +10,9 @@ Storage Helper
Storage path constants
***********************************************************************************************************************************/
#define STORAGE_SPOOL_ARCHIVE_IN "<SPOOL:ARCHIVE:IN>"
STRING_DECLARE(STORAGE_SPOOL_ARCHIVE_IN_STR);
#define STORAGE_SPOOL_ARCHIVE_OUT "<SPOOL:ARCHIVE:OUT>"
STRING_DECLARE(STORAGE_SPOOL_ARCHIVE_OUT_STR);
#define STORAGE_REPO_ARCHIVE "<REPO:ARCHIVE>"