summaryrefslogtreecommitdiff
path: root/Libraries/LibCore
diff options
context:
space:
mode:
authorShannon Booth <shannon.ml.booth@gmail.com>2020-03-07 11:37:51 +1300
committerAndreas Kling <kling@serenityos.org>2020-03-07 01:33:53 +0100
commit57f1c919df4d755790f6ac1e4797ab514d436f9a (patch)
tree9323a1aac5621e2baacf39b41842c84be2a5a2c5 /Libraries/LibCore
parent4a271430f879f2fb90c5ea0b27de6214d685eb28 (diff)
downloadserenity-57f1c919df4d755790f6ac1e4797ab514d436f9a.zip
LibCore: Remove all remaining C prefix references
LibCore's GZip is also moved into the Core namespace with this change.
Diffstat (limited to 'Libraries/LibCore')
-rw-r--r--Libraries/LibCore/Gzip.cpp8
-rw-r--r--Libraries/LibCore/Gzip.h8
-rw-r--r--Libraries/LibCore/HttpJob.cpp32
-rw-r--r--Libraries/LibCore/IODevice.cpp2
-rw-r--r--Libraries/LibCore/LocalSocket.cpp2
-rw-r--r--Libraries/LibCore/ProcessStatisticsReader.cpp2
-rw-r--r--Libraries/LibCore/SocketAddress.h2
-rw-r--r--Libraries/LibCore/TCPSocket.cpp2
-rw-r--r--Libraries/LibCore/UdpSocket.cpp2
9 files changed, 34 insertions, 26 deletions
diff --git a/Libraries/LibCore/Gzip.cpp b/Libraries/LibCore/Gzip.cpp
index 28a2de7152..85c2fe0836 100644
--- a/Libraries/LibCore/Gzip.cpp
+++ b/Libraries/LibCore/Gzip.cpp
@@ -31,7 +31,9 @@
#include <limits.h>
#include <stddef.h>
-bool CGzip::is_compressed(const ByteBuffer& data)
+namespace Core {
+
+bool Gzip::is_compressed(const ByteBuffer& data)
{
return data.size() > 2 && data[0] == 0x1F && data[1] == 0x8b;
}
@@ -102,7 +104,7 @@ static Optional<ByteBuffer> get_gzip_payload(const ByteBuffer& data)
return data.slice(current, new_size);
}
-Optional<ByteBuffer> CGzip::decompress(const ByteBuffer& data)
+Optional<ByteBuffer> Gzip::decompress(const ByteBuffer& data)
{
ASSERT(is_compressed(data));
@@ -145,3 +147,5 @@ Optional<ByteBuffer> CGzip::decompress(const ByteBuffer& data)
return destination;
}
+
+}
diff --git a/Libraries/LibCore/Gzip.h b/Libraries/LibCore/Gzip.h
index 30478d5a53..54232ef6b7 100644
--- a/Libraries/LibCore/Gzip.h
+++ b/Libraries/LibCore/Gzip.h
@@ -28,8 +28,12 @@
#include <AK/Optional.h>
#include <AK/String.h>
-class CGzip {
+namespace Core {
+
+class Gzip {
public:
static bool is_compressed(const ByteBuffer& data);
static Optional<ByteBuffer> decompress(const ByteBuffer& data);
-}; \ No newline at end of file
+};
+
+}
diff --git a/Libraries/LibCore/HttpJob.cpp b/Libraries/LibCore/HttpJob.cpp
index bfe9fe7e69..579ae6e58f 100644
--- a/Libraries/LibCore/HttpJob.cpp
+++ b/Libraries/LibCore/HttpJob.cpp
@@ -38,26 +38,26 @@ namespace Core {
static ByteBuffer handle_content_encoding(const ByteBuffer& buf, const String& content_encoding)
{
#ifdef CHTTPJOB_DEBUG
- dbg() << "CHttpJob::handle_content_encoding: buf has content_encoding = " << content_encoding;
+ dbg() << "HttpJob::handle_content_encoding: buf has content_encoding = " << content_encoding;
#endif
if (content_encoding == "gzip") {
- if (!CGzip::is_compressed(buf)) {
- dbg() << "CHttpJob::handle_content_encoding: buf is not gzip compressed!";
+ if (!Gzip::is_compressed(buf)) {
+ dbg() << "HttpJob::handle_content_encoding: buf is not gzip compressed!";
}
#ifdef CHTTPJOB_DEBUG
- dbg() << "CHttpJob::handle_content_encoding: buf is gzip compressed!";
+ dbg() << "HttpJob::handle_content_encoding: buf is gzip compressed!";
#endif
- auto uncompressed = CGzip::decompress(buf);
+ auto uncompressed = Gzip::decompress(buf);
if (!uncompressed.has_value()) {
- dbg() << "CHttpJob::handle_content_encoding: Gzip::decompress() failed. Returning original buffer.";
+ dbg() << "HttpJob::handle_content_encoding: Gzip::decompress() failed. Returning original buffer.";
return buf;
}
#ifdef CHTTPJOB_DEBUG
- dbg() << "CHttpJob::handle_content_encoding: Gzip::decompress() successful.\n"
+ dbg() << "HttpJob::handle_content_encoding: Gzip::decompress() successful.\n"
<< " Input size = " << buf.size() << "\n"
<< " Output size = " << uncompressed.value().size();
#endif
@@ -81,7 +81,7 @@ void HttpJob::on_socket_connected()
{
auto raw_request = m_request.to_raw_request();
#if 0
- dbg() << "CHttpJob: raw_request:";
+ dbg() << "HttpJob: raw_request:";
dbg() << String::copy(raw_request).characters();
#endif
@@ -97,18 +97,18 @@ void HttpJob::on_socket_connected()
return;
auto line = m_socket->read_line(PAGE_SIZE);
if (line.is_null()) {
- fprintf(stderr, "CHttpJob: Expected HTTP status\n");
+ fprintf(stderr, "HttpJob: Expected HTTP status\n");
return deferred_invoke([this](auto&) { did_fail(NetworkJob::Error::TransmissionFailed); });
}
auto parts = String::copy(line, Chomp).split(' ');
if (parts.size() < 3) {
- fprintf(stderr, "CHttpJob: Expected 3-part HTTP status, got '%s'\n", line.data());
+ fprintf(stderr, "HttpJob: Expected 3-part HTTP status, got '%s'\n", line.data());
return deferred_invoke([this](auto&) { did_fail(NetworkJob::Error::ProtocolFailed); });
}
bool ok;
m_code = parts[1].to_uint(ok);
if (!ok) {
- fprintf(stderr, "CHttpJob: Expected numeric HTTP status\n");
+ fprintf(stderr, "HttpJob: Expected numeric HTTP status\n");
return deferred_invoke([this](auto&) { did_fail(NetworkJob::Error::ProtocolFailed); });
}
m_state = State::InHeaders;
@@ -119,7 +119,7 @@ void HttpJob::on_socket_connected()
return;
auto line = m_socket->read_line(PAGE_SIZE);
if (line.is_null()) {
- fprintf(stderr, "CHttpJob: Expected HTTP header\n");
+ fprintf(stderr, "HttpJob: Expected HTTP header\n");
return did_fail(NetworkJob::Error::ProtocolFailed);
}
auto chomped_line = String::copy(line, Chomp);
@@ -129,18 +129,18 @@ void HttpJob::on_socket_connected()
}
auto parts = chomped_line.split(':');
if (parts.is_empty()) {
- fprintf(stderr, "CHttpJob: Expected HTTP header with key/value\n");
+ fprintf(stderr, "HttpJob: Expected HTTP header with key/value\n");
return deferred_invoke([this](auto&) { did_fail(NetworkJob::Error::ProtocolFailed); });
}
auto name = parts[0];
if (chomped_line.length() < name.length() + 2) {
- fprintf(stderr, "CHttpJob: Malformed HTTP header: '%s' (%zu)\n", chomped_line.characters(), chomped_line.length());
+ fprintf(stderr, "HttpJob: Malformed HTTP header: '%s' (%zu)\n", chomped_line.characters(), chomped_line.length());
return deferred_invoke([this](auto&) { did_fail(NetworkJob::Error::ProtocolFailed); });
}
auto value = chomped_line.substring(name.length() + 2, chomped_line.length() - name.length() - 2);
m_headers.set(name, value);
#ifdef CHTTPJOB_DEBUG
- dbg() << "CHttpJob: [" << name << "] = '" << value << "'";
+ dbg() << "HttpJob: [" << name << "] = '" << value << "'";
#endif
return;
}
@@ -192,7 +192,7 @@ void HttpJob::start()
m_socket = TCPSocket::construct(this);
m_socket->on_connected = [this] {
#ifdef CHTTPJOB_DEBUG
- dbg() << "CHttpJob: on_connected callback";
+ dbg() << "HttpJob: on_connected callback";
#endif
on_socket_connected();
};
diff --git a/Libraries/LibCore/IODevice.cpp b/Libraries/LibCore/IODevice.cpp
index c818286d98..3e8f97776d 100644
--- a/Libraries/LibCore/IODevice.cpp
+++ b/Libraries/LibCore/IODevice.cpp
@@ -104,7 +104,7 @@ ByteBuffer IODevice::read(size_t max_size)
bool IODevice::can_read_from_fd() const
{
- // FIXME: Can we somehow remove this once CSocket is implemented using non-blocking sockets?
+ // FIXME: Can we somehow remove this once Core::Socket is implemented using non-blocking sockets?
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(m_fd, &rfds);
diff --git a/Libraries/LibCore/LocalSocket.cpp b/Libraries/LibCore/LocalSocket.cpp
index 533670b435..3d347d2393 100644
--- a/Libraries/LibCore/LocalSocket.cpp
+++ b/Libraries/LibCore/LocalSocket.cpp
@@ -37,7 +37,7 @@ namespace Core {
LocalSocket::LocalSocket(int fd, Object* parent)
: Socket(Socket::Type::Local, parent)
{
- // NOTE: This constructor is used by CLocalServer::accept(), so the socket is already connected.
+ // NOTE: This constructor is used by LocalServer::accept(), so the socket is already connected.
m_connected = true;
set_fd(fd);
set_mode(IODevice::ReadWrite);
diff --git a/Libraries/LibCore/ProcessStatisticsReader.cpp b/Libraries/LibCore/ProcessStatisticsReader.cpp
index cd87e00e31..13936b9f15 100644
--- a/Libraries/LibCore/ProcessStatisticsReader.cpp
+++ b/Libraries/LibCore/ProcessStatisticsReader.cpp
@@ -40,7 +40,7 @@ HashMap<pid_t, Core::ProcessStatistics> ProcessStatisticsReader::get_all()
{
auto file = Core::File::construct("/proc/all");
if (!file->open(Core::IODevice::ReadOnly)) {
- fprintf(stderr, "CProcessStatisticsReader: Failed to open /proc/all: %s\n", file->error_string());
+ fprintf(stderr, "ProcessStatisticsReader: Failed to open /proc/all: %s\n", file->error_string());
return {};
}
diff --git a/Libraries/LibCore/SocketAddress.h b/Libraries/LibCore/SocketAddress.h
index 7b0868e7d8..04892bf11c 100644
--- a/Libraries/LibCore/SocketAddress.h
+++ b/Libraries/LibCore/SocketAddress.h
@@ -77,7 +77,7 @@ public:
case Type::Local:
return m_local_address;
default:
- return "[CSocketAddress]";
+ return "[SocketAddress]";
}
}
diff --git a/Libraries/LibCore/TCPSocket.cpp b/Libraries/LibCore/TCPSocket.cpp
index 2a61f34fcf..ca23112e0f 100644
--- a/Libraries/LibCore/TCPSocket.cpp
+++ b/Libraries/LibCore/TCPSocket.cpp
@@ -33,7 +33,7 @@ namespace Core {
TCPSocket::TCPSocket(int fd, Object* parent)
: Socket(Socket::Type::TCP, parent)
{
- // NOTE: This constructor is used by CTCPServer::accept(), so the socket is already connected.
+ // NOTE: This constructor is used by TCPServer::accept(), so the socket is already connected.
m_connected = true;
set_fd(fd);
set_mode(IODevice::ReadWrite);
diff --git a/Libraries/LibCore/UdpSocket.cpp b/Libraries/LibCore/UdpSocket.cpp
index fd0c2ccd7c..ae66eaf26e 100644
--- a/Libraries/LibCore/UdpSocket.cpp
+++ b/Libraries/LibCore/UdpSocket.cpp
@@ -33,7 +33,7 @@ namespace Core {
UdpSocket::UdpSocket(int fd, Object* parent)
: Socket(Socket::Type::UDP, parent)
{
- // NOTE: This constructor is used by CUdpServer::accept(), so the socket is already connected.
+ // NOTE: This constructor is used by UdpServer::accept(), so the socket is already connected.
m_connected = true;
set_fd(fd);
set_mode(IODevice::ReadWrite);