Then have long options defined:
- static const struct option <applet>_long_options[] = {
- { "list", 0, NULL, 't' },
- { "extract", 0, NULL, 'x' },
- { NULL, 0, NULL, 0 }
- };
+ static const char <applet>_longopts[] ALIGN1 =
+ "list\0" No_argument "t"
+ "extract\0" No_argument "x"
+ ;
And a code block similar to the following near the top of your applet_main()
routine:
char *str_b;
opt_complementary = "cryptic_string";
- applet_long_options = <applet>_long_options; /* if you have them */
+ applet_long_options = <applet>_longopts; /* if you have them */
opt = getopt32(argc, argv, "ab:c", &str_b);
if (opt & 1) {
handle_option_a();
* Added NLS support (partly written by Arkadiusz Mickiewicz
* <misiek@misiek.eu.org>)
* Ported to Busybox - Alfred M. Szmidt <ams@trillian.itslinux.org>
- * Removed --version/-V and --help/-h in
+ * Removed --version/-V and --help/-h
* Removed parse_error(), using bb_error_msg() from Busybox instead
* Replaced our_malloc with xmalloc and our_realloc with xrealloc
*
//usage: " esac\n"
//usage: "done\n"
-#include <getopt.h>
+#if ENABLE_FEATURE_GETOPT_LONG
+# include <getopt.h>
+#endif
#include "libbb.h"
/* NON_OPT is the code that is returned when a non-option is found in '+'