projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Oops. Since dirent.h depends on BB_FEATURE_SH_TAB_COMPLETION, put it
[oweals/busybox.git]
/
hostname.c
diff --git
a/hostname.c
b/hostname.c
index 44d529c83fc287e2625fc658bdbe5b282d6b61fc..e1486b3655a1b4508f315931607eff5ba200d989 100644
(file)
--- a/
hostname.c
+++ b/
hostname.c
@@
-1,6
+1,6
@@
/* vi: set sw=4 ts=4: */
/*
/* vi: set sw=4 ts=4: */
/*
- * $Id: hostname.c,v 1.
15 2000/10/12 22:30:31
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 <tausq@debian.org>
* Mini hostname implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@
-28,6
+28,7
@@
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
+#include <string.h>
#include <stdio.h>
void do_sethostname(char *s, int isfile)
#include <stdio.h>
void do_sethostname(char *s, int isfile)
@@
-40,21
+41,17
@@
void do_sethostname(char *s, int isfile)
if (!isfile) {
if (sethostname(s, strlen(s)) < 0) {
if (errno == EPERM)
if (!isfile) {
if (sethostname(s, strlen(s)) < 0) {
if (errno == EPERM)
- error
Msg("you must be root to change the hostname\n
");
+ error
_msg_and_die("you must be root to change the hostname
");
else
else
- perror("sethostname");
- exit(1);
+ perror_msg_and_die("sethostname");
}
} else {
f = xfopen(s, "r");
fgets(buf, 255, f);
fclose(f);
}
} else {
f = xfopen(s, "r");
fgets(buf, 255, f);
fclose(f);
- if (buf[strlen(buf) - 1] == '\n')
- buf[strlen(buf) - 1] = 0;
- if (sethostname(buf, strlen(buf)) < 0) {
- perror("sethostname");
- exit(1);
- }
+ chomp(buf);
+ if (sethostname(buf, strlen(buf)) < 0)
+ perror_msg_and_die("sethostname");
}
}
}
}
@@
-69,7
+66,7
@@
int hostname_main(int argc, char **argv)
char *s = NULL;
if (argc < 1)
char *s = NULL;
if (argc < 1)
-
usage(hostname_usage
);
+
show_usage(
);
while (--argc > 0 && **(++argv) == '-') {
while (*(++(*argv))) {
while (--argc > 0 && **(++argv) == '-') {
while (*(++(*argv))) {
@@
-85,18
+82,18
@@
int hostname_main(int argc, char **argv)
break;
case 'F':
if (--argc == 0) {
break;
case 'F':
if (--argc == 0) {
-
usage(hostname_usage
);
+
show_usage(
);
}
filename = *(++argv);
break;
case '-':
if (strcmp(++(*argv), "file") || --argc ==0 ) {
}
filename = *(++argv);
break;
case '-':
if (strcmp(++(*argv), "file") || --argc ==0 ) {
-
usage(hostname_usage
);
+
show_usage(
);
}
filename = *(++argv);
break;
default:
}
filename = *(++argv);
break;
default:
-
usage(hostname_usage
);
+
show_usage(
);
}
if (filename != NULL)
break;
}
if (filename != NULL)
break;