summaryrefslogtreecommitdiff
path: root/Userland/hostname.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-10-26 09:54:29 +0200
committerAndreas Kling <awesomekling@gmail.com>2018-10-26 09:54:29 +0200
commit53abfa7ea1ef7ea1b9e47ca9818e48ab0fa32b8b (patch)
tree5cdfe5eecde7630e3d492bbfc4e6734e78a1c25c /Userland/hostname.cpp
parent3faaa3e04a3eef72554e9235cb81327642b62ab7 (diff)
downloadserenity-53abfa7ea1ef7ea1b9e47ca9818e48ab0fa32b8b.zip
Add sys$gethostname and /bin/hostname
Diffstat (limited to 'Userland/hostname.cpp')
-rw-r--r--Userland/hostname.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/Userland/hostname.cpp b/Userland/hostname.cpp
new file mode 100644
index 0000000000..f33ca87c72
--- /dev/null
+++ b/Userland/hostname.cpp
@@ -0,0 +1,17 @@
+#include <LibC/unistd.h>
+#include <LibC/stdio.h>
+#include <LibC/errno.h>
+#include <LibC/string.h>
+
+int main(int c, char** v)
+{
+ char buffer[HOST_NAME_MAX];
+ int rc = gethostname(buffer, sizeof(buffer));
+ if (rc < 0) {
+ printf("gethostname() error: %s\n", strerror(errno));
+ return 1;
+ }
+ printf("%s\n", buffer);
+ return 0;
+}
+