aboutsummaryrefslogtreecommitdiff
path: root/hostname.c
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-03-18 10:36:22 +1300
committerTom Ryder <tom@sanctum.geek.nz>2016-03-18 10:36:22 +1300
commit79807255feef41b15e91f5c0e82124f83c582517 (patch)
treec799b900fcadca5c736ac5a2ad98462f594a6209 /hostname.c
parentWrote whoami(1) (diff)
downloadtunics-79807255feef41b15e91f5c0e82124f83c582517.tar.gz
tunics-79807255feef41b15e91f5c0e82124f83c582517.zip
Add hostname(1) implementation
Diffstat (limited to 'hostname.c')
-rw-r--r--hostname.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/hostname.c b/hostname.c
new file mode 100644
index 0000000..532fc16
--- /dev/null
+++ b/hostname.c
@@ -0,0 +1,13 @@
+#include "hostname.h"
+
+int main(void) {
+ struct utsname *name;
+ name = malloc(sizeof(struct utsname));
+ if (uname(name) == -1) {
+ perror("uname");
+ exit(EXIT_FAILURE);
+ }
+ fprintf(stdout, "%s\n", name->nodename);
+ exit(EXIT_SUCCESS);
+}
+