Bladeren bron

Use standard xfer_open() argument list for downloader instantiator

tags/v0.9.3
Michael Brown 18 jaren geleden
bovenliggende
commit
7c8cc3ef6c
2 gewijzigde bestanden met toevoegingen van 14 en 9 verwijderingen
  1. 11
    6
      src/core/downloader.c
  2. 3
    3
      src/include/gpxe/downloader.h

+ 11
- 6
src/core/downloader.c Bestand weergeven

17
  */
17
  */
18
 
18
 
19
 #include <stdlib.h>
19
 #include <stdlib.h>
20
+#include <stdarg.h>
20
 #include <errno.h>
21
 #include <errno.h>
21
 #include <gpxe/xfer.h>
22
 #include <gpxe/xfer.h>
22
 #include <gpxe/open.h>
23
 #include <gpxe/open.h>
243
  * Instantiate a downloader
244
  * Instantiate a downloader
244
  *
245
  *
245
  * @v job		Job control interface
246
  * @v job		Job control interface
246
- * @v uri_string	URI string
247
  * @v image		Image to fill with downloaded file
247
  * @v image		Image to fill with downloaded file
248
  * @v register_image	Image registration routine
248
  * @v register_image	Image registration routine
249
+ * @v type		Location type to pass to xfer_open()
250
+ * @v ...		Remaining arguments to pass to xfer_open()
249
  * @ret rc		Return status code
251
  * @ret rc		Return status code
250
  *
252
  *
251
  * Instantiates a downloader object to download the specified URI into
253
  * Instantiates a downloader object to download the specified URI into
252
  * the specified image object.  If the download is successful, the
254
  * the specified image object.  If the download is successful, the
253
  * image registration routine @c register_image() will be called.
255
  * image registration routine @c register_image() will be called.
254
  */
256
  */
255
-int create_downloader ( struct job_interface *job, const char *uri_string,
256
-			struct image *image,
257
-			int ( * register_image ) ( struct image *image ) ) {
257
+int create_downloader ( struct job_interface *job, struct image *image,
258
+			int ( * register_image ) ( struct image *image ),
259
+			int type, ... ) {
258
 	struct downloader *downloader;
260
 	struct downloader *downloader;
261
+	va_list args;
259
 	int rc;
262
 	int rc;
260
 
263
 
261
 	/* Allocate and initialise structure */
264
 	/* Allocate and initialise structure */
270
 		    &downloader->refcnt );
273
 		    &downloader->refcnt );
271
 	downloader->image = image_get ( image );
274
 	downloader->image = image_get ( image );
272
 	downloader->register_image = register_image;
275
 	downloader->register_image = register_image;
276
+	va_start ( args, type );
273
 
277
 
274
 	/* Instantiate child objects and attach to our interfaces */
278
 	/* Instantiate child objects and attach to our interfaces */
275
-	if ( ( rc = xfer_open ( &downloader->xfer, LOCATION_URI,
276
-				uri_string ) ) != 0 )
279
+	if ( ( rc = xfer_vopen ( &downloader->xfer, type, args ) ) != 0 )
277
 		goto err;
280
 		goto err;
278
 
281
 
279
 	/* Attach parent interface, mortalise self, and return */
282
 	/* Attach parent interface, mortalise self, and return */
280
 	job_plug_plug ( &downloader->job, job );
283
 	job_plug_plug ( &downloader->job, job );
281
 	ref_put ( &downloader->refcnt );
284
 	ref_put ( &downloader->refcnt );
285
+	va_end ( args );
282
 	return 0;
286
 	return 0;
283
 
287
 
284
  err:
288
  err:
285
 	downloader_finished ( downloader, rc );
289
 	downloader_finished ( downloader, rc );
286
 	ref_put ( &downloader->refcnt );
290
 	ref_put ( &downloader->refcnt );
291
+	va_end ( args );
287
 	return rc;
292
 	return rc;
288
 }
293
 }

+ 3
- 3
src/include/gpxe/downloader.h Bestand weergeven

10
 struct job_interface;
10
 struct job_interface;
11
 struct image;
11
 struct image;
12
 
12
 
13
-extern int create_downloader ( struct job_interface *job,
14
-			       const char *uri_string, struct image *image,
15
-			       int ( * register_image ) ( struct image * ) );
13
+extern int create_downloader ( struct job_interface *job, struct image *image,
14
+			       int ( * register_image ) ( struct image *image ),
15
+			       int type, ... );
16
 
16
 
17
 #endif /* _GPXE_DOWNLOADER_H */
17
 #endif /* _GPXE_DOWNLOADER_H */

Laden…
Annuleren
Opslaan