Commit | Line | Data |
---|---|---|
bcf1365c DF |
1 | /* |
2 | * Copyright (c) 1983 Regents of the University of California. | |
3 | * All rights reserved. The Berkeley software License Agreement | |
4 | * specifies the terms and conditions for redistribution. | |
5 | */ | |
6 | ||
205a2d85 | 7 | #ifndef lint |
bcf1365c DF |
8 | char copyright[] = |
9 | "@(#) Copyright (c) 1983 Regents of the University of California.\n\ | |
10 | All rights reserved.\n"; | |
11 | #endif not lint | |
12 | ||
13 | #ifndef lint | |
14 | static char sccsid[] = "@(#)hostname.c 5.1 (Berkeley) %G%"; | |
15 | #endif not lint | |
16 | ||
d3d3fc37 KS |
17 | /* |
18 | * hostname -- get (or set hostname) | |
19 | */ | |
20 | #include <stdio.h> | |
21 | ||
22 | char hostname[32]; | |
23 | extern int errno; | |
24 | ||
25 | main(argc,argv) | |
64c52cbb | 26 | char *argv[]; |
d3d3fc37 | 27 | { |
65ed1a40 RH |
28 | int myerrno; |
29 | ||
d3d3fc37 KS |
30 | argc--; |
31 | argv++; | |
64c52cbb SL |
32 | if (argc) { |
33 | if (sethostname(*argv,strlen(*argv))) | |
d3d3fc37 | 34 | perror("sethostname"); |
65ed1a40 | 35 | myerrno = errno; |
d3d3fc37 KS |
36 | } else { |
37 | gethostname(hostname,sizeof(hostname)); | |
65ed1a40 | 38 | myerrno = errno; |
d3d3fc37 KS |
39 | printf("%s\n",hostname); |
40 | } | |
65ed1a40 | 41 | exit(myerrno); |
d3d3fc37 | 42 | } |