summaryrefslogtreecommitdiffstats
path: root/src/core/downloader.c
diff options
context:
space:
mode:
authorMichael Brown2007-05-15 17:23:09 +0200
committerMichael Brown2007-05-15 17:23:09 +0200
commit5471bfbbbe9f49f7be7f2ca92b8c99a02c435458 (patch)
treeb2dcb5f373672a767336ddba8d7e25fcc3f0c554 /src/core/downloader.c
parentAdd always_inline attribute to force gcc to inline single-instruction (diff)
downloadipxe-5471bfbbbe9f49f7be7f2ca92b8c99a02c435458.tar.gz
ipxe-5471bfbbbe9f49f7be7f2ca92b8c99a02c435458.tar.xz
ipxe-5471bfbbbe9f49f7be7f2ca92b8c99a02c435458.zip
Data-transfer interface should now be functionally complete.
Diffstat (limited to 'src/core/downloader.c')
-rw-r--r--src/core/downloader.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/core/downloader.c b/src/core/downloader.c
index f539bb68..2e466cbf 100644
--- a/src/core/downloader.c
+++ b/src/core/downloader.c
@@ -115,7 +115,7 @@ static void downloader_job_start ( struct job_interface *job ) {
container_of ( job, struct downloader, job );
/* Start data transfer */
- xfer_start ( &downloader->xfer );
+ xfer_request_all ( &downloader->xfer );
}
/**
@@ -152,17 +152,30 @@ static struct job_interface_operations downloader_job_operations = {
* @v pos New position
* @ret rc Return status code
*/
-static int downloader_xfer_seek ( struct xfer_interface *xfer, size_t pos ) {
+static int downloader_xfer_seek ( struct xfer_interface *xfer, off_t offset,
+ int whence ) {
struct downloader *downloader =
container_of ( xfer, struct downloader, xfer );
+ off_t new_pos;
int rc;
+ /* Calculate new buffer position */
+ switch ( whence ) {
+ case SEEK_SET:
+ new_pos = offset;
+ break;
+ case SEEK_CUR:
+ new_pos = ( downloader->pos + offset );
+ break;
+ default:
+ assert ( 0 );
+ return -EINVAL;
+ }
+
/* Ensure that we have enough buffer space for this buffer position */
- if ( ( rc = downloader_ensure_size ( downloader, pos ) ) != 0 )
+ if ( ( rc = downloader_ensure_size ( downloader, new_pos ) ) != 0 )
return rc;
-
- /* Update current buffer position */
- downloader->pos = pos;
+ downloader->pos = new_pos;
return 0;
}
@@ -216,11 +229,11 @@ static void downloader_xfer_close ( struct xfer_interface *xfer, int rc ) {
/** Downloader data transfer interface operations */
static struct xfer_interface_operations downloader_xfer_operations = {
- .start = ignore_xfer_start,
.close = downloader_xfer_close,
- .vredirect = default_xfer_vredirect,
+ .vredirect = vopen,
+ .request = ignore_xfer_request,
.seek = downloader_xfer_seek,
- .deliver = xfer_deliver_as_raw,
+ .deliver_iob = xfer_deliver_as_raw,
.deliver_raw = downloader_xfer_deliver_raw,
};