+ /* add input struct entry at the end of link list */
+ *tp = tparams;
+ /* mark input entry as last entry in the link list */
+ tparams->next = NULL;
+
+ debug ("Registered %s\n", tparams->name);
+}
+
+/*
+ * mkimage_get_type -
+ *
+ * It scans all registers image type supports
+ * checks the input type_id for each supported image type
+ *
+ * if successful,
+ * returns respective image_type_params pointer if success
+ * if input type_id is not supported by any of image_type_support
+ * returns NULL
+ */
+struct image_type_params *mkimage_get_type(int type)
+{
+ struct image_type_params *curr;
+
+ for (curr = mkimage_tparams; curr != NULL; curr = curr->next) {
+ if (curr->check_image_type) {
+ if (!curr->check_image_type (type))
+ return curr;
+ }
+ }
+ return NULL;
+}
+
+/*
+ * mkimage_verify_print_header -
+ *
+ * It scans mkimage_tparams link list,
+ * verifies image_header for each supported image type
+ * if verification is successful, prints respective header
+ *
+ * returns negative if input image format does not match with any of
+ * supported image types
+ */
+int mkimage_verify_print_header (void *ptr, struct stat *sbuf)
+{
+ int retval = -1;
+ struct image_type_params *curr;
+
+ for (curr = mkimage_tparams; curr != NULL; curr = curr->next ) {
+ if (curr->verify_header) {
+ retval = curr->verify_header (
+ (unsigned char *)ptr, sbuf->st_size,
+ ¶ms);
+
+ if (retval == 0) {
+ /*
+ * Print the image information
+ * if verify is successful
+ */
+ if (curr->print_header)
+ curr->print_header (ptr);
+ else {
+ fprintf (stderr,
+ "%s: print_header undefined for %s\n",
+ params.cmdname, curr->name);
+ }
+ break;
+ }
+ }
+ }
+ return retval;
+}