+ fprintf(stderr,
+ "Usage: fw_printenv [OPTIONS]... [VARIABLE]...\n"
+ "Print variables from U-Boot environment\n"
+ "\n"
+ " -h, --help print this help.\n"
+ " -v, --version display version\n"
+#ifdef CONFIG_FILE
+ " -c, --config configuration file, default:" CONFIG_FILE "\n"
+#endif
+ " -n, --noheader do not repeat variable name in output\n"
+ " -l, --lock lock node, default:/var/lock\n"
+ "\n");
+}
+
+void usage_env_set(void)
+{
+ fprintf(stderr,
+ "Usage: fw_setenv [OPTIONS]... [VARIABLE]...\n"
+ "Modify variables in U-Boot environment\n"
+ "\n"
+ " -h, --help print this help.\n"
+ " -v, --version display version\n"
+#ifdef CONFIG_FILE
+ " -c, --config configuration file, default:" CONFIG_FILE "\n"
+#endif
+ " -l, --lock lock node, default:/var/lock\n"
+ " -s, --script batch mode to minimize writes\n"
+ "\n"
+ "Examples:\n"
+ " fw_setenv foo bar set variable foo equal bar\n"
+ " fw_setenv foo clear variable foo\n"
+ " fw_setenv --script file run batch script\n"
+ "\n"
+ "Script Syntax:\n"
+ " key [space] value\n"
+ " lines starting with '#' are treated as comment\n"
+ "\n"
+ " A variable without value will be deleted. Any number of spaces are\n"
+ " allowed between key and value. Space inside of the value is treated\n"
+ " as part of the value itself.\n"
+ "\n"
+ "Script Example:\n"
+ " netdev eth0\n"
+ " kernel_addr 400000\n"
+ " foo empty empty empty empty empty empty\n"
+ " bar\n"
+ "\n");
+}
+
+static void parse_common_args(int argc, char *argv[])
+{
+ int c;
+
+#ifdef CONFIG_FILE
+ env_opts.config_file = CONFIG_FILE;
+#endif
+
+ while ((c = getopt_long(argc, argv, ":a:c:l:h:v", long_options, NULL)) !=
+ EOF) {
+ switch (c) {
+#ifdef CONFIG_FILE
+ case 'c':
+ env_opts.config_file = optarg;
+ break;
+#endif
+ case 'l':
+ env_opts.lockname = optarg;
+ break;
+ case 'h':
+ do_printenv ? usage_printenv() : usage_env_set();
+ exit(EXIT_SUCCESS);
+ break;
+ case 'v':
+ fprintf(stderr, "Compiled with " U_BOOT_VERSION "\n");
+ exit(EXIT_SUCCESS);
+ break;
+ default:
+ /* ignore unknown options */
+ break;
+ }