mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 13:37:45 +00:00
Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -26,7 +26,7 @@ void ConnectionFromClient::die()
|
|||
s_connections.remove(client_id());
|
||||
}
|
||||
|
||||
Messages::LookupServer::LookupNameResponse ConnectionFromClient::lookup_name(DeprecatedString const& name)
|
||||
Messages::LookupServer::LookupNameResponse ConnectionFromClient::lookup_name(ByteString const& name)
|
||||
{
|
||||
auto maybe_answers = LookupServer::the().lookup(name, RecordType::A);
|
||||
if (maybe_answers.is_error()) {
|
||||
|
@ -35,19 +35,19 @@ Messages::LookupServer::LookupNameResponse ConnectionFromClient::lookup_name(Dep
|
|||
}
|
||||
|
||||
auto answers = maybe_answers.release_value();
|
||||
Vector<DeprecatedString> addresses;
|
||||
Vector<ByteString> addresses;
|
||||
for (auto& answer : answers) {
|
||||
addresses.append(answer.record_data());
|
||||
}
|
||||
return { 0, move(addresses) };
|
||||
}
|
||||
|
||||
Messages::LookupServer::LookupAddressResponse ConnectionFromClient::lookup_address(DeprecatedString const& address)
|
||||
Messages::LookupServer::LookupAddressResponse ConnectionFromClient::lookup_address(ByteString const& address)
|
||||
{
|
||||
if (address.length() != 4)
|
||||
return { 1, DeprecatedString() };
|
||||
return { 1, ByteString() };
|
||||
IPv4Address ip_address { (u8 const*)address.characters() };
|
||||
auto name = DeprecatedString::formatted("{}.{}.{}.{}.in-addr.arpa",
|
||||
auto name = ByteString::formatted("{}.{}.{}.{}.in-addr.arpa",
|
||||
ip_address[3],
|
||||
ip_address[2],
|
||||
ip_address[1],
|
||||
|
@ -56,12 +56,12 @@ Messages::LookupServer::LookupAddressResponse ConnectionFromClient::lookup_addre
|
|||
auto maybe_answers = LookupServer::the().lookup(name, RecordType::PTR);
|
||||
if (maybe_answers.is_error()) {
|
||||
dbgln("LookupServer: Failed to lookup PTR record: {}", maybe_answers.error());
|
||||
return { 1, DeprecatedString() };
|
||||
return { 1, ByteString() };
|
||||
}
|
||||
|
||||
auto answers = maybe_answers.release_value();
|
||||
if (answers.is_empty())
|
||||
return { 1, DeprecatedString() };
|
||||
return { 1, ByteString() };
|
||||
return { 0, answers[0].record_data() };
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ public:
|
|||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
|
||||
|
||||
virtual Messages::LookupServer::LookupNameResponse lookup_name(DeprecatedString const&) override;
|
||||
virtual Messages::LookupServer::LookupAddressResponse lookup_address(DeprecatedString const&) override;
|
||||
virtual Messages::LookupServer::LookupNameResponse lookup_name(ByteString const&) override;
|
||||
virtual Messages::LookupServer::LookupAddressResponse lookup_address(ByteString const&) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#include "LookupServer.h"
|
||||
#include "ConnectionFromClient.h"
|
||||
#include <AK/BufferedStream.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/Random.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
|
@ -89,7 +89,7 @@ void LookupServer::load_etc_hosts()
|
|||
ErrorOr<HashMap<Name, Vector<Answer>, Name::Traits>> LookupServer::try_load_etc_hosts()
|
||||
{
|
||||
HashMap<Name, Vector<Answer>, Name::Traits> map;
|
||||
auto add_answer = [&map](Name const& name, RecordType record_type, DeprecatedString data) -> ErrorOr<void> {
|
||||
auto add_answer = [&map](Name const& name, RecordType record_type, ByteString data) -> ErrorOr<void> {
|
||||
// FIXME: Since try_ensure does not return a reference to the contained value, we have to
|
||||
// retrieve it separately. This is a try_ensure bug that should be fixed.
|
||||
TRY(map.try_ensure(name, []() { return Vector<Answer> {}; }));
|
||||
|
@ -132,18 +132,18 @@ ErrorOr<HashMap<Name, Vector<Answer>, Name::Traits>> LookupServer::try_load_etc_
|
|||
auto raw_addr = maybe_address->to_in_addr_t();
|
||||
|
||||
Name name { fields[1] };
|
||||
TRY(add_answer(name, RecordType::A, DeprecatedString { (char const*)&raw_addr, sizeof(raw_addr) }));
|
||||
TRY(add_answer(name, RecordType::A, ByteString { (char const*)&raw_addr, sizeof(raw_addr) }));
|
||||
|
||||
StringBuilder builder;
|
||||
TRY(builder.try_append(maybe_address->to_deprecated_string_reversed()));
|
||||
TRY(builder.try_append(maybe_address->to_byte_string_reversed()));
|
||||
TRY(builder.try_append(".in-addr.arpa"sv));
|
||||
TRY(add_answer(builder.to_deprecated_string(), RecordType::PTR, name.as_string()));
|
||||
TRY(add_answer(builder.to_byte_string(), RecordType::PTR, name.as_string()));
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
static DeprecatedString get_hostname()
|
||||
static ByteString get_hostname()
|
||||
{
|
||||
char buffer[_POSIX_HOST_NAME_MAX];
|
||||
VERIFY(gethostname(buffer, sizeof(buffer)) == 0);
|
||||
|
@ -182,7 +182,7 @@ ErrorOr<Vector<Answer>> LookupServer::lookup(Name const& name, RecordType record
|
|||
if (record_type == RecordType::A && get_hostname() == name) {
|
||||
IPv4Address address = { 127, 0, 0, 1 };
|
||||
auto raw_address = address.to_in_addr_t();
|
||||
Answer answer { name, RecordType::A, RecordClass::IN, s_static_ttl, DeprecatedString { (char const*)&raw_address, sizeof(raw_address) }, false };
|
||||
Answer answer { name, RecordType::A, RecordClass::IN, s_static_ttl, ByteString { (char const*)&raw_address, sizeof(raw_address) }, false };
|
||||
answers.append(move(answer));
|
||||
return answers;
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ ErrorOr<Vector<Answer>> LookupServer::lookup(Name const& name, RecordType record
|
|||
return answers;
|
||||
}
|
||||
|
||||
ErrorOr<Vector<Answer>> LookupServer::lookup(Name const& name, DeprecatedString const& nameserver, bool& did_get_response, RecordType record_type, ShouldRandomizeCase should_randomize_case)
|
||||
ErrorOr<Vector<Answer>> LookupServer::lookup(Name const& name, ByteString const& nameserver, bool& did_get_response, RecordType record_type, ShouldRandomizeCase should_randomize_case)
|
||||
{
|
||||
Packet request;
|
||||
request.set_is_query();
|
||||
|
|
|
@ -33,12 +33,12 @@ private:
|
|||
void load_etc_hosts();
|
||||
void put_in_cache(Answer const&);
|
||||
|
||||
ErrorOr<Vector<Answer>> lookup(Name const& hostname, DeprecatedString const& nameserver, bool& did_get_response, RecordType record_type, ShouldRandomizeCase = ShouldRandomizeCase::Yes);
|
||||
ErrorOr<Vector<Answer>> lookup(Name const& hostname, ByteString const& nameserver, bool& did_get_response, RecordType record_type, ShouldRandomizeCase = ShouldRandomizeCase::Yes);
|
||||
|
||||
OwnPtr<IPC::MultiServer<ConnectionFromClient>> m_server;
|
||||
RefPtr<DNSServer> m_dns_server;
|
||||
RefPtr<MulticastDNS> m_mdns;
|
||||
Vector<DeprecatedString> m_nameservers;
|
||||
Vector<ByteString> m_nameservers;
|
||||
RefPtr<Core::FileWatcher> m_file_watcher;
|
||||
HashMap<Name, Vector<Answer>, Name::Traits> m_etc_hosts;
|
||||
HashMap<Name, Vector<Answer>, Name::Traits> m_lookup_cache;
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
endpoint LookupServer
|
||||
{
|
||||
// Keep these definitions synchronized with gethostbyname and gethostbyaddr in netdb.cpp
|
||||
lookup_name(DeprecatedString name) => (int code, Vector<DeprecatedString> addresses)
|
||||
lookup_address(DeprecatedString address) => (int code, DeprecatedString name)
|
||||
lookup_name(ByteString name) => (int code, Vector<ByteString> addresses)
|
||||
lookup_address(ByteString address) => (int code, ByteString name)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
#include "MulticastDNS.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/IPv4Address.h>
|
||||
#include <AK/JsonArray.h>
|
||||
#include <AK/JsonObject.h>
|
||||
|
@ -28,7 +28,7 @@ MulticastDNS::MulticastDNS(Core::EventReceiver* parent)
|
|||
if (gethostname(buffer, sizeof(buffer)) < 0) {
|
||||
perror("gethostname");
|
||||
} else {
|
||||
m_hostname = DeprecatedString::formatted("{}.local", buffer);
|
||||
m_hostname = ByteString::formatted("{}.local", buffer);
|
||||
}
|
||||
|
||||
u8 zero = 0;
|
||||
|
@ -92,7 +92,7 @@ void MulticastDNS::announce()
|
|||
RecordType::A,
|
||||
RecordClass::IN,
|
||||
120,
|
||||
DeprecatedString { (char const*)&raw_addr, sizeof(raw_addr) },
|
||||
ByteString { (char const*)&raw_addr, sizeof(raw_addr) },
|
||||
true,
|
||||
};
|
||||
response.add_answer(answer);
|
||||
|
@ -133,7 +133,7 @@ Vector<IPv4Address> MulticastDNS::local_addresses() const
|
|||
|
||||
json_or_error.value().as_array().for_each([&addresses](auto& value) {
|
||||
auto if_object = value.as_object();
|
||||
auto address = if_object.get_deprecated_string("ipv4_address"sv).value_or({});
|
||||
auto address = if_object.get_byte_string("ipv4_address"sv).value_or({});
|
||||
auto ipv4_address = IPv4Address::from_string(address);
|
||||
// Skip unconfigured interfaces.
|
||||
if (!ipv4_address.has_value())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue