aboutsummaryrefslogtreecommitdiff
path: root/toys/example/hostid.c
blob: 3d7a8a8c5d0e4a148d6d879a03d1ab87ea4b3bd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* hostid.c - Print the numeric identifier for the current host.
 *
 * Copyright 2015 Ranjan Kumar <ranjankumar.bth@gmail.com>
 *
 * No Standard.
 *
 * This is still in coreutils and gethostid() in posix, but a "globally unique
 * 32 bit identifier" is a concept the Linux world has outgrown.

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());
}