summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools/imgtool/modules.cpp
blob: 35b31a38be025f39b6dabfe980ad1a6c77a51f49 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// license:BSD-3-Clause
// copyright-holders:Nathan Woods
/***************************************************************************

    modules.c

    List of Imgtool modules

***************************************************************************/

#include "imgtool.h"
#include "modules.h"

#ifndef MODULES_RECURSIVE
#define MODULES_RECURSIVE

/* step 1: declare all external references */
#define MODULE(name)    extern void name##_get_info(const imgtool_class *imgclass, uint32_t state, union imgtoolinfo *info);
#include "modules.cpp"
#undef MODULE

/* step 2: define the modules[] array */
#define MODULE(name)    name##_get_info,
static void (*const modules[])(const imgtool_class *imgclass, uint32_t state, union imgtoolinfo *info) =
{
#include "modules.cpp"
};

/* step 3: declare imgtool_create_cannonical_library() */
imgtoolerr_t imgtool_create_cannonical_library(bool omit_untested, std::unique_ptr<imgtool::library> &library)
{
	size_t i;

	/* list of modules that we drop */
	static const char *const irrelevant_modules[] =
	{
		"coco_os9_rsdos"
	};

	library.reset(new imgtool::library());
	if (!library)
		return IMGTOOLERR_OUTOFMEMORY;

	// create all modules
	for (i = 0; i < ARRAY_LENGTH(modules); i++)
		library->add(modules[i]);

	// remove irrelevant modules
	for (i = 0; i < ARRAY_LENGTH(irrelevant_modules); i++)
	{
		library->unlink(irrelevant_modules[i]);
	}

	// if we are omitting untested, go through and block out the functionality in question
	if (omit_untested)
	{
		for (auto &module : library->modules())
		{
			if (module->writing_untested)
			{
				module->write_sector = nullptr;
			}
			if (module->creation_untested)
			{
				module->create = nullptr;
				module->createimage_optguide = nullptr;
				module->createimage_optspec = nullptr;
			}
		}
	}

	return IMGTOOLERR_SUCCESS;
}


#else /* MODULES_RECURSIVE */

MODULE(amiga_floppy)
MODULE(concept)
MODULE(mac_mfs)
MODULE(mac_hfs)
MODULE(hd)
MODULE(rsdos)
MODULE(vzdos)
MODULE(os9)
MODULE(ti99_old)
MODULE(ti99_v9t9)
MODULE(ti99_pc99fm)
MODULE(ti99_pc99mfm)
MODULE(ti99_ti99hd)
MODULE(ti990)
MODULE(pc_floppy)
MODULE(pc_chd)
MODULE(prodos_525)
MODULE(prodos_35)
MODULE(thom_fd_basic)
MODULE(thom_qd_basic)
MODULE(thom_sap_basic)
MODULE(cybiko)
MODULE(cybikoxt)
MODULE(psion)
MODULE(bml3)
MODULE(hp48)
MODULE(hp9845_tape)
MODULE(hp85_tape)
MODULE(rt11)

#endif /* MODULES_RECURSIVE */