Commit | Line | Data |
---|---|---|
d3d3fc37 KS |
1 | static char *sccsid = "@(#)hostname.c 1.1 1.1 82/04/08"; |
2 | /* | |
3 | * hostname -- get (or set hostname) | |
4 | */ | |
5 | #include <stdio.h> | |
6 | ||
7 | char hostname[32]; | |
8 | extern int errno; | |
9 | ||
10 | main(argc,argv) | |
11 | char *argv[]; | |
12 | { | |
13 | argc--; | |
14 | argv++; | |
15 | if(argc) { | |
16 | if(sethostname(*argv,strlen(*argv)+1)) | |
17 | perror("sethostname"); | |
18 | } else { | |
19 | gethostname(hostname,sizeof(hostname)); | |
20 | printf("%s\n",hostname); | |
21 | } | |
22 | return(errno); | |
23 | } |