Skip to content
This repository has been archived by the owner on Jan 21, 2025. It is now read-only.

Commit

Permalink
wrap string literals in namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
vortigont authored and mathieucarbou committed Jul 16, 2024
1 parent c004ca8 commit bc8cadb
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/AsyncEventSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "AsyncEventSource.h"
#include "literals.h"

using namespace asyncsrv;

static String generateEventMessage(const char* message, const char* event, uint32_t id, uint32_t reconnect) {
String ev;

Expand Down
3 changes: 3 additions & 0 deletions src/AsyncWebSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@

#define MAX_PRINTF_LEN 64

using namespace asyncsrv;


size_t webSocketSendFrameWindow(AsyncClient* client) {
if (!client->canSend())
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/ESPAsyncWebServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class AsyncWebHeader {

const String& name() const { return _name; }
const String& value() const { return _value; }
String toString() const { return _name + (char)0x3a + (char)0x20 /*": "*/ + _value + T_rn; }
String toString() const { return _name + (char)0x3a + (char)0x20 /*": "*/ + _value + asyncsrv::T_rn; }
};

/*
Expand Down
2 changes: 2 additions & 0 deletions src/WebAuthentication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#endif
#include "literals.h"

using namespace asyncsrv;

// Basic Auth hash = base64("username:password")

bool checkBasicAuthentication(const char* hash, const char* username, const char* password) {
Expand Down
3 changes: 3 additions & 0 deletions src/WebHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#include "ESPAsyncWebServer.h"
#include "WebHandlerImpl.h"

using namespace asyncsrv;


AsyncStaticWebHandler::AsyncStaticWebHandler(const char* uri, FS& fs, const char* path, const char* cache_control)
: _fs(fs), _uri(uri), _path(path), _default_file(F("index.htm")), _cache_control(cache_control), _last_modified(), _callback(nullptr) {
// Ensure leading '/'
Expand Down
2 changes: 2 additions & 0 deletions src/WebRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#define __is_param_char(c) ((c) && ((c) != '{') && ((c) != '[') && ((c) != '&') && ((c) != '='))

using namespace asyncsrv;

enum { PARSE_REQ_START,
PARSE_REQ_HEADERS,
PARSE_REQ_BODY,
Expand Down
2 changes: 2 additions & 0 deletions src/WebResponses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "WebResponseImpl.h"
#include "cbuf.h"

using namespace asyncsrv;

// Since ESP8266 does not link memchr by default, here's its implementation.
void* memchr(void* ptr, int ch, size_t count) {
unsigned char* p = static_cast<unsigned char*>(ptr);
Expand Down
2 changes: 2 additions & 0 deletions src/WebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "ESPAsyncWebServer.h"
#include "WebHandlerImpl.h"

using namespace asyncsrv;

bool ON_STA_FILTER(AsyncWebServerRequest* request) {
return WiFi.localIP() == request->client()->localIP();
}
Expand Down
3 changes: 3 additions & 0 deletions src/literals.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

namespace asyncsrv {

#ifndef ESP8622
static constexpr const char* T_100_CONTINUE = "100-continue";
Expand Down Expand Up @@ -336,3 +337,5 @@ static const char T_uri[] PROGMEM = "uri";
static const char T_username[] PROGMEM = "username";

#endif // ESP8622

} // namespace asyncsrv {}

0 comments on commit bc8cadb

Please sign in to comment.