mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:17:34 +00:00
LibIMAP: Rename IMAP::Parser::{parse => consume}_while()
This isn't parsing anything.
This commit is contained in:
parent
6502d79240
commit
8c05b4e137
2 changed files with 14 additions and 14 deletions
|
@ -22,7 +22,7 @@ ParseStatus Parser::parse(ByteBuffer&& buffer, bool expecting_tag)
|
||||||
|
|
||||||
if (try_consume("+")) {
|
if (try_consume("+")) {
|
||||||
consume(" ");
|
consume(" ");
|
||||||
auto data = parse_while([](u8 x) { return x != '\r'; });
|
auto data = consume_while([](u8 x) { return x != '\r'; });
|
||||||
consume("\r\n");
|
consume("\r\n");
|
||||||
return { true, { ContinueRequest { data } } };
|
return { true, { ContinueRequest { data } } };
|
||||||
}
|
}
|
||||||
|
@ -179,13 +179,13 @@ void Parser::parse_untagged()
|
||||||
m_response.data().set_permanent_flags(move(flags));
|
m_response.data().set_permanent_flags(move(flags));
|
||||||
} else {
|
} else {
|
||||||
dbgln("Unknown: {}", actual_type);
|
dbgln("Unknown: {}", actual_type);
|
||||||
parse_while([](u8 x) { return x != ']'; });
|
consume_while([](u8 x) { return x != ']'; });
|
||||||
}
|
}
|
||||||
consume("]");
|
consume("]");
|
||||||
parse_while([](u8 x) { return x != '\r'; });
|
consume_while([](u8 x) { return x != '\r'; });
|
||||||
consume("\r\n");
|
consume("\r\n");
|
||||||
} else {
|
} else {
|
||||||
parse_while([](u8 x) { return x != '\r'; });
|
consume_while([](u8 x) { return x != '\r'; });
|
||||||
consume("\r\n");
|
consume("\r\n");
|
||||||
}
|
}
|
||||||
} else if (try_consume("SEARCH")) {
|
} else if (try_consume("SEARCH")) {
|
||||||
|
@ -197,7 +197,7 @@ void Parser::parse_untagged()
|
||||||
}
|
}
|
||||||
m_response.data().set_search_results(move(ids));
|
m_response.data().set_search_results(move(ids));
|
||||||
} else if (try_consume("BYE")) {
|
} else if (try_consume("BYE")) {
|
||||||
auto message = parse_while([](u8 x) { return x != '\r'; });
|
auto message = consume_while([](u8 x) { return x != '\r'; });
|
||||||
consume("\r\n");
|
consume("\r\n");
|
||||||
m_response.data().set_bye(message.is_empty() ? Optional<String>() : Optional<String>(message));
|
m_response.data().set_bye(message.is_empty() ? Optional<String>() : Optional<String>(message));
|
||||||
} else if (try_consume("STATUS")) {
|
} else if (try_consume("STATUS")) {
|
||||||
|
@ -236,7 +236,7 @@ void Parser::parse_untagged()
|
||||||
try_consume(" "); // Not in the spec but the Outlook server sends a space for some reason.
|
try_consume(" "); // Not in the spec but the Outlook server sends a space for some reason.
|
||||||
consume("\r\n");
|
consume("\r\n");
|
||||||
} else {
|
} else {
|
||||||
auto x = parse_while([](u8 x) { return x != '\r'; });
|
auto x = consume_while([](u8 x) { return x != '\r'; });
|
||||||
consume("\r\n");
|
consume("\r\n");
|
||||||
dbgln("ignored {}", x);
|
dbgln("ignored {}", x);
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ void Parser::parse_untagged()
|
||||||
|
|
||||||
StringView Parser::parse_quoted_string()
|
StringView Parser::parse_quoted_string()
|
||||||
{
|
{
|
||||||
auto str = parse_while([](u8 x) { return x != '"'; });
|
auto str = consume_while([](u8 x) { return x != '"'; });
|
||||||
consume("\"");
|
consume("\"");
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,7 @@ FetchResponseData Parser::parse_fetch_response()
|
||||||
}
|
}
|
||||||
case FetchCommand::DataItemType::InternalDate: {
|
case FetchCommand::DataItemType::InternalDate: {
|
||||||
consume(" \"");
|
consume(" \"");
|
||||||
auto date_view = parse_while([](u8 x) { return x != '"'; });
|
auto date_view = consume_while([](u8 x) { return x != '"'; });
|
||||||
consume("\"");
|
consume("\"");
|
||||||
auto date = Core::DateTime::parse("%d-%b-%Y %H:%M:%S %z", date_view).value();
|
auto date = Core::DateTime::parse("%d-%b-%Y %H:%M:%S %z", date_view).value();
|
||||||
fetch_response.set_internal_date(date);
|
fetch_response.set_internal_date(date);
|
||||||
|
@ -574,7 +574,7 @@ ListItem Parser::parse_list_item()
|
||||||
flags |= static_cast<unsigned>(flag);
|
flags |= static_cast<unsigned>(flag);
|
||||||
}
|
}
|
||||||
consume(" \"");
|
consume(" \"");
|
||||||
auto reference = parse_while([](u8 x) { return x != '"'; });
|
auto reference = consume_while([](u8 x) { return x != '"'; });
|
||||||
consume("\" ");
|
consume("\" ");
|
||||||
auto mailbox = parse_astring();
|
auto mailbox = parse_astring();
|
||||||
consume("\r\n");
|
consume("\r\n");
|
||||||
|
@ -634,7 +634,7 @@ Vector<T> Parser::parse_list(T converter(StringView))
|
||||||
while (!try_consume(")")) {
|
while (!try_consume(")")) {
|
||||||
if (!first)
|
if (!first)
|
||||||
consume(" ");
|
consume(" ");
|
||||||
auto item = parse_while([](u8 x) {
|
auto item = consume_while([](u8 x) {
|
||||||
return x != ' ' && x != ')';
|
return x != ' ' && x != ')';
|
||||||
});
|
});
|
||||||
x.append(converter(item));
|
x.append(converter(item));
|
||||||
|
@ -677,7 +677,7 @@ MailboxFlag Parser::parse_mailbox_flag(StringView s)
|
||||||
return MailboxFlag::Unknown;
|
return MailboxFlag::Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringView Parser::parse_while(Function<bool(u8)> should_consume)
|
StringView Parser::consume_while(Function<bool(u8)> should_consume)
|
||||||
{
|
{
|
||||||
int chars = 0;
|
int chars = 0;
|
||||||
while (!at_end() && should_consume(m_buffer[position])) {
|
while (!at_end() && should_consume(m_buffer[position])) {
|
||||||
|
@ -689,13 +689,13 @@ StringView Parser::parse_while(Function<bool(u8)> should_consume)
|
||||||
|
|
||||||
FetchCommand::DataItem Parser::parse_fetch_data_item()
|
FetchCommand::DataItem Parser::parse_fetch_data_item()
|
||||||
{
|
{
|
||||||
auto msg_attr = parse_while([](u8 x) { return is_ascii_alpha(x) != 0; });
|
auto msg_attr = consume_while([](u8 x) { return is_ascii_alpha(x) != 0; });
|
||||||
if (msg_attr.equals_ignoring_case("BODY") && try_consume("[")) {
|
if (msg_attr.equals_ignoring_case("BODY") && try_consume("[")) {
|
||||||
auto data_item = FetchCommand::DataItem {
|
auto data_item = FetchCommand::DataItem {
|
||||||
.type = FetchCommand::DataItemType::BodySection,
|
.type = FetchCommand::DataItemType::BodySection,
|
||||||
.section = { {} }
|
.section = { {} }
|
||||||
};
|
};
|
||||||
auto section_type = parse_while([](u8 x) { return x != ']' && x != ' '; });
|
auto section_type = consume_while([](u8 x) { return x != ']' && x != ' '; });
|
||||||
if (section_type.equals_ignoring_case("HEADER.FIELDS")) {
|
if (section_type.equals_ignoring_case("HEADER.FIELDS")) {
|
||||||
data_item.section->type = FetchCommand::DataItem::SectionType::HeaderFields;
|
data_item.section->type = FetchCommand::DataItem::SectionType::HeaderFields;
|
||||||
data_item.section->headers = Vector<String>();
|
data_item.section->headers = Vector<String>();
|
||||||
|
|
|
@ -36,6 +36,7 @@ private:
|
||||||
void parse_response_done();
|
void parse_response_done();
|
||||||
|
|
||||||
void consume(StringView x);
|
void consume(StringView x);
|
||||||
|
StringView consume_while(Function<bool(u8)> should_consume);
|
||||||
|
|
||||||
unsigned parse_number();
|
unsigned parse_number();
|
||||||
Optional<unsigned> try_parse_number();
|
Optional<unsigned> try_parse_number();
|
||||||
|
@ -54,7 +55,6 @@ private:
|
||||||
|
|
||||||
static MailboxFlag parse_mailbox_flag(StringView s);
|
static MailboxFlag parse_mailbox_flag(StringView s);
|
||||||
|
|
||||||
StringView parse_while(Function<bool(u8)> should_consume);
|
|
||||||
|
|
||||||
void parse_capability_response();
|
void parse_capability_response();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue