aboutsummaryrefslogtreecommitdiff
path: root/toys/example/hostid.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/example/hostid.c')
-rw-r--r--toys/example/hostid.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/toys/example/hostid.c b/toys/example/hostid.c
new file mode 100644
index 00000000..feef61bf
--- /dev/null
+++ b/toys/example/hostid.c
@@ -0,0 +1,23 @@
+/* hostid.c - Print the numeric identifier for the current host.
+ *
+ * Copyright 2015 Ranjan Kumar <ranjankumar.bth@gmail.com>
+ *
+ * No Standard.
+
+USE_HOSTID(NEWTOY(hostid, ">0", TOYFLAG_USR|TOYFLAG_BIN))
+
+config HOSTID
+ bool "hostid"
+ default n
+ help
+ usage: hostid
+
+ Print the numeric identifier for the current host.
+*/
+#define FOR_hostid
+#include "toys.h"
+
+void hostid_main(void)
+{
+ xprintf("%08lx\n", gethostid());
+}