summaryrefslogtreecommitdiff
path: root/cleopatre/tools
diff options
context:
space:
mode:
authorNicolas Schodet2012-03-22 14:48:58 +0100
committerNicolas Schodet2012-04-04 16:45:51 +0200
commit685d21b21c9c65f8445debd3788e614fc5744c63 (patch)
tree96b7ab3b49a1695f125aeb272eaf48aa13bcf8cf /cleopatre/tools
parentfc182a9d94ed890d912e9d2025d6464964de35da (diff)
cleopatre/tools/genNVRAM: fix argument parsing
Diffstat (limited to 'cleopatre/tools')
-rw-r--r--cleopatre/tools/genNVRAM/genNVRAM.c115
1 files changed, 58 insertions, 57 deletions
diff --git a/cleopatre/tools/genNVRAM/genNVRAM.c b/cleopatre/tools/genNVRAM/genNVRAM.c
index 5505fd7c14..f10273875b 100644
--- a/cleopatre/tools/genNVRAM/genNVRAM.c
+++ b/cleopatre/tools/genNVRAM/genNVRAM.c
@@ -234,7 +234,6 @@ void str2hwaddr(unsigned char *hw, const char *s)
*/
struct parser {
char label[32];
- char key;
int (*func)(char*);
};
@@ -493,33 +492,33 @@ static char *chop(char *str)
*/
struct parser parse_table[] =
{
- { "infile", 'a', parse_infile },
- { "outfile", 'b', parse_outfile },
- { "pkgcfg", 'c', parse_pkgcfg },
- { "gpio07", 'd', parse_gpio07 },
- { "gpio815", 'e', parse_gpio815 },
- { "gpiodir", 'f', parse_gpiodir },
- { "sconr", 'g', parse_sdramcfg },
- { "stmg0r", 'h', parse_sdramtmg0 },
- { "stmg1r", 'i', parse_sdramtmg1 },
- { "srefr", 'j', parse_sdramrefr },
- { "forg", 'k', parse_forg },
- { "img0off", 'l', parse_img0off },
- { "nbimg", 'm', parse_nbimg },
- { "name", 'n', parse_name },
- { "partnb", 'o', parse_partnb },
- { "desc", 'p', parse_desc },
- { "serial", 'q', parse_serial },
- { "phy", 'r', parse_phy },
- { "ethernet", 's', parse_eth },
- { "plc", 't', parse_plc },
- { "dpw", 'u', parse_dpw },
- { "oem", 'v', parse_oem },
- { "tonemask", 'w', parse_tonemask },
- { "factory", 'x', parse_factory },
- { "portnb", 'y', parse_portnb },
- { "imgmaxsize", 'z', parse_imgmaxsize },
- { "cpupartnb", 'A', parse_cpu_partnb },
+ { "infile", parse_infile },
+ { "outfile", parse_outfile },
+ { "pkgcfg", parse_pkgcfg },
+ { "gpio07", parse_gpio07 },
+ { "gpio815", parse_gpio815 },
+ { "gpiodir", parse_gpiodir },
+ { "sconr", parse_sdramcfg },
+ { "stmg0r", parse_sdramtmg0 },
+ { "stmg1r", parse_sdramtmg1 },
+ { "srefr", parse_sdramrefr },
+ { "forg", parse_forg },
+ { "img0off", parse_img0off },
+ { "nbimg", parse_nbimg },
+ { "name", parse_name },
+ { "partnb", parse_partnb },
+ { "desc", parse_desc },
+ { "serial", parse_serial },
+ { "phy", parse_phy },
+ { "ethernet", parse_eth },
+ { "plc", parse_plc },
+ { "dpw", parse_dpw },
+ { "oem", parse_oem },
+ { "tonemask", parse_tonemask },
+ { "factory", parse_factory },
+ { "portnb", parse_portnb },
+ { "imgmaxsize", parse_imgmaxsize },
+ { "cpupartnb", parse_cpu_partnb },
};
/*
@@ -564,40 +563,42 @@ int main(int argc, char **argv)
int c;
int opt_index = 0;
struct option long_opts[] = {
- { "infile", required_argument, NULL, 'a' },
- { "outfile", required_argument, NULL, 'b' },
- { "pkgcfg", required_argument, NULL, 'c' },
- { "gpio07", required_argument, NULL, 'd' },
- { "gpio815", required_argument, NULL, 'e' },
- { "gpiodir", required_argument, NULL, 'f' },
- { "sconr", required_argument, NULL, 'g' },
- { "stmg0", required_argument, NULL, 'h' },
- { "stmg1", required_argument, NULL, 'i' },
- { "srefr", required_argument, NULL, 'j' },
- { "forg", required_argument, NULL, 'k' },
- { "img0off", required_argument, NULL, 'l' },
- { "nbimg", required_argument, NULL, 'm' },
- { "name", required_argument, NULL, 'n' },
- { "partnb", required_argument, NULL, 'o' },
- { "desc", required_argument, NULL, 'p' },
- { "serial", required_argument, NULL, 'q' },
- { "phy", required_argument, NULL, 'r' },
- { "ether", required_argument, NULL, 's' },
- { "plc", required_argument, NULL, 't' },
- { "dpw", required_argument, NULL, 'u' },
- { "oem", required_argument, NULL, 'v' },
- { "tonemask", required_argument, NULL, 'w' },
- { "factory", required_argument, NULL, 'x' },
- { "portnb", required_argument, NULL, 'y' },
- { "imgmaxsize", required_argument, NULL, 'z' },
- { "cpupartnb", required_argument, NULL, 'A' },
+ /* The val field should be set to the index of the corresponding parse
+ * function in parse_table. */
+ { "infile", required_argument, NULL, 0 },
+ { "outfile", required_argument, NULL, 1 },
+ { "pkgcfg", required_argument, NULL, 2 },
+ { "gpio07", required_argument, NULL, 3 },
+ { "gpio815", required_argument, NULL, 4 },
+ { "gpiodir", required_argument, NULL, 5 },
+ { "sconr", required_argument, NULL, 6 },
+ { "stmg0", required_argument, NULL, 7 },
+ { "stmg1", required_argument, NULL, 8 },
+ { "srefr", required_argument, NULL, 9 },
+ { "forg", required_argument, NULL, 10 },
+ { "img0off", required_argument, NULL, 11 },
+ { "nbimg", required_argument, NULL, 12 },
+ { "name", required_argument, NULL, 13 },
+ { "partnb", required_argument, NULL, 14 },
+ { "desc", required_argument, NULL, 15 },
+ { "serial", required_argument, NULL, 16 },
+ { "phy", required_argument, NULL, 17 },
+ { "ether", required_argument, NULL, 18 },
+ { "plc", required_argument, NULL, 19 },
+ { "dpw", required_argument, NULL, 20 },
+ { "oem", required_argument, NULL, 21 },
+ { "tonemask", required_argument, NULL, 22 },
+ { "factory", required_argument, NULL, 23 },
+ { "portnb", required_argument, NULL, 24 },
+ { "imgmaxsize", required_argument, NULL, 25 },
+ { "cpupartnb", required_argument, NULL, 26 },
};
while( ( c = getopt_long_only(argc, argv, "", long_opts, &opt_index) ) != -1 )
{
- if((c >= 'a') && (c <= 'x'))
+ if (c != '?')
{
- if((parse_table[c - 'a'].func (optarg)) < 0)
+ if((parse_table[c].func (optarg)) < 0)
{
print_usage (argv[0]);
exit (1);