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

Automatically generate option value StringIds in make build-config.

Remove strIdGenerate() since bldStrId() performs the same function without cluttering the core code. Since bldStrId() is intended to work in non-debug builds, move the validity checks for input strings out of the DEBUG block.

StringIds are generated as 5/6 bit, whichever is most efficient, for each option value. cfgOptionStrIdInternal() has been updated for this logic.
This commit is contained in:
David Steele 2021-07-26 12:02:31 -04:00
parent eeaab6a3d1
commit 52d4574460
14 changed files with 154 additions and 112 deletions

View File

@ -50,4 +50,41 @@ bldPut(const Storage *const storage, const char *const file, const Buffer *const
storagePutP(storageNewWriteP(storage, STR(file), .noSyncPath = true), contentNew);
}
/***********************************************************************************************************************************
Generate constant StringIds
To generate a constant StringId call bldStrId(). It will return a String with the generated StringId macro.
For example:
bldStrId("test");
will return the following:
STRID5("test", 0xa4cb40)
which can be used in a function, switch, or #define, e.g.:
#define TEST_STRID STRID5("test", 0xa4cb40)
DO NOT MODIFY either parameter in the macro -- ALWAYS use bldStrId() to create a new constant StringId.
***********************************************************************************************************************************/
String *
bldStrId(const char *const buffer)
{
StringId result = 0;
TRY_BEGIN()
{
result = strIdFromZ(stringIdBit5, buffer);
}
CATCH_ANY()
{
result = strIdFromZ(stringIdBit6, buffer);
}
TRY_END();
return strNewFmt("STRID%u(\"%s\", 0x%" PRIx64 ")", (unsigned int)(result & STRING_ID_BIT_MASK) + 5, buffer, result);
}
#endif

View File

@ -196,14 +196,16 @@ bldCfgRender(const Storage *const storageRepo, const BldCfg bldCfg)
for (unsigned int allowListIdx = 0; allowListIdx < strLstSize(allowList); allowListIdx++)
{
const String *const allowListItem = strLstGet(allowList, allowListIdx);
const String *const constPrefix = strUpper(
strReplaceChr(strNewFmt("CFGOPTVAL_%s_%s", strZ(opt->name), strZ(allowListItem)), '-', '_'));
// Render StringId
strCatFmt(config, "%s\n", strZ(bldDefineRender(constPrefix, bldStrId(strZ(allowListItem)))));
// Render Z
strCatFmt(
config, "%s\n",
strZ(
bldDefineRender(
strUpper(
strReplaceChr(strNewFmt("CFGOPTVAL_%s_%s_Z", strZ(opt->name), strZ(allowListItem)), '-', '_')),
strNewFmt("\"%s\"", strZ(allowListItem)))));
strZ(bldDefineRender(strNewFmt("%s_Z", strZ(constPrefix)), strNewFmt("\"%s\"", strZ(allowListItem)))));
}
lf = true;

View File

@ -54,7 +54,6 @@ strIdFromZN(const StringIdBit bit, const char *const buffer, const size_t size)
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
#ifdef DEBUG
// Make sure the string is valid for this encoding
for (size_t bufferIdx = 0; bufferIdx < size; bufferIdx++)
{
@ -64,7 +63,6 @@ strIdFromZN(const StringIdBit bit, const char *const buffer, const size_t size)
if (map[(uint8_t)buffer[bufferIdx]] == 0)
THROW_FMT(FormatError, "'%c' is invalid for 5-bit encoding in '%s'", buffer[bufferIdx], buffer);
}
#endif
// Set encoding in header
uint64_t result = stringIdBit5;
@ -144,7 +142,6 @@ strIdFromZN(const StringIdBit bit, const char *const buffer, const size_t size)
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
#ifdef DEBUG
// Make sure the string is valid for this encoding
for (size_t bufferIdx = 0; bufferIdx < size; bufferIdx++)
{
@ -154,7 +151,6 @@ strIdFromZN(const StringIdBit bit, const char *const buffer, const size_t size)
if (map[(uint8_t)buffer[bufferIdx]] == 0)
THROW_FMT(FormatError, "'%c' is invalid for 6-bit encoding in '%s'", buffer[bufferIdx], buffer);
}
#endif
// Set encoding in header
uint64_t result = stringIdBit6;
@ -341,30 +337,6 @@ strIdToZ(const StringId strId, char *const buffer)
FUNCTION_TEST_RETURN(size);
}
/**********************************************************************************************************************************/
#ifdef DEBUG
void
strIdGenerate(const char *const buffer)
{
StringId result = 0;
TRY_BEGIN()
{
result = strIdFromZ(stringIdBit5, buffer);
}
CATCH_ANY()
{
result = strIdFromZ(stringIdBit6, buffer);
}
TRY_END();
THROW_FMT(FormatError, "STRID%u(\"%s\", 0x%" PRIx64 ")", (unsigned int)(result & STRING_ID_BIT_MASK) + 5, buffer, result);
}
#endif
/**********************************************************************************************************************************/
size_t
strIdToLog(const StringId strId, char *const buffer, const size_t bufferSize)

View File

@ -17,7 +17,7 @@ When assigning a StringId to an enum, it will be necessary to cast the StringId
values, since some compilers will complain about the implicit conversion without a cast. The enum will be 32-bit if all values of
the enum are <= 0xffffffff.
See strIdGenerate() for information on StringId constants.
See bldStrId() for information on generating StringId constants.
***********************************************************************************************************************************/
#ifndef COMMON_TYPE_STRINGID_H
#define COMMON_TYPE_STRINGID_H
@ -40,6 +40,11 @@ when calling strIdToZN. If the buffer needs to be zero-terminated then an extra
// Maximum for any encoding
#define STRID_MAX STRID5_MAX
/***********************************************************************************************************************************
Constants used to extract information from the header
***********************************************************************************************************************************/
#define STRING_ID_BIT_MASK 3
/***********************************************************************************************************************************
StringId typedef to make them more recognizable in the code
***********************************************************************************************************************************/
@ -55,8 +60,8 @@ typedef enum
} StringIdBit;
/***********************************************************************************************************************************
Macros to define constant StringIds. ALWAYS use strIdGenerate() to create these macros. The parameters in the macros are not
verified against each other so the str parameter is included only for documentation purposes.
Macros to define constant StringIds. ALWAYS use bldStrId() to create these macros. The parameters in the macros are not verified
against each other so the str parameter is included only for documentation purposes.
***********************************************************************************************************************************/
#define STRID5(str, strId) strId
#define STRID6(str, strId) strId
@ -94,31 +99,6 @@ String *strIdToStr(const StringId strId);
// Convert StringId to zero-terminated string. See strIdToZN() for buffer sizing and return value.
size_t strIdToZ(const StringId strId, char *const buffer);
/***********************************************************************************************************************************
Generate constant StringIds
To generate a constant StringId call strIdGenerate() in any debug build. It will throw an error with the generated StringId macro
in the error message.
For example:
strIdGenerate("test");
will throw the following error message:
STRID5("test", 0xa4cb40)
which can be used in a function, switch, or #define, e.g.:
#define TEST_STRID STRID5("test", 0xa4cb40)
DO NOT MODIFY either parameter in the macro -- ALWAYS use strIdGenerate() to create a new constant StringId.
***********************************************************************************************************************************/
#ifdef DEBUG
// Generate a new constant StringId
void strIdGenerate(const char *const buffer) __attribute__((__noreturn__));
#endif
/***********************************************************************************************************************************
Macros for function logging
***********************************************************************************************************************************/

View File

