struct image *image;
/** Current position within image buffer */
size_t pos;
- /** Image registration routine */
- int ( * register_image ) ( struct image *image );
};
/**
*/
static void downloader_finished ( struct downloader *downloader, int rc ) {
- /* Register image if download was successful */
- if ( rc == 0 )
- rc = downloader->register_image ( downloader->image );
-
/* Shut down interfaces */
intf_shutdown ( &downloader->xfer, rc );
intf_shutdown ( &downloader->job, rc );
*
* @v job Job control interface
* @v image Image to fill with downloaded file
- * @v register_image Image registration routine
* @v type Location type to pass to xfer_open()
* @v ... Remaining arguments to pass to xfer_open()
* @ret rc Return status code
* image registration routine @c register_image() will be called.
*/
int create_downloader ( struct interface *job, struct image *image,
- int ( * register_image ) ( struct image *image ),
int type, ... ) {
struct downloader *downloader;
va_list args;
intf_init ( &downloader->xfer, &downloader_xfer_desc,
&downloader->refcnt );
downloader->image = image_get ( image );
- downloader->register_image = register_image;
va_start ( args, type );
/* Instantiate child objects and attach to our interfaces */
struct image;
extern int create_downloader ( struct interface *job, struct image *image,
- int ( * register_image ) ( struct image *image ),
int type, ... );
#endif /* _IPXE_DOWNLOADER_H */
struct image;
extern int imgdownload ( struct image *image, struct uri *uri,
- int ( * image_register ) ( struct image *image ) );
+ int ( * action ) ( struct image *image ) );
extern int imgfetch ( struct image *image, const char *uri_string,
- int ( * image_register ) ( struct image *image ) );
+ int ( * action ) ( struct image *image ) );
extern int imgload ( struct image *image );
extern int imgexec ( struct image *image );
extern struct image * imgautoselect ( void );
*
* @v image Image
* @v uri URI
- * @v image_register Action to take upon a successful download
+ * @v action Action to take upon a successful download
* @ret rc Return status code
*/
int imgdownload ( struct image *image, struct uri *uri,
- int ( * image_register ) ( struct image *image ) ) {
+ int ( * action ) ( struct image *image ) ) {
size_t len = ( unparse_uri ( NULL, 0, uri, URI_ALL ) + 1 );
char uri_string_redacted[len];
const char *password;
uri->password = password;
/* Create downloader */
- if ( ( rc = create_downloader ( &monojob, image, image_register,
- LOCATION_URI, uri ) ) != 0 )
+ if ( ( rc = create_downloader ( &monojob, image, LOCATION_URI,
+ uri ) ) != 0 )
return rc;
/* Wait for download to complete */
if ( ( rc = monojob_wait ( uri_string_redacted ) ) != 0 )
return rc;
+ /* Act upon downloaded image */
+ if ( ( rc = action ( image ) ) != 0 )
+ return rc;
+
return 0;
}
*
* @v image Image
* @v uri_string URI as a string (e.g. "http://www.nowhere.com/vmlinuz")
- * @v image_register Action to take upon a successful fetch
+ * @v action Action to take upon a successful download
* @ret rc Return status code
*/
int imgfetch ( struct image *image, const char *uri_string,
- int ( * image_register ) ( struct image *image ) ) {
+ int ( * action ) ( struct image *image ) ) {
struct uri *uri;
int rc;
if ( ! ( uri = parse_uri ( uri_string ) ) )
return -ENOMEM;
- rc = imgdownload ( image, uri, image_register );
+ rc = imgdownload ( image, uri, action );
uri_put ( uri );
return rc;