diff --git a/Bdd/Targets/Common/BddTargetMtlsConfig.c b/Bdd/Targets/Common/BddTargetMtlsConfig.c index 460eb70a..435706e3 100644 --- a/Bdd/Targets/Common/BddTargetMtlsConfig.c +++ b/Bdd/Targets/Common/BddTargetMtlsConfig.c @@ -60,8 +60,8 @@ const char* BddTargetMtlsConfig_GetClientKeyPath(void) void BddTargetMtlsConfig_GetEndpoint(struct SolidSyslogEndpoint* endpoint) { - SolidSyslogFormatter_BoundedString(endpoint->host, BddTargetMtlsConfig_GetHost(), SOLIDSYSLOG_MAX_HOST_SIZE); - endpoint->port = BddTargetMtlsConfig_GetPort(); + SolidSyslogFormatter_BoundedString(endpoint->Host, BddTargetMtlsConfig_GetHost(), SOLIDSYSLOG_MAX_HOST_SIZE); + endpoint->Port = BddTargetMtlsConfig_GetPort(); } /* Static config — host/port never change, so version stays 0 forever and the diff --git a/Bdd/Targets/Common/BddTargetTlsConfig.c b/Bdd/Targets/Common/BddTargetTlsConfig.c index e2c8ea24..f6e77807 100644 --- a/Bdd/Targets/Common/BddTargetTlsConfig.c +++ b/Bdd/Targets/Common/BddTargetTlsConfig.c @@ -43,8 +43,8 @@ const char* BddTargetTlsConfig_GetServerName(void) void BddTargetTlsConfig_GetEndpoint(struct SolidSyslogEndpoint* endpoint) { - SolidSyslogFormatter_BoundedString(endpoint->host, BddTargetTlsConfig_GetHost(), SOLIDSYSLOG_MAX_HOST_SIZE); - endpoint->port = BddTargetTlsConfig_GetPort(); + SolidSyslogFormatter_BoundedString(endpoint->Host, BddTargetTlsConfig_GetHost(), SOLIDSYSLOG_MAX_HOST_SIZE); + endpoint->Port = BddTargetTlsConfig_GetPort(); } /* Static config — host/port never change, so version stays 0 forever and the diff --git a/Bdd/Targets/Common/BddTargetTlsSender_OpenSsl_PosixTcp.c b/Bdd/Targets/Common/BddTargetTlsSender_OpenSsl_PosixTcp.c index 6a5698f1..7b6db1a0 100644 --- a/Bdd/Targets/Common/BddTargetTlsSender_OpenSsl_PosixTcp.c +++ b/Bdd/Targets/Common/BddTargetTlsSender_OpenSsl_PosixTcp.c @@ -23,28 +23,28 @@ struct SolidSyslogSender* BddTargetTlsSender_Create(struct SolidSyslogResolver* static struct SolidSyslogTlsStreamConfig tlsStreamConfig; tlsStreamConfig = (struct SolidSyslogTlsStreamConfig) {0}; - tlsStreamConfig.transport = underlyingStream; - tlsStreamConfig.sleep = SolidSyslogPosixSleep; + tlsStreamConfig.Transport = underlyingStream; + tlsStreamConfig.Sleep = SolidSyslogPosixSleep; if (mtls) { - tlsStreamConfig.caBundlePath = BddTargetMtlsConfig_GetCaBundlePath(); - tlsStreamConfig.serverName = BddTargetMtlsConfig_GetServerName(); - tlsStreamConfig.clientCertChainPath = BddTargetMtlsConfig_GetClientCertChainPath(); - tlsStreamConfig.clientKeyPath = BddTargetMtlsConfig_GetClientKeyPath(); + tlsStreamConfig.CaBundlePath = BddTargetMtlsConfig_GetCaBundlePath(); + tlsStreamConfig.ServerName = BddTargetMtlsConfig_GetServerName(); + tlsStreamConfig.ClientCertChainPath = BddTargetMtlsConfig_GetClientCertChainPath(); + tlsStreamConfig.ClientKeyPath = BddTargetMtlsConfig_GetClientKeyPath(); } else { - tlsStreamConfig.caBundlePath = BddTargetTlsConfig_GetCaBundlePath(); - tlsStreamConfig.serverName = BddTargetTlsConfig_GetServerName(); + tlsStreamConfig.CaBundlePath = BddTargetTlsConfig_GetCaBundlePath(); + tlsStreamConfig.ServerName = BddTargetTlsConfig_GetServerName(); } tlsStream = SolidSyslogTlsStream_Create(&tlsStreamStorage, &tlsStreamConfig); static struct SolidSyslogStreamSenderConfig senderConfig; senderConfig = (struct SolidSyslogStreamSenderConfig) {0}; - senderConfig.resolver = resolver; - senderConfig.stream = tlsStream; - senderConfig.endpoint = mtls ? BddTargetMtlsConfig_GetEndpoint : BddTargetTlsConfig_GetEndpoint; - senderConfig.endpointVersion = + senderConfig.Resolver = resolver; + senderConfig.Stream = tlsStream; + senderConfig.Endpoint = mtls ? BddTargetMtlsConfig_GetEndpoint : BddTargetTlsConfig_GetEndpoint; + senderConfig.EndpointVersion = mtls ? BddTargetMtlsConfig_GetEndpointVersion : BddTargetTlsConfig_GetEndpointVersion; sender = SolidSyslogStreamSender_Create(&senderStorage, &senderConfig); diff --git a/Bdd/Targets/Common/BddTargetTlsSender_OpenSsl_WinsockTcp.c b/Bdd/Targets/Common/BddTargetTlsSender_OpenSsl_WinsockTcp.c index b0fefe7b..2d58b9ed 100644 --- a/Bdd/Targets/Common/BddTargetTlsSender_OpenSsl_WinsockTcp.c +++ b/Bdd/Targets/Common/BddTargetTlsSender_OpenSsl_WinsockTcp.c @@ -23,28 +23,28 @@ struct SolidSyslogSender* BddTargetTlsSender_Create(struct SolidSyslogResolver* static struct SolidSyslogTlsStreamConfig tlsStreamConfig; tlsStreamConfig = (struct SolidSyslogTlsStreamConfig) {0}; - tlsStreamConfig.transport = underlyingStream; - tlsStreamConfig.sleep = SolidSyslogWindowsSleep; + tlsStreamConfig.Transport = underlyingStream; + tlsStreamConfig.Sleep = SolidSyslogWindowsSleep; if (mtls) { - tlsStreamConfig.caBundlePath = BddTargetMtlsConfig_GetCaBundlePath(); - tlsStreamConfig.serverName = BddTargetMtlsConfig_GetServerName(); - tlsStreamConfig.clientCertChainPath = BddTargetMtlsConfig_GetClientCertChainPath(); - tlsStreamConfig.clientKeyPath = BddTargetMtlsConfig_GetClientKeyPath(); + tlsStreamConfig.CaBundlePath = BddTargetMtlsConfig_GetCaBundlePath(); + tlsStreamConfig.ServerName = BddTargetMtlsConfig_GetServerName(); + tlsStreamConfig.ClientCertChainPath = BddTargetMtlsConfig_GetClientCertChainPath(); + tlsStreamConfig.ClientKeyPath = BddTargetMtlsConfig_GetClientKeyPath(); } else { - tlsStreamConfig.caBundlePath = BddTargetTlsConfig_GetCaBundlePath(); - tlsStreamConfig.serverName = BddTargetTlsConfig_GetServerName(); + tlsStreamConfig.CaBundlePath = BddTargetTlsConfig_GetCaBundlePath(); + tlsStreamConfig.ServerName = BddTargetTlsConfig_GetServerName(); } tlsStream = SolidSyslogTlsStream_Create(&tlsStreamStorage, &tlsStreamConfig); static struct SolidSyslogStreamSenderConfig senderConfig; senderConfig = (struct SolidSyslogStreamSenderConfig) {0}; - senderConfig.resolver = resolver; - senderConfig.stream = tlsStream; - senderConfig.endpoint = mtls ? BddTargetMtlsConfig_GetEndpoint : BddTargetTlsConfig_GetEndpoint; - senderConfig.endpointVersion = + senderConfig.Resolver = resolver; + senderConfig.Stream = tlsStream; + senderConfig.Endpoint = mtls ? BddTargetMtlsConfig_GetEndpoint : BddTargetTlsConfig_GetEndpoint; + senderConfig.EndpointVersion = mtls ? BddTargetMtlsConfig_GetEndpointVersion : BddTargetTlsConfig_GetEndpointVersion; sender = SolidSyslogStreamSender_Create(&senderStorage, &senderConfig); diff --git a/Bdd/Targets/FreeRtos/main.c b/Bdd/Targets/FreeRtos/main.c index 61b85192..1f23a5ac 100644 --- a/Bdd/Targets/FreeRtos/main.c +++ b/Bdd/Targets/FreeRtos/main.c @@ -143,10 +143,10 @@ static uint16_t port = (uint16_t) BDD_TARGET_UDP_PORT; static uint32_t endpointVersion = 0U; static struct SolidSyslogMessage testMessage = { - .facility = SolidSyslogFacility_Local0, - .severity = SolidSyslogSeverity_Informational, - .messageId = messageId, - .msg = msg, + .Facility = SolidSyslogFacility_Local0, + .Severity = SolidSyslogSeverity_Informational, + .MessageId = messageId, + .Msg = msg, }; /* Plus-TCP requires the network interface descriptor and its endpoint(s) @@ -231,7 +231,7 @@ static size_t pendingCapacityThreshold = 0; static volatile bool pendingNoSd = false; /* Holds the final SolidSyslog config so the rebuild path can rewrite - * .store and pass the same struct back into SolidSyslog_Create. */ + * .Store and pass the same struct back into SolidSyslog_Create. */ static struct SolidSyslogConfig solidSyslogConfig; static struct SolidSyslogStructuredData* sdList[3]; static struct SolidSyslogAtomicCounter* atomicCounter = NULL; @@ -337,7 +337,7 @@ static void GetAppName(struct SolidSyslogFormatter* formatter) /* No RTC and no time-sync on this reference target — the example models an * embedded device that has no concept of wall-clock time. RFC 5424 §6.2.3.1 * mandates NILVALUE TIMESTAMP in that case, and the timeQuality SD reports - * tzKnown=0, isSynced=0. SolidSyslogConfig.clock=NULL drops through to the + * tzKnown=0, isSynced=0. SolidSyslogConfig.Clock=NULL drops through to the * library's NilClock; the resulting all-zero SolidSyslogTimestamp fails * TimestampIsValid in Core/Source/SolidSyslog.c and emits "-" on the wire. */ static void ErrorHandler(void* context, enum SolidSyslogSeverity severity, const char* message) @@ -348,9 +348,9 @@ static void ErrorHandler(void* context, enum SolidSyslogSeverity severity, const static void GetTimeQuality(struct SolidSyslogTimeQuality* timeQuality) { - timeQuality->tzKnown = false; - timeQuality->isSynced = false; - timeQuality->syncAccuracyMicroseconds = SOLIDSYSLOG_SYNC_ACCURACY_OMIT; + timeQuality->TzKnown = false; + timeQuality->IsSynced = false; + timeQuality->SyncAccuracyMicroseconds = SOLIDSYSLOG_SYNC_ACCURACY_OMIT; } static void GetEndpoint(struct SolidSyslogEndpoint* endpoint) @@ -360,8 +360,8 @@ static void GetEndpoint(struct SolidSyslogEndpoint* endpoint) * here for forward-compatibility with the follow-up slice that will * teach the resolver to parse dotted-quads. The port reaches the * wire via sendto unchanged. */ - SolidSyslogFormatter_BoundedString(endpoint->host, host, strlen(host)); - endpoint->port = port; + SolidSyslogFormatter_BoundedString(endpoint->Host, host, strlen(host)); + endpoint->Port = port; } static uint32_t GetEndpointVersion(void) @@ -410,7 +410,7 @@ static bool OnSet(const char* name, const char* value) { return false; } - testMessage.facility = (enum SolidSyslogFacility) parsed; + testMessage.Facility = (enum SolidSyslogFacility) parsed; return true; } if (strcmp(name, "severity") == 0) @@ -420,7 +420,7 @@ static bool OnSet(const char* name, const char* value) { return false; } - testMessage.severity = (enum SolidSyslogSeverity) parsed; + testMessage.Severity = (enum SolidSyslogSeverity) parsed; return true; } if (strcmp(name, "transport") == 0) @@ -592,25 +592,25 @@ static bool RebuildWithFileStore(void) struct SolidSyslogSecurityPolicy* policy = SolidSyslogCrc16Policy_Create(); struct SolidSyslogBlockStoreConfig storeConfig = { - .blockDevice = storeBlockDevice, - .maxBlockSize = pendingMaxBlockSize, - .maxBlocks = pendingMaxBlocks, - .discardPolicy = MapDiscardPolicy(pendingDiscardPolicy), - .securityPolicy = policy, - .onStoreFull = OnStoreFull, - .storeFullContext = NULL, - .getCapacityThreshold = GetCapacityThreshold, - .onThresholdCrossed = NULL, - .thresholdContext = &pendingCapacityThreshold, + .BlockDevice = storeBlockDevice, + .MaxBlockSize = pendingMaxBlockSize, + .MaxBlocks = pendingMaxBlocks, + .DiscardPolicy = MapDiscardPolicy(pendingDiscardPolicy), + .SecurityPolicy = policy, + .OnStoreFull = OnStoreFull, + .StoreFullContext = NULL, + .GetCapacityThreshold = GetCapacityThreshold, + .OnThresholdCrossed = NULL, + .ThresholdContext = &pendingCapacityThreshold, }; currentStore = SolidSyslogBlockStore_Create(&blockStoreStorage, &storeConfig); currentStoreIsFile = true; - solidSyslogConfig.store = currentStore; + solidSyslogConfig.Store = currentStore; /* Re-honour `set no-sd 1` if it arrived before this rebuild — the * sort order in target_driver.py guarantees `set no-sd` comes before * `set store file` so the value is final by the time we get here. */ - solidSyslogConfig.sdCount = pendingNoSd ? 1U : (sizeof(sdList) / sizeof(sdList[0])); + solidSyslogConfig.SdCount = pendingNoSd ? 1U : (sizeof(sdList) / sizeof(sdList[0])); SolidSyslog_Create(&solidSyslogConfig); solidSyslogReady = true; SolidSyslogMutex_Unlock(lifecycleMutex); @@ -782,10 +782,10 @@ static void InteractiveTask(void* argument) datagram = SolidSyslogFreeRtosDatagram_Create(&datagramStorage); struct SolidSyslogUdpSenderConfig udpConfig = { - .resolver = resolver, - .datagram = datagram, - .endpoint = GetEndpoint, - .endpointVersion = GetEndpointVersion, + .Resolver = resolver, + .Datagram = datagram, + .Endpoint = GetEndpoint, + .EndpointVersion = GetEndpointVersion, }; struct SolidSyslogSender* udpSender = SolidSyslogUdpSender_Create(&udpConfig); @@ -795,10 +795,10 @@ static void InteractiveTask(void* argument) * Bdd/syslog-ng/syslog-ng.conf has a TCP listener on 5514 alongside UDP. */ tcpStream = SolidSyslogFreeRtosTcpStream_Create(&tcpStreamStorage); struct SolidSyslogStreamSenderConfig tcpConfig = { - .resolver = resolver, - .stream = tcpStream, - .endpoint = GetEndpoint, - .endpointVersion = GetEndpointVersion, + .Resolver = resolver, + .Stream = tcpStream, + .Endpoint = GetEndpoint, + .EndpointVersion = GetEndpointVersion, }; tcpSender = SolidSyslogStreamSender_Create(&tcpSenderStorage, &tcpConfig); @@ -810,9 +810,9 @@ static void InteractiveTask(void* argument) inners[BDD_TARGET_SWITCH_UDP] = udpSender; inners[BDD_TARGET_SWITCH_TCP] = tcpSender; struct SolidSyslogSwitchingSenderConfig switchConfig = { - .senders = inners, - .senderCount = sizeof(inners) / sizeof(inners[0]), - .selector = BddTargetSwitchConfig_Selector, + .Senders = inners, + .SenderCount = sizeof(inners) / sizeof(inners[0]), + .Selector = BddTargetSwitchConfig_Selector, }; BddTargetSwitchConfig_SetByName("udp"); struct SolidSyslogSender* sender = SolidSyslogSwitchingSender_Create(&switchConfig); @@ -836,18 +836,18 @@ static void InteractiveTask(void* argument) atomicCounter = SolidSyslogAtomicCounter_Create(); struct SolidSyslogMetaSdConfig metaConfig = { - .counter = atomicCounter, - .getSysUpTime = SolidSyslogFreeRtosSysUpTime_Get, - .getLanguage = BddTargetLanguage_Get, + .Counter = atomicCounter, + .GetSysUpTime = SolidSyslogFreeRtosSysUpTime_Get, + .GetLanguage = BddTargetLanguage_Get, }; metaSd = SolidSyslogMetaSd_Create(&metaConfig); timeQualitySd = SolidSyslogTimeQualitySd_Create(GetTimeQuality); struct SolidSyslogOriginSdConfig originConfig = { - .software = "SolidSyslogBddTarget", - .swVersion = "0.7.0", - .enterpriseId = BDD_TARGET_ENTERPRISE_ID, - .getIpCount = BddTargetIps_Count, - .getIpAt = BddTargetIps_At, + .Software = "SolidSyslogBddTarget", + .SwVersion = "0.7.0", + .EnterpriseId = BDD_TARGET_ENTERPRISE_ID, + .GetIpCount = BddTargetIps_Count, + .GetIpAt = BddTargetIps_At, }; originSd = SolidSyslogOriginSd_Create(&originConfig); sdList[0] = metaSd; @@ -855,26 +855,26 @@ static void InteractiveTask(void* argument) sdList[2] = originSd; solidSyslogConfig = (struct SolidSyslogConfig) { - .buffer = buffer, - .sender = sender, - .clock = NULL, - .getHostname = GetHostname, - .getAppName = GetAppName, + .Buffer = buffer, + .Sender = sender, + .Clock = NULL, + .GetHostname = GetHostname, + .GetAppName = GetAppName, /* PROCID — RFC 5424 §6.2.6 NILVALUE: FreeRTOS QEMU has no * process model. NULL drops through to the library's * NilStringFunction which yields an empty field; FormatStringField * (Core/Source/SolidSyslog.c) then emits "-" on the wire. */ - .getProcessId = NULL, - .store = currentStore, - .sd = sdList, + .GetProcessId = NULL, + .Store = currentStore, + .Sd = sdList, /* pendingNoSd is normally false at this initial Setup call — * the `set no-sd 1` translation runs over the UART AFTER the * prompt is up. Slice 6's @store scenarios on FreeRTOS always * couple --no-sd with --store file, so the rebuild path rewrites - * .sdCount with the up-to-date value. This initial value is + * .SdCount with the up-to-date value. This initial value is * defensive in case a future scenario sends `set no-sd 1` before * any rebuild. */ - .sdCount = pendingNoSd ? 1U : (sizeof(sdList) / sizeof(sdList[0])), + .SdCount = pendingNoSd ? 1U : (sizeof(sdList) / sizeof(sdList[0])), }; SolidSyslog_SetErrorHandler(ErrorHandler, NULL); SolidSyslog_Create(&solidSyslogConfig); diff --git a/Bdd/Targets/Linux/BddTargetCommandLine.c b/Bdd/Targets/Linux/BddTargetCommandLine.c index 4dabc147..738c6625 100644 --- a/Bdd/Targets/Linux/BddTargetCommandLine.c +++ b/Bdd/Targets/Linux/BddTargetCommandLine.c @@ -39,19 +39,19 @@ static bool IsValidDiscardPolicy(const char* policy) int BddTargetCommandLine_Parse(int argc, char* argv[], struct BddTargetOptions* options) { - options->facility = SolidSyslogFacility_Local0; - options->severity = SolidSyslogSeverity_Informational; - options->messageId = NULL; - options->msg = NULL; - options->appName = NULL; - options->transport = "udp"; - options->store = "null"; - options->maxBlocks = DEFAULT_MAX_BLOCKS; - options->maxBlockSize = DEFAULT_MAX_BLOCK_SIZE; - options->discardPolicy = "oldest"; - options->capacityThreshold = 0; - options->noSd = false; - options->haltExit = false; + options->Facility = SolidSyslogFacility_Local0; + options->Severity = SolidSyslogSeverity_Informational; + options->MessageId = NULL; + options->Msg = NULL; + options->AppName = NULL; + options->Transport = "udp"; + options->Store = "null"; + options->MaxBlocks = DEFAULT_MAX_BLOCKS; + options->MaxBlockSize = DEFAULT_MAX_BLOCK_SIZE; + options->DiscardPolicy = "oldest"; + options->CapacityThreshold = 0; + options->NoSd = false; + options->HaltExit = false; static struct option longOptions[] = { {"facility", required_argument, NULL, 'f'}, @@ -76,16 +76,16 @@ int BddTargetCommandLine_Parse(int argc, char* argv[], struct BddTargetOptions* switch (opt) { case 'f': - options->facility = (enum SolidSyslogFacility) atoi(optarg); + options->Facility = (enum SolidSyslogFacility) atoi(optarg); break; case 's': - options->severity = (enum SolidSyslogSeverity) atoi(optarg); + options->Severity = (enum SolidSyslogSeverity) atoi(optarg); break; case 'i': - options->messageId = optarg; + options->MessageId = optarg; break; case 'm': - options->msg = optarg; + options->Msg = optarg; break; case 't': if ((strcmp(optarg, "udp") != 0) && (strcmp(optarg, "tcp") != 0) && (strcmp(optarg, "tls") != 0) && @@ -93,23 +93,23 @@ int BddTargetCommandLine_Parse(int argc, char* argv[], struct BddTargetOptions* { return 1; } - options->transport = optarg; + options->Transport = optarg; break; case 'o': if ((strcmp(optarg, "null") != 0) && (strcmp(optarg, "file") != 0)) { return 1; } - options->store = optarg; + options->Store = optarg; break; case OPT_MAX_BLOCKS: - if (!ParsePositiveNumber(optarg, &options->maxBlocks)) + if (!ParsePositiveNumber(optarg, &options->MaxBlocks)) { return 1; } break; case OPT_MAX_BLOCK_SIZE: - if (!ParsePositiveNumber(optarg, &options->maxBlockSize)) + if (!ParsePositiveNumber(optarg, &options->MaxBlockSize)) { return 1; } @@ -119,22 +119,22 @@ int BddTargetCommandLine_Parse(int argc, char* argv[], struct BddTargetOptions* { return 1; } - options->discardPolicy = optarg; + options->DiscardPolicy = optarg; break; case OPT_CAPACITY_THRESHOLD: - if (!ParsePositiveNumber(optarg, &options->capacityThreshold)) + if (!ParsePositiveNumber(optarg, &options->CapacityThreshold)) { return 1; } break; case OPT_NO_SD: - options->noSd = true; + options->NoSd = true; break; case OPT_HALT_EXIT: - options->haltExit = true; + options->HaltExit = true; break; case OPT_APP_NAME: - options->appName = optarg; + options->AppName = optarg; break; default: return 1; diff --git a/Bdd/Targets/Linux/BddTargetCommandLine.h b/Bdd/Targets/Linux/BddTargetCommandLine.h index b0f009bc..284ad1b3 100644 --- a/Bdd/Targets/Linux/BddTargetCommandLine.h +++ b/Bdd/Targets/Linux/BddTargetCommandLine.h @@ -11,19 +11,19 @@ EXTERN_C_BEGIN struct BddTargetOptions { - enum SolidSyslogFacility facility; - enum SolidSyslogSeverity severity; - const char* messageId; - const char* msg; - const char* appName; /* --app-name (NULL: derive from argv[0]) */ - const char* transport; - const char* store; - size_t maxBlocks; - size_t maxBlockSize; - const char* discardPolicy; - size_t capacityThreshold; - bool noSd; - bool haltExit; + enum SolidSyslogFacility Facility; + enum SolidSyslogSeverity Severity; + const char* MessageId; + const char* Msg; + const char* AppName; /* --app-name (NULL: derive from argv[0]) */ + const char* Transport; + const char* Store; + size_t MaxBlocks; + size_t MaxBlockSize; + const char* DiscardPolicy; + size_t CapacityThreshold; + bool NoSd; + bool HaltExit; }; int BddTargetCommandLine_Parse(int argc, char* argv[], struct BddTargetOptions* options); diff --git a/Bdd/Targets/Linux/BddTargetTcpConfig.c b/Bdd/Targets/Linux/BddTargetTcpConfig.c index c23c9bc4..b79833ec 100644 --- a/Bdd/Targets/Linux/BddTargetTcpConfig.c +++ b/Bdd/Targets/Linux/BddTargetTcpConfig.c @@ -24,8 +24,8 @@ uint16_t BddTargetTcpConfig_GetPort(void) void BddTargetTcpConfig_GetEndpoint(struct SolidSyslogEndpoint* endpoint) { - SolidSyslogFormatter_BoundedString(endpoint->host, BddTargetTcpConfig_GetHost(), SOLIDSYSLOG_MAX_HOST_SIZE); - endpoint->port = BddTargetTcpConfig_GetPort(); + SolidSyslogFormatter_BoundedString(endpoint->Host, BddTargetTcpConfig_GetHost(), SOLIDSYSLOG_MAX_HOST_SIZE); + endpoint->Port = BddTargetTcpConfig_GetPort(); } /* Static config — host/port never change, so version stays 0 forever and the diff --git a/Bdd/Targets/Linux/BddTargetUdpConfig.c b/Bdd/Targets/Linux/BddTargetUdpConfig.c index bf01cf9e..7d00e6aa 100644 --- a/Bdd/Targets/Linux/BddTargetUdpConfig.c +++ b/Bdd/Targets/Linux/BddTargetUdpConfig.c @@ -23,8 +23,8 @@ uint16_t BddTargetUdpConfig_GetPort(void) void BddTargetUdpConfig_GetEndpoint(struct SolidSyslogEndpoint* endpoint) { - SolidSyslogFormatter_BoundedString(endpoint->host, BddTargetUdpConfig_GetHost(), SOLIDSYSLOG_MAX_HOST_SIZE); - endpoint->port = BddTargetUdpConfig_GetPort(); + SolidSyslogFormatter_BoundedString(endpoint->Host, BddTargetUdpConfig_GetHost(), SOLIDSYSLOG_MAX_HOST_SIZE); + endpoint->Port = BddTargetUdpConfig_GetPort(); } /* Static config — host/port never change, so version stays 0 forever and the diff --git a/Bdd/Targets/Linux/main.c b/Bdd/Targets/Linux/main.c index 9f462b57..7d7b5714 100644 --- a/Bdd/Targets/Linux/main.c +++ b/Bdd/Targets/Linux/main.c @@ -58,9 +58,9 @@ static struct SolidSyslogSender* plainTcpSender; static void GetTimeQuality(struct SolidSyslogTimeQuality* timeQuality) { - timeQuality->tzKnown = true; - timeQuality->isSynced = true; - timeQuality->syncAccuracyMicroseconds = SOLIDSYSLOG_SYNC_ACCURACY_OMIT; + timeQuality->TzKnown = true; + timeQuality->IsSynced = true; + timeQuality->SyncAccuracyMicroseconds = SOLIDSYSLOG_SYNC_ACCURACY_OMIT; } static volatile bool shutdown_flag; @@ -74,23 +74,23 @@ static void* ServiceThreadEntry(void* arg) static struct SolidSyslogSender* CreateSender(const struct BddTargetOptions* options) { - bool mtlsModeActive = (strcmp(options->transport, "mtls") == 0); + bool mtlsModeActive = (strcmp(options->Transport, "mtls") == 0); struct SolidSyslogResolver* resolver = SolidSyslogGetAddrInfoResolver_Create(); static struct SolidSyslogUdpSenderConfig udpConfig = {0}; - udpConfig.resolver = resolver; - udpConfig.datagram = SolidSyslogPosixDatagram_Create(); - udpConfig.endpoint = BddTargetUdpConfig_GetEndpoint; - udpConfig.endpointVersion = BddTargetUdpConfig_GetEndpointVersion; + udpConfig.Resolver = resolver; + udpConfig.Datagram = SolidSyslogPosixDatagram_Create(); + udpConfig.Endpoint = BddTargetUdpConfig_GetEndpoint; + udpConfig.EndpointVersion = BddTargetUdpConfig_GetEndpointVersion; struct SolidSyslogSender* udpSender = SolidSyslogUdpSender_Create(&udpConfig); plainTcpStream = SolidSyslogPosixTcpStream_Create(&plainTcpStreamStorage); static struct SolidSyslogStreamSenderConfig tcpConfig = {0}; - tcpConfig.resolver = resolver; - tcpConfig.stream = plainTcpStream; - tcpConfig.endpoint = BddTargetTcpConfig_GetEndpoint; - tcpConfig.endpointVersion = BddTargetTcpConfig_GetEndpointVersion; + tcpConfig.Resolver = resolver; + tcpConfig.Stream = plainTcpStream; + tcpConfig.Endpoint = BddTargetTcpConfig_GetEndpoint; + tcpConfig.EndpointVersion = BddTargetTcpConfig_GetEndpointVersion; plainTcpSender = SolidSyslogStreamSender_Create(&plainTcpSenderStorage, &tcpConfig); struct SolidSyslogSender* tlsSender = BddTargetTlsSender_Create(resolver, mtlsModeActive); @@ -101,11 +101,11 @@ static struct SolidSyslogSender* CreateSender(const struct BddTargetOptions* opt inners[BDD_TARGET_SWITCH_TLS] = tlsSender; static struct SolidSyslogSwitchingSenderConfig switchConfig = {0}; - switchConfig.senders = inners; - switchConfig.senderCount = BDD_TARGET_SWITCH_COUNT; - switchConfig.selector = BddTargetSwitchConfig_Selector; + switchConfig.Senders = inners; + switchConfig.SenderCount = BDD_TARGET_SWITCH_COUNT; + switchConfig.Selector = BddTargetSwitchConfig_Selector; - BddTargetSwitchConfig_SetByName(options->transport); + BddTargetSwitchConfig_SetByName(options->Transport); return SolidSyslogSwitchingSender_Create(&switchConfig); } @@ -151,7 +151,7 @@ static void OnThresholdCrossed(void* context) static struct SolidSyslogStore* CreateStore(const struct BddTargetOptions* options) { - bool useFile = (strcmp(options->store, "file") == 0); + bool useFile = (strcmp(options->Store, "file") == 0); if (useFile) { @@ -162,17 +162,17 @@ static struct SolidSyslogStore* CreateStore(const struct BddTargetOptions* optio storeBlockDevice = SolidSyslogFileBlockDevice_Create(&blockDeviceStorage, storeFile, STORE_PATH_PREFIX); static size_t capacityThreshold; - capacityThreshold = options->capacityThreshold; + capacityThreshold = options->CapacityThreshold; static struct SolidSyslogBlockStoreConfig storeConfig = {0}; - storeConfig.blockDevice = storeBlockDevice; - storeConfig.maxBlockSize = options->maxBlockSize; - storeConfig.maxBlocks = options->maxBlocks; - storeConfig.discardPolicy = MapDiscardPolicy(options->discardPolicy); - storeConfig.securityPolicy = SolidSyslogCrc16Policy_Create(); - storeConfig.onStoreFull = OnStoreFull; - storeConfig.getCapacityThreshold = GetCapacityThreshold; - storeConfig.onThresholdCrossed = OnThresholdCrossed; - storeConfig.thresholdContext = &capacityThreshold; + storeConfig.BlockDevice = storeBlockDevice; + storeConfig.MaxBlockSize = options->MaxBlockSize; + storeConfig.MaxBlocks = options->MaxBlocks; + storeConfig.DiscardPolicy = MapDiscardPolicy(options->DiscardPolicy); + storeConfig.SecurityPolicy = SolidSyslogCrc16Policy_Create(); + storeConfig.OnStoreFull = OnStoreFull; + storeConfig.GetCapacityThreshold = GetCapacityThreshold; + storeConfig.OnThresholdCrossed = OnThresholdCrossed; + storeConfig.ThresholdContext = &capacityThreshold; static SolidSyslogBlockStoreStorage storeStorage; return SolidSyslogBlockStore_Create(&storeStorage, &storeConfig); @@ -194,7 +194,7 @@ static void DestroySender(void) static void DestroyStore(struct SolidSyslogStore* store, const struct BddTargetOptions* options) { - bool useFile = (strcmp(options->store, "file") == 0); + bool useFile = (strcmp(options->Store, "file") == 0); if (useFile) { @@ -227,7 +227,7 @@ int main(int argc, char* argv[]) /* Honour --app-name when supplied (BDD scenarios pin it for record-size parity across runners); otherwise derive from argv[0] as before. */ - BddTargetAppName_Set((options.appName != NULL) ? options.appName : argv[0]); + BddTargetAppName_Set((options.AppName != NULL) ? options.AppName : argv[0]); struct SolidSyslogSender* sender = CreateSender(&options); struct SolidSyslogStore* store = CreateStore(&options); @@ -235,49 +235,49 @@ int main(int argc, char* argv[]) struct SolidSyslogBuffer* buffer = SolidSyslogPosixMessageQueueBuffer_Create(SOLIDSYSLOG_MAX_MESSAGE_SIZE, 10); struct SolidSyslogAtomicCounter* counter = SolidSyslogAtomicCounter_Create(); struct SolidSyslogMetaSdConfig metaConfig = { - .counter = counter, - .getSysUpTime = SolidSyslogPosixSysUpTime_Get, - .getLanguage = BddTargetLanguage_Get, + .Counter = counter, + .GetSysUpTime = SolidSyslogPosixSysUpTime_Get, + .GetLanguage = BddTargetLanguage_Get, }; struct SolidSyslogStructuredData* metaSd = SolidSyslogMetaSd_Create(&metaConfig); struct SolidSyslogStructuredData* timeQuality = SolidSyslogTimeQualitySd_Create(GetTimeQuality); struct SolidSyslogOriginSdConfig originConfig = { - .software = "SolidSyslogBddTarget", - .swVersion = "0.7.0", - .enterpriseId = BDD_TARGET_ENTERPRISE_ID, - .getIpCount = BddTargetIps_Count, - .getIpAt = BddTargetIps_At, + .Software = "SolidSyslogBddTarget", + .SwVersion = "0.7.0", + .EnterpriseId = BDD_TARGET_ENTERPRISE_ID, + .GetIpCount = BddTargetIps_Count, + .GetIpAt = BddTargetIps_At, }; struct SolidSyslogStructuredData* originSd = SolidSyslogOriginSd_Create(&originConfig); struct SolidSyslogStructuredData* sdList[3] = {metaSd, timeQuality, originSd}; - size_t sdCount = options.noSd ? 1 : 3; + size_t sdCount = options.NoSd ? 1 : 3; struct SolidSyslogConfig config = { - .buffer = buffer, - .sender = sender, - .clock = SolidSyslogPosixClock_GetTimestamp, - .getHostname = SolidSyslogPosixHostname_Get, - .getAppName = BddTargetAppName_Get, - .getProcessId = SolidSyslogPosixProcessId_Get, - .store = store, - .sd = sdList, - .sdCount = sdCount, + .Buffer = buffer, + .Sender = sender, + .Clock = SolidSyslogPosixClock_GetTimestamp, + .GetHostname = SolidSyslogPosixHostname_Get, + .GetAppName = BddTargetAppName_Get, + .GetProcessId = SolidSyslogPosixProcessId_Get, + .Store = store, + .Sd = sdList, + .SdCount = sdCount, }; SolidSyslog_Create(&config); shutdown_flag = false; - haltExit = options.haltExit; + haltExit = options.HaltExit; pthread_t serviceThread = 0; pthread_create(&serviceThread, NULL, ServiceThreadEntry, (void*) &shutdown_flag); struct SolidSyslogMessage message = { - .facility = options.facility, - .severity = options.severity, - .messageId = options.messageId, - .msg = options.msg, + .Facility = options.Facility, + .Severity = options.Severity, + .MessageId = options.MessageId, + .Msg = options.Msg, }; BddTargetInteractive_Run(&message, stdin, BddTargetSwitchConfig_SetByName, NULL); diff --git a/Bdd/Targets/Windows/BddTargetWindows.c b/Bdd/Targets/Windows/BddTargetWindows.c index 6a99b369..df06ab38 100644 --- a/Bdd/Targets/Windows/BddTargetWindows.c +++ b/Bdd/Targets/Windows/BddTargetWindows.c @@ -100,8 +100,8 @@ static int GetPort(void) static void GetEndpoint(struct SolidSyslogEndpoint* endpoint) { - SolidSyslogFormatter_BoundedString(endpoint->host, GetHost(), SOLIDSYSLOG_MAX_HOST_SIZE); - endpoint->port = (uint16_t) GetPort(); + SolidSyslogFormatter_BoundedString(endpoint->Host, GetHost(), SOLIDSYSLOG_MAX_HOST_SIZE); + endpoint->Port = (uint16_t) GetPort(); } static uint32_t GetEndpointVersion(void) @@ -111,9 +111,9 @@ static uint32_t GetEndpointVersion(void) static void GetTimeQuality(struct SolidSyslogTimeQuality* timeQuality) { - timeQuality->tzKnown = true; - timeQuality->isSynced = true; - timeQuality->syncAccuracyMicroseconds = SOLIDSYSLOG_SYNC_ACCURACY_OMIT; + timeQuality->TzKnown = true; + timeQuality->IsSynced = true; + timeQuality->SyncAccuracyMicroseconds = SOLIDSYSLOG_SYNC_ACCURACY_OMIT; } /* MSVC's getenv triggers C4996; getenv_s is the strict-mode equivalent. @@ -176,24 +176,24 @@ static void OnThresholdCrossed(void* context) static struct SolidSyslogSender* CreateSender(const struct BddTargetWindowsOptions* options) { - bool mtlsModeActive = (strcmp(options->transport, "mtls") == 0); + bool mtlsModeActive = (strcmp(options->Transport, "mtls") == 0); struct SolidSyslogResolver* resolver = SolidSyslogWinsockResolver_Create(); udpDatagram = SolidSyslogWinsockDatagram_Create(); static struct SolidSyslogUdpSenderConfig udpConfig = {0}; - udpConfig.resolver = resolver; - udpConfig.datagram = udpDatagram; - udpConfig.endpoint = GetEndpoint; - udpConfig.endpointVersion = GetEndpointVersion; + udpConfig.Resolver = resolver; + udpConfig.Datagram = udpDatagram; + udpConfig.Endpoint = GetEndpoint; + udpConfig.EndpointVersion = GetEndpointVersion; struct SolidSyslogSender* udpSender = SolidSyslogUdpSender_Create(&udpConfig); plainTcpStream = SolidSyslogWinsockTcpStream_Create(&tcpStreamStorage); static struct SolidSyslogStreamSenderConfig tcpConfig = {0}; - tcpConfig.resolver = resolver; - tcpConfig.stream = plainTcpStream; - tcpConfig.endpoint = GetEndpoint; - tcpConfig.endpointVersion = GetEndpointVersion; + tcpConfig.Resolver = resolver; + tcpConfig.Stream = plainTcpStream; + tcpConfig.Endpoint = GetEndpoint; + tcpConfig.EndpointVersion = GetEndpointVersion; plainTcpSender = SolidSyslogStreamSender_Create(&tcpSenderStorage, &tcpConfig); struct SolidSyslogSender* tlsSender = BddTargetTlsSender_Create(resolver, mtlsModeActive); @@ -204,11 +204,11 @@ static struct SolidSyslogSender* CreateSender(const struct BddTargetWindowsOptio inners[BDD_TARGET_SWITCH_TLS] = tlsSender; static struct SolidSyslogSwitchingSenderConfig switchConfig = {0}; - switchConfig.senders = inners; - switchConfig.senderCount = BDD_TARGET_SWITCH_COUNT; - switchConfig.selector = BddTargetSwitchConfig_Selector; + switchConfig.Senders = inners; + switchConfig.SenderCount = BDD_TARGET_SWITCH_COUNT; + switchConfig.Selector = BddTargetSwitchConfig_Selector; - BddTargetSwitchConfig_SetByName(options->transport); + BddTargetSwitchConfig_SetByName(options->Transport); return SolidSyslogSwitchingSender_Create(&switchConfig); } @@ -225,7 +225,7 @@ static void DestroySender(void) static struct SolidSyslogStore* CreateStore(const struct BddTargetWindowsOptions* options) { - bool useFile = (strcmp(options->store, "file") == 0); + bool useFile = (strcmp(options->Store, "file") == 0); if (useFile) { @@ -236,17 +236,17 @@ static struct SolidSyslogStore* CreateStore(const struct BddTargetWindowsOptions storeBlockDevice = SolidSyslogFileBlockDevice_Create(&blockDeviceStorage, storeFile, STORE_PATH_PREFIX); static size_t capacityThreshold; - capacityThreshold = options->capacityThreshold; + capacityThreshold = options->CapacityThreshold; static struct SolidSyslogBlockStoreConfig storeConfig = {0}; - storeConfig.blockDevice = storeBlockDevice; - storeConfig.maxBlockSize = options->maxBlockSize; - storeConfig.maxBlocks = options->maxBlocks; - storeConfig.discardPolicy = MapDiscardPolicy(options->discardPolicy); - storeConfig.securityPolicy = SolidSyslogCrc16Policy_Create(); - storeConfig.onStoreFull = OnStoreFull; - storeConfig.getCapacityThreshold = GetCapacityThreshold; - storeConfig.onThresholdCrossed = OnThresholdCrossed; - storeConfig.thresholdContext = &capacityThreshold; + storeConfig.BlockDevice = storeBlockDevice; + storeConfig.MaxBlockSize = options->MaxBlockSize; + storeConfig.MaxBlocks = options->MaxBlocks; + storeConfig.DiscardPolicy = MapDiscardPolicy(options->DiscardPolicy); + storeConfig.SecurityPolicy = SolidSyslogCrc16Policy_Create(); + storeConfig.OnStoreFull = OnStoreFull; + storeConfig.GetCapacityThreshold = GetCapacityThreshold; + storeConfig.OnThresholdCrossed = OnThresholdCrossed; + storeConfig.ThresholdContext = &capacityThreshold; static SolidSyslogBlockStoreStorage storeStorage; return SolidSyslogBlockStore_Create(&storeStorage, &storeConfig); @@ -257,7 +257,7 @@ static struct SolidSyslogStore* CreateStore(const struct BddTargetWindowsOptions static void DestroyStore(struct SolidSyslogStore* store, const struct BddTargetWindowsOptions* options) { - bool useFile = (strcmp(options->store, "file") == 0); + bool useFile = (strcmp(options->Store, "file") == 0); if (useFile) { @@ -295,9 +295,9 @@ int BddTargetWindows_Run(int argc, char* argv[]) /* Honour --app-name when supplied (BDD scenarios pin it for record-size parity across runners); otherwise derive from argv[0] as before. */ - BddTargetAppName_Set((options.appName != NULL) ? options.appName : argv[0]); + BddTargetAppName_Set((options.AppName != NULL) ? options.AppName : argv[0]); - haltExit = options.haltExit; + haltExit = options.HaltExit; struct SolidSyslogSender* sender = CreateSender(&options); struct SolidSyslogStore* store = CreateStore(&options); @@ -306,18 +306,18 @@ int BddTargetWindows_Run(int argc, char* argv[]) struct SolidSyslogBuffer* buffer = SolidSyslogCircularBuffer_Create(bufferStorage, sizeof(bufferStorage), mutex); struct SolidSyslogAtomicCounter* counter = SolidSyslogAtomicCounter_Create(); struct SolidSyslogMetaSdConfig metaConfig = { - .counter = counter, - .getSysUpTime = SolidSyslogWindowsSysUpTime_Get, - .getLanguage = BddTargetLanguage_Get, + .Counter = counter, + .GetSysUpTime = SolidSyslogWindowsSysUpTime_Get, + .GetLanguage = BddTargetLanguage_Get, }; struct SolidSyslogStructuredData* metaSd = SolidSyslogMetaSd_Create(&metaConfig); struct SolidSyslogStructuredData* timeQuality = SolidSyslogTimeQualitySd_Create(GetTimeQuality); struct SolidSyslogOriginSdConfig originConfig = { - .software = "SolidSyslogBddTarget", - .swVersion = "0.7.0", - .enterpriseId = BDD_TARGET_ENTERPRISE_ID, - .getIpCount = BddTargetIps_Count, - .getIpAt = BddTargetIps_At, + .Software = "SolidSyslogBddTarget", + .SwVersion = "0.7.0", + .EnterpriseId = BDD_TARGET_ENTERPRISE_ID, + .GetIpCount = BddTargetIps_Count, + .GetIpAt = BddTargetIps_At, }; struct SolidSyslogStructuredData* originSd = SolidSyslogOriginSd_Create(&originConfig); @@ -326,18 +326,18 @@ int BddTargetWindows_Run(int argc, char* argv[]) optional timeQuality and origin SDs to keep records under the BlockStore's per-block packing budget for store-capacity tests. */ struct SolidSyslogStructuredData* sdList[3] = {metaSd, timeQuality, originSd}; - size_t sdCount = options.noSd ? 1 : 3; + size_t sdCount = options.NoSd ? 1 : 3; struct SolidSyslogConfig config = { - .buffer = buffer, - .sender = sender, - .clock = SolidSyslogWindowsClock_GetTimestamp, - .getHostname = SolidSyslogWindowsHostname_Get, - .getAppName = BddTargetAppName_Get, - .getProcessId = SolidSyslogWindowsProcessId_Get, - .store = store, - .sd = sdList, - .sdCount = sdCount, + .Buffer = buffer, + .Sender = sender, + .Clock = SolidSyslogWindowsClock_GetTimestamp, + .GetHostname = SolidSyslogWindowsHostname_Get, + .GetAppName = BddTargetAppName_Get, + .GetProcessId = SolidSyslogWindowsProcessId_Get, + .Store = store, + .Sd = sdList, + .SdCount = sdCount, }; SolidSyslog_Create(&config); @@ -345,10 +345,10 @@ int BddTargetWindows_Run(int argc, char* argv[]) HANDLE serviceThread = (HANDLE) _beginthreadex(NULL, 0, ServiceThreadEntry, (void*) &shutdownFlag, 0, NULL); struct SolidSyslogMessage message = { - .facility = options.facility, - .severity = options.severity, - .messageId = options.messageId, - .msg = options.msg, + .Facility = options.Facility, + .Severity = options.Severity, + .MessageId = options.MessageId, + .Msg = options.Msg, }; BddTargetInteractive_Run(&message, stdin, BddTargetSwitchConfig_SetByName, NULL); diff --git a/Bdd/Targets/Windows/BddTargetWindowsCommandLine.c b/Bdd/Targets/Windows/BddTargetWindowsCommandLine.c index 9ffbe97c..a4d8a5f1 100644 --- a/Bdd/Targets/Windows/BddTargetWindowsCommandLine.c +++ b/Bdd/Targets/Windows/BddTargetWindowsCommandLine.c @@ -38,73 +38,73 @@ static bool ParsePositiveSize(const char* text, size_t* out) void BddTargetWindowsCommandLine_Parse(int argc, char* argv[], struct BddTargetWindowsOptions* options) { - options->facility = SolidSyslogFacility_Local0; - options->severity = SolidSyslogSeverity_Informational; - options->transport = "udp"; - options->messageId = NULL; - options->msg = NULL; - options->appName = NULL; - options->store = "null"; - options->maxBlocks = DEFAULT_MAX_BLOCKS; - options->maxBlockSize = DEFAULT_MAX_BLOCK_SIZE; - options->discardPolicy = "oldest"; - options->capacityThreshold = 0; - options->haltExit = false; - options->noSd = false; + options->Facility = SolidSyslogFacility_Local0; + options->Severity = SolidSyslogSeverity_Informational; + options->Transport = "udp"; + options->MessageId = NULL; + options->Msg = NULL; + options->AppName = NULL; + options->Store = "null"; + options->MaxBlocks = DEFAULT_MAX_BLOCKS; + options->MaxBlockSize = DEFAULT_MAX_BLOCK_SIZE; + options->DiscardPolicy = "oldest"; + options->CapacityThreshold = 0; + options->HaltExit = false; + options->NoSd = false; for (int i = 1; i < argc; i++) { if (((i + 1) < argc) && (strcmp(argv[i], "--facility") == 0)) { - options->facility = (enum SolidSyslogFacility) atoi(argv[++i]); + options->Facility = (enum SolidSyslogFacility) atoi(argv[++i]); } else if (((i + 1) < argc) && (strcmp(argv[i], "--severity") == 0)) { - options->severity = (enum SolidSyslogSeverity) atoi(argv[++i]); + options->Severity = (enum SolidSyslogSeverity) atoi(argv[++i]); } else if (((i + 1) < argc) && (strcmp(argv[i], "--msgid") == 0)) { - options->messageId = argv[++i]; + options->MessageId = argv[++i]; } else if (((i + 1) < argc) && (strcmp(argv[i], "--message") == 0)) { - options->msg = argv[++i]; + options->Msg = argv[++i]; } else if (((i + 1) < argc) && (strcmp(argv[i], "--transport") == 0)) { - options->transport = argv[++i]; + options->Transport = argv[++i]; } else if (((i + 1) < argc) && (strcmp(argv[i], "--app-name") == 0)) { - options->appName = argv[++i]; + options->AppName = argv[++i]; } else if (((i + 1) < argc) && (strcmp(argv[i], "--store") == 0)) { - options->store = argv[++i]; + options->Store = argv[++i]; } else if (((i + 1) < argc) && (strcmp(argv[i], "--max-blocks") == 0)) { - (void) ParsePositiveSize(argv[++i], &options->maxBlocks); + (void) ParsePositiveSize(argv[++i], &options->MaxBlocks); } else if (((i + 1) < argc) && (strcmp(argv[i], "--max-block-size") == 0)) { - (void) ParsePositiveSize(argv[++i], &options->maxBlockSize); + (void) ParsePositiveSize(argv[++i], &options->MaxBlockSize); } else if (((i + 1) < argc) && (strcmp(argv[i], "--discard-policy") == 0)) { - options->discardPolicy = argv[++i]; + options->DiscardPolicy = argv[++i]; } else if (((i + 1) < argc) && (strcmp(argv[i], "--capacity-threshold") == 0)) { - (void) ParsePositiveSize(argv[++i], &options->capacityThreshold); + (void) ParsePositiveSize(argv[++i], &options->CapacityThreshold); } else if (strcmp(argv[i], "--halt-exit") == 0) { - options->haltExit = true; + options->HaltExit = true; } else if (strcmp(argv[i], "--no-sd") == 0) { - options->noSd = true; + options->NoSd = true; } } } diff --git a/Bdd/Targets/Windows/BddTargetWindowsCommandLine.h b/Bdd/Targets/Windows/BddTargetWindowsCommandLine.h index 17befbd7..0d15a121 100644 --- a/Bdd/Targets/Windows/BddTargetWindowsCommandLine.h +++ b/Bdd/Targets/Windows/BddTargetWindowsCommandLine.h @@ -11,19 +11,19 @@ EXTERN_C_BEGIN struct BddTargetWindowsOptions { - enum SolidSyslogFacility facility; - enum SolidSyslogSeverity severity; - const char* transport; /* "udp" | "tcp" | "tls" | "mtls" — initial selector */ - const char* messageId; - const char* msg; - const char* appName; /* --app-name (NULL: derive from argv[0]) */ - const char* store; /* "null" (default) | "file" — block-store backend */ - size_t maxBlocks; /* --max-blocks */ - size_t maxBlockSize; /* --max-block-size */ - const char* discardPolicy; /* "oldest" (default) | "newest" | "halt" */ - size_t capacityThreshold; /* --capacity-threshold (bytes; 0 disables) */ - bool haltExit; /* --halt-exit */ - bool noSd; /* --no-sd (suppress structured data) */ + enum SolidSyslogFacility Facility; + enum SolidSyslogSeverity Severity; + const char* Transport; /* "udp" | "tcp" | "tls" | "mtls" — initial selector */ + const char* MessageId; + const char* Msg; + const char* AppName; /* --app-name (NULL: derive from argv[0]) */ + const char* Store; /* "null" (default) | "file" — block-store backend */ + size_t MaxBlocks; /* --max-blocks */ + size_t MaxBlockSize; /* --max-block-size */ + const char* DiscardPolicy; /* "oldest" (default) | "newest" | "halt" */ + size_t CapacityThreshold; /* --capacity-threshold (bytes; 0 disables) */ + bool HaltExit; /* --halt-exit */ + bool NoSd; /* --no-sd (suppress structured data) */ }; /* Minimal CLI parser — recognises the flags below. Unknown flags and diff --git a/CLAUDE.md b/CLAUDE.md index 91ffe4f3..57dc5158 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -394,7 +394,8 @@ public identifier. One-line summary: public C functions `SolidSyslogClass_Function`, public types `SolidSyslogClass`, public macros `SOLIDSYSLOG_SCREAMING_SNAKE`, file-scope statics `Class_Function` / `CLASS_SCREAMING_SNAKE`, -locals/parameters/members `lowerCamelCase`, files `PascalCase.c`. No +struct members `PascalCase` (data + vtable function-pointer alike), +locals/parameters `lowerCamelCase`, files `PascalCase.c`. No Hungarian notation. No member-variable prefixes. No `typedef struct` for project-owned struct types. diff --git a/Core/Interface/SolidSyslog.h b/Core/Interface/SolidSyslog.h index 0321de3b..50eba0d7 100644 --- a/Core/Interface/SolidSyslog.h +++ b/Core/Interface/SolidSyslog.h @@ -8,10 +8,10 @@ EXTERN_C_BEGIN struct SolidSyslogMessage { - enum SolidSyslogFacility facility; - enum SolidSyslogSeverity severity; - const char* messageId; - const char* msg; + enum SolidSyslogFacility Facility; + enum SolidSyslogSeverity Severity; + const char* MessageId; + const char* Msg; }; void SolidSyslog_Log(const struct SolidSyslogMessage* message); diff --git a/Core/Interface/SolidSyslogBlockStore.h b/Core/Interface/SolidSyslogBlockStore.h index 0d4333f5..dae67f17 100644 --- a/Core/Interface/SolidSyslogBlockStore.h +++ b/Core/Interface/SolidSyslogBlockStore.h @@ -36,16 +36,16 @@ EXTERN_C_BEGIN { /* Required. Caller-owned: must outlive the BlockStore. SolidSyslogBlockStore_Destroy * does NOT destroy the block device — that is the integrator's responsibility. */ - struct SolidSyslogBlockDevice* blockDevice; - size_t maxBlockSize; - size_t maxBlocks; - enum SolidSyslogDiscardPolicy discardPolicy; - struct SolidSyslogSecurityPolicy* securityPolicy; - SolidSyslogStoreFullCallback onStoreFull; - void* storeFullContext; - SolidSyslogStoreThresholdFunction getCapacityThreshold; - SolidSyslogStoreThresholdCallback onThresholdCrossed; - void* thresholdContext; + struct SolidSyslogBlockDevice* BlockDevice; + size_t MaxBlockSize; + size_t MaxBlocks; + enum SolidSyslogDiscardPolicy DiscardPolicy; + struct SolidSyslogSecurityPolicy* SecurityPolicy; + SolidSyslogStoreFullCallback OnStoreFull; + void* StoreFullContext; + SolidSyslogStoreThresholdFunction GetCapacityThreshold; + SolidSyslogStoreThresholdCallback OnThresholdCrossed; + void* ThresholdContext; }; enum diff --git a/Core/Interface/SolidSyslogConfig.h b/Core/Interface/SolidSyslogConfig.h index dc74f53b..f69b4959 100644 --- a/Core/Interface/SolidSyslogConfig.h +++ b/Core/Interface/SolidSyslogConfig.h @@ -17,15 +17,15 @@ EXTERN_C_BEGIN struct SolidSyslogConfig { - struct SolidSyslogBuffer* buffer; - struct SolidSyslogSender* sender; - SolidSyslogClockFunction clock; - SolidSyslogStringFunction getHostname; - SolidSyslogStringFunction getAppName; - SolidSyslogStringFunction getProcessId; - struct SolidSyslogStore* store; - struct SolidSyslogStructuredData** sd; - size_t sdCount; + struct SolidSyslogBuffer* Buffer; + struct SolidSyslogSender* Sender; + SolidSyslogClockFunction Clock; + SolidSyslogStringFunction GetHostname; + SolidSyslogStringFunction GetAppName; + SolidSyslogStringFunction GetProcessId; + struct SolidSyslogStore* Store; + struct SolidSyslogStructuredData** Sd; + size_t SdCount; }; void SolidSyslog_Create(const struct SolidSyslogConfig* config); diff --git a/Core/Interface/SolidSyslogEndpoint.h b/Core/Interface/SolidSyslogEndpoint.h index a4d7411e..8da3b8be 100644 --- a/Core/Interface/SolidSyslogEndpoint.h +++ b/Core/Interface/SolidSyslogEndpoint.h @@ -14,8 +14,8 @@ EXTERN_C_BEGIN struct SolidSyslogEndpoint { - struct SolidSyslogFormatter* host; /* library-provided; user writes destination host into it */ - uint16_t port; /* user assigns destination port */ + struct SolidSyslogFormatter* Host; /* library-provided; user writes destination host into it */ + uint16_t Port; /* user assigns destination port */ }; typedef void (*SolidSyslogEndpointFunction)(struct SolidSyslogEndpoint* endpoint); diff --git a/Core/Interface/SolidSyslogMetaSd.h b/Core/Interface/SolidSyslogMetaSd.h index 5c0586ed..2f690271 100644 --- a/Core/Interface/SolidSyslogMetaSd.h +++ b/Core/Interface/SolidSyslogMetaSd.h @@ -15,9 +15,9 @@ EXTERN_C_BEGIN struct SolidSyslogMetaSdConfig { - struct SolidSyslogAtomicCounter* counter; - SolidSyslogSysUpTimeFunction getSysUpTime; - SolidSyslogStringFunction getLanguage; + struct SolidSyslogAtomicCounter* Counter; + SolidSyslogSysUpTimeFunction GetSysUpTime; + SolidSyslogStringFunction GetLanguage; }; struct SolidSyslogStructuredData* SolidSyslogMetaSd_Create(const struct SolidSyslogMetaSdConfig* config); diff --git a/Core/Interface/SolidSyslogOriginSd.h b/Core/Interface/SolidSyslogOriginSd.h index 58c13d0c..daeb7971 100644 --- a/Core/Interface/SolidSyslogOriginSd.h +++ b/Core/Interface/SolidSyslogOriginSd.h @@ -15,11 +15,11 @@ EXTERN_C_BEGIN struct SolidSyslogOriginSdConfig { - const char* software; - const char* swVersion; - const char* enterpriseId; - SolidSyslogOriginIpCountFunction getIpCount; - SolidSyslogOriginIpAtFunction getIpAt; + const char* Software; + const char* SwVersion; + const char* EnterpriseId; + SolidSyslogOriginIpCountFunction GetIpCount; + SolidSyslogOriginIpAtFunction GetIpAt; }; struct SolidSyslogStructuredData* SolidSyslogOriginSd_Create(const struct SolidSyslogOriginSdConfig* config); diff --git a/Core/Interface/SolidSyslogSecurityPolicyDefinition.h b/Core/Interface/SolidSyslogSecurityPolicyDefinition.h index 6096bf72..1884ebfd 100644 --- a/Core/Interface/SolidSyslogSecurityPolicyDefinition.h +++ b/Core/Interface/SolidSyslogSecurityPolicyDefinition.h @@ -16,7 +16,7 @@ EXTERN_C_BEGIN struct SolidSyslogSecurityPolicy { - uint16_t integritySize; + uint16_t IntegritySize; void (*ComputeIntegrity)(const uint8_t* data, uint16_t length, uint8_t* integrityOut); bool (*VerifyIntegrity)(const uint8_t* data, uint16_t length, const uint8_t* integrityIn); }; diff --git a/Core/Interface/SolidSyslogStreamSender.h b/Core/Interface/SolidSyslogStreamSender.h index c15064cb..0b61c4ee 100644 --- a/Core/Interface/SolidSyslogStreamSender.h +++ b/Core/Interface/SolidSyslogStreamSender.h @@ -12,10 +12,10 @@ EXTERN_C_BEGIN struct SolidSyslogStreamSenderConfig { - struct SolidSyslogResolver* resolver; - struct SolidSyslogStream* stream; - SolidSyslogEndpointFunction endpoint; /* fills host/port; called only on (re)connect */ - SolidSyslogEndpointVersionFunction endpointVersion; /* polled cheaply on every Send for stale check */ + struct SolidSyslogResolver* Resolver; + struct SolidSyslogStream* Stream; + SolidSyslogEndpointFunction Endpoint; /* fills host/port; called only on (re)connect */ + SolidSyslogEndpointVersionFunction EndpointVersion; /* polled cheaply on every Send for stale check */ }; enum diff --git a/Core/Interface/SolidSyslogSwitchingSender.h b/Core/Interface/SolidSyslogSwitchingSender.h index c2461db8..d2860d74 100644 --- a/Core/Interface/SolidSyslogSwitchingSender.h +++ b/Core/Interface/SolidSyslogSwitchingSender.h @@ -12,9 +12,9 @@ EXTERN_C_BEGIN struct SolidSyslogSwitchingSenderConfig { - struct SolidSyslogSender** senders; - size_t senderCount; - SolidSyslogSwitchingSenderSelector selector; + struct SolidSyslogSender** Senders; + size_t SenderCount; + SolidSyslogSwitchingSenderSelector Selector; }; struct SolidSyslogSender* SolidSyslogSwitchingSender_Create(const struct SolidSyslogSwitchingSenderConfig* config); diff --git a/Core/Interface/SolidSyslogTimeQuality.h b/Core/Interface/SolidSyslogTimeQuality.h index 0b1afc5e..f0e0968d 100644 --- a/Core/Interface/SolidSyslogTimeQuality.h +++ b/Core/Interface/SolidSyslogTimeQuality.h @@ -15,9 +15,9 @@ EXTERN_C_BEGIN struct SolidSyslogTimeQuality { - bool tzKnown; - bool isSynced; - uint32_t syncAccuracyMicroseconds; /* SOLIDSYSLOG_SYNC_ACCURACY_OMIT to omit from output */ + bool TzKnown; + bool IsSynced; + uint32_t SyncAccuracyMicroseconds; /* SOLIDSYSLOG_SYNC_ACCURACY_OMIT to omit from output */ }; typedef void (*SolidSyslogTimeQualityFunction)(struct SolidSyslogTimeQuality* timeQuality); diff --git a/Core/Interface/SolidSyslogTimestamp.h b/Core/Interface/SolidSyslogTimestamp.h index 82305584..4e0e29d8 100644 --- a/Core/Interface/SolidSyslogTimestamp.h +++ b/Core/Interface/SolidSyslogTimestamp.h @@ -19,15 +19,15 @@ EXTERN_C_BEGIN struct SolidSyslogTimestamp { uint16_t - year; /* Gregorian year, e.g. 2026. Not independently validated — clocks are trusted to produce a sensible value. */ - uint8_t month; /* 1-12. */ - uint8_t day; /* 1-31. */ - uint8_t hour; /* 0-23. */ - uint8_t minute; /* 0-59. */ - uint8_t second; /* 0-59. Leap seconds are not represented. */ - uint32_t microsecond; /* 0-999999. */ + Year; /* Gregorian year, e.g. 2026. Not independently validated — clocks are trusted to produce a sensible value. */ + uint8_t Month; /* 1-12. */ + uint8_t Day; /* 1-31. */ + uint8_t Hour; /* 0-23. */ + uint8_t Minute; /* 0-59. */ + uint8_t Second; /* 0-59. Leap seconds are not represented. */ + uint32_t Microsecond; /* 0-999999. */ int16_t - utcOffsetMinutes; /* Offset from UTC in minutes; 0 for UTC. Must be -720..840 (UTC-12:00 to UTC+14:00). */ + UtcOffsetMinutes; /* Offset from UTC in minutes; 0 for UTC. Must be -720..840 (UTC-12:00 to UTC+14:00). */ }; typedef void (*SolidSyslogClockFunction)(struct SolidSyslogTimestamp* timestamp); diff --git a/Core/Interface/SolidSyslogUdpSender.h b/Core/Interface/SolidSyslogUdpSender.h index e3aa4b39..a6c800a9 100644 --- a/Core/Interface/SolidSyslogUdpSender.h +++ b/Core/Interface/SolidSyslogUdpSender.h @@ -8,10 +8,10 @@ EXTERN_C_BEGIN struct SolidSyslogUdpSenderConfig { - struct SolidSyslogResolver* resolver; - struct SolidSyslogDatagram* datagram; - SolidSyslogEndpointFunction endpoint; /* fills host/port; called only on (re)connect */ - SolidSyslogEndpointVersionFunction endpointVersion; /* polled cheaply on every Send for stale check */ + struct SolidSyslogResolver* Resolver; + struct SolidSyslogDatagram* Datagram; + SolidSyslogEndpointFunction Endpoint; /* fills host/port; called only on (re)connect */ + SolidSyslogEndpointVersionFunction EndpointVersion; /* polled cheaply on every Send for stale check */ }; struct SolidSyslogSender* SolidSyslogUdpSender_Create(const struct SolidSyslogUdpSenderConfig* config); diff --git a/Core/Source/BlockSequence.c b/Core/Source/BlockSequence.c index 7e9b5c1e..34ff3633 100644 --- a/Core/Source/BlockSequence.c +++ b/Core/Source/BlockSequence.c @@ -16,7 +16,7 @@ static inline uint8_t BlockSequence_NextSequence(uint8_t current) static inline size_t BlockSequence_BlockCount(const struct BlockSequence* blockSequence) { - return (size_t) ((blockSequence->writeSequence - blockSequence->oldestSequence + SEQUENCE_MODULUS) % + return (size_t) ((blockSequence->WriteSequence - blockSequence->OldestSequence + SEQUENCE_MODULUS) % SEQUENCE_MODULUS) + 1; } @@ -41,24 +41,24 @@ static inline size_t BlockSequence_ClampToRange(size_t value, size_t min, size_t void BlockSequence_Init(struct BlockSequence* blockSequence, const struct BlockSequenceConfig* config) { - blockSequence->blockDevice = config->blockDevice; - blockSequence->maxBlockSize = config->maxBlockSize; - blockSequence->maxBlocks = BlockSequence_ClampToRange(config->maxBlocks, MIN_MAX_BLOCKS, MAX_MAX_BLOCKS); - blockSequence->discardPolicy = config->discardPolicy; - blockSequence->onStoreFull = config->onStoreFull; - blockSequence->storeFullContext = config->storeFullContext; - blockSequence->getCapacityThreshold = config->getCapacityThreshold; - blockSequence->onThresholdCrossed = config->onThresholdCrossed; - blockSequence->thresholdContext = config->thresholdContext; - blockSequence->halted = false; - blockSequence->atCapacity = false; - blockSequence->thresholdCrossed = false; - blockSequence->oldestSequence = 0; - blockSequence->readSequence = 0; - blockSequence->writeSequence = 0; - blockSequence->readCursor = 0; - blockSequence->writePosition = 0; - blockSequence->writeBlockCorrupt = false; + blockSequence->BlockDevice = config->BlockDevice; + blockSequence->MaxBlockSize = config->MaxBlockSize; + blockSequence->MaxBlocks = BlockSequence_ClampToRange(config->MaxBlocks, MIN_MAX_BLOCKS, MAX_MAX_BLOCKS); + blockSequence->DiscardPolicy = config->DiscardPolicy; + blockSequence->OnStoreFull = config->OnStoreFull; + blockSequence->StoreFullContext = config->StoreFullContext; + blockSequence->GetCapacityThreshold = config->GetCapacityThreshold; + blockSequence->OnThresholdCrossed = config->OnThresholdCrossed; + blockSequence->ThresholdContext = config->ThresholdContext; + blockSequence->Halted = false; + blockSequence->AtCapacity = false; + blockSequence->ThresholdCrossed = false; + blockSequence->OldestSequence = 0; + blockSequence->ReadSequence = 0; + blockSequence->WriteSequence = 0; + blockSequence->ReadCursor = 0; + blockSequence->WritePosition = 0; + blockSequence->WriteBlockCorrupt = false; } static bool BlockSequence_ScanForExistingBlocks(struct BlockSequence* blockSequence); @@ -71,13 +71,13 @@ bool BlockSequence_Open(struct BlockSequence* blockSequence) if (foundExistingBlocks) { - blockSequence->writePosition = - SolidSyslogBlockDevice_Size(blockSequence->blockDevice, blockSequence->writeSequence); + blockSequence->WritePosition = + SolidSyslogBlockDevice_Size(blockSequence->BlockDevice, blockSequence->WriteSequence); ready = true; } else { - ready = SolidSyslogBlockDevice_Acquire(blockSequence->blockDevice, 0); + ready = SolidSyslogBlockDevice_Acquire(blockSequence->BlockDevice, 0); } if (ready) @@ -95,10 +95,10 @@ enum struct BlockPresence { - bool present[MAX_SEQUENCE]; - bool foundAny; - bool foundAbsent; - int firstAbsent; + bool Present[MAX_SEQUENCE]; + bool FoundAny; + bool FoundAbsent; + int FirstAbsent; }; static inline int BlockSequence_CircularPrev(int index); @@ -118,38 +118,38 @@ static bool BlockSequence_ScanForExistingBlocks(struct BlockSequence* blockSeque struct BlockPresence presence; BlockSequence_ScanForBlockPresence(blockSequence, &presence); - if (presence.foundAny) + if (presence.FoundAny) { int oldest = 0; int newest = MAX_SEQUENCE - 1; BlockSequence_LocateRunBoundaries(&presence, &oldest, &newest); - blockSequence->oldestSequence = (uint8_t) oldest; - blockSequence->readSequence = (uint8_t) oldest; - blockSequence->writeSequence = (uint8_t) newest; + blockSequence->OldestSequence = (uint8_t) oldest; + blockSequence->ReadSequence = (uint8_t) oldest; + blockSequence->WriteSequence = (uint8_t) newest; } - return presence.foundAny; + return presence.FoundAny; } static void BlockSequence_ScanForBlockPresence(struct BlockSequence* blockSequence, struct BlockPresence* presence) { - presence->foundAny = false; - presence->foundAbsent = false; - presence->firstAbsent = 0; + presence->FoundAny = false; + presence->FoundAbsent = false; + presence->FirstAbsent = 0; for (int seq = 0; seq < MAX_SEQUENCE; seq++) { - presence->present[seq] = SolidSyslogBlockDevice_Exists(blockSequence->blockDevice, (size_t) seq); + presence->Present[seq] = SolidSyslogBlockDevice_Exists(blockSequence->BlockDevice, (size_t) seq); - if (presence->present[seq]) + if (presence->Present[seq]) { - presence->foundAny = true; + presence->FoundAny = true; } - else if (!presence->foundAbsent) + else if (!presence->FoundAbsent) { - presence->firstAbsent = seq; - presence->foundAbsent = true; + presence->FirstAbsent = seq; + presence->FoundAbsent = true; } } } @@ -157,16 +157,16 @@ static void BlockSequence_ScanForBlockPresence(struct BlockSequence* blockSequen // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) -- oldest / newest are positional run endpoints; distinct semantics static void BlockSequence_LocateRunBoundaries(const struct BlockPresence* presence, int* oldest, int* newest) { - if (presence->foundAbsent) + if (presence->FoundAbsent) { - *oldest = BlockSequence_CircularNext(presence->firstAbsent); - while (!presence->present[*oldest]) + *oldest = BlockSequence_CircularNext(presence->FirstAbsent); + while (!presence->Present[*oldest]) { *oldest = BlockSequence_CircularNext(*oldest); } - *newest = BlockSequence_CircularPrev(presence->firstAbsent); - while (!presence->present[*newest]) + *newest = BlockSequence_CircularPrev(presence->FirstAbsent); + while (!presence->Present[*newest]) { *newest = BlockSequence_CircularPrev(*newest); } @@ -199,7 +199,7 @@ bool BlockSequence_PrepareForWrite(struct BlockSequence* blockSequence, size_t r if (blockFull && BlockSequence_StoreIsFull(blockSequence)) { - blockSequence->atCapacity = true; /* sticky 100% — fixes UsedBytes at total */ + blockSequence->AtCapacity = true; /* sticky 100% — fixes UsedBytes at total */ BlockSequence_NotifyThresholdCrossed(blockSequence); /* threshold first per S05.09 ordering */ BlockSequence_NotifyStoreFull(blockSequence); spaceAvailable = false; @@ -214,25 +214,25 @@ bool BlockSequence_PrepareForWrite(struct BlockSequence* blockSequence, size_t r static inline bool BlockSequence_BlockIsFull(const struct BlockSequence* blockSequence, size_t recordSize) { - return (blockSequence->writeBlockCorrupt) || - ((blockSequence->writePosition + recordSize) > blockSequence->maxBlockSize); + return (blockSequence->WriteBlockCorrupt) || + ((blockSequence->WritePosition + recordSize) > blockSequence->MaxBlockSize); } static inline bool BlockSequence_StoreIsFull(const struct BlockSequence* blockSequence) { - return (BlockSequence_BlockCount(blockSequence) >= blockSequence->maxBlocks) && - (blockSequence->discardPolicy != SolidSyslogDiscardPolicy_Oldest); + return (BlockSequence_BlockCount(blockSequence) >= blockSequence->MaxBlocks) && + (blockSequence->DiscardPolicy != SolidSyslogDiscardPolicy_Oldest); } static inline void BlockSequence_NotifyStoreFull(struct BlockSequence* blockSequence) { - if ((blockSequence->discardPolicy == SolidSyslogDiscardPolicy_Halt) && !blockSequence->halted) + if ((blockSequence->DiscardPolicy == SolidSyslogDiscardPolicy_Halt) && !blockSequence->Halted) { - blockSequence->halted = true; + blockSequence->Halted = true; - if (blockSequence->onStoreFull != NULL) + if (blockSequence->OnStoreFull != NULL) { - blockSequence->onStoreFull(blockSequence->storeFullContext); + blockSequence->OnStoreFull(blockSequence->StoreFullContext); } } } @@ -246,8 +246,8 @@ static inline bool BlockSequence_AcquireEmptyBlock(struct SolidSyslogBlockDevice static bool BlockSequence_RotateToNextBlock(struct BlockSequence* blockSequence, bool* readBlockChanged) { - uint8_t nextSequence = BlockSequence_NextSequence(blockSequence->writeSequence); - bool acquired = BlockSequence_AcquireEmptyBlock(blockSequence->blockDevice, nextSequence); + uint8_t nextSequence = BlockSequence_NextSequence(blockSequence->WriteSequence); + bool acquired = BlockSequence_AcquireEmptyBlock(blockSequence->BlockDevice, nextSequence); *readBlockChanged = false; @@ -300,24 +300,24 @@ static inline bool BlockSequence_AcquireEmptyBlock(struct SolidSyslogBlockDevice static inline void BlockSequence_AdvanceWriteToNewBlock(struct BlockSequence* blockSequence, uint8_t nextSequence) { - blockSequence->writeSequence = nextSequence; - blockSequence->writePosition = 0; - blockSequence->writeBlockCorrupt = false; + blockSequence->WriteSequence = nextSequence; + blockSequence->WritePosition = 0; + blockSequence->WriteBlockCorrupt = false; } static inline bool BlockSequence_ExceedsMaxBlocks(const struct BlockSequence* blockSequence) { - return BlockSequence_BlockCount(blockSequence) > blockSequence->maxBlocks; + return BlockSequence_BlockCount(blockSequence) > blockSequence->MaxBlocks; } static bool BlockSequence_DiscardOldestBlock(struct BlockSequence* blockSequence) { bool readBlockChanged = false; - if (SolidSyslogBlockDevice_Dispose(blockSequence->blockDevice, blockSequence->oldestSequence)) + if (SolidSyslogBlockDevice_Dispose(blockSequence->BlockDevice, blockSequence->OldestSequence)) { - bool readingOldestBlock = (blockSequence->readSequence == blockSequence->oldestSequence); - blockSequence->oldestSequence = BlockSequence_NextSequence(blockSequence->oldestSequence); + bool readingOldestBlock = (blockSequence->ReadSequence == blockSequence->OldestSequence); + blockSequence->OldestSequence = BlockSequence_NextSequence(blockSequence->OldestSequence); if (readingOldestBlock) { @@ -331,23 +331,23 @@ static bool BlockSequence_DiscardOldestBlock(struct BlockSequence* blockSequence static void BlockSequence_ResetReadToOldest(struct BlockSequence* blockSequence) { - blockSequence->readSequence = blockSequence->oldestSequence; - blockSequence->readCursor = 0; + blockSequence->ReadSequence = blockSequence->OldestSequence; + blockSequence->ReadCursor = 0; } struct SolidSyslogBlockDevice* BlockSequence_BlockDevice(const struct BlockSequence* blockSequence) { - return blockSequence->blockDevice; + return blockSequence->BlockDevice; } size_t BlockSequence_WriteSequence(const struct BlockSequence* blockSequence) { - return blockSequence->writeSequence; + return blockSequence->WriteSequence; } void BlockSequence_NoteRecordWritten(struct BlockSequence* blockSequence, size_t recordSize) { - blockSequence->writePosition += recordSize; + blockSequence->WritePosition += recordSize; BlockSequence_NotifyThresholdCrossed(blockSequence); } @@ -358,23 +358,23 @@ static inline void BlockSequence_NotifyThresholdCrossed(struct BlockSequence* bl { if (BlockSequence_ThresholdEnabled(blockSequence)) { - size_t threshold = blockSequence->getCapacityThreshold(blockSequence->thresholdContext); + size_t threshold = blockSequence->GetCapacityThreshold(blockSequence->ThresholdContext); if (!BlockSequence_IsAboveThreshold(blockSequence, threshold)) { - blockSequence->thresholdCrossed = false; + blockSequence->ThresholdCrossed = false; } - else if (!blockSequence->thresholdCrossed) + else if (!blockSequence->ThresholdCrossed) { - blockSequence->thresholdCrossed = true; - blockSequence->onThresholdCrossed(blockSequence->thresholdContext); + blockSequence->ThresholdCrossed = true; + blockSequence->OnThresholdCrossed(blockSequence->ThresholdContext); } } } static inline bool BlockSequence_ThresholdEnabled(const struct BlockSequence* blockSequence) { - return (blockSequence->onThresholdCrossed != NULL) && (blockSequence->getCapacityThreshold != NULL); + return (blockSequence->OnThresholdCrossed != NULL) && (blockSequence->GetCapacityThreshold != NULL); } static inline bool BlockSequence_IsAboveThreshold(const struct BlockSequence* blockSequence, size_t threshold) @@ -384,22 +384,22 @@ static inline bool BlockSequence_IsAboveThreshold(const struct BlockSequence* bl void BlockSequence_MarkWriteBlockCorrupt(struct BlockSequence* blockSequence) { - blockSequence->writeBlockCorrupt = true; + blockSequence->WriteBlockCorrupt = true; } size_t BlockSequence_ReadSequence(const struct BlockSequence* blockSequence) { - return blockSequence->readSequence; + return blockSequence->ReadSequence; } size_t BlockSequence_ReadCursor(const struct BlockSequence* blockSequence) { - return blockSequence->readCursor; + return blockSequence->ReadCursor; } void BlockSequence_SetReadCursor(struct BlockSequence* blockSequence, size_t cursor) { - blockSequence->readCursor = cursor; + blockSequence->ReadCursor = cursor; } static inline bool BlockSequence_IsReadBlockActiveWrite(const struct BlockSequence* blockSequence); @@ -414,7 +414,7 @@ void BlockSequence_DisposeReadBlockIfDrained(struct BlockSequence* blockSequence if (!BlockSequence_IsReadBlockActiveWrite(blockSequence) && BlockSequence_IsReadBlockOldest(blockSequence) && BlockSequence_IsReadBlockFullyDrained(blockSequence)) { - if (SolidSyslogBlockDevice_Dispose(blockSequence->blockDevice, blockSequence->readSequence)) + if (SolidSyslogBlockDevice_Dispose(blockSequence->BlockDevice, blockSequence->ReadSequence)) { BlockSequence_AdvancePastDrainedReadBlock(blockSequence); *readBlockChanged = true; @@ -424,66 +424,66 @@ void BlockSequence_DisposeReadBlockIfDrained(struct BlockSequence* blockSequence static inline bool BlockSequence_IsReadBlockActiveWrite(const struct BlockSequence* blockSequence) { - return blockSequence->readSequence == blockSequence->writeSequence; + return blockSequence->ReadSequence == blockSequence->WriteSequence; } static inline bool BlockSequence_IsReadBlockOldest(const struct BlockSequence* blockSequence) { - return blockSequence->readSequence == blockSequence->oldestSequence; + return blockSequence->ReadSequence == blockSequence->OldestSequence; } static inline bool BlockSequence_IsReadBlockFullyDrained(const struct BlockSequence* blockSequence) { - return blockSequence->readCursor >= - SolidSyslogBlockDevice_Size(blockSequence->blockDevice, blockSequence->readSequence); + return blockSequence->ReadCursor >= + SolidSyslogBlockDevice_Size(blockSequence->BlockDevice, blockSequence->ReadSequence); } static inline void BlockSequence_AdvancePastDrainedReadBlock(struct BlockSequence* blockSequence) { - blockSequence->oldestSequence = BlockSequence_NextSequence(blockSequence->oldestSequence); - blockSequence->readSequence = blockSequence->oldestSequence; - blockSequence->readCursor = 0; + blockSequence->OldestSequence = BlockSequence_NextSequence(blockSequence->OldestSequence); + blockSequence->ReadSequence = blockSequence->OldestSequence; + blockSequence->ReadCursor = 0; BlockSequence_NotifyThresholdCrossed(blockSequence); } void BlockSequence_AdvanceToNextReadBlock(struct BlockSequence* blockSequence) { - blockSequence->readSequence = BlockSequence_NextSequence(blockSequence->readSequence); - blockSequence->readCursor = 0; + blockSequence->ReadSequence = BlockSequence_NextSequence(blockSequence->ReadSequence); + blockSequence->ReadCursor = 0; } bool BlockSequence_ReadIsBehindWrite(const struct BlockSequence* blockSequence) { - return blockSequence->readSequence != blockSequence->writeSequence; + return blockSequence->ReadSequence != blockSequence->WriteSequence; } bool BlockSequence_HasUnsent(const struct BlockSequence* blockSequence) { - return BlockSequence_ReadIsBehindWrite(blockSequence) || (blockSequence->readCursor < blockSequence->writePosition); + return BlockSequence_ReadIsBehindWrite(blockSequence) || (blockSequence->ReadCursor < blockSequence->WritePosition); } bool BlockSequence_IsHalted(const struct BlockSequence* blockSequence) { - return blockSequence->halted; + return blockSequence->Halted; } size_t BlockSequence_TotalBytes(const struct BlockSequence* blockSequence) { - return blockSequence->maxBlocks * blockSequence->maxBlockSize; + return blockSequence->MaxBlocks * blockSequence->MaxBlockSize; } size_t BlockSequence_UsedBytes(const struct BlockSequence* blockSequence) { size_t used = 0; - if (blockSequence->atCapacity) + if (blockSequence->AtCapacity) { used = BlockSequence_TotalBytes(blockSequence); } else { size_t closedBlocks = BlockSequence_BlockCount(blockSequence) - 1; - used = (closedBlocks * blockSequence->maxBlockSize) + blockSequence->writePosition; + used = (closedBlocks * blockSequence->MaxBlockSize) + blockSequence->WritePosition; } return used; diff --git a/Core/Source/BlockSequence.h b/Core/Source/BlockSequence.h index 0b3db9f7..50bf33d0 100644 --- a/Core/Source/BlockSequence.h +++ b/Core/Source/BlockSequence.h @@ -11,37 +11,37 @@ struct SolidSyslogBlockDevice; struct BlockSequenceConfig { - struct SolidSyslogBlockDevice* blockDevice; - size_t maxBlockSize; - size_t maxBlocks; - enum SolidSyslogDiscardPolicy discardPolicy; - SolidSyslogStoreFullCallback onStoreFull; - void* storeFullContext; - SolidSyslogStoreThresholdFunction getCapacityThreshold; - SolidSyslogStoreThresholdCallback onThresholdCrossed; - void* thresholdContext; + struct SolidSyslogBlockDevice* BlockDevice; + size_t MaxBlockSize; + size_t MaxBlocks; + enum SolidSyslogDiscardPolicy DiscardPolicy; + SolidSyslogStoreFullCallback OnStoreFull; + void* StoreFullContext; + SolidSyslogStoreThresholdFunction GetCapacityThreshold; + SolidSyslogStoreThresholdCallback OnThresholdCrossed; + void* ThresholdContext; }; struct BlockSequence { - struct SolidSyslogBlockDevice* blockDevice; - size_t maxBlockSize; - size_t maxBlocks; - enum SolidSyslogDiscardPolicy discardPolicy; - SolidSyslogStoreFullCallback onStoreFull; - void* storeFullContext; - SolidSyslogStoreThresholdFunction getCapacityThreshold; - SolidSyslogStoreThresholdCallback onThresholdCrossed; - void* thresholdContext; - bool halted; - bool atCapacity; - bool thresholdCrossed; - uint8_t oldestSequence; - uint8_t readSequence; - uint8_t writeSequence; - size_t readCursor; - size_t writePosition; - bool writeBlockCorrupt; + struct SolidSyslogBlockDevice* BlockDevice; + size_t MaxBlockSize; + size_t MaxBlocks; + enum SolidSyslogDiscardPolicy DiscardPolicy; + SolidSyslogStoreFullCallback OnStoreFull; + void* StoreFullContext; + SolidSyslogStoreThresholdFunction GetCapacityThreshold; + SolidSyslogStoreThresholdCallback OnThresholdCrossed; + void* ThresholdContext; + bool Halted; + bool AtCapacity; + bool ThresholdCrossed; + uint8_t OldestSequence; + uint8_t ReadSequence; + uint8_t WriteSequence; + size_t ReadCursor; + size_t WritePosition; + bool WriteBlockCorrupt; }; void BlockSequence_Init(struct BlockSequence* blockSequence, const struct BlockSequenceConfig* config); diff --git a/Core/Source/RecordStore.c b/Core/Source/RecordStore.c index e6fe6205..33e1194c 100644 --- a/Core/Source/RecordStore.c +++ b/Core/Source/RecordStore.c @@ -24,7 +24,7 @@ enum static inline uint8_t* RecordStore_MagicAddress(struct RecordStore* recordStore) { - return recordStore->buffer; + return recordStore->Buffer; } static inline uint8_t* RecordStore_LengthAddress(struct RecordStore* recordStore) @@ -44,7 +44,7 @@ static inline uint8_t* RecordStore_IntegrityChecksumAddress(struct RecordStore* static inline uint8_t* RecordStore_SentFlagAddress(struct RecordStore* recordStore, size_t dataSize) { - return RecordStore_IntegrityChecksumAddress(recordStore, dataSize) + recordStore->securityPolicy->integritySize; + return RecordStore_IntegrityChecksumAddress(recordStore, dataSize) + recordStore->SecurityPolicy->IntegritySize; } static inline uint8_t* RecordStore_IntegrityRegionAddress(struct RecordStore* recordStore) @@ -68,20 +68,20 @@ static inline size_t RecordStore_SentFlagOffset( uint16_t dataLength ) { - return RecordStore_IntegrityChecksumOffset(recordStart, dataLength) + recordStore->securityPolicy->integritySize; + return RecordStore_IntegrityChecksumOffset(recordStart, dataLength) + recordStore->SecurityPolicy->IntegritySize; } void RecordStore_Init(struct RecordStore* recordStore, struct SolidSyslogSecurityPolicy* securityPolicy) { - recordStore->securityPolicy = securityPolicy; - recordStore->hasReadRecord = false; - recordStore->lastReadBlockIndex = 0; - recordStore->lastSentFlagOffset = 0; + recordStore->SecurityPolicy = securityPolicy; + recordStore->HasReadRecord = false; + recordStore->LastReadBlockIndex = 0; + recordStore->LastSentFlagOffset = 0; } size_t RecordStore_RecordSize(const struct RecordStore* recordStore, uint16_t dataLength) { - return (size_t) MAGIC_SIZE + RECORD_LENGTH_SIZE + dataLength + recordStore->securityPolicy->integritySize + + return (size_t) MAGIC_SIZE + RECORD_LENGTH_SIZE + dataLength + recordStore->SecurityPolicy->IntegritySize + SENT_FLAG_SIZE; } @@ -99,7 +99,7 @@ bool RecordStore_Append( return SolidSyslogBlockDevice_Append( blockDevice, blockIndex, - recordStore->buffer, + recordStore->Buffer, RecordStore_RecordSize(recordStore, (uint16_t) dataSize) ); } @@ -113,7 +113,7 @@ static inline void RecordStore_AssembleRecord(struct RecordStore* recordStore, c memcpy(RecordStore_LengthAddress(recordStore), &length, RECORD_LENGTH_SIZE); memcpy(RecordStore_MessageAddress(recordStore), data, size); - recordStore->securityPolicy->ComputeIntegrity( + recordStore->SecurityPolicy->ComputeIntegrity( RecordStore_IntegrityRegionAddress(recordStore), RecordStore_IntegrityRegionSize(size), RecordStore_IntegrityChecksumAddress(recordStore, size) @@ -289,13 +289,13 @@ static inline bool RecordStore_ReadIntegrityChecksum( blockIndex, RecordStore_IntegrityChecksumOffset(recordStart, dataLength), RecordStore_IntegrityChecksumAddress(recordStore, dataLength), - recordStore->securityPolicy->integritySize + recordStore->SecurityPolicy->IntegritySize ); } static inline bool RecordStore_VerifyIntegrity(struct RecordStore* recordStore, uint16_t length) { - return recordStore->securityPolicy->VerifyIntegrity( + return recordStore->SecurityPolicy->VerifyIntegrity( RecordStore_IntegrityRegionAddress(recordStore), RecordStore_IntegrityRegionSize(length), RecordStore_IntegrityChecksumAddress(recordStore, length) @@ -328,9 +328,9 @@ static inline void RecordStore_RememberCurrentRecord( uint16_t length ) { - recordStore->lastReadBlockIndex = blockIndex; - recordStore->lastSentFlagOffset = RecordStore_SentFlagOffset(recordStore, offset, length); - recordStore->hasReadRecord = true; + recordStore->LastReadBlockIndex = blockIndex; + recordStore->LastSentFlagOffset = RecordStore_SentFlagOffset(recordStore, offset, length); + recordStore->HasReadRecord = true; } // NOLINTEND(bugprone-easily-swappable-parameters) @@ -348,10 +348,10 @@ bool RecordStore_MarkLastReadAsSent( { bool marked = false; - if (recordStore->hasReadRecord && RecordStore_WriteSentFlag(recordStore, blockDevice)) + if (recordStore->HasReadRecord && RecordStore_WriteSentFlag(recordStore, blockDevice)) { - *nextCursor = recordStore->lastSentFlagOffset + SENT_FLAG_SIZE; - recordStore->hasReadRecord = false; + *nextCursor = recordStore->LastSentFlagOffset + SENT_FLAG_SIZE; + recordStore->HasReadRecord = false; marked = true; } @@ -366,8 +366,8 @@ static inline bool RecordStore_WriteSentFlag( uint8_t flag = SENT_FLAG_SENT; return SolidSyslogBlockDevice_WriteAt( blockDevice, - recordStore->lastReadBlockIndex, - recordStore->lastSentFlagOffset, + recordStore->LastReadBlockIndex, + recordStore->LastSentFlagOffset, &flag, SENT_FLAG_SIZE ); @@ -375,7 +375,7 @@ static inline bool RecordStore_WriteSentFlag( void RecordStore_ForgetLastRead(struct RecordStore* recordStore) { - recordStore->hasReadRecord = false; + recordStore->HasReadRecord = false; } static bool RecordStore_AdvancePastSentRecord( diff --git a/Core/Source/RecordStore.h b/Core/Source/RecordStore.h index ad48fce8..accd13f2 100644 --- a/Core/Source/RecordStore.h +++ b/Core/Source/RecordStore.h @@ -17,11 +17,11 @@ enum struct RecordStore { - struct SolidSyslogSecurityPolicy* securityPolicy; - bool hasReadRecord; - size_t lastReadBlockIndex; - size_t lastSentFlagOffset; - uint8_t buffer[RECORD_BUFFER_SIZE]; + struct SolidSyslogSecurityPolicy* SecurityPolicy; + bool HasReadRecord; + size_t LastReadBlockIndex; + size_t LastSentFlagOffset; + uint8_t Buffer[RECORD_BUFFER_SIZE]; }; void RecordStore_Init(struct RecordStore* recordStore, struct SolidSyslogSecurityPolicy* securityPolicy); diff --git a/Core/Source/SolidSyslog.c b/Core/Source/SolidSyslog.c index 6c37fc9a..6a70174a 100644 --- a/Core/Source/SolidSyslog.c +++ b/Core/Source/SolidSyslog.c @@ -32,15 +32,15 @@ enum struct SolidSyslog { - struct SolidSyslogBuffer* buffer; - struct SolidSyslogSender* sender; - SolidSyslogClockFunction clock; - SolidSyslogStringFunction getHostname; - SolidSyslogStringFunction getAppName; - SolidSyslogStringFunction getProcessId; - struct SolidSyslogStore* store; - struct SolidSyslogStructuredData** sd; - size_t sdCount; + struct SolidSyslogBuffer* Buffer; + struct SolidSyslogSender* Sender; + SolidSyslogClockFunction Clock; + SolidSyslogStringFunction GetHostname; + SolidSyslogStringFunction GetAppName; + SolidSyslogStringFunction GetProcessId; + struct SolidSyslogStore* Store; + struct SolidSyslogStructuredData** Sd; + size_t SdCount; }; /* Forward declarations for the Nil "class" defined at the bottom of the file. @@ -59,13 +59,13 @@ static bool nilSenderReportArmed; static bool instanceInitialised; static struct SolidSyslog instance = { - .buffer = &NilBuffer, - .sender = &NilSender, - .clock = SolidSyslog_NilClock, - .getHostname = SolidSyslog_NilStringFunction, - .getAppName = SolidSyslog_NilStringFunction, - .getProcessId = SolidSyslog_NilStringFunction, - .store = &NilStore, + .Buffer = &NilBuffer, + .Sender = &NilSender, + .Clock = SolidSyslog_NilClock, + .GetHostname = SolidSyslog_NilStringFunction, + .GetAppName = SolidSyslog_NilStringFunction, + .GetProcessId = SolidSyslog_NilStringFunction, + .Store = &NilStore, }; /* Template used by _Create and _Destroy to reset every slot to its nil. C99 @@ -73,13 +73,13 @@ static struct SolidSyslog instance = { * appears once above and once here; both sites stay in sync trivially because * the values are nil-object addresses. */ static const struct SolidSyslog NilInstance = { - .buffer = &NilBuffer, - .sender = &NilSender, - .clock = SolidSyslog_NilClock, - .getHostname = SolidSyslog_NilStringFunction, - .getAppName = SolidSyslog_NilStringFunction, - .getProcessId = SolidSyslog_NilStringFunction, - .store = &NilStore, + .Buffer = &NilBuffer, + .Sender = &NilSender, + .Clock = SolidSyslog_NilClock, + .GetHostname = SolidSyslog_NilStringFunction, + .GetAppName = SolidSyslog_NilStringFunction, + .GetProcessId = SolidSyslog_NilStringFunction, + .Store = &NilStore, }; /* SolidSyslog helpers forward-declared so the public functions and @@ -151,14 +151,14 @@ void SolidSyslog_Create(const struct SolidSyslogConfig* config) static void SolidSyslog_InstallConfig(const struct SolidSyslogConfig* config) { instance = NilInstance; - SolidSyslog_InstallBuffer(config->buffer); - SolidSyslog_InstallSender(config->sender); - SolidSyslog_InstallStore(config->store); - SolidSyslog_InstallClock(config->clock); - SolidSyslog_InstallHostname(config->getHostname); - SolidSyslog_InstallAppName(config->getAppName); - SolidSyslog_InstallProcessId(config->getProcessId); - SolidSyslog_InstallStructuredData(config->sd, config->sdCount); + SolidSyslog_InstallBuffer(config->Buffer); + SolidSyslog_InstallSender(config->Sender); + SolidSyslog_InstallStore(config->Store); + SolidSyslog_InstallClock(config->Clock); + SolidSyslog_InstallHostname(config->GetHostname); + SolidSyslog_InstallAppName(config->GetAppName); + SolidSyslog_InstallProcessId(config->GetProcessId); + SolidSyslog_InstallStructuredData(config->Sd, config->SdCount); } static void SolidSyslog_InstallBuffer(struct SolidSyslogBuffer* configured) @@ -169,7 +169,7 @@ static void SolidSyslog_InstallBuffer(struct SolidSyslogBuffer* configured) } else { - instance.buffer = configured; + instance.Buffer = configured; } } @@ -181,7 +181,7 @@ static void SolidSyslog_InstallSender(struct SolidSyslogSender* configured) } else { - instance.sender = configured; + instance.Sender = configured; } } @@ -193,7 +193,7 @@ static void SolidSyslog_InstallStore(struct SolidSyslogStore* configured) } else { - instance.store = configured; + instance.Store = configured; } } @@ -201,7 +201,7 @@ static void SolidSyslog_InstallClock(SolidSyslogClockFunction configured) { if (configured != NULL) { - instance.clock = configured; + instance.Clock = configured; } } @@ -209,7 +209,7 @@ static void SolidSyslog_InstallHostname(SolidSyslogStringFunction configured) { if (configured != NULL) { - instance.getHostname = configured; + instance.GetHostname = configured; } } @@ -217,7 +217,7 @@ static void SolidSyslog_InstallAppName(SolidSyslogStringFunction configured) { if (configured != NULL) { - instance.getAppName = configured; + instance.GetAppName = configured; } } @@ -225,14 +225,14 @@ static void SolidSyslog_InstallProcessId(SolidSyslogStringFunction configured) { if (configured != NULL) { - instance.getProcessId = configured; + instance.GetProcessId = configured; } } static void SolidSyslog_InstallStructuredData(struct SolidSyslogStructuredData** configured, size_t count) { - instance.sd = configured; - instance.sdCount = count; + instance.Sd = configured; + instance.SdCount = count; } void SolidSyslog_Destroy(void) @@ -253,7 +253,7 @@ void SolidSyslog_Service(void) static inline bool SolidSyslog_IsServiceEnabled(void) { - return !SolidSyslogStore_IsHalted(instance.store); + return !SolidSyslogStore_IsHalted(instance.Store); } static void SolidSyslog_ProcessMessages(void) @@ -276,11 +276,11 @@ static inline void SolidSyslog_DrainBufferIntoStore(void) char buf[SOLIDSYSLOG_MAX_MESSAGE_SIZE]; size_t len = 0; - while (SolidSyslogBuffer_Read(instance.buffer, buf, sizeof(buf), &len)) + while (SolidSyslogBuffer_Read(instance.Buffer, buf, sizeof(buf), &len)) { - if (!SolidSyslogStore_Write(instance.store, buf, len) && SolidSyslogStore_IsTransient(instance.store)) + if (!SolidSyslogStore_Write(instance.Store, buf, len) && SolidSyslogStore_IsTransient(instance.Store)) { - SolidSyslogSender_Send(instance.sender, buf, len); + SolidSyslogSender_Send(instance.Sender, buf, len); } } } @@ -290,10 +290,10 @@ static inline void SolidSyslog_SendOneFromStore(void) char buf[SOLIDSYSLOG_MAX_MESSAGE_SIZE]; size_t len = 0; - if (SolidSyslogStore_ReadNextUnsent(instance.store, buf, sizeof(buf), &len) && - SolidSyslogSender_Send(instance.sender, buf, len)) + if (SolidSyslogStore_ReadNextUnsent(instance.Store, buf, sizeof(buf), &len) && + SolidSyslogSender_Send(instance.Sender, buf, len)) { - SolidSyslogStore_MarkSent(instance.store); + SolidSyslogStore_MarkSent(instance.Store); } } @@ -310,7 +310,7 @@ void SolidSyslog_Log(const struct SolidSyslogMessage* message) SolidSyslog_FormatMessage(f, message); SolidSyslogBuffer_Write( - instance.buffer, + instance.Buffer, SolidSyslogFormatter_AsFormattedBuffer(f), SolidSyslogFormatter_Length(f) ); @@ -322,18 +322,18 @@ static inline void SolidSyslog_FormatMessage(struct SolidSyslogFormatter* f, con SolidSyslog_FormatPrival(f, SolidSyslog_MakePrival(message)); SolidSyslogFormatter_AsciiCharacter(f, '1'); SolidSyslogFormatter_AsciiCharacter(f, ' '); - SolidSyslog_FormatTimestamp(f, instance.clock); + SolidSyslog_FormatTimestamp(f, instance.Clock); SolidSyslogFormatter_AsciiCharacter(f, ' '); - SolidSyslog_FormatStringField(f, instance.getHostname, SOLIDSYSLOG_MAX_HOSTNAME_SIZE); + SolidSyslog_FormatStringField(f, instance.GetHostname, SOLIDSYSLOG_MAX_HOSTNAME_SIZE); SolidSyslogFormatter_AsciiCharacter(f, ' '); - SolidSyslog_FormatStringField(f, instance.getAppName, SOLIDSYSLOG_MAX_APP_NAME_SIZE); + SolidSyslog_FormatStringField(f, instance.GetAppName, SOLIDSYSLOG_MAX_APP_NAME_SIZE); SolidSyslogFormatter_AsciiCharacter(f, ' '); - SolidSyslog_FormatStringField(f, instance.getProcessId, SOLIDSYSLOG_MAX_PROCESS_ID_SIZE); + SolidSyslog_FormatStringField(f, instance.GetProcessId, SOLIDSYSLOG_MAX_PROCESS_ID_SIZE); SolidSyslogFormatter_AsciiCharacter(f, ' '); - SolidSyslog_FormatMsgId(f, message->messageId); + SolidSyslog_FormatMsgId(f, message->MessageId); SolidSyslogFormatter_AsciiCharacter(f, ' '); - SolidSyslog_FormatStructuredData(f, instance.sd, instance.sdCount); - SolidSyslog_FormatMsg(f, message->msg); + SolidSyslog_FormatStructuredData(f, instance.Sd, instance.SdCount); + SolidSyslog_FormatMsg(f, message->Msg); } static inline void SolidSyslog_FormatPrival(struct SolidSyslogFormatter* f, uint8_t prival) @@ -345,8 +345,8 @@ static inline void SolidSyslog_FormatPrival(struct SolidSyslogFormatter* f, uint static inline uint8_t SolidSyslog_MakePrival(const struct SolidSyslogMessage* message) { - uint8_t f = (uint8_t) message->facility; - uint8_t s = (uint8_t) message->severity; + uint8_t f = (uint8_t) message->Facility; + uint8_t s = (uint8_t) message->Severity; uint8_t prival = SolidSyslog_CombineFacilityAndSeverity(SolidSyslogFacility_Syslog, SolidSyslogSeverity_Error); if (SolidSyslog_PrivalComponentsAreValid(f, s)) @@ -401,13 +401,13 @@ static inline bool SolidSyslog_TimestampIsValid(const struct SolidSyslogTimestam { bool valid = true; - valid = valid && (ts->month >= 1U) && (ts->month <= 12U); - valid = valid && (ts->day >= 1U) && (ts->day <= 31U); - valid = valid && (ts->hour <= 23U); - valid = valid && (ts->minute <= 59U); - valid = valid && (ts->second <= 59U); - valid = valid && (ts->microsecond <= 999999U); - valid = valid && (ts->utcOffsetMinutes >= -720) && (ts->utcOffsetMinutes <= 840); + valid = valid && (ts->Month >= 1U) && (ts->Month <= 12U); + valid = valid && (ts->Day >= 1U) && (ts->Day <= 31U); + valid = valid && (ts->Hour <= 23U); + valid = valid && (ts->Minute <= 59U); + valid = valid && (ts->Second <= 59U); + valid = valid && (ts->Microsecond <= 999999U); + valid = valid && (ts->UtcOffsetMinutes >= -720) && (ts->UtcOffsetMinutes <= 840); return valid; } @@ -417,20 +417,20 @@ static inline void SolidSyslog_FormatCapturedTimestamp( const struct SolidSyslogTimestamp* ts ) { - SolidSyslogFormatter_FourDigit(f, ts->year); + SolidSyslogFormatter_FourDigit(f, ts->Year); SolidSyslogFormatter_AsciiCharacter(f, '-'); - SolidSyslogFormatter_TwoDigit(f, ts->month); + SolidSyslogFormatter_TwoDigit(f, ts->Month); SolidSyslogFormatter_AsciiCharacter(f, '-'); - SolidSyslogFormatter_TwoDigit(f, ts->day); + SolidSyslogFormatter_TwoDigit(f, ts->Day); SolidSyslogFormatter_AsciiCharacter(f, 'T'); - SolidSyslogFormatter_TwoDigit(f, ts->hour); + SolidSyslogFormatter_TwoDigit(f, ts->Hour); SolidSyslogFormatter_AsciiCharacter(f, ':'); - SolidSyslogFormatter_TwoDigit(f, ts->minute); + SolidSyslogFormatter_TwoDigit(f, ts->Minute); SolidSyslogFormatter_AsciiCharacter(f, ':'); - SolidSyslogFormatter_TwoDigit(f, ts->second); + SolidSyslogFormatter_TwoDigit(f, ts->Second); SolidSyslogFormatter_AsciiCharacter(f, '.'); - SolidSyslogFormatter_SixDigit(f, ts->microsecond); - SolidSyslog_FormatUtcOffset(f, ts->utcOffsetMinutes); + SolidSyslogFormatter_SixDigit(f, ts->Microsecond); + SolidSyslog_FormatUtcOffset(f, ts->UtcOffsetMinutes); } static inline void SolidSyslog_FormatUtcOffset(struct SolidSyslogFormatter* f, int16_t offsetMinutes) @@ -693,7 +693,7 @@ static size_t SolidSyslog_NilStoreGetUsedBytes(struct SolidSyslogStore* self) return 0; } -/* NilStore stands in when the integrator passes config.store = NULL — +/* NilStore stands in when the integrator passes config.Store = NULL — * "no store, just try to send." Same transient semantics as NullStore: * Service falls through to the sender on Write rejection. */ static bool SolidSyslog_NilStoreIsTransient(struct SolidSyslogStore* self) diff --git a/Core/Source/SolidSyslogAtomicCounter.c b/Core/Source/SolidSyslogAtomicCounter.c index 7197c90e..29289af0 100644 --- a/Core/Source/SolidSyslogAtomicCounter.c +++ b/Core/Source/SolidSyslogAtomicCounter.c @@ -12,8 +12,8 @@ static const uint32_t SEQUENCE_ID_MAX = 2147483647U; struct SolidSyslogAtomicCounter { - SolidSyslogAtomicU32Storage storage; - struct SolidSyslogAtomicU32* slot; + SolidSyslogAtomicU32Storage Storage; + struct SolidSyslogAtomicU32* Slot; }; static struct SolidSyslogAtomicCounter instance; @@ -32,20 +32,20 @@ static inline bool AtomicCounter_TryAdvance(struct SolidSyslogAtomicU32* slot, u struct SolidSyslogAtomicCounter* SolidSyslogAtomicCounter_Create(void) { - instance.slot = SolidSyslogAtomicU32_FromStorage(&instance.storage); - SolidSyslogAtomicU32_Init(instance.slot, 0); + instance.Slot = SolidSyslogAtomicU32_FromStorage(&instance.Storage); + SolidSyslogAtomicU32_Init(instance.Slot, 0); return &instance; } void SolidSyslogAtomicCounter_Destroy(void) { - instance.slot = NULL; + instance.Slot = NULL; } uint32_t SolidSyslogAtomicCounter_Increment(struct SolidSyslogAtomicCounter* counter) { uint32_t next = 0; - while (!AtomicCounter_TryAdvance(counter->slot, &next)) + while (!AtomicCounter_TryAdvance(counter->Slot, &next)) { } return next; diff --git a/Core/Source/SolidSyslogBlockStore.c b/Core/Source/SolidSyslogBlockStore.c index 1e340518..c0b89346 100644 --- a/Core/Source/SolidSyslogBlockStore.c +++ b/Core/Source/SolidSyslogBlockStore.c @@ -26,9 +26,9 @@ static bool BlockStore_IsTransient(struct SolidSyslogStore* self); struct SolidSyslogBlockStore { - struct SolidSyslogStore base; - struct RecordStore recordStore; - struct BlockSequence blockSequence; + struct SolidSyslogStore Base; + struct RecordStore RecordStore; + struct BlockSequence BlockSequence; }; SOLIDSYSLOG_STATIC_ASSERT( @@ -61,19 +61,19 @@ struct SolidSyslogStore* SolidSyslogBlockStore_Create( struct SolidSyslogBlockStore* blockStore = (struct SolidSyslogBlockStore*) storage; *blockStore = DEFAULT_INSTANCE; - RecordStore_Init(&blockStore->recordStore, BlockStore_ResolveSecurityPolicy(config->securityPolicy)); + RecordStore_Init(&blockStore->RecordStore, BlockStore_ResolveSecurityPolicy(config->SecurityPolicy)); - struct BlockSequenceConfig blockConfig = BlockStore_BuildBlockSequenceConfig(config, &blockStore->recordStore); - BlockSequence_Init(&blockStore->blockSequence, &blockConfig); + struct BlockSequenceConfig blockConfig = BlockStore_BuildBlockSequenceConfig(config, &blockStore->RecordStore); + BlockSequence_Init(&blockStore->BlockSequence, &blockConfig); BlockStore_InitialiseVtable(blockStore); - if (BlockSequence_Open(&blockStore->blockSequence)) + if (BlockSequence_Open(&blockStore->BlockSequence)) { BlockStore_ResumeFromExistingBlock(blockStore); } - return &blockStore->base; + return &blockStore->Base; } static inline struct SolidSyslogBlockStore* BlockStore_AsBlockStore(struct SolidSyslogStore* store) @@ -87,7 +87,7 @@ static inline struct SolidSyslogSecurityPolicy* BlockStore_ResolveSecurityPolicy { struct SolidSyslogSecurityPolicy* resolved = configured; - if ((resolved == NULL) || (resolved->integritySize > SOLIDSYSLOG_MAX_INTEGRITY_SIZE)) + if ((resolved == NULL) || (resolved->IntegritySize > SOLIDSYSLOG_MAX_INTEGRITY_SIZE)) { resolved = SolidSyslogNullSecurityPolicy_Create(); } @@ -101,38 +101,38 @@ static inline struct BlockSequenceConfig BlockStore_BuildBlockSequenceConfig( ) { size_t minBlockSize = RecordStore_RecordSize(recordStore, SOLIDSYSLOG_MAX_MESSAGE_SIZE); - size_t maxBlockSize = (config->maxBlockSize < minBlockSize) ? minBlockSize : config->maxBlockSize; + size_t maxBlockSize = (config->MaxBlockSize < minBlockSize) ? minBlockSize : config->MaxBlockSize; struct BlockSequenceConfig blockConfig = { - .blockDevice = config->blockDevice, - .maxBlockSize = maxBlockSize, - .maxBlocks = config->maxBlocks, - .discardPolicy = config->discardPolicy, - .onStoreFull = config->onStoreFull, - .storeFullContext = config->storeFullContext, - .getCapacityThreshold = config->getCapacityThreshold, - .onThresholdCrossed = config->onThresholdCrossed, - .thresholdContext = config->thresholdContext, + .BlockDevice = config->BlockDevice, + .MaxBlockSize = maxBlockSize, + .MaxBlocks = config->MaxBlocks, + .DiscardPolicy = config->DiscardPolicy, + .OnStoreFull = config->OnStoreFull, + .StoreFullContext = config->StoreFullContext, + .GetCapacityThreshold = config->GetCapacityThreshold, + .OnThresholdCrossed = config->OnThresholdCrossed, + .ThresholdContext = config->ThresholdContext, }; return blockConfig; } static inline void BlockStore_InitialiseVtable(struct SolidSyslogBlockStore* blockStore) { - blockStore->base.Write = BlockStore_Write; - blockStore->base.ReadNextUnsent = BlockStore_ReadNextUnsent; - blockStore->base.MarkSent = BlockStore_MarkSent; - blockStore->base.HasUnsent = BlockStore_HasUnsent; - blockStore->base.IsHalted = BlockStore_IsHalted; - blockStore->base.GetTotalBytes = BlockStore_GetTotalBytes; - blockStore->base.GetUsedBytes = BlockStore_GetUsedBytes; - blockStore->base.IsTransient = BlockStore_IsTransient; + blockStore->Base.Write = BlockStore_Write; + blockStore->Base.ReadNextUnsent = BlockStore_ReadNextUnsent; + blockStore->Base.MarkSent = BlockStore_MarkSent; + blockStore->Base.HasUnsent = BlockStore_HasUnsent; + blockStore->Base.IsHalted = BlockStore_IsHalted; + blockStore->Base.GetTotalBytes = BlockStore_GetTotalBytes; + blockStore->Base.GetUsedBytes = BlockStore_GetUsedBytes; + blockStore->Base.IsTransient = BlockStore_IsTransient; } static void BlockStore_ResumeFromExistingBlock(struct SolidSyslogBlockStore* blockStore) { - struct SolidSyslogBlockDevice* device = BlockSequence_BlockDevice(&blockStore->blockSequence); - size_t readSequence = BlockSequence_ReadSequence(&blockStore->blockSequence); + struct SolidSyslogBlockDevice* device = BlockSequence_BlockDevice(&blockStore->BlockSequence); + size_t readSequence = BlockSequence_ReadSequence(&blockStore->BlockSequence); /* Bound the scan by the read block's actual size, not WritePosition. On a * multi-block resume the read block is a closed earlier block whose size * is independent of the write block's fill level. */ @@ -140,13 +140,13 @@ static void BlockStore_ResumeFromExistingBlock(struct SolidSyslogBlockStore* blo bool corrupt = false; size_t cursor = - RecordStore_FindFirstUnsent(&blockStore->recordStore, device, readSequence, readBlockSize, &corrupt); + RecordStore_FindFirstUnsent(&blockStore->RecordStore, device, readSequence, readBlockSize, &corrupt); - BlockSequence_SetReadCursor(&blockStore->blockSequence, cursor); + BlockSequence_SetReadCursor(&blockStore->BlockSequence, cursor); if (corrupt) { - BlockSequence_MarkWriteBlockCorrupt(&blockStore->blockSequence); + BlockSequence_MarkWriteBlockCorrupt(&blockStore->BlockSequence); } } @@ -173,26 +173,26 @@ static bool BlockStore_Write(struct SolidSyslogStore* self, const void* data, si static bool BlockStore_StoreRecord(struct SolidSyslogBlockStore* blockStore, const void* data, size_t size) { - size_t recordSize = RecordStore_RecordSize(&blockStore->recordStore, (uint16_t) size); + size_t recordSize = RecordStore_RecordSize(&blockStore->RecordStore, (uint16_t) size); bool readBlockChanged = false; bool written = false; - if (BlockSequence_PrepareForWrite(&blockStore->blockSequence, recordSize, &readBlockChanged)) + if (BlockSequence_PrepareForWrite(&blockStore->BlockSequence, recordSize, &readBlockChanged)) { if (readBlockChanged) { - RecordStore_ForgetLastRead(&blockStore->recordStore); + RecordStore_ForgetLastRead(&blockStore->RecordStore); } if (RecordStore_Append( - &blockStore->recordStore, - BlockSequence_BlockDevice(&blockStore->blockSequence), - BlockSequence_WriteSequence(&blockStore->blockSequence), + &blockStore->RecordStore, + BlockSequence_BlockDevice(&blockStore->BlockSequence), + BlockSequence_WriteSequence(&blockStore->BlockSequence), data, size )) { - BlockSequence_NoteRecordWritten(&blockStore->blockSequence, recordSize); + BlockSequence_NoteRecordWritten(&blockStore->BlockSequence, recordSize); written = true; } } @@ -206,22 +206,22 @@ static bool BlockStore_StoreRecord(struct SolidSyslogBlockStore* blockStore, con static bool BlockStore_HasUnsent(struct SolidSyslogStore* self) { - return BlockSequence_HasUnsent(&BlockStore_AsBlockStore(self)->blockSequence); + return BlockSequence_HasUnsent(&BlockStore_AsBlockStore(self)->BlockSequence); } static bool BlockStore_IsHalted(struct SolidSyslogStore* self) { - return BlockSequence_IsHalted(&BlockStore_AsBlockStore(self)->blockSequence); + return BlockSequence_IsHalted(&BlockStore_AsBlockStore(self)->BlockSequence); } static size_t BlockStore_GetTotalBytes(struct SolidSyslogStore* self) { - return BlockSequence_TotalBytes(&BlockStore_AsBlockStore(self)->blockSequence); + return BlockSequence_TotalBytes(&BlockStore_AsBlockStore(self)->BlockSequence); } static size_t BlockStore_GetUsedBytes(struct SolidSyslogStore* self) { - return BlockSequence_UsedBytes(&BlockStore_AsBlockStore(self)->blockSequence); + return BlockSequence_UsedBytes(&BlockStore_AsBlockStore(self)->BlockSequence); } /* BlockStore retains records — a BlockStore_Write rejection here is the discard @@ -250,14 +250,14 @@ static bool BlockStore_ReadNextUnsent(struct SolidSyslogStore* self, void* data, bool read = false; *bytesRead = 0; - if (BlockSequence_HasUnsent(&blockStore->blockSequence)) + if (BlockSequence_HasUnsent(&blockStore->BlockSequence)) { read = BlockStore_ReadCurrent(blockStore, data, maxSize, bytesRead); - while (!read && BlockSequence_ReadIsBehindWrite(&blockStore->blockSequence)) + while (!read && BlockSequence_ReadIsBehindWrite(&blockStore->BlockSequence)) { - BlockSequence_AdvanceToNextReadBlock(&blockStore->blockSequence); - RecordStore_ForgetLastRead(&blockStore->recordStore); + BlockSequence_AdvanceToNextReadBlock(&blockStore->BlockSequence); + RecordStore_ForgetLastRead(&blockStore->RecordStore); read = BlockStore_ReadCurrent(blockStore, data, maxSize, bytesRead); } } @@ -273,10 +273,10 @@ static bool BlockStore_ReadCurrent( ) { return RecordStore_Read( - &blockStore->recordStore, - BlockSequence_BlockDevice(&blockStore->blockSequence), - BlockSequence_ReadSequence(&blockStore->blockSequence), - BlockSequence_ReadCursor(&blockStore->blockSequence), + &blockStore->RecordStore, + BlockSequence_BlockDevice(&blockStore->BlockSequence), + BlockSequence_ReadSequence(&blockStore->BlockSequence), + BlockSequence_ReadCursor(&blockStore->BlockSequence), data, maxSize, bytesRead @@ -293,19 +293,19 @@ static void BlockStore_MarkSent(struct SolidSyslogStore* self) size_t nextCursor = 0; if (RecordStore_MarkLastReadAsSent( - &blockStore->recordStore, - BlockSequence_BlockDevice(&blockStore->blockSequence), + &blockStore->RecordStore, + BlockSequence_BlockDevice(&blockStore->BlockSequence), &nextCursor )) { - BlockSequence_SetReadCursor(&blockStore->blockSequence, nextCursor); + BlockSequence_SetReadCursor(&blockStore->BlockSequence, nextCursor); bool readBlockChanged = false; - BlockSequence_DisposeReadBlockIfDrained(&blockStore->blockSequence, &readBlockChanged); + BlockSequence_DisposeReadBlockIfDrained(&blockStore->BlockSequence, &readBlockChanged); if (readBlockChanged) { - RecordStore_ForgetLastRead(&blockStore->recordStore); + RecordStore_ForgetLastRead(&blockStore->RecordStore); } } } diff --git a/Core/Source/SolidSyslogCircularBuffer.c b/Core/Source/SolidSyslogCircularBuffer.c index 727850c2..7eed6f0d 100644 --- a/Core/Source/SolidSyslogCircularBuffer.c +++ b/Core/Source/SolidSyslogCircularBuffer.c @@ -17,13 +17,13 @@ enum struct SolidSyslogCircularBuffer { - struct SolidSyslogBuffer base; - struct SolidSyslogMutex* mutex; - size_t capacity; - size_t head; - size_t tail; - size_t wrapPoint; - uint8_t storage[]; + struct SolidSyslogBuffer Base; + struct SolidSyslogMutex* Mutex; + size_t Capacity; + size_t Head; + size_t Tail; + size_t WrapPoint; + uint8_t Storage[]; }; SOLIDSYSLOG_STATIC_ASSERT( @@ -64,30 +64,30 @@ struct SolidSyslogBuffer* SolidSyslogCircularBuffer_Create( ) { struct SolidSyslogCircularBuffer* circular = (struct SolidSyslogCircularBuffer*) storage; - circular->base.Read = CircularBuffer_Read; - circular->base.Write = CircularBuffer_Write; - circular->mutex = mutex; - circular->capacity = storageBytes - sizeof(struct SolidSyslogCircularBuffer); + circular->Base.Read = CircularBuffer_Read; + circular->Base.Write = CircularBuffer_Write; + circular->Mutex = mutex; + circular->Capacity = storageBytes - sizeof(struct SolidSyslogCircularBuffer); CircularBuffer_ResetToStart(circular); - return &circular->base; + return &circular->Base; } void SolidSyslogCircularBuffer_Destroy(struct SolidSyslogBuffer* buffer) { struct SolidSyslogCircularBuffer* circular = (struct SolidSyslogCircularBuffer*) buffer; - circular->base.Read = NULL; - circular->base.Write = NULL; - circular->mutex = NULL; - circular->capacity = 0; - circular->head = 0; - circular->tail = 0; - circular->wrapPoint = 0; + circular->Base.Read = NULL; + circular->Base.Write = NULL; + circular->Mutex = NULL; + circular->Capacity = 0; + circular->Head = 0; + circular->Tail = 0; + circular->WrapPoint = 0; } static bool CircularBuffer_Read(struct SolidSyslogBuffer* self, void* data, size_t maxSize, size_t* bytesRead) { struct SolidSyslogCircularBuffer* circular = (struct SolidSyslogCircularBuffer*) self; - SolidSyslogMutex_Lock(circular->mutex); + SolidSyslogMutex_Lock(circular->Mutex); *bytesRead = 0; bool delivered = !CircularBuffer_IsEmpty(circular); if (delivered) @@ -105,38 +105,38 @@ static bool CircularBuffer_Read(struct SolidSyslogBuffer* self, void* data, size delivered = false; } } - SolidSyslogMutex_Unlock(circular->mutex); + SolidSyslogMutex_Unlock(circular->Mutex); return delivered; } static inline bool CircularBuffer_IsEmpty(const struct SolidSyslogCircularBuffer* circular) { - return circular->head == circular->tail; + return circular->Head == circular->Tail; } static inline bool CircularBuffer_HeadAtWrapPoint(const struct SolidSyslogCircularBuffer* circular) { - return circular->head >= circular->wrapPoint; + return circular->Head >= circular->WrapPoint; } static inline void CircularBuffer_ConsumeWrapMarker(struct SolidSyslogCircularBuffer* circular) { - circular->head = 0; - circular->wrapPoint = circular->capacity; + circular->Head = 0; + circular->WrapPoint = circular->Capacity; } static inline size_t CircularBuffer_PeekRecordSize(const struct SolidSyslogCircularBuffer* circular) { uint16_t header = 0; - memcpy(&header, &circular->storage[circular->head], HEADER_BYTES); + memcpy(&header, &circular->Storage[circular->Head], HEADER_BYTES); return header; } static inline void CircularBuffer_LoadRecord(struct SolidSyslogCircularBuffer* circular, void* data, size_t* bytesRead) { size_t recordSize = CircularBuffer_PeekRecordSize(circular); - memcpy(data, &circular->storage[circular->head + HEADER_BYTES], recordSize); - circular->head += HEADER_BYTES + recordSize; + memcpy(data, &circular->Storage[circular->Head + HEADER_BYTES], recordSize); + circular->Head += HEADER_BYTES + recordSize; *bytesRead = recordSize; } @@ -145,7 +145,7 @@ static void CircularBuffer_Write(struct SolidSyslogBuffer* self, const void* dat struct SolidSyslogCircularBuffer* circular = (struct SolidSyslogCircularBuffer*) self; if (size <= SOLIDSYSLOG_MAX_MESSAGE_SIZE) { - SolidSyslogMutex_Lock(circular->mutex); + SolidSyslogMutex_Lock(circular->Mutex); if (CircularBuffer_IsEmpty(circular)) { CircularBuffer_ResetToStart(circular); @@ -161,22 +161,22 @@ static void CircularBuffer_Write(struct SolidSyslogBuffer* self, const void* dat } CircularBuffer_StoreRecord(circular, data, size); } - SolidSyslogMutex_Unlock(circular->mutex); + SolidSyslogMutex_Unlock(circular->Mutex); } } static inline bool CircularBuffer_IsWrapped(const struct SolidSyslogCircularBuffer* circular) { - return circular->head > circular->tail; + return circular->Head > circular->Tail; } static inline bool CircularBuffer_RecordFitsAtTail(const struct SolidSyslogCircularBuffer* circular, size_t recordBytes) { if (CircularBuffer_IsWrapped(circular)) { - return circular->tail + recordBytes < circular->head; + return circular->Tail + recordBytes < circular->Head; } - return circular->tail + recordBytes <= circular->capacity; + return circular->Tail + recordBytes <= circular->Capacity; } static inline bool CircularBuffer_RecordFitsAfterWrap( @@ -184,26 +184,26 @@ static inline bool CircularBuffer_RecordFitsAfterWrap( size_t recordBytes ) { - return (!CircularBuffer_IsWrapped(circular)) && recordBytes < circular->head; + return (!CircularBuffer_IsWrapped(circular)) && recordBytes < circular->Head; } static inline void CircularBuffer_ResetToStart(struct SolidSyslogCircularBuffer* circular) { - circular->head = 0; - circular->tail = 0; - circular->wrapPoint = circular->capacity; + circular->Head = 0; + circular->Tail = 0; + circular->WrapPoint = circular->Capacity; } static inline void CircularBuffer_WrapTail(struct SolidSyslogCircularBuffer* circular) { - circular->wrapPoint = circular->tail; - circular->tail = 0; + circular->WrapPoint = circular->Tail; + circular->Tail = 0; } static inline void CircularBuffer_StoreRecord(struct SolidSyslogCircularBuffer* circular, const void* data, size_t size) { uint16_t header = (uint16_t) size; - memcpy(&circular->storage[circular->tail], &header, HEADER_BYTES); - memcpy(&circular->storage[circular->tail + HEADER_BYTES], data, size); - circular->tail += HEADER_BYTES + size; + memcpy(&circular->Storage[circular->Tail], &header, HEADER_BYTES); + memcpy(&circular->Storage[circular->Tail + HEADER_BYTES], data, size); + circular->Tail += HEADER_BYTES + size; } diff --git a/Core/Source/SolidSyslogErrorMessages.h b/Core/Source/SolidSyslogErrorMessages.h index 8e2d4488..89e61227 100644 --- a/Core/Source/SolidSyslogErrorMessages.h +++ b/Core/Source/SolidSyslogErrorMessages.h @@ -2,20 +2,20 @@ #define SOLIDSYSLOGERRORMESSAGES_H #define SOLIDSYSLOG_ERROR_MSG_CREATE_NULL_CONFIG "SolidSyslog_Create called with NULL config" -#define SOLIDSYSLOG_ERROR_MSG_CREATE_NULL_BUFFER "SolidSyslog_Create config.buffer is NULL" -#define SOLIDSYSLOG_ERROR_MSG_CREATE_NULL_SENDER "SolidSyslog_Create config.sender is NULL" -#define SOLIDSYSLOG_ERROR_MSG_CREATE_NULL_STORE "SolidSyslog_Create config.store is NULL" +#define SOLIDSYSLOG_ERROR_MSG_CREATE_NULL_BUFFER "SolidSyslog_Create config.Buffer is NULL" +#define SOLIDSYSLOG_ERROR_MSG_CREATE_NULL_SENDER "SolidSyslog_Create config.Sender is NULL" +#define SOLIDSYSLOG_ERROR_MSG_CREATE_NULL_STORE "SolidSyslog_Create config.Store is NULL" #define SOLIDSYSLOG_ERROR_MSG_CREATE_ALREADY_INITIALISED \ "SolidSyslog_Create called while already initialised - call _Destroy first" #define SOLIDSYSLOG_ERROR_MSG_LOG_NULL_MESSAGE "SolidSyslog_Log called with NULL message" #define SOLIDSYSLOG_ERROR_MSG_NIL_BUFFER_USED "SolidSyslog_Log called with no buffer configured" #define SOLIDSYSLOG_ERROR_MSG_NIL_SENDER_USED "SolidSyslog_Service tried to send with no sender configured" #define SOLIDSYSLOG_ERROR_MSG_METASD_CREATE_NULL_CONFIG "SolidSyslogMetaSd_Create called with NULL config" -#define SOLIDSYSLOG_ERROR_MSG_METASD_CREATE_NULL_COUNTER "SolidSyslogMetaSd_Create config.counter is NULL" +#define SOLIDSYSLOG_ERROR_MSG_METASD_CREATE_NULL_COUNTER "SolidSyslogMetaSd_Create config.Counter is NULL" #define SOLIDSYSLOG_ERROR_MSG_UDPSENDER_CREATE_NULL_CONFIG "SolidSyslogUdpSender_Create called with NULL config" -#define SOLIDSYSLOG_ERROR_MSG_UDPSENDER_CREATE_NULL_RESOLVER "SolidSyslogUdpSender_Create config.resolver is NULL" -#define SOLIDSYSLOG_ERROR_MSG_UDPSENDER_CREATE_NULL_DATAGRAM "SolidSyslogUdpSender_Create config.datagram is NULL" -#define SOLIDSYSLOG_ERROR_MSG_UDPSENDER_CREATE_NULL_ENDPOINT "SolidSyslogUdpSender_Create config.endpoint is NULL" +#define SOLIDSYSLOG_ERROR_MSG_UDPSENDER_CREATE_NULL_RESOLVER "SolidSyslogUdpSender_Create config.Resolver is NULL" +#define SOLIDSYSLOG_ERROR_MSG_UDPSENDER_CREATE_NULL_DATAGRAM "SolidSyslogUdpSender_Create config.Datagram is NULL" +#define SOLIDSYSLOG_ERROR_MSG_UDPSENDER_CREATE_NULL_ENDPOINT "SolidSyslogUdpSender_Create config.Endpoint is NULL" #define SOLIDSYSLOG_ERROR_MSG_UDPSENDER_SEND_NULL_BUFFER "SolidSyslogUdpSender_Send called with NULL buffer" #endif /* SOLIDSYSLOGERRORMESSAGES_H */ diff --git a/Core/Source/SolidSyslogFileBlockDevice.c b/Core/Source/SolidSyslogFileBlockDevice.c index 0b7f2f62..e858759b 100644 --- a/Core/Source/SolidSyslogFileBlockDevice.c +++ b/Core/Source/SolidSyslogFileBlockDevice.c @@ -39,16 +39,16 @@ static inline bool FileBlockDevice_IsValidBlockIndex(size_t blockIndex) * invariant — by construction the device has exactly one underlying file. */ struct OpenHandle { - struct SolidSyslogFile* file; - size_t blockIndex; - bool isOpen; + struct SolidSyslogFile* File; + size_t BlockIndex; + bool IsOpen; }; struct SolidSyslogFileBlockDevice { - struct SolidSyslogBlockDevice base; - struct OpenHandle handle; - const char* pathPrefix; + struct SolidSyslogBlockDevice Base; + struct OpenHandle Handle; + const char* PathPrefix; }; SOLIDSYSLOG_STATIC_ASSERT( @@ -103,10 +103,10 @@ struct SolidSyslogBlockDevice* SolidSyslogFileBlockDevice_Create( struct SolidSyslogFileBlockDevice* device = (struct SolidSyslogFileBlockDevice*) storage; FileBlockDevice_InitialiseVtable(device); - device->handle = (struct OpenHandle) {.file = file, .blockIndex = 0, .isOpen = false}; - device->pathPrefix = pathPrefix; + device->Handle = (struct OpenHandle) {.File = file, .BlockIndex = 0, .IsOpen = false}; + device->PathPrefix = pathPrefix; - return &device->base; + return &device->Base; } static inline struct SolidSyslogFileBlockDevice* FileBlockDevice_AsFileBlockDevice(struct SolidSyslogBlockDevice* device @@ -117,13 +117,13 @@ static inline struct SolidSyslogFileBlockDevice* FileBlockDevice_AsFileBlockDevi static inline void FileBlockDevice_InitialiseVtable(struct SolidSyslogFileBlockDevice* device) { - device->base.Acquire = FileBlockDevice_Acquire; - device->base.Dispose = FileBlockDevice_Dispose; - device->base.Exists = FileBlockDevice_Exists; - device->base.Read = FileBlockDevice_Read; - device->base.Append = FileBlockDevice_Append; - device->base.WriteAt = FileBlockDevice_WriteAt; - device->base.Size = FileBlockDevice_Size; + device->Base.Acquire = FileBlockDevice_Acquire; + device->Base.Dispose = FileBlockDevice_Dispose; + device->Base.Exists = FileBlockDevice_Exists; + device->Base.Read = FileBlockDevice_Read; + device->Base.Append = FileBlockDevice_Append; + device->Base.WriteAt = FileBlockDevice_WriteAt; + device->Base.Size = FileBlockDevice_Size; } /* ------------------------------------------------------------------ @@ -135,15 +135,15 @@ static inline void FileBlockDevice_CloseIfOpen(struct OpenHandle* handle); void SolidSyslogFileBlockDevice_Destroy(struct SolidSyslogBlockDevice* device) { struct SolidSyslogFileBlockDevice* fileDevice = FileBlockDevice_AsFileBlockDevice(device); - FileBlockDevice_CloseIfOpen(&fileDevice->handle); + FileBlockDevice_CloseIfOpen(&fileDevice->Handle); } static inline void FileBlockDevice_CloseIfOpen(struct OpenHandle* handle) { - if (handle->isOpen) + if (handle->IsOpen) { - SolidSyslogFile_Close(handle->file); - handle->isOpen = false; + SolidSyslogFile_Close(handle->File); + handle->IsOpen = false; } } @@ -174,11 +174,11 @@ static bool FileBlockDevice_Acquire(struct SolidSyslogBlockDevice* self, size_t if (FileBlockDevice_IsValidBlockIndex(blockIndex)) { struct SolidSyslogFileBlockDevice* device = FileBlockDevice_AsFileBlockDevice(self); - ready = FileBlockDevice_EnsureHandleOpenOnBlock(&device->handle, device, blockIndex); + ready = FileBlockDevice_EnsureHandleOpenOnBlock(&device->Handle, device, blockIndex); if (ready) { - SolidSyslogFile_Truncate(device->handle.file); + SolidSyslogFile_Truncate(device->Handle.File); } } @@ -191,7 +191,7 @@ static inline bool FileBlockDevice_IsHandleAlreadyOpenOnBlock( size_t blockIndex ) { - return handle->isOpen && underlyingFileIsOpen && (handle->blockIndex == blockIndex); + return handle->IsOpen && underlyingFileIsOpen && (handle->BlockIndex == blockIndex); } static bool FileBlockDevice_EnsureHandleOpenOnBlock( @@ -200,7 +200,7 @@ static bool FileBlockDevice_EnsureHandleOpenOnBlock( size_t blockIndex ) { - bool underlyingFileIsOpen = SolidSyslogFile_IsOpen(handle->file); + bool underlyingFileIsOpen = SolidSyslogFile_IsOpen(handle->File); bool ready = FileBlockDevice_IsHandleAlreadyOpenOnBlock(handle, underlyingFileIsOpen, blockIndex); if (!ready) @@ -217,21 +217,21 @@ static bool FileBlockDevice_OpenHandleOnBlock( size_t blockIndex ) { - if (SolidSyslogFile_IsOpen(handle->file)) + if (SolidSyslogFile_IsOpen(handle->File)) { - SolidSyslogFile_Close(handle->file); + SolidSyslogFile_Close(handle->File); } - handle->isOpen = false; + handle->IsOpen = false; SolidSyslogFormatterStorage nameStorage[SOLIDSYSLOG_FORMATTER_STORAGE_SIZE(MAX_PATH_SIZE)]; const char* name = FileBlockDevice_FormatBlockFilename(device, nameStorage, blockIndex); - bool opened = SolidSyslogFile_Open(handle->file, name); + bool opened = SolidSyslogFile_Open(handle->File, name); if (opened) { - handle->blockIndex = blockIndex; - handle->isOpen = true; + handle->BlockIndex = blockIndex; + handle->IsOpen = true; } return opened; @@ -245,7 +245,7 @@ static inline const char* FileBlockDevice_FormatBlockFilename( { struct SolidSyslogFormatter* formatter = SolidSyslogFormatter_Create(storage, MAX_PATH_SIZE); - SolidSyslogFormatter_BoundedString(formatter, device->pathPrefix, MAX_PREFIX_LENGTH); + SolidSyslogFormatter_BoundedString(formatter, device->PathPrefix, MAX_PREFIX_LENGTH); SolidSyslogFormatter_TwoDigit(formatter, (uint8_t) blockIndex); SolidSyslogFormatter_BoundedString(formatter, FILE_EXTENSION, sizeof(FILE_EXTENSION) - 1); @@ -266,11 +266,11 @@ static bool FileBlockDevice_Dispose(struct SolidSyslogBlockDevice* self, size_t { struct SolidSyslogFileBlockDevice* device = FileBlockDevice_AsFileBlockDevice(self); - FileBlockDevice_CloseIfHoldingBlock(&device->handle, blockIndex); + FileBlockDevice_CloseIfHoldingBlock(&device->Handle, blockIndex); SolidSyslogFormatterStorage nameStorage[SOLIDSYSLOG_FORMATTER_STORAGE_SIZE(MAX_PATH_SIZE)]; const char* name = FileBlockDevice_FormatBlockFilename(device, nameStorage, blockIndex); - disposed = SolidSyslogFile_Delete(device->handle.file, name); + disposed = SolidSyslogFile_Delete(device->Handle.File, name); } return disposed; @@ -278,10 +278,10 @@ static bool FileBlockDevice_Dispose(struct SolidSyslogBlockDevice* self, size_t static inline void FileBlockDevice_CloseIfHoldingBlock(struct OpenHandle* handle, size_t blockIndex) { - if (handle->isOpen && (handle->blockIndex == blockIndex)) + if (handle->IsOpen && (handle->BlockIndex == blockIndex)) { - SolidSyslogFile_Close(handle->file); - handle->isOpen = false; + SolidSyslogFile_Close(handle->File); + handle->IsOpen = false; } } @@ -298,7 +298,7 @@ static bool FileBlockDevice_Exists(struct SolidSyslogBlockDevice* self, size_t b struct SolidSyslogFileBlockDevice* device = FileBlockDevice_AsFileBlockDevice(self); SolidSyslogFormatterStorage nameStorage[SOLIDSYSLOG_FORMATTER_STORAGE_SIZE(MAX_PATH_SIZE)]; const char* name = FileBlockDevice_FormatBlockFilename(device, nameStorage, blockIndex); - exists = SolidSyslogFile_Exists(device->handle.file, name); + exists = SolidSyslogFile_Exists(device->Handle.File, name); } return exists; @@ -322,10 +322,10 @@ static bool FileBlockDevice_Read( if (FileBlockDevice_IsValidBlockIndex(blockIndex)) { struct SolidSyslogFileBlockDevice* device = FileBlockDevice_AsFileBlockDevice(self); - if (FileBlockDevice_EnsureHandleOpenOnBlock(&device->handle, device, blockIndex)) + if (FileBlockDevice_EnsureHandleOpenOnBlock(&device->Handle, device, blockIndex)) { - SolidSyslogFile_SeekTo(device->handle.file, offset); - read = SolidSyslogFile_Read(device->handle.file, buf, count); + SolidSyslogFile_SeekTo(device->Handle.File, offset); + read = SolidSyslogFile_Read(device->Handle.File, buf, count); } } @@ -346,10 +346,10 @@ static bool FileBlockDevice_Append( if (FileBlockDevice_IsValidBlockIndex(blockIndex)) { struct SolidSyslogFileBlockDevice* device = FileBlockDevice_AsFileBlockDevice(self); - if (FileBlockDevice_EnsureHandleOpenOnBlock(&device->handle, device, blockIndex)) + if (FileBlockDevice_EnsureHandleOpenOnBlock(&device->Handle, device, blockIndex)) { - SolidSyslogFile_SeekTo(device->handle.file, SolidSyslogFile_Size(device->handle.file)); - written = SolidSyslogFile_Write(device->handle.file, buf, count); + SolidSyslogFile_SeekTo(device->Handle.File, SolidSyslogFile_Size(device->Handle.File)); + written = SolidSyslogFile_Write(device->Handle.File, buf, count); } } @@ -370,10 +370,10 @@ static bool FileBlockDevice_WriteAt( if (FileBlockDevice_IsValidBlockIndex(blockIndex)) { struct SolidSyslogFileBlockDevice* device = FileBlockDevice_AsFileBlockDevice(self); - if (FileBlockDevice_EnsureHandleOpenOnBlock(&device->handle, device, blockIndex)) + if (FileBlockDevice_EnsureHandleOpenOnBlock(&device->Handle, device, blockIndex)) { - SolidSyslogFile_SeekTo(device->handle.file, offset); - written = SolidSyslogFile_Write(device->handle.file, buf, count); + SolidSyslogFile_SeekTo(device->Handle.File, offset); + written = SolidSyslogFile_Write(device->Handle.File, buf, count); } } @@ -389,9 +389,9 @@ static size_t FileBlockDevice_Size(struct SolidSyslogBlockDevice* self, size_t b if (FileBlockDevice_IsValidBlockIndex(blockIndex)) { struct SolidSyslogFileBlockDevice* device = FileBlockDevice_AsFileBlockDevice(self); - if (FileBlockDevice_EnsureHandleOpenOnBlock(&device->handle, device, blockIndex)) + if (FileBlockDevice_EnsureHandleOpenOnBlock(&device->Handle, device, blockIndex)) { - size = SolidSyslogFile_Size(device->handle.file); + size = SolidSyslogFile_Size(device->Handle.File); } } diff --git a/Core/Source/SolidSyslogFormatter.c b/Core/Source/SolidSyslogFormatter.c index 5af425fd..293f04d7 100644 --- a/Core/Source/SolidSyslogFormatter.c +++ b/Core/Source/SolidSyslogFormatter.c @@ -7,9 +7,9 @@ struct SolidSyslogFormatter { - size_t size; - size_t position; - char buffer[]; + size_t Size; + size_t Position; + char Buffer[]; }; SOLIDSYSLOG_STATIC_ASSERT( @@ -43,12 +43,12 @@ static const size_t ESCAPED_CHARACTER_DECODED_LENGTH = 1; * fit and the loop must terminate. */ struct EscapedContext { - struct SolidSyslogFormatter* formatter; - const char* source; - size_t sourcePos; - size_t decodedLength; - size_t maxDecodedLength; - bool exhausted; + struct SolidSyslogFormatter* Formatter; + const char* Source; + size_t SourcePos; + size_t DecodedLength; + size_t MaxDecodedLength; + bool Exhausted; }; static inline bool Formatter_CodepointFits(size_t codepointLength, size_t remainingDecodedLength); @@ -91,17 +91,17 @@ static inline void Formatter_WriteReplacement(struct EscapedContext* context); struct SolidSyslogFormatter* SolidSyslogFormatter_Create(SolidSyslogFormatterStorage* storage, size_t bufferSize) { struct SolidSyslogFormatter* formatter = (struct SolidSyslogFormatter*) storage; - formatter->size = bufferSize; - formatter->position = 0; + formatter->Size = bufferSize; + formatter->Position = 0; Formatter_NullTerminate(formatter); return formatter; } static inline void Formatter_NullTerminate(struct SolidSyslogFormatter* formatter) { - if (formatter->size > 0) + if (formatter->Size > 0) { - formatter->buffer[formatter->position] = '\0'; + formatter->Buffer[formatter->Position] = '\0'; } } @@ -130,14 +130,14 @@ static inline void Formatter_WriteChar(struct SolidSyslogFormatter* formatter, c { if (Formatter_HasCapacity(formatter)) { - formatter->buffer[formatter->position] = value; - formatter->position++; + formatter->Buffer[formatter->Position] = value; + formatter->Position++; } } static inline bool Formatter_HasCapacity(const struct SolidSyslogFormatter* formatter) { - return (formatter->size > 0) && (formatter->position < formatter->size - 1); + return (formatter->Size > 0) && (formatter->Position < formatter->Size - 1); } /* @@ -275,17 +275,17 @@ void SolidSyslogFormatter_EscapedString( ) { struct EscapedContext context = { - .formatter = formatter, - .source = source, - .sourcePos = 0, - .decodedLength = 0, - .maxDecodedLength = maxDecodedLength, - .exhausted = false, + .Formatter = formatter, + .Source = source, + .SourcePos = 0, + .DecodedLength = 0, + .MaxDecodedLength = maxDecodedLength, + .Exhausted = false, }; while (!Formatter_IsExhausted(&context)) { - if (Formatter_NeedsEscape(source[context.sourcePos])) + if (Formatter_NeedsEscape(source[context.SourcePos])) { Formatter_WriteEscaped(&context); } @@ -304,14 +304,14 @@ static inline bool Formatter_NeedsEscape(char value) static inline bool Formatter_IsExhausted(const struct EscapedContext* context) { - return context->exhausted || (context->source[context->sourcePos] == '\0'); + return context->Exhausted || (context->Source[context->SourcePos] == '\0'); } static inline void Formatter_WriteEscaped(struct EscapedContext* context) { if (Formatter_Fits(context, ESCAPED_CHARACTER_DECODED_LENGTH)) { - char escaped[] = {ESCAPE_PREFIX, context->source[context->sourcePos]}; + char escaped[] = {ESCAPE_PREFIX, context->Source[context->SourcePos]}; Formatter_WriteContext(context, escaped, sizeof(escaped), 1, ESCAPED_CHARACTER_DECODED_LENGTH); return; } @@ -320,7 +320,7 @@ static inline void Formatter_WriteEscaped(struct EscapedContext* context) static inline bool Formatter_Fits(const struct EscapedContext* context, size_t decodedAdvance) { - return (decodedAdvance > 0) && (decodedAdvance <= context->maxDecodedLength - context->decodedLength); + return (decodedAdvance > 0) && (decodedAdvance <= context->MaxDecodedLength - context->DecodedLength); } /* NOLINTBEGIN(bugprone-easily-swappable-parameters) -- see forward declaration */ @@ -332,16 +332,16 @@ static inline void Formatter_WriteContext( size_t decodedAdvance ) { - Formatter_WriteBytes(context->formatter, bytes, byteCount); - context->sourcePos += sourceAdvance; - context->decodedLength += decodedAdvance; + Formatter_WriteBytes(context->Formatter, bytes, byteCount); + context->SourcePos += sourceAdvance; + context->DecodedLength += decodedAdvance; } /* NOLINTEND(bugprone-easily-swappable-parameters) */ static inline void Formatter_Exhaust(struct EscapedContext* context) { - context->exhausted = true; + context->Exhausted = true; } /* Writes the source codepoint at sourcePos if it fits the decoded budget; @@ -350,12 +350,12 @@ static inline void Formatter_Exhaust(struct EscapedContext* context) * Formatter_Utf8CodepointLength returns 0 for ill-formed sequences. */ static inline void Formatter_WriteCodepoint(struct EscapedContext* context) { - size_t codepointLength = Formatter_Utf8CodepointLength(&context->source[context->sourcePos]); + size_t codepointLength = Formatter_Utf8CodepointLength(&context->Source[context->SourcePos]); if (Formatter_Fits(context, codepointLength)) { Formatter_WriteContext( context, - &context->source[context->sourcePos], + &context->Source[context->SourcePos], codepointLength, codepointLength, codepointLength @@ -481,13 +481,13 @@ void SolidSyslogFormatter_SixDigit(struct SolidSyslogFormatter* formatter, uint3 const char* SolidSyslogFormatter_AsFormattedBuffer(struct SolidSyslogFormatter* formatter) { Formatter_TrimTruncatedMultiByteTail(formatter); - return formatter->buffer; + return formatter->Buffer; } static inline void Formatter_TrimTruncatedMultiByteTail(struct SolidSyslogFormatter* formatter) { - char* buffer = formatter->buffer; - size_t p = formatter->position; + char* buffer = formatter->Buffer; + size_t p = formatter->Position; size_t trimFrom = p; if ((p >= 1) && (SolidSyslogUtf8_IsTwoByteLead(buffer[p - 1]) || SolidSyslogUtf8_IsThreeByteLead(buffer[p - 1]) || @@ -512,5 +512,5 @@ static inline void Formatter_TrimTruncatedMultiByteTail(struct SolidSyslogFormat size_t SolidSyslogFormatter_Length(const struct SolidSyslogFormatter* formatter) { - return formatter->position; + return formatter->Position; } diff --git a/Core/Source/SolidSyslogMetaSd.c b/Core/Source/SolidSyslogMetaSd.c index 4352aa93..09200030 100644 --- a/Core/Source/SolidSyslogMetaSd.c +++ b/Core/Source/SolidSyslogMetaSd.c @@ -13,10 +13,10 @@ struct SolidSyslogFormatter; struct SolidSyslogMetaSd { - struct SolidSyslogStructuredData base; - struct SolidSyslogAtomicCounter* counter; - SolidSyslogSysUpTimeFunction getSysUpTime; - SolidSyslogStringFunction getLanguage; + struct SolidSyslogStructuredData Base; + struct SolidSyslogAtomicCounter* Counter; + SolidSyslogSysUpTimeFunction GetSysUpTime; + SolidSyslogStringFunction GetLanguage; }; static void MetaSd_Format(struct SolidSyslogStructuredData* self, struct SolidSyslogFormatter* formatter); @@ -35,27 +35,27 @@ struct SolidSyslogStructuredData* SolidSyslogMetaSd_Create(const struct SolidSys { SolidSyslog_Error(SolidSyslogSeverity_Warning, SOLIDSYSLOG_ERROR_MSG_METASD_CREATE_NULL_CONFIG); } - else if (config->counter == NULL) + else if (config->Counter == NULL) { SolidSyslog_Error(SolidSyslogSeverity_Warning, SOLIDSYSLOG_ERROR_MSG_METASD_CREATE_NULL_COUNTER); } else { - instance.base.Format = MetaSd_Format; - instance.counter = config->counter; - instance.getSysUpTime = config->getSysUpTime; - instance.getLanguage = config->getLanguage; - result = &instance.base; + instance.Base.Format = MetaSd_Format; + instance.Counter = config->Counter; + instance.GetSysUpTime = config->GetSysUpTime; + instance.GetLanguage = config->GetLanguage; + result = &instance.Base; } return result; } void SolidSyslogMetaSd_Destroy(void) { - instance.base.Format = NULL; - instance.counter = NULL; - instance.getSysUpTime = NULL; - instance.getLanguage = NULL; + instance.Base.Format = NULL; + instance.Counter = NULL; + instance.GetSysUpTime = NULL; + instance.GetLanguage = NULL; } static void MetaSd_NilMetaSdFormat(struct SolidSyslogStructuredData* self, struct SolidSyslogFormatter* formatter) @@ -83,26 +83,26 @@ static void MetaSd_Format(struct SolidSyslogStructuredData* self, struct SolidSy static inline void MetaSd_EmitSequenceId(struct SolidSyslogMetaSd* meta, struct SolidSyslogFormatter* formatter) { SolidSyslogFormatter_BoundedString(formatter, SEQUENCE_ID_SD, sizeof(SEQUENCE_ID_SD) - 1); - SolidSyslogFormatter_Uint32(formatter, SolidSyslogAtomicCounter_Increment(meta->counter)); + SolidSyslogFormatter_Uint32(formatter, SolidSyslogAtomicCounter_Increment(meta->Counter)); SolidSyslogFormatter_AsciiCharacter(formatter, '"'); } static inline void MetaSd_EmitSysUpTime(struct SolidSyslogMetaSd* meta, struct SolidSyslogFormatter* formatter) { - if (meta->getSysUpTime != NULL) + if (meta->GetSysUpTime != NULL) { SolidSyslogFormatter_BoundedString(formatter, SYS_UP_TIME_SD, sizeof(SYS_UP_TIME_SD) - 1); - SolidSyslogFormatter_Uint32(formatter, meta->getSysUpTime()); + SolidSyslogFormatter_Uint32(formatter, meta->GetSysUpTime()); SolidSyslogFormatter_AsciiCharacter(formatter, '"'); } } static inline void MetaSd_EmitLanguage(struct SolidSyslogMetaSd* meta, struct SolidSyslogFormatter* formatter) { - if (meta->getLanguage != NULL) + if (meta->GetLanguage != NULL) { SolidSyslogFormatter_BoundedString(formatter, LANGUAGE_SD, sizeof(LANGUAGE_SD) - 1); - meta->getLanguage(formatter); + meta->GetLanguage(formatter); SolidSyslogFormatter_AsciiCharacter(formatter, '"'); } } diff --git a/Core/Source/SolidSyslogNullBuffer.c b/Core/Source/SolidSyslogNullBuffer.c index 81e5da4f..c9df4da1 100644 --- a/Core/Source/SolidSyslogNullBuffer.c +++ b/Core/Source/SolidSyslogNullBuffer.c @@ -11,25 +11,25 @@ static void NullBuffer_Write(struct SolidSyslogBuffer* self, const void* data, s struct SolidSyslogNullBuffer { - struct SolidSyslogBuffer base; - struct SolidSyslogSender* sender; + struct SolidSyslogBuffer Base; + struct SolidSyslogSender* Sender; }; static struct SolidSyslogNullBuffer instance; struct SolidSyslogBuffer* SolidSyslogNullBuffer_Create(struct SolidSyslogSender* sender) { - instance.base.Write = NullBuffer_Write; - instance.base.Read = NullBuffer_Read; - instance.sender = sender; - return &instance.base; + instance.Base.Write = NullBuffer_Write; + instance.Base.Read = NullBuffer_Read; + instance.Sender = sender; + return &instance.Base; } void SolidSyslogNullBuffer_Destroy(void) { - instance.base.Write = NULL; - instance.base.Read = NULL; - instance.sender = NULL; + instance.Base.Write = NULL; + instance.Base.Read = NULL; + instance.Sender = NULL; } static bool NullBuffer_Read(struct SolidSyslogBuffer* self, void* data, size_t maxSize, size_t* bytesRead) @@ -44,5 +44,5 @@ static bool NullBuffer_Read(struct SolidSyslogBuffer* self, void* data, size_t m static void NullBuffer_Write(struct SolidSyslogBuffer* self, const void* data, size_t size) { struct SolidSyslogNullBuffer* nullBuffer = (struct SolidSyslogNullBuffer*) self; - SolidSyslogSender_Send(nullBuffer->sender, data, size); + SolidSyslogSender_Send(nullBuffer->Sender, data, size); } diff --git a/Core/Source/SolidSyslogNullStore.c b/Core/Source/SolidSyslogNullStore.c index 604a2dae..744601c8 100644 --- a/Core/Source/SolidSyslogNullStore.c +++ b/Core/Source/SolidSyslogNullStore.c @@ -16,34 +16,34 @@ static bool NullStore_IsTransient(struct SolidSyslogStore* self); struct SolidSyslogNullStore { - struct SolidSyslogStore base; + struct SolidSyslogStore Base; }; static struct SolidSyslogNullStore instance; struct SolidSyslogStore* SolidSyslogNullStore_Create(void) { - instance.base.Write = NullStore_Write; - instance.base.ReadNextUnsent = NullStore_ReadNextUnsent; - instance.base.MarkSent = NullStore_MarkSent; - instance.base.HasUnsent = NullStore_HasUnsent; - instance.base.IsHalted = NullStore_IsHalted; - instance.base.GetTotalBytes = NullStore_GetTotalBytes; - instance.base.GetUsedBytes = NullStore_GetUsedBytes; - instance.base.IsTransient = NullStore_IsTransient; - return &instance.base; + instance.Base.Write = NullStore_Write; + instance.Base.ReadNextUnsent = NullStore_ReadNextUnsent; + instance.Base.MarkSent = NullStore_MarkSent; + instance.Base.HasUnsent = NullStore_HasUnsent; + instance.Base.IsHalted = NullStore_IsHalted; + instance.Base.GetTotalBytes = NullStore_GetTotalBytes; + instance.Base.GetUsedBytes = NullStore_GetUsedBytes; + instance.Base.IsTransient = NullStore_IsTransient; + return &instance.Base; } void SolidSyslogNullStore_Destroy(void) { - instance.base.Write = NULL; - instance.base.ReadNextUnsent = NULL; - instance.base.MarkSent = NULL; - instance.base.HasUnsent = NULL; - instance.base.IsHalted = NULL; - instance.base.GetTotalBytes = NULL; - instance.base.GetUsedBytes = NULL; - instance.base.IsTransient = NULL; + instance.Base.Write = NULL; + instance.Base.ReadNextUnsent = NULL; + instance.Base.MarkSent = NULL; + instance.Base.HasUnsent = NULL; + instance.Base.IsHalted = NULL; + instance.Base.GetTotalBytes = NULL; + instance.Base.GetUsedBytes = NULL; + instance.Base.IsTransient = NULL; } /* NullStore never retains. Returns false to signal "not held by this store" diff --git a/Core/Source/SolidSyslogOriginSd.c b/Core/Source/SolidSyslogOriginSd.c index a7d48255..80b82920 100644 --- a/Core/Source/SolidSyslogOriginSd.c +++ b/Core/Source/SolidSyslogOriginSd.c @@ -18,10 +18,10 @@ enum struct SolidSyslogOriginSd { - struct SolidSyslogStructuredData base; - SolidSyslogOriginIpCountFunction getIpCount; - SolidSyslogOriginIpAtFunction getIpAt; - SolidSyslogFormatterStorage formattedStorage[SOLIDSYSLOG_FORMATTER_STORAGE_SIZE(ORIGIN_FORMATTED_MAX)]; + struct SolidSyslogStructuredData Base; + SolidSyslogOriginIpCountFunction GetIpCount; + SolidSyslogOriginIpAtFunction GetIpAt; + SolidSyslogFormatterStorage FormattedStorage[SOLIDSYSLOG_FORMATTER_STORAGE_SIZE(ORIGIN_FORMATTED_MAX)]; }; static const char SD_PREFIX[] = "[origin"; @@ -55,24 +55,24 @@ static struct SolidSyslogOriginSd instance; struct SolidSyslogStructuredData* SolidSyslogOriginSd_Create(const struct SolidSyslogOriginSdConfig* config) { - instance.base.Format = OriginSd_Format; - instance.getIpCount = config->getIpCount; - instance.getIpAt = config->getIpAt; + instance.Base.Format = OriginSd_Format; + instance.GetIpCount = config->GetIpCount; + instance.GetIpAt = config->GetIpAt; OriginSd_PreFormatStaticPrefix(config); - return &instance.base; + return &instance.Base; } void SolidSyslogOriginSd_Destroy(void) { - instance.base.Format = NULL; - instance.getIpCount = NULL; - instance.getIpAt = NULL; + instance.Base.Format = NULL; + instance.GetIpCount = NULL; + instance.GetIpAt = NULL; } static void OriginSd_Format(struct SolidSyslogStructuredData* self, struct SolidSyslogFormatter* formatter) { struct SolidSyslogOriginSd* origin = (struct SolidSyslogOriginSd*) self; - struct SolidSyslogFormatter* preformat = SolidSyslogFormatter_FromStorage(origin->formattedStorage); + struct SolidSyslogFormatter* preformat = SolidSyslogFormatter_FromStorage(origin->FormattedStorage); SolidSyslogFormatter_BoundedString( formatter, @@ -85,7 +85,7 @@ static void OriginSd_Format(struct SolidSyslogStructuredData* self, struct Solid static inline void OriginSd_PreFormatStaticPrefix(const struct SolidSyslogOriginSdConfig* config) { - struct SolidSyslogFormatter* f = SolidSyslogFormatter_Create(instance.formattedStorage, ORIGIN_FORMATTED_MAX); + struct SolidSyslogFormatter* f = SolidSyslogFormatter_Create(instance.FormattedStorage, ORIGIN_FORMATTED_MAX); SolidSyslogFormatter_BoundedString(f, SD_PREFIX, sizeof(SD_PREFIX) - 1); OriginSd_EmitSoftware(f, config); @@ -96,10 +96,10 @@ static inline void OriginSd_PreFormatStaticPrefix(const struct SolidSyslogOrigin static inline void OriginSd_EmitSoftware(struct SolidSyslogFormatter* f, const struct SolidSyslogOriginSdConfig* config) { - if (config->software != NULL) + if (config->Software != NULL) { SolidSyslogFormatter_BoundedString(f, SD_SOFTWARE_SD, sizeof(SD_SOFTWARE_SD) - 1); - SolidSyslogFormatter_EscapedString(f, config->software, ORIGIN_SOFTWARE_MAX); + SolidSyslogFormatter_EscapedString(f, config->Software, ORIGIN_SOFTWARE_MAX); SolidSyslogFormatter_AsciiCharacter(f, '"'); } } @@ -109,10 +109,10 @@ static inline void OriginSd_EmitSwVersion( const struct SolidSyslogOriginSdConfig* config ) { - if (config->swVersion != NULL) + if (config->SwVersion != NULL) { SolidSyslogFormatter_BoundedString(f, SD_VERSION_SD, sizeof(SD_VERSION_SD) - 1); - SolidSyslogFormatter_EscapedString(f, config->swVersion, ORIGIN_SWVERSION_MAX); + SolidSyslogFormatter_EscapedString(f, config->SwVersion, ORIGIN_SWVERSION_MAX); SolidSyslogFormatter_AsciiCharacter(f, '"'); } } @@ -122,19 +122,19 @@ static inline void OriginSd_EmitEnterpriseId( const struct SolidSyslogOriginSdConfig* config ) { - if (config->enterpriseId != NULL) + if (config->EnterpriseId != NULL) { SolidSyslogFormatter_BoundedString(f, SD_ENTERPRISE_ID_SD, sizeof(SD_ENTERPRISE_ID_SD) - 1); - SolidSyslogFormatter_EscapedString(f, config->enterpriseId, ORIGIN_ENTERPRISE_ID_MAX); + SolidSyslogFormatter_EscapedString(f, config->EnterpriseId, ORIGIN_ENTERPRISE_ID_MAX); SolidSyslogFormatter_AsciiCharacter(f, '"'); } } static inline void OriginSd_EmitIps(struct SolidSyslogFormatter* formatter, const struct SolidSyslogOriginSd* origin) { - if ((origin->getIpCount != NULL) && (origin->getIpAt != NULL)) + if ((origin->GetIpCount != NULL) && (origin->GetIpAt != NULL)) { - size_t count = origin->getIpCount(); + size_t count = origin->GetIpCount(); for (size_t i = 0; i < count; i++) { OriginSd_EmitIp(formatter, origin, i); @@ -149,6 +149,6 @@ static inline void OriginSd_EmitIp( ) { SolidSyslogFormatter_BoundedString(formatter, SD_IP_SD, sizeof(SD_IP_SD) - 1); - origin->getIpAt(formatter, index); + origin->GetIpAt(formatter, index); SolidSyslogFormatter_AsciiCharacter(formatter, '"'); } diff --git a/Core/Source/SolidSyslogStreamSender.c b/Core/Source/SolidSyslogStreamSender.c index 3b22ccad..7bb2849d 100644 --- a/Core/Source/SolidSyslogStreamSender.c +++ b/Core/Source/SolidSyslogStreamSender.c @@ -17,10 +17,10 @@ struct SolidSyslogAddress; struct SolidSyslogStreamSender { - struct SolidSyslogSender base; - struct SolidSyslogStreamSenderConfig config; - bool connected; - uint32_t lastEndpointVersion; + struct SolidSyslogSender Base; + struct SolidSyslogStreamSenderConfig Config; + bool Connected; + uint32_t LastEndpointVersion; }; enum @@ -76,17 +76,17 @@ struct SolidSyslogSender* SolidSyslogStreamSender_Create( { struct SolidSyslogStreamSender* sender = (struct SolidSyslogStreamSender*) storage; *sender = DEFAULT_INSTANCE; - sender->config.resolver = config->resolver; - sender->config.stream = config->stream; - if (config->endpoint != NULL) + sender->Config.Resolver = config->Resolver; + sender->Config.Stream = config->Stream; + if (config->Endpoint != NULL) { - sender->config.endpoint = config->endpoint; + sender->Config.Endpoint = config->Endpoint; } - if (config->endpointVersion != NULL) + if (config->EndpointVersion != NULL) { - sender->config.endpointVersion = config->endpointVersion; + sender->Config.EndpointVersion = config->EndpointVersion; } - return &sender->base; + return &sender->Base; } void SolidSyslogStreamSender_Destroy(struct SolidSyslogSender* sender) @@ -110,12 +110,12 @@ static inline bool StreamSender_Reconcile(struct SolidSyslogStreamSender* sender static inline void StreamSender_DisconnectIfStale(struct SolidSyslogStreamSender* sender) { - uint32_t version = sender->config.endpointVersion(); + uint32_t version = sender->Config.EndpointVersion(); - if (version != sender->lastEndpointVersion) + if (version != sender->LastEndpointVersion) { - StreamSender_Disconnect(&sender->base); - sender->lastEndpointVersion = version; + StreamSender_Disconnect(&sender->Base); + sender->LastEndpointVersion = version; } } @@ -126,7 +126,7 @@ static inline bool StreamSender_EnsureConnected(struct SolidSyslogStreamSender* static inline bool StreamSender_Connected(struct SolidSyslogStreamSender* sender) { - return sender->connected; + return sender->Connected; } static bool StreamSender_Connect(struct SolidSyslogStreamSender* sender) @@ -136,7 +136,7 @@ static bool StreamSender_Connect(struct SolidSyslogStreamSender* sender) if (StreamSender_ResolveDestination(sender, addr)) { - sender->connected = SolidSyslogStream_Open(sender->config.stream, addr); + sender->Connected = SolidSyslogStream_Open(sender->Config.Stream, addr); } return StreamSender_Connected(sender); @@ -146,15 +146,15 @@ static bool StreamSender_ResolveDestination(struct SolidSyslogStreamSender* send { SolidSyslogFormatterStorage hostStorage[SOLIDSYSLOG_FORMATTER_STORAGE_SIZE(SOLIDSYSLOG_MAX_HOST_SIZE)]; struct SolidSyslogFormatter* hostFormatter = SolidSyslogFormatter_Create(hostStorage, SOLIDSYSLOG_MAX_HOST_SIZE); - struct SolidSyslogEndpoint endpoint = {.host = hostFormatter, .port = 0}; + struct SolidSyslogEndpoint endpoint = {.Host = hostFormatter, .Port = 0}; - sender->config.endpoint(&endpoint); + sender->Config.Endpoint(&endpoint); return SolidSyslogResolver_Resolve( - sender->config.resolver, + sender->Config.Resolver, SolidSyslogTransport_Tcp, SolidSyslogFormatter_AsFormattedBuffer(hostFormatter), - endpoint.port, + endpoint.Port, addr ); } @@ -171,8 +171,8 @@ static void StreamSender_Disconnect(struct SolidSyslogSender* self) static inline void StreamSender_CloseStream(struct SolidSyslogStreamSender* sender) { - SolidSyslogStream_Close(sender->config.stream); - sender->connected = false; + SolidSyslogStream_Close(sender->Config.Stream); + sender->Connected = false; } static bool StreamSender_TransmitFramed(struct SolidSyslogStreamSender* sender, const void* buffer, size_t size) @@ -201,7 +201,7 @@ static struct SolidSyslogFormatter* StreamSender_FormatOctetCountingPrefix( static bool StreamSender_SendBytes(struct SolidSyslogStreamSender* sender, const void* data, size_t len) { - bool sent = SolidSyslogStream_Send(sender->config.stream, data, len); + bool sent = SolidSyslogStream_Send(sender->Config.Stream, data, len); if (!sent) { @@ -213,8 +213,8 @@ static bool StreamSender_SendBytes(struct SolidSyslogStreamSender* sender, const static void StreamSender_NilEndpoint(struct SolidSyslogEndpoint* endpoint) { - SolidSyslogFormatter_BoundedString(endpoint->host, "", 0); - endpoint->port = 0; + SolidSyslogFormatter_BoundedString(endpoint->Host, "", 0); + endpoint->Port = 0; } static uint32_t StreamSender_NilEndpointVersion(void) diff --git a/Core/Source/SolidSyslogSwitchingSender.c b/Core/Source/SolidSyslogSwitchingSender.c index b4c32b35..3706fa15 100644 --- a/Core/Source/SolidSyslogSwitchingSender.c +++ b/Core/Source/SolidSyslogSwitchingSender.c @@ -8,9 +8,9 @@ struct SolidSyslogSwitchingSender { - struct SolidSyslogSender base; - struct SolidSyslogSwitchingSenderConfig config; - struct SolidSyslogSender* currentSender; + struct SolidSyslogSender Base; + struct SolidSyslogSwitchingSenderConfig Config; + struct SolidSyslogSender* CurrentSender; }; static bool SwitchingSender_Send(struct SolidSyslogSender* sender, const void* buffer, size_t size); @@ -29,16 +29,16 @@ static bool SwitchingSender_NilSend(struct SolidSyslogSender* sender, const void static void SwitchingSender_NilDisconnect(struct SolidSyslogSender* sender); static struct SolidSyslogSender NIL_SENDER = {SwitchingSender_NilSend, SwitchingSender_NilDisconnect}; -static const struct SolidSyslogSwitchingSender DEFAULT_INSTANCE = {.currentSender = &NIL_SENDER}; +static const struct SolidSyslogSwitchingSender DEFAULT_INSTANCE = {.CurrentSender = &NIL_SENDER}; static struct SolidSyslogSwitchingSender instance; struct SolidSyslogSender* SolidSyslogSwitchingSender_Create(const struct SolidSyslogSwitchingSenderConfig* config) { instance = DEFAULT_INSTANCE; - instance.config = *config; - instance.base.Send = SwitchingSender_Send; - instance.base.Disconnect = SwitchingSender_Disconnect; - return &instance.base; + instance.Config = *config; + instance.Base.Send = SwitchingSender_Send; + instance.Base.Disconnect = SwitchingSender_Disconnect; + return &instance.Base; } void SolidSyslogSwitchingSender_Destroy(void) @@ -50,13 +50,13 @@ static bool SwitchingSender_Send(struct SolidSyslogSender* sender, const void* b { struct SolidSyslogSwitchingSender* self = (struct SolidSyslogSwitchingSender*) sender; SwitchingSender_SelectSender(self); - return SolidSyslogSender_Send(self->currentSender, buffer, size); + return SolidSyslogSender_Send(self->CurrentSender, buffer, size); } static void SwitchingSender_Disconnect(struct SolidSyslogSender* sender) { struct SolidSyslogSwitchingSender* self = (struct SolidSyslogSwitchingSender*) sender; - SolidSyslogSender_Disconnect(self->currentSender); + SolidSyslogSender_Disconnect(self->CurrentSender); } static inline void SwitchingSender_SelectSender(struct SolidSyslogSwitchingSender* self) @@ -74,7 +74,7 @@ static inline bool SwitchingSender_SenderChanged( const struct SolidSyslogSender* requestedSender ) { - return requestedSender != self->currentSender; + return requestedSender != self->CurrentSender; } static inline void SwitchingSender_SwitchTo( @@ -82,8 +82,8 @@ static inline void SwitchingSender_SwitchTo( struct SolidSyslogSender* newCurrent ) { - SolidSyslogSender_Disconnect(self->currentSender); - self->currentSender = newCurrent; + SolidSyslogSender_Disconnect(self->CurrentSender); + self->CurrentSender = newCurrent; } /* Falls back to the nil sender when the selector returns an out-of-range @@ -91,12 +91,12 @@ static inline void SwitchingSender_SwitchTo( * violation of an invalid selector without corrupting memory or crashing. */ static inline struct SolidSyslogSender* SwitchingSender_RequestedSender(const struct SolidSyslogSwitchingSender* self) { - uint8_t index = self->config.selector(); + uint8_t index = self->Config.Selector(); struct SolidSyslogSender* result = &NIL_SENDER; - if (index < self->config.senderCount) + if (index < self->Config.SenderCount) { - result = self->config.senders[index]; + result = self->Config.Senders[index]; } return result; diff --git a/Core/Source/SolidSyslogTimeQualitySd.c b/Core/Source/SolidSyslogTimeQualitySd.c index 92f56009..234b74f6 100644 --- a/Core/Source/SolidSyslogTimeQualitySd.c +++ b/Core/Source/SolidSyslogTimeQualitySd.c @@ -11,8 +11,8 @@ struct SolidSyslogFormatter; struct SolidSyslogTimeQualitySd { - struct SolidSyslogStructuredData base; - SolidSyslogTimeQualityFunction getTimeQuality; + struct SolidSyslogStructuredData Base; + SolidSyslogTimeQualityFunction GetTimeQuality; }; static void TimeQualitySd_Format(struct SolidSyslogStructuredData* self, struct SolidSyslogFormatter* formatter); @@ -28,15 +28,15 @@ static struct SolidSyslogTimeQualitySd instance; struct SolidSyslogStructuredData* SolidSyslogTimeQualitySd_Create(SolidSyslogTimeQualityFunction getTimeQuality) { - instance.base.Format = TimeQualitySd_Format; - instance.getTimeQuality = getTimeQuality; - return &instance.base; + instance.Base.Format = TimeQualitySd_Format; + instance.GetTimeQuality = getTimeQuality; + return &instance.Base; } void SolidSyslogTimeQualitySd_Destroy(void) { - instance.base.Format = NULL; - instance.getTimeQuality = NULL; + instance.Base.Format = NULL; + instance.GetTimeQuality = NULL; } static const char SD_PREFIX[] = "[timeQuality"; @@ -49,12 +49,12 @@ static void TimeQualitySd_Format(struct SolidSyslogStructuredData* self, struct struct SolidSyslogTimeQualitySd* tq = (struct SolidSyslogTimeQualitySd*) self; struct SolidSyslogTimeQuality q = {0}; - tq->getTimeQuality(&q); + tq->GetTimeQuality(&q); SolidSyslogFormatter_BoundedString(formatter, SD_PREFIX, sizeof(SD_PREFIX) - 1); - TimeQualitySd_FormatBoolParam(formatter, PARAM_TZ_KNOWN, sizeof(PARAM_TZ_KNOWN) - 1, q.tzKnown); - TimeQualitySd_FormatBoolParam(formatter, PARAM_IS_SYNCED, sizeof(PARAM_IS_SYNCED) - 1, q.isSynced); - TimeQualitySd_FormatSyncAccuracy(formatter, q.syncAccuracyMicroseconds); + TimeQualitySd_FormatBoolParam(formatter, PARAM_TZ_KNOWN, sizeof(PARAM_TZ_KNOWN) - 1, q.TzKnown); + TimeQualitySd_FormatBoolParam(formatter, PARAM_IS_SYNCED, sizeof(PARAM_IS_SYNCED) - 1, q.IsSynced); + TimeQualitySd_FormatSyncAccuracy(formatter, q.SyncAccuracyMicroseconds); SolidSyslogFormatter_AsciiCharacter(formatter, ']'); } diff --git a/Core/Source/SolidSyslogUdpSender.c b/Core/Source/SolidSyslogUdpSender.c index 17b1c4bc..692dbc10 100644 --- a/Core/Source/SolidSyslogUdpSender.c +++ b/Core/Source/SolidSyslogUdpSender.c @@ -19,11 +19,11 @@ struct SolidSyslogFormatter; struct SolidSyslogUdpSender { - struct SolidSyslogSender base; - struct SolidSyslogUdpSenderConfig config; - SolidSyslogAddressStorage addrStorage; - bool connected; - uint32_t lastEndpointVersion; + struct SolidSyslogSender Base; + struct SolidSyslogUdpSenderConfig Config; + SolidSyslogAddressStorage AddrStorage; + bool Connected; + uint32_t LastEndpointVersion; }; static bool UdpSender_IsValidConfig(const struct SolidSyslogUdpSenderConfig* config); @@ -54,7 +54,7 @@ static bool UdpSender_NilUdpSenderSend(struct SolidSyslogSender* self, const voi static void UdpSender_NilUdpSenderDisconnect(struct SolidSyslogSender* self); static const struct SolidSyslogUdpSender DEFAULT_INSTANCE = { - .config = {.endpointVersion = UdpSender_NilEndpointVersion} + .Config = {.EndpointVersion = UdpSender_NilEndpointVersion} }; static struct SolidSyslogUdpSender instance; static struct SolidSyslogSender NilUdpSender = { @@ -68,7 +68,7 @@ struct SolidSyslogSender* SolidSyslogUdpSender_Create(const struct SolidSyslogUd if (UdpSender_IsValidConfig(config)) { UdpSender_InstallConfig(config); - result = &instance.base; + result = &instance.Base; } return result; } @@ -80,15 +80,15 @@ static bool UdpSender_IsValidConfig(const struct SolidSyslogUdpSenderConfig* con { SolidSyslog_Error(SolidSyslogSeverity_Error, SOLIDSYSLOG_ERROR_MSG_UDPSENDER_CREATE_NULL_CONFIG); } - else if (config->resolver == NULL) + else if (config->Resolver == NULL) { SolidSyslog_Error(SolidSyslogSeverity_Error, SOLIDSYSLOG_ERROR_MSG_UDPSENDER_CREATE_NULL_RESOLVER); } - else if (config->datagram == NULL) + else if (config->Datagram == NULL) { SolidSyslog_Error(SolidSyslogSeverity_Error, SOLIDSYSLOG_ERROR_MSG_UDPSENDER_CREATE_NULL_DATAGRAM); } - else if (config->endpoint == NULL) + else if (config->Endpoint == NULL) { SolidSyslog_Error(SolidSyslogSeverity_Error, SOLIDSYSLOG_ERROR_MSG_UDPSENDER_CREATE_NULL_ENDPOINT); } @@ -102,18 +102,18 @@ static bool UdpSender_IsValidConfig(const struct SolidSyslogUdpSenderConfig* con static void UdpSender_InstallConfig(const struct SolidSyslogUdpSenderConfig* config) { instance = DEFAULT_INSTANCE; - instance.config = *config; - if (instance.config.endpointVersion == NULL) + instance.Config = *config; + if (instance.Config.EndpointVersion == NULL) { - instance.config.endpointVersion = UdpSender_NilEndpointVersion; + instance.Config.EndpointVersion = UdpSender_NilEndpointVersion; } - instance.base.Send = UdpSender_Send; - instance.base.Disconnect = UdpSender_Disconnect; + instance.Base.Send = UdpSender_Send; + instance.Base.Disconnect = UdpSender_Disconnect; } void SolidSyslogUdpSender_Destroy(void) { - UdpSender_Disconnect(&instance.base); + UdpSender_Disconnect(&instance.Base); instance = DEFAULT_INSTANCE; } @@ -150,12 +150,12 @@ static inline bool UdpSender_Reconcile(struct SolidSyslogUdpSender* udp) static inline void UdpSender_DisconnectIfStale(struct SolidSyslogUdpSender* udp) { - uint32_t version = udp->config.endpointVersion(); + uint32_t version = udp->Config.EndpointVersion(); - if (version != udp->lastEndpointVersion) + if (version != udp->LastEndpointVersion) { - UdpSender_Disconnect(&udp->base); - udp->lastEndpointVersion = version; + UdpSender_Disconnect(&udp->Base); + udp->LastEndpointVersion = version; } } @@ -166,7 +166,7 @@ static inline bool UdpSender_EnsureConnected(struct SolidSyslogUdpSender* udp) static inline bool UdpSender_Connected(struct SolidSyslogUdpSender* udp) { - return udp->connected; + return udp->Connected; } static bool UdpSender_Connect(struct SolidSyslogUdpSender* udp) @@ -178,7 +178,7 @@ static bool UdpSender_Connect(struct SolidSyslogUdpSender* udp) if (UdpSender_OpenSocket(udp) && UdpSender_ResolveDestination(udp, host, port)) { - udp->connected = true; + udp->Connected = true; } else { @@ -192,20 +192,20 @@ static inline uint16_t UdpSender_QueryEndpointPort( struct SolidSyslogFormatter* hostFormatter ) { - struct SolidSyslogEndpoint endpoint = {.host = hostFormatter, .port = 0}; - udp->config.endpoint(&endpoint); - return endpoint.port; + struct SolidSyslogEndpoint endpoint = {.Host = hostFormatter, .Port = 0}; + udp->Config.Endpoint(&endpoint); + return endpoint.Port; } static inline bool UdpSender_OpenSocket(struct SolidSyslogUdpSender* udp) { - return SolidSyslogDatagram_Open(udp->config.datagram); + return SolidSyslogDatagram_Open(udp->Config.Datagram); } static bool UdpSender_ResolveDestination(struct SolidSyslogUdpSender* udp, const char* host, uint16_t port) { return SolidSyslogResolver_Resolve( - udp->config.resolver, + udp->Config.Resolver, SolidSyslogTransport_Udp, host, port, @@ -215,19 +215,19 @@ static bool UdpSender_ResolveDestination(struct SolidSyslogUdpSender* udp, const static inline struct SolidSyslogAddress* UdpSender_Address(struct SolidSyslogUdpSender* udp) { - return SolidSyslogAddress_FromStorage(&udp->addrStorage); + return SolidSyslogAddress_FromStorage(&udp->AddrStorage); } static inline void UdpSender_CloseSocket(struct SolidSyslogUdpSender* udp) { - SolidSyslogDatagram_Close(udp->config.datagram); - udp->connected = false; + SolidSyslogDatagram_Close(udp->Config.Datagram); + udp->Connected = false; } static inline bool UdpSender_TransmitDatagram(struct SolidSyslogUdpSender* udp, const void* buffer, size_t size) { enum SolidSyslogDatagramSendResult result = - SolidSyslogDatagram_SendTo(udp->config.datagram, buffer, size, UdpSender_Address(udp)); + SolidSyslogDatagram_SendTo(udp->Config.Datagram, buffer, size, UdpSender_Address(udp)); if (result == SolidSyslogDatagramSendResult_Oversize) { result = UdpSender_RetryAfterOversize(udp, buffer, size); @@ -241,7 +241,7 @@ static inline enum SolidSyslogDatagramSendResult UdpSender_RetryAfterOversize( size_t size ) { - size_t maxPayload = SolidSyslogDatagram_MaxPayload(udp->config.datagram); + size_t maxPayload = SolidSyslogDatagram_MaxPayload(udp->Config.Datagram); size_t clipLimit = (size < maxPayload) ? size : maxPayload; size_t trimmed = SolidSyslogUdpPayload_TrimToCodepointBoundary((const uint8_t*) buffer, clipLimit); /* Default SENT swallows trimmed == 0 (path can't carry the message) so the @@ -249,7 +249,7 @@ static inline enum SolidSyslogDatagramSendResult UdpSender_RetryAfterOversize( enum SolidSyslogDatagramSendResult result = SolidSyslogDatagramSendResult_Sent; if (trimmed > 0) { - result = SolidSyslogDatagram_SendTo(udp->config.datagram, buffer, trimmed, UdpSender_Address(udp)); + result = SolidSyslogDatagram_SendTo(udp->Config.Datagram, buffer, trimmed, UdpSender_Address(udp)); if (result == SolidSyslogDatagramSendResult_Oversize) { /* Retry still OVERSIZE means the kernel disagrees with its own diff --git a/DEVLOG.md b/DEVLOG.md index 86bcc62d..9d10079a 100644 --- a/DEVLOG.md +++ b/DEVLOG.md @@ -7670,3 +7670,76 @@ tag in the same pass. ### Open questions - None. + +## 2026-05-15 — S10.09 PascalCase data-member sweep (Tier 4) + +### Decisions + +- Took the cross-cutting Tier 4 data-member rename next (the + S10.07-sibling slot, numbered S10.09 when raised — story numbers + are identifiers, not sequencing). Issue #373, parent epic #12. +- Sliced into **eight cluster commits + one docs commit** on a + single feature branch (`feat/s10-09-data-member-pascalcase`), + pushed once at the end. The user's preference for many commits + over one wide sweep won out — cluster-by-cluster keeps each + commit small enough for CodeRabbit to digest, even though it + meant more wall-clock effort fighting test-fixture collisions. +- Eight commits, in order: + 1. **Formatter + EscapedContext** (file-local; 36+/36-) + 2. **Storage cluster** — BlockStore + Configs + RecordStore + + BlockSequence + BlockPresence + FileBlockDevice + OpenHandle + + NullStore + Posix/Windows/FatFs File impls (462+/462- across + 19 files; **API break** — `BlockStoreConfig` field names) + 3. **Buffer cluster** — NullBuffer + CircularBuffer + + PosixMessageQueueBuffer + `BufferFake` test fixture (81+/81-) + 4. **Sender impl bodies** — Udp/Stream/Switching senders, + TlsStream, Posix/Winsock/FreeRtos Datagram/TcpStream/Resolver + impls (221+/221- across 13 files; no API touch yet) + 5. **Sender Config public headers + test fakes + BDD** — + `UdpSenderConfig`, `StreamSenderConfig`, `SwitchingSenderConfig`, + `TlsStreamConfig` + SenderFake/DatagramFake/StreamFake + + OpenSslIntegration TlsTestServer/BioPairStream (336+/336- + across 23 files; **API break**) + 6. **SD cluster** — MetaSd, OriginSd, TimeQualitySd + Configs + (109+/109-; **API break** for `MetaSdConfig` and + `OriginSdConfig`) + 7. **Sync + atomics** — Posix/Windows/FreeRtosMutex, + AtomicCounter, StdAtomicU32, WindowsAtomicU32 (48+/48-, no + API break — impl bodies only) + 8. **Top-level public structs + impl `struct SolidSyslog`** — + `SolidSyslogConfig` (full slate), `Message`, `Timestamp`, + `Endpoint`, `TimeQuality`, `SecurityPolicy.IntegritySize` + + `BddTargetOptions` / `BddTargetWindowsOptions` to follow + (484+/484- across 39 files; **biggest API break**) +- Slice 5 carved `transport` out of the broad sed because it + collides with `BddTargetOptions.transport`. Slice 8 finished + the Tier-3 BDD-options rename so all three of `Transport`, + `Store`, `MaxBlocks` etc. line up on both sides of the + `storeConfig.X = options->X` assignment. +- Error messages in `SolidSyslogErrorMessages.h` that quote Config + field names follow the rename in the same slice as the Config + itself (slice 2 BlockStore — none renamed; slice 5 — UDP sender + 3 messages; slice 6 — MetaSd 1 message; slice 8 — top-level + 3 messages). The corresponding BadSetup tests assert on these + literal strings, so they had to move together. +- Updated `CLAUDE.md` one-line summary (members move to PascalCase), + `docs/misra-conformance.md` rows for the member kind and the + sweep volume table, and appended this DEVLOG entry. NAMING.md + was already authoritative — no change there. + +### Deferred + +- `analyze-tidy` reports zero `readability-identifier-naming` + member findings after slice 8. Other naming kinds remain in + their existing state; no shift in those numbers attributable + to this story. +- A handful of test-fixture structs deliberately kept *some* + members lowerCamelCase when only one field collided with a + production name (e.g. `SenderSpy.successfulSends` in slice 2 — + only `base` became `Base`). Tier 5 test code is "consistency- + only", so half-and-half there is acceptable; a future test-code + hygiene story can revisit if desired. + +### Open questions + +- None. The sweep cleared its named target; tidy is green. diff --git a/Platform/Atomics/Source/SolidSyslogStdAtomicU32.c b/Platform/Atomics/Source/SolidSyslogStdAtomicU32.c index 38e640a3..a04317db 100644 --- a/Platform/Atomics/Source/SolidSyslogStdAtomicU32.c +++ b/Platform/Atomics/Source/SolidSyslogStdAtomicU32.c @@ -8,7 +8,7 @@ struct SolidSyslogAtomicU32 { - _Atomic uint32_t value; + _Atomic uint32_t Value; }; SOLIDSYSLOG_STATIC_ASSERT( @@ -28,12 +28,12 @@ struct SolidSyslogAtomicU32* SolidSyslogAtomicU32_FromStorage(SolidSyslogAtomicU void SolidSyslogAtomicU32_Init(struct SolidSyslogAtomicU32* slot, uint32_t value) { - atomic_init(&slot->value, value); + atomic_init(&slot->Value, value); } uint32_t SolidSyslogAtomicU32_Load(struct SolidSyslogAtomicU32* slot) { - return atomic_load_explicit(&slot->value, memory_order_relaxed); + return atomic_load_explicit(&slot->Value, memory_order_relaxed); } // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) — CAS shape is universal (compare_exchange convention) @@ -41,7 +41,7 @@ bool SolidSyslogAtomicU32_CompareAndSwap(struct SolidSyslogAtomicU32* slot, uint { uint32_t expectedLocal = expected; return atomic_compare_exchange_strong_explicit( - &slot->value, + &slot->Value, &expectedLocal, desired, memory_order_relaxed, diff --git a/Platform/FatFs/Source/SolidSyslogFatFsFile.c b/Platform/FatFs/Source/SolidSyslogFatFsFile.c index 3a8a8ab9..c6405e73 100644 --- a/Platform/FatFs/Source/SolidSyslogFatFsFile.c +++ b/Platform/FatFs/Source/SolidSyslogFatFsFile.c @@ -24,9 +24,9 @@ static inline FIL* FatFsFile_Handle(struct SolidSyslogFile* self); struct SolidSyslogFatFsFile { - struct SolidSyslogFile base; - FIL fp; - bool isOpen; + struct SolidSyslogFile Base; + FIL Fp; + bool IsOpen; }; SOLIDSYSLOG_STATIC_ASSERT( @@ -35,7 +35,7 @@ SOLIDSYSLOG_STATIC_ASSERT( ); static const struct SolidSyslogFatFsFile DEFAULT_INSTANCE = { - .base = + .Base = {FatFsFile_Open, FatFsFile_Close, FatFsFile_IsOpen, @@ -46,14 +46,14 @@ static const struct SolidSyslogFatFsFile DEFAULT_INSTANCE = { FatFsFile_Truncate, FatFsFile_Exists, FatFsFile_Delete}, - .isOpen = false, + .IsOpen = false, }; struct SolidSyslogFile* SolidSyslogFatFsFile_Create(SolidSyslogFatFsFileStorage* storage) { struct SolidSyslogFatFsFile* fatfs = (struct SolidSyslogFatFsFile*) storage; *fatfs = DEFAULT_INSTANCE; - return &fatfs->base; + return &fatfs->Base; } void SolidSyslogFatFsFile_Destroy(struct SolidSyslogFile* file) @@ -64,9 +64,9 @@ void SolidSyslogFatFsFile_Destroy(struct SolidSyslogFile* file) static bool FatFsFile_Open(struct SolidSyslogFile* self, const char* path) { struct SolidSyslogFatFsFile* fatfs = FatFsFile_Self(self); - FRESULT result = f_open(&fatfs->fp, path, READ_WRITE_OR_CREATE); - fatfs->isOpen = (result == FR_OK); - return fatfs->isOpen; + FRESULT result = f_open(&fatfs->Fp, path, READ_WRITE_OR_CREATE); + fatfs->IsOpen = (result == FR_OK); + return fatfs->IsOpen; } static inline struct SolidSyslogFatFsFile* FatFsFile_Self(struct SolidSyslogFile* self) @@ -77,16 +77,16 @@ static inline struct SolidSyslogFatFsFile* FatFsFile_Self(struct SolidSyslogFile static void FatFsFile_Close(struct SolidSyslogFile* self) { struct SolidSyslogFatFsFile* fatfs = FatFsFile_Self(self); - if (fatfs->isOpen) + if (fatfs->IsOpen) { - f_close(&fatfs->fp); - fatfs->isOpen = false; + f_close(&fatfs->Fp); + fatfs->IsOpen = false; } } static bool FatFsFile_IsOpen(struct SolidSyslogFile* self) { - return FatFsFile_Self(self)->isOpen; + return FatFsFile_Self(self)->IsOpen; } static bool FatFsFile_Read(struct SolidSyslogFile* self, void* buf, size_t count) @@ -98,7 +98,7 @@ static bool FatFsFile_Read(struct SolidSyslogFile* self, void* buf, size_t count static inline FIL* FatFsFile_Handle(struct SolidSyslogFile* self) { - return &FatFsFile_Self(self)->fp; + return &FatFsFile_Self(self)->Fp; } static bool FatFsFile_Write(struct SolidSyslogFile* self, const void* buf, size_t count) diff --git a/Platform/FreeRtos/Source/SolidSyslogFreeRtosDatagram.c b/Platform/FreeRtos/Source/SolidSyslogFreeRtosDatagram.c index 58bc07f1..e33873d9 100644 --- a/Platform/FreeRtos/Source/SolidSyslogFreeRtosDatagram.c +++ b/Platform/FreeRtos/Source/SolidSyslogFreeRtosDatagram.c @@ -17,8 +17,8 @@ typedef struct SolidSyslogFreeRtosDatagram FreeRtosDatagram; struct SolidSyslogFreeRtosDatagram { - struct SolidSyslogDatagram base; - Socket_t socket; + struct SolidSyslogDatagram Base; + Socket_t Socket; }; SOLIDSYSLOG_STATIC_ASSERT( @@ -60,7 +60,7 @@ struct SolidSyslogDatagram* SolidSyslogFreeRtosDatagram_Create(SolidSyslogFreeRt { FreeRtosDatagram* datagram = (FreeRtosDatagram*) storage; *datagram = DEFAULT_INSTANCE; - return &datagram->base; + return &datagram->Base; } void SolidSyslogFreeRtosDatagram_Destroy(struct SolidSyslogDatagram* datagram) @@ -80,7 +80,7 @@ static bool FreeRtosDatagram_Open(struct SolidSyslogDatagram* self) FreeRtosDatagram* datagram = FreeRtosDatagram_From(self); if (!FreeRtosDatagram_IsOpen(datagram)) { - datagram->socket = FreeRTOS_socket(FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP); + datagram->Socket = FreeRTOS_socket(FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP); } return FreeRtosDatagram_IsOpen(datagram); } @@ -98,7 +98,7 @@ static enum SolidSyslogDatagramSendResult FreeRtosDatagram_SendTo( { const struct freertos_sockaddr* dest = SolidSyslogAddress_AsConstFreertosSockaddr(addr); FreeRtosDatagram_PrimeArpIfMissing(dest->sin_address.ulIP_IPv4); - int32_t sent = FreeRTOS_sendto(datagram->socket, buffer, size, 0, dest, sizeof(*dest)); + int32_t sent = FreeRTOS_sendto(datagram->Socket, buffer, size, 0, dest, sizeof(*dest)); if (sent > 0) { result = SolidSyslogDatagramSendResult_Sent; @@ -124,7 +124,7 @@ static inline void FreeRtosDatagram_PrimeArpIfMissing(uint32_t ip) static inline bool FreeRtosDatagram_IsOpen(const FreeRtosDatagram* datagram) { - return datagram->socket != FREERTOS_INVALID_SOCKET; + return datagram->Socket != FREERTOS_INVALID_SOCKET; } static size_t FreeRtosDatagram_MaxPayload(struct SolidSyslogDatagram* self) @@ -138,8 +138,8 @@ static void FreeRtosDatagram_Close(struct SolidSyslogDatagram* self) FreeRtosDatagram* datagram = FreeRtosDatagram_From(self); if (FreeRtosDatagram_IsOpen(datagram)) { - (void) FreeRTOS_closesocket(datagram->socket); - datagram->socket = FREERTOS_INVALID_SOCKET; + (void) FreeRTOS_closesocket(datagram->Socket); + datagram->Socket = FREERTOS_INVALID_SOCKET; } } diff --git a/Platform/FreeRtos/Source/SolidSyslogFreeRtosMutex.c b/Platform/FreeRtos/Source/SolidSyslogFreeRtosMutex.c index 9ccb67a4..95fe41bb 100644 --- a/Platform/FreeRtos/Source/SolidSyslogFreeRtosMutex.c +++ b/Platform/FreeRtos/Source/SolidSyslogFreeRtosMutex.c @@ -14,8 +14,8 @@ typedef struct SolidSyslogFreeRtosMutex FreeRtosMutex; * the Posix (pthread_mutex_t) and Windows (CRITICAL_SECTION) adapters. */ struct SolidSyslogFreeRtosMutex { - struct SolidSyslogMutex base; - StaticSemaphore_t buffer; + struct SolidSyslogMutex Base; + StaticSemaphore_t Buffer; }; SOLIDSYSLOG_STATIC_ASSERT( @@ -31,18 +31,18 @@ static inline SemaphoreHandle_t FreeRtosMutex_AsHandle(FreeRtosMutex* self); struct SolidSyslogMutex* SolidSyslogFreeRtosMutex_Create(SolidSyslogFreeRtosMutexStorage* storage) { FreeRtosMutex* mutex = (FreeRtosMutex*) storage; - mutex->base.Lock = FreeRtosMutex_Lock; - mutex->base.Unlock = FreeRtosMutex_Unlock; - (void) xSemaphoreCreateMutexStatic(&mutex->buffer); - return &mutex->base; + mutex->Base.Lock = FreeRtosMutex_Lock; + mutex->Base.Unlock = FreeRtosMutex_Unlock; + (void) xSemaphoreCreateMutexStatic(&mutex->Buffer); + return &mutex->Base; } void SolidSyslogFreeRtosMutex_Destroy(struct SolidSyslogMutex* mutex) { FreeRtosMutex* self = FreeRtosMutex_From(mutex); vSemaphoreDelete(FreeRtosMutex_AsHandle(self)); - self->base.Lock = NULL; - self->base.Unlock = NULL; + self->Base.Lock = NULL; + self->Base.Unlock = NULL; } static inline FreeRtosMutex* FreeRtosMutex_From(struct SolidSyslogMutex* self) @@ -52,7 +52,7 @@ static inline FreeRtosMutex* FreeRtosMutex_From(struct SolidSyslogMutex* self) static inline SemaphoreHandle_t FreeRtosMutex_AsHandle(FreeRtosMutex* self) { - return (SemaphoreHandle_t) &self->buffer; + return (SemaphoreHandle_t) &self->Buffer; } static void FreeRtosMutex_Lock(struct SolidSyslogMutex* self) diff --git a/Platform/FreeRtos/Source/SolidSyslogFreeRtosStaticResolver.c b/Platform/FreeRtos/Source/SolidSyslogFreeRtosStaticResolver.c index 868a9ba5..0729edf0 100644 --- a/Platform/FreeRtos/Source/SolidSyslogFreeRtosStaticResolver.c +++ b/Platform/FreeRtos/Source/SolidSyslogFreeRtosStaticResolver.c @@ -12,8 +12,8 @@ typedef struct SolidSyslogFreeRtosStaticResolver FreeRtosStaticResolver; struct SolidSyslogFreeRtosStaticResolver { - struct SolidSyslogResolver base; - uint8_t octets[4]; + struct SolidSyslogResolver Base; + uint8_t Octets[4]; }; SOLIDSYSLOG_STATIC_ASSERT( @@ -47,11 +47,11 @@ struct SolidSyslogResolver* SolidSyslogFreeRtosStaticResolver_Create( { FreeRtosStaticResolver* self = (FreeRtosStaticResolver*) storage; *self = DEFAULT_INSTANCE; - self->octets[0] = ipv4Octets[0]; - self->octets[1] = ipv4Octets[1]; - self->octets[2] = ipv4Octets[2]; - self->octets[3] = ipv4Octets[3]; - return &self->base; + self->Octets[0] = ipv4Octets[0]; + self->Octets[1] = ipv4Octets[1]; + self->Octets[2] = ipv4Octets[2]; + self->Octets[3] = ipv4Octets[3]; + return &self->Base; } void SolidSyslogFreeRtosStaticResolver_Destroy(struct SolidSyslogResolver* resolver) @@ -80,6 +80,6 @@ static bool FreeRtosStaticResolver_Resolve( sockaddr->sin_family = FREERTOS_AF_INET; sockaddr->sin_port = (uint16_t) FreeRTOS_htons(port); sockaddr->sin_address.ulIP_IPv4 = - FreeRTOS_inet_addr_quick(me->octets[0], me->octets[1], me->octets[2], me->octets[3]); + FreeRTOS_inet_addr_quick(me->Octets[0], me->Octets[1], me->Octets[2], me->Octets[3]); return true; } diff --git a/Platform/FreeRtos/Source/SolidSyslogFreeRtosTcpStream.c b/Platform/FreeRtos/Source/SolidSyslogFreeRtosTcpStream.c index 80a3bc09..27f98e87 100644 --- a/Platform/FreeRtos/Source/SolidSyslogFreeRtosTcpStream.c +++ b/Platform/FreeRtos/Source/SolidSyslogFreeRtosTcpStream.c @@ -18,8 +18,8 @@ typedef struct SolidSyslogFreeRtosTcpStream FreeRtosTcpStream; struct SolidSyslogFreeRtosTcpStream { - struct SolidSyslogStream base; - Socket_t socket; + struct SolidSyslogStream Base; + Socket_t Socket; }; /* 200 ms is short enough that the Service task keeps draining predictably @@ -94,7 +94,7 @@ struct SolidSyslogStream* SolidSyslogFreeRtosTcpStream_Create(SolidSyslogFreeRto { FreeRtosTcpStream* stream = (FreeRtosTcpStream*) storage; *stream = DEFAULT_INSTANCE; - return &stream->base; + return &stream->Base; } void SolidSyslogFreeRtosTcpStream_Destroy(struct SolidSyslogStream* stream) @@ -125,7 +125,7 @@ static bool FreeRtosTcpStream_Open(struct SolidSyslogStream* self, const struct static inline bool FreeRtosTcpStream_IsOpen(const FreeRtosTcpStream* stream) { - return stream->socket != FREERTOS_INVALID_SOCKET; + return stream->Socket != FREERTOS_INVALID_SOCKET; } static inline bool FreeRtosTcpStream_IsClosed(const FreeRtosTcpStream* stream) @@ -135,14 +135,14 @@ static inline bool FreeRtosTcpStream_IsClosed(const FreeRtosTcpStream* stream) static void FreeRtosTcpStream_OpenSocket(FreeRtosTcpStream* stream) { - stream->socket = FreeRTOS_socket(FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP); + stream->Socket = FreeRTOS_socket(FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP); } static void FreeRtosTcpStream_ConnectOrCloseOnFailure(FreeRtosTcpStream* stream, const struct SolidSyslogAddress* addr) { if (FreeRtosTcpStream_TryConnect(stream, addr)) { - FreeRtosTcpStream_ClearTimeouts(stream->socket); + FreeRtosTcpStream_ClearTimeouts(stream->Socket); } else { @@ -156,9 +156,9 @@ static bool FreeRtosTcpStream_TryConnect(FreeRtosTcpStream* stream, const struct { const struct freertos_sockaddr* dest = SolidSyslogAddress_AsConstFreertosSockaddr(addr); FreeRtosTcpStream_PrimeArpIfMissing(dest->sin_address.ulIP_IPv4); - FreeRtosTcpStream_SetSendTimeout(stream->socket, CONNECT_TIMEOUT_TICKS); - FreeRtosTcpStream_SetRecvTimeout(stream->socket, CONNECT_TIMEOUT_TICKS); - return FreeRTOS_connect(stream->socket, dest, sizeof(*dest)) == 0; + FreeRtosTcpStream_SetSendTimeout(stream->Socket, CONNECT_TIMEOUT_TICKS); + FreeRtosTcpStream_SetRecvTimeout(stream->Socket, CONNECT_TIMEOUT_TICKS); + return FreeRTOS_connect(stream->Socket, dest, sizeof(*dest)) == 0; } /* On ARP cache miss issue a probe and yield once for the reply to land @@ -214,7 +214,7 @@ static bool FreeRtosTcpStream_SendOrCloseOnFailure(FreeRtosTcpStream* stream, co static bool FreeRtosTcpStream_TrySend(FreeRtosTcpStream* stream, const void* buffer, size_t size) { - BaseType_t sentCount = FreeRTOS_send(stream->socket, buffer, size, SEND_RECV_FLAGS_DEFAULT); + BaseType_t sentCount = FreeRTOS_send(stream->Socket, buffer, size, SEND_RECV_FLAGS_DEFAULT); return FreeRtosTcpStream_AllBytesSent(sentCount, size); } @@ -239,7 +239,7 @@ static SolidSyslogSsize FreeRtosTcpStream_Read(struct SolidSyslogStream* self, v static SolidSyslogSsize FreeRtosTcpStream_ReceiveOrCloseOnFailure(FreeRtosTcpStream* stream, void* buffer, size_t size) { - BaseType_t receivedCount = FreeRTOS_recv(stream->socket, buffer, size, SEND_RECV_FLAGS_DEFAULT); + BaseType_t receivedCount = FreeRTOS_recv(stream->Socket, buffer, size, SEND_RECV_FLAGS_DEFAULT); SolidSyslogSsize result = READ_FAILED; if (receivedCount >= 0) { @@ -261,8 +261,8 @@ static void FreeRtosTcpStream_CloseSocket(FreeRtosTcpStream* stream) { if (FreeRtosTcpStream_IsOpen(stream)) { - (void) FreeRTOS_closesocket(stream->socket); - stream->socket = FREERTOS_INVALID_SOCKET; + (void) FreeRTOS_closesocket(stream->Socket); + stream->Socket = FREERTOS_INVALID_SOCKET; } } diff --git a/Platform/OpenSsl/Interface/SolidSyslogTlsStream.h b/Platform/OpenSsl/Interface/SolidSyslogTlsStream.h index aac10634..289d617f 100644 --- a/Platform/OpenSsl/Interface/SolidSyslogTlsStream.h +++ b/Platform/OpenSsl/Interface/SolidSyslogTlsStream.h @@ -22,14 +22,14 @@ EXTERN_C_BEGIN struct SolidSyslogTlsStreamConfig { - struct SolidSyslogStream* transport; /* underlying byte stream — caller owns */ + struct SolidSyslogStream* Transport; /* underlying byte stream — caller owns */ SolidSyslogSleepFunction - sleep; /* drives bounded handshake retry between WANT_READ/WANT_WRITE polls — required */ - const char* caBundlePath; /* PEM file of trust anchors */ - const char* serverName; /* SNI + cert hostname check; NULL to skip */ - const char* cipherList; /* TLS 1.2 cipher list; NULL = OpenSSL default */ - const char* clientCertChainPath; /* PEM: leaf cert (+ intermediates); NULL = no mTLS */ - const char* clientKeyPath; /* PEM: matching private key; NULL = no mTLS */ + Sleep; /* drives bounded handshake retry between WANT_READ/WANT_WRITE polls — required */ + const char* CaBundlePath; /* PEM file of trust anchors */ + const char* ServerName; /* SNI + cert hostname check; NULL to skip */ + const char* CipherList; /* TLS 1.2 cipher list; NULL = OpenSSL default */ + const char* ClientCertChainPath; /* PEM: leaf cert (+ intermediates); NULL = no mTLS */ + const char* ClientKeyPath; /* PEM: matching private key; NULL = no mTLS */ }; struct SolidSyslogStream* SolidSyslogTlsStream_Create( diff --git a/Platform/OpenSsl/Source/SolidSyslogTlsStream.c b/Platform/OpenSsl/Source/SolidSyslogTlsStream.c index 7e93ed91..2c00c1ed 100644 --- a/Platform/OpenSsl/Source/SolidSyslogTlsStream.c +++ b/Platform/OpenSsl/Source/SolidSyslogTlsStream.c @@ -24,11 +24,11 @@ struct SolidSyslogAddress; struct SolidSyslogTlsStream { - struct SolidSyslogStream base; - struct SolidSyslogTlsStreamConfig config; - SSL_CTX* ctx; - SSL* ssl; - BIO_METHOD* bioMethod; + struct SolidSyslogStream Base; + struct SolidSyslogTlsStreamConfig Config; + SSL_CTX* Ctx; + SSL* Ssl; + BIO_METHOD* BioMethod; }; SOLIDSYSLOG_STATIC_ASSERT( @@ -85,8 +85,8 @@ struct SolidSyslogStream* SolidSyslogTlsStream_Create( { struct SolidSyslogTlsStream* stream = (struct SolidSyslogTlsStream*) storage; *stream = DEFAULT_INSTANCE; - stream->config = *config; - return &stream->base; + stream->Config = *config; + return &stream->Base; } void SolidSyslogTlsStream_Destroy(struct SolidSyslogStream* stream) @@ -105,43 +105,43 @@ static inline void TlsStream_ReleaseHandshakeState(struct SolidSyslogTlsStream* static inline void TlsStream_ReleaseSsl(struct SolidSyslogTlsStream* stream) { - if (stream->ssl != NULL) + if (stream->Ssl != NULL) { - SSL_free(stream->ssl); - stream->ssl = NULL; + SSL_free(stream->Ssl); + stream->Ssl = NULL; } } static inline void TlsStream_ReleaseBioMethod(struct SolidSyslogTlsStream* stream) { - if (stream->bioMethod != NULL) + if (stream->BioMethod != NULL) { - BIO_meth_free(stream->bioMethod); - stream->bioMethod = NULL; + BIO_meth_free(stream->BioMethod); + stream->BioMethod = NULL; } } static inline void TlsStream_ReleaseSslContext(struct SolidSyslogTlsStream* stream) { - if (stream->ctx != NULL) + if (stream->Ctx != NULL) { - SSL_CTX_free(stream->ctx); - stream->ctx = NULL; + SSL_CTX_free(stream->Ctx); + stream->Ctx = NULL; } } static inline bool TlsStream_Open(struct SolidSyslogStream* self, const struct SolidSyslogAddress* addr) { struct SolidSyslogTlsStream* stream = (struct SolidSyslogTlsStream*) self; - return SolidSyslogStream_Open(stream->config.transport, addr) && TlsStream_InitSslContext(stream) && + return SolidSyslogStream_Open(stream->Config.Transport, addr) && TlsStream_InitSslContext(stream) && TlsStream_InitSslSession(stream) && TlsStream_AttachTransportBio(stream) && TlsStream_ConfigureExpectedHostname(stream) && TlsStream_PerformHandshake(stream); } static inline bool TlsStream_InitSslContext(struct SolidSyslogTlsStream* stream) { - stream->ctx = TlsStream_CreateSslContext(&stream->config); - return stream->ctx != NULL; + stream->Ctx = TlsStream_CreateSslContext(&stream->Config); + return stream->Ctx != NULL; } static inline SSL_CTX* TlsStream_CreateSslContext(const struct SolidSyslogTlsStreamConfig* config) @@ -157,15 +157,15 @@ static inline SSL_CTX* TlsStream_CreateSslContext(const struct SolidSyslogTlsStr static inline bool TlsStream_ConfigureSslContext(SSL_CTX* ctx, const struct SolidSyslogTlsStreamConfig* config) { - return TlsStream_ConfigureTrustAnchors(ctx, config->caBundlePath) && + return TlsStream_ConfigureTrustAnchors(ctx, config->CaBundlePath) && TlsStream_ConfigureClientIdentity(ctx, config) && TlsStream_ConfigureProtocolFloor(ctx) && - TlsStream_ConfigureCipherList(ctx, config->cipherList); + TlsStream_ConfigureCipherList(ctx, config->CipherList); } static inline bool TlsStream_ConfigureClientIdentity(SSL_CTX* ctx, const struct SolidSyslogTlsStreamConfig* config) { - bool hasCert = config->clientCertChainPath != NULL; - bool hasKey = config->clientKeyPath != NULL; + bool hasCert = config->ClientCertChainPath != NULL; + bool hasKey = config->ClientKeyPath != NULL; bool ok = true; if (hasCert != hasKey) { @@ -173,8 +173,8 @@ static inline bool TlsStream_ConfigureClientIdentity(SSL_CTX* ctx, const struct } else if (hasCert) { - ok = (SSL_CTX_use_certificate_chain_file(ctx, config->clientCertChainPath) == 1) && - (SSL_CTX_use_PrivateKey_file(ctx, config->clientKeyPath, SSL_FILETYPE_PEM) == 1) && + ok = (SSL_CTX_use_certificate_chain_file(ctx, config->ClientCertChainPath) == 1) && + (SSL_CTX_use_PrivateKey_file(ctx, config->ClientKeyPath, SSL_FILETYPE_PEM) == 1) && (SSL_CTX_check_private_key(ctx) == 1); } return ok; @@ -207,8 +207,8 @@ static inline bool TlsStream_ConfigureCipherList(SSL_CTX* ctx, const char* ciphe static inline bool TlsStream_InitSslSession(struct SolidSyslogTlsStream* stream) { - stream->ssl = SSL_new(stream->ctx); - return stream->ssl != NULL; + stream->Ssl = SSL_new(stream->Ctx); + return stream->Ssl != NULL; } static inline bool TlsStream_AttachTransportBio(struct SolidSyslogTlsStream* stream) @@ -217,19 +217,19 @@ static inline bool TlsStream_AttachTransportBio(struct SolidSyslogTlsStream* str bool ok = bio != NULL; if (ok) { - BIO_set_data(bio, stream->config.transport); - SSL_set_bio(stream->ssl, bio, bio); + BIO_set_data(bio, stream->Config.Transport); + SSL_set_bio(stream->Ssl, bio, bio); } return ok; } static inline BIO* TlsStream_CreateTransportBio(struct SolidSyslogTlsStream* stream) { - stream->bioMethod = TlsStream_CreateTransportBioMethod(); + stream->BioMethod = TlsStream_CreateTransportBioMethod(); BIO* bio = NULL; - if (stream->bioMethod != NULL) + if (stream->BioMethod != NULL) { - bio = BIO_new(stream->bioMethod); + bio = BIO_new(stream->BioMethod); if (bio == NULL) { TlsStream_ReleaseBioMethod(stream); @@ -331,10 +331,10 @@ static inline long TlsStream_TransportBioCtrl(BIO* bio, int cmd, long larg, void static inline bool TlsStream_ConfigureExpectedHostname(struct SolidSyslogTlsStream* stream) { bool ok = true; - if (stream->config.serverName != NULL) + if (stream->Config.ServerName != NULL) { - ok = (SSL_set_tlsext_host_name(stream->ssl, stream->config.serverName) == 1) && - (SSL_set1_host(stream->ssl, stream->config.serverName) == 1); + ok = (SSL_set_tlsext_host_name(stream->Ssl, stream->Config.ServerName) == 1) && + (SSL_set1_host(stream->Ssl, stream->Config.ServerName) == 1); } return ok; } @@ -362,7 +362,7 @@ static inline bool TlsStream_PerformHandshake(struct SolidSyslogTlsStream* strea while (!done) { - int rc = SSL_connect(stream->ssl); + int rc = SSL_connect(stream->Ssl); if (rc > 0) { result = true; @@ -370,14 +370,14 @@ static inline bool TlsStream_PerformHandshake(struct SolidSyslogTlsStream* strea } else { - int err = SSL_get_error(stream->ssl, rc); + int err = SSL_get_error(stream->Ssl, rc); if (!TlsStream_IsRetryableSslError(err) || TlsStream_IsHandshakeBudgetExhausted(totalSleptMs)) { done = true; } else { - stream->config.sleep(HANDSHAKE_POLL_INTERVAL_MILLISECONDS); + stream->Config.Sleep(HANDSHAKE_POLL_INTERVAL_MILLISECONDS); totalSleptMs += HANDSHAKE_POLL_INTERVAL_MILLISECONDS; } } @@ -388,7 +388,7 @@ static inline bool TlsStream_PerformHandshake(struct SolidSyslogTlsStream* strea static inline bool TlsStream_Send(struct SolidSyslogStream* self, const void* buffer, size_t size) { struct SolidSyslogTlsStream* stream = (struct SolidSyslogTlsStream*) self; - int rc = SSL_write(stream->ssl, buffer, (int) size); + int rc = SSL_write(stream->Ssl, buffer, (int) size); bool ok = (rc > 0) && ((size_t) rc == size); if (!ok) @@ -410,14 +410,14 @@ static inline bool TlsStream_Send(struct SolidSyslogStream* self, const void* bu static inline SolidSyslogSsize TlsStream_Read(struct SolidSyslogStream* self, void* buffer, size_t size) { struct SolidSyslogTlsStream* stream = (struct SolidSyslogTlsStream*) self; - int rc = SSL_read(stream->ssl, buffer, (int) size); + int rc = SSL_read(stream->Ssl, buffer, (int) size); SolidSyslogSsize result = -1; if (rc > 0) { result = (SolidSyslogSsize) rc; } - else if (SSL_get_error(stream->ssl, rc) == SSL_ERROR_WANT_READ) + else if (SSL_get_error(stream->Ssl, rc) == SSL_ERROR_WANT_READ) { result = 0; } @@ -434,10 +434,10 @@ static inline SolidSyslogSsize TlsStream_Read(struct SolidSyslogStream* self, vo static inline void TlsStream_Close(struct SolidSyslogStream* self) { struct SolidSyslogTlsStream* stream = (struct SolidSyslogTlsStream*) self; - if (stream->ssl != NULL) + if (stream->Ssl != NULL) { - SSL_shutdown(stream->ssl); + SSL_shutdown(stream->Ssl); TlsStream_ReleaseHandshakeState(stream); } - SolidSyslogStream_Close(stream->config.transport); + SolidSyslogStream_Close(stream->Config.Transport); } diff --git a/Platform/Posix/Source/SolidSyslogGetAddrInfoResolver.c b/Platform/Posix/Source/SolidSyslogGetAddrInfoResolver.c index 13422296..77314752 100644 --- a/Platform/Posix/Source/SolidSyslogGetAddrInfoResolver.c +++ b/Platform/Posix/Source/SolidSyslogGetAddrInfoResolver.c @@ -30,20 +30,20 @@ static int GetAddrInfoResolver_MapTransport(enum SolidSyslogTransport transport) struct SolidSyslogGetAddrInfoResolver { - struct SolidSyslogResolver base; + struct SolidSyslogResolver Base; }; static struct SolidSyslogGetAddrInfoResolver instance; struct SolidSyslogResolver* SolidSyslogGetAddrInfoResolver_Create(void) { - instance.base.Resolve = GetAddrInfoResolver_Resolve; - return &instance.base; + instance.Base.Resolve = GetAddrInfoResolver_Resolve; + return &instance.Base; } void SolidSyslogGetAddrInfoResolver_Destroy(void) { - instance.base.Resolve = NULL; + instance.Base.Resolve = NULL; } static bool GetAddrInfoResolver_Resolve( diff --git a/Platform/Posix/Source/SolidSyslogPosixClock.c b/Platform/Posix/Source/SolidSyslogPosixClock.c index 691a15d4..cdd4a858 100644 --- a/Platform/Posix/Source/SolidSyslogPosixClock.c +++ b/Platform/Posix/Source/SolidSyslogPosixClock.c @@ -40,11 +40,11 @@ static inline void PosixClock_PopulateTimestamp( const struct tm* breakdown ) { - timestamp->year = (uint16_t) (breakdown->tm_year + 1900); - timestamp->month = (uint8_t) (breakdown->tm_mon + 1); - timestamp->day = (uint8_t) breakdown->tm_mday; - timestamp->hour = (uint8_t) breakdown->tm_hour; - timestamp->minute = (uint8_t) breakdown->tm_min; - timestamp->second = (uint8_t) breakdown->tm_sec; - timestamp->microsecond = (uint32_t) (now->tv_nsec / 1000); + timestamp->Year = (uint16_t) (breakdown->tm_year + 1900); + timestamp->Month = (uint8_t) (breakdown->tm_mon + 1); + timestamp->Day = (uint8_t) breakdown->tm_mday; + timestamp->Hour = (uint8_t) breakdown->tm_hour; + timestamp->Minute = (uint8_t) breakdown->tm_min; + timestamp->Second = (uint8_t) breakdown->tm_sec; + timestamp->Microsecond = (uint32_t) (now->tv_nsec / 1000); } diff --git a/Platform/Posix/Source/SolidSyslogPosixDatagram.c b/Platform/Posix/Source/SolidSyslogPosixDatagram.c index 21539aad..2e12784a 100644 --- a/Platform/Posix/Source/SolidSyslogPosixDatagram.c +++ b/Platform/Posix/Source/SolidSyslogPosixDatagram.c @@ -22,9 +22,9 @@ enum struct SolidSyslogPosixDatagram { - struct SolidSyslogDatagram base; - int fd; - bool connected; + struct SolidSyslogDatagram Base; + int Fd; + bool Connected; }; static bool PosixDatagram_Open(struct SolidSyslogDatagram* self); @@ -42,31 +42,31 @@ static inline bool PosixDatagram_ConnectIfNeeded( ); static inline bool PosixDatagram_IsFileDescriptorValid(int fd); -static struct SolidSyslogPosixDatagram instance = {.fd = INVALID_FD}; +static struct SolidSyslogPosixDatagram instance = {.Fd = INVALID_FD}; struct SolidSyslogDatagram* SolidSyslogPosixDatagram_Create(void) { - instance.base.Open = PosixDatagram_Open; - instance.base.SendTo = PosixDatagram_SendTo; - instance.base.MaxPayload = PosixDatagram_MaxPayload; - instance.base.Close = PosixDatagram_Close; - return &instance.base; + instance.Base.Open = PosixDatagram_Open; + instance.Base.SendTo = PosixDatagram_SendTo; + instance.Base.MaxPayload = PosixDatagram_MaxPayload; + instance.Base.Close = PosixDatagram_Close; + return &instance.Base; } void SolidSyslogPosixDatagram_Destroy(void) { - instance.base.Open = NULL; - instance.base.SendTo = NULL; - instance.base.MaxPayload = NULL; - instance.base.Close = NULL; + instance.Base.Open = NULL; + instance.Base.SendTo = NULL; + instance.Base.MaxPayload = NULL; + instance.Base.Close = NULL; } static bool PosixDatagram_Open(struct SolidSyslogDatagram* self) { struct SolidSyslogPosixDatagram* datagram = (struct SolidSyslogPosixDatagram*) self; - datagram->fd = socket(AF_INET, SOCK_DGRAM, 0); - datagram->connected = false; - return PosixDatagram_IsFileDescriptorValid(datagram->fd); + datagram->Fd = socket(AF_INET, SOCK_DGRAM, 0); + datagram->Connected = false; + return PosixDatagram_IsFileDescriptorValid(datagram->Fd); } static inline bool PosixDatagram_IsFileDescriptorValid(int fd) @@ -86,7 +86,7 @@ static enum SolidSyslogDatagramSendResult PosixDatagram_SendTo( if (PosixDatagram_ConnectIfNeeded(datagram, addr)) { const struct sockaddr_in* sin = SolidSyslogAddress_AsConstSockaddrIn(addr); - ssize_t sent = sendto(datagram->fd, buffer, size, 0, (const struct sockaddr*) sin, sizeof(*sin)); + ssize_t sent = sendto(datagram->Fd, buffer, size, 0, (const struct sockaddr*) sin, sizeof(*sin)); if (sent >= 0) { result = SolidSyslogDatagramSendResult_Sent; @@ -104,28 +104,28 @@ static inline bool PosixDatagram_ConnectIfNeeded( const struct SolidSyslogAddress* addr ) { - if (!datagram->connected) + if (!datagram->Connected) { const struct sockaddr_in* sin = SolidSyslogAddress_AsConstSockaddrIn(addr); - if (connect(datagram->fd, (const struct sockaddr*) sin, sizeof(*sin)) == 0) + if (connect(datagram->Fd, (const struct sockaddr*) sin, sizeof(*sin)) == 0) { const int pmtu = IP_PMTUDISC_DO; - (void) setsockopt(datagram->fd, IPPROTO_IP, IP_MTU_DISCOVER, &pmtu, sizeof(pmtu)); - datagram->connected = true; + (void) setsockopt(datagram->Fd, IPPROTO_IP, IP_MTU_DISCOVER, &pmtu, sizeof(pmtu)); + datagram->Connected = true; } } - return datagram->connected; + return datagram->Connected; } static size_t PosixDatagram_MaxPayload(struct SolidSyslogDatagram* self) { struct SolidSyslogPosixDatagram* datagram = (struct SolidSyslogPosixDatagram*) self; size_t result = SOLIDSYSLOG_UDP_IPV6_SAFE_PAYLOAD; - if (datagram->connected) + if (datagram->Connected) { int mtu = 0; socklen_t optlen = sizeof(mtu); - if ((getsockopt(datagram->fd, IPPROTO_IP, IP_MTU, &mtu, &optlen) == 0) && (mtu > 0)) + if ((getsockopt(datagram->Fd, IPPROTO_IP, IP_MTU, &mtu, &optlen) == 0) && (mtu > 0)) { result = SolidSyslogUdpPayload_FromMtu((size_t) mtu, false); } @@ -136,10 +136,10 @@ static size_t PosixDatagram_MaxPayload(struct SolidSyslogDatagram* self) static void PosixDatagram_Close(struct SolidSyslogDatagram* self) { struct SolidSyslogPosixDatagram* datagram = (struct SolidSyslogPosixDatagram*) self; - if (PosixDatagram_IsFileDescriptorValid(datagram->fd)) + if (PosixDatagram_IsFileDescriptorValid(datagram->Fd)) { - close(datagram->fd); - datagram->fd = INVALID_FD; - datagram->connected = false; + close(datagram->Fd); + datagram->Fd = INVALID_FD; + datagram->Connected = false; } } diff --git a/Platform/Posix/Source/SolidSyslogPosixFile.c b/Platform/Posix/Source/SolidSyslogPosixFile.c index 3ad7f964..55bd715f 100644 --- a/Platform/Posix/Source/SolidSyslogPosixFile.c +++ b/Platform/Posix/Source/SolidSyslogPosixFile.c @@ -31,8 +31,8 @@ static bool PosixFile_Delete(struct SolidSyslogFile* self, const char* path); struct SolidSyslogPosixFile { - struct SolidSyslogFile base; - int fd; + struct SolidSyslogFile Base; + int Fd; }; SOLIDSYSLOG_STATIC_ASSERT( @@ -63,16 +63,16 @@ struct SolidSyslogFile* SolidSyslogPosixFile_Create(SolidSyslogPosixFileStorage* { struct SolidSyslogPosixFile* posix = (struct SolidSyslogPosixFile*) storage; *posix = DEFAULT_INSTANCE; - return &posix->base; + return &posix->Base; } void SolidSyslogPosixFile_Destroy(struct SolidSyslogFile* file) { struct SolidSyslogPosixFile* posix = (struct SolidSyslogPosixFile*) file; - if (posix->fd != INVALID_FD) + if (posix->Fd != INVALID_FD) { - close(posix->fd); + close(posix->Fd); } *posix = DESTROYED_INSTANCE; @@ -81,56 +81,56 @@ void SolidSyslogPosixFile_Destroy(struct SolidSyslogFile* file) static bool PosixFile_Open(struct SolidSyslogFile* self, const char* path) { struct SolidSyslogPosixFile* posix = (struct SolidSyslogPosixFile*) self; - posix->fd = open(path, O_RDWR | O_CREAT, DEFAULT_FILE_PERMISSIONS); - return posix->fd != INVALID_FD; + posix->Fd = open(path, O_RDWR | O_CREAT, DEFAULT_FILE_PERMISSIONS); + return posix->Fd != INVALID_FD; } static void PosixFile_Close(struct SolidSyslogFile* self) { struct SolidSyslogPosixFile* posix = (struct SolidSyslogPosixFile*) self; - if (posix->fd != INVALID_FD) + if (posix->Fd != INVALID_FD) { - close(posix->fd); - posix->fd = INVALID_FD; + close(posix->Fd); + posix->Fd = INVALID_FD; } } static bool PosixFile_IsOpen(struct SolidSyslogFile* self) { struct SolidSyslogPosixFile* posix = (struct SolidSyslogPosixFile*) self; - return posix->fd != INVALID_FD; + return posix->Fd != INVALID_FD; } static bool PosixFile_Read(struct SolidSyslogFile* self, void* buf, size_t count) { struct SolidSyslogPosixFile* posix = (struct SolidSyslogPosixFile*) self; - return read(posix->fd, buf, count) == (ssize_t) count; + return read(posix->Fd, buf, count) == (ssize_t) count; } static bool PosixFile_Write(struct SolidSyslogFile* self, const void* buf, size_t count) { struct SolidSyslogPosixFile* posix = (struct SolidSyslogPosixFile*) self; - return write(posix->fd, buf, count) == (ssize_t) count; + return write(posix->Fd, buf, count) == (ssize_t) count; } static void PosixFile_SeekTo(struct SolidSyslogFile* self, size_t offset) { struct SolidSyslogPosixFile* posix = (struct SolidSyslogPosixFile*) self; - lseek(posix->fd, (off_t) offset, SEEK_SET); + lseek(posix->Fd, (off_t) offset, SEEK_SET); } static size_t PosixFile_Size(struct SolidSyslogFile* self) { struct SolidSyslogPosixFile* posix = (struct SolidSyslogPosixFile*) self; - off_t size = lseek(posix->fd, 0, SEEK_END); + off_t size = lseek(posix->Fd, 0, SEEK_END); return (size >= 0) ? (size_t) size : 0; } static void PosixFile_Truncate(struct SolidSyslogFile* self) { struct SolidSyslogPosixFile* posix = (struct SolidSyslogPosixFile*) self; - ftruncate(posix->fd, 0); + ftruncate(posix->Fd, 0); } static bool PosixFile_Exists(struct SolidSyslogFile* self, const char* path) diff --git a/Platform/Posix/Source/SolidSyslogPosixMessageQueueBuffer.c b/Platform/Posix/Source/SolidSyslogPosixMessageQueueBuffer.c index 34d5c3f2..c3e93484 100644 --- a/Platform/Posix/Source/SolidSyslogPosixMessageQueueBuffer.c +++ b/Platform/Posix/Source/SolidSyslogPosixMessageQueueBuffer.c @@ -21,17 +21,17 @@ static void PosixMessageQueueBuffer_Write(struct SolidSyslogBuffer* self, const struct SolidSyslogPosixMessageQueueBuffer { - struct SolidSyslogBuffer base; - mqd_t mq; - SolidSyslogFormatterStorage nameStorage[SOLIDSYSLOG_FORMATTER_STORAGE_SIZE(MAX_NAME_SIZE)]; - size_t maxMessageSize; + struct SolidSyslogBuffer Base; + mqd_t Mq; + SolidSyslogFormatterStorage NameStorage[SOLIDSYSLOG_FORMATTER_STORAGE_SIZE(MAX_NAME_SIZE)]; + size_t MaxMessageSize; }; static struct SolidSyslogPosixMessageQueueBuffer instance; static inline const char* PosixMessageQueueBuffer_QueueName(void) { - return SolidSyslogFormatter_AsFormattedBuffer(SolidSyslogFormatter_FromStorage(instance.nameStorage)); + return SolidSyslogFormatter_AsFormattedBuffer(SolidSyslogFormatter_FromStorage(instance.NameStorage)); } // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) -- distinct semantic meaning; struct wrapper would over-engineer @@ -39,7 +39,7 @@ struct SolidSyslogBuffer* SolidSyslogPosixMessageQueueBuffer_Create(size_t maxMe { instance = (struct SolidSyslogPosixMessageQueueBuffer) {0}; - struct SolidSyslogFormatter* name = SolidSyslogFormatter_Create(instance.nameStorage, MAX_NAME_SIZE); + struct SolidSyslogFormatter* name = SolidSyslogFormatter_Create(instance.NameStorage, MAX_NAME_SIZE); SolidSyslogFormatter_BoundedString(name, QUEUE_NAME_PREFIX, sizeof(QUEUE_NAME_PREFIX) - 1); SolidSyslogPosixProcessId_Get(name); @@ -47,17 +47,17 @@ struct SolidSyslogBuffer* SolidSyslogPosixMessageQueueBuffer_Create(size_t maxMe attr.mq_maxmsg = maxMessages; attr.mq_msgsize = (long) maxMessageSize; - instance.mq = mq_open(PosixMessageQueueBuffer_QueueName(), O_CREAT | O_RDWR | O_NONBLOCK, 0600, &attr); - instance.maxMessageSize = maxMessageSize; - instance.base.Write = PosixMessageQueueBuffer_Write; - instance.base.Read = PosixMessageQueueBuffer_Read; + instance.Mq = mq_open(PosixMessageQueueBuffer_QueueName(), O_CREAT | O_RDWR | O_NONBLOCK, 0600, &attr); + instance.MaxMessageSize = maxMessageSize; + instance.Base.Write = PosixMessageQueueBuffer_Write; + instance.Base.Read = PosixMessageQueueBuffer_Read; - return &instance.base; + return &instance.Base; } void SolidSyslogPosixMessageQueueBuffer_Destroy(void) { - mq_close(instance.mq); + mq_close(instance.Mq); mq_unlink(PosixMessageQueueBuffer_QueueName()); instance = (struct SolidSyslogPosixMessageQueueBuffer) {0}; } @@ -65,7 +65,7 @@ void SolidSyslogPosixMessageQueueBuffer_Destroy(void) static bool PosixMessageQueueBuffer_Read(struct SolidSyslogBuffer* self, void* data, size_t maxSize, size_t* bytesRead) { struct SolidSyslogPosixMessageQueueBuffer* mqBuffer = (struct SolidSyslogPosixMessageQueueBuffer*) self; - ssize_t received = mq_receive(mqBuffer->mq, data, maxSize, NULL); + ssize_t received = mq_receive(mqBuffer->Mq, data, maxSize, NULL); bool success = received >= 0; *bytesRead = success ? (size_t) received : 0; @@ -76,5 +76,5 @@ static bool PosixMessageQueueBuffer_Read(struct SolidSyslogBuffer* self, void* d static void PosixMessageQueueBuffer_Write(struct SolidSyslogBuffer* self, const void* data, size_t size) { struct SolidSyslogPosixMessageQueueBuffer* mqBuffer = (struct SolidSyslogPosixMessageQueueBuffer*) self; - mq_send(mqBuffer->mq, data, size, 0); + mq_send(mqBuffer->Mq, data, size, 0); } diff --git a/Platform/Posix/Source/SolidSyslogPosixMutex.c b/Platform/Posix/Source/SolidSyslogPosixMutex.c index 4c2a5754..996e0905 100644 --- a/Platform/Posix/Source/SolidSyslogPosixMutex.c +++ b/Platform/Posix/Source/SolidSyslogPosixMutex.c @@ -8,8 +8,8 @@ struct SolidSyslogPosixMutex { - struct SolidSyslogMutex base; - pthread_mutex_t mutex; + struct SolidSyslogMutex Base; + pthread_mutex_t Mutex; }; SOLIDSYSLOG_STATIC_ASSERT( @@ -23,28 +23,28 @@ static void PosixMutex_Unlock(struct SolidSyslogMutex* self); struct SolidSyslogMutex* SolidSyslogPosixMutex_Create(SolidSyslogPosixMutexStorage* storage) { struct SolidSyslogPosixMutex* posix = (struct SolidSyslogPosixMutex*) storage; - posix->base.Lock = PosixMutex_Lock; - posix->base.Unlock = PosixMutex_Unlock; - pthread_mutex_init(&posix->mutex, NULL); - return &posix->base; + posix->Base.Lock = PosixMutex_Lock; + posix->Base.Unlock = PosixMutex_Unlock; + pthread_mutex_init(&posix->Mutex, NULL); + return &posix->Base; } void SolidSyslogPosixMutex_Destroy(struct SolidSyslogMutex* mutex) { struct SolidSyslogPosixMutex* posix = (struct SolidSyslogPosixMutex*) mutex; - pthread_mutex_destroy(&posix->mutex); - posix->base.Lock = NULL; - posix->base.Unlock = NULL; + pthread_mutex_destroy(&posix->Mutex); + posix->Base.Lock = NULL; + posix->Base.Unlock = NULL; } static void PosixMutex_Lock(struct SolidSyslogMutex* self) { struct SolidSyslogPosixMutex* posix = (struct SolidSyslogPosixMutex*) self; - pthread_mutex_lock(&posix->mutex); + pthread_mutex_lock(&posix->Mutex); } static void PosixMutex_Unlock(struct SolidSyslogMutex* self) { struct SolidSyslogPosixMutex* posix = (struct SolidSyslogPosixMutex*) self; - pthread_mutex_unlock(&posix->mutex); + pthread_mutex_unlock(&posix->Mutex); } diff --git a/Platform/Posix/Source/SolidSyslogPosixTcpStream.c b/Platform/Posix/Source/SolidSyslogPosixTcpStream.c index c0336d34..f737cac4 100644 --- a/Platform/Posix/Source/SolidSyslogPosixTcpStream.c +++ b/Platform/Posix/Source/SolidSyslogPosixTcpStream.c @@ -38,8 +38,8 @@ enum struct SolidSyslogPosixTcpStream { - struct SolidSyslogStream base; - int fd; + struct SolidSyslogStream Base; + int Fd; }; static bool PosixTcpStream_Open(struct SolidSyslogStream* self, const struct SolidSyslogAddress* addr); @@ -82,7 +82,7 @@ struct SolidSyslogStream* SolidSyslogPosixTcpStream_Create(SolidSyslogPosixTcpSt { struct SolidSyslogPosixTcpStream* stream = (struct SolidSyslogPosixTcpStream*) storage; *stream = DEFAULT_INSTANCE; - return &stream->base; + return &stream->Base; } void SolidSyslogPosixTcpStream_Destroy(struct SolidSyslogStream* stream) @@ -98,8 +98,8 @@ static bool PosixTcpStream_Open(struct SolidSyslogStream* self, const struct Sol const struct sockaddr_in* sin = SolidSyslogAddress_AsConstSockaddrIn(addr); bool connected = false; - stream->fd = PosixTcpStream_OpenAndConfigureSocket(); - if (PosixTcpStream_IsFileDescriptorValid(stream->fd)) + stream->Fd = PosixTcpStream_OpenAndConfigureSocket(); + if (PosixTcpStream_IsFileDescriptorValid(stream->Fd)) { connected = PosixTcpStream_ConnectOrCloseOnFailure(stream, sin); } @@ -169,11 +169,11 @@ static bool PosixTcpStream_ConnectOrCloseOnFailure( const struct sockaddr_in* sin ) { - bool connected = PosixTcpStream_Connect(stream->fd, sin); + bool connected = PosixTcpStream_Connect(stream->Fd, sin); if (!connected) { - close(stream->fd); - stream->fd = INVALID_FD; + close(stream->Fd); + stream->Fd = INVALID_FD; } return connected; } @@ -227,7 +227,7 @@ static bool PosixTcpStream_ReadDeferredConnectError(int fd) static bool PosixTcpStream_Send(struct SolidSyslogStream* self, const void* buffer, size_t size) { struct SolidSyslogPosixTcpStream* stream = (struct SolidSyslogPosixTcpStream*) self; - ssize_t sent = send(stream->fd, buffer, size, MSG_NOSIGNAL); + ssize_t sent = send(stream->Fd, buffer, size, MSG_NOSIGNAL); bool ok = PosixTcpStream_WroteAllBytes(sent, size); if (!ok) @@ -247,7 +247,7 @@ static bool PosixTcpStream_WroteAllBytes(ssize_t sent, size_t expected) static SolidSyslogSsize PosixTcpStream_Read(struct SolidSyslogStream* self, void* buffer, size_t size) { struct SolidSyslogPosixTcpStream* stream = (struct SolidSyslogPosixTcpStream*) self; - ssize_t n = recv(stream->fd, buffer, size, 0); + ssize_t n = recv(stream->Fd, buffer, size, 0); SolidSyslogSsize result = -1; if (n > 0) @@ -273,9 +273,9 @@ static inline bool PosixTcpStream_WouldBlock(void) static void PosixTcpStream_Close(struct SolidSyslogStream* self) { struct SolidSyslogPosixTcpStream* stream = (struct SolidSyslogPosixTcpStream*) self; - if (PosixTcpStream_IsFileDescriptorValid(stream->fd)) + if (PosixTcpStream_IsFileDescriptorValid(stream->Fd)) { - close(stream->fd); - stream->fd = INVALID_FD; + close(stream->Fd); + stream->Fd = INVALID_FD; } } diff --git a/Platform/Windows/Source/SolidSyslogWindowsAtomicU32.c b/Platform/Windows/Source/SolidSyslogWindowsAtomicU32.c index 7a9de7b6..a20266c8 100644 --- a/Platform/Windows/Source/SolidSyslogWindowsAtomicU32.c +++ b/Platform/Windows/Source/SolidSyslogWindowsAtomicU32.c @@ -8,7 +8,7 @@ struct SolidSyslogAtomicU32 { - volatile LONG value; + volatile LONG Value; }; SOLIDSYSLOG_STATIC_ASSERT( @@ -28,17 +28,17 @@ struct SolidSyslogAtomicU32* SolidSyslogAtomicU32_FromStorage(SolidSyslogAtomicU void SolidSyslogAtomicU32_Init(struct SolidSyslogAtomicU32* slot, uint32_t value) { - slot->value = (LONG) value; + slot->Value = (LONG) value; } uint32_t SolidSyslogAtomicU32_Load(struct SolidSyslogAtomicU32* slot) { - return (uint32_t) InterlockedCompareExchange(&slot->value, 0, 0); + return (uint32_t) InterlockedCompareExchange(&slot->Value, 0, 0); } // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) — CAS shape is universal (compare_exchange convention) bool SolidSyslogAtomicU32_CompareAndSwap(struct SolidSyslogAtomicU32* slot, uint32_t expected, uint32_t desired) { - LONG actual = InterlockedCompareExchange(&slot->value, (LONG) desired, (LONG) expected); + LONG actual = InterlockedCompareExchange(&slot->Value, (LONG) desired, (LONG) expected); return (LONG) expected == actual; } diff --git a/Platform/Windows/Source/SolidSyslogWindowsClock.c b/Platform/Windows/Source/SolidSyslogWindowsClock.c index 26611010..f4faef57 100644 --- a/Platform/Windows/Source/SolidSyslogWindowsClock.c +++ b/Platform/Windows/Source/SolidSyslogWindowsClock.c @@ -63,11 +63,11 @@ static inline void WindowsClock_PopulateTimestamp( uint32_t microseconds ) { - timestamp->year = breakdown->wYear; - timestamp->month = (uint8_t) breakdown->wMonth; - timestamp->day = (uint8_t) breakdown->wDay; - timestamp->hour = (uint8_t) breakdown->wHour; - timestamp->minute = (uint8_t) breakdown->wMinute; - timestamp->second = (uint8_t) breakdown->wSecond; - timestamp->microsecond = microseconds; + timestamp->Year = breakdown->wYear; + timestamp->Month = (uint8_t) breakdown->wMonth; + timestamp->Day = (uint8_t) breakdown->wDay; + timestamp->Hour = (uint8_t) breakdown->wHour; + timestamp->Minute = (uint8_t) breakdown->wMinute; + timestamp->Second = (uint8_t) breakdown->wSecond; + timestamp->Microsecond = microseconds; } diff --git a/Platform/Windows/Source/SolidSyslogWindowsFile.c b/Platform/Windows/Source/SolidSyslogWindowsFile.c index 47e9483c..cbbd2f6f 100644 --- a/Platform/Windows/Source/SolidSyslogWindowsFile.c +++ b/Platform/Windows/Source/SolidSyslogWindowsFile.c @@ -35,8 +35,8 @@ static bool WindowsFile_Delete(struct SolidSyslogFile* self, const char* path); struct SolidSyslogWindowsFile { - struct SolidSyslogFile base; - int fd; + struct SolidSyslogFile Base; + int Fd; }; SOLIDSYSLOG_STATIC_ASSERT( @@ -67,16 +67,16 @@ struct SolidSyslogFile* SolidSyslogWindowsFile_Create(SolidSyslogWindowsFileStor { struct SolidSyslogWindowsFile* windows = (struct SolidSyslogWindowsFile*) storage; *windows = DEFAULT_INSTANCE; - return &windows->base; + return &windows->Base; } void SolidSyslogWindowsFile_Destroy(struct SolidSyslogFile* file) { struct SolidSyslogWindowsFile* windows = (struct SolidSyslogWindowsFile*) file; - if (windows->fd != INVALID_FD) + if (windows->Fd != INVALID_FD) { - _close(windows->fd); + _close(windows->Fd); } *windows = DESTROYED_INSTANCE; @@ -89,60 +89,60 @@ static bool WindowsFile_Open(struct SolidSyslogFile* self, const char* path) * _CRT_SECURE_NO_WARNINGS is forbidden by the project's banned-API * policy. _SH_DENYNO matches POSIX open()'s default of no share mode. */ struct SolidSyslogWindowsFile* windows = (struct SolidSyslogWindowsFile*) self; - errno_t err = _sopen_s(&windows->fd, path, DEFAULT_OPEN_FLAGS, _SH_DENYNO, DEFAULT_FILE_PERMISSIONS); + errno_t err = _sopen_s(&windows->Fd, path, DEFAULT_OPEN_FLAGS, _SH_DENYNO, DEFAULT_FILE_PERMISSIONS); if (err != 0) { - windows->fd = INVALID_FD; + windows->Fd = INVALID_FD; } - return windows->fd != INVALID_FD; + return windows->Fd != INVALID_FD; } static void WindowsFile_Close(struct SolidSyslogFile* self) { struct SolidSyslogWindowsFile* windows = (struct SolidSyslogWindowsFile*) self; - if (windows->fd != INVALID_FD) + if (windows->Fd != INVALID_FD) { - _close(windows->fd); - windows->fd = INVALID_FD; + _close(windows->Fd); + windows->Fd = INVALID_FD; } } static bool WindowsFile_IsOpen(struct SolidSyslogFile* self) { struct SolidSyslogWindowsFile* windows = (struct SolidSyslogWindowsFile*) self; - return windows->fd != INVALID_FD; + return windows->Fd != INVALID_FD; } static bool WindowsFile_Read(struct SolidSyslogFile* self, void* buf, size_t count) { struct SolidSyslogWindowsFile* windows = (struct SolidSyslogWindowsFile*) self; - return _read(windows->fd, buf, (unsigned int) count) == (int) count; + return _read(windows->Fd, buf, (unsigned int) count) == (int) count; } static bool WindowsFile_Write(struct SolidSyslogFile* self, const void* buf, size_t count) { struct SolidSyslogWindowsFile* windows = (struct SolidSyslogWindowsFile*) self; - return _write(windows->fd, buf, (unsigned int) count) == (int) count; + return _write(windows->Fd, buf, (unsigned int) count) == (int) count; } static void WindowsFile_SeekTo(struct SolidSyslogFile* self, size_t offset) { struct SolidSyslogWindowsFile* windows = (struct SolidSyslogWindowsFile*) self; - _lseeki64(windows->fd, (__int64) offset, SEEK_SET); + _lseeki64(windows->Fd, (__int64) offset, SEEK_SET); } static size_t WindowsFile_Size(struct SolidSyslogFile* self) { struct SolidSyslogWindowsFile* windows = (struct SolidSyslogWindowsFile*) self; - __int64 size = _lseeki64(windows->fd, 0, SEEK_END); + __int64 size = _lseeki64(windows->Fd, 0, SEEK_END); return (size >= 0) ? (size_t) size : 0; } static void WindowsFile_Truncate(struct SolidSyslogFile* self) { struct SolidSyslogWindowsFile* windows = (struct SolidSyslogWindowsFile*) self; - _chsize_s(windows->fd, 0); + _chsize_s(windows->Fd, 0); } static bool WindowsFile_Exists(struct SolidSyslogFile* self, const char* path) diff --git a/Platform/Windows/Source/SolidSyslogWindowsMutex.c b/Platform/Windows/Source/SolidSyslogWindowsMutex.c index 8114bd81..f7a5d362 100644 --- a/Platform/Windows/Source/SolidSyslogWindowsMutex.c +++ b/Platform/Windows/Source/SolidSyslogWindowsMutex.c @@ -8,8 +8,8 @@ struct SolidSyslogWindowsMutex { - struct SolidSyslogMutex base; - CRITICAL_SECTION section; + struct SolidSyslogMutex Base; + CRITICAL_SECTION Section; }; SOLIDSYSLOG_STATIC_ASSERT( @@ -23,28 +23,28 @@ static void WindowsMutex_Unlock(struct SolidSyslogMutex* self); struct SolidSyslogMutex* SolidSyslogWindowsMutex_Create(SolidSyslogWindowsMutexStorage* storage) { struct SolidSyslogWindowsMutex* windows = (struct SolidSyslogWindowsMutex*) storage; - windows->base.Lock = WindowsMutex_Lock; - windows->base.Unlock = WindowsMutex_Unlock; - InitializeCriticalSection(&windows->section); - return &windows->base; + windows->Base.Lock = WindowsMutex_Lock; + windows->Base.Unlock = WindowsMutex_Unlock; + InitializeCriticalSection(&windows->Section); + return &windows->Base; } void SolidSyslogWindowsMutex_Destroy(struct SolidSyslogMutex* mutex) { struct SolidSyslogWindowsMutex* windows = (struct SolidSyslogWindowsMutex*) mutex; - DeleteCriticalSection(&windows->section); - windows->base.Lock = NULL; - windows->base.Unlock = NULL; + DeleteCriticalSection(&windows->Section); + windows->Base.Lock = NULL; + windows->Base.Unlock = NULL; } static void WindowsMutex_Lock(struct SolidSyslogMutex* self) { struct SolidSyslogWindowsMutex* windows = (struct SolidSyslogWindowsMutex*) self; - EnterCriticalSection(&windows->section); + EnterCriticalSection(&windows->Section); } static void WindowsMutex_Unlock(struct SolidSyslogMutex* self) { struct SolidSyslogWindowsMutex* windows = (struct SolidSyslogWindowsMutex*) self; - LeaveCriticalSection(&windows->section); + LeaveCriticalSection(&windows->Section); } diff --git a/Platform/Windows/Source/SolidSyslogWinsockDatagram.c b/Platform/Windows/Source/SolidSyslogWinsockDatagram.c index 5efcb783..66bc9b07 100644 --- a/Platform/Windows/Source/SolidSyslogWinsockDatagram.c +++ b/Platform/Windows/Source/SolidSyslogWinsockDatagram.c @@ -60,9 +60,9 @@ static int WSAAPI WinsockDatagram_CallGetSockOpt(SOCKET s, int level, int optnam struct SolidSyslogWinsockDatagram { - struct SolidSyslogDatagram base; - SOCKET fd; - bool connected; + struct SolidSyslogDatagram Base; + SOCKET Fd; + bool Connected; }; static bool WinsockDatagram_Open(struct SolidSyslogDatagram* self); @@ -80,31 +80,31 @@ static inline bool WinsockDatagram_ConnectIfNeeded( ); static inline bool WinsockDatagram_IsSocketValid(SOCKET fd); -static struct SolidSyslogWinsockDatagram instance = {.fd = INVALID_SOCKET}; +static struct SolidSyslogWinsockDatagram instance = {.Fd = INVALID_SOCKET}; struct SolidSyslogDatagram* SolidSyslogWinsockDatagram_Create(void) { - instance.base.Open = WinsockDatagram_Open; - instance.base.SendTo = WinsockDatagram_SendTo; - instance.base.MaxPayload = WinsockDatagram_MaxPayload; - instance.base.Close = WinsockDatagram_Close; - return &instance.base; + instance.Base.Open = WinsockDatagram_Open; + instance.Base.SendTo = WinsockDatagram_SendTo; + instance.Base.MaxPayload = WinsockDatagram_MaxPayload; + instance.Base.Close = WinsockDatagram_Close; + return &instance.Base; } void SolidSyslogWinsockDatagram_Destroy(void) { - instance.base.Open = NULL; - instance.base.SendTo = NULL; - instance.base.MaxPayload = NULL; - instance.base.Close = NULL; + instance.Base.Open = NULL; + instance.Base.SendTo = NULL; + instance.Base.MaxPayload = NULL; + instance.Base.Close = NULL; } static bool WinsockDatagram_Open(struct SolidSyslogDatagram* self) { struct SolidSyslogWinsockDatagram* datagram = (struct SolidSyslogWinsockDatagram*) self; - datagram->fd = Winsock_socket(AF_INET, SOCK_DGRAM, 0); - datagram->connected = false; - return WinsockDatagram_IsSocketValid(datagram->fd); + datagram->Fd = Winsock_socket(AF_INET, SOCK_DGRAM, 0); + datagram->Connected = false; + return WinsockDatagram_IsSocketValid(datagram->Fd); } static inline bool WinsockDatagram_IsSocketValid(SOCKET fd) @@ -125,7 +125,7 @@ static enum SolidSyslogDatagramSendResult WinsockDatagram_SendTo( { const struct sockaddr_in* sin = SolidSyslogAddress_AsConstSockaddrIn(addr); int sent = Winsock_sendto( - datagram->fd, + datagram->Fd, (const char*) buffer, (int) size, 0, @@ -149,29 +149,29 @@ static inline bool WinsockDatagram_ConnectIfNeeded( const struct SolidSyslogAddress* addr ) { - if (!datagram->connected) + if (!datagram->Connected) { const struct sockaddr_in* sin = SolidSyslogAddress_AsConstSockaddrIn(addr); - if (Winsock_connect(datagram->fd, (const struct sockaddr*) sin, (int) sizeof(*sin)) != SOCKET_ERROR) + if (Winsock_connect(datagram->Fd, (const struct sockaddr*) sin, (int) sizeof(*sin)) != SOCKET_ERROR) { const int pmtu = IP_PMTUDISC_DO; (void - ) Winsock_setsockopt(datagram->fd, IPPROTO_IP, IP_MTU_DISCOVER, (const char*) &pmtu, (int) sizeof(pmtu)); - datagram->connected = true; + ) Winsock_setsockopt(datagram->Fd, IPPROTO_IP, IP_MTU_DISCOVER, (const char*) &pmtu, (int) sizeof(pmtu)); + datagram->Connected = true; } } - return datagram->connected; + return datagram->Connected; } static size_t WinsockDatagram_MaxPayload(struct SolidSyslogDatagram* self) { struct SolidSyslogWinsockDatagram* datagram = (struct SolidSyslogWinsockDatagram*) self; size_t result = SOLIDSYSLOG_UDP_IPV6_SAFE_PAYLOAD; - if (datagram->connected) + if (datagram->Connected) { int mtu = 0; int optlen = (int) sizeof(mtu); - if ((Winsock_getsockopt(datagram->fd, IPPROTO_IP, IP_MTU, (char*) &mtu, &optlen) != SOCKET_ERROR) && (mtu > 0)) + if ((Winsock_getsockopt(datagram->Fd, IPPROTO_IP, IP_MTU, (char*) &mtu, &optlen) != SOCKET_ERROR) && (mtu > 0)) { result = SolidSyslogUdpPayload_FromMtu((size_t) mtu, false); } @@ -182,10 +182,10 @@ static size_t WinsockDatagram_MaxPayload(struct SolidSyslogDatagram* self) static void WinsockDatagram_Close(struct SolidSyslogDatagram* self) { struct SolidSyslogWinsockDatagram* datagram = (struct SolidSyslogWinsockDatagram*) self; - if (WinsockDatagram_IsSocketValid(datagram->fd)) + if (WinsockDatagram_IsSocketValid(datagram->Fd)) { - Winsock_closesocket(datagram->fd); - datagram->fd = INVALID_SOCKET; - datagram->connected = false; + Winsock_closesocket(datagram->Fd); + datagram->Fd = INVALID_SOCKET; + datagram->Connected = false; } } diff --git a/Platform/Windows/Source/SolidSyslogWinsockResolver.c b/Platform/Windows/Source/SolidSyslogWinsockResolver.c index c17e1646..e75d54f6 100644 --- a/Platform/Windows/Source/SolidSyslogWinsockResolver.c +++ b/Platform/Windows/Source/SolidSyslogWinsockResolver.c @@ -45,20 +45,20 @@ static int WinsockResolver_MapTransport(enum SolidSyslogTransport transport); struct SolidSyslogWinsockResolver { - struct SolidSyslogResolver base; + struct SolidSyslogResolver Base; }; static struct SolidSyslogWinsockResolver instance; struct SolidSyslogResolver* SolidSyslogWinsockResolver_Create(void) { - instance.base.Resolve = WinsockResolver_Resolve; - return &instance.base; + instance.Base.Resolve = WinsockResolver_Resolve; + return &instance.Base; } void SolidSyslogWinsockResolver_Destroy(void) { - instance.base.Resolve = NULL; + instance.Base.Resolve = NULL; } static bool WinsockResolver_Resolve( diff --git a/Platform/Windows/Source/SolidSyslogWinsockTcpStream.c b/Platform/Windows/Source/SolidSyslogWinsockTcpStream.c index 2633c33c..467044c4 100644 --- a/Platform/Windows/Source/SolidSyslogWinsockTcpStream.c +++ b/Platform/Windows/Source/SolidSyslogWinsockTcpStream.c @@ -115,8 +115,8 @@ enum struct SolidSyslogWinsockTcpStream { - struct SolidSyslogStream base; - SOCKET fd; + struct SolidSyslogStream Base; + SOCKET Fd; }; static bool WinsockTcpStream_Open(struct SolidSyslogStream* self, const struct SolidSyslogAddress* addr); @@ -159,7 +159,7 @@ struct SolidSyslogStream* SolidSyslogWinsockTcpStream_Create(SolidSyslogWinsockT { struct SolidSyslogWinsockTcpStream* stream = (struct SolidSyslogWinsockTcpStream*) storage; *stream = DEFAULT_INSTANCE; - return &stream->base; + return &stream->Base; } void SolidSyslogWinsockTcpStream_Destroy(struct SolidSyslogStream* stream) @@ -175,8 +175,8 @@ static bool WinsockTcpStream_Open(struct SolidSyslogStream* self, const struct S const struct sockaddr_in* sin = SolidSyslogAddress_AsConstSockaddrIn(addr); bool connected = false; - stream->fd = WinsockTcpStream_OpenAndConfigureSocket(); - if (WinsockTcpStream_IsSocketValid(stream->fd)) + stream->Fd = WinsockTcpStream_OpenAndConfigureSocket(); + if (WinsockTcpStream_IsSocketValid(stream->Fd)) { connected = WinsockTcpStream_ConnectOrCloseOnFailure(stream, sin); } @@ -236,11 +236,11 @@ static bool WinsockTcpStream_ConnectOrCloseOnFailure( const struct sockaddr_in* sin ) { - bool connected = WinsockTcpStream_Connect(stream->fd, sin); + bool connected = WinsockTcpStream_Connect(stream->Fd, sin); if (!connected) { - WinsockTcpStream_closesocket(stream->fd); - stream->fd = INVALID_SOCKET; + WinsockTcpStream_closesocket(stream->Fd); + stream->Fd = INVALID_SOCKET; } return connected; } @@ -306,7 +306,7 @@ static bool WinsockTcpStream_ReadDeferredConnectError(SOCKET fd) static bool WinsockTcpStream_Send(struct SolidSyslogStream* self, const void* buffer, size_t size) { struct SolidSyslogWinsockTcpStream* stream = (struct SolidSyslogWinsockTcpStream*) self; - int sent = WinsockTcpStream_send(stream->fd, (const char*) buffer, (int) size, 0); + int sent = WinsockTcpStream_send(stream->Fd, (const char*) buffer, (int) size, 0); bool ok = WinsockTcpStream_WroteAllBytes(sent, size); if (!ok) @@ -326,7 +326,7 @@ static bool WinsockTcpStream_WroteAllBytes(int sent, size_t expected) static SolidSyslogSsize WinsockTcpStream_Read(struct SolidSyslogStream* self, void* buffer, size_t size) { struct SolidSyslogWinsockTcpStream* stream = (struct SolidSyslogWinsockTcpStream*) self; - int n = WinsockTcpStream_recv(stream->fd, (char*) buffer, (int) size, 0); + int n = WinsockTcpStream_recv(stream->Fd, (char*) buffer, (int) size, 0); SolidSyslogSsize result = -1; if (n > 0) @@ -352,9 +352,9 @@ static inline bool WinsockTcpStream_WouldBlock(int wsaError) static void WinsockTcpStream_Close(struct SolidSyslogStream* self) { struct SolidSyslogWinsockTcpStream* stream = (struct SolidSyslogWinsockTcpStream*) self; - if (WinsockTcpStream_IsSocketValid(stream->fd)) + if (WinsockTcpStream_IsSocketValid(stream->Fd)) { - WinsockTcpStream_closesocket(stream->fd); - stream->fd = INVALID_SOCKET; + WinsockTcpStream_closesocket(stream->Fd); + stream->Fd = INVALID_SOCKET; } } diff --git a/Tests/Bdd/Targets/BddTargetCommandLineTest.cpp b/Tests/Bdd/Targets/BddTargetCommandLineTest.cpp index c307ccc5..c39025d2 100644 --- a/Tests/Bdd/Targets/BddTargetCommandLineTest.cpp +++ b/Tests/Bdd/Targets/BddTargetCommandLineTest.cpp @@ -26,7 +26,7 @@ TEST(BddTargetCommandLine, DefaultMaxBlocks) char arg0[] = "test"; char* argv[] = {arg0, nullptr}; Parse(1, argv); - LONGS_EQUAL(10, options.maxBlocks); + LONGS_EQUAL(10, options.MaxBlocks); } TEST(BddTargetCommandLine, DefaultMaxBlockSize) @@ -34,7 +34,7 @@ TEST(BddTargetCommandLine, DefaultMaxBlockSize) char arg0[] = "test"; char* argv[] = {arg0, nullptr}; Parse(1, argv); - LONGS_EQUAL(65536, options.maxBlockSize); + LONGS_EQUAL(65536, options.MaxBlockSize); } TEST(BddTargetCommandLine, DefaultDiscardPolicy) @@ -42,7 +42,7 @@ TEST(BddTargetCommandLine, DefaultDiscardPolicy) char arg0[] = "test"; char* argv[] = {arg0, nullptr}; Parse(1, argv); - STRCMP_EQUAL("oldest", options.discardPolicy); + STRCMP_EQUAL("oldest", options.DiscardPolicy); } TEST(BddTargetCommandLine, DefaultNoSd) @@ -50,7 +50,7 @@ TEST(BddTargetCommandLine, DefaultNoSd) char arg0[] = "test"; char* argv[] = {arg0, nullptr}; Parse(1, argv); - CHECK_FALSE(options.noSd); + CHECK_FALSE(options.NoSd); } TEST(BddTargetCommandLine, MaxBlocksFlag) @@ -60,7 +60,7 @@ TEST(BddTargetCommandLine, MaxBlocksFlag) char arg2[] = "5"; char* argv[] = {arg0, arg1, arg2, nullptr}; LONGS_EQUAL(0, Parse(3, argv)); - LONGS_EQUAL(5, options.maxBlocks); + LONGS_EQUAL(5, options.MaxBlocks); } TEST(BddTargetCommandLine, MaxBlockSizeFlag) @@ -70,7 +70,7 @@ TEST(BddTargetCommandLine, MaxBlockSizeFlag) char arg2[] = "1024"; char* argv[] = {arg0, arg1, arg2, nullptr}; LONGS_EQUAL(0, Parse(3, argv)); - LONGS_EQUAL(1024, options.maxBlockSize); + LONGS_EQUAL(1024, options.MaxBlockSize); } TEST(BddTargetCommandLine, DiscardPolicyOldest) @@ -80,7 +80,7 @@ TEST(BddTargetCommandLine, DiscardPolicyOldest) char arg2[] = "oldest"; char* argv[] = {arg0, arg1, arg2, nullptr}; LONGS_EQUAL(0, Parse(3, argv)); - STRCMP_EQUAL("oldest", options.discardPolicy); + STRCMP_EQUAL("oldest", options.DiscardPolicy); } TEST(BddTargetCommandLine, DiscardPolicyNewest) @@ -90,7 +90,7 @@ TEST(BddTargetCommandLine, DiscardPolicyNewest) char arg2[] = "newest"; char* argv[] = {arg0, arg1, arg2, nullptr}; LONGS_EQUAL(0, Parse(3, argv)); - STRCMP_EQUAL("newest", options.discardPolicy); + STRCMP_EQUAL("newest", options.DiscardPolicy); } TEST(BddTargetCommandLine, DiscardPolicyHalt) @@ -100,7 +100,7 @@ TEST(BddTargetCommandLine, DiscardPolicyHalt) char arg2[] = "halt"; char* argv[] = {arg0, arg1, arg2, nullptr}; LONGS_EQUAL(0, Parse(3, argv)); - STRCMP_EQUAL("halt", options.discardPolicy); + STRCMP_EQUAL("halt", options.DiscardPolicy); } TEST(BddTargetCommandLine, InvalidDiscardPolicyReturnsOne) @@ -173,7 +173,7 @@ TEST(BddTargetCommandLine, TransportTlsAccepted) char argVal[] = "tls"; char* argv[] = {arg0, argFlag, argVal, nullptr}; LONGS_EQUAL(0, Parse(3, argv)); - STRCMP_EQUAL("tls", options.transport); + STRCMP_EQUAL("tls", options.Transport); } TEST(BddTargetCommandLine, NoSdFlag) @@ -182,7 +182,7 @@ TEST(BddTargetCommandLine, NoSdFlag) char arg1[] = "--no-sd"; char* argv[] = {arg0, arg1, nullptr}; LONGS_EQUAL(0, Parse(2, argv)); - CHECK_TRUE(options.noSd); + CHECK_TRUE(options.NoSd); } TEST(BddTargetCommandLine, DefaultAppNameIsNull) @@ -190,7 +190,7 @@ TEST(BddTargetCommandLine, DefaultAppNameIsNull) char arg0[] = "test"; char* argv[] = {arg0, nullptr}; LONGS_EQUAL(0, Parse(1, argv)); - POINTERS_EQUAL(nullptr, options.appName); + POINTERS_EQUAL(nullptr, options.AppName); } TEST(BddTargetCommandLine, AppNameFlagSetsAppName) @@ -200,5 +200,5 @@ TEST(BddTargetCommandLine, AppNameFlagSetsAppName) char arg2[] = "SolidSyslogThreadedExample"; char* argv[] = {arg0, arg1, arg2, nullptr}; LONGS_EQUAL(0, Parse(3, argv)); - STRCMP_EQUAL("SolidSyslogThreadedExample", options.appName); + STRCMP_EQUAL("SolidSyslogThreadedExample", options.AppName); } diff --git a/Tests/Bdd/Targets/BddTargetServiceThreadTest.cpp b/Tests/Bdd/Targets/BddTargetServiceThreadTest.cpp index 1573ab23..19affffd 100644 --- a/Tests/Bdd/Targets/BddTargetServiceThreadTest.cpp +++ b/Tests/Bdd/Targets/BddTargetServiceThreadTest.cpp @@ -37,8 +37,8 @@ static void SleepFake(int milliseconds) static void BddTargetEndpoint(struct SolidSyslogEndpoint* endpoint) { - SolidSyslogFormatter_BoundedString(endpoint->host, BddTargetUdpConfig_GetHost(), SOLIDSYSLOG_MAX_HOST_SIZE); - endpoint->port = BddTargetUdpConfig_GetPort(); + SolidSyslogFormatter_BoundedString(endpoint->Host, BddTargetUdpConfig_GetHost(), SOLIDSYSLOG_MAX_HOST_SIZE); + endpoint->Port = BddTargetUdpConfig_GetPort(); } static uint32_t BddTargetEndpointVersion() // NOLINT(modernize-use-trailing-return-type) diff --git a/Tests/Bdd/Targets/BddTargetWindowsCommandLineTest.cpp b/Tests/Bdd/Targets/BddTargetWindowsCommandLineTest.cpp index 38a62c49..a9bd2510 100644 --- a/Tests/Bdd/Targets/BddTargetWindowsCommandLineTest.cpp +++ b/Tests/Bdd/Targets/BddTargetWindowsCommandLineTest.cpp @@ -19,7 +19,7 @@ TEST(BddTargetWindowsCommandLine, DefaultFacilityIsLocal0) char arg0[] = "test"; char* argv[] = {arg0, nullptr}; Parse(1, argv); - LONGS_EQUAL(SolidSyslogFacility_Local0, options.facility); + LONGS_EQUAL(SolidSyslogFacility_Local0, options.Facility); } TEST(BddTargetWindowsCommandLine, DefaultSeverityIsInfo) @@ -27,7 +27,7 @@ TEST(BddTargetWindowsCommandLine, DefaultSeverityIsInfo) char arg0[] = "test"; char* argv[] = {arg0, nullptr}; Parse(1, argv); - LONGS_EQUAL(SolidSyslogSeverity_Informational, options.severity); + LONGS_EQUAL(SolidSyslogSeverity_Informational, options.Severity); } TEST(BddTargetWindowsCommandLine, DefaultMessageIdIsNull) @@ -35,7 +35,7 @@ TEST(BddTargetWindowsCommandLine, DefaultMessageIdIsNull) char arg0[] = "test"; char* argv[] = {arg0, nullptr}; Parse(1, argv); - POINTERS_EQUAL(nullptr, options.messageId); + POINTERS_EQUAL(nullptr, options.MessageId); } TEST(BddTargetWindowsCommandLine, DefaultMsgIsNull) @@ -43,7 +43,7 @@ TEST(BddTargetWindowsCommandLine, DefaultMsgIsNull) char arg0[] = "test"; char* argv[] = {arg0, nullptr}; Parse(1, argv); - POINTERS_EQUAL(nullptr, options.msg); + POINTERS_EQUAL(nullptr, options.Msg); } TEST(BddTargetWindowsCommandLine, FacilityFlagSetsFacility) @@ -53,7 +53,7 @@ TEST(BddTargetWindowsCommandLine, FacilityFlagSetsFacility) char arg2[] = "23"; char* argv[] = {arg0, arg1, arg2, nullptr}; Parse(3, argv); - LONGS_EQUAL(23, options.facility); + LONGS_EQUAL(23, options.Facility); } TEST(BddTargetWindowsCommandLine, SeverityFlagSetsSeverity) @@ -63,7 +63,7 @@ TEST(BddTargetWindowsCommandLine, SeverityFlagSetsSeverity) char arg2[] = "7"; char* argv[] = {arg0, arg1, arg2, nullptr}; Parse(3, argv); - LONGS_EQUAL(7, options.severity); + LONGS_EQUAL(7, options.Severity); } TEST(BddTargetWindowsCommandLine, MsgidFlagSetsMessageId) @@ -73,7 +73,7 @@ TEST(BddTargetWindowsCommandLine, MsgidFlagSetsMessageId) char arg2[] = "ID47"; char* argv[] = {arg0, arg1, arg2, nullptr}; Parse(3, argv); - STRCMP_EQUAL("ID47", options.messageId); + STRCMP_EQUAL("ID47", options.MessageId); } TEST(BddTargetWindowsCommandLine, MessageFlagSetsMsg) @@ -83,7 +83,7 @@ TEST(BddTargetWindowsCommandLine, MessageFlagSetsMsg) char arg2[] = "system started"; char* argv[] = {arg0, arg1, arg2, nullptr}; Parse(3, argv); - STRCMP_EQUAL("system started", options.msg); + STRCMP_EQUAL("system started", options.Msg); } TEST(BddTargetWindowsCommandLine, DefaultTransportIsUdp) @@ -91,7 +91,7 @@ TEST(BddTargetWindowsCommandLine, DefaultTransportIsUdp) char arg0[] = "test"; char* argv[] = {arg0, nullptr}; Parse(1, argv); - STRCMP_EQUAL("udp", options.transport); + STRCMP_EQUAL("udp", options.Transport); } TEST(BddTargetWindowsCommandLine, TransportFlagSetsTcp) @@ -101,7 +101,7 @@ TEST(BddTargetWindowsCommandLine, TransportFlagSetsTcp) char arg2[] = "tcp"; char* argv[] = {arg0, arg1, arg2, nullptr}; Parse(3, argv); - STRCMP_EQUAL("tcp", options.transport); + STRCMP_EQUAL("tcp", options.Transport); } TEST(BddTargetWindowsCommandLine, AllFlagsTogether) @@ -117,10 +117,10 @@ TEST(BddTargetWindowsCommandLine, AllFlagsTogether) char arg8[] = "session opened"; char* argv[] = {arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, nullptr}; Parse(9, argv); - LONGS_EQUAL(16, options.facility); - LONGS_EQUAL(6, options.severity); - STRCMP_EQUAL("CONN", options.messageId); - STRCMP_EQUAL("session opened", options.msg); + LONGS_EQUAL(16, options.Facility); + LONGS_EQUAL(6, options.Severity); + STRCMP_EQUAL("CONN", options.MessageId); + STRCMP_EQUAL("session opened", options.Msg); } TEST(BddTargetWindowsCommandLine, UnknownFlagIsIgnored) @@ -130,8 +130,8 @@ TEST(BddTargetWindowsCommandLine, UnknownFlagIsIgnored) char arg2[] = "value"; char* argv[] = {arg0, arg1, arg2, nullptr}; Parse(3, argv); - LONGS_EQUAL(SolidSyslogFacility_Local0, options.facility); - POINTERS_EQUAL(nullptr, options.messageId); + LONGS_EQUAL(SolidSyslogFacility_Local0, options.Facility); + POINTERS_EQUAL(nullptr, options.MessageId); } TEST(BddTargetWindowsCommandLine, FacilityFlagWithoutValueIsIgnored) @@ -140,7 +140,7 @@ TEST(BddTargetWindowsCommandLine, FacilityFlagWithoutValueIsIgnored) char arg1[] = "--facility"; char* argv[] = {arg0, arg1, nullptr}; Parse(2, argv); - LONGS_EQUAL(SolidSyslogFacility_Local0, options.facility); + LONGS_EQUAL(SolidSyslogFacility_Local0, options.Facility); } TEST(BddTargetWindowsCommandLine, DefaultAppNameIsNull) @@ -148,7 +148,7 @@ TEST(BddTargetWindowsCommandLine, DefaultAppNameIsNull) char arg0[] = "test"; char* argv[] = {arg0, nullptr}; Parse(1, argv); - POINTERS_EQUAL(nullptr, options.appName); + POINTERS_EQUAL(nullptr, options.AppName); } TEST(BddTargetWindowsCommandLine, AppNameFlagSetsAppName) @@ -158,7 +158,7 @@ TEST(BddTargetWindowsCommandLine, AppNameFlagSetsAppName) char arg2[] = "SolidSyslogThreadedExample"; char* argv[] = {arg0, arg1, arg2, nullptr}; Parse(3, argv); - STRCMP_EQUAL("SolidSyslogThreadedExample", options.appName); + STRCMP_EQUAL("SolidSyslogThreadedExample", options.AppName); } TEST(BddTargetWindowsCommandLine, DefaultHaltExitIsFalse) @@ -166,7 +166,7 @@ TEST(BddTargetWindowsCommandLine, DefaultHaltExitIsFalse) char arg0[] = "test"; char* argv[] = {arg0, nullptr}; Parse(1, argv); - CHECK_FALSE(options.haltExit); + CHECK_FALSE(options.HaltExit); } TEST(BddTargetWindowsCommandLine, HaltExitFlagSetsHaltExit) @@ -175,5 +175,5 @@ TEST(BddTargetWindowsCommandLine, HaltExitFlagSetsHaltExit) char arg1[] = "--halt-exit"; char* argv[] = {arg0, arg1, nullptr}; Parse(2, argv); - CHECK_TRUE(options.haltExit); + CHECK_TRUE(options.HaltExit); } diff --git a/Tests/BlockSequenceTest.cpp b/Tests/BlockSequenceTest.cpp index 5e5f80f7..dc6a3590 100644 --- a/Tests/BlockSequenceTest.cpp +++ b/Tests/BlockSequenceTest.cpp @@ -27,12 +27,12 @@ struct DeviceCall // cppcheck-suppress unusedStructMember -- read by DisposePrecedesAcquire / loop assertions; cppcheck does not model std::vector element access CallType type; // cppcheck-suppress unusedStructMember -- read by DisposePrecedesAcquire; cppcheck does not model std::vector element access - size_t blockIndex; + size_t BlockIndex; }; struct ScanFake { - struct SolidSyslogBlockDevice base; + struct SolidSyslogBlockDevice Base; std::set* existing; std::vector* calls; /* optional — tests that don't care leave nullptr */ std::map* sizes; /* optional — tests that need realistic Size readings populate */ @@ -149,21 +149,21 @@ TEST_GROUP(BlockSequenceScan) void setup() override { - fakeDevice.base.Acquire = FakeAcquire; - fakeDevice.base.Dispose = FakeDispose; - fakeDevice.base.Exists = FakeExists; - fakeDevice.base.Read = FakeRead; - fakeDevice.base.Append = FakeAppend; - fakeDevice.base.WriteAt = FakeWriteAt; - fakeDevice.base.Size = FakeSize; + fakeDevice.Base.Acquire = FakeAcquire; + fakeDevice.Base.Dispose = FakeDispose; + fakeDevice.Base.Exists = FakeExists; + fakeDevice.Base.Read = FakeRead; + fakeDevice.Base.Append = FakeAppend; + fakeDevice.Base.WriteAt = FakeWriteAt; + fakeDevice.Base.Size = FakeSize; // cppcheck-suppress unreadVariable -- read indirectly via FakeExists; cppcheck does not model the function-pointer indirection fakeDevice.existing = &existing; struct BlockSequenceConfig config = {}; - config.blockDevice = &fakeDevice.base; - config.maxBlockSize = 1000; - config.maxBlocks = 99; - config.discardPolicy = SolidSyslogDiscardPolicy_Oldest; + config.BlockDevice = &fakeDevice.Base; + config.MaxBlockSize = 1000; + config.MaxBlocks = 99; + config.DiscardPolicy = SolidSyslogDiscardPolicy_Oldest; BlockSequence_Init(&sequence, &config); } }; @@ -235,23 +235,23 @@ TEST_GROUP(BlockSequenceRotation) void setup() override { - fakeDevice.base.Acquire = FakeAcquire; - fakeDevice.base.Dispose = FakeDispose; - fakeDevice.base.Exists = FakeExists; - fakeDevice.base.Read = FakeRead; - fakeDevice.base.Append = FakeAppend; - fakeDevice.base.WriteAt = FakeWriteAt; - fakeDevice.base.Size = FakeSize; + fakeDevice.Base.Acquire = FakeAcquire; + fakeDevice.Base.Dispose = FakeDispose; + fakeDevice.Base.Exists = FakeExists; + fakeDevice.Base.Read = FakeRead; + fakeDevice.Base.Append = FakeAppend; + fakeDevice.Base.WriteAt = FakeWriteAt; + fakeDevice.Base.Size = FakeSize; fakeDevice.existing = &existing; fakeDevice.calls = &calls; // cppcheck-suppress unreadVariable -- read indirectly via FakeSize; cppcheck does not model the function-pointer indirection fakeDevice.sizes = &sizes; struct BlockSequenceConfig config = {}; - config.blockDevice = &fakeDevice.base; - config.maxBlockSize = ROTATION_BLOCK_SIZE; - config.maxBlocks = 99; - config.discardPolicy = SolidSyslogDiscardPolicy_Oldest; + config.BlockDevice = &fakeDevice.Base; + config.MaxBlockSize = ROTATION_BLOCK_SIZE; + config.MaxBlocks = 99; + config.DiscardPolicy = SolidSyslogDiscardPolicy_Oldest; BlockSequence_Init(&sequence, &config); BlockSequence_Open(&sequence); /* cold start: Acquire(0) */ @@ -269,11 +269,11 @@ TEST_GROUP(BlockSequenceRotation) std::ptrdiff_t acquireAt = -1; for (size_t i = 0; i < calls.size(); i++) { - if ((calls[i].blockIndex == blockIndex) && (calls[i].type == CallType::Dispose)) + if ((calls[i].BlockIndex == blockIndex) && (calls[i].type == CallType::Dispose)) { disposeAt = static_cast(i); } - if ((calls[i].blockIndex == blockIndex) && (calls[i].type == CallType::Acquire)) + if ((calls[i].BlockIndex == blockIndex) && (calls[i].type == CallType::Acquire)) { acquireAt = static_cast(i); } @@ -326,7 +326,7 @@ TEST(BlockSequenceRotation, RotationFailsWhenStaleBlockDisposeFails) CHECK_FALSE(acquired); for (const auto& call : calls) { - if ((call.type == CallType::Acquire) && (call.blockIndex == 1)) + if ((call.type == CallType::Acquire) && (call.BlockIndex == 1)) { FAIL("Acquire(1) was called even though Dispose(1) failed"); } diff --git a/Tests/BufferFake.c b/Tests/BufferFake.c index 4d99d241..d9c42163 100644 --- a/Tests/BufferFake.c +++ b/Tests/BufferFake.c @@ -16,10 +16,10 @@ static void Write(struct SolidSyslogBuffer* self, const void* data, size_t size) struct BufferFake { - struct SolidSyslogBuffer base; - char stored[BUFFERFAKE_MAX_SIZE]; - size_t storedSize; - bool pending; + struct SolidSyslogBuffer Base; + char Stored[BUFFERFAKE_MAX_SIZE]; + size_t StoredSize; + bool Pending; }; static struct BufferFake instance; @@ -27,9 +27,9 @@ static struct BufferFake instance; struct SolidSyslogBuffer* BufferFake_Create(void) { instance = (struct BufferFake) {0}; - instance.base.Write = Write; - instance.base.Read = Read; - return &instance.base; + instance.Base.Write = Write; + instance.Base.Read = Read; + return &instance.Base; } void BufferFake_Destroy(void) @@ -40,14 +40,14 @@ void BufferFake_Destroy(void) static bool Read(struct SolidSyslogBuffer* self, void* data, size_t maxSize, size_t* bytesRead) { struct BufferFake* fake = (struct BufferFake*) self; - bool success = fake->pending; + bool success = fake->Pending; if (success) { - size_t copySize = MinSize(fake->storedSize, maxSize); - memcpy(data, fake->stored, copySize); + size_t copySize = MinSize(fake->StoredSize, maxSize); + memcpy(data, fake->Stored, copySize); *bytesRead = copySize; - fake->pending = false; + fake->Pending = false; } return success; @@ -57,8 +57,8 @@ static void Write(struct SolidSyslogBuffer* self, const void* data, size_t size) { struct BufferFake* fake = (struct BufferFake*) self; - size_t copySize = MinSize(size, sizeof(fake->stored)); - memcpy(fake->stored, data, copySize); - fake->storedSize = copySize; - fake->pending = true; + size_t copySize = MinSize(size, sizeof(fake->Stored)); + memcpy(fake->Stored, data, copySize); + fake->StoredSize = copySize; + fake->Pending = true; } diff --git a/Tests/DatagramFake.c b/Tests/DatagramFake.c index 7741089d..838f80f9 100644 --- a/Tests/DatagramFake.c +++ b/Tests/DatagramFake.c @@ -12,15 +12,15 @@ enum struct DatagramFake { - struct SolidSyslogDatagram base; - int openCallCount; - int sendCallCount; - int maxPayloadCallCount; - int closeCallCount; - enum SolidSyslogDatagramSendResult sendResults[DATAGRAMFAKE_MAX_SEND_CALLS]; - size_t maxPayload; - const void* sendBuffers[DATAGRAMFAKE_MAX_SEND_CALLS]; - size_t sendSizes[DATAGRAMFAKE_MAX_SEND_CALLS]; + struct SolidSyslogDatagram Base; + int OpenCallCount; + int SendCallCount; + int MaxPayloadCallCount; + int CloseCallCount; + enum SolidSyslogDatagramSendResult SendResults[DATAGRAMFAKE_MAX_SEND_CALLS]; + size_t MaxPayload; + const void* SendBuffers[DATAGRAMFAKE_MAX_SEND_CALLS]; + size_t SendSizes[DATAGRAMFAKE_MAX_SEND_CALLS]; }; static bool Open(struct SolidSyslogDatagram* self); @@ -36,15 +36,15 @@ static void Close(struct SolidSyslogDatagram* self); struct SolidSyslogDatagram* DatagramFake_Create(void) { struct DatagramFake* fake = (struct DatagramFake*) calloc(1, sizeof(struct DatagramFake)); - fake->base.Open = Open; - fake->base.SendTo = SendTo; - fake->base.MaxPayload = MaxPayload; - fake->base.Close = Close; + fake->Base.Open = Open; + fake->Base.SendTo = SendTo; + fake->Base.MaxPayload = MaxPayload; + fake->Base.Close = Close; for (int i = 0; i < DATAGRAMFAKE_MAX_SEND_CALLS; i++) { - fake->sendResults[i] = SolidSyslogDatagramSendResult_Sent; + fake->SendResults[i] = SolidSyslogDatagramSendResult_Sent; } - return &fake->base; + return &fake->Base; } void DatagramFake_Destroy(struct SolidSyslogDatagram* datagram) @@ -60,33 +60,33 @@ void DatagramFake_SetSendResult( { if ((callIndex >= 0) && (callIndex < DATAGRAMFAKE_MAX_SEND_CALLS)) { - ((struct DatagramFake*) datagram)->sendResults[callIndex] = result; + ((struct DatagramFake*) datagram)->SendResults[callIndex] = result; } } void DatagramFake_SetMaxPayload(struct SolidSyslogDatagram* datagram, size_t maxPayload) { - ((struct DatagramFake*) datagram)->maxPayload = maxPayload; + ((struct DatagramFake*) datagram)->MaxPayload = maxPayload; } int DatagramFake_OpenCallCount(struct SolidSyslogDatagram* datagram) { - return ((struct DatagramFake*) datagram)->openCallCount; + return ((struct DatagramFake*) datagram)->OpenCallCount; } int DatagramFake_SendCallCount(struct SolidSyslogDatagram* datagram) { - return ((struct DatagramFake*) datagram)->sendCallCount; + return ((struct DatagramFake*) datagram)->SendCallCount; } int DatagramFake_MaxPayloadCallCount(struct SolidSyslogDatagram* datagram) { - return ((struct DatagramFake*) datagram)->maxPayloadCallCount; + return ((struct DatagramFake*) datagram)->MaxPayloadCallCount; } int DatagramFake_CloseCallCount(struct SolidSyslogDatagram* datagram) { - return ((struct DatagramFake*) datagram)->closeCallCount; + return ((struct DatagramFake*) datagram)->CloseCallCount; } const void* DatagramFake_SendBuffer(struct SolidSyslogDatagram* datagram, int callIndex) @@ -95,7 +95,7 @@ const void* DatagramFake_SendBuffer(struct SolidSyslogDatagram* datagram, int ca { return NULL; } - return ((struct DatagramFake*) datagram)->sendBuffers[callIndex]; + return ((struct DatagramFake*) datagram)->SendBuffers[callIndex]; } size_t DatagramFake_SendSize(struct SolidSyslogDatagram* datagram, int callIndex) @@ -104,13 +104,13 @@ size_t DatagramFake_SendSize(struct SolidSyslogDatagram* datagram, int callIndex { return 0; } - return ((struct DatagramFake*) datagram)->sendSizes[callIndex]; + return ((struct DatagramFake*) datagram)->SendSizes[callIndex]; } static bool Open(struct SolidSyslogDatagram* self) { struct DatagramFake* fake = (struct DatagramFake*) self; - fake->openCallCount++; + fake->OpenCallCount++; return true; } @@ -122,27 +122,27 @@ static enum SolidSyslogDatagramSendResult SendTo( ) { struct DatagramFake* fake = (struct DatagramFake*) self; - int idx = fake->sendCallCount; + int idx = fake->SendCallCount; enum SolidSyslogDatagramSendResult result = SolidSyslogDatagramSendResult_Failed; (void) addr; if (idx < DATAGRAMFAKE_MAX_SEND_CALLS) { - fake->sendBuffers[idx] = buffer; - fake->sendSizes[idx] = size; - result = fake->sendResults[idx]; + fake->SendBuffers[idx] = buffer; + fake->SendSizes[idx] = size; + result = fake->SendResults[idx]; } - fake->sendCallCount++; + fake->SendCallCount++; return result; } static size_t MaxPayload(struct SolidSyslogDatagram* self) { struct DatagramFake* fake = (struct DatagramFake*) self; - fake->maxPayloadCallCount++; - return fake->maxPayload; + fake->MaxPayloadCallCount++; + return fake->MaxPayload; } static void Close(struct SolidSyslogDatagram* self) { - ((struct DatagramFake*) self)->closeCallCount++; + ((struct DatagramFake*) self)->CloseCallCount++; } diff --git a/Tests/FreeRtos/SolidSyslogFreeRtosStaticResolverTest.cpp b/Tests/FreeRtos/SolidSyslogFreeRtosStaticResolverTest.cpp index 14f1659d..8435e9cf 100644 --- a/Tests/FreeRtos/SolidSyslogFreeRtosStaticResolverTest.cpp +++ b/Tests/FreeRtos/SolidSyslogFreeRtosStaticResolverTest.cpp @@ -78,7 +78,7 @@ TEST(SolidSyslogFreeRtosStaticResolver, ResolveWritesPortFromArgInNetworkOrder) TEST(SolidSyslogFreeRtosStaticResolver, ResolveProducesSameIpv4ForAnyHostString) { - Resolve("first.host"); + Resolve("first.Host"); uint32_t firstIpv4 = Result()->sin_address.ulIP_IPv4; addrStorage = {}; diff --git a/Tests/OpenSslIntegration/BioPairStream.c b/Tests/OpenSslIntegration/BioPairStream.c index a5e95d6a..f5e998b2 100644 --- a/Tests/OpenSslIntegration/BioPairStream.c +++ b/Tests/OpenSslIntegration/BioPairStream.c @@ -11,10 +11,10 @@ struct SolidSyslogAddress; struct BioPairStream { - struct SolidSyslogStream base; - BIO* bio; - BioPairStreamPumpFunction pump; - void* pumpContext; + struct SolidSyslogStream Base; + BIO* Bio; + BioPairStreamPumpFunction Pump; + void* PumpContext; }; static bool Open(struct SolidSyslogStream* self, const struct SolidSyslogAddress* addr); @@ -25,12 +25,12 @@ static void Close(struct SolidSyslogStream* self); struct SolidSyslogStream* BioPairStream_Create(BIO* bio) { struct BioPairStream* stream = (struct BioPairStream*) calloc(1, sizeof(struct BioPairStream)); - stream->base.Open = Open; - stream->base.Send = Send; - stream->base.Read = Read; - stream->base.Close = Close; - stream->bio = bio; - return &stream->base; + stream->Base.Open = Open; + stream->Base.Send = Send; + stream->Base.Read = Read; + stream->Base.Close = Close; + stream->Bio = bio; + return &stream->Base; } void BioPairStream_Destroy(struct SolidSyslogStream* self) @@ -41,8 +41,8 @@ void BioPairStream_Destroy(struct SolidSyslogStream* self) void BioPairStream_SetPump(struct SolidSyslogStream* self, BioPairStreamPumpFunction pump, void* context) { struct BioPairStream* stream = (struct BioPairStream*) self; - stream->pump = pump; - stream->pumpContext = context; + stream->Pump = pump; + stream->PumpContext = context; } static bool Open(struct SolidSyslogStream* self, const struct SolidSyslogAddress* addr) @@ -55,7 +55,7 @@ static bool Open(struct SolidSyslogStream* self, const struct SolidSyslogAddress static bool Send(struct SolidSyslogStream* self, const void* buffer, size_t size) { struct BioPairStream* stream = (struct BioPairStream*) self; - int written = BIO_write(stream->bio, buffer, (int) size); + int written = BIO_write(stream->Bio, buffer, (int) size); return written == (int) size; } @@ -70,19 +70,19 @@ static SolidSyslogSsize Read(struct SolidSyslogStream* self, void* buffer, size_ bool done = false; while (!done) { - int bytesRead = BIO_read(stream->bio, buffer, (int) size); + int bytesRead = BIO_read(stream->Bio, buffer, (int) size); if (bytesRead > 0) { result = (SolidSyslogSsize) bytesRead; done = true; } - else if (!BIO_should_retry(stream->bio) || stream->pump == NULL) + else if (!BIO_should_retry(stream->Bio) || stream->Pump == NULL) { done = true; } else { - stream->pump(stream->pumpContext); + stream->Pump(stream->PumpContext); } } return result; diff --git a/Tests/OpenSslIntegration/SolidSyslogTlsStreamIntegrationTest.cpp b/Tests/OpenSslIntegration/SolidSyslogTlsStreamIntegrationTest.cpp index ef4641e5..afffef25 100644 --- a/Tests/OpenSslIntegration/SolidSyslogTlsStreamIntegrationTest.cpp +++ b/Tests/OpenSslIntegration/SolidSyslogTlsStreamIntegrationTest.cpp @@ -81,17 +81,17 @@ TEST_GROUP(TlsStreamIntegration) TlsTestCert_WritePemToFile(&cert, caPath); struct TlsTestServerConfig serverConfig = {}; - serverConfig.serverCert = &cert; - serverConfig.clientCaCert = serverClientCa; + serverConfig.ServerCert = &cert; + serverConfig.ClientCaCert = serverClientCa; server = TlsTestServer_Create(&serverConfig); transport = BioPairStream_Create(TlsTestServer_ClientSideBio(server)); BioPairStream_SetPump(transport, TlsTestServer_Pump, server); - tlsConfig.transport = transport; - tlsConfig.sleep = NoOpSleep; - tlsConfig.caBundlePath = caPath; - tlsConfig.serverName = clientServerName; + tlsConfig.Transport = transport; + tlsConfig.Sleep = NoOpSleep; + tlsConfig.CaBundlePath = caPath; + tlsConfig.ServerName = clientServerName; tlsStream = SolidSyslogTlsStream_Create(&tlsStreamStorage, &tlsConfig); } @@ -111,8 +111,8 @@ TEST_GROUP(TlsStreamIntegration) TlsTestCert_WritePemToFile(&clientCert, clientCertPath); TlsTestCert_WritePrivateKeyPemToFile(&clientCert, clientKeyPath); - tlsConfig.clientCertChainPath = clientCertPath; - tlsConfig.clientKeyPath = clientKeyPath; + tlsConfig.ClientCertChainPath = clientCertPath; + tlsConfig.ClientKeyPath = clientKeyPath; } void createClientCa() @@ -155,7 +155,7 @@ TEST(TlsStreamIntegration, HandshakeRejectedWhenServerCertHostnameDoesNotMatch) struct TlsTestCertConfig certConfig = {}; certConfig.commonName = "someone-else.example"; certConfig.subjectAltDnsNames = otherSans; - buildScenario(certConfig); /* client.serverName defaults to "localhost" */ + buildScenario(certConfig); /* client.ServerName defaults to "localhost" */ CHECK_FALSE(SolidSyslogStream_Open(tlsStream, addr)); } @@ -187,7 +187,7 @@ TEST(TlsStreamIntegration, HandshakeRejectedWhenCipherListIsUnsupported) struct TlsTestCertConfig certConfig = {}; certConfig.commonName = "localhost"; certConfig.subjectAltDnsNames = LOCALHOST_SANS; - tlsConfig.cipherList = "NOT-A-REAL-CIPHER"; + tlsConfig.CipherList = "NOT-A-REAL-CIPHER"; buildScenario(certConfig); CHECK_FALSE(SolidSyslogStream_Open(tlsStream, addr)); diff --git a/Tests/OpenSslIntegration/TlsTestServer.c b/Tests/OpenSslIntegration/TlsTestServer.c index 15ec7322..94ce04f1 100644 --- a/Tests/OpenSslIntegration/TlsTestServer.c +++ b/Tests/OpenSslIntegration/TlsTestServer.c @@ -11,41 +11,41 @@ struct TlsTestServer { - SSL_CTX* ctx; - SSL* ssl; - BIO* serverBio; - BIO* clientBio; - bool handshakeComplete; + SSL_CTX* Ctx; + SSL* Ssl; + BIO* ServerBio; + BIO* ClientBio; + bool HandshakeComplete; }; struct TlsTestServer* TlsTestServer_Create(const struct TlsTestServerConfig* config) { struct TlsTestServer* self = (struct TlsTestServer*) calloc(1, sizeof(struct TlsTestServer)); - self->ctx = SSL_CTX_new(TLS_server_method()); - SSL_CTX_use_certificate(self->ctx, config->serverCert->cert); - SSL_CTX_use_PrivateKey(self->ctx, config->serverCert->key); - if (config->cipherList != NULL) + self->Ctx = SSL_CTX_new(TLS_server_method()); + SSL_CTX_use_certificate(self->Ctx, config->ServerCert->cert); + SSL_CTX_use_PrivateKey(self->Ctx, config->ServerCert->key); + if (config->CipherList != NULL) { - SSL_CTX_set_cipher_list(self->ctx, config->cipherList); + SSL_CTX_set_cipher_list(self->Ctx, config->CipherList); } - if (config->clientCaCert != NULL) + if (config->ClientCaCert != NULL) { - X509_STORE* store = SSL_CTX_get_cert_store(self->ctx); - X509_STORE_add_cert(store, config->clientCaCert->cert); - SSL_CTX_set_verify(self->ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL); + X509_STORE* store = SSL_CTX_get_cert_store(self->Ctx); + X509_STORE_add_cert(store, config->ClientCaCert->cert); + SSL_CTX_set_verify(self->Ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL); /* Pin TLS 1.2 for mTLS tests — in TLS 1.3 the client's SSL_connect * can return before the server's verify completes, so a cert rejection * on the server shows up on the client only on the next read. * TLS 1.2 keeps rejection synchronous within the handshake. */ - SSL_CTX_set_max_proto_version(self->ctx, TLS1_2_VERSION); + SSL_CTX_set_max_proto_version(self->Ctx, TLS1_2_VERSION); } - self->ssl = SSL_new(self->ctx); - BIO_new_bio_pair(&self->serverBio, 0, &self->clientBio, 0); - SSL_set_bio(self->ssl, self->serverBio, self->serverBio); - self->serverBio = NULL; /* ownership transferred to SSL via SSL_set_bio */ - SSL_set_accept_state(self->ssl); + self->Ssl = SSL_new(self->Ctx); + BIO_new_bio_pair(&self->ServerBio, 0, &self->ClientBio, 0); + SSL_set_bio(self->Ssl, self->ServerBio, self->ServerBio); + self->ServerBio = NULL; /* ownership transferred to SSL via SSL_set_bio */ + SSL_set_accept_state(self->Ssl); return self; } @@ -56,35 +56,35 @@ void TlsTestServer_Destroy(struct TlsTestServer* self) { return; } - if (self->ssl != NULL) + if (self->Ssl != NULL) { - SSL_free(self->ssl); /* also frees serverBio */ + SSL_free(self->Ssl); /* also frees serverBio */ } - if (self->clientBio != NULL) + if (self->ClientBio != NULL) { - BIO_free(self->clientBio); + BIO_free(self->ClientBio); } - if (self->ctx != NULL) + if (self->Ctx != NULL) { - SSL_CTX_free(self->ctx); + SSL_CTX_free(self->Ctx); } free(self); } BIO* TlsTestServer_ClientSideBio(struct TlsTestServer* self) { - return self->clientBio; + return self->ClientBio; } void TlsTestServer_Pump(void* context) { struct TlsTestServer* self = (struct TlsTestServer*) context; - if (!self->handshakeComplete) + if (!self->HandshakeComplete) { - int ret = SSL_accept(self->ssl); + int ret = SSL_accept(self->Ssl); if (ret == 1) { - self->handshakeComplete = true; + self->HandshakeComplete = true; } } } diff --git a/Tests/OpenSslIntegration/TlsTestServer.h b/Tests/OpenSslIntegration/TlsTestServer.h index 87652944..098b819d 100644 --- a/Tests/OpenSslIntegration/TlsTestServer.h +++ b/Tests/OpenSslIntegration/TlsTestServer.h @@ -11,9 +11,9 @@ EXTERN_C_BEGIN struct TlsTestServerConfig { - const struct TlsTestCert* serverCert; /* includes matching private key */ - const char* cipherList; /* NULL = server default */ - const struct TlsTestCert* clientCaCert; /* NULL = no mTLS; set to require & verify client cert */ + const struct TlsTestCert* ServerCert; /* includes matching private key */ + const char* CipherList; /* NULL = server default */ + const struct TlsTestCert* ClientCaCert; /* NULL = no mTLS; set to require & verify client cert */ }; struct TlsTestServer* TlsTestServer_Create(const struct TlsTestServerConfig* config); diff --git a/Tests/SenderFake.c b/Tests/SenderFake.c index c7db9772..e63cf5d0 100644 --- a/Tests/SenderFake.c +++ b/Tests/SenderFake.c @@ -10,26 +10,26 @@ struct SenderFake { - struct SolidSyslogSender base; - int sendCount; - int disconnectCount; - char lastBuffer[SOLIDSYSLOG_MAX_MESSAGE_SIZE]; - size_t lastSize; - bool failNextSend; + struct SolidSyslogSender Base; + int SendCount; + int DisconnectCount; + char LastBuffer[SOLIDSYSLOG_MAX_MESSAGE_SIZE]; + size_t LastSize; + bool FailNextSend; }; static bool Send(struct SolidSyslogSender* self, const void* buffer, size_t size) { struct SenderFake* fake = (struct SenderFake*) self; - size_t copySize = MinSize(size, sizeof(fake->lastBuffer) - 1); - memcpy(fake->lastBuffer, buffer, copySize); - fake->lastBuffer[copySize] = '\0'; - fake->lastSize = size; - fake->sendCount++; + size_t copySize = MinSize(size, sizeof(fake->LastBuffer) - 1); + memcpy(fake->LastBuffer, buffer, copySize); + fake->LastBuffer[copySize] = '\0'; + fake->LastSize = size; + fake->SendCount++; - if (fake->failNextSend) + if (fake->FailNextSend) { - fake->failNextSend = false; + fake->FailNextSend = false; return false; } return true; @@ -38,15 +38,15 @@ static bool Send(struct SolidSyslogSender* self, const void* buffer, size_t size static void Disconnect(struct SolidSyslogSender* self) { struct SenderFake* fake = (struct SenderFake*) self; - fake->disconnectCount++; + fake->DisconnectCount++; } struct SolidSyslogSender* SenderFake_Create(void) { struct SenderFake* fake = (struct SenderFake*) calloc(1, sizeof(struct SenderFake)); - fake->base.Send = Send; - fake->base.Disconnect = Disconnect; - return &fake->base; + fake->Base.Send = Send; + fake->Base.Disconnect = Disconnect; + return &fake->Base; } void SenderFake_Destroy(struct SolidSyslogSender* sender) @@ -57,34 +57,34 @@ void SenderFake_Destroy(struct SolidSyslogSender* sender) void SenderFake_Reset(struct SolidSyslogSender* sender) { struct SenderFake* fake = (struct SenderFake*) sender; - fake->sendCount = 0; - fake->disconnectCount = 0; - fake->lastBuffer[0] = '\0'; - fake->lastSize = 0; - fake->failNextSend = false; + fake->SendCount = 0; + fake->DisconnectCount = 0; + fake->LastBuffer[0] = '\0'; + fake->LastSize = 0; + fake->FailNextSend = false; } int SenderFake_SendCallCount(struct SolidSyslogSender* sender) { - return ((struct SenderFake*) sender)->sendCount; + return ((struct SenderFake*) sender)->SendCount; } int SenderFake_DisconnectCallCount(struct SolidSyslogSender* sender) { - return ((struct SenderFake*) sender)->disconnectCount; + return ((struct SenderFake*) sender)->DisconnectCount; } const char* SenderFake_LastBufferAsString(struct SolidSyslogSender* sender) { - return ((struct SenderFake*) sender)->lastBuffer; + return ((struct SenderFake*) sender)->LastBuffer; } size_t SenderFake_LastSize(struct SolidSyslogSender* sender) { - return ((struct SenderFake*) sender)->lastSize; + return ((struct SenderFake*) sender)->LastSize; } void SenderFake_FailNextSend(struct SolidSyslogSender* sender) { - ((struct SenderFake*) sender)->failNextSend = true; + ((struct SenderFake*) sender)->FailNextSend = true; } diff --git a/Tests/SolidSyslogAtomicCounterTest.cpp b/Tests/SolidSyslogAtomicCounterTest.cpp index e0df3b94..6ef088c0 100644 --- a/Tests/SolidSyslogAtomicCounterTest.cpp +++ b/Tests/SolidSyslogAtomicCounterTest.cpp @@ -78,15 +78,15 @@ TEST(SolidSyslogAtomicCounter, NextSequenceIdAtMaxWrapsTo1) TEST(SolidSyslogAtomicCounter, TryAdvanceRereadsSlotAfterExternalMutation) { uint32_t firstNext = 0; - CHECK_TRUE(AtomicCounter_TryAdvance(counter->slot, &firstNext)); + CHECK_TRUE(AtomicCounter_TryAdvance(counter->Slot, &firstNext)); LONGS_EQUAL(1, firstNext); /* Simulate "another writer committed first" — TryAdvance must re-Load (rather than reuse a stale current) on its next call, so the returned value is one above the slot's actual current value. */ - SolidSyslogAtomicU32_Init(counter->slot, 5); + SolidSyslogAtomicU32_Init(counter->Slot, 5); uint32_t secondNext = 0; - CHECK_TRUE(AtomicCounter_TryAdvance(counter->slot, &secondNext)); + CHECK_TRUE(AtomicCounter_TryAdvance(counter->Slot, &secondNext)); LONGS_EQUAL(6, secondNext); } diff --git a/Tests/SolidSyslogBlockDeviceTest.cpp b/Tests/SolidSyslogBlockDeviceTest.cpp index c9a13fc3..95187120 100644 --- a/Tests/SolidSyslogBlockDeviceTest.cpp +++ b/Tests/SolidSyslogBlockDeviceTest.cpp @@ -8,7 +8,7 @@ namespace { struct FakeBlockDevice { - struct SolidSyslogBlockDevice base; + struct SolidSyslogBlockDevice Base; size_t lastBlockIndex = 0; size_t lastOffset = 0; size_t lastCount = 0; @@ -97,15 +97,15 @@ TEST_GROUP(SolidSyslogBlockDevice) void setup() override { - fake.base.Acquire = FakeAcquire; - fake.base.Dispose = FakeDispose; - fake.base.Exists = FakeExists; - fake.base.Read = FakeRead; - fake.base.Append = FakeAppend; - fake.base.WriteAt = FakeWriteAt; - fake.base.Size = FakeSize; + fake.Base.Acquire = FakeAcquire; + fake.Base.Dispose = FakeDispose; + fake.Base.Exists = FakeExists; + fake.Base.Read = FakeRead; + fake.Base.Append = FakeAppend; + fake.Base.WriteAt = FakeWriteAt; + fake.Base.Size = FakeSize; // cppcheck-suppress unreadVariable -- used across TEST_GROUP methods; cppcheck does not model CppUTest macros - device = &fake.base; + device = &fake.Base; } }; diff --git a/Tests/SolidSyslogBlockStoreDrainOrderingTest.cpp b/Tests/SolidSyslogBlockStoreDrainOrderingTest.cpp index 8981f79e..1b78e01b 100644 --- a/Tests/SolidSyslogBlockStoreDrainOrderingTest.cpp +++ b/Tests/SolidSyslogBlockStoreDrainOrderingTest.cpp @@ -47,7 +47,7 @@ static const char* const TEST_PATH_PREFIX = "/tmp/draintest_"; * interleave. */ struct SenderSpy { - struct SolidSyslogSender base; + struct SolidSyslogSender Base; std::vector> successfulSends; bool outage; }; @@ -71,8 +71,8 @@ static void SenderSpy_Disconnect(struct SolidSyslogSender* self) static void SenderSpy_Init(SenderSpy& spy) { - spy.base.Send = SenderSpy_Send; - spy.base.Disconnect = SenderSpy_Disconnect; + spy.Base.Send = SenderSpy_Send; + spy.Base.Disconnect = SenderSpy_Disconnect; spy.outage = false; spy.successfulSends.clear(); } @@ -96,12 +96,12 @@ struct DrainTestConfig /* cppcheck cannot follow CreateStore's reads through TEST_GROUP- * generated test classes; these fields ARE consumed there. */ // cppcheck-suppress unusedStructMember - size_t maxBlocks; + size_t MaxBlocks; // cppcheck-suppress unusedStructMember - size_t maxBlockSize; - size_t payloadSize; + size_t MaxBlockSize; + size_t PayloadSize; // cppcheck-suppress unusedStructMember - enum SolidSyslogDiscardPolicy discardPolicy; + enum SolidSyslogDiscardPolicy DiscardPolicy; }; /* Shared file / block-device / null-security-policy fixture. Lifted out of @@ -159,11 +159,11 @@ TEST_GROUP_BASE(BlockStoreDrainOrdering, DrainTestFixtureBase) void CreateStore(const DrainTestConfig& cfg) { struct SolidSyslogBlockStoreConfig config = {}; - config.blockDevice = device; - config.maxBlockSize = cfg.maxBlockSize; - config.maxBlocks = cfg.maxBlocks; - config.discardPolicy = cfg.discardPolicy; - config.securityPolicy = policy; + config.BlockDevice = device; + config.MaxBlockSize = cfg.MaxBlockSize; + config.MaxBlocks = cfg.MaxBlocks; + config.DiscardPolicy = cfg.DiscardPolicy; + config.SecurityPolicy = policy; store = SolidSyslogBlockStore_Create(&storeStorage, &config); } @@ -255,17 +255,17 @@ TEST_GROUP_BASE(ServiceDrainInterleave, DrainTestFixtureBase) void Setup(const DrainTestConfig& cfg) { struct SolidSyslogBlockStoreConfig storeCfg = {}; - storeCfg.blockDevice = device; - storeCfg.maxBlockSize = cfg.maxBlockSize; - storeCfg.maxBlocks = cfg.maxBlocks; - storeCfg.discardPolicy = cfg.discardPolicy; - storeCfg.securityPolicy = policy; + storeCfg.BlockDevice = device; + storeCfg.MaxBlockSize = cfg.MaxBlockSize; + storeCfg.MaxBlocks = cfg.MaxBlocks; + storeCfg.DiscardPolicy = cfg.DiscardPolicy; + storeCfg.SecurityPolicy = policy; store = SolidSyslogBlockStore_Create(&storeStorage, &storeCfg); struct SolidSyslogConfig sysCfg = {}; - sysCfg.buffer = buffer; - sysCfg.sender = &spy.base; - sysCfg.store = store; + sysCfg.Buffer = buffer; + sysCfg.Sender = &spy.Base; + sysCfg.Store = store; SolidSyslog_Create(&sysCfg); } @@ -311,7 +311,7 @@ TEST(ServiceDrainInterleave, DiscardNewestDoesNotLetNewestBypassOldestOnRecovery Setup(cfg); /* Pre-outage send: msg 1 flows buffer -> store -> sender successfully. */ - Enqueue(1, cfg.payloadSize); + Enqueue(1, cfg.PayloadSize); SolidSyslog_Service(); LONGS_EQUAL(1U, spy.successfulSends.size()); @@ -319,13 +319,13 @@ TEST(ServiceDrainInterleave, DiscardNewestDoesNotLetNewestBypassOldestOnRecovery spy.outage = true; /* Two messages fit into the 2-block store. */ - Enqueue(2, cfg.payloadSize); - Enqueue(3, cfg.payloadSize); + Enqueue(2, cfg.PayloadSize); + Enqueue(3, cfg.PayloadSize); SolidSyslog_Service(); /* Message 11 arrives still in outage — it lands in the buffer but * hasn't been pulled by Service yet at the moment the oracle resumes. */ - Enqueue(11, cfg.payloadSize); + Enqueue(11, cfg.PayloadSize); /* Oracle resumes. Drain by ticking Service repeatedly. */ spy.outage = false; @@ -382,13 +382,13 @@ TEST(BlockStoreDrainOrdering, OutageDrainProducesAscendingSequenceIds) /* Pre-outage send + drain — mirrors `When the client sends a message` * + `Then the syslog oracle receives 1 message` in the BDD scenario. */ - CHECK_TRUE(WriteMessage(1, cfg.payloadSize)); + CHECK_TRUE(WriteMessage(1, cfg.PayloadSize)); LONGS_EQUAL(1U, DrainOne()); /* Outage period: 10 messages queued without intermediate drains. */ for (uint32_t id = 2; id <= 11U; ++id) { - (void) WriteMessage(id, cfg.payloadSize); + (void) WriteMessage(id, cfg.PayloadSize); } /* Drain everything that's still there. */ diff --git a/Tests/SolidSyslogBlockStorePosixTest.cpp b/Tests/SolidSyslogBlockStorePosixTest.cpp index 233ed997..539266bb 100644 --- a/Tests/SolidSyslogBlockStorePosixTest.cpp +++ b/Tests/SolidSyslogBlockStorePosixTest.cpp @@ -66,10 +66,10 @@ TEST_GROUP(SolidSyslogBlockStorePosix) void CreateStore(size_t maxBlockSize = ONE_MAX_MSG_RECORD, size_t maxBlocks = 2) { struct SolidSyslogBlockStoreConfig config = {}; - config.blockDevice = device; - config.maxBlockSize = maxBlockSize; - config.maxBlocks = maxBlocks; - config.discardPolicy = SolidSyslogDiscardPolicy_Oldest; + config.BlockDevice = device; + config.MaxBlockSize = maxBlockSize; + config.MaxBlocks = maxBlocks; + config.DiscardPolicy = SolidSyslogDiscardPolicy_Oldest; // cppcheck-suppress unreadVariable -- used across TEST_GROUP methods; cppcheck does not model CppUTest macros store = SolidSyslogBlockStore_Create(&storeStorage, &config); } diff --git a/Tests/SolidSyslogBlockStoreTest.cpp b/Tests/SolidSyslogBlockStoreTest.cpp index dad25565..149bbf60 100644 --- a/Tests/SolidSyslogBlockStoreTest.cpp +++ b/Tests/SolidSyslogBlockStoreTest.cpp @@ -57,7 +57,7 @@ static SolidSyslogBlockStoreStorage storeStorage = {}; static struct SolidSyslogBlockStoreConfig MakeConfig(struct SolidSyslogBlockDevice* device) { struct SolidSyslogBlockStoreConfig config = DEFAULT_CONFIG; - config.blockDevice = device; + config.BlockDevice = device; return config; } @@ -481,7 +481,7 @@ TEST_GROUP_BASE(SolidSyslogBlockStoreConfig, BlockDeviceTestBase) void CreateWithMaxBlocks(size_t maxBlocks) { struct SolidSyslogBlockStoreConfig config = MakeConfig(device); - config.maxBlocks = maxBlocks; + config.MaxBlocks = maxBlocks; // cppcheck-suppress unreadVariable -- used across TEST_GROUP methods; cppcheck does not model CppUTest macros store = SolidSyslogBlockStore_Create(&storeStorage, &config); } @@ -489,7 +489,7 @@ TEST_GROUP_BASE(SolidSyslogBlockStoreConfig, BlockDeviceTestBase) void CreateWithMaxBlockSize(size_t maxBlockSize) { struct SolidSyslogBlockStoreConfig config = MakeConfig(device); - config.maxBlockSize = maxBlockSize; + config.MaxBlockSize = maxBlockSize; // cppcheck-suppress unreadVariable -- used across TEST_GROUP methods; cppcheck does not model CppUTest macros store = SolidSyslogBlockStore_Create(&storeStorage, &config); } @@ -579,7 +579,7 @@ TEST(SolidSyslogBlockStoreConfig, FilenameTruncatedWhenPrefixTooLong) TEST(SolidSyslogBlockStoreConfig, NullSecurityPolicyDefaultsToNoOp) { struct SolidSyslogBlockStoreConfig config = MakeConfig(device); - config.securityPolicy = nullptr; + config.SecurityPolicy = nullptr; store = SolidSyslogBlockStore_Create(&storeStorage, &config); VerifyWriteAndReadBack(); } @@ -592,7 +592,7 @@ TEST(SolidSyslogBlockStoreConfig, OversizedSecurityPolicyLeavesNoIntegrityGap) nullptr, }; struct SolidSyslogBlockStoreConfig config = MakeConfig(device); - config.securityPolicy = &oversizedPolicy; + config.SecurityPolicy = &oversizedPolicy; store = SolidSyslogBlockStore_Create(&storeStorage, &config); const char body[] = "HELLO WORLD"; @@ -714,12 +714,12 @@ TEST_GROUP_BASE(SolidSyslogBlockStoreRotation, BlockDeviceTestBase) SolidSyslogStoreFullCallback onStoreFull = nullptr, void* storeFullContext = nullptr) { struct SolidSyslogBlockStoreConfig config = DEFAULT_CONFIG; - config.blockDevice = device; - config.maxBlockSize = maxBlockSize; - config.maxBlocks = maxBlocks; - config.discardPolicy = policy; - config.onStoreFull = onStoreFull; - config.storeFullContext = storeFullContext; + config.BlockDevice = device; + config.MaxBlockSize = maxBlockSize; + config.MaxBlocks = maxBlocks; + config.DiscardPolicy = policy; + config.OnStoreFull = onStoreFull; + config.StoreFullContext = storeFullContext; // cppcheck-suppress unreadVariable -- used across TEST_GROUP methods; cppcheck does not model CppUTest macros store = SolidSyslogBlockStore_Create(&storeStorage, &config); } @@ -1428,8 +1428,8 @@ TEST_GROUP_BASE(SolidSyslogBlockStoreIntegrity, BlockDeviceTestBase) memset(verifyIntegrityData, 0, sizeof(verifyIntegrityData)); struct SolidSyslogBlockStoreConfig config = DEFAULT_CONFIG; - config.blockDevice = device; - config.securityPolicy = &spyPolicy; + config.BlockDevice = device; + config.SecurityPolicy = &spyPolicy; // cppcheck-suppress unreadVariable -- used across TEST_GROUP methods; cppcheck does not model CppUTest macros store = SolidSyslogBlockStore_Create(&storeStorage, &config); } @@ -1574,7 +1574,7 @@ TEST(SolidSyslogBlockStoreCorruption, TruncatedBodyHasNoUnsent) TEST(SolidSyslogBlockStoreCorruption, ValidRecordBeforeCorruptionIsReadable) { struct SolidSyslogBlockStoreConfig config = MakeConfig(device); - config.securityPolicy = SolidSyslogCrc16Policy_Create(); + config.SecurityPolicy = SolidSyslogCrc16Policy_Create(); store = SolidSyslogBlockStore_Create(&storeStorage, &config); SolidSyslogStore_Write(store, "first", 5); SolidSyslogStore_Write(store, "second", 6); @@ -1610,7 +1610,7 @@ TEST(SolidSyslogBlockStoreCorruption, ValidRecordBeforeCorruptionIsReadable) TEST(SolidSyslogBlockStoreCorruption, IntegrityFailureReadReturnsFalse) { struct SolidSyslogBlockStoreConfig config = MakeConfig(device); - config.securityPolicy = SolidSyslogCrc16Policy_Create(); + config.SecurityPolicy = SolidSyslogCrc16Policy_Create(); store = SolidSyslogBlockStore_Create(&storeStorage, &config); SolidSyslogStore_Write(store, TEST_DATA, TEST_DATA_LEN); SolidSyslogBlockStore_Destroy(store); @@ -1685,10 +1685,10 @@ TEST_GROUP_BASE(SolidSyslogBlockStoreCorruptionRecovery, BlockDeviceTestBase) void CreateWithMaxBlockSize(size_t maxBlockSize, size_t maxBlocks = 2) { struct SolidSyslogBlockStoreConfig config = DEFAULT_CONFIG; - config.blockDevice = device; - config.maxBlockSize = maxBlockSize; - config.maxBlocks = maxBlocks; - config.securityPolicy = policy; + config.BlockDevice = device; + config.MaxBlockSize = maxBlockSize; + config.MaxBlocks = maxBlocks; + config.SecurityPolicy = policy; // cppcheck-suppress unreadVariable -- used across TEST_GROUP methods; cppcheck does not model CppUTest macros store = SolidSyslogBlockStore_Create(&storeStorage, &config); } @@ -1789,9 +1789,9 @@ TEST_GROUP_BASE(SolidSyslogBlockStoreCapacity, BlockDeviceTestBase) enum SolidSyslogDiscardPolicy policy = SolidSyslogDiscardPolicy_Oldest) { struct SolidSyslogBlockStoreConfig config = MakeConfig(device); - config.maxBlockSize = maxBlockSize; - config.maxBlocks = maxBlocks; - config.discardPolicy = policy; + config.MaxBlockSize = maxBlockSize; + config.MaxBlocks = maxBlocks; + config.DiscardPolicy = policy; store = SolidSyslogBlockStore_Create(&storeStorage, &config); } @@ -1924,8 +1924,8 @@ TEST_GROUP_BASE(SolidSyslogBlockStoreCapacityThreshold, BlockDeviceTestBase) void CreateWithThreshold(size_t threshold) { struct SolidSyslogBlockStoreConfig config = MakeConfig(device); - config.getCapacityThreshold = ReturnsConfiguredThreshold; - config.onThresholdCrossed = CountThresholdCrossings; + config.GetCapacityThreshold = ReturnsConfiguredThreshold; + config.OnThresholdCrossed = CountThresholdCrossings; thresholdReturnValue = threshold; store = SolidSyslogBlockStore_Create(&storeStorage, &config); } @@ -1967,11 +1967,11 @@ TEST(SolidSyslogBlockStoreCapacityThreshold, ReArmsAfterFallingEdgeOnDiscardOlde memset(maxMsg, 'A', sizeof(maxMsg)); struct SolidSyslogBlockStoreConfig config = MakeConfig(device); - config.maxBlockSize = TWO_RECORDS; - config.maxBlocks = 2; - config.discardPolicy = SolidSyslogDiscardPolicy_Oldest; - config.getCapacityThreshold = ReturnsConfiguredThreshold; - config.onThresholdCrossed = CountThresholdCrossings; + config.MaxBlockSize = TWO_RECORDS; + config.MaxBlocks = 2; + config.DiscardPolicy = SolidSyslogDiscardPolicy_Oldest; + config.GetCapacityThreshold = ReturnsConfiguredThreshold; + config.OnThresholdCrossed = CountThresholdCrossings; /* Threshold sits between 3 and 4 records: 4-records crosses, 3-records is below. */ thresholdReturnValue = (3 * MAX_MSG_RECORD) + 1; store = SolidSyslogBlockStore_Create(&storeStorage, &config); @@ -2003,8 +2003,8 @@ TEST(SolidSyslogBlockStoreCapacityThreshold, DoesNotFireWhenThresholdIsZero) TEST(SolidSyslogBlockStoreCapacityThreshold, DoesNotFireWhenThresholdFunctionIsNull) { struct SolidSyslogBlockStoreConfig config = MakeConfig(device); - config.getCapacityThreshold = nullptr; - config.onThresholdCrossed = CountThresholdCrossings; + config.GetCapacityThreshold = nullptr; + config.OnThresholdCrossed = CountThresholdCrossings; store = SolidSyslogBlockStore_Create(&storeStorage, &config); SolidSyslogStore_Write(store, TEST_DATA, TEST_DATA_LEN); @@ -2035,9 +2035,9 @@ TEST(SolidSyslogBlockStoreCapacityThreshold, ContextIsPassedToBothCallbacks) capturedThresholdFunctionContext = nullptr; capturedThresholdCallbackContext = nullptr; struct SolidSyslogBlockStoreConfig config = MakeConfig(device); - config.getCapacityThreshold = CaptureThresholdFunctionContext; - config.onThresholdCrossed = CaptureThresholdCallbackContext; - config.thresholdContext = &sentinel; + config.GetCapacityThreshold = CaptureThresholdFunctionContext; + config.OnThresholdCrossed = CaptureThresholdCallbackContext; + config.ThresholdContext = &sentinel; thresholdReturnValue = TEST_DATA_LEN; store = SolidSyslogBlockStore_Create(&storeStorage, &config); @@ -2079,12 +2079,12 @@ TEST(SolidSyslogBlockStoreCapacityThreshold, AtFullCapacityWithHaltThresholdFire storeFullFireOrder = 0; struct SolidSyslogBlockStoreConfig config = MakeConfig(device); - config.maxBlockSize = MAX_MSG_RECORD + SLACK; - config.maxBlocks = 2; - config.discardPolicy = SolidSyslogDiscardPolicy_Halt; - config.onStoreFull = RecordStoreFullFireOrder; - config.getCapacityThreshold = ReturnsConfiguredThreshold; - config.onThresholdCrossed = RecordThresholdFireOrder; + config.MaxBlockSize = MAX_MSG_RECORD + SLACK; + config.MaxBlocks = 2; + config.DiscardPolicy = SolidSyslogDiscardPolicy_Halt; + config.OnStoreFull = RecordStoreFullFireOrder; + config.GetCapacityThreshold = ReturnsConfiguredThreshold; + config.OnThresholdCrossed = RecordThresholdFireOrder; /* Threshold = total: only the sticky-100% engagement on a failed Write reaches it. */ thresholdReturnValue = 2 * (MAX_MSG_RECORD + SLACK); store = SolidSyslogBlockStore_Create(&storeStorage, &config); @@ -2110,11 +2110,11 @@ TEST(SolidSyslogBlockStoreCapacityThreshold, StickyHundredPercentDoesNotRefireTh memset(maxMsg, 'A', sizeof(maxMsg)); struct SolidSyslogBlockStoreConfig config = MakeConfig(device); - config.maxBlockSize = MAX_MSG_RECORD + SLACK; - config.maxBlocks = 2; - config.discardPolicy = SolidSyslogDiscardPolicy_Halt; - config.getCapacityThreshold = ReturnsConfiguredThreshold; - config.onThresholdCrossed = CountThresholdCrossings; + config.MaxBlockSize = MAX_MSG_RECORD + SLACK; + config.MaxBlocks = 2; + config.DiscardPolicy = SolidSyslogDiscardPolicy_Halt; + config.GetCapacityThreshold = ReturnsConfiguredThreshold; + config.OnThresholdCrossed = CountThresholdCrossings; thresholdReturnValue = 2 * (MAX_MSG_RECORD + SLACK); store = SolidSyslogBlockStore_Create(&storeStorage, &config); diff --git a/Tests/SolidSyslogCrc16PolicyTest.cpp b/Tests/SolidSyslogCrc16PolicyTest.cpp index ff264c50..ea722e38 100644 --- a/Tests/SolidSyslogCrc16PolicyTest.cpp +++ b/Tests/SolidSyslogCrc16PolicyTest.cpp @@ -30,7 +30,7 @@ TEST(SolidSyslogCrc16Policy, CreateReturnsNonNull) TEST(SolidSyslogCrc16Policy, IntegritySizeIsTwo) { - LONGS_EQUAL(2, policy->integritySize); + LONGS_EQUAL(2, policy->IntegritySize); } TEST(SolidSyslogCrc16Policy, ComputeIntegrityReturnsCrc16) diff --git a/Tests/SolidSyslogMetaSdTest.cpp b/Tests/SolidSyslogMetaSdTest.cpp index 05b1edf8..d396a763 100644 --- a/Tests/SolidSyslogMetaSdTest.cpp +++ b/Tests/SolidSyslogMetaSdTest.cpp @@ -84,7 +84,7 @@ TEST_GROUP(SolidSyslogMetaSd) fakeLanguageContent = nullptr; fakeLanguageMaxLength = 0; config = {}; - config.counter = counter; + config.Counter = counter; sd = SolidSyslogMetaSd_Create(&config); } @@ -109,7 +109,7 @@ TEST_GROUP(SolidSyslogMetaSd) void useSysUpTime(uint32_t value) { fakeSysUpTimeValue = value; - config.getSysUpTime = FakeSysUpTime_Get; + config.GetSysUpTime = FakeSysUpTime_Get; recreate(); } @@ -117,7 +117,7 @@ TEST_GROUP(SolidSyslogMetaSd) { fakeLanguageContent = tag; fakeLanguageMaxLength = strlen(tag); - config.getLanguage = FakeLanguage_Get; + config.GetLanguage = FakeLanguage_Get; recreate(); } @@ -251,7 +251,7 @@ TEST(SolidSyslogMetaSd, FormatWithAllThreeParamsEmitsAllThree) TEST(SolidSyslogMetaSd, FormatEmitsNothingWhenConfigCounterIsNullEvenIfOtherFieldsPresent) { - config.counter = nullptr; + config.Counter = nullptr; useSysUpTime(12345); useLanguage("en-GB"); format(); @@ -276,10 +276,10 @@ TEST(SolidSyslogMetaSd, CreateWithNullConfigReportsWarning) TEST(SolidSyslogMetaSd, CreateWithNullCounterReportsWarning) { - config.counter = nullptr; + config.Counter = nullptr; recreate(); CALLED_FAKE(ErrorHandlerFake_Handle, ONCE); LONGS_EQUAL(SolidSyslogSeverity_Warning, ErrorHandlerFake_LastSeverity()); - STRCMP_EQUAL("SolidSyslogMetaSd_Create config.counter is NULL", ErrorHandlerFake_LastMessage()); + STRCMP_EQUAL("SolidSyslogMetaSd_Create config.Counter is NULL", ErrorHandlerFake_LastMessage()); } diff --git a/Tests/SolidSyslogNullSecurityPolicyTest.cpp b/Tests/SolidSyslogNullSecurityPolicyTest.cpp index cda56148..53b7cf90 100644 --- a/Tests/SolidSyslogNullSecurityPolicyTest.cpp +++ b/Tests/SolidSyslogNullSecurityPolicyTest.cpp @@ -28,7 +28,7 @@ TEST(SolidSyslogNullSecurityPolicy, CreateReturnsNonNull) TEST(SolidSyslogNullSecurityPolicy, IntegritySizeIsZero) { - LONGS_EQUAL(0, policy->integritySize); + LONGS_EQUAL(0, policy->IntegritySize); } TEST(SolidSyslogNullSecurityPolicy, VerifyIntegrityReturnsTrue) diff --git a/Tests/SolidSyslogOriginSdTest.cpp b/Tests/SolidSyslogOriginSdTest.cpp index 4eff1127..b89a0ed0 100644 --- a/Tests/SolidSyslogOriginSdTest.cpp +++ b/Tests/SolidSyslogOriginSdTest.cpp @@ -87,8 +87,8 @@ TEST_GROUP(SolidSyslogOriginSd) { formatter = SolidSyslogFormatter_Create(storage, TEST_BUFFER_SIZE); config = {}; - config.software = "TestSoftware"; - config.swVersion = "9.8.7"; + config.Software = "TestSoftware"; + config.SwVersion = "9.8.7"; fakeIpCount = 0; sd = SolidSyslogOriginSd_Create(&config); } @@ -102,15 +102,15 @@ TEST_GROUP(SolidSyslogOriginSd) void recreate(const char* software, const char* swVersion) { SolidSyslogOriginSd_Destroy(); - config.software = software; - config.swVersion = swVersion; + config.Software = software; + config.SwVersion = swVersion; sd = SolidSyslogOriginSd_Create(&config); } void useEnterpriseId(const char* enterpriseId) { SolidSyslogOriginSd_Destroy(); - config.enterpriseId = enterpriseId; + config.EnterpriseId = enterpriseId; sd = SolidSyslogOriginSd_Create(&config); } @@ -123,8 +123,8 @@ TEST_GROUP(SolidSyslogOriginSd) { fakeIps.at(i++) = ip; } - config.getIpCount = FakeIpCount; - config.getIpAt = FakeIpAt; + config.GetIpCount = FakeIpCount; + config.GetIpAt = FakeIpAt; sd = SolidSyslogOriginSd_Create(&config); } @@ -422,8 +422,8 @@ TEST(SolidSyslogOriginSd, IpContainingSpecialsIsEscaped) TEST(SolidSyslogOriginSd, GetIpCountSetButGetIpAtNullOmitsIpParams) { SolidSyslogOriginSd_Destroy(); - config.getIpCount = FakeIpCount; - config.getIpAt = nullptr; + config.GetIpCount = FakeIpCount; + config.GetIpAt = nullptr; sd = SolidSyslogOriginSd_Create(&config); resetFormatter(); format(); @@ -436,8 +436,8 @@ TEST(SolidSyslogOriginSd, GetIpCountSetButGetIpAtNullOmitsIpParams) TEST(SolidSyslogOriginSd, GetIpAtSetButGetIpCountNullOmitsIpParams) { SolidSyslogOriginSd_Destroy(); - config.getIpCount = nullptr; - config.getIpAt = FakeIpAt; + config.GetIpCount = nullptr; + config.GetIpAt = FakeIpAt; sd = SolidSyslogOriginSd_Create(&config); resetFormatter(); format(); @@ -461,8 +461,8 @@ TEST(SolidSyslogOriginSd, AllFourParamsTogether) TEST(SolidSyslogOriginSd, EnterpriseIdOnlyNoStaticNoIps) { - config.software = nullptr; - config.swVersion = nullptr; + config.Software = nullptr; + config.SwVersion = nullptr; useEnterpriseId("1.3.6.1.4.1.12345"); resetFormatter(); format(); @@ -471,8 +471,8 @@ TEST(SolidSyslogOriginSd, EnterpriseIdOnlyNoStaticNoIps) TEST(SolidSyslogOriginSd, IpsOnlyNoStatic) { - config.software = nullptr; - config.swVersion = nullptr; + config.Software = nullptr; + config.SwVersion = nullptr; useIps({"192.0.2.1"}); resetFormatter(); format(); @@ -481,8 +481,8 @@ TEST(SolidSyslogOriginSd, IpsOnlyNoStatic) TEST(SolidSyslogOriginSd, EnterpriseIdAndIpsNoSoftwareSwVersion) { - config.software = nullptr; - config.swVersion = nullptr; + config.Software = nullptr; + config.SwVersion = nullptr; useEnterpriseId("1.3.6.1.4.1.12345"); useIps({"192.0.2.1"}); resetFormatter(); diff --git a/Tests/SolidSyslogPosixClockTest.cpp b/Tests/SolidSyslogPosixClockTest.cpp index 11d42354..ac9189c6 100644 --- a/Tests/SolidSyslogPosixClockTest.cpp +++ b/Tests/SolidSyslogPosixClockTest.cpp @@ -11,15 +11,15 @@ static const time_t TEST_EPOCH = 1743552000; // clang-format off // NOLINTBEGIN(cppcoreguidelines-macro-usage) -- macros preserve __FILE__/__LINE__ in test failure output #define GET_TIMESTAMP() getTimestamp() -#define CHECK_YEAR(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().year) -#define CHECK_MONTH(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().month) -#define CHECK_DAY(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().day) -#define CHECK_HOUR(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().hour) -#define CHECK_MINUTE(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().minute) -#define CHECK_SECOND(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().second) -#define CHECK_MICROSECOND(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().microsecond) -#define CHECK_UTC_OFFSET(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().utcOffsetMinutes) -#define CHECK_MONTH_IS_INVALID() LONGS_EQUAL(0, GET_TIMESTAMP().month) +#define CHECK_YEAR(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().Year) +#define CHECK_MONTH(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().Month) +#define CHECK_DAY(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().Day) +#define CHECK_HOUR(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().Hour) +#define CHECK_MINUTE(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().Minute) +#define CHECK_SECOND(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().Second) +#define CHECK_MICROSECOND(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().Microsecond) +#define CHECK_UTC_OFFSET(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().UtcOffsetMinutes) +#define CHECK_MONTH_IS_INVALID() LONGS_EQUAL(0, GET_TIMESTAMP().Month) // NOLINTEND(cppcoreguidelines-macro-usage) // clang-format on @@ -174,12 +174,12 @@ TEST(SolidSyslogPosixClock, NoY2038LimitOnThisPlatform) TEST(SolidSyslogPosixClock, AllFieldsInValidRanges) { struct SolidSyslogTimestamp ts = getTimestamp(); - CHECK(ts.year > 0); - CHECK((ts.month >= 1) && (ts.month <= 12)); - CHECK((ts.day >= 1) && (ts.day <= 31)); - CHECK(ts.hour <= 23); - CHECK(ts.minute <= 59); - CHECK(ts.second <= 59); - CHECK(ts.microsecond <= 999999); - LONGS_EQUAL(0, ts.utcOffsetMinutes); + CHECK(ts.Year > 0); + CHECK((ts.Month >= 1) && (ts.Month <= 12)); + CHECK((ts.Day >= 1) && (ts.Day <= 31)); + CHECK(ts.Hour <= 23); + CHECK(ts.Minute <= 59); + CHECK(ts.Second <= 59); + CHECK(ts.Microsecond <= 999999); + LONGS_EQUAL(0, ts.UtcOffsetMinutes); } diff --git a/Tests/SolidSyslogStreamSenderTest.cpp b/Tests/SolidSyslogStreamSenderTest.cpp index dceca31d..3251b96d 100644 --- a/Tests/SolidSyslogStreamSenderTest.cpp +++ b/Tests/SolidSyslogStreamSenderTest.cpp @@ -73,8 +73,8 @@ static uint32_t endpointVersion = 0; static void TestEndpoint(struct SolidSyslogEndpoint* endpoint) { - SolidSyslogFormatter_BoundedString(endpoint->host, endpointGetHost(), SOLIDSYSLOG_MAX_HOST_SIZE); - endpoint->port = (uint16_t) endpointGetPort(); + SolidSyslogFormatter_BoundedString(endpoint->Host, endpointGetHost(), SOLIDSYSLOG_MAX_HOST_SIZE); + endpoint->Port = (uint16_t) endpointGetPort(); } static uint32_t TestEndpointVersion() // NOLINT(modernize-use-trailing-return-type) diff --git a/Tests/SolidSyslogTest.cpp b/Tests/SolidSyslogTest.cpp index 7780af40..f96f4f67 100644 --- a/Tests/SolidSyslogTest.cpp +++ b/Tests/SolidSyslogTest.cpp @@ -418,42 +418,42 @@ TEST(SolidSyslog, PriValIs134) TEST(SolidSyslog, FacilityAppearsInPrival) { - message.facility = SolidSyslogFacility_News; + message.Facility = SolidSyslogFacility_News; Log(); CHECK_PRIVAL("<62>"); } TEST(SolidSyslog, SeverityAppearsInPrival) { - message.severity = SolidSyslogSeverity_Critical; + message.Severity = SolidSyslogSeverity_Critical; Log(); CHECK_PRIVAL("<130>"); } TEST(SolidSyslog, LowestFacilityProducesCorrectPrival) { - message.facility = SolidSyslogFacility_Kern; + message.Facility = SolidSyslogFacility_Kern; Log(); CHECK_PRIVAL("<6>"); } TEST(SolidSyslog, HighestFacilityProducesCorrectPrival) { - message.facility = SolidSyslogFacility_Local7; + message.Facility = SolidSyslogFacility_Local7; Log(); CHECK_PRIVAL("<190>"); } TEST(SolidSyslog, LowestSeverityProducesCorrectPrival) { - message.severity = SolidSyslogSeverity_Emergency; + message.Severity = SolidSyslogSeverity_Emergency; Log(); CHECK_PRIVAL("<128>"); } TEST(SolidSyslog, HighestSeverityProducesCorrectPrival) { - message.severity = SolidSyslogSeverity_Debug; + message.Severity = SolidSyslogSeverity_Debug; Log(); CHECK_PRIVAL("<135>"); } @@ -461,7 +461,7 @@ TEST(SolidSyslog, HighestSeverityProducesCorrectPrival) TEST(SolidSyslog, OutOfRangeFacilityProducesErrorPrival) { // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange) -- intentionally testing out-of-range input - message.facility = (enum SolidSyslogFacility) 24; + message.Facility = (enum SolidSyslogFacility) 24; Log(); CHECK_PRIVAL("<43>"); } @@ -471,7 +471,7 @@ TEST(SolidSyslog, OutOfRangeSeverityProducesErrorPrival) enum SolidSyslogSeverity invalid = SolidSyslogSeverity_Debug; // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange) -- intentionally testing out-of-range input invalid = static_cast(static_cast(invalid) + 1); - message.severity = invalid; + message.Severity = invalid; Log(); CHECK_PRIVAL("<43>"); } @@ -486,7 +486,7 @@ TEST(SolidSyslog, VersionIs1) TEST(SolidSyslog, NullGetHostnameProducesNilvalue) { - config.getHostname = nullptr; + config.GetHostname = nullptr; SolidSyslog_Destroy(); SolidSyslog_Create(&config); Log(); @@ -512,7 +512,7 @@ TEST(SolidSyslog, HostnameCallbackIsInvokedPerLogCall) TEST(SolidSyslog, NullGetAppNameProducesNilvalue) { - config.getAppName = nullptr; + config.GetAppName = nullptr; SolidSyslog_Destroy(); SolidSyslog_Create(&config); Log(); @@ -538,7 +538,7 @@ TEST(SolidSyslog, AppNameCallbackIsInvokedPerLogCall) TEST(SolidSyslog, NullGetProcessIdProducesNilvalue) { - config.getProcessId = nullptr; + config.GetProcessId = nullptr; SolidSyslog_Destroy(); SolidSyslog_Create(&config); Log(); @@ -570,21 +570,21 @@ TEST(SolidSyslog, NullMessageIdProducesNilvalue) TEST(SolidSyslog, MessageIdAppearsInMessage) { - message.messageId = "ID47"; + message.MessageId = "ID47"; Log(); CHECK_MSGID("ID47"); } TEST(SolidSyslog, MessageIdIsNotHardCoded) { - message.messageId = TEST_MSGID; + message.MessageId = TEST_MSGID; Log(); CHECK_MSGID(TEST_MSGID); } TEST(SolidSyslog, EmptyMessageIdProducesNilvalue) { - message.messageId = ""; + message.MessageId = ""; Log(); CHECK_MSGID("-"); } @@ -592,7 +592,7 @@ TEST(SolidSyslog, EmptyMessageIdProducesNilvalue) TEST(SolidSyslog, MessageIdAt32CharsIsAccepted) { std::string maxMsgId(32, 'M'); - message.messageId = maxMsgId.c_str(); + message.MessageId = maxMsgId.c_str(); Log(); CHECK_MSGID(maxMsgId.c_str()); } @@ -600,7 +600,7 @@ TEST(SolidSyslog, MessageIdAt32CharsIsAccepted) TEST(SolidSyslog, MessageIdAt33CharsIsTruncatedTo32) { std::string longMsgId(33, 'M'); - message.messageId = longMsgId.c_str(); + message.MessageId = longMsgId.c_str(); Log(); std::string expected(32, 'M'); CHECK_MSGID(expected.c_str()); @@ -608,7 +608,7 @@ TEST(SolidSyslog, MessageIdAt33CharsIsTruncatedTo32) TEST(SolidSyslog, MessageIdNonPrintableByteIsSubstitutedWithQuestionMark) { - message.messageId = "a b"; + message.MessageId = "a b"; Log(); CHECK_MSGID("a?b"); } @@ -622,8 +622,8 @@ TEST(SolidSyslog, StructuredDataIsNilValue) TEST(SolidSyslog, InjectedSdObjectFormatIsCalledDuringLog) { SolidSyslogStructuredData* sdList[] = {&sdSpy}; - config.sd = sdList; - config.sdCount = 1; + config.Sd = sdList; + config.SdCount = 1; SolidSyslog_Destroy(); SolidSyslog_Create(&config); Log(); @@ -634,11 +634,11 @@ TEST(SolidSyslog, MetaSdProducesSequenceIdInStructuredData) { SolidSyslogAtomicCounter* counter = SolidSyslogAtomicCounter_Create(); SolidSyslogMetaSdConfig metaConfig{}; - metaConfig.counter = counter; + metaConfig.Counter = counter; SolidSyslogStructuredData* metaSd = SolidSyslogMetaSd_Create(&metaConfig); SolidSyslogStructuredData* sdList[] = {metaSd}; - config.sd = sdList; - config.sdCount = 1; + config.Sd = sdList; + config.SdCount = 1; SolidSyslog_Destroy(); SolidSyslog_Create(&config); Log(); @@ -651,11 +651,11 @@ TEST(SolidSyslog, MetaSdSequenceIdIncrementsAcrossLogCalls) { SolidSyslogAtomicCounter* counter = SolidSyslogAtomicCounter_Create(); SolidSyslogMetaSdConfig metaConfig{}; - metaConfig.counter = counter; + metaConfig.Counter = counter; SolidSyslogStructuredData* metaSd = SolidSyslogMetaSd_Create(&metaConfig); SolidSyslogStructuredData* sdList[] = {metaSd}; - config.sd = sdList; - config.sdCount = 1; + config.Sd = sdList; + config.SdCount = 1; SolidSyslog_Destroy(); SolidSyslog_Create(&config); Log(); @@ -669,14 +669,14 @@ TEST(SolidSyslog, MsgFieldPreservedWithMetaSd) { SolidSyslogAtomicCounter* counter = SolidSyslogAtomicCounter_Create(); SolidSyslogMetaSdConfig metaConfig{}; - metaConfig.counter = counter; + metaConfig.Counter = counter; SolidSyslogStructuredData* metaSd = SolidSyslogMetaSd_Create(&metaConfig); SolidSyslogStructuredData* sdList[] = {metaSd}; - config.sd = sdList; - config.sdCount = 1; + config.Sd = sdList; + config.SdCount = 1; SolidSyslog_Destroy(); SolidSyslog_Create(&config); - message.msg = "hello world"; + message.Msg = "hello world"; Log(); STRCMP_EQUAL("hello world", SyslogMsg(lastMessage()).c_str()); SolidSyslogMetaSd_Destroy(); @@ -686,8 +686,8 @@ TEST(SolidSyslog, MsgFieldPreservedWithMetaSd) TEST(SolidSyslog, MultipleSdItemsAreConcatenated) { SolidSyslogStructuredData* sdList[] = {&sdSpy, &sdSpy2}; - config.sd = sdList; - config.sdCount = 2; + config.Sd = sdList; + config.SdCount = 2; SolidSyslog_Destroy(); SolidSyslog_Create(&config); Log(); @@ -697,8 +697,8 @@ TEST(SolidSyslog, MultipleSdItemsAreConcatenated) TEST(SolidSyslog, SingleSdReturningZeroBytesProducesNilvalue) { SolidSyslogStructuredData* sdList[] = {&sdFail}; - config.sd = sdList; - config.sdCount = 1; + config.Sd = sdList; + config.SdCount = 1; SolidSyslog_Destroy(); SolidSyslog_Create(&config); Log(); @@ -708,8 +708,8 @@ TEST(SolidSyslog, SingleSdReturningZeroBytesProducesNilvalue) TEST(SolidSyslog, FailingSdIsSkippedWhenOtherSdSucceeds) { SolidSyslogStructuredData* sdList[] = {&sdFail, &sdSpy}; - config.sd = sdList; - config.sdCount = 2; + config.Sd = sdList; + config.SdCount = 2; SolidSyslog_Destroy(); SolidSyslog_Create(&config); Log(); @@ -719,8 +719,8 @@ TEST(SolidSyslog, FailingSdIsSkippedWhenOtherSdSucceeds) TEST(SolidSyslog, AllSdFailingProducesNilvalue) { SolidSyslogStructuredData* sdList[] = {&sdFail, &sdFail}; - config.sd = sdList; - config.sdCount = 2; + config.Sd = sdList; + config.SdCount = 2; SolidSyslog_Destroy(); SolidSyslog_Create(&config); Log(); @@ -731,12 +731,12 @@ TEST(SolidSyslog, MetaSdAndTimeQualitySdCoexistInSdArray) { SolidSyslogAtomicCounter* counter = SolidSyslogAtomicCounter_Create(); SolidSyslogMetaSdConfig metaConfig{}; - metaConfig.counter = counter; + metaConfig.Counter = counter; SolidSyslogStructuredData* metaSd = SolidSyslogMetaSd_Create(&metaConfig); SolidSyslogStructuredData* timeQuality = SolidSyslogTimeQualitySd_Create(IntegrationGetTimeQuality); SolidSyslogStructuredData* sdList[] = {metaSd, timeQuality}; - config.sd = sdList; - config.sdCount = 2; + config.Sd = sdList; + config.SdCount = 2; SolidSyslog_Destroy(); SolidSyslog_Create(&config); Log(); @@ -758,28 +758,28 @@ TEST(SolidSyslog, NullMessageOmitsMsgField) TEST(SolidSyslog, MessageBodyAppearsInMessage) { - message.msg = "system started"; + message.Msg = "system started"; Log(); STRCMP_EQUAL("system started", SyslogMsg(lastMessage()).c_str()); } TEST(SolidSyslog, MessageBodyIsPrecededByUtf8Bom) { - message.msg = "system started"; + message.Msg = "system started"; Log(); CHECK(SyslogMsgHasBom(lastMessage())); } TEST(SolidSyslog, CallerSuppliedBomIsStrippedSoOutputHasOnlyOne) { - message.msg = "\xEF\xBB\xBFsystem started"; + message.Msg = "\xEF\xBB\xBFsystem started"; Log(); STRCMP_EQUAL("system started", SyslogMsg(lastMessage()).c_str()); } TEST(SolidSyslog, EmptyMessageOmitsMsgField) { - message.msg = ""; + message.Msg = ""; Log(); CHECK_FALSE(SyslogMsgHasBom(lastMessage())); STRCMP_EQUAL("", SyslogMsg(lastMessage()).c_str()); @@ -787,14 +787,14 @@ TEST(SolidSyslog, EmptyMessageOmitsMsgField) TEST(SolidSyslog, MessageBodyIsNotHardCoded) { - message.msg = TEST_MSG; + message.Msg = TEST_MSG; Log(); STRCMP_EQUAL(TEST_MSG, SyslogMsg(lastMessage()).c_str()); } TEST(SolidSyslog, MessageWithSpacesIsPreserved) { - message.msg = "hello world with spaces"; + message.Msg = "hello world with spaces"; Log(); STRCMP_EQUAL("hello world with spaces", SyslogMsg(lastMessage()).c_str()); } @@ -804,7 +804,7 @@ TEST(SolidSyslog, MessageFillsRemainingBuffer) std::string header("<134>1 - - - - - - " + std::string(UTF8_BOM)); size_t maxMsg = SOLIDSYSLOG_MAX_MESSAGE_SIZE - header.size() - 1; std::string longMsg(maxMsg, 'X'); - message.msg = longMsg.c_str(); + message.Msg = longMsg.c_str(); Log(); STRCMP_EQUAL(longMsg.c_str(), SyslogMsg(lastMessage()).c_str()); } @@ -814,7 +814,7 @@ TEST(SolidSyslog, MessageTruncatedWhenExceedingBuffer) std::string header("<134>1 - - - - - - " + std::string(UTF8_BOM)); size_t maxMsg = SOLIDSYSLOG_MAX_MESSAGE_SIZE - header.size() - 1; std::string longMsg(maxMsg + 100, 'X'); - message.msg = longMsg.c_str(); + message.Msg = longMsg.c_str(); Log(); std::string expected(maxMsg, 'X'); STRCMP_EQUAL(expected.c_str(), SyslogMsg(lastMessage()).c_str()); @@ -826,7 +826,7 @@ TEST(SolidSyslog, BomIsPreservedWhenMessageBodyTruncates) * the body but the BOM — written before the body — must remain * present. Pins the FormatMsg ordering: BOM first, body second. */ std::string longMsg(SOLIDSYSLOG_MAX_MESSAGE_SIZE, 'X'); - message.msg = longMsg.c_str(); + message.Msg = longMsg.c_str(); Log(); CHECK(SyslogMsgHasBom(lastMessage())); } @@ -834,7 +834,7 @@ TEST(SolidSyslog, BomIsPreservedWhenMessageBodyTruncates) TEST(SolidSyslog, HugeMessageDoesNotCorruptMemory) { std::string hugeMsg(10000, 'Z'); - message.msg = hugeMsg.c_str(); + message.Msg = hugeMsg.c_str(); Log(); std::string result = SyslogMsg(lastMessage()); CHECK(result.size() <= SOLIDSYSLOG_MAX_MESSAGE_SIZE); @@ -865,7 +865,7 @@ TEST_GROUP_BASE(SolidSyslogTimestamp, TEST_GROUP_CppUTestGroupSolidSyslog) { TEST_GROUP_CppUTestGroupSolidSyslog::setup(); stubTimestamp = {TEST_YEAR, TEST_MONTH, TEST_DAY, TEST_HOUR, TEST_MINUTE, TEST_SECOND, TEST_MICROSECOND, TEST_UTC_OFFSET}; - config.clock = StubClock; + config.Clock = StubClock; SolidSyslog_Destroy(); SolidSyslog_Create(&config); } @@ -875,7 +875,7 @@ TEST_GROUP_BASE(SolidSyslogTimestamp, TEST_GROUP_CppUTestGroupSolidSyslog) TEST(SolidSyslogTimestamp, NullClockProducesNilvalue) { - config.clock = nullptr; + config.Clock = nullptr; SolidSyslog_Destroy(); SolidSyslog_Create(&config); Log(); @@ -884,49 +884,49 @@ TEST(SolidSyslogTimestamp, NullClockProducesNilvalue) TEST(SolidSyslogTimestamp, YearFormatsAsFourDigitZeroPadded) { - stubTimestamp.year = 2026; + stubTimestamp.Year = 2026; Log(); CHECK_TIMESTAMP_YEAR("2026"); } TEST(SolidSyslogTimestamp, MonthFormatsAsTwoDigitZeroPadded) { - stubTimestamp.month = 4; + stubTimestamp.Month = 4; Log(); CHECK_TIMESTAMP_MONTH("04"); } TEST(SolidSyslogTimestamp, DayFormatsAsTwoDigitZeroPadded) { - stubTimestamp.day = 2; + stubTimestamp.Day = 2; Log(); CHECK_TIMESTAMP_DAY("02"); } TEST(SolidSyslogTimestamp, HourFormatsAsTwoDigitZeroPadded) { - stubTimestamp.hour = 14; + stubTimestamp.Hour = 14; Log(); CHECK_TIMESTAMP_HOUR("14"); } TEST(SolidSyslogTimestamp, MinuteFormatsAsTwoDigitZeroPadded) { - stubTimestamp.minute = 30; + stubTimestamp.Minute = 30; Log(); CHECK_TIMESTAMP_MINUTE("30"); } TEST(SolidSyslogTimestamp, SecondFormatsAsTwoDigitZeroPadded) { - stubTimestamp.second = 7; + stubTimestamp.Second = 7; Log(); CHECK_TIMESTAMP_SECOND("07"); } TEST(SolidSyslogTimestamp, MicrosecondFormatsAsSixDigitZeroPadded) { - stubTimestamp.microsecond = 42; + stubTimestamp.Microsecond = 42; Log(); CHECK_TIMESTAMP_MICROSECOND(".000042"); } @@ -969,203 +969,203 @@ TEST(SolidSyslogTimestamp, TimestampAppearsInCorrectMessageFieldPosition) TEST(SolidSyslogTimestamp, ZeroOffsetFormatsAsZ) { - stubTimestamp.utcOffsetMinutes = 0; + stubTimestamp.UtcOffsetMinutes = 0; Log(); CHECK_TIMESTAMP_OFFSET("Z"); } TEST(SolidSyslogTimestamp, PositiveOffsetFormatsAsPlusHHMM) { - stubTimestamp.utcOffsetMinutes = 330; + stubTimestamp.UtcOffsetMinutes = 330; Log(); CHECK_TIMESTAMP_OFFSET("+05:30"); } TEST(SolidSyslogTimestamp, NegativeOffsetFormatsAsMinusHHMM) { - stubTimestamp.utcOffsetMinutes = -300; + stubTimestamp.UtcOffsetMinutes = -300; Log(); CHECK_TIMESTAMP_OFFSET("-05:00"); } TEST(SolidSyslogTimestamp, YearZeroFormatsAs0000) { - stubTimestamp.year = 0; + stubTimestamp.Year = 0; Log(); CHECK_TIMESTAMP_YEAR("0000"); } TEST(SolidSyslogTimestamp, Year9999FormatsAs9999) { - stubTimestamp.year = 9999; + stubTimestamp.Year = 9999; Log(); CHECK_TIMESTAMP_YEAR("9999"); } TEST(SolidSyslogTimestamp, Month1FormatsAs01) { - stubTimestamp.month = 1; + stubTimestamp.Month = 1; Log(); CHECK_TIMESTAMP_MONTH("01"); } TEST(SolidSyslogTimestamp, Month12FormatsAs12) { - stubTimestamp.month = 12; + stubTimestamp.Month = 12; Log(); CHECK_TIMESTAMP_MONTH("12"); } TEST(SolidSyslogTimestamp, Day1FormatsAs01) { - stubTimestamp.day = 1; + stubTimestamp.Day = 1; Log(); CHECK_TIMESTAMP_DAY("01"); } TEST(SolidSyslogTimestamp, Day31FormatsAs31) { - stubTimestamp.day = 31; + stubTimestamp.Day = 31; Log(); CHECK_TIMESTAMP_DAY("31"); } TEST(SolidSyslogTimestamp, Hour0FormatsAs00) { - stubTimestamp.hour = 0; + stubTimestamp.Hour = 0; Log(); CHECK_TIMESTAMP_HOUR("00"); } TEST(SolidSyslogTimestamp, Hour23FormatsAs23) { - stubTimestamp.hour = 23; + stubTimestamp.Hour = 23; Log(); CHECK_TIMESTAMP_HOUR("23"); } TEST(SolidSyslogTimestamp, Minute0FormatsAs00) { - stubTimestamp.minute = 0; + stubTimestamp.Minute = 0; Log(); CHECK_TIMESTAMP_MINUTE("00"); } TEST(SolidSyslogTimestamp, Minute59FormatsAs59) { - stubTimestamp.minute = 59; + stubTimestamp.Minute = 59; Log(); CHECK_TIMESTAMP_MINUTE("59"); } TEST(SolidSyslogTimestamp, Second0FormatsAs00) { - stubTimestamp.second = 0; + stubTimestamp.Second = 0; Log(); CHECK_TIMESTAMP_SECOND("00"); } TEST(SolidSyslogTimestamp, Second59FormatsAs59) { - stubTimestamp.second = 59; + stubTimestamp.Second = 59; Log(); CHECK_TIMESTAMP_SECOND("59"); } TEST(SolidSyslogTimestamp, Microsecond0FormatsAs000000) { - stubTimestamp.microsecond = 0; + stubTimestamp.Microsecond = 0; Log(); CHECK_TIMESTAMP_MICROSECOND(".000000"); } TEST(SolidSyslogTimestamp, Microsecond999999FormatsAs999999) { - stubTimestamp.microsecond = 999999; + stubTimestamp.Microsecond = 999999; Log(); CHECK_TIMESTAMP_MICROSECOND(".999999"); } TEST(SolidSyslogTimestamp, UtcOffsetPlus840FormatsAsPlus1400) { - stubTimestamp.utcOffsetMinutes = 840; + stubTimestamp.UtcOffsetMinutes = 840; Log(); CHECK_TIMESTAMP_OFFSET("+14:00"); } TEST(SolidSyslogTimestamp, UtcOffsetMinus720FormatsAsMinus1200) { - stubTimestamp.utcOffsetMinutes = -720; + stubTimestamp.UtcOffsetMinutes = -720; Log(); CHECK_TIMESTAMP_OFFSET("-12:00"); } TEST(SolidSyslogTimestamp, Month0ProducesNilvalue) { - stubTimestamp.month = 0; + stubTimestamp.Month = 0; Log(); CHECK_TIMESTAMP_IS_NILVALUE(); } TEST(SolidSyslogTimestamp, Month13ProducesNilvalue) { - stubTimestamp.month = 13; + stubTimestamp.Month = 13; Log(); CHECK_TIMESTAMP_IS_NILVALUE(); } TEST(SolidSyslogTimestamp, Day0ProducesNilvalue) { - stubTimestamp.day = 0; + stubTimestamp.Day = 0; Log(); CHECK_TIMESTAMP_IS_NILVALUE(); } TEST(SolidSyslogTimestamp, Day32ProducesNilvalue) { - stubTimestamp.day = 32; + stubTimestamp.Day = 32; Log(); CHECK_TIMESTAMP_IS_NILVALUE(); } TEST(SolidSyslogTimestamp, Hour24ProducesNilvalue) { - stubTimestamp.hour = 24; + stubTimestamp.Hour = 24; Log(); CHECK_TIMESTAMP_IS_NILVALUE(); } TEST(SolidSyslogTimestamp, Minute60ProducesNilvalue) { - stubTimestamp.minute = 60; + stubTimestamp.Minute = 60; Log(); CHECK_TIMESTAMP_IS_NILVALUE(); } TEST(SolidSyslogTimestamp, Second60ProducesNilvalue) { - stubTimestamp.second = 60; + stubTimestamp.Second = 60; Log(); CHECK_TIMESTAMP_IS_NILVALUE(); } TEST(SolidSyslogTimestamp, Microsecond1000000ProducesNilvalue) { - stubTimestamp.microsecond = 1000000; + stubTimestamp.Microsecond = 1000000; Log(); CHECK_TIMESTAMP_IS_NILVALUE(); } TEST(SolidSyslogTimestamp, UtcOffsetPlus841ProducesNilvalue) { - stubTimestamp.utcOffsetMinutes = 841; + stubTimestamp.UtcOffsetMinutes = 841; Log(); CHECK_TIMESTAMP_IS_NILVALUE(); } TEST(SolidSyslogTimestamp, UtcOffsetMinus721ProducesNilvalue) { - stubTimestamp.utcOffsetMinutes = -721; + stubTimestamp.UtcOffsetMinutes = -721; Log(); CHECK_TIMESTAMP_IS_NILVALUE(); } @@ -1254,11 +1254,11 @@ TEST(SolidSyslog, AllFieldsAtMaxLengthProducesValidMessage) StringFake_SetAppName(maxAppName.c_str()); StringFake_SetProcessId(maxProcessId.c_str()); stubTimestamp = {9999, 12, 31, 23, 59, 59, 999999, 840}; - config.clock = StubClock; + config.Clock = StubClock; SolidSyslog_Destroy(); SolidSyslog_Create(&config); - message.facility = SolidSyslogFacility_Local7; - message.severity = SolidSyslogSeverity_Debug; + message.Facility = SolidSyslogFacility_Local7; + message.Severity = SolidSyslogSeverity_Debug; Log(); CHECK_PRIVAL("<191>"); CHECK_TIMESTAMP("9999-12-31T23:59:59.999999+14:00"); @@ -1546,9 +1546,9 @@ TEST_GROUP(SolidSyslogServiceEagerDrain) fakeStore = StoreFake_Create(); SolidSyslogConfig serviceConfig = {}; - serviceConfig.buffer = circularBuffer; - serviceConfig.sender = fakeSender; - serviceConfig.store = fakeStore; + serviceConfig.Buffer = circularBuffer; + serviceConfig.Sender = fakeSender; + serviceConfig.Store = fakeStore; SolidSyslog_Create(&serviceConfig); } @@ -1726,7 +1726,7 @@ TEST(SolidSyslogLifecycle, CreateWithNullBufferReportsError) { ErrorHandlerFake_Install(nullptr); SolidSyslogConfig config = validConfig(); - config.buffer = nullptr; + config.Buffer = nullptr; SolidSyslog_Create(&config); @@ -1737,7 +1737,7 @@ TEST(SolidSyslogLifecycle, CreateWithNullSenderReportsError) { ErrorHandlerFake_Install(nullptr); SolidSyslogConfig config = validConfig(); - config.sender = nullptr; + config.Sender = nullptr; SolidSyslog_Create(&config); @@ -1748,7 +1748,7 @@ TEST(SolidSyslogLifecycle, CreateWithNullStoreReportsError) { ErrorHandlerFake_Install(nullptr); SolidSyslogConfig config = validConfig(); - config.store = nullptr; + config.Store = nullptr; SolidSyslog_Create(&config); @@ -1758,7 +1758,7 @@ TEST(SolidSyslogLifecycle, CreateWithNullStoreReportsError) TEST(SolidSyslogLifecycle, ServiceWithNilStoreDrainsThroughToRealSender) { SolidSyslogConfig config = validConfig(); - config.store = nullptr; + config.Store = nullptr; SolidSyslog_Create(&config); SolidSyslog_Log(&message); @@ -1770,7 +1770,7 @@ TEST(SolidSyslogLifecycle, ServiceWithNilStoreDrainsThroughToRealSender) TEST(SolidSyslogLifecycle, ServiceWithNilSenderReportsNilSenderUsed) { SolidSyslogConfig config = validConfig(); - config.sender = nullptr; + config.Sender = nullptr; SolidSyslog_Create(&config); SolidSyslog_Log(&message); ErrorHandlerFake_Install(nullptr); @@ -1783,7 +1783,7 @@ TEST(SolidSyslogLifecycle, ServiceWithNilSenderReportsNilSenderUsed) TEST(SolidSyslogLifecycle, RepeatedServiceWithNilSenderReportsNilSenderUsedOnlyOnce) { SolidSyslogConfig config = validConfig(); - config.sender = nullptr; + config.Sender = nullptr; SolidSyslog_Create(&config); SolidSyslog_Log(&message); SolidSyslog_Service(); @@ -1814,7 +1814,7 @@ TEST(SolidSyslogLifecycle, SecondCreateLeavesFirstConfigInstalled) SolidSyslog_Create(&firstConfig); SolidSyslogSender* otherSender = SenderFake_Create(); SolidSyslogConfig secondConfig = validConfig(); - secondConfig.sender = otherSender; + secondConfig.Sender = otherSender; SolidSyslog_Create(&secondConfig); SolidSyslog_Log(&message); @@ -1856,7 +1856,7 @@ TEST(SolidSyslogLifecycle, DestroyClearsInitialisedFlagSoCreateSucceedsAgain) TEST(SolidSyslogLifecycle, DestroyReArmsNilSenderReporter) { SolidSyslogConfig config = validConfig(); - config.sender = nullptr; + config.Sender = nullptr; SolidSyslog_Create(&config); SolidSyslog_Log(&message); SolidSyslog_Service(); diff --git a/Tests/SolidSyslogTimeQualitySdTest.cpp b/Tests/SolidSyslogTimeQualitySdTest.cpp index 07f9b3e4..e9edd35f 100644 --- a/Tests/SolidSyslogTimeQualitySdTest.cpp +++ b/Tests/SolidSyslogTimeQualitySdTest.cpp @@ -69,15 +69,15 @@ TEST(SolidSyslogTimeQualitySd, FormatProducesTzKnownAndIsSynced) TEST(SolidSyslogTimeQualitySd, FormatWithFalseValues) { - stubTimeQuality.tzKnown = false; - stubTimeQuality.isSynced = false; + stubTimeQuality.TzKnown = false; + stubTimeQuality.IsSynced = false; format(); STRCMP_EQUAL("[timeQuality tzKnown=\"0\" isSynced=\"0\"]", SolidSyslogFormatter_AsFormattedBuffer(formatter)); } TEST(SolidSyslogTimeQualitySd, FormatIncludesSyncAccuracyWhenNonZero) { - stubTimeQuality.syncAccuracyMicroseconds = 50; + stubTimeQuality.SyncAccuracyMicroseconds = 50; format(); STRCMP_EQUAL( "[timeQuality tzKnown=\"1\" isSynced=\"1\" syncAccuracy=\"50\"]", @@ -87,7 +87,7 @@ TEST(SolidSyslogTimeQualitySd, FormatIncludesSyncAccuracyWhenNonZero) TEST(SolidSyslogTimeQualitySd, SyncAccuracyOfOneIsSmallestNonOmitValue) { - stubTimeQuality.syncAccuracyMicroseconds = 1; + stubTimeQuality.SyncAccuracyMicroseconds = 1; format(); STRCMP_EQUAL( "[timeQuality tzKnown=\"1\" isSynced=\"1\" syncAccuracy=\"1\"]", @@ -97,7 +97,7 @@ TEST(SolidSyslogTimeQualitySd, SyncAccuracyOfOneIsSmallestNonOmitValue) TEST(SolidSyslogTimeQualitySd, SyncAccuracyAtMaxUint32) { - stubTimeQuality.syncAccuracyMicroseconds = UINT32_MAX; + stubTimeQuality.SyncAccuracyMicroseconds = UINT32_MAX; format(); STRCMP_EQUAL( "[timeQuality tzKnown=\"1\" isSynced=\"1\" syncAccuracy=\"4294967295\"]", @@ -107,7 +107,7 @@ TEST(SolidSyslogTimeQualitySd, SyncAccuracyAtMaxUint32) TEST(SolidSyslogTimeQualitySd, OmitSyncAccuracyUsesDefinedConstant) { - stubTimeQuality.syncAccuracyMicroseconds = SOLIDSYSLOG_SYNC_ACCURACY_OMIT; + stubTimeQuality.SyncAccuracyMicroseconds = SOLIDSYSLOG_SYNC_ACCURACY_OMIT; format(); STRCMP_EQUAL("[timeQuality tzKnown=\"1\" isSynced=\"1\"]", SolidSyslogFormatter_AsFormattedBuffer(formatter)); } @@ -117,7 +117,7 @@ TEST(SolidSyslogTimeQualitySd, CallbackIsInvokedOnEachFormat) format(); STRCMP_EQUAL("[timeQuality tzKnown=\"1\" isSynced=\"1\"]", SolidSyslogFormatter_AsFormattedBuffer(formatter)); - stubTimeQuality.isSynced = false; + stubTimeQuality.IsSynced = false; resetFormatter(); format(); STRCMP_EQUAL("[timeQuality tzKnown=\"1\" isSynced=\"0\"]", SolidSyslogFormatter_AsFormattedBuffer(formatter)); @@ -133,7 +133,7 @@ TEST(SolidSyslogTimeQualitySd, FormatAdvancesFormatterLength) TEST(SolidSyslogTimeQualitySd, FormatAdvancesLengthWithSyncAccuracy) { - stubTimeQuality.syncAccuracyMicroseconds = 50; + stubTimeQuality.SyncAccuracyMicroseconds = 50; format(); LONGS_EQUAL(strlen(SolidSyslogFormatter_AsFormattedBuffer(formatter)), SolidSyslogFormatter_Length(formatter)); } diff --git a/Tests/SolidSyslogTlsStreamTest.cpp b/Tests/SolidSyslogTlsStreamTest.cpp index 00a40b6d..8cffd4a4 100644 --- a/Tests/SolidSyslogTlsStreamTest.cpp +++ b/Tests/SolidSyslogTlsStreamTest.cpp @@ -45,8 +45,8 @@ TEST_GROUP(SolidSyslogTlsStream) NoOpSleepCallCount = 0; g_lastSleepMs = 0; transport = StreamFake_Create(); - config.transport = transport; - config.sleep = NoOpSleep; + config.Transport = transport; + config.Sleep = NoOpSleep; // cppcheck-suppress unreadVariable -- used across TEST_GROUP methods; cppcheck does not model CppUTest macros stream = SolidSyslogTlsStream_Create(&streamStorage, &config); // cppcheck-suppress unreadVariable -- used across TEST_GROUP methods; cppcheck does not model CppUTest macros @@ -168,7 +168,7 @@ TEST(SolidSyslogTlsStream, CreateReturnsHandleInsideCallerSuppliedStorage) { SolidSyslogTlsStreamStorage localStorage{}; struct SolidSyslogTlsStreamConfig localConfig = {}; - localConfig.transport = transport; + localConfig.Transport = transport; struct SolidSyslogStream* localStream = SolidSyslogTlsStream_Create(&localStorage, &localConfig); POINTERS_EQUAL(&localStorage, localStream); SolidSyslogTlsStream_Destroy(localStream); @@ -195,7 +195,7 @@ TEST(SolidSyslogTlsStream, OpenCreatesSslContext) TEST(SolidSyslogTlsStream, OpenLoadsCaBundleFromConfig) { SolidSyslogTlsStream_Destroy(stream); - config.caBundlePath = "/some/path/ca.pem"; + config.CaBundlePath = "/some/path/ca.pem"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); SolidSyslogStream_Open(stream, addr); STRCMP_EQUAL("/some/path/ca.pem", OpenSslFake_LastCaBundlePath()); @@ -216,7 +216,7 @@ TEST(SolidSyslogTlsStream, OpenSetsTls12Floor) TEST(SolidSyslogTlsStream, OpenPassesCipherListToSslCtx) { SolidSyslogTlsStream_Destroy(stream); - config.cipherList = "ECDHE+AESGCM"; + config.CipherList = "ECDHE+AESGCM"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); SolidSyslogStream_Open(stream, addr); STRCMP_EQUAL("ECDHE+AESGCM", OpenSslFake_LastCipherList()); @@ -231,7 +231,7 @@ TEST(SolidSyslogTlsStream, OpenSkipsCipherListSetupWhenNotConfigured) TEST(SolidSyslogTlsStream, OpenReturnsFalseWhenCipherListRejected) { SolidSyslogTlsStream_Destroy(stream); - config.cipherList = "not-a-real-cipher"; + config.CipherList = "not-a-real-cipher"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); OpenSslFake_SetCipherListFails(true); CHECK_FALSE(SolidSyslogStream_Open(stream, addr)); @@ -240,7 +240,7 @@ TEST(SolidSyslogTlsStream, OpenReturnsFalseWhenCipherListRejected) TEST(SolidSyslogTlsStream, CipherListFailureFreesCtx) { SolidSyslogTlsStream_Destroy(stream); - config.cipherList = "not-a-real-cipher"; + config.CipherList = "not-a-real-cipher"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); OpenSslFake_SetCipherListFails(true); SolidSyslogStream_Open(stream, addr); @@ -298,7 +298,7 @@ TEST(SolidSyslogTlsStream, OpenPassesSslToConnect) TEST(SolidSyslogTlsStream, OpenSetsSniHostnameFromConfig) { SolidSyslogTlsStream_Destroy(stream); - config.serverName = "logs.example"; + config.ServerName = "logs.example"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); SolidSyslogStream_Open(stream, addr); STRCMP_EQUAL("logs.example", OpenSslFake_LastSniHostname()); @@ -307,7 +307,7 @@ TEST(SolidSyslogTlsStream, OpenSetsSniHostnameFromConfig) TEST(SolidSyslogTlsStream, OpenSetsExpectedCertHostname) { SolidSyslogTlsStream_Destroy(stream); - config.serverName = "logs.example"; + config.ServerName = "logs.example"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); SolidSyslogStream_Open(stream, addr); STRCMP_EQUAL("logs.example", OpenSslFake_LastSet1Host()); @@ -315,7 +315,7 @@ TEST(SolidSyslogTlsStream, OpenSetsExpectedCertHostname) TEST(SolidSyslogTlsStream, OpenSkipsHostnameSetupWhenServerNameIsNull) { - /* Default config.serverName is NULL */ + /* Default config.ServerName is NULL */ SolidSyslogStream_Open(stream, addr); POINTERS_EQUAL(NULL, OpenSslFake_LastSet1Host()); } @@ -547,7 +547,7 @@ TEST(SolidSyslogTlsStream, OpenPassesSameBioForReadAndWrite) TEST(SolidSyslogTlsStream, OpenPassesSslToSniCtrl) { SolidSyslogTlsStream_Destroy(stream); - config.serverName = "logs.example"; + config.ServerName = "logs.example"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); SolidSyslogStream_Open(stream, addr); POINTERS_EQUAL(OpenSslFake_LastSslReturned(), OpenSslFake_LastSslCtrlSslArg()); @@ -556,7 +556,7 @@ TEST(SolidSyslogTlsStream, OpenPassesSslToSniCtrl) TEST(SolidSyslogTlsStream, OpenPassesSslFromNewToSet1Host) { SolidSyslogTlsStream_Destroy(stream); - config.serverName = "logs.example"; + config.ServerName = "logs.example"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); SolidSyslogStream_Open(stream, addr); POINTERS_EQUAL(OpenSslFake_LastSslReturned(), OpenSslFake_LastSet1HostSslArg()); @@ -610,7 +610,7 @@ TEST(SolidSyslogTlsStream, OpenReturnsFalseWhenHandshakeFails) TEST(SolidSyslogTlsStream, OpenReturnsFalseWhenSet1HostFails) { SolidSyslogTlsStream_Destroy(stream); - config.serverName = "logs.example"; + config.ServerName = "logs.example"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); OpenSslFake_SetSet1HostFails(true); CHECK_FALSE(SolidSyslogStream_Open(stream, addr)); @@ -619,7 +619,7 @@ TEST(SolidSyslogTlsStream, OpenReturnsFalseWhenSet1HostFails) TEST(SolidSyslogTlsStream, OpenReturnsFalseWhenSniHostnameSetupFails) { SolidSyslogTlsStream_Destroy(stream); - config.serverName = "logs.example"; + config.ServerName = "logs.example"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); OpenSslFake_SetSniHostnameFails(true); CHECK_FALSE(SolidSyslogStream_Open(stream, addr)); @@ -771,8 +771,8 @@ TEST(SolidSyslogTlsStream, OpenSkipsClientIdentityWhenBothPathsAreNull) TEST(SolidSyslogTlsStream, OpenLoadsClientCertChainFromConfig) { SolidSyslogTlsStream_Destroy(stream); - config.clientCertChainPath = "/some/path/client.pem"; - config.clientKeyPath = "/some/path/client.key"; + config.ClientCertChainPath = "/some/path/client.pem"; + config.ClientKeyPath = "/some/path/client.key"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); SolidSyslogStream_Open(stream, addr); STRCMP_EQUAL("/some/path/client.pem", OpenSslFake_LastClientCertChainPath()); @@ -781,8 +781,8 @@ TEST(SolidSyslogTlsStream, OpenLoadsClientCertChainFromConfig) TEST(SolidSyslogTlsStream, OpenLoadsClientKeyFromConfig) { SolidSyslogTlsStream_Destroy(stream); - config.clientCertChainPath = "/some/path/client.pem"; - config.clientKeyPath = "/some/path/client.key"; + config.ClientCertChainPath = "/some/path/client.pem"; + config.ClientKeyPath = "/some/path/client.key"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); SolidSyslogStream_Open(stream, addr); STRCMP_EQUAL("/some/path/client.key", OpenSslFake_LastClientKeyPath()); @@ -792,8 +792,8 @@ TEST(SolidSyslogTlsStream, OpenLoadsClientKeyFromConfig) TEST(SolidSyslogTlsStream, OpenChecksClientKeyMatchesCert) { SolidSyslogTlsStream_Destroy(stream); - config.clientCertChainPath = "/some/path/client.pem"; - config.clientKeyPath = "/some/path/client.key"; + config.ClientCertChainPath = "/some/path/client.pem"; + config.ClientKeyPath = "/some/path/client.key"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); SolidSyslogStream_Open(stream, addr); CALLED_FAKE(OpenSslFake_CheckPrivateKey, ONCE); @@ -802,8 +802,8 @@ TEST(SolidSyslogTlsStream, OpenChecksClientKeyMatchesCert) TEST(SolidSyslogTlsStream, OpenFailsWhenOnlyClientCertIsSet) { SolidSyslogTlsStream_Destroy(stream); - config.clientCertChainPath = "/some/path/client.pem"; - config.clientKeyPath = nullptr; + config.ClientCertChainPath = "/some/path/client.pem"; + config.ClientKeyPath = nullptr; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); CHECK_FALSE(SolidSyslogStream_Open(stream, addr)); } @@ -811,8 +811,8 @@ TEST(SolidSyslogTlsStream, OpenFailsWhenOnlyClientCertIsSet) TEST(SolidSyslogTlsStream, OpenMakesNoClientIdentityCallsWhenOnlyClientCertIsSet) { SolidSyslogTlsStream_Destroy(stream); - config.clientCertChainPath = "/some/path/client.pem"; - config.clientKeyPath = nullptr; + config.ClientCertChainPath = "/some/path/client.pem"; + config.ClientKeyPath = nullptr; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); SolidSyslogStream_Open(stream, addr); CALLED_FAKE(OpenSslFake_UseCertChainFile, NEVER); @@ -823,8 +823,8 @@ TEST(SolidSyslogTlsStream, OpenMakesNoClientIdentityCallsWhenOnlyClientCertIsSet TEST(SolidSyslogTlsStream, OpenFailsWhenOnlyClientKeyIsSet) { SolidSyslogTlsStream_Destroy(stream); - config.clientCertChainPath = nullptr; - config.clientKeyPath = "/some/path/client.key"; + config.ClientCertChainPath = nullptr; + config.ClientKeyPath = "/some/path/client.key"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); CHECK_FALSE(SolidSyslogStream_Open(stream, addr)); } @@ -832,8 +832,8 @@ TEST(SolidSyslogTlsStream, OpenFailsWhenOnlyClientKeyIsSet) TEST(SolidSyslogTlsStream, OpenMakesNoClientIdentityCallsWhenOnlyClientKeyIsSet) { SolidSyslogTlsStream_Destroy(stream); - config.clientCertChainPath = nullptr; - config.clientKeyPath = "/some/path/client.key"; + config.ClientCertChainPath = nullptr; + config.ClientKeyPath = "/some/path/client.key"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); SolidSyslogStream_Open(stream, addr); CALLED_FAKE(OpenSslFake_UseCertChainFile, NEVER); @@ -844,8 +844,8 @@ TEST(SolidSyslogTlsStream, OpenMakesNoClientIdentityCallsWhenOnlyClientKeyIsSet) TEST(SolidSyslogTlsStream, PartialClientIdentityConfigFreesCtx) { SolidSyslogTlsStream_Destroy(stream); - config.clientCertChainPath = "/some/path/client.pem"; - config.clientKeyPath = nullptr; + config.ClientCertChainPath = "/some/path/client.pem"; + config.ClientKeyPath = nullptr; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); SolidSyslogStream_Open(stream, addr); CALLED_FAKE(OpenSslFake_CtxFree, ONCE); @@ -854,8 +854,8 @@ TEST(SolidSyslogTlsStream, PartialClientIdentityConfigFreesCtx) TEST(SolidSyslogTlsStream, OpenReturnsFalseWhenUseCertChainFileFails) { SolidSyslogTlsStream_Destroy(stream); - config.clientCertChainPath = "/some/path/client.pem"; - config.clientKeyPath = "/some/path/client.key"; + config.ClientCertChainPath = "/some/path/client.pem"; + config.ClientKeyPath = "/some/path/client.key"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); OpenSslFake_SetUseCertChainFileFails(true); CHECK_FALSE(SolidSyslogStream_Open(stream, addr)); @@ -864,8 +864,8 @@ TEST(SolidSyslogTlsStream, OpenReturnsFalseWhenUseCertChainFileFails) TEST(SolidSyslogTlsStream, UseCertChainFileFailureFreesCtx) { SolidSyslogTlsStream_Destroy(stream); - config.clientCertChainPath = "/some/path/client.pem"; - config.clientKeyPath = "/some/path/client.key"; + config.ClientCertChainPath = "/some/path/client.pem"; + config.ClientKeyPath = "/some/path/client.key"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); OpenSslFake_SetUseCertChainFileFails(true); SolidSyslogStream_Open(stream, addr); @@ -875,8 +875,8 @@ TEST(SolidSyslogTlsStream, UseCertChainFileFailureFreesCtx) TEST(SolidSyslogTlsStream, OpenReturnsFalseWhenUsePrivateKeyFileFails) { SolidSyslogTlsStream_Destroy(stream); - config.clientCertChainPath = "/some/path/client.pem"; - config.clientKeyPath = "/some/path/client.key"; + config.ClientCertChainPath = "/some/path/client.pem"; + config.ClientKeyPath = "/some/path/client.key"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); OpenSslFake_SetUsePrivateKeyFileFails(true); CHECK_FALSE(SolidSyslogStream_Open(stream, addr)); @@ -885,8 +885,8 @@ TEST(SolidSyslogTlsStream, OpenReturnsFalseWhenUsePrivateKeyFileFails) TEST(SolidSyslogTlsStream, UsePrivateKeyFileFailureFreesCtx) { SolidSyslogTlsStream_Destroy(stream); - config.clientCertChainPath = "/some/path/client.pem"; - config.clientKeyPath = "/some/path/client.key"; + config.ClientCertChainPath = "/some/path/client.pem"; + config.ClientKeyPath = "/some/path/client.key"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); OpenSslFake_SetUsePrivateKeyFileFails(true); SolidSyslogStream_Open(stream, addr); @@ -896,8 +896,8 @@ TEST(SolidSyslogTlsStream, UsePrivateKeyFileFailureFreesCtx) TEST(SolidSyslogTlsStream, OpenReturnsFalseWhenCheckPrivateKeyFails) { SolidSyslogTlsStream_Destroy(stream); - config.clientCertChainPath = "/some/path/client.pem"; - config.clientKeyPath = "/some/path/client.key"; + config.ClientCertChainPath = "/some/path/client.pem"; + config.ClientKeyPath = "/some/path/client.key"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); OpenSslFake_SetCheckPrivateKeyFails(true); CHECK_FALSE(SolidSyslogStream_Open(stream, addr)); @@ -906,8 +906,8 @@ TEST(SolidSyslogTlsStream, OpenReturnsFalseWhenCheckPrivateKeyFails) TEST(SolidSyslogTlsStream, CheckPrivateKeyFailureFreesCtx) { SolidSyslogTlsStream_Destroy(stream); - config.clientCertChainPath = "/some/path/client.pem"; - config.clientKeyPath = "/some/path/client.key"; + config.ClientCertChainPath = "/some/path/client.pem"; + config.ClientKeyPath = "/some/path/client.key"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); OpenSslFake_SetCheckPrivateKeyFails(true); SolidSyslogStream_Open(stream, addr); @@ -917,8 +917,8 @@ TEST(SolidSyslogTlsStream, CheckPrivateKeyFailureFreesCtx) TEST(SolidSyslogTlsStream, OpenPassesCtxFromNewToUseCertChainFile) { SolidSyslogTlsStream_Destroy(stream); - config.clientCertChainPath = "/some/path/client.pem"; - config.clientKeyPath = "/some/path/client.key"; + config.ClientCertChainPath = "/some/path/client.pem"; + config.ClientKeyPath = "/some/path/client.key"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); SolidSyslogStream_Open(stream, addr); POINTERS_EQUAL(OpenSslFake_LastCtxReturned(), OpenSslFake_LastUseCertChainFileCtxArg()); @@ -927,8 +927,8 @@ TEST(SolidSyslogTlsStream, OpenPassesCtxFromNewToUseCertChainFile) TEST(SolidSyslogTlsStream, OpenPassesCtxFromNewToUsePrivateKeyFile) { SolidSyslogTlsStream_Destroy(stream); - config.clientCertChainPath = "/some/path/client.pem"; - config.clientKeyPath = "/some/path/client.key"; + config.ClientCertChainPath = "/some/path/client.pem"; + config.ClientKeyPath = "/some/path/client.key"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); SolidSyslogStream_Open(stream, addr); POINTERS_EQUAL(OpenSslFake_LastCtxReturned(), OpenSslFake_LastUsePrivateKeyFileCtxArg()); @@ -937,8 +937,8 @@ TEST(SolidSyslogTlsStream, OpenPassesCtxFromNewToUsePrivateKeyFile) TEST(SolidSyslogTlsStream, OpenPassesCtxFromNewToCheckPrivateKey) { SolidSyslogTlsStream_Destroy(stream); - config.clientCertChainPath = "/some/path/client.pem"; - config.clientKeyPath = "/some/path/client.key"; + config.ClientCertChainPath = "/some/path/client.pem"; + config.ClientKeyPath = "/some/path/client.key"; stream = SolidSyslogTlsStream_Create(&streamStorage, &config); SolidSyslogStream_Open(stream, addr); POINTERS_EQUAL(OpenSslFake_LastCtxReturned(), OpenSslFake_LastCheckPrivateKeyCtxArg()); diff --git a/Tests/SolidSyslogUdpSenderTest.cpp b/Tests/SolidSyslogUdpSenderTest.cpp index 055cbbdc..8f44943e 100644 --- a/Tests/SolidSyslogUdpSenderTest.cpp +++ b/Tests/SolidSyslogUdpSenderTest.cpp @@ -68,7 +68,7 @@ static int SpyGetPort() } // Endpoint stubs — file-scope because TestEndpoint is a free function that -// the sender invokes via udp->config.endpoint(). Tests mutate these globals +// the sender invokes via udp->config.Endpoint(). Tests mutate these globals // between Sends to drive endpoint-changed and callback-spy scenarios; the // TEST_BASE resets them in setup so groups don't leak state between tests. static const char* (*endpointGetHost)() = GetDefaultHost; @@ -77,8 +77,8 @@ static uint32_t endpointVersion = 0; static void TestEndpoint(struct SolidSyslogEndpoint* endpoint) { - SolidSyslogFormatter_BoundedString(endpoint->host, endpointGetHost(), SOLIDSYSLOG_MAX_HOST_SIZE); - endpoint->port = (uint16_t) endpointGetPort(); + SolidSyslogFormatter_BoundedString(endpoint->Host, endpointGetHost(), SOLIDSYSLOG_MAX_HOST_SIZE); + endpoint->Port = (uint16_t) endpointGetPort(); } static uint32_t TestEndpointVersion() // NOLINT(modernize-use-trailing-return-type) @@ -747,28 +747,28 @@ TEST(SolidSyslogUdpSenderBadSetup, DisconnectOnBadSetupSenderDoesNotCrash) TEST(SolidSyslogUdpSenderBadSetup, CreateWithNullResolverReportsError) { - config.resolver = nullptr; + config.Resolver = nullptr; SolidSyslogUdpSender_Create(&config); - CHECK_REPORTED_ERROR("SolidSyslogUdpSender_Create config.resolver is NULL"); + CHECK_REPORTED_ERROR("SolidSyslogUdpSender_Create config.Resolver is NULL"); } TEST(SolidSyslogUdpSenderBadSetup, CreateWithNullDatagramReportsError) { - config.datagram = nullptr; + config.Datagram = nullptr; SolidSyslogUdpSender_Create(&config); - CHECK_REPORTED_ERROR("SolidSyslogUdpSender_Create config.datagram is NULL"); + CHECK_REPORTED_ERROR("SolidSyslogUdpSender_Create config.Datagram is NULL"); } TEST(SolidSyslogUdpSenderBadSetup, CreateWithNullEndpointReportsError) { - config.endpoint = nullptr; + config.Endpoint = nullptr; SolidSyslogUdpSender_Create(&config); - CHECK_REPORTED_ERROR("SolidSyslogUdpSender_Create config.endpoint is NULL"); + CHECK_REPORTED_ERROR("SolidSyslogUdpSender_Create config.Endpoint is NULL"); } TEST(SolidSyslogUdpSenderBadSetup, NullEndpointVersionIsOptional) { - config.endpointVersion = nullptr; + config.EndpointVersion = nullptr; sender = SolidSyslogUdpSender_Create(&config); CHECK_NOTHING_REPORTED(); CHECK_TRUE(Send()); diff --git a/Tests/SolidSyslogWindowsClockTest.cpp b/Tests/SolidSyslogWindowsClockTest.cpp index ea68fd7d..57c71b14 100644 --- a/Tests/SolidSyslogWindowsClockTest.cpp +++ b/Tests/SolidSyslogWindowsClockTest.cpp @@ -24,15 +24,15 @@ static void WINAPI FakeGetSystemTimeAsFileTime(LPFILETIME fileTime) // clang-format off // NOLINTBEGIN(cppcoreguidelines-macro-usage) -- macros preserve __FILE__/__LINE__ in test failure output #define GET_TIMESTAMP() getTimestamp() -#define CHECK_YEAR(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().year) -#define CHECK_MONTH(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().month) -#define CHECK_DAY(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().day) -#define CHECK_HOUR(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().hour) -#define CHECK_MINUTE(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().minute) -#define CHECK_SECOND(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().second) -#define CHECK_MICROSECOND(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().microsecond) -#define CHECK_UTC_OFFSET(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().utcOffsetMinutes) -#define CHECK_MONTH_IS_INVALID() LONGS_EQUAL(0, GET_TIMESTAMP().month) +#define CHECK_YEAR(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().Year) +#define CHECK_MONTH(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().Month) +#define CHECK_DAY(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().Day) +#define CHECK_HOUR(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().Hour) +#define CHECK_MINUTE(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().Minute) +#define CHECK_SECOND(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().Second) +#define CHECK_MICROSECOND(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().Microsecond) +#define CHECK_UTC_OFFSET(expected) LONGS_EQUAL(expected, GET_TIMESTAMP().UtcOffsetMinutes) +#define CHECK_MONTH_IS_INVALID() LONGS_EQUAL(0, GET_TIMESTAMP().Month) // NOLINTEND(cppcoreguidelines-macro-usage) // clang-format on @@ -176,12 +176,12 @@ TEST(SolidSyslogWindowsClock, ZeroFileTimeProduces1601) TEST(SolidSyslogWindowsClock, AllFieldsInValidRanges) { struct SolidSyslogTimestamp ts = getTimestamp(); - CHECK(ts.year > 0); - CHECK((ts.month >= 1) && (ts.month <= 12)); - CHECK((ts.day >= 1) && (ts.day <= 31)); - CHECK(ts.hour <= 23); - CHECK(ts.minute <= 59); - CHECK(ts.second <= 59); - CHECK(ts.microsecond <= 999999); - LONGS_EQUAL(0, ts.utcOffsetMinutes); + CHECK(ts.Year > 0); + CHECK((ts.Month >= 1) && (ts.Month <= 12)); + CHECK((ts.Day >= 1) && (ts.Day <= 31)); + CHECK(ts.Hour <= 23); + CHECK(ts.Minute <= 59); + CHECK(ts.Second <= 59); + CHECK(ts.Microsecond <= 999999); + LONGS_EQUAL(0, ts.UtcOffsetMinutes); } diff --git a/Tests/StreamFake.c b/Tests/StreamFake.c index 6caaa4b1..dd88475a 100644 --- a/Tests/StreamFake.c +++ b/Tests/StreamFake.c @@ -5,61 +5,61 @@ struct StreamFake { - struct SolidSyslogStream base; - int openCallCount; - const struct SolidSyslogAddress* lastOpenAddr; - bool openFails; - int sendCallCount; - const void* lastSendBuf; - size_t lastSendSize; - bool sendFails; - int readCallCount; - void* lastReadBuf; - size_t lastReadSize; - SolidSyslogSsize readReturn; - int closeCallCount; + struct SolidSyslogStream Base; + int OpenCallCount; + const struct SolidSyslogAddress* LastOpenAddr; + bool OpenFails; + int SendCallCount; + const void* LastSendBuf; + size_t LastSendSize; + bool SendFails; + int ReadCallCount; + void* LastReadBuf; + size_t LastReadSize; + SolidSyslogSsize ReadReturn; + int CloseCallCount; }; static bool Open(struct SolidSyslogStream* self, const struct SolidSyslogAddress* addr) { struct StreamFake* fake = (struct StreamFake*) self; - fake->openCallCount++; - fake->lastOpenAddr = addr; - return !fake->openFails; + fake->OpenCallCount++; + fake->LastOpenAddr = addr; + return !fake->OpenFails; } static bool Send(struct SolidSyslogStream* self, const void* buffer, size_t size) { struct StreamFake* fake = (struct StreamFake*) self; - fake->sendCallCount++; - fake->lastSendBuf = buffer; - fake->lastSendSize = size; - return !fake->sendFails; + fake->SendCallCount++; + fake->LastSendBuf = buffer; + fake->LastSendSize = size; + return !fake->SendFails; } static SolidSyslogSsize Read(struct SolidSyslogStream* self, void* buffer, size_t size) { struct StreamFake* fake = (struct StreamFake*) self; - fake->readCallCount++; - fake->lastReadBuf = buffer; - fake->lastReadSize = size; - return fake->readReturn; + fake->ReadCallCount++; + fake->LastReadBuf = buffer; + fake->LastReadSize = size; + return fake->ReadReturn; } static void Close(struct SolidSyslogStream* self) { struct StreamFake* fake = (struct StreamFake*) self; - fake->closeCallCount++; + fake->CloseCallCount++; } struct SolidSyslogStream* StreamFake_Create(void) { struct StreamFake* fake = (struct StreamFake*) calloc(1, sizeof(struct StreamFake)); - fake->base.Open = Open; - fake->base.Send = Send; - fake->base.Read = Read; - fake->base.Close = Close; - return &fake->base; + fake->Base.Open = Open; + fake->Base.Send = Send; + fake->Base.Read = Read; + fake->Base.Close = Close; + return &fake->Base; } void StreamFake_Destroy(struct SolidSyslogStream* stream) @@ -69,60 +69,60 @@ void StreamFake_Destroy(struct SolidSyslogStream* stream) int StreamFake_OpenCallCount(struct SolidSyslogStream* stream) { - return ((struct StreamFake*) stream)->openCallCount; + return ((struct StreamFake*) stream)->OpenCallCount; } const struct SolidSyslogAddress* StreamFake_LastOpenAddr(struct SolidSyslogStream* stream) { - return ((struct StreamFake*) stream)->lastOpenAddr; + return ((struct StreamFake*) stream)->LastOpenAddr; } int StreamFake_SendCallCount(struct SolidSyslogStream* stream) { - return ((struct StreamFake*) stream)->sendCallCount; + return ((struct StreamFake*) stream)->SendCallCount; } const void* StreamFake_LastSendBuf(struct SolidSyslogStream* stream) { - return ((struct StreamFake*) stream)->lastSendBuf; + return ((struct StreamFake*) stream)->LastSendBuf; } size_t StreamFake_LastSendSize(struct SolidSyslogStream* stream) { - return ((struct StreamFake*) stream)->lastSendSize; + return ((struct StreamFake*) stream)->LastSendSize; } int StreamFake_ReadCallCount(struct SolidSyslogStream* stream) { - return ((struct StreamFake*) stream)->readCallCount; + return ((struct StreamFake*) stream)->ReadCallCount; } void* StreamFake_LastReadBuf(struct SolidSyslogStream* stream) { - return ((struct StreamFake*) stream)->lastReadBuf; + return ((struct StreamFake*) stream)->LastReadBuf; } size_t StreamFake_LastReadSize(struct SolidSyslogStream* stream) { - return ((struct StreamFake*) stream)->lastReadSize; + return ((struct StreamFake*) stream)->LastReadSize; } void StreamFake_SetReadReturn(struct SolidSyslogStream* stream, SolidSyslogSsize value) { - ((struct StreamFake*) stream)->readReturn = value; + ((struct StreamFake*) stream)->ReadReturn = value; } void StreamFake_SetOpenFails(struct SolidSyslogStream* stream, bool fails) { - ((struct StreamFake*) stream)->openFails = fails; + ((struct StreamFake*) stream)->OpenFails = fails; } void StreamFake_SetSendFails(struct SolidSyslogStream* stream, bool fails) { - ((struct StreamFake*) stream)->sendFails = fails; + ((struct StreamFake*) stream)->SendFails = fails; } int StreamFake_CloseCallCount(struct SolidSyslogStream* stream) { - return ((struct StreamFake*) stream)->closeCallCount; + return ((struct StreamFake*) stream)->CloseCallCount; } diff --git a/docs/misra-conformance.md b/docs/misra-conformance.md index c9f8985f..84a5028f 100644 --- a/docs/misra-conformance.md +++ b/docs/misra-conformance.md @@ -71,7 +71,7 @@ following verdicts: | Kind | Count | Top sites | Verdict | Rationale | Owner | |------|------:|-----------|---------|-----------|-------| | **enum constant** | 252 → 101 *(named enums landed in S10.07; anonymous-enum idiom unchanged)* | `SolidSyslogPrival.h` (128 — `SOLIDSYSLOG_FACILITY_*`, `SOLIDSYSLOG_SEVERITY_*`), `SolidSyslogTransport.h` (24), `SolidSyslogBlockStore.h` (12) | **Mixed** | `docs/NAMING.md` already specifies `SolidSyslogClass_Constant` form (e.g. `SolidSyslogSeverity_Emergency`) for *tagged* enums — renamed across the tree in five per-enum slices on `feat/s10-07-enum-rename`. The remaining 101 findings are the anonymous-`enum { … };` named-constant idiom (`SOLIDSYSLOG_ADDRESS_SIZE`, `SOLIDSYSLOG_MAX_HOST_SIZE`, `INVALID_FD`, …) — functionally macros, currently classified by clang-tidy as enum constants and so flagged by the prefix/case rules. Needs its own verdict: either re-classify as macro-equivalent and tighten the relevant `.clang-tidy` regex, or rename to a class-prefixed PascalCase form. Loose thread surfaced during S10.07 verification; carried into the S10.07-sibling or its own ticket. | **S10.07** (named enums); follow-up for anonymous-enum idiom | -| **member** | 128 → 186 *(post Tier 4 re-statement)* | Pre-change: `SolidSyslog*Definition.h` headers (vtable function-pointer members in PascalCase). Post-change: ~186 data members in lowerCamelCase across `SolidSyslog*Config`, impl structs, helper structs, and test fakes. | **Disable original + Fix new** *(decided in S10.05)* | The original 128 findings were all vtable function-pointer members in PascalCase, flagged because Tier 4 was previously `lowerCamelCase`. **Tier 4 was re-stated in this story to `PascalCase` for all members** — a single rule with no member-kind exception. `.clang-tidy` flipped to `MemberCase: CamelCase`. The 128 vtable warnings disappeared; **186 lowerCamelCase data-member warnings now surface** and must be cleared by a rename sweep. | NAMING.md + `.clang-tidy` landed here; data-member rename sweep → **new sibling story to S10.07** (call it S10.07a or similar) | +| **member** | 128 → 186 → 0 *(post Tier 4 re-statement; sweep landed in S10.09)* | Pre-change: `SolidSyslog*Definition.h` headers (vtable function-pointer members in PascalCase). Post-change: ~186 data members in lowerCamelCase across `SolidSyslog*Config`, impl structs, helper structs, and test fakes. | **Disable original + Fix — landed in S10.09** | The original 128 findings were all vtable function-pointer members in PascalCase, flagged because Tier 4 was previously `lowerCamelCase`. **Tier 4 was re-stated in S10.05 to `PascalCase` for all members** — a single rule with no member-kind exception. `.clang-tidy` flipped to `MemberCase: CamelCase`. The 128 vtable warnings disappeared and **S10.09 cleared the 186 lowerCamelCase data-member warnings** with a per-cluster sweep (Formatter → storage → buffer → sender impls → sender Configs + fakes → SD → sync/atomics → top-level public structs + impl `struct SolidSyslog`). `analyze-tidy` reports zero `readability-identifier-naming` member findings post-S10.09. | landed in **S10.09** | | **global function** | 12 → 0 *(post Tier 1 second-shape addition)* | `SolidSyslogError.h` (8 — `SolidSyslog_SetErrorHandler`, `SolidSyslog_Error`), `SolidSyslog.h` (2 — `SolidSyslog_Log`, `SolidSyslog_Service`), `SolidSyslogConfig.h` (2 — `SolidSyslog_Create`, `SolidSyslog_Destroy`) | **Disable + landed in S10.05** | All six unique function names follow the form `SolidSyslog_` — the library-level API entry points. **NAMING.md Tier 1 was re-stated in this story** to recognise `SolidSyslog_` as a first-class shape for whole-library operations (alongside `SolidSyslog_` for class-scoped ones). `.clang-tidy` gained a `GlobalFunctionIgnoredRegexp` of `^SolidSyslog_[A-Z][A-Za-z0-9]*$` to accept the shape. The 12 warnings vanished in this commit. | NAMING.md + `.clang-tidy` landed here | | **enum** | 8 → 0 *(landed in S10.07)* | `SolidSyslogPrival.h` (8 — `SolidSyslog_Facility`, `SolidSyslog_Severity`) | **Fix — landed in S10.07** | Enum tag names should be `SolidSyslogFacility` and `SolidSyslogSeverity` (no underscore) per NAMING.md Tier 1 struct/enum rule. The underscore is residue. Renamed alongside the enum constants in the same per-enum slices. | **S10.07** | | **struct** | 4 → 0 *(post Tier 2 tag-rule clarification)* | `SolidSyslog.c` (`SolidSyslog` — opaque-impl), `SolidSyslogFormatter.c` (`EscapedContext`), `BlockSequence.c` (`BlockPresence`), `SolidSyslogFileBlockDevice.c` (`OpenHandle`) | **Disable + landed in S10.05** | Three are Tier 2 file-scope helper tags (`EscapedContext`, `BlockPresence`, `OpenHandle`) and one is the opaque-impl case (`struct SolidSyslog` matches the public opaque tag verbatim). **NAMING.md Tier 2 was extended in this story** to state that file-scope struct tags use bare PascalCase (no `SolidSyslog` prefix), and the opaque-impl exception was documented. `.clang-tidy` gained a `StructIgnoredRegexp` with negative lookahead — accepts `SolidSyslog` exactly, accepts any PascalCase tag that does NOT start with `SolidSyslog`, keeps Tier 1 `SolidSyslog` tags subject to the StructPrefix rule. The 4 warnings vanished in this commit. | NAMING.md + `.clang-tidy` landed here | @@ -81,7 +81,7 @@ following verdicts: | Verdict | Count | What's covered | |---------|------:|----------------| | **Fix — landed in S10.07** — enum-tag rename + named enum-constant rename | 260 → 101 | SCREAMING_SNAKE enum constants (252 → 101 — anonymous-`enum { … };` idiom carried over for separate verdict) + `SolidSyslog_` enum tags (8 → 0) | -| **Fix** — new S10.07-sibling: data-member PascalCase rename | 186 | All lowerCamelCase struct data members | +| **Fix — landed in S10.09** — data-member PascalCase rename | 186 → 0 | All lowerCamelCase struct data members (Config + impl + test-fake) cleared by per-cluster sweep | | **Disable + landed in S10.05** — vtable function-pointer members | 128 → 0 | Tier 4 re-stated to PascalCase for all members; `MemberCase: CamelCase` | | **Disable + landed in S10.05** — library-top-level functions | 12 → 0 | Tier 1 re-stated to two shapes (`SolidSyslog_` and `SolidSyslog_`); `GlobalFunctionIgnoredRegexp` accepts the second | | **Disable + landed in S10.05** — file-scope Tier 2 struct tags | 4 → 0 | Tier 2 extended to cover struct tags (bare PascalCase, no prefix); `StructIgnoredRegexp` whitelists the 4 known sites | @@ -171,7 +171,7 @@ Rough order-of-magnitude for sweep planning. These are **upper bounds** (some Fi | Story | Scope | Expected fix count | |-------|-------|--------------------| | S10.07 | Enum constants → `Class_PascalCase` + enum tags | 260 | -| S10.07-sibling *(new — slotted in S10.06)* | Data members lowerCamelCase → PascalCase per Tier 4 re-statement | 186 | +| S10.09 *(was the S10.07-sibling slot; named in S10.09 issue)* | Data members lowerCamelCase → PascalCase per Tier 4 re-statement — **landed** | 186 → 0 | | S10.08 | Static functions → `Class_Function` (MISRA 5.9) | 168 | | S10.09 | Abbreviation purge | (out of scope here — different lens) | | **Mechanical MISRA sweep** *(new — slotted in S10.06)* | Tree-wide hybrid mechanical fixes (10.4 / 12.1 / 2.5 / 15.7 / 10.8 / 10.1 / 2.4 / 3.1 / 7.1 / 14.4) | 126 |