mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
IPCMagicLinter: Use LibMain
This commit is contained in:
parent
4dcdc3bd25
commit
b35a6b206b
Notes:
sideshowbarker
2024-07-16 22:26:05 +09:00
Author: https://github.com/LucasChollet Commit: https://github.com/SerenityOS/serenity/commit/b35a6b206b Pull-request: https://github.com/SerenityOS/serenity/pull/18528
2 changed files with 7 additions and 7 deletions
|
@ -2,4 +2,4 @@ set(SOURCES
|
|||
main.cpp
|
||||
)
|
||||
|
||||
lagom_tool(IPCMagicLinter)
|
||||
lagom_tool(IPCMagicLinter LIBS LibMain)
|
||||
|
|
|
@ -8,23 +8,23 @@
|
|||
#include <AK/StringView.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
||||
// Exit code is bitwise-or of these values:
|
||||
static constexpr auto EXIT_COLLISION = 0x1;
|
||||
static constexpr auto EXIT_ERROR = 0x2;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
if (argc < 3) {
|
||||
warnln("Usage: {} path/to/some.ipc path/to/other.ipc [more ipc files ...]", argv[0]);
|
||||
if (arguments.argc < 3) {
|
||||
warnln("Usage: {} path/to/some.ipc path/to/other.ipc [more ipc files ...]", arguments.strings[0]);
|
||||
return EXIT_ERROR;
|
||||
}
|
||||
|
||||
// Read files, compute their hashes, ignore collisions for now.
|
||||
HashMap<u32, Vector<DeprecatedString>> inverse_hashes;
|
||||
bool had_errors = false;
|
||||
for (int file_index = 1; file_index < argc; ++file_index) {
|
||||
DeprecatedString filename(argv[file_index]);
|
||||
for (auto filename : arguments.strings.slice(1)) {
|
||||
auto file_or_error = Core::DeprecatedFile::open(filename, Core::OpenMode::ReadOnly);
|
||||
if (file_or_error.is_error()) {
|
||||
warnln("Error: Cannot open '{}': {}", filename, file_or_error.error());
|
||||
|
@ -77,7 +77,7 @@ int main(int argc, char** argv)
|
|||
had_collisions = true;
|
||||
}
|
||||
|
||||
outln("Checked {} files, saw {} distinct magic numbers.", argc - 1, inverse_hashes.size());
|
||||
outln("Checked {} files, saw {} distinct magic numbers.", arguments.argc - 1, inverse_hashes.size());
|
||||
if (had_collisions)
|
||||
outln("Consider giving your new service a different name.");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue