From 0b11733b75f3edccc4a5e28718c6bf72fd28a063 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 18 Jan 2007 03:37:05 +0000 Subject: Replacement for fetch() which operates asynchronously and identifies protocols by URI scheme. --- src/include/gpxe/download.h | 59 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/include/gpxe/download.h (limited to 'src/include') diff --git a/src/include/gpxe/download.h b/src/include/gpxe/download.h new file mode 100644 index 000000000..cb58b7adc --- /dev/null +++ b/src/include/gpxe/download.h @@ -0,0 +1,59 @@ +#ifndef _GPXE_DOWNLOAD_H +#define _GPXE_DOWNLOAD_H + +/** @file + * + * Download protocols + * + */ + +#include +#include +#include +#include +#include +#include + +/** A download protocol */ +struct download_protocol { + /** Protocol name (e.g. "http") */ + const char *name; + /** Start a download via this protocol + * + * @v uri Uniform Resource Identifier + * @v buffer Buffer into which to download file + * @v parent Parent asynchronous operation + * @ret rc Return status code + * + * The @c uri and @c buffer will remain persistent for the + * duration of the asynchronous operation. + */ + int ( * start_download ) ( struct uri *uri, struct buffer *buffer, + struct async *parent ); +}; + +/** Register a download protocol */ +#define __download_protocol __table ( struct download_protocol, \ + download_protocols, 01 ) + +/** A download in progress */ +struct download { + /** User buffer allocated for the download */ + userptr_t *data; + /** Size of the download */ + size_t *len; + + /** URI being downloaded */ + struct uri *uri; + /** Expandable buffer for this download */ + struct buffer buffer; + /** Download protocol */ + struct download_protocol *protocol; + /** Asynchronous operation for this download */ + struct async async; +}; + +extern int start_download ( const char *uri_string, struct async *parent, + userptr_t *data, size_t *len ); + +#endif /* _GPXE_DOWNLOAD_H */ -- cgit v1.2.3-55-g7522