diff options
author | 2016-07-08 15:29:50 +1000 | |
---|---|---|
committer | 2016-07-08 15:29:50 +1000 | |
commit | 6a67de94f99f02e342df83e9b5d7e8093a688942 (patch) | |
tree | d58fcfa459e1851bfdda205172d9590f1e1c85a6 /src | |
parent | aaa3090dd3a40587f3d4cd7ab8016bcd96131e08 (diff) |
Fix up imgtool as well
Diffstat (limited to 'src')
31 files changed, 218 insertions, 239 deletions
diff --git a/src/tools/imgtool/filtbas.cpp b/src/tools/imgtool/filtbas.cpp index a83d7a80108..0bcb40204e8 100644 --- a/src/tools/imgtool/filtbas.cpp +++ b/src/tools/imgtool/filtbas.cpp @@ -175,7 +175,7 @@ done: static imgtoolerr_t basic_writefile(const basictokens *tokens, imgtool_partition *partition, const char *filename, - const char *fork, imgtool_stream *sourcef, option_resolution *opts) + const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) { imgtoolerr_t err; imgtool_stream *mem_stream; @@ -2965,7 +2965,7 @@ static imgtoolerr_t cocobas_readfile(imgtool_partition *partition, const char *f } static imgtoolerr_t cocobas_writefile(imgtool_partition *partition, const char *filename, - const char *fork, imgtool_stream *sourcef, option_resolution *opts) + const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) { return basic_writefile(&cocobas_tokens, partition, filename, fork, sourcef, opts); } @@ -3009,7 +3009,7 @@ static imgtoolerr_t dragonbas_readfile(imgtool_partition *partition, const char } static imgtoolerr_t dragonbas_writefile(imgtool_partition *partition, const char *filename, - const char *fork, imgtool_stream *sourcef, option_resolution *opts) + const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) { return basic_writefile(&dragonbas_tokens, partition, filename, fork, sourcef, opts); } @@ -3054,7 +3054,7 @@ static imgtoolerr_t vzbas_readfile(imgtool_partition *partition, const char *fil } static imgtoolerr_t vzbas_writefile(imgtool_partition *partition, const char *filename, - const char *fork, imgtool_stream *sourcef, option_resolution *opts) + const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) { return basic_writefile(&vzbas_tokens, partition, filename, fork, sourcef, opts); } @@ -3098,7 +3098,7 @@ static imgtoolerr_t bml3bas_readfile(imgtool_partition *partition, const char *f } static imgtoolerr_t bml3bas_writefile(imgtool_partition *partition, const char *filename, - const char *fork, imgtool_stream *sourcef, option_resolution *opts) + const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) { return basic_writefile(&bml3bas_tokens, partition, filename, fork, sourcef, opts); } diff --git a/src/tools/imgtool/filteoln.cpp b/src/tools/imgtool/filteoln.cpp index 457ac89aee6..abc612ff6e8 100644 --- a/src/tools/imgtool/filteoln.cpp +++ b/src/tools/imgtool/filteoln.cpp @@ -82,7 +82,7 @@ done: -static imgtoolerr_t ascii_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, option_resolution *opts) +static imgtoolerr_t ascii_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) { imgtoolerr_t err; imgtool_stream *mem_stream = nullptr; diff --git a/src/tools/imgtool/formats/coco_dsk.cpp b/src/tools/imgtool/formats/coco_dsk.cpp index 9674ed9de11..7d7d2544046 100644 --- a/src/tools/imgtool/formats/coco_dsk.cpp +++ b/src/tools/imgtool/formats/coco_dsk.cpp @@ -200,11 +200,11 @@ static FLOPPY_CONSTRUCT(coco_jvc_construct) { /* create */ memset(&geometry, 0, sizeof(geometry)); - geometry.heads = option_resolution_lookup_int(params, PARAM_HEADS); - geometry.tracks = option_resolution_lookup_int(params, PARAM_TRACKS); - geometry.sectors = option_resolution_lookup_int(params, PARAM_SECTORS); - geometry.first_sector_id = option_resolution_lookup_int(params, PARAM_FIRST_SECTOR_ID); - geometry.sector_length = option_resolution_lookup_int(params, PARAM_SECTOR_LENGTH); + geometry.heads = params->lookup_int(PARAM_HEADS); + geometry.tracks = params->lookup_int(PARAM_TRACKS); + geometry.sectors = params->lookup_int(PARAM_SECTORS); + geometry.first_sector_id = params->lookup_int(PARAM_FIRST_SECTOR_ID); + geometry.sector_length = params->lookup_int(PARAM_SECTOR_LENGTH); header[0] = (UINT8) geometry.sectors; header[1] = (UINT8) geometry.heads; @@ -325,7 +325,7 @@ static floperr_t coco_os9_readheader(floppy_image_legacy *floppy, struct basicds -static floperr_t coco_os9_post_format(floppy_image_legacy *floppy, option_resolution *params) +static floperr_t coco_os9_post_format(floppy_image_legacy *floppy, util::option_resolution *params) { UINT8 header[0x0400]; floperr_t err; @@ -333,9 +333,9 @@ static floperr_t coco_os9_post_format(floppy_image_legacy *floppy, option_resolu struct tm *ltime; int heads, tracks, sectors, total_sectors; - heads = option_resolution_lookup_int(params, PARAM_HEADS); - tracks = option_resolution_lookup_int(params, PARAM_TRACKS); - sectors = option_resolution_lookup_int(params, PARAM_SECTORS); + heads = params->lookup_int(PARAM_HEADS); + tracks = params->lookup_int(PARAM_TRACKS); + sectors = params->lookup_int(PARAM_SECTORS); total_sectors = heads * tracks * sectors; /* write the initial header */ @@ -439,11 +439,11 @@ static FLOPPY_CONSTRUCT(coco_os9_construct) { /* create */ memset(&geometry, 0, sizeof(geometry)); - geometry.heads = option_resolution_lookup_int(params, PARAM_HEADS); - geometry.tracks = option_resolution_lookup_int(params, PARAM_TRACKS); - geometry.sectors = option_resolution_lookup_int(params, PARAM_SECTORS); - geometry.first_sector_id = option_resolution_lookup_int(params, PARAM_FIRST_SECTOR_ID); - geometry.sector_length = option_resolution_lookup_int(params, PARAM_SECTOR_LENGTH); + geometry.heads = params->lookup_int(PARAM_HEADS); + geometry.tracks = params->lookup_int(PARAM_TRACKS); + geometry.sectors = params->lookup_int(PARAM_SECTORS); + geometry.first_sector_id = params->lookup_int(PARAM_FIRST_SECTOR_ID); + geometry.sector_length = params->lookup_int(PARAM_SECTOR_LENGTH); } else { @@ -549,8 +549,8 @@ static FLOPPY_CONSTRUCT(coco_vdk_construct) { /* create */ memset(&geometry, 0, sizeof(geometry)); - geometry.heads = option_resolution_lookup_int(params, PARAM_HEADS); - geometry.tracks = option_resolution_lookup_int(params, PARAM_TRACKS); + geometry.heads = params->lookup_int(PARAM_HEADS); + geometry.tracks = params->lookup_int(PARAM_TRACKS); geometry.sectors = 18; geometry.first_sector_id = 1; geometry.sector_length = 256; @@ -707,7 +707,7 @@ static floperr_t coco_dmk_get_track_data_offset(floppy_image_legacy *floppy, int -static floperr_t coco_dmk_format_track(floppy_image_legacy *floppy, int head, int track, option_resolution *params) +static floperr_t coco_dmk_format_track(floppy_image_legacy *floppy, int head, int track, util::option_resolution *params) { int sectors; int sector_length; @@ -724,10 +724,10 @@ static floperr_t coco_dmk_format_track(floppy_image_legacy *floppy, int head, in UINT32 max_track_size; std::vector<int> sector_map; - sectors = option_resolution_lookup_int(params, PARAM_SECTORS); - sector_length = option_resolution_lookup_int(params, PARAM_SECTOR_LENGTH); - interleave = option_resolution_lookup_int(params, PARAM_INTERLEAVE); - first_sector_id = option_resolution_lookup_int(params, PARAM_FIRST_SECTOR_ID); + sectors = params->lookup_int(PARAM_SECTORS); + sector_length = params->lookup_int(PARAM_SECTOR_LENGTH); + interleave = params->lookup_int(PARAM_INTERLEAVE); + first_sector_id = params->lookup_int(PARAM_FIRST_SECTOR_ID); max_track_size = get_dmk_tag(floppy)->track_size; @@ -1102,10 +1102,10 @@ FLOPPY_CONSTRUCT(coco_dmk_construct) if (params) { - heads = option_resolution_lookup_int(params, PARAM_HEADS); - tracks = option_resolution_lookup_int(params, PARAM_TRACKS); - sectors = option_resolution_lookup_int(params, PARAM_SECTORS); - sector_length = option_resolution_lookup_int(params, PARAM_SECTOR_LENGTH); + heads = params->lookup_int(PARAM_HEADS); + tracks = params->lookup_int(PARAM_TRACKS); + sectors = params->lookup_int(PARAM_SECTORS); + sector_length = params->lookup_int(PARAM_SECTOR_LENGTH); track_size = coco_dmk_min_track_size(sectors, sector_length) + DMK_EXTRA_TRACK_LENGTH; diff --git a/src/tools/imgtool/formats/vt_dsk.cpp b/src/tools/imgtool/formats/vt_dsk.cpp index 4e75e843d28..efdab281163 100644 --- a/src/tools/imgtool/formats/vt_dsk.cpp +++ b/src/tools/imgtool/formats/vt_dsk.cpp @@ -28,11 +28,11 @@ static FLOPPY_CONSTRUCT(vz_construct) if (params) { - geometry.heads = option_resolution_lookup_int(params, PARAM_HEADS); - geometry.tracks = option_resolution_lookup_int(params, PARAM_TRACKS); - geometry.sectors = option_resolution_lookup_int(params, PARAM_SECTORS); - geometry.first_sector_id = option_resolution_lookup_int(params, PARAM_FIRST_SECTOR_ID); - geometry.sector_length = option_resolution_lookup_int(params, PARAM_SECTOR_LENGTH); + geometry.heads = params->lookup_int(PARAM_HEADS); + geometry.tracks = params->lookup_int(PARAM_TRACKS); + geometry.sectors = params->lookup_int(PARAM_SECTORS); + geometry.first_sector_id = params->lookup_int(PARAM_FIRST_SECTOR_ID); + geometry.sector_length = params->lookup_int(PARAM_SECTOR_LENGTH); } else { diff --git a/src/tools/imgtool/iflopimg.cpp b/src/tools/imgtool/iflopimg.cpp index 3bf05aacd35..aebd63212f5 100644 --- a/src/tools/imgtool/iflopimg.cpp +++ b/src/tools/imgtool/iflopimg.cpp @@ -144,20 +144,20 @@ static imgtoolerr_t imgtool_floppy_open(imgtool_image *image, imgtool_stream *f) -static imgtoolerr_t imgtool_floppy_create(imgtool_image *image, imgtool_stream *f, option_resolution *opts) +static imgtoolerr_t imgtool_floppy_create(imgtool_image *image, imgtool_stream *f, util::option_resolution *opts) { floperr_t ferr; imgtoolerr_t err = IMGTOOLERR_SUCCESS; struct imgtool_floppy_image *fimg; const imgtool_class *imgclass; const struct FloppyFormat *format; - imgtoolerr_t (*create)(imgtool_image *, imgtool_stream *, option_resolution *); + imgtoolerr_t (*create)(imgtool_image *, imgtool_stream *, util::option_resolution *); imgtoolerr_t (*open)(imgtool_image *image, imgtool_stream *f); fimg = (struct imgtool_floppy_image *) imgtool_image_extra_bytes(image); imgclass = &imgtool_image_module(image)->imgclass; format = (const struct FloppyFormat *) imgclass->derived_param; - create = (imgtoolerr_t (*)(imgtool_image *, imgtool_stream *, option_resolution *)) imgtool_get_info_ptr(imgclass, IMGTOOLINFO_PTR_FLOPPY_CREATE); + create = (imgtoolerr_t (*)(imgtool_image *, imgtool_stream *, util::option_resolution *)) imgtool_get_info_ptr(imgclass, IMGTOOLINFO_PTR_FLOPPY_CREATE); open = (imgtoolerr_t (*)(imgtool_image *, imgtool_stream *)) imgtool_get_info_ptr(imgclass, IMGTOOLINFO_PTR_FLOPPY_OPEN); /* open up the floppy */ diff --git a/src/tools/imgtool/imghd.cpp b/src/tools/imgtool/imghd.cpp index 715076b63b4..79a60a5d010 100644 --- a/src/tools/imgtool/imghd.cpp +++ b/src/tools/imgtool/imghd.cpp @@ -215,7 +215,7 @@ const hard_disk_info *imghd_get_header(struct mess_hard_disk_file *disk) } -static imgtoolerr_t mess_hd_image_create(imgtool_image *image, imgtool_stream *f, option_resolution *createoptions); +static imgtoolerr_t mess_hd_image_create(imgtool_image *image, imgtool_stream *f, util::option_resolution *createoptions); enum { @@ -254,16 +254,16 @@ void hd_get_info(const imgtool_class *imgclass, UINT32 state, union imgtoolinfo -static imgtoolerr_t mess_hd_image_create(imgtool_image *image, imgtool_stream *f, option_resolution *createoptions) +static imgtoolerr_t mess_hd_image_create(imgtool_image *image, imgtool_stream *f, util::option_resolution *createoptions) { UINT32 blocksize, cylinders, heads, sectors, seclen; /* read options */ - blocksize = option_resolution_lookup_int(createoptions, mess_hd_createopts_blocksize); - cylinders = option_resolution_lookup_int(createoptions, mess_hd_createopts_cylinders); - heads = option_resolution_lookup_int(createoptions, mess_hd_createopts_heads); - sectors = option_resolution_lookup_int(createoptions, mess_hd_createopts_sectors); - seclen = option_resolution_lookup_int(createoptions, mess_hd_createopts_seclen); + blocksize = createoptions->lookup_int(mess_hd_createopts_blocksize); + cylinders = createoptions->lookup_int(mess_hd_createopts_cylinders); + heads = createoptions->lookup_int(mess_hd_createopts_heads); + sectors = createoptions->lookup_int(mess_hd_createopts_sectors); + seclen = createoptions->lookup_int(mess_hd_createopts_seclen); return imghd_create(f, blocksize, cylinders, heads, sectors, seclen); } diff --git a/src/tools/imgtool/imgtool.cpp b/src/tools/imgtool/imgtool.cpp index c2c07e4ee23..95efbc9ab18 100644 --- a/src/tools/imgtool/imgtool.cpp +++ b/src/tools/imgtool/imgtool.cpp @@ -53,7 +53,7 @@ struct imgtool_partition void (*close_enum) (imgtool_directory *enumeration); imgtoolerr_t (*free_space) (imgtool_partition *partition, UINT64 *size); imgtoolerr_t (*read_file) (imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *destf); - imgtoolerr_t (*write_file) (imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, option_resolution *opts); + imgtoolerr_t (*write_file) (imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts); imgtoolerr_t (*delete_file) (imgtool_partition *partition, const char *filename); imgtoolerr_t (*list_forks) (imgtool_partition *partition, const char *path, imgtool_forkent *ents, size_t len); imgtoolerr_t (*create_dir) (imgtool_partition *partition, const char *path); @@ -788,7 +788,7 @@ imgtoolerr_t imgtool_partition_open(imgtool_image *image, int partition_index, i p->next_enum = (imgtoolerr_t (*)(imgtool_directory *, imgtool_dirent *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_NEXT_ENUM); p->free_space = (imgtoolerr_t (*)(imgtool_partition *, UINT64 *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_FREE_SPACE); p->read_file = (imgtoolerr_t (*)(imgtool_partition *, const char *, const char *, imgtool_stream *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_READ_FILE); - p->write_file = (imgtoolerr_t (*)(imgtool_partition *, const char *, const char *, imgtool_stream *, option_resolution *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_WRITE_FILE); + p->write_file = (imgtoolerr_t (*)(imgtool_partition *, const char *, const char *, imgtool_stream *, util::option_resolution *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_WRITE_FILE); p->delete_file = (imgtoolerr_t (*)(imgtool_partition *, const char *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_DELETE_FILE); p->list_forks = (imgtoolerr_t (*)(imgtool_partition *, const char *, imgtool_forkent *, size_t)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_LIST_FORKS); p->create_dir = (imgtoolerr_t (*)(imgtool_partition *, const char *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_CREATE_DIR); @@ -1018,15 +1018,15 @@ int imgtool_validitychecks(void) if (module->createimage_optguide && module->createimage_optspec) { guide_entry = module->createimage_optguide; - while(guide_entry->option_type != OPTIONTYPE_END) + while (guide_entry->option_type != OPTIONTYPE_END) { - if (option_resolution_contains(module->createimage_optspec, guide_entry->parameter)) + if (util::option_resolution::contains(module->createimage_optspec, guide_entry->parameter)) { - switch(guide_entry->option_type) + switch (guide_entry->option_type) { case OPTIONTYPE_INT: case OPTIONTYPE_ENUM_BEGIN: - err = (imgtoolerr_t)option_resolution_getdefault(module->createimage_optspec, + err = (imgtoolerr_t)util::option_resolution::get_default(module->createimage_optspec, guide_entry->parameter, &val); if (err) goto done; @@ -1088,7 +1088,7 @@ char *imgtool_temp_str(void) ***************************************************************************/ static imgtoolerr_t internal_open(const imgtool_module *module, const char *fname, - int read_or_write, option_resolution *createopts, imgtool_image **outimg) + int read_or_write, util::option_resolution *createopts, imgtool_image **outimg) { imgtoolerr_t err; imgtool_stream *f = nullptr; @@ -1211,33 +1211,21 @@ void imgtool_image_close(imgtool_image *image) -------------------------------------------------*/ imgtoolerr_t imgtool_image_create(const imgtool_module *module, const char *fname, - option_resolution *opts, imgtool_image **image) + util::option_resolution *opts, imgtool_image **image) { - imgtoolerr_t err; - option_resolution *alloc_resolution = nullptr; + std::unique_ptr<util::option_resolution> alloc_resolution; /* allocate dummy options if necessary */ if (!opts && module->createimage_optguide) { - alloc_resolution = option_resolution_create(module->createimage_optguide, module->createimage_optspec); - if (!alloc_resolution) - { - err = (imgtoolerr_t)IMGTOOLERR_OUTOFMEMORY; - goto done; - } - opts = alloc_resolution; + try { alloc_resolution.reset(new util::option_resolution(module->createimage_optguide, module->createimage_optspec)); } + catch (...) { return (imgtoolerr_t)IMGTOOLERR_OUTOFMEMORY; } + opts = alloc_resolution.get(); } if (opts) - option_resolution_finish(opts); + opts->finish(); - err = internal_open(module, fname, OSD_FOPEN_RW_CREATE, opts, image); - if (err) - goto done; - -done: - if (alloc_resolution) - option_resolution_close(alloc_resolution); - return err; + return internal_open(module, fname, OSD_FOPEN_RW_CREATE, opts, image); } @@ -1247,7 +1235,7 @@ done: -------------------------------------------------*/ imgtoolerr_t imgtool_image_create_byname(const char *modulename, const char *fname, - option_resolution *opts, imgtool_image **image) + util::option_resolution *opts, imgtool_image **image) { const imgtool_module *module; @@ -1949,12 +1937,12 @@ done: to a new file on an image with a stream -------------------------------------------------*/ -imgtoolerr_t imgtool_partition_write_file(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, option_resolution *opts, filter_getinfoproc filter) +imgtoolerr_t imgtool_partition_write_file(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts, filter_getinfoproc filter) { imgtoolerr_t err; char *buf = nullptr; char *s; - option_resolution *alloc_resolution = nullptr; + std::unique_ptr<util::option_resolution> alloc_resolution; char *alloc_path = nullptr; UINT64 free_space; UINT64 file_size; @@ -2012,16 +2000,16 @@ imgtoolerr_t imgtool_partition_write_file(imgtool_partition *partition, const ch /* allocate dummy options if necessary */ if (!opts && partition->writefile_optguide) { - alloc_resolution = option_resolution_create(partition->writefile_optguide, partition->writefile_optspec); - if (!alloc_resolution) + try { alloc_resolution.reset(new util::option_resolution(partition->writefile_optguide, partition->writefile_optspec)); } + catch (...) { err = IMGTOOLERR_OUTOFMEMORY; goto done; } - opts = alloc_resolution; + opts = alloc_resolution.get(); } if (opts) - option_resolution_finish(opts); + opts->finish(); /* if free_space is implemented; do a quick check to see if space is available */ if (partition->free_space) @@ -2056,8 +2044,6 @@ done: free(buf); if (alloc_path) free(alloc_path); - if (alloc_resolution) - option_resolution_close(alloc_resolution); return err; } @@ -2137,7 +2123,7 @@ done: -------------------------------------------------*/ imgtoolerr_t imgtool_partition_put_file(imgtool_partition *partition, const char *newfname, const char *fork, - const char *source, option_resolution *opts, filter_getinfoproc filter) + const char *source, util::option_resolution *opts, filter_getinfoproc filter) { imgtoolerr_t err; imgtool_stream *f = nullptr; diff --git a/src/tools/imgtool/imgtool.h b/src/tools/imgtool/imgtool.h index e688dfb60f1..39a2db70d5e 100644 --- a/src/tools/imgtool/imgtool.h +++ b/src/tools/imgtool/imgtool.h @@ -89,8 +89,8 @@ char *imgtool_basename(char *filename); imgtoolerr_t imgtool_identify_file(const char *filename, imgtool_module **modules, size_t count); imgtoolerr_t imgtool_image_open(const imgtool_module *module, const char *filename, int read_or_write, imgtool_image **outimg); imgtoolerr_t imgtool_image_open_byname(const char *modulename, const char *filename, int read_or_write, imgtool_image **outimg); -imgtoolerr_t imgtool_image_create(const imgtool_module *module, const char *fname, option_resolution *opts, imgtool_image **image); -imgtoolerr_t imgtool_image_create_byname(const char *modulename, const char *fname, option_resolution *opts, imgtool_image **image); +imgtoolerr_t imgtool_image_create(const imgtool_module *module, const char *fname, util::option_resolution *opts, imgtool_image **image); +imgtoolerr_t imgtool_image_create_byname(const char *modulename, const char *fname, util::option_resolution *opts, imgtool_image **image); void imgtool_image_close(imgtool_image *image); imgtoolerr_t imgtool_image_info(imgtool_image *image, char *string, size_t len); imgtoolerr_t imgtool_image_get_sector_size(imgtool_image *image, UINT32 track, UINT32 head, UINT32 sector, UINT32 *length); @@ -117,9 +117,9 @@ imgtoolerr_t imgtool_partition_get_directory_entry(imgtool_partition *partition, imgtoolerr_t imgtool_partition_get_file_size(imgtool_partition *partition, const char *filename, UINT64 *filesize); imgtoolerr_t imgtool_partition_get_free_space(imgtool_partition *partition, UINT64 *sz); imgtoolerr_t imgtool_partition_read_file(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *destf, filter_getinfoproc filter); -imgtoolerr_t imgtool_partition_write_file(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, option_resolution *resolution, filter_getinfoproc filter); +imgtoolerr_t imgtool_partition_write_file(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *resolution, filter_getinfoproc filter); imgtoolerr_t imgtool_partition_get_file(imgtool_partition *partition, const char *filename, const char *fork, const char *dest, filter_getinfoproc filter); -imgtoolerr_t imgtool_partition_put_file(imgtool_partition *partition, const char *newfname, const char *fork, const char *source, option_resolution *opts, filter_getinfoproc filter); +imgtoolerr_t imgtool_partition_put_file(imgtool_partition *partition, const char *newfname, const char *fork, const char *source, util::option_resolution *opts, filter_getinfoproc filter); imgtoolerr_t imgtool_partition_delete_file(imgtool_partition *partition, const char *fname); imgtoolerr_t imgtool_partition_list_file_forks(imgtool_partition *partition, const char *path, imgtool_forkent *ents, size_t len); imgtoolerr_t imgtool_partition_create_directory(imgtool_partition *partition, const char *path); diff --git a/src/tools/imgtool/library.cpp b/src/tools/imgtool/library.cpp index 88c1119a85a..491e1c8e1c8 100644 --- a/src/tools/imgtool/library.cpp +++ b/src/tools/imgtool/library.cpp @@ -91,7 +91,7 @@ static void imgtool_library_add_class(imgtool_library *library, const imgtool_cl module->writing_untested = imgtool_get_info_int(imgclass, IMGTOOLINFO_INT_WRITING_UNTESTED) ? 1 : 0; module->creation_untested = imgtool_get_info_int(imgclass, IMGTOOLINFO_INT_CREATION_UNTESTED) ? 1 : 0; module->open = (imgtoolerr_t (*)(imgtool_image *, imgtool_stream *)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_OPEN); - module->create = (imgtoolerr_t (*)(imgtool_image *, imgtool_stream *, option_resolution *)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_CREATE); + module->create = (imgtoolerr_t (*)(imgtool_image *, imgtool_stream *, util::option_resolution *)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_CREATE); module->close = (void (*)(imgtool_image *)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_CLOSE); module->info = (void (*)(imgtool_image *, char *, size_t)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_INFO); module->read_sector = (imgtoolerr_t (*)(imgtool_image *, UINT32, UINT32, UINT32, void *, size_t)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_READ_SECTOR); diff --git a/src/tools/imgtool/library.h b/src/tools/imgtool/library.h index f9b792bc740..9371f019bfc 100644 --- a/src/tools/imgtool/library.h +++ b/src/tools/imgtool/library.h @@ -46,7 +46,7 @@ union filterinfo const char *s; /* generic strings */ imgtoolerr_t (*read_file)(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *destf); - imgtoolerr_t (*write_file)(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, option_resolution *opts); + imgtoolerr_t (*write_file)(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts); imgtoolerr_t (*check_stream)(imgtool_stream *stream, imgtool_suggestion_viability_t *viability); }; @@ -260,7 +260,7 @@ union imgtoolinfo imgtoolerr_t (*open) (imgtool_image *image, imgtool_stream *stream); void (*close) (imgtool_image *image); - imgtoolerr_t (*create) (imgtool_image *image, imgtool_stream *stream, option_resolution *opts); + imgtoolerr_t (*create) (imgtool_image *image, imgtool_stream *stream, util::option_resolution *opts); imgtoolerr_t (*create_partition) (imgtool_image *image, UINT64 first_block, UINT64 block_count); void (*info) (imgtool_image *image, char *string, size_t len); imgtoolerr_t (*begin_enum) (imgtool_directory *enumeration, const char *path); @@ -269,7 +269,7 @@ union imgtoolinfo imgtoolerr_t (*open_partition) (imgtool_partition *partition, UINT64 first_block, UINT64 block_count); imgtoolerr_t (*free_space) (imgtool_partition *partition, UINT64 *size); imgtoolerr_t (*read_file) (imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *destf); - imgtoolerr_t (*write_file) (imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, option_resolution *opts); + imgtoolerr_t (*write_file) (imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts); imgtoolerr_t (*delete_file) (imgtool_partition *partition, const char *filename); imgtoolerr_t (*list_forks) (imgtool_partition *partition, const char *path, imgtool_forkent *ents, size_t len); imgtoolerr_t (*create_dir) (imgtool_partition *partition, const char *path); @@ -358,7 +358,7 @@ struct imgtool_module imgtoolerr_t (*open) (imgtool_image *image, imgtool_stream *f); void (*close) (imgtool_image *image); void (*info) (imgtool_image *image, char *string, size_t len); - imgtoolerr_t (*create) (imgtool_image *image, imgtool_stream *f, option_resolution *opts); + imgtoolerr_t (*create) (imgtool_image *image, imgtool_stream *f, util::option_resolution *opts); imgtoolerr_t (*get_sector_size)(imgtool_image *image, UINT32 track, UINT32 head, UINT32 sector, UINT32 *sector_size); imgtoolerr_t (*get_geometry) (imgtool_image *image, UINT32 *track, UINT32 *heads, UINT32 *sectors); imgtoolerr_t (*read_sector) (imgtool_image *image, UINT32 track, UINT32 head, UINT32 sector, void *buffer, size_t len); diff --git a/src/tools/imgtool/main.cpp b/src/tools/imgtool/main.cpp index fb34403f51a..1faac27ee22 100644 --- a/src/tools/imgtool/main.cpp +++ b/src/tools/imgtool/main.cpp @@ -33,14 +33,14 @@ static void writeusage(FILE *f, int write_word_usage, const struct command *c, c /* ----------------------------------------------------------------------- */ static int parse_options(int argc, char *argv[], int minunnamed, int maxunnamed, - option_resolution *resolution, filter_getinfoproc *filter, const char **fork) + util::option_resolution *resolution, filter_getinfoproc *filter, const char **fork) { int i; int lastunnamed = 0; char *s; char *name = nullptr; char *value = nullptr; - optreserr_t oerr; + util::option_resolution::error oerr; static char buf[256]; if (filter) @@ -97,8 +97,8 @@ static int parse_options(int argc, char *argv[], int minunnamed, int maxunnamed, if (i < minunnamed) goto error; /* Too few unnamed */ - oerr = option_resolution_add_param(resolution, name, value); - if (oerr) + oerr = resolution->add_param(name, value); + if (oerr != util::option_resolution::error::SUCCESS) goto opterror; } } @@ -114,7 +114,7 @@ optionalreadyspecified: return -1; opterror: - fprintf(stderr, "%s: %s\n", name, option_resolution_error_string(oerr)); + fprintf(stderr, "%s: %s\n", name, util::option_resolution::error_string(oerr)); return -1; error: @@ -125,7 +125,7 @@ error: void reporterror(imgtoolerr_t err, const struct command *c, const char *format, const char *imagename, - const char *filename, const char *newname, option_resolution *opts) + const char *filename, const char *newname, util::option_resolution *opts) { const char *src = "imgtool"; const char *err_name; @@ -322,7 +322,7 @@ static int cmd_put(const struct command *c, int argc, char *argv[]) int unnamedargs; filter_getinfoproc filter; const imgtool_module *module; - option_resolution *resolution = nullptr; + std::unique_ptr<util::option_resolution> resolution; const char *fork; const char *new_filename; char **filename_list; @@ -358,8 +358,8 @@ static int cmd_put(const struct command *c, int argc, char *argv[]) if (writefile_optguide && writefile_optspec) { - resolution = option_resolution_create(writefile_optguide, writefile_optspec); - if (!resolution) + try { resolution.reset(new util::option_resolution(writefile_optguide, writefile_optspec)); } + catch (...) { err = IMGTOOLERR_OUTOFMEMORY; goto done; @@ -367,7 +367,7 @@ static int cmd_put(const struct command *c, int argc, char *argv[]) } } - unnamedargs = parse_options(argc, argv, 4, 0xffff, resolution, &filter, &fork); + unnamedargs = parse_options(argc, argv, 4, 0xffff, resolution.get(), &filter, &fork); if (unnamedargs < 0) return -1; @@ -381,7 +381,7 @@ static int cmd_put(const struct command *c, int argc, char *argv[]) { filename = filename_list[i]; printf("Putting file '%s'...\n", filename); - err = imgtool_partition_put_file(partition, new_filename, fork, filename, resolution, filter); + err = imgtool_partition_put_file(partition, new_filename, fork, filename, resolution.get(), filter); if (err) goto done; } @@ -391,10 +391,8 @@ done: imgtool_partition_close(partition); if (image) imgtool_image_close(image); - if (resolution) - option_resolution_close(resolution); if (err) - reporterror(err, c, argv[0], argv[1], filename, nullptr, resolution); + reporterror(err, c, argv[0], argv[1], filename, nullptr, resolution.get()); return err ? -1 : 0; } @@ -561,18 +559,19 @@ static int cmd_identify(const struct command *c, int argc, char *argv[]) err = imgtool_identify_file(argv[0], modules, ARRAY_LENGTH(modules)); if (err) - goto error; - - for (i = 0; modules[i]; i++) { - printf("%.16s %s\n", modules[i]->name, modules[i]->description); + reporterror(err, c, nullptr, argv[0], nullptr, nullptr, nullptr); + return -1; } + else + { + for (i = 0; modules[i]; i++) + { + printf("%.16s %s\n", modules[i]->name, modules[i]->description); + } - return 0; - -error: - reporterror(err, c, nullptr, argv[0], nullptr, nullptr, nullptr); - return -1; + return 0; + } } @@ -582,7 +581,7 @@ static int cmd_create(const struct command *c, int argc, char *argv[]) imgtoolerr_t err; int unnamedargs; const imgtool_module *module; - option_resolution *resolution = nullptr; + std::unique_ptr<util::option_resolution> resolution; module = imgtool_find_module(argv[0]); if (!module) @@ -593,29 +592,25 @@ static int cmd_create(const struct command *c, int argc, char *argv[]) if (module->createimage_optguide && module->createimage_optspec) { - resolution = option_resolution_create(module->createimage_optguide, module->createimage_optspec); - if (!resolution) + try { resolution.reset(new util::option_resolution(module->createimage_optguide, module->createimage_optspec)); } + catch (...) { err = IMGTOOLERR_OUTOFMEMORY; goto error; } } - unnamedargs = parse_options(argc, argv, 2, 3, resolution, nullptr, nullptr); + unnamedargs = parse_options(argc, argv, 2, 3, resolution.get(), nullptr, nullptr); if (unnamedargs < 0) return -1; - err = imgtool_image_create(module, argv[1], resolution, nullptr); + err = imgtool_image_create(module, argv[1], resolution.get(), nullptr); if (err) goto error; - if (resolution) - option_resolution_close(resolution); return 0; error: - if (resolution) - option_resolution_close(resolution); reporterror(err, c, argv[0], argv[1], nullptr, nullptr, nullptr); return -1; } @@ -751,7 +746,7 @@ static void listoptions(const option_guide *opt_guide, const char *opt_spec) { char opt_name[32]; const char *opt_desc; - struct OptionRange range[32]; + util::option_resolution::range range[32]; char range_buffer[512]; char buf[32]; int i; @@ -776,7 +771,7 @@ static void listoptions(const option_guide *opt_guide, const char *opt_spec) switch(opt_guide->option_type) { case OPTIONTYPE_INT: - option_resolution_listranges(opt_spec, opt_guide->parameter, + util::option_resolution::list_ranges(opt_spec, opt_guide->parameter, range, ARRAY_LENGTH(range)); for (i = 0; range[i].max >= 0; i++) @@ -831,7 +826,10 @@ static int cmd_listdriveroptions(const struct command *c, int argc, char *argv[] mod = imgtool_find_module(argv[0]); if (!mod) - goto error; + { + reporterror((imgtoolerr_t)(IMGTOOLERR_MODULENOTFOUND|IMGTOOLERR_SRC_MODULE), c, argv[0], nullptr, nullptr, nullptr, nullptr); + return -1; + } fprintf(stdout, "Driver specific options for module '%s':\n\n", argv[0]); @@ -863,10 +861,6 @@ static int cmd_listdriveroptions(const struct command *c, int argc, char *argv[] } return 0; - -error: - reporterror((imgtoolerr_t)(IMGTOOLERR_MODULENOTFOUND|IMGTOOLERR_SRC_MODULE), c, argv[0], nullptr, nullptr, nullptr, nullptr); - return -1; } diff --git a/src/tools/imgtool/main.h b/src/tools/imgtool/main.h index d4089686437..70cb43ebb49 100644 --- a/src/tools/imgtool/main.h +++ b/src/tools/imgtool/main.h @@ -13,7 +13,7 @@ struct command }; void reporterror(imgtoolerr_t err, const struct command *c, const char *format, const char *imagename, - const char *filename, const char *newname, option_resolution *opts); + const char *filename, const char *newname, util::option_resolution *opts); #ifdef MAME_DEBUG int cmd_testsuite(struct command *c, int argc, char *argv[]); diff --git a/src/tools/imgtool/modules/amiga.cpp b/src/tools/imgtool/modules/amiga.cpp index 7723748cbd2..35e8b896c1f 100644 --- a/src/tools/imgtool/modules/amiga.cpp +++ b/src/tools/imgtool/modules/amiga.cpp @@ -2184,16 +2184,16 @@ static imgtoolerr_t amiga_image_deletefile(imgtool_partition *partition, const c } -static imgtoolerr_t amiga_image_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, option_resolution *opts) +static imgtoolerr_t amiga_image_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) { return IMGTOOLERR_UNIMPLEMENTED; } -static imgtoolerr_t amiga_image_create(imgtool_image *img, imgtool_stream *stream, option_resolution *opts) +static imgtoolerr_t amiga_image_create(imgtool_image *img, imgtool_stream *stream, util::option_resolution *opts) { amiga_floppy *f = (amiga_floppy *) imgtool_image_extra_bytes(img); - const char *dskname = option_resolution_lookup_string(opts, 'N'); + const char *dskname = opts->lookup_string('N'); imgtoolerr_t ret; UINT8 buffer[BSIZE]; root_block root; @@ -2203,7 +2203,7 @@ static imgtoolerr_t amiga_image_create(imgtool_image *img, imgtool_stream *strea f->stream = stream; - switch (option_resolution_lookup_int(opts, 'S')) + switch (opts->lookup_int('S')) { case 0: f->sectors = 11; break; case 1: f->sectors = 22; break; @@ -2220,10 +2220,10 @@ static imgtoolerr_t amiga_image_create(imgtool_image *img, imgtool_stream *strea buffer[3] = 0; /* File system */ - buffer[3] += (option_resolution_lookup_int(opts, 'F')); + buffer[3] += (opts->lookup_int('F')); /* File system mode */ - buffer[3] += (option_resolution_lookup_int(opts, 'M')); + buffer[3] += (opts->lookup_int('M')); /* write first bootblock sector */ ret = write_block(img, 0, buffer); diff --git a/src/tools/imgtool/modules/bml3.cpp b/src/tools/imgtool/modules/bml3.cpp index 1ed1b645f69..ba825dab389 100644 --- a/src/tools/imgtool/modules/bml3.cpp +++ b/src/tools/imgtool/modules/bml3.cpp @@ -696,7 +696,7 @@ static imgtoolerr_t bml3_diskimage_readfile(imgtool_partition *partition, const -static imgtoolerr_t bml3_diskimage_writefile(imgtool_partition *partition, const char *fname, const char *fork, imgtool_stream *sourcef, option_resolution *writeoptions) +static imgtoolerr_t bml3_diskimage_writefile(imgtool_partition *partition, const char *fname, const char *fork, imgtool_stream *sourcef, util::option_resolution *writeoptions) { floperr_t ferr; imgtoolerr_t err; @@ -737,8 +737,8 @@ static imgtoolerr_t bml3_diskimage_writefile(imgtool_partition *partition, const if (err) return err; - ent.ftype = option_resolution_lookup_int(writeoptions, BML3_OPTIONS_FTYPE); - ent.asciiflag = ((UINT8) option_resolution_lookup_int(writeoptions, BML3_OPTIONS_ASCII)) - 1; + ent.ftype = writeoptions->lookup_int(BML3_OPTIONS_FTYPE); + ent.asciiflag = UINT8(writeoptions->lookup_int(BML3_OPTIONS_ASCII)) - 1; gptr = &ent.first_granule; ferr = get_granule_map(img, granule_map, &granule_count); diff --git a/src/tools/imgtool/modules/concept.cpp b/src/tools/imgtool/modules/concept.cpp index 3da7304c955..debbb631196 100644 --- a/src/tools/imgtool/modules/concept.cpp +++ b/src/tools/imgtool/modules/concept.cpp @@ -135,9 +135,9 @@ static void concept_image_closeenum(imgtool_directory *enumeration); static imgtoolerr_t concept_image_freespace(imgtool_partition *partition, UINT64 *size); static imgtoolerr_t concept_image_readfile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *destf); #if 0 -static imgtoolerr_t concept_image_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, option_resolution *writeoptions); +static imgtoolerr_t concept_image_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *writeoptions); static imgtoolerr_t concept_image_deletefile(imgtool_partition *partition, const char *filename); -static imgtoolerr_t concept_image_create(const imgtool_module *mod, imgtool_stream *f, option_resolution *createoptions); +static imgtoolerr_t concept_image_create(const imgtool_module *mod, imgtool_stream *f, util::option_resolution *createoptions); #endif void concept_get_info(const imgtool_class *imgclass, UINT32 state, union imgtoolinfo *info) @@ -463,7 +463,7 @@ static imgtoolerr_t concept_image_readfile(imgtool_partition *partition, const c /* Add a file to a concept_image. */ -static imgtoolerr_t concept_image_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, option_resolution *writeoptions) +static imgtoolerr_t concept_image_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *writeoptions) { /* ... */ @@ -483,7 +483,7 @@ static imgtoolerr_t concept_image_deletefile(imgtool_partition *partition, const /* Create a blank concept_image. */ -static imgtoolerr_t concept_image_create(const imgtool_module *mod, imgtool_stream *f, option_resolution *createoptions) +static imgtoolerr_t concept_image_create(const imgtool_module *mod, imgtool_stream *f, util::option_resolution *createoptions) { /* ... */ diff --git a/src/tools/imgtool/modules/cybiko.cpp b/src/tools/imgtool/modules/cybiko.cpp index 1fc2afd319b..735bb733be5 100644 --- a/src/tools/imgtool/modules/cybiko.cpp +++ b/src/tools/imgtool/modules/cybiko.cpp @@ -364,12 +364,12 @@ static void cybiko_image_close( imgtool_image *image) stream_close( cfs->stream); } -static imgtoolerr_t cybiko_image_create( imgtool_image *image, imgtool_stream *stream, option_resolution *opts) +static imgtoolerr_t cybiko_image_create( imgtool_image *image, imgtool_stream *stream, util::option_resolution *opts) { cybiko_file_system *cfs = (cybiko_file_system*)imgtool_image_extra_bytes( image); int flash_type; // init - flash_type = flash_option_to_flash_type( option_resolution_lookup_int( opts, 'F')); + flash_type = flash_option_to_flash_type(opts->lookup_int('F')); if (!cfs_init( cfs, stream, flash_type)) return IMGTOOLERR_CORRUPTIMAGE; // format if (!cfs_format( cfs)) return IMGTOOLERR_CORRUPTIMAGE; @@ -458,7 +458,7 @@ static imgtoolerr_t cybiko_image_read_file( imgtool_partition *partition, const return IMGTOOLERR_SUCCESS; } -static imgtoolerr_t cybiko_image_write_file( imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, option_resolution *opts) +static imgtoolerr_t cybiko_image_write_file( imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) { imgtool_image *image = imgtool_partition_image( partition); cybiko_file_system *cfs = (cybiko_file_system*)imgtool_image_extra_bytes( image); diff --git a/src/tools/imgtool/modules/cybikoxt.cpp b/src/tools/imgtool/modules/cybikoxt.cpp index a1908dc9c76..661a9e651cf 100644 --- a/src/tools/imgtool/modules/cybikoxt.cpp +++ b/src/tools/imgtool/modules/cybikoxt.cpp @@ -336,7 +336,7 @@ static void cybiko_image_close( imgtool_image *image) stream_close( cfs->stream); } -static imgtoolerr_t cybiko_image_create( imgtool_image *image, imgtool_stream *stream, option_resolution *opts) +static imgtoolerr_t cybiko_image_create( imgtool_image *image, imgtool_stream *stream, util::option_resolution *opts) { cybiko_file_system *cfs = (cybiko_file_system*)imgtool_image_extra_bytes( image); // init @@ -430,7 +430,7 @@ static imgtoolerr_t cybiko_image_read_file( imgtool_partition *partition, const return IMGTOOLERR_SUCCESS; } -static imgtoolerr_t cybiko_image_write_file( imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, option_resolution *opts) +static imgtoolerr_t cybiko_image_write_file( imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) { imgtool_image *image = imgtool_partition_image( partition); cybiko_file_system *cfs = (cybiko_file_system*)imgtool_image_extra_bytes( image); diff --git a/src/tools/imgtool/modules/fat.cpp b/src/tools/imgtool/modules/fat.cpp index 4f2fca17c25..c9305a7fab2 100644 --- a/src/tools/imgtool/modules/fat.cpp +++ b/src/tools/imgtool/modules/fat.cpp @@ -1931,7 +1931,7 @@ static imgtoolerr_t fat_partition_readfile(imgtool_partition *partition, const c -static imgtoolerr_t fat_partition_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, option_resolution *opts) +static imgtoolerr_t fat_partition_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) { imgtoolerr_t err; fat_file file; diff --git a/src/tools/imgtool/modules/hp48.cpp b/src/tools/imgtool/modules/hp48.cpp index e54908c9c1e..bfc193e9979 100644 --- a/src/tools/imgtool/modules/hp48.cpp +++ b/src/tools/imgtool/modules/hp48.cpp @@ -365,12 +365,12 @@ static imgtoolerr_t hp48_open(imgtool_image *img, imgtool_stream *stream) static imgtoolerr_t hp48_create(imgtool_image* img, imgtool_stream *stream, - option_resolution *opts) + util::option_resolution *opts) { hp48_card* c = (hp48_card*) imgtool_image_extra_bytes( img ); int size; - size = option_resolution_lookup_int(opts, 'S'); + size = opts->lookup_int('S'); c->stream = stream; c->modified = 1; @@ -614,7 +614,7 @@ static imgtoolerr_t hp48_writefile(imgtool_partition *part, const char *filename, const char *fork, imgtool_stream *sourcef, - option_resolution *opts) + util::option_resolution *opts) { imgtool_image* img = imgtool_partition_image( part ); hp48_card* c = (hp48_card*) imgtool_image_extra_bytes( img ); diff --git a/src/tools/imgtool/modules/mac.cpp b/src/tools/imgtool/modules/mac.cpp index 938a8a19ec5..bfa111c6205 100644 --- a/src/tools/imgtool/modules/mac.cpp +++ b/src/tools/imgtool/modules/mac.cpp @@ -1542,7 +1542,7 @@ struct mfs_dirref -static imgtoolerr_t mfs_image_create(imgtool_image *image, imgtool_stream *stream, option_resolution *opts) +static imgtoolerr_t mfs_image_create(imgtool_image *image, imgtool_stream *stream, util::option_resolution *opts) { imgtoolerr_t err; UINT8 buffer[512]; @@ -1550,9 +1550,9 @@ static imgtoolerr_t mfs_image_create(imgtool_image *image, imgtool_stream *strea UINT32 total_disk_blocks, total_allocation_blocks, allocation_block_size; UINT32 free_allocation_blocks; - heads = option_resolution_lookup_int(opts, 'H'); - tracks = option_resolution_lookup_int(opts, 'T'); - sector_bytes = option_resolution_lookup_int(opts, 'L'); + heads = opts->lookup_int('H'); + tracks = opts->lookup_int('T'); + sector_bytes = opts->lookup_int('L'); get_imgref(image)->l1_img.image = image; get_imgref(image)->l1_img.heads = heads; @@ -5277,7 +5277,7 @@ static imgtoolerr_t mac_image_beginenum(imgtool_directory *enumeration, const ch static imgtoolerr_t mac_image_nextenum(imgtool_directory *enumeration, imgtool_dirent *ent); static imgtoolerr_t mac_image_freespace(imgtool_partition *partition, UINT64 *size); static imgtoolerr_t mac_image_readfile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *destf); -static imgtoolerr_t mac_image_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, option_resolution *writeoptions); +static imgtoolerr_t mac_image_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *writeoptions); #ifdef UNUSED_FUNCTION /* @@ -5660,7 +5660,7 @@ static imgtoolerr_t mac_image_readfile(imgtool_partition *partition, const char /* Add a file to a disk image. */ -static imgtoolerr_t mac_image_writefile(imgtool_partition *partition, const char *fpath, const char *fork, imgtool_stream *sourcef, option_resolution *writeoptions) +static imgtoolerr_t mac_image_writefile(imgtool_partition *partition, const char *fpath, const char *fork, imgtool_stream *sourcef, util::option_resolution *writeoptions) { imgtool_image *img = imgtool_partition_image(partition); struct mac_l2_imgref *image = get_imgref(img); diff --git a/src/tools/imgtool/modules/macbin.cpp b/src/tools/imgtool/modules/macbin.cpp index 3ef85a039d1..5f6f362d030 100644 --- a/src/tools/imgtool/modules/macbin.cpp +++ b/src/tools/imgtool/modules/macbin.cpp @@ -182,7 +182,7 @@ static imgtoolerr_t macbinary_readfile(imgtool_partition *partition, const char static imgtoolerr_t write_fork(imgtool_partition *partition, const char *filename, const char *fork, - imgtool_stream *sourcef, UINT64 pos, UINT64 fork_len, option_resolution *opts) + imgtool_stream *sourcef, UINT64 pos, UINT64 fork_len, util::option_resolution *opts) { imgtoolerr_t err = IMGTOOLERR_SUCCESS; imgtool_stream *mem_stream = NULL; @@ -216,7 +216,7 @@ done: -static imgtoolerr_t macbinary_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, option_resolution *opts) +static imgtoolerr_t macbinary_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) { static const UINT32 attrs[] = { diff --git a/src/tools/imgtool/modules/os9.cpp b/src/tools/imgtool/modules/os9.cpp index 2a9e2fb0292..32138dccc9c 100644 --- a/src/tools/imgtool/modules/os9.cpp +++ b/src/tools/imgtool/modules/os9.cpp @@ -710,7 +710,7 @@ static imgtoolerr_t os9_diskimage_open(imgtool_image *image, imgtool_stream *str -static imgtoolerr_t os9_diskimage_create(imgtool_image *img, imgtool_stream *stream, option_resolution *opts) +static imgtoolerr_t os9_diskimage_create(imgtool_image *img, imgtool_stream *stream, util::option_resolution *opts) { imgtoolerr_t err; dynamic_buffer header; @@ -727,11 +727,11 @@ static imgtoolerr_t os9_diskimage_create(imgtool_image *img, imgtool_stream *str time(&t); ltime = localtime(&t); - heads = option_resolution_lookup_int(opts, 'H'); - tracks = option_resolution_lookup_int(opts, 'T'); - sectors = option_resolution_lookup_int(opts, 'S'); - sector_bytes = option_resolution_lookup_int(opts, 'L'); - first_sector_id = option_resolution_lookup_int(opts, 'F'); + heads = opts->lookup_int('H'); + tracks = opts->lookup_int('T'); + sectors = opts->lookup_int('S'); + sector_bytes = opts->lookup_int('L'); + first_sector_id = opts->lookup_int('F'); title = ""; header.resize(sector_bytes); @@ -1026,7 +1026,7 @@ static imgtoolerr_t os9_diskimage_readfile(imgtool_partition *partition, const c -static imgtoolerr_t os9_diskimage_writefile(imgtool_partition *partition, const char *path, const char *fork, imgtool_stream *sourcef, option_resolution *opts) +static imgtoolerr_t os9_diskimage_writefile(imgtool_partition *partition, const char *path, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) { imgtoolerr_t err; imgtool_image *image = imgtool_partition_image(partition); diff --git a/src/tools/imgtool/modules/pc_flop.cpp b/src/tools/imgtool/modules/pc_flop.cpp index 916cf873c46..a958151c5db 100644 --- a/src/tools/imgtool/modules/pc_flop.cpp +++ b/src/tools/imgtool/modules/pc_flop.cpp @@ -17,7 +17,7 @@ #define FAT_SECLEN 512 -static imgtoolerr_t fat_image_create(imgtool_image *image, imgtool_stream *stream, option_resolution *opts) +static imgtoolerr_t fat_image_create(imgtool_image *image, imgtool_stream *stream, util::option_resolution *opts) { imgtoolerr_t err; UINT32 tracks, heads, sectors; @@ -25,9 +25,9 @@ static imgtoolerr_t fat_image_create(imgtool_image *image, imgtool_stream *strea imgtool_class imgclass = { fat_get_info }; imgtoolerr_t (*fat_partition_create)(imgtool_image *image, UINT64 first_block, UINT64 block_count); - tracks = option_resolution_lookup_int(opts, 'T'); - heads = option_resolution_lookup_int(opts, 'H'); - sectors = option_resolution_lookup_int(opts, 'S'); + tracks = opts->lookup_int('T'); + heads = opts->lookup_int('H'); + sectors = opts->lookup_int('S'); /* set up just enough of a boot sector to specify geometry */ memset(buffer, 0, sizeof(buffer)); diff --git a/src/tools/imgtool/modules/pc_hard.cpp b/src/tools/imgtool/modules/pc_hard.cpp index 915032932c7..eefc78b85ec 100644 --- a/src/tools/imgtool/modules/pc_hard.cpp +++ b/src/tools/imgtool/modules/pc_hard.cpp @@ -232,16 +232,16 @@ static imgtoolerr_t pc_chd_read_partition_header(imgtool_image *image) -static imgtoolerr_t pc_chd_image_create(imgtool_image *image, imgtool_stream *f, option_resolution *opts) +static imgtoolerr_t pc_chd_image_create(imgtool_image *image, imgtool_stream *f, util::option_resolution *opts) { imgtoolerr_t err; UINT32 cylinders, heads, sectors; pc_chd_image_info *info; UINT8 header_block[FAT_SECLEN]; - cylinders = option_resolution_lookup_int(opts, 'T'); - heads = option_resolution_lookup_int(opts, 'H'); - sectors = option_resolution_lookup_int(opts, 'S'); + cylinders = opts->lookup_int('T'); + heads = opts->lookup_int('H'); + sectors = opts->lookup_int('S'); info = pc_chd_get_image_info(image); diff --git a/src/tools/imgtool/modules/prodos.cpp b/src/tools/imgtool/modules/prodos.cpp index 5800e2bf9f3..576f496da8a 100644 --- a/src/tools/imgtool/modules/prodos.cpp +++ b/src/tools/imgtool/modules/prodos.cpp @@ -660,7 +660,7 @@ done: /* ----------------------------------------------------------------------- */ -static imgtoolerr_t prodos_diskimage_create(imgtool_image *image, option_resolution *opts) +static imgtoolerr_t prodos_diskimage_create(imgtool_image *image, util::option_resolution *opts) { imgtoolerr_t err; UINT32 heads, tracks, sectors, sector_bytes; @@ -668,10 +668,10 @@ static imgtoolerr_t prodos_diskimage_create(imgtool_image *image, option_resolut UINT32 volume_bitmap_block_count, total_blocks; UINT8 buffer[BLOCK_SIZE]; - heads = option_resolution_lookup_int(opts, 'H'); - tracks = option_resolution_lookup_int(opts, 'T'); - sectors = option_resolution_lookup_int(opts, 'S'); - sector_bytes = option_resolution_lookup_int(opts, 'L'); + heads = opts->lookup_int('H'); + tracks = opts->lookup_int('T'); + sectors = opts->lookup_int('S'); + sector_bytes = opts->lookup_int('L'); dirent_size = 39; volume_bitmap_block = 6; @@ -702,7 +702,7 @@ static imgtoolerr_t prodos_diskimage_create(imgtool_image *image, option_resolut -static imgtoolerr_t prodos_diskimage_create_525(imgtool_image *image, imgtool_stream *stream, option_resolution *opts) +static imgtoolerr_t prodos_diskimage_create_525(imgtool_image *image, imgtool_stream *stream, util::option_resolution *opts) { prodos_setprocs_525(image); return prodos_diskimage_create(image, opts); @@ -710,7 +710,7 @@ static imgtoolerr_t prodos_diskimage_create_525(imgtool_image *image, imgtool_st -static imgtoolerr_t prodos_diskimage_create_35(imgtool_image *image, imgtool_stream *stream, option_resolution *opts) +static imgtoolerr_t prodos_diskimage_create_35(imgtool_image *image, imgtool_stream *stream, util::option_resolution *opts) { prodos_setprocs_35(image); return prodos_diskimage_create(image, opts); @@ -1744,7 +1744,7 @@ static imgtoolerr_t prodos_diskimage_readfile(imgtool_partition *partition, cons -static imgtoolerr_t prodos_diskimage_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, option_resolution *opts) +static imgtoolerr_t prodos_diskimage_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) { imgtoolerr_t err; imgtool_image *image = imgtool_partition_image(partition); diff --git a/src/tools/imgtool/modules/psion.cpp b/src/tools/imgtool/modules/psion.cpp index d343dde5c6a..815cd78f265 100644 --- a/src/tools/imgtool/modules/psion.cpp +++ b/src/tools/imgtool/modules/psion.cpp @@ -403,19 +403,19 @@ static imgtoolerr_t datapack_open( imgtool_image *image, imgtool_stream *stream) return IMGTOOLERR_CORRUPTIMAGE; } -static imgtoolerr_t datapack_create( imgtool_image *image, imgtool_stream *stream, option_resolution *opts) +static imgtoolerr_t datapack_create( imgtool_image *image, imgtool_stream *stream, util::option_resolution *opts) { psion_pack *pack = (psion_pack*)imgtool_image_extra_bytes(image); static const UINT8 opk_magic[4] = {'O', 'P', 'K', 0x00}; UINT8 pack_head[8] = {0x40, 0x00, 0x59, 0x01, 0x01, 0x01, 0x00, 0x00}; UINT16 checksum; - pack_head[0] |= (option_resolution_lookup_int(opts, 'R')) ? 0x00 : 0x02; - pack_head[0] |= (option_resolution_lookup_int(opts, 'P')) ? 0x04 : 0x00; - pack_head[0] |= (option_resolution_lookup_int(opts, 'W')) ? 0x00 : 0x08; - pack_head[0] |= (option_resolution_lookup_int(opts, 'B')) ? 0x00 : 0x10; - pack_head[0] |= (option_resolution_lookup_int(opts, 'C')) ? 0x20 : 0x00; - pack_head[1] = option_resolution_lookup_int(opts, 'S'); + pack_head[0] |= (opts->lookup_int('R')) ? 0x00 : 0x02; + pack_head[0] |= (opts->lookup_int('P')) ? 0x04 : 0x00; + pack_head[0] |= (opts->lookup_int('W')) ? 0x00 : 0x08; + pack_head[0] |= (opts->lookup_int('B')) ? 0x00 : 0x10; + pack_head[0] |= (opts->lookup_int('C')) ? 0x20 : 0x00; + pack_head[1] = opts->lookup_int('S'); checksum = head_checksum(pack_head); @@ -543,15 +543,15 @@ static imgtoolerr_t datapack_read_file(imgtool_partition *partition, const char return IMGTOOLERR_FILENOTFOUND; } -static imgtoolerr_t datapack_write_file( imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, option_resolution *opts) +static imgtoolerr_t datapack_write_file( imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) { imgtool_image *image = imgtool_partition_image(partition); psion_pack *pack = (psion_pack*)imgtool_image_extra_bytes(image); static const UINT8 data_head[4] = {0x02, 0x80, 0x00, 0x00}; UINT8 head[3]; UINT16 size = 0; - UINT8 type = option_resolution_lookup_int(opts, 'T'); - UINT8 file_id = option_resolution_lookup_int(opts, 'I'); + UINT8 type = opts->lookup_int('T'); + UINT8 file_id = opts->lookup_int('I'); if (!pack->eop) return IMGTOOLERR_CORRUPTIMAGE; diff --git a/src/tools/imgtool/modules/rsdos.cpp b/src/tools/imgtool/modules/rsdos.cpp index 8323574b001..d6d28c7610e 100644 --- a/src/tools/imgtool/modules/rsdos.cpp +++ b/src/tools/imgtool/modules/rsdos.cpp @@ -409,7 +409,7 @@ static imgtoolerr_t rsdos_diskimage_readfile(imgtool_partition *partition, const -static imgtoolerr_t rsdos_diskimage_writefile(imgtool_partition *partition, const char *fname, const char *fork, imgtool_stream *sourcef, option_resolution *writeoptions) +static imgtoolerr_t rsdos_diskimage_writefile(imgtool_partition *partition, const char *fname, const char *fork, imgtool_stream *sourcef, util::option_resolution *writeoptions) { floperr_t ferr; imgtoolerr_t err; @@ -441,8 +441,8 @@ static imgtoolerr_t rsdos_diskimage_writefile(imgtool_partition *partition, cons if (err) return err; - ent.ftype = option_resolution_lookup_int(writeoptions, RSDOS_OPTIONS_FTYPE); - ent.asciiflag = ((UINT8) option_resolution_lookup_int(writeoptions, RSDOS_OPTIONS_ASCII)) - 1; + ent.ftype = writeoptions->lookup_int(RSDOS_OPTIONS_FTYPE); + ent.asciiflag = UINT8(writeoptions->lookup_int(RSDOS_OPTIONS_ASCII)) - 1; ent.lastsectorbytes_lsb = sz % 256; ent.lastsectorbytes_msb = (((sz % 256) == 0) && (sz > 0)) ? 1 : 0; gptr = &ent.first_granule; diff --git a/src/tools/imgtool/modules/thomson.cpp b/src/tools/imgtool/modules/thomson.cpp index 43684bc0aea..4d0c6718780 100644 --- a/src/tools/imgtool/modules/thomson.cpp +++ b/src/tools/imgtool/modules/thomson.cpp @@ -994,7 +994,7 @@ static imgtoolerr_t thom_write_file(imgtool_partition *part, const char *filename, const char *fork, imgtool_stream *sourcef, - option_resolution *opts) + util::option_resolution *opts) { int head = *( (int*) imgtool_partition_extra_bytes( part ) ); imgtool_image* img = imgtool_partition_image( part ); @@ -1003,7 +1003,6 @@ static imgtoolerr_t thom_write_file(imgtool_partition *part, int size = stream_size( sourcef ); int blocks = thom_get_free_blocks( f, head ); char name[9], ext[4], fname[14]; - const char* comment; int is_new = 1; if ( stream_isreadonly( f->stream ) ) return IMGTOOLERR_WRITEERROR; @@ -1033,7 +1032,7 @@ static imgtoolerr_t thom_write_file(imgtool_partition *part, memcpy( d.ext, ext, 4 ); /* file type */ - switch ( option_resolution_lookup_int( opts, 'T' ) ) { + switch ( opts->lookup_int('T') ) { case 0: if ( ! is_new ) break; if ( ! core_stricmp( ext, "BAS" ) ) d.ftype = 0; @@ -1053,7 +1052,7 @@ static imgtoolerr_t thom_write_file(imgtool_partition *part, } /* format flag */ - switch ( option_resolution_lookup_int( opts, 'F' ) ) { + switch ( opts->lookup_int('F') ) { case 0: if ( ! is_new ) break; if ( ! core_stricmp( ext, "DAT" ) ) d.format = 0xff; @@ -1066,9 +1065,9 @@ static imgtoolerr_t thom_write_file(imgtool_partition *part, } /* comment */ - comment = option_resolution_lookup_string( opts, 'C' ); - if ( comment && *comment ) - strncpy( d.comment, comment, 8 ); + char const *const comment = opts->lookup_string('C'); + if (comment && *comment) + strncpy(d.comment, comment, 8); /* write file */ thom_put_file( f, head, &d, sourcef ); @@ -1120,7 +1119,7 @@ static imgtoolerr_t thom_suggest_transfer(imgtool_partition *part, static imgtoolerr_t thom_create(imgtool_image* img, imgtool_stream *stream, - option_resolution *opts) + util::option_resolution *opts) { thom_floppy* f = (thom_floppy*) imgtool_image_extra_bytes( img ); int i; @@ -1131,10 +1130,10 @@ static imgtoolerr_t thom_create(imgtool_image* img, f->modified = 0; /* get parameters */ - f->heads = option_resolution_lookup_int( opts, 'H' ); - f->tracks = option_resolution_lookup_int( opts, 'T' ); - name = option_resolution_lookup_string( opts, 'N' ); - switch ( option_resolution_lookup_int( opts, 'D' ) ) { + f->heads = opts->lookup_int('H'); + f->tracks = opts->lookup_int('T'); + name = opts->lookup_string('N'); + switch ( opts->lookup_int('D') ) { case 0: f->sector_size = 128; f->sectuse_size = 128; break; case 1: f->sector_size = 256; f->sectuse_size = 255; break; default: return IMGTOOLERR_PARAMCORRUPT; @@ -1351,7 +1350,7 @@ static imgtoolerr_t thomcrypt_read_file(imgtool_partition *part, static imgtoolerr_t thomcrypt_write_file(imgtool_partition *part, const char *name, const char *fork, imgtool_stream *src, - option_resolution *opts) + util::option_resolution *opts) { UINT8 buf[3]; @@ -1468,7 +1467,7 @@ static imgtoolerr_t thom_basic_write_file(imgtool_partition *part, const char *name, const char *fork, imgtool_stream *src, - option_resolution *opts, + util::option_resolution *opts, const char *const table[2][128]) { return IMGTOOLERR_UNIMPLEMENTED; @@ -1487,7 +1486,7 @@ static imgtoolerr_t thom_basic_write_file(imgtool_partition *part, const char *name, \ const char *fork, \ imgtool_stream *src, \ - option_resolution *opts) \ + util::option_resolution *opts) \ { \ return thom_basic_write_file( part, name, fork, src, opts, short ); \ } \ diff --git a/src/tools/imgtool/modules/ti99.cpp b/src/tools/imgtool/modules/ti99.cpp index eb72b22c577..f5554d5fc9c 100644 --- a/src/tools/imgtool/modules/ti99.cpp +++ b/src/tools/imgtool/modules/ti99.cpp @@ -3861,11 +3861,11 @@ static imgtoolerr_t win_image_beginenum(imgtool_directory *enumeration, const ch static imgtoolerr_t win_image_nextenum(imgtool_directory *enumeration, imgtool_dirent *ent); static imgtoolerr_t ti99_image_freespace(imgtool_partition *partition, UINT64 *size); static imgtoolerr_t ti99_image_readfile(imgtool_partition *partition, const char *fpath, const char *fork, imgtool_stream *destf); -static imgtoolerr_t ti99_image_writefile(imgtool_partition *partition, const char *fpath, const char *fork, imgtool_stream *sourcef, option_resolution *writeoptions); +static imgtoolerr_t ti99_image_writefile(imgtool_partition *partition, const char *fpath, const char *fork, imgtool_stream *sourcef, util::option_resolution *writeoptions); static imgtoolerr_t dsk_image_deletefile(imgtool_partition *partition, const char *fpath); static imgtoolerr_t win_image_deletefile(imgtool_partition *partition, const char *fpath); -static imgtoolerr_t dsk_image_create_mess(imgtool_image *image, imgtool_stream *f, option_resolution *createoptions); -static imgtoolerr_t dsk_image_create_v9t9(imgtool_image *image, imgtool_stream *f, option_resolution *createoptions); +static imgtoolerr_t dsk_image_create_mess(imgtool_image *image, imgtool_stream *f, util::option_resolution *createoptions); +static imgtoolerr_t dsk_image_create_v9t9(imgtool_image *image, imgtool_stream *f, util::option_resolution *createoptions); enum { @@ -4644,7 +4644,7 @@ static imgtoolerr_t ti99_image_readfile(imgtool_partition *partition, const char /* Add a file to a ti99_image. The file must be in tifile format. */ -static imgtoolerr_t ti99_image_writefile(imgtool_partition *partition, const char *fpath, const char *fork, imgtool_stream *sourcef, option_resolution *writeoptions) +static imgtoolerr_t ti99_image_writefile(imgtool_partition *partition, const char *fpath, const char *fork, imgtool_stream *sourcef, util::option_resolution *writeoptions) { imgtool_image *img = imgtool_partition_image(partition); struct ti99_lvl2_imgref *image = (struct ti99_lvl2_imgref *) imgtool_image_extra_bytes(img); @@ -5226,7 +5226,7 @@ static imgtoolerr_t win_image_deletefile(imgtool_partition *partition, const cha Supports MESS and V9T9 formats only */ -static imgtoolerr_t dsk_image_create(imgtool_image *image, imgtool_stream *f, option_resolution *createoptions, ti99_img_format img_format) +static imgtoolerr_t dsk_image_create(imgtool_image *image, imgtool_stream *f, util::option_resolution *createoptions, ti99_img_format img_format) { const char *volname; int density; @@ -5244,12 +5244,12 @@ static imgtoolerr_t dsk_image_create(imgtool_image *image, imgtool_stream *f, op l1_img.file_handle = f; /* read options */ - volname = option_resolution_lookup_string(createoptions, dsk_createopts_volname); - l1_img.geometry.heads = option_resolution_lookup_int(createoptions, dsk_createopts_sides); - l1_img.geometry.cylinders = option_resolution_lookup_int(createoptions, dsk_createopts_tracks); - l1_img.geometry.secspertrack = option_resolution_lookup_int(createoptions, dsk_createopts_sectors); - protected_var = option_resolution_lookup_int(createoptions, dsk_createopts_protection); - density = option_resolution_lookup_int(createoptions, dsk_createopts_density); + volname = createoptions->lookup_string(dsk_createopts_volname); + l1_img.geometry.heads = createoptions->lookup_int(dsk_createopts_sides); + l1_img.geometry.cylinders = createoptions->lookup_int(dsk_createopts_tracks); + l1_img.geometry.secspertrack = createoptions->lookup_int(dsk_createopts_sectors); + protected_var = createoptions->lookup_int(dsk_createopts_protection); + density = createoptions->lookup_int(dsk_createopts_density); /* NPW 03-DEC-2003 - Fixes a crash if volname is NULL */ if (!volname) @@ -5346,7 +5346,7 @@ static imgtoolerr_t dsk_image_create(imgtool_image *image, imgtool_stream *f, op /* Create a blank ti99_image (MESS format). */ -static imgtoolerr_t dsk_image_create_mess(imgtool_image *image, imgtool_stream *f, option_resolution *createoptions) +static imgtoolerr_t dsk_image_create_mess(imgtool_image *image, imgtool_stream *f, util::option_resolution *createoptions) { return dsk_image_create(image, f, createoptions, if_mess); } @@ -5354,7 +5354,7 @@ static imgtoolerr_t dsk_image_create_mess(imgtool_image *image, imgtool_stream * /* Create a blank ti99_image (V9T9 format). */ -static imgtoolerr_t dsk_image_create_v9t9(imgtool_image *image, imgtool_stream *f, option_resolution *createoptions) +static imgtoolerr_t dsk_image_create_v9t9(imgtool_image *image, imgtool_stream *f, util::option_resolution *createoptions) { return dsk_image_create(image, f, createoptions, if_v9t9); } diff --git a/src/tools/imgtool/modules/ti990hd.cpp b/src/tools/imgtool/modules/ti990hd.cpp index 554addb97bd..d4731f4d753 100644 --- a/src/tools/imgtool/modules/ti990hd.cpp +++ b/src/tools/imgtool/modules/ti990hd.cpp @@ -395,10 +395,10 @@ static void ti990_image_closeenum(imgtool_directory *enumeration); static imgtoolerr_t ti990_image_freespace(imgtool_partition *partition, UINT64 *size); #ifdef UNUSED_FUNCTION static imgtoolerr_t ti990_image_readfile(imgtool_partition *partition, const char *fpath, imgtool_stream *destf); -static imgtoolerr_t ti990_image_writefile(imgtool_partition *partition, const char *fpath, imgtool_stream *sourcef, option_resolution *writeoptions); +static imgtoolerr_t ti990_image_writefile(imgtool_partition *partition, const char *fpath, imgtool_stream *sourcef, util::option_resolution *writeoptions); static imgtoolerr_t ti990_image_deletefile(imgtool_partition *partition, const char *fpath); #endif -static imgtoolerr_t ti990_image_create(imgtool_image *image, imgtool_stream *f, option_resolution *createoptions); +static imgtoolerr_t ti990_image_create(imgtool_image *image, imgtool_stream *f, util::option_resolution *createoptions); enum { @@ -1550,7 +1550,7 @@ static imgtoolerr_t ti990_image_readfile(imgtool_partition *partition, const cha /* Add a file to a ti990_image. */ -static imgtoolerr_t ti990_image_writefile(imgtool_partition *partition, const char *fpath, imgtool_stream *sourcef, option_resolution *writeoptions) +static imgtoolerr_t ti990_image_writefile(imgtool_partition *partition, const char *fpath, imgtool_stream *sourcef, util::option_resolution *writeoptions) { imgtool_image *img = imgtool_partition_image(partition); ti990_image *image = (ti990_image *) imgtool_image_extra_bytes(img); @@ -1764,7 +1764,7 @@ static imgtoolerr_t ti990_image_deletefile(imgtool_partition *partition, const c /* Create a blank ti990_image. */ -static imgtoolerr_t ti990_image_create(imgtool_image *image, imgtool_stream *f, option_resolution *createoptions) +static imgtoolerr_t ti990_image_create(imgtool_image *image, imgtool_stream *f, util::option_resolution *createoptions) { //const char *volname; ti990_geometry geometry; @@ -1776,11 +1776,11 @@ static imgtoolerr_t ti990_image_create(imgtool_image *image, imgtool_stream *f, int i; /* read options */ - //volname = option_resolution_lookup_string(createoptions, ti990_createopts_volname); - geometry.cylinders = option_resolution_lookup_int(createoptions, ti990_createopts_cylinders); - geometry.heads = option_resolution_lookup_int(createoptions, ti990_createopts_heads); - geometry.sectors_per_track = option_resolution_lookup_int(createoptions, ti990_createopts_sectors); - geometry.bytes_per_sector = option_resolution_lookup_int(createoptions, ti990_createopts_sectorsize); + //volname = createoptions->lookup_string(ti990_createopts_volname); + geometry.cylinders = createoptions->lookup_int(ti990_createopts_cylinders); + geometry.heads = createoptions->lookup_int(ti990_createopts_heads); + geometry.sectors_per_track = createoptions->lookup_int(ti990_createopts_sectors); + geometry.bytes_per_sector = createoptions->lookup_int(ti990_createopts_sectorsize); totsecs = geometry.cylinders * geometry.heads * geometry.sectors_per_track; diff --git a/src/tools/imgtool/modules/vzdos.cpp b/src/tools/imgtool/modules/vzdos.cpp index bacaa448ef8..09f01556b06 100644 --- a/src/tools/imgtool/modules/vzdos.cpp +++ b/src/tools/imgtool/modules/vzdos.cpp @@ -700,7 +700,7 @@ static imgtoolerr_t vzdos_writefile(imgtool_partition *partition, int offset, im } /* create a new file or overwrite a file */ -static imgtoolerr_t vzdos_diskimage_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, option_resolution *opts) +static imgtoolerr_t vzdos_diskimage_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) { imgtoolerr_t ret; int ftype; @@ -711,7 +711,7 @@ static imgtoolerr_t vzdos_diskimage_writefile(imgtool_partition *partition, cons return IMGTOOLERR_BADFILENAME; /* prepare directory entry */ - ftype = option_resolution_lookup_int(opts, 'T'); + ftype = opts->lookup_int('T'); switch (ftype) { case 0: @@ -789,7 +789,7 @@ static imgtoolerr_t vzdos_diskimage_suggesttransfer(imgtool_partition *partition return IMGTOOLERR_SUCCESS; } -static imgtoolerr_t vzdos_diskimage_create(imgtool_image *img, imgtool_stream *stream, option_resolution *opts) +static imgtoolerr_t vzdos_diskimage_create(imgtool_image *img, imgtool_stream *stream, util::option_resolution *opts) { imgtoolerr_t ret; int track, sector; @@ -852,7 +852,7 @@ static imgtoolerr_t vzsnapshot_readfile(imgtool_partition *partition, const char return IMGTOOLERR_SUCCESS; } -static imgtoolerr_t vzsnapshot_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, option_resolution *opts) +static imgtoolerr_t vzsnapshot_writefile(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) { imgtoolerr_t ret; int fnameopt; @@ -868,7 +868,7 @@ static imgtoolerr_t vzsnapshot_writefile(imgtool_partition *partition, const cha entry.start_address = pick_integer_le(header, 22, 2); /* filename from header or directly? */ - fnameopt = option_resolution_lookup_int(opts, 'F'); + fnameopt = opts->lookup_int('F'); if (fnameopt == 0) { memcpy(&entry.fname, &header[4], 8); |