downloader.h File Reference

Image downloader. More...

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
int create_downloader (struct job_interface *job, struct image *image, int(*register_image)(struct image *image), int type,...)
 Instantiate a downloader.


Detailed Description

Image downloader.

Definition in file downloader.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

int create_downloader ( struct job_interface job,
struct image image,
int(*)(struct image *image register_image,
int  type,
  ... 
)

Instantiate a downloader.

Parameters:
job Job control interface
image Image to fill with downloaded file
register_image Image registration routine
type Location type to pass to xfer_open()
... Remaining arguments to pass to xfer_open()
Return values:
rc Return status code
Instantiates a downloader object to download the specified URI into the specified image object. If the download is successful, the image registration routine register_image() will be called.

Definition at line 256 of file downloader.c.

References downloader_finished(), downloader_free(), ENOMEM, refcnt::free, downloader::image, image_get(), downloader::job, job_init(), job_plug_plug(), ref_put(), downloader::refcnt, register_image(), downloader::register_image, va_end, va_start, downloader::xfer, xfer_init(), xfer_vopen(), and zalloc().

Referenced by imgfetch().

00258                                         {
00259         struct downloader *downloader;
00260         va_list args;
00261         int rc;
00262 
00263         /* Allocate and initialise structure */
00264         downloader = zalloc ( sizeof ( *downloader ) );
00265         if ( ! downloader )
00266                 return -ENOMEM;
00267         downloader->refcnt.free = downloader_free;
00268         job_init ( &downloader->job, &downloader_job_operations,
00269                    &downloader->refcnt );
00270         xfer_init ( &downloader->xfer, &downloader_xfer_operations,
00271                     &downloader->refcnt );
00272         downloader->image = image_get ( image );
00273         downloader->register_image = register_image;
00274         va_start ( args, type );
00275 
00276         /* Instantiate child objects and attach to our interfaces */
00277         if ( ( rc = xfer_vopen ( &downloader->xfer, type, args ) ) != 0 )
00278                 goto err;
00279 
00280         /* Attach parent interface, mortalise self, and return */
00281         job_plug_plug ( &downloader->job, job );
00282         ref_put ( &downloader->refcnt );
00283         va_end ( args );
00284         return 0;
00285 
00286  err:
00287         downloader_finished ( downloader, rc );
00288         ref_put ( &downloader->refcnt );
00289         va_end ( args );
00290         return rc;
00291 }


Generated on Tue Apr 6 20:01:48 2010 for gPXE by  doxygen 1.5.7.1