44 lines
811 B
C++
44 lines
811 B
C++
/*
|
|
* ESP8266 RGBW controller
|
|
* Copyright 2020 (c) Mark van Renswoude
|
|
*
|
|
* https://git.x2software.net/pub/RGBWifi
|
|
*/
|
|
#include "./charproperties.h"
|
|
#include <cstddef>
|
|
#include <string.h>
|
|
#include "./debug.h"
|
|
|
|
void assignChar(char** field, const char* newValue)
|
|
{
|
|
if (*field != nullptr)
|
|
delete *field;
|
|
|
|
if (newValue != nullptr)
|
|
{
|
|
// Include the terminating null character
|
|
size_t length = strlen(newValue) + 1;
|
|
|
|
if (length > 0)
|
|
{
|
|
*field = new char[length];
|
|
strncpy(*field, newValue, length);
|
|
}
|
|
else
|
|
*field = nullptr;
|
|
}
|
|
else
|
|
*field = nullptr;
|
|
}
|
|
|
|
|
|
bool sameStr(const char* value1, const char* value2)
|
|
{
|
|
if ((value1 == nullptr) != (value2 == nullptr))
|
|
return true;
|
|
|
|
if (value1 == nullptr)
|
|
return false;
|
|
|
|
return strcmp(value1, value2) == 0;
|
|
} |