diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-12-09 14:19:03 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-01-10 09:53:34 +0100 |
commit | 75b706fde4cbf82bcd41a1cec319778aa0f8eb2d (patch) | |
tree | ea39a351a1f6337b5a5dd6036314693adef5ffe6 /freebsd/bin | |
parent | VMSTAT(8): Port to RTEMS (diff) | |
download | rtems-libbsd-75b706fde4cbf82bcd41a1cec319778aa0f8eb2d.tar.bz2 |
Update to FreeBSD head 2016-12-10
Git mirror commit 80c55f08a05ab3b26a73b226ccb56adc3122a55c.
Diffstat (limited to 'freebsd/bin')
-rw-r--r-- | freebsd/bin/hostname/hostname.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/freebsd/bin/hostname/hostname.c b/freebsd/bin/hostname/hostname.c index 8e9fc975..61b5dbad 100644 --- a/freebsd/bin/hostname/hostname.c +++ b/freebsd/bin/hostname/hostname.c @@ -96,7 +96,7 @@ rtems_shell_cmd_t rtems_shell_HOSTNAME_Command = { int main(int argc, char *argv[]) { - int ch, sflag; + int ch, sflag, dflag; char *p, hostname[MAXHOSTNAMELEN]; #ifdef __rtems__ struct getopt_data getopt_data; @@ -107,10 +107,11 @@ main(int argc, char *argv[]) #endif /* __rtems__ */ sflag = 0; + dflag = 0; #ifndef __rtems__ - while ((ch = getopt(argc, argv, "fs")) != -1) + while ((ch = getopt(argc, argv, "fsd")) != -1) #else /* __rtems__ */ - while ((ch = getopt(argc, argv, "fms")) != -1) + while ((ch = getopt(argc, argv, "fdms")) != -1) #endif /* __rtems__ */ switch (ch) { case 'f': @@ -123,6 +124,9 @@ main(int argc, char *argv[]) case 's': sflag = 1; break; + case 'd': + dflag = 1; + break; #ifdef __rtems__ case 'm': mflag = 1; @@ -135,7 +139,7 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - if (argc > 1) + if (argc > 1 || (sflag && dflag)) usage(); if (*argv) { @@ -164,6 +168,10 @@ main(int argc, char *argv[]) p = strchr(hostname, '.'); if (p != NULL) *p = '\0'; + } else if (dflag) { + p = strchr(hostname, '.'); + if (p != NULL) + strcpy(hostname, ++p); } (void)printf("%s\n", hostname); } @@ -174,6 +182,10 @@ static void usage(void) { - (void)fprintf(stderr, "usage: hostname [-fms] [name-of-host]\n"); +#ifndef __rtems__ + (void)fprintf(stderr, "usage: hostname [-f] [-s | -d] [name-of-host]\n"); +#else /* __rtems__ */ + (void)fprintf(stderr, "usage: hostname [-f] [-m | -s | -d] [name-of-host]\n"); +#endif /* __rtems__ */ exit(1); } |