- if (argc >= 1) {
- do_sethostname(*argv, 0);
- } else if (filename!=NULL) {
- do_sethostname(filename, 1);
- } else {
- gethostname(buf, 255);
- if (opt_short) {
- s = strchr(buf, '.');
- if (!s) s = buf; *s = 0;
- printf("%s\n", buf);
- } else if (opt_domain) {
- s = strchr(buf, '.');
- printf("%s\n", (s ? s+1 : ""));
- } else if (opt_ip) {
- h = gethostbyname(buf);
- if (!h) {
- printf("Host not found\n");
- exit(1);
- }
- printf("%s\n", inet_ntoa(*(struct in_addr *)(h->h_addr)));
- } else {
- printf("%s\n", buf);
- }
- }
- exit( 0);
+ if (argc >= 1) {
+ do_sethostname(*argv, 0);
+ } else if (filename != NULL) {
+ do_sethostname(filename, 1);
+ } else {
+ gethostname(buf, 255);
+ if (opt_short) {
+ s = strchr(buf, '.');
+ if (!s)
+ s = buf;
+ *s = 0;
+ printf("%s\n", buf);
+ } else if (opt_domain) {
+ s = strchr(buf, '.');
+ printf("%s\n", (s ? s + 1 : ""));
+ } else if (opt_ip) {
+ h = gethostbyname(buf);
+ if (!h) {
+ printf("Host not found\n");
+ exit(1);
+ }
+ printf("%s\n", inet_ntoa(*(struct in_addr *) (h->h_addr)));
+ } else {
+ printf("%s\n", buf);
+ }
+ }
+ return(0);