summaryrefslogtreecommitdiff
path: root/Libraries/LibCore
AgeCommit message (Collapse)Author
2020-06-22LibCore: Remove some debug spam in Local{Server,Socket}Andreas Kling
2020-06-22LibCore: Put safe_syscall() debug spam behind #ifdefAndreas Kling
2020-06-21LibCore: Add API for taking over an accepted socket from SystemServerAndreas Kling
Core::LocalSocket::take_over_accepted_socket_from_system_server() now allows you to construct a Core::LocalSocket for a pre-accepted socket when using SystemServer's new AcceptSocketConnections mode.
2020-06-17LibCore: Add File::read_link() :^)Sergey Bugaev
This is a convenient wrapper around readlink() that hides away the details of buffers and buffer sizes, and simply returns a String. The best part is it doesn't rely on PATH_MAX :D It comes in two versions, for Serenity, where we can pass non-null-terminated strings to syscalls, and where sys$readlink() returns the total link size, and for other systems, where we have to copy out the string, and always have to do two syscalls.
2020-06-13AK: JsonParser improvementsMatthew Olsson
- Parsing invalid JSON no longer asserts Instead of asserting when coming across malformed JSON, JsonParser::parse now returns an Optional<JsonValue>. - Disallow trailing commas in JSON objects and arrays - No longer parse 'undefined', as that is a purely JS thing - No longer allow non-whitespace after anything consumed by the initial parse() call. Examples of things that were valid and no longer are: - undefineddfz - {"foo": 1}abcd - [1,2,3]4 - JsonObject.for_each_member now iterates in original insertion order
2020-06-12LibCore: Add Core::File::real_path_for()Andreas Kling
A slightly convenient wrapper around realpath(3).
2020-06-12AK: Make string-to-number conversion helpers return OptionalAndreas Kling
Get rid of the weird old signature: - int StringType::to_int(bool& ok) const And replace it with sensible new signature: - Optional<int> StringType::to_int() const
2020-06-11LibCore: Fix typo in Forward.hAndreas Kling
2020-06-11LibCore: Add Timer::restart() convenience APIAndreas Kling
This simply restarts the timer with the existing millisecond interval.
2020-06-08LibCore: Make sure to disable notifiers when closing a socketSergey Bugaev
RefPtr<Notifier> doesn't work quite like it appears to, since the notifier is also a "child" of the socket, in Core::Object sense. Thus we have to both remove it from the parent (socket) and drop the additional RefPtr<Notifier> for it to actually go away. A proper fix for this would be to untangle parent-child relashionship from refcounting and inspectability. This fixes use-after-close of client file descriptors in IPC servers.
2020-06-02LibCore: Put some annoying debug spam behind EVENTLOOP_DEBUGAndreas Kling
2020-05-30LibCore: Update Core::ArgsParser to the new error message formatSergey Bugaev
2020-05-30Lagom: Adjust AK, LibCore and LibTLS to build on MacOSMarcin Gasperowicz
2020-05-29Meta: Add a script check the presence of "#pragma once" in header filesEmanuele Torre
.. and make travis run it. I renamed check-license-headers.sh to check-style.sh and expanded it so that it now also checks for the presence of "#pragma once" in .h files. It also checks the presence of a (single) blank line above and below the "#pragma once" line. I also added "#pragma once" to all the files that need it: even the ones we are not check. I also added/removed blank lines in order to make the script not fail. I also ran clang-format on the files I modified.
2020-05-29LibCore+Inspector: Move RPC sockets to /tmp/rpcSergey Bugaev
We have a hierarchical filesystem, let's make use of it :^)
2020-05-29LibCore: Do not assert that we can start the RPC serverSergey Bugaev
Now that the Shell uses Core::EventLoop, we can't afford to just crash if /tmp is unwritable.
2020-05-26AK: Rename FileSystemPath -> LexicalPathSergey Bugaev
And move canonicalized_path() to a static method on LexicalPath. This is to make it clear that FileSystemPath/canonicalized_path() only perform *lexical* canonicalization.
2020-05-23Build: Make Lagom build under macOS (#2341)Marcin Gasperowicz
Lagom now builds under macOS. Only two minor adjustments were required: * LibCore TCP/UDP code can't use `SOCK_{NONBLOCK,CLOEXEC}` on macOS, use ioctl() and fcntl() instead * LibJS `Heap` code pthread usage ported to MacOS
2020-05-18LibCore+LibTLS: Don't keep a "ready to write" notifier on all SocketsAndreas Kling
The "ready to write" notifier we set up in generic socket connection is really only meant to detect a successful connection. Once we have a TCP connection, for example, it will fire on every event loop iteration. This was causing IRC Client to max out the CPU by getting this no-op notifier callback over and over. Since this was only used by TLSv12, I changed that code to create its own notifier instead. It might be possible to improve TLS performance by only processing writes when actually needed, but I didn't look very closely at that for this patch. :^)
2020-05-17LibCore: Allow ArgsParser::parse() to not exit on failureAnotherTest
This allows its use in places where multiple calls to ArgsParser::parse() are needed, such as Shell builtins.
2020-05-17LibCore: Reset getopt's state when starting parse()AnotherTest
This way, a program can use ArgsParser multiple times, potentially with multiple different options.
2020-05-16LibCore: Always wait_for_events() when pumping the event loopAndreas Kling
This fixes an issue where continuously posting new events to the queue would keep the event loop saturated, causing it to ignore notifiers. Since notifiers are part of the big select(), we always have to call wait_for_events() even if there are pending events. We're already smart enough to select() without a timeout if we already have pending events.
2020-05-15LibCore: Fix timer expiration processingSergey Bugaev
The previous code did not account for the case when there are timers present, but none are enabled, and used a zero polling timeout. Fixes https://github.com/SerenityOS/serenity/issues/2222
2020-05-15LibCore: Make IODevice::can_read_line() constAnotherTest
This also makes LibHTTP's Job::can_read_line() const, as IODevice was keeping that from being const. Fixes #2219
2020-05-14Build: Switch to CMake :^)Sergey Bugaev
Closes https://github.com/SerenityOS/serenity/issues/2080
2020-05-09LibDesktop: Switch to LaunchServer for DesktopServices::openNicholas Hollett
Moves DirectoryServices out of LibCore (because we need to link with LibIPC), renames it Desktop::Launcher (because Desktop::DesktopServices doesn't scan right) and ports it to use the LaunchServer which is now responsible for starting programs for a file.
2020-05-08LibCore: DesktopServices, open fonts with FontEditorHüseyin ASLITÜRK
2020-05-07LibCore: Add a primitive comparison function to DateTimeAnotherTest
This should go away when we get the ability to parse strings to DateTime's.
2020-05-06Misc: Replace "String(string_view)" with "string_view.to_string()"Linus Groh
StringView::to_string() was added in 917ccb1 but not actually used anywhere yet.
2020-05-05LibCore: Add a standard downloads directory (~/Downloads)Andreas Kling
2020-05-03ProtocolServer: Implement and handle download progressAnotherTest
Also updates `pro` to display download progress and speed on stderr
2020-05-02LibCore+LibHTTP: Move out the HTTP handler and add HTTPSAnotherTest
2020-05-02LibCore: Mark Socket::{common_,}connect() virtual and add a on_writeAnotherTest
2020-04-30LibCore: Do not assert that NonnullRefPtr is non-nullSergey Bugaev
Clang complains about this; with the change the next commit is going to make to ASSERT() internals, GCC is going to start to complain as well.
2020-04-30LibCore: Don't continue in forked child if exec() failsAndreas Kling
Fixes #1854.
2020-04-28LibCore: Trim decompressed Gzip output to sizeAnotherTest
Prior to this commit, we would (re-)allocate the output buffer aligned to 1024 bytes, but never trim it down to size, which caused Gzip::decompress to return uninitialised data.
2020-04-26LibCore: Open gif files with QuickShowHüseyin ASLITÜRK
2020-04-23LibCore: read_bool_entry parse "true" / "false" strings in config filesBrendan Coles
`read_bool_entry()` can now interpret both integers (1 or 0) and Boolean strings ("true" or "false") in configuration files. All values other than "1" or "true" are considered false.
2020-04-23DesktopServices: Add irc URL protocol handlerBrendan Coles
2020-04-21LibCore: Make Core::File::open() return a Result<NNRP<File>, String>Andreas Kling
It was impractical to return a RefPtr<File> since that left us no way to extract the error string. This is usually needed for the UI, so the old static open() got basically no use.
2020-04-19LibCore: Add StandardPaths thing to retrieve various standard locationsAndreas Kling
Fixes #1853.
2020-04-19LibCore: Check for fork() failureSergey Bugaev
For those good boy points :^)
2020-04-19LibCore+LibGUI: Move DesktopServices to LibCoreSergey Bugaev
2020-04-07LibCore: Add Core::Timer::create_single_shot()Andreas Kling
This is just a convenience function for creating single-shot timers.
2020-04-06AK: Make dbgprintf() and dbgputstr() go to stderr on non-Serenity hostsAndreas Kling
2020-04-04LibCore: Fix UDPServer up to properly receive dataAnotherTest
Prior to this, UDPServer was using listen/accept, which does not make sense in the context of UDP.
2020-04-03LibCore: Don't replay last handled event when leaving nested event loopAndreas Kling
The event that triggered the exit from an inner event loop would always get re-delivered in the outer event loop due to a silly off-by-one mistake when transferring pending events between loops.
2020-03-30LibCore: Add a static Core::File::open() convenience functionAndreas Kling
This helper opens a file with a given name, mode and permissions and returns it in a RefPtr<File>. I think this will be a bit nicer to use than having to go through Core::File::construct() every time.
2020-03-23LibCore: Tweak DateTime.cpp so it compiles on Linux + drive-by bug fixAndreas Kling
2020-03-22LibCore: Wrap commented out debug messages in a preprocessor defineShannon Booth
We can also remove an outdated FIXME as dbg() does now support unsigned longs :^)