4 * Written by Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
6 * SPDX-License-Identifier: GPL-2.0+
13 struct image_type_params *imagetool_get_type(int type)
15 struct image_type_params **curr;
16 INIT_SECTION(image_type);
18 struct image_type_params **start = __start_image_type;
19 struct image_type_params **end = __stop_image_type;
21 for (curr = start; curr != end; curr++) {
22 if ((*curr)->check_image_type) {
23 if (!(*curr)->check_image_type(type))
30 int imagetool_verify_print_header(
33 struct image_type_params *tparams,
34 struct image_tool_params *params)
37 struct image_type_params **curr;
38 INIT_SECTION(image_type);
40 struct image_type_params **start = __start_image_type;
41 struct image_type_params **end = __stop_image_type;
43 for (curr = start; curr != end; curr++) {
44 if ((*curr)->verify_header) {
45 retval = (*curr)->verify_header((unsigned char *)ptr,
46 sbuf->st_size, params);
50 * Print the image information if verify is
53 if ((*curr)->print_header) {
54 (*curr)->print_header(ptr);
57 "%s: print_header undefined for %s\n",
58 params->cmdname, (*curr)->name);
68 int imagetool_save_subimage(
69 const char *file_name,
75 dfd = open(file_name, O_RDWR | O_CREAT | O_TRUNC | O_BINARY,
78 fprintf(stderr, "Can't open \"%s\": %s\n",
79 file_name, strerror(errno));
83 if (write(dfd, (void *)file_data, file_len) != (ssize_t)file_len) {
84 fprintf(stderr, "Write error on \"%s\": %s\n",
85 file_name, strerror(errno));