david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

Use standard xfer_open() argument list for downloader instantiator

This commit is contained in:
Michael Brown 2007-06-09 17:42:46 +01:00
parent 08e286714f
commit 7c8cc3ef6c
2 changed files with 14 additions and 9 deletions

View File

@ -17,6 +17,7 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h>
#include <errno.h> #include <errno.h>
#include <gpxe/xfer.h> #include <gpxe/xfer.h>
#include <gpxe/open.h> #include <gpxe/open.h>
@ -243,19 +244,21 @@ static struct xfer_interface_operations downloader_xfer_operations = {
* Instantiate a downloader * Instantiate a downloader
* *
* @v job Job control interface * @v job Job control interface
* @v uri_string URI string
* @v image Image to fill with downloaded file * @v image Image to fill with downloaded file
* @v register_image Image registration routine * @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 * @ret rc Return status code
* *
* Instantiates a downloader object to download the specified URI into * Instantiates a downloader object to download the specified URI into
* the specified image object. If the download is successful, the * the specified image object. If the download is successful, the
* image registration routine @c register_image() will be called. * image registration routine @c register_image() will be called.
*/ */
int create_downloader ( struct job_interface *job, const char *uri_string, int create_downloader ( struct job_interface *job, struct image *image,
struct image *image, int ( * register_image ) ( struct image *image ),
int ( * register_image ) ( struct image *image ) ) { int type, ... ) {
struct downloader *downloader; struct downloader *downloader;
va_list args;
int rc; int rc;
/* Allocate and initialise structure */ /* Allocate and initialise structure */
@ -270,19 +273,21 @@ int create_downloader ( struct job_interface *job, const char *uri_string,
&downloader->refcnt ); &downloader->refcnt );
downloader->image = image_get ( image ); downloader->image = image_get ( image );
downloader->register_image = register_image; downloader->register_image = register_image;
va_start ( args, type );
/* Instantiate child objects and attach to our interfaces */ /* Instantiate child objects and attach to our interfaces */
if ( ( rc = xfer_open ( &downloader->xfer, LOCATION_URI, if ( ( rc = xfer_vopen ( &downloader->xfer, type, args ) ) != 0 )
uri_string ) ) != 0 )
goto err; goto err;
/* Attach parent interface, mortalise self, and return */ /* Attach parent interface, mortalise self, and return */
job_plug_plug ( &downloader->job, job ); job_plug_plug ( &downloader->job, job );
ref_put ( &downloader->refcnt ); ref_put ( &downloader->refcnt );
va_end ( args );
return 0; return 0;
err: err:
downloader_finished ( downloader, rc ); downloader_finished ( downloader, rc );
ref_put ( &downloader->refcnt ); ref_put ( &downloader->refcnt );
va_end ( args );
return rc; return rc;
} }

View File

@ -10,8 +10,8 @@
struct job_interface; struct job_interface;
struct image; struct image;
extern int create_downloader ( struct job_interface *job, extern int create_downloader ( struct job_interface *job, struct image *image,
const char *uri_string, struct image *image, int ( * register_image ) ( struct image *image ),
int ( * register_image ) ( struct image * ) ); int type, ... );
#endif /* _GPXE_DOWNLOADER_H */ #endif /* _GPXE_DOWNLOADER_H */