#include <stdint.h>
#include <getopt.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <linux/string.h>
#include <ctype.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <basetypes.h>
#include <inttypes.h>
enum numeric_short_options {
HELP = 0,
VERSION_INFO,
AUTO_DOWNLOAD,
AUTO_BOOT,
PRI_ADDR,
};
static const char *short_options = "b:fjopqs:ytd:KMRBGA:HQIUWXYZC:c:F:L:S:D:V:E:N:B:P:";
static struct option long_options[] = {
{"jffs2", no_argument, 0, 'j'},
{"yaffs", no_argument, 0, 'y'},
{"forcelegacy", no_argument, 0, 'f'},
{"oob", no_argument, 0, 'o'},
{"start", required_argument, 0, 's'},
{"pad", no_argument, 0, 'p'},
{"blockalign", required_argument, 0, 'b'},
{"quiet", no_argument, 0, 'q'},
{"skiphead", no_argument, 0, 't'},
{"help", no_argument, 0, HELP},
{"version", no_argument, 0, VERSION_INFO},
{"fdt", required_argument, 0, 'd'},
{"auto_boot", required_argument, 0, AUTO_BOOT},
{"auto_dl", required_argument, 0, AUTO_DOWNLOAD},
{0, 0, 0, 0},
};
static int ambarella_auto_dl = 0;
static u8 ambarella_auto_dl_data=1;
static int ambarella_auto_boot = 0;
static u8 ambarella_auto_boot_data=1;
int main(int argc, char *argv[])
{
int error = 0;
int ch;
int option_index = 0;
while ((ch = getopt_long(argc, argv, short_options, long_options, &option_index)) != -1) {
switch (ch) {
case HELP:
usage();
break;
case VERSION_INFO:
display_version();
break;
case AUTO_DOWNLOAD:
ambarella_auto_dl = 1;
ambarella_auto_dl_data=strtoul (optarg, NULL, 0);
break;
case AUTO_BOOT:
ambarella_auto_boot_data=strtoul (optarg, NULL, 0);
ambarella_skip_img = 1;
break;
case PRI_ADDR:
ambarella_pri_addr = 1;
ambarella_pri_addr_data = strtoul (optarg, NULL, 0);
ambarella_skip_img = 1;
break;
case PRI_FILE:
ambarella_pri_file = 1;
strncpy(ambarella_pri_file_data, optarg, SN_SIZE - 1);
ambarella_pri_file_data[SN_SIZE - 1] = '\0';
ambarella_skip_img = 1;
break;
case 'M':
ambarella_rmd = 1;
break;
case 'R':
ambarella_rom = 1;
break;
}
}
return 0;
}
required_argument? 为需要带参数后面跟着:号 如 debug -a test;
no_argument? 不需要带参数 不跟:号 如 debug -a;
|