ソースを参照

Use standard xfer_open() argument list for downloader instantiator

tags/v0.9.3
Michael Brown 17年前
コミット
7c8cc3ef6c
2個のファイルの変更14行の追加9行の削除
  1. 11
    6
      src/core/downloader.c
  2. 3
    3
      src/include/gpxe/downloader.h

+ 11
- 6
src/core/downloader.c ファイルの表示

@@ -17,6 +17,7 @@
17 17
  */
18 18
 
19 19
 #include <stdlib.h>
20
+#include <stdarg.h>
20 21
 #include <errno.h>
21 22
 #include <gpxe/xfer.h>
22 23
 #include <gpxe/open.h>
@@ -243,19 +244,21 @@ static struct xfer_interface_operations downloader_xfer_operations = {
243 244
  * Instantiate a downloader
244 245
  *
245 246
  * @v job		Job control interface
246
- * @v uri_string	URI string
247 247
  * @v image		Image to fill with downloaded file
248 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 251
  * @ret rc		Return status code
250 252
  *
251 253
  * Instantiates a downloader object to download the specified URI into
252 254
  * the specified image object.  If the download is successful, the
253 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 260
 	struct downloader *downloader;
261
+	va_list args;
259 262
 	int rc;
260 263
 
261 264
 	/* Allocate and initialise structure */
@@ -270,19 +273,21 @@ int create_downloader ( struct job_interface *job, const char *uri_string,
270 273
 		    &downloader->refcnt );
271 274
 	downloader->image = image_get ( image );
272 275
 	downloader->register_image = register_image;
276
+	va_start ( args, type );
273 277
 
274 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 280
 		goto err;
278 281
 
279 282
 	/* Attach parent interface, mortalise self, and return */
280 283
 	job_plug_plug ( &downloader->job, job );
281 284
 	ref_put ( &downloader->refcnt );
285
+	va_end ( args );
282 286
 	return 0;
283 287
 
284 288
  err:
285 289
 	downloader_finished ( downloader, rc );
286 290
 	ref_put ( &downloader->refcnt );
291
+	va_end ( args );
287 292
 	return rc;
288 293
 }

+ 3
- 3
src/include/gpxe/downloader.h ファイルの表示

@@ -10,8 +10,8 @@
10 10
 struct job_interface;
11 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 17
 #endif /* _GPXE_DOWNLOADER_H */

読み込み中…
キャンセル
保存