mirror of
https://github.com/esphome/esphome.git
synced 2025-08-07 02:47:47 +00:00
cleanup
This commit is contained in:
parent
849d99b0dc
commit
ad4dd6a060
@ -1,7 +1,7 @@
|
|||||||
#include "esphome/core/defines.h"
|
#include "esphome/core/defines.h"
|
||||||
#if defined(USE_ESP_IDF) && defined(USE_WEBSERVER_OTA)
|
#if defined(USE_ESP_IDF) && defined(USE_WEBSERVER_OTA)
|
||||||
#include "multipart.h"
|
#include "multipart.h"
|
||||||
#include "parser_utils.h"
|
#include "utils.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "multipart_parser.h"
|
#include "multipart_parser.h"
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
#include "esphome/core/defines.h"
|
|
||||||
#ifdef USE_ESP_IDF
|
|
||||||
#include "parser_utils.h"
|
|
||||||
#include <cstring>
|
|
||||||
#include <cctype>
|
|
||||||
|
|
||||||
namespace esphome {
|
|
||||||
namespace web_server_idf {
|
|
||||||
|
|
||||||
// Helper function for case-insensitive string region comparison
|
|
||||||
bool str_ncmp_ci(const char *s1, const char *s2, size_t n) {
|
|
||||||
for (size_t i = 0; i < n; i++) {
|
|
||||||
if (!char_equals_ci(s1[i], s2[i])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Case-insensitive string search (like strstr but case-insensitive)
|
|
||||||
const char *stristr(const char *haystack, const char *needle) {
|
|
||||||
if (!haystack) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t needle_len = strlen(needle);
|
|
||||||
if (needle_len == 0) {
|
|
||||||
return haystack;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const char *p = haystack; *p; p++) {
|
|
||||||
if (str_ncmp_ci(p, needle, needle_len)) {
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace web_server_idf
|
|
||||||
} // namespace esphome
|
|
||||||
#endif // USE_ESP_IDF
|
|
@ -1,21 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "esphome/core/defines.h"
|
|
||||||
#ifdef USE_ESP_IDF
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace esphome {
|
|
||||||
namespace web_server_idf {
|
|
||||||
|
|
||||||
// Helper function for case-insensitive character comparison
|
|
||||||
inline bool char_equals_ci(char a, char b) { return ::tolower(a) == ::tolower(b); }
|
|
||||||
|
|
||||||
// Helper function for case-insensitive string region comparison
|
|
||||||
bool str_ncmp_ci(const char *s1, const char *s2, size_t n);
|
|
||||||
|
|
||||||
// Case-insensitive string search (like strstr but case-insensitive)
|
|
||||||
const char *stristr(const char *haystack, const char *needle);
|
|
||||||
|
|
||||||
} // namespace web_server_idf
|
|
||||||
} // namespace esphome
|
|
||||||
#endif // USE_ESP_IDF
|
|
@ -1,5 +1,7 @@
|
|||||||
#ifdef USE_ESP_IDF
|
#ifdef USE_ESP_IDF
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <cstring>
|
||||||
|
#include <cctype>
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
#include "http_parser.h"
|
#include "http_parser.h"
|
||||||
@ -88,6 +90,36 @@ optional<std::string> query_key_value(const std::string &query_url, const std::s
|
|||||||
return {val.get()};
|
return {val.get()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper function for case-insensitive string region comparison
|
||||||
|
bool str_ncmp_ci(const char *s1, const char *s2, size_t n) {
|
||||||
|
for (size_t i = 0; i < n; i++) {
|
||||||
|
if (!char_equals_ci(s1[i], s2[i])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Case-insensitive string search (like strstr but case-insensitive)
|
||||||
|
const char *stristr(const char *haystack, const char *needle) {
|
||||||
|
if (!haystack) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t needle_len = strlen(needle);
|
||||||
|
if (needle_len == 0) {
|
||||||
|
return haystack;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const char *p = haystack; *p; p++) {
|
||||||
|
if (str_ncmp_ci(p, needle, needle_len)) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace web_server_idf
|
} // namespace web_server_idf
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
#endif // USE_ESP_IDF
|
#endif // USE_ESP_IDF
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#ifdef USE_ESP_IDF
|
#ifdef USE_ESP_IDF
|
||||||
|
|
||||||
#include <esp_http_server.h>
|
#include <esp_http_server.h>
|
||||||
|
#include <string>
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
@ -12,6 +13,15 @@ optional<std::string> request_get_header(httpd_req_t *req, const char *name);
|
|||||||
optional<std::string> request_get_url_query(httpd_req_t *req);
|
optional<std::string> request_get_url_query(httpd_req_t *req);
|
||||||
optional<std::string> query_key_value(const std::string &query_url, const std::string &key);
|
optional<std::string> query_key_value(const std::string &query_url, const std::string &key);
|
||||||
|
|
||||||
|
// Helper function for case-insensitive character comparison
|
||||||
|
inline bool char_equals_ci(char a, char b) { return ::tolower(a) == ::tolower(b); }
|
||||||
|
|
||||||
|
// Helper function for case-insensitive string region comparison
|
||||||
|
bool str_ncmp_ci(const char *s1, const char *s2, size_t n);
|
||||||
|
|
||||||
|
// Case-insensitive string search (like strstr but case-insensitive)
|
||||||
|
const char *stristr(const char *haystack, const char *needle);
|
||||||
|
|
||||||
} // namespace web_server_idf
|
} // namespace web_server_idf
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
#endif // USE_ESP_IDF
|
#endif // USE_ESP_IDF
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "web_server_idf.h"
|
#include "web_server_idf.h"
|
||||||
#include "parser_utils.h"
|
|
||||||
|
|
||||||
#ifdef USE_WEBSERVER_OTA
|
#ifdef USE_WEBSERVER_OTA
|
||||||
#include "multipart.h"
|
#include "multipart.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user