| 2115 | } |
| 2116 | |
| 2117 | int main(int argc, char **argv) |
| 2118 | { |
| 2119 | size_t i; |
| 2120 | int c; |
| 2121 | |
| 2122 | if (argc < 3) { |
| 2123 | usage(argv[0]); |
| 2124 | return 1; |
| 2125 | } |
| 2126 | |
| 2127 | char *image_name = argv[1]; |
| 2128 | char *cmd = argv[2]; |
| 2129 | optind += 2; |
| 2130 | |
| 2131 | for (i = 0; i < ARRAY_SIZE(commands); i++) { |
| 2132 | if (strcmp(cmd, commands[i].name) != 0) |
| 2133 | continue; |
| 2134 | |
| 2135 | while (1) { |
| 2136 | char *suffix = NULL; |
| 2137 | int option_index = 0; |
| 2138 | |
| 2139 | c = getopt_long(argc, argv, commands[i].optstring, |
| 2140 | long_options, &option_index); |
| 2141 | if (c == -1) { |
| 2142 | if (optind < argc) { |
| 2143 | ERROR("%s: excessive argument -- '%s'" |
| 2144 | "\n", argv[0], argv[optind]); |
| 2145 | return 1; |
| 2146 | } |
| 2147 | break; |
| 2148 | } |
| 2149 | |
| 2150 | /* Filter out illegal long options */ |
| 2151 | if (!valid_opt(i, c)) { |
| 2152 | ERROR("%s: invalid option -- '%d'\n", |
| 2153 | argv[0], c); |
| 2154 | c = '?'; |
| 2155 | } |
| 2156 | |
| 2157 | switch(c) { |
| 2158 | case 'n': |
| 2159 | param.name = optarg; |
| 2160 | break; |
| 2161 | case 't': |
| 2162 | if (intfiletype(optarg) != ((uint64_t) - 1)) |
| 2163 | param.type = intfiletype(optarg); |
| 2164 | else |
| 2165 | param.type = strtoul(optarg, NULL, 0); |
| 2166 | if (param.type == 0) |
| 2167 | WARN("Unknown type '%s' ignored\n", |
| 2168 | optarg); |
| 2169 | break; |
| 2170 | case 'c': { |
| 2171 | if (strcmp(optarg, "precompression") == 0) { |
| 2172 | param.precompression = 1; |
| 2173 | break; |
| 2174 | } |
nothing calls this directly
no test coverage detected