/* returns negative if input image format does not match with any of supported image types  */
static int dumpimage_extract_subimage(struct image_type_params *tparams, void *ptr, struct stat *sbuf)
/* returns negative if input image format does not match with any of supported image types  */
static int dumpimage_extract_subimage(struct image_type_params *tparams, void *ptr, struct stat *sbuf)
{
	int retval = -1;
	if (tparams->verify_header) {
		retval = tparams->verify_header((unsigned char *)ptr,
				sbuf->st_size, &params);
		if (retval != 0)
			return -1;
		if (tparams->extract_subimage) {
			retval = tparams->extract_subimage(ptr, &params);
		} else {
			fprintf(stderr,
				"%s: extract_subimage undefined for %s\n",
				params.cmdname, tparams->name);
			return -2;
		}
	}
	return retval;
}