@ -122,93 +122,164 @@ Option constants
/***********************************************************************************************************************************
Option value constants
***********************************************************************************************************************************/
#define CFGOPTVAL_ARCHIVE_MODE_OFF STRID5("off", 0x18cf0)
#define CFGOPTVAL_ARCHIVE_MODE_OFF_Z "off"
#define CFGOPTVAL_ARCHIVE_MODE_PRESERVE STRID5("preserve", 0x2da45996500)
#define CFGOPTVAL_ARCHIVE_MODE_PRESERVE_Z "preserve"
#define CFGOPTVAL_COMPRESS_TYPE_BZ2 STRID5("bz2", 0x73420)
#define CFGOPTVAL_COMPRESS_TYPE_BZ2_Z "bz2"
#define CFGOPTVAL_COMPRESS_TYPE_GZ STRID5("gz", 0x3470)
#define CFGOPTVAL_COMPRESS_TYPE_GZ_Z "gz"
#define CFGOPTVAL_COMPRESS_TYPE_LZ4 STRID6("lz4", 0x2068c1)
#define CFGOPTVAL_COMPRESS_TYPE_LZ4_Z "lz4"
#define CFGOPTVAL_COMPRESS_TYPE_NONE STRID5("none", 0x2b9ee0)
#define CFGOPTVAL_COMPRESS_TYPE_NONE_Z "none"
#define CFGOPTVAL_COMPRESS_TYPE_ZST STRID5("zst", 0x527a0)
#define CFGOPTVAL_COMPRESS_TYPE_ZST_Z "zst"
#define CFGOPTVAL_LOG_LEVEL_CONSOLE_DEBUG STRID5("debug", 0x7a88a40)
#define CFGOPTVAL_LOG_LEVEL_CONSOLE_DEBUG_Z "debug"
#define CFGOPTVAL_LOG_LEVEL_CONSOLE_DETAIL STRID5("detail", 0x1890d0a40)
#define CFGOPTVAL_LOG_LEVEL_CONSOLE_DETAIL_Z "detail"
#define CFGOPTVAL_LOG_LEVEL_CONSOLE_ERROR STRID5("error", 0x127ca450)
#define CFGOPTVAL_LOG_LEVEL_CONSOLE_ERROR_Z "error"
#define CFGOPTVAL_LOG_LEVEL_CONSOLE_INFO STRID5("info", 0x799c90)
#define CFGOPTVAL_LOG_LEVEL_CONSOLE_INFO_Z "info"
#define CFGOPTVAL_LOG_LEVEL_CONSOLE_OFF STRID5("off", 0x18cf0)
#define CFGOPTVAL_LOG_LEVEL_CONSOLE_OFF_Z "off"
#define CFGOPTVAL_LOG_LEVEL_CONSOLE_TRACE STRID5("trace", 0x5186540)
#define CFGOPTVAL_LOG_LEVEL_CONSOLE_TRACE_Z "trace"
#define CFGOPTVAL_LOG_LEVEL_CONSOLE_WARN STRID5("warn", 0x748370)
#define CFGOPTVAL_LOG_LEVEL_CONSOLE_WARN_Z "warn"
#define CFGOPTVAL_LOG_LEVEL_FILE_DEBUG STRID5("debug", 0x7a88a40)
#define CFGOPTVAL_LOG_LEVEL_FILE_DEBUG_Z "debug"
#define CFGOPTVAL_LOG_LEVEL_FILE_DETAIL STRID5("detail", 0x1890d0a40)
#define CFGOPTVAL_LOG_LEVEL_FILE_DETAIL_Z "detail"
#define CFGOPTVAL_LOG_LEVEL_FILE_ERROR STRID5("error", 0x127ca450)
#define CFGOPTVAL_LOG_LEVEL_FILE_ERROR_Z "error"
#define CFGOPTVAL_LOG_LEVEL_FILE_INFO STRID5("info", 0x799c90)
#define CFGOPTVAL_LOG_LEVEL_FILE_INFO_Z "info"
#define CFGOPTVAL_LOG_LEVEL_FILE_OFF STRID5("off", 0x18cf0)
#define CFGOPTVAL_LOG_LEVEL_FILE_OFF_Z "off"
#define CFGOPTVAL_LOG_LEVEL_FILE_TRACE STRID5("trace", 0x5186540)
#define CFGOPTVAL_LOG_LEVEL_FILE_TRACE_Z "trace"
#define CFGOPTVAL_LOG_LEVEL_FILE_WARN STRID5("warn", 0x748370)
#define CFGOPTVAL_LOG_LEVEL_FILE_WARN_Z "warn"
#define CFGOPTVAL_LOG_LEVEL_STDERR_DEBUG STRID5("debug", 0x7a88a40)
#define CFGOPTVAL_LOG_LEVEL_STDERR_DEBUG_Z "debug"
#define CFGOPTVAL_LOG_LEVEL_STDERR_DETAIL STRID5("detail", 0x1890d0a40)
#define CFGOPTVAL_LOG_LEVEL_STDERR_DETAIL_Z "detail"
#define CFGOPTVAL_LOG_LEVEL_STDERR_ERROR STRID5("error", 0x127ca450)
#define CFGOPTVAL_LOG_LEVEL_STDERR_ERROR_Z "error"
#define CFGOPTVAL_LOG_LEVEL_STDERR_INFO STRID5("info", 0x799c90)
#define CFGOPTVAL_LOG_LEVEL_STDERR_INFO_Z "info"
#define CFGOPTVAL_LOG_LEVEL_STDERR_OFF STRID5("off", 0x18cf0)
#define CFGOPTVAL_LOG_LEVEL_STDERR_OFF_Z "off"
#define CFGOPTVAL_LOG_LEVEL_STDERR_TRACE STRID5("trace", 0x5186540)
#define CFGOPTVAL_LOG_LEVEL_STDERR_TRACE_Z "trace"
#define CFGOPTVAL_LOG_LEVEL_STDERR_WARN STRID5("warn", 0x748370)
#define CFGOPTVAL_LOG_LEVEL_STDERR_WARN_Z "warn"
#define CFGOPTVAL_OUTPUT_JSON STRID5("json", 0x73e6a0)
#define CFGOPTVAL_OUTPUT_JSON_Z "json"
#define CFGOPTVAL_OUTPUT_TEXT STRID5("text", 0xa60b40)
#define CFGOPTVAL_OUTPUT_TEXT_Z "text"
#define CFGOPTVAL_REMOTE_TYPE_PG STRID5("pg", 0xf00)
#define CFGOPTVAL_REMOTE_TYPE_PG_Z "pg"
#define CFGOPTVAL_REMOTE_TYPE_REPO STRID5("repo", 0x7c0b20)
#define CFGOPTVAL_REMOTE_TYPE_REPO_Z "repo"
#define CFGOPTVAL_REPO_AZURE_KEY_TYPE_SAS STRID5("sas", 0x4c330)
#define CFGOPTVAL_REPO_AZURE_KEY_TYPE_SAS_Z "sas"
#define CFGOPTVAL_REPO_AZURE_KEY_TYPE_SHARED STRID5("shared", 0x85905130)
#define CFGOPTVAL_REPO_AZURE_KEY_TYPE_SHARED_Z "shared"
#define CFGOPTVAL_REPO_CIPHER_TYPE_AES_256_CBC STRID5("aes-256-cbc", 0xc43dfbbcdcca10)
#define CFGOPTVAL_REPO_CIPHER_TYPE_AES_256_CBC_Z "aes-256-cbc"
#define CFGOPTVAL_REPO_CIPHER_TYPE_NONE STRID5("none", 0x2b9ee0)
#define CFGOPTVAL_REPO_CIPHER_TYPE_NONE_Z "none"
#define CFGOPTVAL_REPO_GCS_KEY_TYPE_AUTO STRID5("auto", 0x7d2a10)
#define CFGOPTVAL_REPO_GCS_KEY_TYPE_AUTO_Z "auto"
#define CFGOPTVAL_REPO_GCS_KEY_TYPE_SERVICE STRID5("service", 0x1469b48b30)
#define CFGOPTVAL_REPO_GCS_KEY_TYPE_SERVICE_Z "service"
#define CFGOPTVAL_REPO_GCS_KEY_TYPE_TOKEN STRID5("token", 0xe2adf40)
#define CFGOPTVAL_REPO_GCS_KEY_TYPE_TOKEN_Z "token"
#define CFGOPTVAL_REPO_RETENTION_ARCHIVE_TYPE_DIFF STRID5("diff", 0x319240)
#define CFGOPTVAL_REPO_RETENTION_ARCHIVE_TYPE_DIFF_Z "diff"
#define CFGOPTVAL_REPO_RETENTION_ARCHIVE_TYPE_FULL STRID5("full", 0x632a60)
#define CFGOPTVAL_REPO_RETENTION_ARCHIVE_TYPE_FULL_Z "full"
#define CFGOPTVAL_REPO_RETENTION_ARCHIVE_TYPE_INCR STRID5("incr", 0x90dc90)
#define CFGOPTVAL_REPO_RETENTION_ARCHIVE_TYPE_INCR_Z "incr"
#define CFGOPTVAL_REPO_RETENTION_FULL_TYPE_COUNT STRID5("count", 0x14755e30)
#define CFGOPTVAL_REPO_RETENTION_FULL_TYPE_COUNT_Z "count"
#define CFGOPTVAL_REPO_RETENTION_FULL_TYPE_TIME STRID5("time", 0x2b5340)
#define CFGOPTVAL_REPO_RETENTION_FULL_TYPE_TIME_Z "time"
#define CFGOPTVAL_REPO_S3_KEY_TYPE_AUTO STRID5("auto", 0x7d2a10)
#define CFGOPTVAL_REPO_S3_KEY_TYPE_AUTO_Z "auto"
#define CFGOPTVAL_REPO_S3_KEY_TYPE_SHARED STRID5("shared", 0x85905130)
#define CFGOPTVAL_REPO_S3_KEY_TYPE_SHARED_Z "shared"
#define CFGOPTVAL_REPO_S3_URI_STYLE_HOST STRID5("host", 0xa4de80)
#define CFGOPTVAL_REPO_S3_URI_STYLE_HOST_Z "host"
#define CFGOPTVAL_REPO_S3_URI_STYLE_PATH STRID5("path", 0x450300)
#define CFGOPTVAL_REPO_S3_URI_STYLE_PATH_Z "path"
#define CFGOPTVAL_REPO_TYPE_AZURE STRID5("azure", 0x5957410)
#define CFGOPTVAL_REPO_TYPE_AZURE_Z "azure"
#define CFGOPTVAL_REPO_TYPE_CIFS STRID5("cifs", 0x999230)
#define CFGOPTVAL_REPO_TYPE_CIFS_Z "cifs"
#define CFGOPTVAL_REPO_TYPE_GCS STRID5("gcs", 0x4c670)
#define CFGOPTVAL_REPO_TYPE_GCS_Z "gcs"
#define CFGOPTVAL_REPO_TYPE_POSIX STRID5("posix", 0x184cdf00)
#define CFGOPTVAL_REPO_TYPE_POSIX_Z "posix"
#define CFGOPTVAL_REPO_TYPE_S3 STRID6("s3", 0x7d31)
#define CFGOPTVAL_REPO_TYPE_S3_Z "s3"
#define CFGOPTVAL_SORT_ASC STRID5("asc", 0xe610)
#define CFGOPTVAL_SORT_ASC_Z "asc"
#define CFGOPTVAL_SORT_DESC STRID5("desc", 0x1cca40)
#define CFGOPTVAL_SORT_DESC_Z "desc"
#define CFGOPTVAL_SORT_NONE STRID5("none", 0x2b9ee0)
#define CFGOPTVAL_SORT_NONE_Z "none"
#define CFGOPTVAL_TARGET_ACTION_PAUSE STRID5("pause", 0x59d4300)
#define CFGOPTVAL_TARGET_ACTION_PAUSE_Z "pause"
#define CFGOPTVAL_TARGET_ACTION_PROMOTE STRID5("promote", 0x168f6be500)
#define CFGOPTVAL_TARGET_ACTION_PROMOTE_Z "promote"
#define CFGOPTVAL_TARGET_ACTION_SHUTDOWN STRID5("shutdown", 0x75de4a55130)
#define CFGOPTVAL_TARGET_ACTION_SHUTDOWN_Z "shutdown"
#define CFGOPTVAL_TYPE_DEFAULT STRID5("default", 0x5195098a40)
#define CFGOPTVAL_TYPE_DEFAULT_Z "default"
#define CFGOPTVAL_TYPE_DIFF STRID5("diff", 0x319240)
#define CFGOPTVAL_TYPE_DIFF_Z "diff"
#define CFGOPTVAL_TYPE_FULL STRID5("full", 0x632a60)
#define CFGOPTVAL_TYPE_FULL_Z "full"
#define CFGOPTVAL_TYPE_IMMEDIATE STRID5("immediate", 0x5a05242b5a90)
#define CFGOPTVAL_TYPE_IMMEDIATE_Z "immediate"
#define CFGOPTVAL_TYPE_INCR STRID5("incr", 0x90dc90)
#define CFGOPTVAL_TYPE_INCR_Z "incr"
#define CFGOPTVAL_TYPE_LSN STRID5("lsn", 0x3a6c0)
#define CFGOPTVAL_TYPE_LSN_Z "lsn"
#define CFGOPTVAL_TYPE_NAME STRID5("name", 0x2b42e0)
#define CFGOPTVAL_TYPE_NAME_Z "name"
#define CFGOPTVAL_TYPE_NONE STRID5("none", 0x2b9ee0)
#define CFGOPTVAL_TYPE_NONE_Z "none"
#define CFGOPTVAL_TYPE_PRESERVE STRID5("preserve", 0x2da45996500)
#define CFGOPTVAL_TYPE_PRESERVE_Z "preserve"
#define CFGOPTVAL_TYPE_STANDBY STRID5("standby", 0x6444706930)
#define CFGOPTVAL_TYPE_STANDBY_Z "standby"
#define CFGOPTVAL_TYPE_TIME STRID5("time", 0x2b5340)
#define CFGOPTVAL_TYPE_TIME_Z "time"
#define CFGOPTVAL_TYPE_XID STRID5("xid", 0x11380)
#define CFGOPTVAL_TYPE_XID_Z "xid"
/***********************************************************************************************************************************

View File

@ -1149,11 +1149,19 @@ cfgOptionStrIdInternal(
FUNCTION_TEST_END();
const String *const value = varStr(cfgOptionIdxInternal(optionId, optionIdx, varTypeString, false));
StringId result = 0;
if (optionId == cfgOptRepoType)
FUNCTION_TEST_RETURN(strIdFromStr(stringIdBit6, value));
TRY_BEGIN()
{
result = strIdFromStr(stringIdBit5, value);
}
CATCH_ANY()
{
result = strIdFromStr(stringIdBit6, value);
}
TRY_END();
FUNCTION_TEST_RETURN(strIdFromStr(stringIdBit5, value));
FUNCTION_TEST_RETURN(result);
}
StringId

View File

@ -42,39 +42,6 @@ typedef enum
#define CFG_COMMAND_ROLE_TOTAL 4
/***********************************************************************************************************************************
Constants for configuration option values
??? These should be generated automatically but for now just put them here so they are easy to find when it is time to replace them
with the auto-generated values. Note that the _Z variants of these constants are auto-generated.
***********************************************************************************************************************************/
#define CFGOPTVAL_ARCHIVE_MODE_OFF STRID5("off", 0x18cf0)
#define CFGOPTVAL_ARCHIVE_MODE_PRESERVE STRID5("preserve", 0x2da45996500)
#define CFGOPTVAL_OUTPUT_TEXT STRID5("text", 0xa60b40)
#define CFGOPTVAL_OUTPUT_JSON STRID5("json", 0x73e6a0)
#define CFGOPTVAL_REPO_RETENTION_ARCHIVE_TYPE_DIFF STRID5("diff", 0x319240)
#define CFGOPTVAL_REPO_RETENTION_ARCHIVE_TYPE_FULL STRID5("full", 0x632a60)
#define CFGOPTVAL_REPO_RETENTION_ARCHIVE_TYPE_INCR STRID5("incr", 0x90dc90)
#define CFGOPTVAL_REPO_RETENTION_FULL_TYPE_COUNT STRID5("count", 0x14755e30)
#define CFGOPTVAL_REPO_RETENTION_FULL_TYPE_TIME STRID5("time", 0x2b5340)
#define CFGOPTVAL_TARGET_ACTION_PAUSE STRID5("pause", 0x59d4300)
#define CFGOPTVAL_TARGET_ACTION_SHUTDOWN STRID5("shutdown", 0x75de4a55130)
#define CFGOPTVAL_SORT_ASC STRID5("asc", 0xe610)
#define CFGOPTVAL_SORT_DESC STRID5("desc", 0x1cca40)
#define CFGOPTVAL_SORT_NONE STRID5("none", 0x2b9ee0)
#define CFGOPTVAL_TYPE_DEFAULT STRID5("default", 0x5195098a40)
#define CFGOPTVAL_TYPE_IMMEDIATE STRID5("immediate", 0x5a05242b5a90)
#define CFGOPTVAL_TYPE_NONE STRID5("none", 0x2b9ee0)
#define CFGOPTVAL_TYPE_PRESERVE STRID5("preserve", 0x2da45996500)
#define CFGOPTVAL_TYPE_STANDBY STRID5("standby", 0x6444706930)
#define CFGOPTVAL_TYPE_TIME STRID5("time", 0x2b5340)
/***********************************************************************************************************************************
Command Functions

View File

@ -9,7 +9,7 @@ Azure Storage
/***********************************************************************************************************************************
Storage type
***********************************************************************************************************************************/
#define STORAGE_AZURE_TYPE STRID6("azure", 0x54956811)
#define STORAGE_AZURE_TYPE STRID5("azure", 0x5957410)
/***********************************************************************************************************************************
Key type

View File

@ -9,7 +9,7 @@ CIFS Storage
/***********************************************************************************************************************************
Storage type
***********************************************************************************************************************************/
#define STORAGE_CIFS_TYPE STRID6("cifs", 0x4c62431)
#define STORAGE_CIFS_TYPE STRID5("cifs", 0x999230)
/***********************************************************************************************************************************
Constructors

View File

@ -9,7 +9,7 @@ GCS Storage
/***********************************************************************************************************************************
Storage type
***********************************************************************************************************************************/
#define STORAGE_GCS_TYPE STRID6("gcs", 0x130c71)
#define STORAGE_GCS_TYPE STRID5("gcs", 0x4c670)
/***********************************************************************************************************************************
Key type

View File

@ -14,7 +14,7 @@ typedef struct StoragePosix StoragePosix;
/***********************************************************************************************************************************
Storage type
***********************************************************************************************************************************/
#define STORAGE_POSIX_TYPE STRID6("posix", 0x182533d01)
#define STORAGE_POSIX_TYPE STRID5("posix", 0x184cdf00)
/***********************************************************************************************************************************
Constructors

View File

@ -10,7 +10,7 @@ Remote Storage
/***********************************************************************************************************************************
Storage type
***********************************************************************************************************************************/
#define STORAGE_REMOTE_TYPE STRID6("remote", 0x1543cd1521)
#define STORAGE_REMOTE_TYPE STRID5("remote", 0xb47b4b20)
/***********************************************************************************************************************************
Constructors

View File

@ -176,7 +176,7 @@ testRun(void)
" - off\n"
" - error\n"
" - warn\n"
" - debug\n"
" - debug1\n"
"\n"
" log-level-file:\n"
" section: global\n"
@ -248,14 +248,22 @@ testRun(void)
COMMENT_BLOCK_BEGIN "\n"
"Option value constants\n"
COMMENT_BLOCK_END "\n"
"#define CFGOPTVAL_LOG_LEVEL_CONSOLE_DEBUG_Z \"debug\"\n"
"#define CFGOPTVAL_LOG_LEVEL_CONSOLE_DEBUG1 STRID6(\"debug1\", 0x7475421441)\n"
"#define CFGOPTVAL_LOG_LEVEL_CONSOLE_DEBUG1_Z \"debug1\"\n"
"#define CFGOPTVAL_LOG_LEVEL_CONSOLE_ERROR STRID5(\"error\", 0x127ca450)\n"
"#define CFGOPTVAL_LOG_LEVEL_CONSOLE_ERROR_Z \"error\"\n"
"#define CFGOPTVAL_LOG_LEVEL_CONSOLE_OFF STRID5(\"off\", 0x18cf0)\n"
"#define CFGOPTVAL_LOG_LEVEL_CONSOLE_OFF_Z \"off\"\n"
"#define CFGOPTVAL_LOG_LEVEL_CONSOLE_WARN STRID5(\"warn\", 0x748370)\n"
"#define CFGOPTVAL_LOG_LEVEL_CONSOLE_WARN_Z \"warn\"\n"
"\n"
"#define CFGOPTVAL_LOG_LEVEL_FILE_DEBUG_Z \"debug\"\n"
"#define CFGOPTVAL_LOG_LEVEL_FILE_DEBUG1 STRID6(\"debug1\", 0x7475421441)\n"
"#define CFGOPTVAL_LOG_LEVEL_FILE_DEBUG1_Z \"debug1\"\n"
"#define CFGOPTVAL_LOG_LEVEL_FILE_ERROR STRID5(\"error\", 0x127ca450)\n"
"#define CFGOPTVAL_LOG_LEVEL_FILE_ERROR_Z \"error\"\n"
"#define CFGOPTVAL_LOG_LEVEL_FILE_OFF STRID5(\"off\", 0x18cf0)\n"
"#define CFGOPTVAL_LOG_LEVEL_FILE_OFF_Z \"off\"\n"
"#define CFGOPTVAL_LOG_LEVEL_FILE_WARN STRID5(\"warn\", 0x748370)\n"
"#define CFGOPTVAL_LOG_LEVEL_FILE_WARN_Z \"warn\"\n"
"\n"
COMMENT_BLOCK_BEGIN "\n"

View File

@ -545,6 +545,8 @@ testRun(void)
TEST_RESULT_UINT(strIdFromZN(stringIdBit5, "abc-zkz2-y56?", 13), TEST_STR5ID13, "5 bits 13 chars");
TEST_RESULT_UINT(strIdFromZN(stringIdBit5, "abc-zkz2-y56??", 14), TEST_STR5ID13, "5 bits 14 chars");
TEST_ERROR(strIdFromZN(stringIdBit5, "AB", 2), FormatError, "'A' is invalid for 5-bit encoding in 'AB'");
#define TEST_STR6ID1 (stringIdBit6 | (uint16_t)('a' - 96) << 4)
#define TEST_STR6ID2 (TEST_STR6ID1 | (uint16_t)('b' - 96) << 10)
#define TEST_STR6ID3 ((uint32_t)TEST_STR6ID2 | (uint32_t)('C' - 27) << 16)
@ -563,6 +565,8 @@ testRun(void)
TEST_RESULT_UINT(strIdFromZN(stringIdBit6, "abC-40MzZ9?", 11), TEST_STR6ID11, "6 bits 11 chars");
TEST_RESULT_UINT(strIdFromZN(stringIdBit6, "abC-40MzZ9??", 12), TEST_STR6ID11, "6 bits 12 chars");
TEST_ERROR(strIdFromZN(stringIdBit6, "|B", 2), FormatError, "'|' is invalid for 6-bit encoding in '|B'");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("STRID*()");
@ -662,13 +666,6 @@ testRun(void)
TEST_RESULT_STR_Z(strIdToStr(testStringIdEnumTest), "test", "pass to StringId param");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("strIdGenerate()");
TEST_ERROR(strIdGenerate("watcha"), FormatError, "STRID5(\"watcha\", 0x281d0370)");
TEST_ERROR(strIdGenerate("Watcha"), FormatError, "STRID6(\"Watcha\", 0x480d407c1)");
TEST_ERROR(strIdGenerate("%tcha"), FormatError, "'%' is invalid for 6-bit encoding in '%tcha'");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("strIdToLog()");