mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +00:00
Userland: Run clang-format on everything.
This commit is contained in:
parent
f7ede145b4
commit
b07bbf383d
48 changed files with 271 additions and 268 deletions
|
@ -1,6 +1,6 @@
|
|||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static volatile bool got_alarm = false;
|
||||
|
||||
|
@ -11,7 +11,7 @@ int main(int c, char** v)
|
|||
ret = alarm(2);
|
||||
printf("alarm() with an alarm(5) set: %u\n", ret);
|
||||
|
||||
signal(SIGALRM, [] (int) {
|
||||
signal(SIGALRM, [](int) {
|
||||
got_alarm = true;
|
||||
});
|
||||
printf("Entering infinite loop.\n");
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (argc != 3) {
|
||||
printf("usage: chmod <octal-mode> <path>\n");
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
printf("usage: chown <uid[:gid]> <path>\n");
|
||||
|
|
|
@ -6,4 +6,3 @@ int main(int, char**)
|
|||
fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <assert.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
|
|
@ -10,7 +10,13 @@ static void print_usage_and_exit()
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
enum Mode { SegmentationViolation, DivisionByZero, IllegalInstruction, Abort };
|
||||
enum Mode
|
||||
{
|
||||
SegmentationViolation,
|
||||
DivisionByZero,
|
||||
IllegalInstruction,
|
||||
Abort
|
||||
};
|
||||
Mode mode = SegmentationViolation;
|
||||
|
||||
if (argc != 2)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
@ -21,4 +21,3 @@ int main(int argc, char** argv)
|
|||
tm->tm_sec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct FileSystem {
|
||||
String fs;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#include <LibCore/CFile.h>
|
||||
#include <assert.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <LibCore/CFile.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
CFile f("/proc/dmesg");
|
||||
if (!f.open(CIODevice::ReadOnly)) {
|
||||
fprintf(stderr, "open: failed to open /proc/dmesg: %s", f.error_string());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
#include <Kernel/Syscall.h>
|
||||
#include <SharedGraphics/GraphicsBitmap.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
#include <LibGUI/GWidget.h>
|
||||
#include <LibGUI/GLabel.h>
|
||||
#include <LibGUI/GButton.h>
|
||||
#include <LibGUI/GTextBox.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GCheckBox.h>
|
||||
#include <LibGUI/GProgressBar.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GButton.h>
|
||||
#include <LibGUI/GCheckBox.h>
|
||||
#include <LibGUI/GLabel.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GProgressBar.h>
|
||||
#include <LibGUI/GTextBox.h>
|
||||
#include <LibGUI/GWidget.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
#include <SharedGraphics/GraphicsBitmap.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static GWindow* make_launcher_window();
|
||||
static GWindow* make_progress_window();
|
||||
|
@ -69,7 +69,7 @@ GWindow* make_launcher_window()
|
|||
terminal_button->set_relative_rect({ 5, 20, 90, 20 });
|
||||
terminal_button->set_text("Terminal");
|
||||
|
||||
terminal_button->on_click = [label] (GButton&) {
|
||||
terminal_button->on_click = [label](GButton&) {
|
||||
pid_t child_pid = fork();
|
||||
if (!child_pid) {
|
||||
execve("/bin/Terminal", nullptr, nullptr);
|
||||
|
@ -85,7 +85,7 @@ GWindow* make_launcher_window()
|
|||
guitest_button->set_relative_rect({ 5, 50, 90, 20 });
|
||||
guitest_button->set_text("guitest");
|
||||
|
||||
guitest_button->on_click = [label] (GButton&) {
|
||||
guitest_button->on_click = [label](GButton&) {
|
||||
pid_t child_pid = fork();
|
||||
if (!child_pid) {
|
||||
execve("/bin/guitest", nullptr, nullptr);
|
||||
|
@ -120,7 +120,7 @@ GWindow* make_launcher_window()
|
|||
auto* close_button = new GButton(widget);
|
||||
close_button->set_relative_rect({ 5, 200, 90, 20 });
|
||||
close_button->set_text("Close");
|
||||
close_button->on_click = [window] (GButton&) {
|
||||
close_button->on_click = [window](GButton&) {
|
||||
window->close();
|
||||
};
|
||||
|
||||
|
@ -169,7 +169,7 @@ static GWindow* make_frames_window()
|
|||
widget->layout()->set_margins({ 8, 8, 8, 8 });
|
||||
widget->layout()->set_spacing(8);
|
||||
|
||||
auto add_label = [widget] (const String& text, FrameShape shape, FrameShadow shadow) {
|
||||
auto add_label = [widget](const String& text, FrameShape shape, FrameShadow shadow) {
|
||||
auto* label = new GLabel(text, widget);
|
||||
label->set_size_policy(SizePolicy::Fill, SizePolicy::Fill);
|
||||
label->set_frame_thickness(1);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <LibCore/CArgsParser.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <LibCore/CArgsParser.h>
|
||||
|
||||
int head(const String& filename, bool print_filename, int line_count);
|
||||
|
||||
|
@ -40,7 +40,7 @@ int main(int argc, char** argv)
|
|||
|
||||
int rc = 0;
|
||||
|
||||
for (auto &file : files) {
|
||||
for (auto& file : files) {
|
||||
if (head(file, print_filenames, line_count) != 0) {
|
||||
rc = 1;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
char buffer[HOST_NAME_MAX];
|
||||
int rc = gethostname(buffer, sizeof(buffer));
|
||||
if (rc < 0) {
|
||||
|
@ -16,4 +16,3 @@ int main(int argc, char** argv)
|
|||
printf("%s\n", buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <alloca.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern "C" int main(int, char**);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
uid_t uid = getuid();
|
||||
gid_t gid = getgid();
|
||||
|
||||
|
@ -40,4 +40,3 @@ int main(int argc, char** argv)
|
|||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void print_usage_and_exit()
|
||||
{
|
||||
|
@ -38,4 +38,3 @@ int main(int argc, char** argv)
|
|||
perror("kill");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <LibCore/CProcessStatisticsReader.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <LibCore/CProcessStatisticsReader.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void print_usage_and_exit()
|
||||
{
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <LibCore/CArgsParser.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
@ -35,4 +35,3 @@ int main(int argc, char** argv)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/CDirIterator.h>
|
||||
#include <pwd.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static int do_file_system_object_long(const char* path);
|
||||
static int do_file_system_object_short(const char* path);
|
||||
|
@ -51,7 +51,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
}
|
||||
|
||||
auto do_file_system_object = [&] (const char* path) {
|
||||
auto do_file_system_object = [&](const char* path) {
|
||||
if (flag_long)
|
||||
return do_file_system_object_long(path);
|
||||
return do_file_system_object_short(path);
|
||||
|
@ -60,7 +60,7 @@ int main(int argc, char** argv)
|
|||
int status;
|
||||
if (optind >= argc) {
|
||||
status = do_file_system_object(".");
|
||||
} else if (optind+1 >= argc) {
|
||||
} else if (optind + 1 >= argc) {
|
||||
status = do_file_system_object(argv[optind]);
|
||||
} else {
|
||||
for (; optind < argc; ++optind) {
|
||||
|
@ -119,7 +119,8 @@ int print_name(struct stat& st, const char* name, const char* path_for_link_reso
|
|||
return nprinted;
|
||||
}
|
||||
|
||||
bool print_filesystem_object(const char* path, const char* name) {
|
||||
bool print_filesystem_object(const char* path, const char* name)
|
||||
{
|
||||
struct stat st;
|
||||
int rc = lstat(path, &st);
|
||||
if (rc == -1) {
|
||||
|
@ -155,8 +156,7 @@ bool print_filesystem_object(const char* path, const char* name) {
|
|||
st.st_mode & S_IWGRP ? 'w' : '-',
|
||||
st.st_mode & S_ISGID ? 's' : (st.st_mode & S_IXGRP ? 'x' : '-'),
|
||||
st.st_mode & S_IROTH ? 'r' : '-',
|
||||
st.st_mode & S_IWOTH ? 'w' : '-'
|
||||
);
|
||||
st.st_mode & S_IWOTH ? 'w' : '-');
|
||||
|
||||
if (st.st_mode & S_ISVTX)
|
||||
printf("t");
|
||||
|
@ -166,14 +166,14 @@ bool print_filesystem_object(const char* path, const char* name) {
|
|||
passwd* pwd = getpwuid(st.st_uid);
|
||||
group* grp = getgrgid(st.st_gid);
|
||||
if (!flag_print_numeric && pwd) {
|
||||
printf(" %5s", pwd->pw_name);
|
||||
printf(" %5s", pwd->pw_name);
|
||||
} else {
|
||||
printf(" %5u", st.st_uid);
|
||||
printf(" %5u", st.st_uid);
|
||||
}
|
||||
if (!flag_print_numeric && grp) {
|
||||
printf(" %5s", grp->gr_name);
|
||||
printf(" %5s", grp->gr_name);
|
||||
} else {
|
||||
printf(" %5u", st.st_gid);
|
||||
printf(" %5u", st.st_gid);
|
||||
}
|
||||
|
||||
if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))
|
||||
|
@ -221,8 +221,8 @@ int do_file_system_object_long(const char* path)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool print_filesystem_object_short(const char *path, const char *name, int *nprinted) {
|
||||
bool print_filesystem_object_short(const char* path, const char* name, int* nprinted)
|
||||
{
|
||||
struct stat st;
|
||||
int rc = lstat(path, &st);
|
||||
if (rc == -1) {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
inline constexpr unsigned encoded_device(unsigned major, unsigned minor)
|
||||
{
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include <LibCore/CFile.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <LibCore/CFile.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
CFile f("/proc/mm");
|
||||
if (!f.open(CIODevice::ReadOnly)) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static int key_fd;
|
||||
|
||||
|
@ -16,8 +16,8 @@ void wait_for_key()
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
key_fd = open(ttyname(1), O_RDONLY);
|
||||
if (key_fd < 0) {
|
||||
|
@ -39,7 +39,6 @@ int main(int argc, char** argv)
|
|||
if ((lines_printed % (ws.ws_row - 1)) == 0) {
|
||||
wait_for_key();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
close(key_fd);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <LibCore/CArgsParser.h>
|
||||
#include <LibCore/CDirIterator.h>
|
||||
#include <LibGUI/GDesktop.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GDesktop.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static int handle_show_all()
|
||||
{
|
||||
|
@ -73,4 +73,3 @@ int main(int argc, char** argv)
|
|||
|
||||
return handle_set_pape(values[0]);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <LibCore/CProcessStatisticsReader.h>
|
||||
#include <LibCore/CArgsParser.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/CArgsParser.h>
|
||||
#include <LibCore/CProcessStatisticsReader.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static int pid_of(const String& process_name, bool single_shot, bool omit_pid, pid_t pid)
|
||||
{
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/ip_icmp.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip_icmp.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
uint16_t internet_checksum(const void* ptr, size_t count)
|
||||
{
|
||||
uint32_t checksum = 0;
|
||||
uint32_t checksum = 0;
|
||||
auto* w = (const uint16_t*)ptr;
|
||||
while (count > 1) {
|
||||
checksum += ntohs(*w++);
|
||||
|
@ -47,7 +47,9 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
struct timeval timeout { 1, 0 };
|
||||
struct timeval timeout {
|
||||
1, 0
|
||||
};
|
||||
int rc = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
|
||||
if (rc < 0) {
|
||||
perror("setsockopt");
|
||||
|
@ -131,8 +133,7 @@ int main(int argc, char** argv)
|
|||
ntohs(pong_packet.header.un.echo.id),
|
||||
ntohs(pong_packet.header.un.echo.sequence),
|
||||
pong_packet.header.un.echo.sequence != ping_packet.header.un.echo.sequence ? "(!)" : "",
|
||||
ms
|
||||
);
|
||||
ms);
|
||||
|
||||
// If this was a response to an earlier packet, we still need to wait for the current one.
|
||||
if (pong_packet.header.un.echo.sequence != ping_packet.header.un.echo.sequence)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include <LibCore/CFile.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <LibCore/CFile.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
CFile f("/proc/summary");
|
||||
if (!f.open(CIODevice::ReadOnly)) {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include <SharedGraphics/PNGLoader.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
#include <LibGUI/GLabel.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GMenuBar.h>
|
||||
#include <LibGUI/GMenu.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GLabel.h>
|
||||
#include <LibGUI/GMenu.h>
|
||||
#include <LibGUI/GMenuBar.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
#include <SharedGraphics/PNGLoader.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
@ -15,7 +15,7 @@ int main(int argc, char** argv)
|
|||
auto menubar = make<GMenuBar>();
|
||||
|
||||
auto app_menu = make<GMenu>("QuickShow");
|
||||
app_menu->add_action(GAction::create("Quit", { Mod_Alt, Key_F4 }, [] (const GAction&) {
|
||||
app_menu->add_action(GAction::create("Quit", { Mod_Alt, Key_F4 }, [](const GAction&) {
|
||||
GApplication::the().quit(0);
|
||||
return;
|
||||
}));
|
||||
|
@ -25,7 +25,7 @@ int main(int argc, char** argv)
|
|||
menubar->add_menu(move(file_menu));
|
||||
|
||||
auto help_menu = make<GMenu>("Help");
|
||||
help_menu->add_action(GAction::create("About", [] (const GAction&) {
|
||||
help_menu->add_action(GAction::create("About", [](const GAction&) {
|
||||
dbgprintf("FIXME: Implement Help/About\n");
|
||||
}));
|
||||
menubar->add_menu(move(help_menu));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
@ -15,4 +15,3 @@ int main(int argc, char** argv)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void handle_sigint(int)
|
||||
{
|
||||
|
@ -29,4 +29,3 @@ int main(int argc, char** argv)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <AK/AKString.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -16,7 +16,7 @@ int main(int argc, char** argv)
|
|||
lines.append(buffer);
|
||||
}
|
||||
|
||||
quick_sort(lines.begin(), lines.end(), [] (auto& a, auto& b) {
|
||||
quick_sort(lines.begin(), lines.end(), [](auto& a, auto& b) {
|
||||
return strcmp(a.characters(), b.characters()) < 0;
|
||||
});
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
@ -62,8 +62,7 @@ int main(int argc, char** argv)
|
|||
st.st_mode & S_IWGRP ? 'w' : '-',
|
||||
st.st_mode & S_ISGID ? 's' : (st.st_mode & S_IXGRP ? 'x' : '-'),
|
||||
st.st_mode & S_IROTH ? 'r' : '-',
|
||||
st.st_mode & S_IWOTH ? 'w' : '-'
|
||||
);
|
||||
st.st_mode & S_IWOTH ? 'w' : '-');
|
||||
|
||||
if (st.st_mode & S_ISVTX)
|
||||
printf("t");
|
||||
|
@ -72,7 +71,7 @@ int main(int argc, char** argv)
|
|||
|
||||
printf(")\n");
|
||||
|
||||
auto print_time = [] (time_t t) {
|
||||
auto print_time = [](time_t t) {
|
||||
auto* tm = localtime(&t);
|
||||
printf("%4u-%02u-%02u %02u:%02u:%02u\n",
|
||||
tm->tm_year + 1900,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Syscall.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static int usage()
|
||||
{
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <alloca.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern "C" int main(int, char**);
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/CArgsParser.h>
|
||||
#include <LibCore/CDirIterator.h>
|
||||
#include <LibCore/CFile.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static String read_var(const String& name)
|
||||
{
|
||||
|
@ -48,7 +48,6 @@ static void write_var(const String& name, const String& value)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static int handle_show_all()
|
||||
{
|
||||
CDirIterator di("/proc/sys", CDirIterator::SkipDots);
|
||||
|
@ -102,4 +101,3 @@ int main(int argc, char** argv)
|
|||
Vector<String> values = args.get_single_values();
|
||||
return handle_var(values[0]);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <AK/Assertions.h>
|
||||
#include <LibCore/CFile.h>
|
||||
#include <LibCore/CArgsParser.h>
|
||||
#include <LibCore/CFile.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define DEFAULT_LINE_COUNT 10
|
||||
|
||||
|
@ -50,7 +50,7 @@ off_t find_seek_pos(CFile& file, int wanted_lines)
|
|||
|
||||
// FIXME: Reading char-by-char is only OK if CIODevice's read buffer
|
||||
// is smart enough to not read char-by-char. Fix it there, or fix it here :)
|
||||
for(; pos >= 0; pos--) {
|
||||
for (; pos >= 0; pos--) {
|
||||
file.seek(pos);
|
||||
const auto& ch = file.read(1);
|
||||
if (ch.is_empty()) {
|
||||
|
@ -74,7 +74,7 @@ static void exit_because_we_wanted_lines()
|
|||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
CArgsParser args_parser("tail");
|
||||
|
||||
|
@ -98,7 +98,7 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
} else {
|
||||
line_count = DEFAULT_LINE_COUNT;
|
||||
line_count = DEFAULT_LINE_COUNT;
|
||||
}
|
||||
|
||||
CFile f(values[0]);
|
||||
|
|
|
@ -20,7 +20,9 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
struct timeval timeout { 3, 0 };
|
||||
struct timeval timeout {
|
||||
3, 0
|
||||
};
|
||||
int rc = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
|
||||
if (rc < 0) {
|
||||
perror("setsockopt");
|
||||
|
|
|
@ -120,4 +120,3 @@ int main(int argc, char** argv)
|
|||
|
||||
return (err_open || err_write) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <fcntl.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static HashMap<unsigned, String>* s_usernames;
|
||||
|
||||
|
@ -89,14 +89,14 @@ int main(int, char**)
|
|||
|
||||
printf("\033[3J\033[H\033[2J");
|
||||
printf("\033[47;30m%6s %3s % 8s % 8s %6s %6s %4s %s\033[K\033[0m\n",
|
||||
"PID",
|
||||
"PRI",
|
||||
"USER",
|
||||
"STATE",
|
||||
"LINEAR",
|
||||
"COMMIT",
|
||||
"%CPU",
|
||||
"NAME");
|
||||
"PID",
|
||||
"PRI",
|
||||
"USER",
|
||||
"STATE",
|
||||
"LINEAR",
|
||||
"COMMIT",
|
||||
"%CPU",
|
||||
"NAME");
|
||||
for (auto& it : current.map) {
|
||||
pid_t pid = it.key;
|
||||
if (pid == 0)
|
||||
|
@ -108,13 +108,12 @@ int main(int, char**)
|
|||
dword nsched_before = (*jt).value.nsched;
|
||||
dword nsched_diff = nsched_now - nsched_before;
|
||||
it.value.nsched_since_prev = nsched_diff;
|
||||
it.value.cpu_percent = ((nsched_diff * 100)/ sum_diff);
|
||||
it.value.cpu_percent_decimal = (((nsched_diff * 1000)/ sum_diff) % 10);
|
||||
it.value.cpu_percent = ((nsched_diff * 100) / sum_diff);
|
||||
it.value.cpu_percent_decimal = (((nsched_diff * 1000) / sum_diff) % 10);
|
||||
processes.append(&it.value);
|
||||
}
|
||||
|
||||
|
||||
quick_sort(processes.begin(), processes.end(), [] (auto* p1, auto* p2) {
|
||||
quick_sort(processes.begin(), processes.end(), [](auto* p1, auto* p2) {
|
||||
return p2->nsched_since_prev < p1->nsched_since_prev;
|
||||
});
|
||||
|
||||
|
@ -128,8 +127,7 @@ int main(int, char**)
|
|||
process->committed / 1024,
|
||||
process->cpu_percent,
|
||||
process->cpu_percent_decimal,
|
||||
process->name.characters()
|
||||
);
|
||||
process->name.characters());
|
||||
}
|
||||
processes.clear_with_capacity();
|
||||
prev = move(current);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <utime.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <utime.h>
|
||||
|
||||
static bool file_exists(const char* path)
|
||||
{
|
||||
|
@ -46,4 +46,3 @@ int main(int argc, char** argv)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <AK/AKString.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
struct winsize ws;
|
||||
int rc = ioctl(0, TIOCGWINSZ, &ws);
|
||||
|
|
|
@ -20,7 +20,9 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
struct timeval timeout { 5, 0 };
|
||||
struct timeval timeout {
|
||||
5, 0
|
||||
};
|
||||
int rc = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
|
||||
if (rc < 0) {
|
||||
perror("setsockopt");
|
||||
|
@ -41,12 +43,12 @@ int main(int argc, char** argv)
|
|||
char buffer[BUFSIZ];
|
||||
const char* msg = "Test message";
|
||||
|
||||
sendto(fd, (const char *)msg, strlen(msg), 0,(const struct sockaddr *)&dst_addr, sizeof(dst_addr));
|
||||
sendto(fd, (const char*)msg, strlen(msg), 0, (const struct sockaddr*)&dst_addr, sizeof(dst_addr));
|
||||
printf("Message sent.\n");
|
||||
|
||||
struct sockaddr_in src_addr;
|
||||
socklen_t src_addr_len = sizeof(src_addr);
|
||||
ssize_t nrecv = recvfrom(fd, (char *)buffer, sizeof(buffer), 0, (struct sockaddr*)&src_addr, &src_addr_len);
|
||||
ssize_t nrecv = recvfrom(fd, (char*)buffer, sizeof(buffer), 0, (struct sockaddr*)&src_addr, &src_addr_len);
|
||||
if (nrecv < 0) {
|
||||
perror("recvfrom");
|
||||
return 1;
|
||||
|
|
|
@ -20,11 +20,21 @@ int main(int argc, char** argv)
|
|||
if (argv[i][0] == '-') {
|
||||
for (const char* o = &argv[i][1]; *o; ++o) {
|
||||
switch (*o) {
|
||||
case 's': flag_s = true; break;
|
||||
case 'n': flag_n = true; break;
|
||||
case 'r': flag_r = true; break;
|
||||
case 'm': flag_m = true; break;
|
||||
case 'a': flag_s = flag_n = flag_r = flag_m = true; break;
|
||||
case 's':
|
||||
flag_s = true;
|
||||
break;
|
||||
case 'n':
|
||||
flag_n = true;
|
||||
break;
|
||||
case 'r':
|
||||
flag_r = true;
|
||||
break;
|
||||
case 'm':
|
||||
flag_m = true;
|
||||
break;
|
||||
case 'a':
|
||||
flag_s = flag_n = flag_r = flag_m = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,4 +53,3 @@ int main(int argc, char** argv)
|
|||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue