X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=hostname.c;h=e1486b3655a1b4508f315931607eff5ba200d989;hb=5165fbed639916e0fde15a827241b21981be7934;hp=b1f0613694a56d0b2f7ed67587efa652bd3fc067;hpb=f6c6d9aacc9645c7edf077575c17dcb20fbb2ac4;p=oweals%2Fbusybox.git diff --git a/hostname.c b/hostname.c index b1f061369..e1486b365 100644 --- a/hostname.c +++ b/hostname.c @@ -1,6 +1,6 @@ /* vi: set sw=4 ts=4: */ /* - * $Id: hostname.c,v 1.20 2001/01/24 18:44:54 andersen Exp $ + * $Id: hostname.c,v 1.24 2001/02/14 21:23:06 andersen Exp $ * Mini hostname implementation for busybox * * Copyright (C) 1999 by Randolph Chung @@ -28,6 +28,7 @@ #include #include #include +#include #include void do_sethostname(char *s, int isfile) @@ -40,7 +41,7 @@ void do_sethostname(char *s, int isfile) if (!isfile) { if (sethostname(s, strlen(s)) < 0) { if (errno == EPERM) - error_msg_and_die("you must be root to change the hostname\n"); + error_msg_and_die("you must be root to change the hostname"); else perror_msg_and_die("sethostname"); } @@ -48,8 +49,7 @@ void do_sethostname(char *s, int isfile) f = xfopen(s, "r"); fgets(buf, 255, f); fclose(f); - if (buf[strlen(buf) - 1] == '\n') - buf[strlen(buf) - 1] = 0; + chomp(buf); if (sethostname(buf, strlen(buf)) < 0) perror_msg_and_die("sethostname"); } @@ -66,7 +66,7 @@ int hostname_main(int argc, char **argv) char *s = NULL; if (argc < 1) - usage(hostname_usage); + show_usage(); while (--argc > 0 && **(++argv) == '-') { while (*(++(*argv))) { @@ -82,18 +82,18 @@ int hostname_main(int argc, char **argv) break; case 'F': if (--argc == 0) { - usage(hostname_usage); + show_usage(); } filename = *(++argv); break; case '-': if (strcmp(++(*argv), "file") || --argc ==0 ) { - usage(hostname_usage); + show_usage(); } filename = *(++argv); break; default: - usage(hostname_usage); + show_usage(); } if (filename != NULL) break;