]>
Commit | Line | Data |
---|---|---|
6dbe3af9 KZ |
1 | /* Mitch DSouza - (m.dsouza@mrc-apu.cam.ac.uk) */ |
2 | ||
3 | #include <stdio.h> | |
4 | #include <stdlib.h> | |
5 | #include <unistd.h> | |
6 | #include <errno.h> | |
7 | #include <getopt.h> | |
8 | ||
fd6b7a7f | 9 | int main (int argc, char **argv) |
6dbe3af9 KZ |
10 | { |
11 | int verbose = 0; | |
12 | ||
13 | if(argc == 2 && strcmp(argv[1], "-v") == 0) { | |
14 | verbose = 1; | |
15 | argc--; | |
16 | argv++; | |
17 | } | |
18 | ||
19 | if (argc==2) { | |
20 | if (sethostid(atoi(argv[1]))!=0) { | |
21 | perror("sethostid"); | |
22 | exit(1); | |
23 | } | |
24 | } else if (argc==1) { | |
25 | unsigned long id = gethostid(); | |
26 | ||
27 | if(id && verbose) { | |
28 | printf("Hostid is %lu (0x%lx)\n",id,id); | |
29 | } else if(id) { | |
30 | printf("0x%lx\n", id); | |
31 | } else { | |
32 | printf("Usage: %s hostid_number\n",*argv); | |
33 | } | |
34 | } | |
fd6b7a7f | 35 | return 0; |
6dbe3af9 | 36 | } |