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