lineedit: do not hang on error, but return error indicator.
[oweals/busybox.git] / coreutils / uname.c
index 8e51aa817d832d218397602084357e85d497d297..d1c50e222f4572cc5cd460f6d7d8091832b8d62e 100644 (file)
@@ -2,7 +2,7 @@
 /* uname -- print system information
  * Copyright (C) 1989-1999 Free Software Foundation, Inc.
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
 
 /* BB_AUDIT SUSv3 compliant */
@@ -48,8 +48,9 @@
  *  Fix handling of -a to not print "unknown", add -o and -i support.
  */
 
-#include <sys/utsname.h>
 #include "libbb.h"
+/* After libbb.h, since it needs sys/types.h on some systems */
+#include <sys/utsname.h>
 
 typedef struct {
        struct utsname name;
@@ -73,6 +74,21 @@ static const unsigned short utsname_offset[] = {
 int uname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int uname_main(int argc UNUSED_PARAM, char **argv)
 {
+#if ENABLE_LONG_OPTS
+       static const char uname_longopts[] ALIGN1 =
+               /* name, has_arg, val */
+               "all\0"               No_argument       "a"
+               "kernel-name\0"       No_argument       "s"
+               "nodename\0"          No_argument       "n"
+               "kernel-release\0"    No_argument       "r"
+               "release\0"           No_argument       "r"
+               "kernel-version\0"    No_argument       "v"
+               "machine\0"           No_argument       "m"
+               "processor\0"         No_argument       "p"
+               "hardware-platform\0" No_argument       "i"
+               "operating-system\0"  No_argument       "o"
+       ;
+#endif
        uname_info_t uname_info;
 #if defined(__sparc__) && defined(__linux__)
        char *fake_sparc = getenv("FAKE_SPARC");
@@ -80,8 +96,9 @@ int uname_main(int argc UNUSED_PARAM, char **argv)
        const char *unknown_str = "unknown";
        const char *fmt;
        const unsigned short *delta;
-       char toprint;
+       unsigned toprint;
 
+       IF_LONG_OPTS(applet_long_options = uname_longopts);
        toprint = getopt32(argv, options);
 
        if (argv[optind]) { /* coreutils-6.9 compat */