summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools/imgtool/filter.cpp
blob: 9df7c3c1692da7949abdbb59f94078cb69ada1e8 (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
// license:BSD-3-Clause
// copyright-holders:Nathan Woods
/***************************************************************************

    filter.c

    Imgtool filters

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

#include "filter.h"

#include <cstring>

/* ----------------------------------------------------------------------- */

int64_t filter_get_info_int(imgtool::filter_getinfoproc get_info, uint32_t state)
{
	imgtool::filterinfo info;
	info.i = 0;
	get_info(state, &info);
	return info.i;
}

void *filter_get_info_ptr(imgtool::filter_getinfoproc get_info, uint32_t state)
{
	imgtool::filterinfo info;
	info.p = nullptr;
	get_info(state, &info);
	return info.p;
}

void *filter_get_info_fct(imgtool::filter_getinfoproc get_info, uint32_t state)
{
	imgtool::filterinfo info;
	info.f = nullptr;
	get_info(state, &info);
	return info.f;
}

const char *filter_get_info_string(imgtool::filter_getinfoproc get_info, uint32_t state)
{
	imgtool::filterinfo info;
	info.s = nullptr;
	get_info(state, &info);
	return info.s;
}

/* ----------------------------------------------------------------------- */

const imgtool::filter_getinfoproc filters[] =
{
	filter_eoln_getinfo,
	filter_cocobas_getinfo,
	filter_dragonbas_getinfo,
	filter_vzsnapshot_getinfo,
	filter_vzbas_getinfo,
	filter_thombas5_getinfo,
	filter_thombas7_getinfo,
	filter_thombas128_getinfo,
	filter_thomcrypt_getinfo,
	filter_bml3bas_getinfo,
		filter_hp9845data_getinfo,
	nullptr
};



imgtool::filter_getinfoproc filter_lookup(const char *name)
{
	for (int i = 0; filters[i]; i++)
	{
		char const *const filter_name = filter_get_info_string(filters[i], FILTINFO_STR_NAME);
		if (!strcmp(name, filter_name))
			return filters[i];
	}

	return nullptr;
}