summaryrefslogtreecommitdiffhomepage
path: root/NetEx
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-03-31 23:06:47 +0200
committerAki <please@ignore.pl>2022-03-31 23:06:47 +0200
commit28873b2e25752a85b795317cce1904dd1872e401 (patch)
tree317671f7bb19cadf0ffba1f77377c21955d962a9 /NetEx
parent7f4b865a5bf94dea63ff5510a801df0ad315bfdb (diff)
downloadstarshatter-28873b2e25752a85b795317cce1904dd1872e401.zip
starshatter-28873b2e25752a85b795317cce1904dd1872e401.tar.gz
starshatter-28873b2e25752a85b795317cce1904dd1872e401.tar.bz2
Fixed left-overs that failed linux gcc compilation
Diffstat (limited to 'NetEx')
-rw-r--r--NetEx/HttpResponse.cpp23
-rw-r--r--NetEx/HttpServer.cpp24
-rw-r--r--NetEx/HttpServer.h4
-rw-r--r--NetEx/HttpServletExec.cpp12
4 files changed, 32 insertions, 31 deletions
diff --git a/NetEx/HttpResponse.cpp b/NetEx/HttpResponse.cpp
index 2047612..65b7e5d 100644
--- a/NetEx/HttpResponse.cpp
+++ b/NetEx/HttpResponse.cpp
@@ -6,13 +6,14 @@
#include "HttpResponse.h"
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
#ifndef _WIN32
#include <strings.h>
#endif
+#include <cctype>
+#include <cstdio>
+#include <cstring>
+
#include "HttpParam.h"
#include "List.h"
#include "Text.h"
@@ -92,20 +93,20 @@ HttpResponse::operator Text()
char buffer[256];
if (content.length()) {
- sprintf_s(buffer, "%d", content.length());
+ std::sprintf(buffer, "%d", content.length());
SetHeader("Content-Length", buffer);
}
for (int i = 0; i < cookies.size(); i++) {
HttpParam* cookie = cookies.at(i);
- sprintf_s(buffer, "%s=\"%s\"; Version=\"1\"", cookie->name.data(), cookie->value.data());
+ std::sprintf(buffer, "%s=\"%s\"; Version=\"1\"", cookie->name.data(), cookie->value.data());
AddHeader("Set-Cookie", buffer);
}
for (int i = 0; i < headers.size(); i++) {
const HttpParam* p = headers.at(i);
- sprintf_s(buffer, "%s: %s\n", p->name.data(), p->value.data());
+ std::sprintf(buffer, "%s: %s\n", p->name.data(), p->value.data());
response += buffer;
}
@@ -215,7 +216,7 @@ HttpResponse::ParseResponse(Text response)
const char* pStatus = response.data() + 9;
- sscanf_s(pStatus, "%d", &status);
+ std::sscanf(pStatus, "%d", &status);
if (!status) return;
int i = 0;
@@ -237,7 +238,7 @@ HttpResponse::ParseResponse(Text response)
name_buf[i] = 0;
p++; // skip ':'
- while (isspace(*p)) p++; // skip spaces
+ while (std::isspace(*p)) p++; // skip spaces
i = 0;
while (*p && *p != '\r' && *p != '\n') // read to end of header line
@@ -274,18 +275,18 @@ HttpResponse::ParseCookie(const char* param)
const char* p = param;
while (p && *p) {
- while (isspace(*p)) p++;
+ while (std::isspace(*p)) p++;
// just ignore reserved attributes
if (*p == '$') {
- while (*p && !isspace(*p) && *p != ';') p++;
+ while (*p && !std::isspace(*p) && *p != ';') p++;
if (*p == ';')
p++;
}
// found a cookie!
- else if (isalpha(*p)) {
+ else if (std::isalpha(*p)) {
char name[1024];
char data[1024];
diff --git a/NetEx/HttpServer.cpp b/NetEx/HttpServer.cpp
index 98d997f..e38612c 100644
--- a/NetEx/HttpServer.cpp
+++ b/NetEx/HttpServer.cpp
@@ -13,8 +13,8 @@
#include "HttpServer.h"
-#include <stdint.h>
-#include <stdio.h>
+#include <cstdint>
+#include <cstdio>
#include "HttpParam.h"
#include "HttpRequest.h"
@@ -25,7 +25,7 @@
#include "Text.h"
-HttpServer::HttpServer(uint16_t port, int poolsize) :
+HttpServer::HttpServer(std::uint16_t port, int poolsize) :
NetServer(port, poolsize)
{
http_server_name = "Generic HttpServer 1.0";
@@ -121,12 +121,12 @@ HttpServer::DoGet(HttpRequest& request, HttpResponse& response)
content += "</h1>\n";
content += "<br><h3>Client Address:</h3><p>\n";
- sprintf_s(buffer, "%d.%d.%d.%d:%d<br><br>\n",
- client_addr.B1(),
- client_addr.B2(),
- client_addr.B3(),
- client_addr.B4(),
- client_addr.Port());
+ std::sprintf(buffer, "%d.%d.%d.%d:%d<br><br>\n",
+ client_addr.B1(),
+ client_addr.B2(),
+ client_addr.B3(),
+ client_addr.B4(),
+ client_addr.Port());
content += buffer;
content += "<h3>Request Method:</h3><p>\n";
@@ -160,7 +160,7 @@ HttpServer::DoGet(HttpRequest& request, HttpResponse& response)
ListIter<HttpParam> q_iter = request.GetQuery();
while (++q_iter) {
HttpParam* q = q_iter.value();
- sprintf_s(buffer, "<b>%s:</b> <i>%s</i><br>\n", q->name.data(), q->value.data());
+ std::printf(buffer, "<b>%s:</b> <i>%s</i><br>\n", q->name.data(), q->value.data());
content += buffer;
}
}
@@ -169,7 +169,7 @@ HttpServer::DoGet(HttpRequest& request, HttpResponse& response)
ListIter<HttpParam> h_iter = request.GetHeaders();
while (++h_iter) {
HttpParam* h = h_iter.value();
- sprintf_s(buffer, "<b>%s:</b> <i>%s</i><br>\n", h->name.data(), h->value.data());
+ std::sprintf(buffer, "<b>%s:</b> <i>%s</i><br>\n", h->name.data(), h->value.data());
content += buffer;
}
@@ -199,7 +199,7 @@ HttpServer::DoHead(HttpRequest& request, HttpResponse& response)
int len = response.Content().length();
char buffer[256];
- sprintf_s(buffer, "%d", len);
+ std::sprintf(buffer, "%d", len);
response.SetHeader("Content-Length", buffer);
response.SetContent("");
diff --git a/NetEx/HttpServer.h b/NetEx/HttpServer.h
index 2bba488..88c1c3c 100644
--- a/NetEx/HttpServer.h
+++ b/NetEx/HttpServer.h
@@ -14,7 +14,7 @@
#ifndef HttpServer_h
#define HttpServer_h
-#include <stdint.h>
+#include <cstdint>
#include "HttpRequest.h"
#include "HttpResponse.h"
@@ -28,7 +28,7 @@ class HttpServer : public NetServer
public:
static const char* TYPENAME() { return "HttpServer"; }
- HttpServer(uint16_t port, int poolsize=1);
+ HttpServer(std::uint16_t port, int poolsize=1);
virtual ~HttpServer();
int operator == (const HttpServer& l) const { return addr == l.addr; }
diff --git a/NetEx/HttpServletExec.cpp b/NetEx/HttpServletExec.cpp
index bbd7efe..c64df85 100644
--- a/NetEx/HttpServletExec.cpp
+++ b/NetEx/HttpServletExec.cpp
@@ -13,9 +13,9 @@
#include "HttpServletExec.h"
-#include <stdio.h>
-
+#include <chrono>
#include <cstdint>
+#include <cstdio>
#include <thread>
#include "HttpRequest.h"
@@ -60,7 +60,7 @@ public:
ListIter<HttpParam> q_iter = request.GetQuery();
while (++q_iter) {
HttpParam* q = q_iter.value();
- sprintf_s(buffer, "<b>%s:</b> <i>%s</i><br>\n", q->name.data(), q->value.data());
+ std::sprintf(buffer, "<b>%s:</b> <i>%s</i><br>\n", q->name.data(), q->value.data());
content += buffer;
}
}
@@ -69,7 +69,7 @@ public:
ListIter<HttpParam> h_iter = request.GetHeaders();
while (++h_iter) {
HttpParam* h = h_iter.value();
- sprintf_s(buffer, "<b>%s:</b> <i>%s</i><br>\n", h->name.data(), h->value.data());
+ std::sprintf(buffer, "<b>%s:</b> <i>%s</i><br>\n", h->name.data(), h->value.data());
content += buffer;
}
@@ -78,7 +78,7 @@ public:
ListIter<HttpParam> c_iter = request.GetCookies();
while (++c_iter) {
HttpParam* c = c_iter.value();
- sprintf_s(buffer, "<b>%s:</b> <i>%s</i><br>\n", c->name.data(), c->value.data());
+ std::sprintf(buffer, "<b>%s:</b> <i>%s</i><br>\n", c->name.data(), c->value.data());
content += buffer;
}
}
@@ -206,7 +206,7 @@ HttpServletExec::CheckSessions()
DoSyncedCheck();
sync.unlock();
- Sleep(100);
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
}