Add MQTT origin handling and string utility function
Implemented a new function to strip surrounding quotes from strings in TxtDataHelpers, enhancing string manipulation capabilities. Updated CommonCLI to handle MQTT origin configuration, allowing for both setting and clearing of the mqtt.origin preference. This change improves the flexibility of MQTT origin management in the CLI.
This commit is contained in:
1 parent
303cf8c2bd
commit
b9f478c989
4 files changed
+24
-21
No files matched your search
@@ -1,4 +1,18 @@
|
||||
#include "TxtDataHelpers.h"
|
||||
#include <string.h>
|
||||
|
||||
void StrHelper::stripSurroundingQuotes(char* str, size_t buf_sz) {
|
||||
if (!str || buf_sz == 0) return;
|
||||
size_t len = strlen(str);
|
||||
if (len == 0) return;
|
||||
if (str[0] == '"' || str[0] == '\'') {
|
||||
memmove(str, str + 1, len);
|
||||
len--;
|
||||
}
|
||||
if (len > 0 && (str[len - 1] == '"' || str[len - 1] == '\'')) {
|
||||
str[len - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void StrHelper::strncpy(char* dest, const char* src, size_t buf_sz) {
|
||||
while (buf_sz > 1 && *src) {
|
||||
|
||||
Reference in new issue
Block a user