This one should be able to deal with the USAGE macros a little
[oweals/busybox.git] / utility.c
index cf0aecc804e77c77f126b59a37729165573c1b72..e3535966f367cbcdec3c3fa525506ccf5b0b2d38 100644 (file)
--- a/utility.c
+++ b/utility.c
@@ -36,6 +36,7 @@
 #include <ctype.h>
 #include <stdlib.h>
 #include <limits.h>
+#include <stdarg.h>
 #include <sys/ioctl.h>
 #include <sys/utsname.h>               /* for uname(2) */
 
@@ -54,7 +55,6 @@
 #define bb_need_full_version
 #define BB_DECLARE_EXTERN
 #include "messages.c"
-#include "usage.h"
 
 #include "pwd_grp/pwd.h"
 #include "pwd_grp/grp.h"
@@ -81,21 +81,20 @@ static struct BB_applet *applet_using;
 
 extern void show_usage(void)
 {
-       static const char no_help[] = "No help available.\n";
-
-       const char *usage_string = no_help;
+       const char *format_string;
+       const char *usage_string = usage_messages;
        int i;
 
-       if (applet_using->usage_index >= 0) {
-               usage_string = usage_messages;
-               for (i=applet_using->usage_index ; i>0 ; ) {
-                       if (!*usage_string++) {
-                               --i;
-                       }
+       for (i = applet_using - applets; i > 0; ) {
+               if (!*usage_string++) {
+                       --i;
                }
        }
-       fprintf(stderr, "%s\n\nUsage: %s %s\n\n", full_version,
-                       applet_using->name, usage_string);
+       format_string = "%s\n\nUsage: %s %s\n\n";
+       if(*usage_string == 0)
+               format_string = "%s\n\nNo help available.\n\n";
+       fprintf(stderr, format_string,
+                       full_version, applet_using->name, usage_string);
        exit(EXIT_FAILURE);
 }
 
@@ -202,7 +201,7 @@ extern _syscall5(int, mount, const char *, special_file, const char *, dir,
                const char *, fstype, unsigned long int, rwflag, const void *, data);
 #endif
 
-#if defined BB_INSMOD || defined BB_LSMOD
+#if defined BB_FEATURE_NEW_MODULE_INTERFACE && ( defined BB_INSMOD || defined BB_LSMOD )
 #ifndef __NR_query_module
 static const int __NR_query_module = 167;
 #endif