static bool options(params string[] args) { parseopt pos = new parseopt(args); ulong start, end; DATA map; int opt; string r; string arg; while ((opt = pos.next()) >= 0) { switch (opt) { case 0: if (opt_infile != "") { Log("{0}: too many input files", cmdname); usage(); return false; } opt_infile = pos.arg(); break; case 'D': case 'd': arg = pos.arg(); if (arg == null || arg == "") goto missing; if (parserange(opt, arg, out r, out start, out end)) break; rangemap.Add(new RANGE(start, end, 1)); break; case 'E': case 'e': // if (!(arg = parseopt_arg(&pos))) // goto missing; // fprintf(stderr, "%s: symbol table not implemented yet!\n"); return false; case 'F': case 'f': // if (!(arg = parseopt_arg(&pos))) // goto missing; // if (parsemap(opt, arg, &r, &start, &end, &map)) // break; // insmap(&filemap, map, map + end - start, start); break; case 'H': case 'h': case '?': usage(); return false; case 'I': case 'i': arg = pos.arg(); if (arg == null || arg == "") goto missing; RANGE range = parsemap(opt, arg, out r); if (range == null) break; filemap.Add(range); break; case 'L': case 'l': opt_little = true; break; case 'M': case 'm': arg = pos.arg(); if (arg == null || parserange(opt, arg, out r, out start, out end)) { showhelp(memtypehelp); return false; } if (parsememtype(r.Substring(1), out map)) return false; memmap.Add(new RANGE(start, end, map)); break; case 'O': case 'o': opt_outfile = pos.arg(); if (opt_outfile == null || opt_outfile == "") goto missing; break; case 'R': case 'r': opt_split = true; break; case 'S': case 's': // if (!(arg = parseopt_arg(&pos))) // goto missing; // fprintf(stderr, "%s: symbol table not implemented yet!\n"); // exit(1); break; case 'T': case 't': // if (!(arg = parseopt_arg(&pos))) // goto missing; // start = parseul(arg, &r); // insmap(&memmap, start, start + 0x3FF, MKDATA(1, MD_VECTOR)); break; case 'V': case 'v': opt_outflag |= OutOpt.OF_VERBOSE; break; case 'W': case 'w': // if (!(arg = parseopt_arg(&pos))) // goto missing; // if (parseflags(opt, arg, &opt_outflag, outflags)) // exit(1); break; case 'X': case 'x': arg = pos.arg(); if (arg == null || fileoptions(arg) == false) { Log("{0}: cannot open options file \"{1}\"", cmdname, arg); usage(); return false; } break; case 'Z': case 'z': opt_outflag |= OutOpt.OF_DEBUG; break; default: Log("{0}: unknown option \"-{1}\"", cmdname, opt); usage(); return false; } } pos.end(); return true; missing: Log("{0}: option \"-{1}\" requires an argument", cmdname, opt); return false; }
static bool options(params string[] args) { parseopt pos = new parseopt(args); ulong start, end; DATA map; int opt; string r; string arg; while ((opt = pos.next()) >= 0) { switch (opt) { case 0: if (opt_infile != "") { Log("{0}: too many input files", cmdname); usage(); return(false); } opt_infile = pos.arg(); break; case 'D': case 'd': arg = pos.arg(); if (arg == null || arg == "") { goto missing; } if (parserange(opt, arg, out r, out start, out end)) { break; } rangemap.Add(new RANGE(start, end, 1)); break; case 'E': case 'e': // if (!(arg = parseopt_arg(&pos))) // goto missing; // fprintf(stderr, "%s: symbol table not implemented yet!\n"); return(false); case 'F': case 'f': // if (!(arg = parseopt_arg(&pos))) // goto missing; // if (parsemap(opt, arg, &r, &start, &end, &map)) // break; // insmap(&filemap, map, map + end - start, start); break; case 'H': case 'h': case '?': usage(); return(false); case 'I': case 'i': arg = pos.arg(); if (arg == null || arg == "") { goto missing; } RANGE range = parsemap(opt, arg, out r); if (range == null) { break; } filemap.Add(range); break; case 'L': case 'l': opt_little = true; break; case 'M': case 'm': arg = pos.arg(); if (arg == null || parserange(opt, arg, out r, out start, out end)) { showhelp(memtypehelp); return(false); } if (parsememtype(r.Substring(1), out map)) { return(false); } memmap.Add(new RANGE(start, end, map)); break; case 'O': case 'o': opt_outfile = pos.arg(); if (opt_outfile == null || opt_outfile == "") { goto missing; } break; case 'R': case 'r': opt_split = true; break; case 'S': case 's': // if (!(arg = parseopt_arg(&pos))) // goto missing; // fprintf(stderr, "%s: symbol table not implemented yet!\n"); // exit(1); break; case 'T': case 't': // if (!(arg = parseopt_arg(&pos))) // goto missing; // start = parseul(arg, &r); // insmap(&memmap, start, start + 0x3FF, MKDATA(1, MD_VECTOR)); break; case 'V': case 'v': opt_outflag |= OutOpt.OF_VERBOSE; break; case 'W': case 'w': // if (!(arg = parseopt_arg(&pos))) // goto missing; // if (parseflags(opt, arg, &opt_outflag, outflags)) // exit(1); break; case 'X': case 'x': arg = pos.arg(); if (arg == null || fileoptions(arg) == false) { Log("{0}: cannot open options file \"{1}\"", cmdname, arg); usage(); return(false); } break; case 'Z': case 'z': opt_outflag |= OutOpt.OF_DEBUG; break; default: Log("{0}: unknown option \"-{1}\"", cmdname, opt); usage(); return(false); } } pos.end(); return(true); missing: Log("{0}: option \"-{1}\" requires an argument", cmdname, opt); return(false); }