You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

download.h 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef _GPXE_DOWNLOAD_H
  2. #define _GPXE_DOWNLOAD_H
  3. /** @file
  4. *
  5. * Download protocols
  6. *
  7. */
  8. #include <stdint.h>
  9. #include <gpxe/uaccess.h>
  10. #include <gpxe/async.h>
  11. #include <gpxe/buffer.h>
  12. #include <gpxe/uri.h>
  13. #include <gpxe/tables.h>
  14. /** A download protocol */
  15. struct download_protocol {
  16. /** Protocol name (e.g. "http") */
  17. const char *name;
  18. /** Start a download via this protocol
  19. *
  20. * @v uri Uniform Resource Identifier
  21. * @v buffer Buffer into which to download file
  22. * @v parent Parent asynchronous operation
  23. * @ret rc Return status code
  24. *
  25. * The @c uri and @c buffer will remain persistent for the
  26. * duration of the asynchronous operation.
  27. */
  28. int ( * start_download ) ( struct uri *uri, struct buffer *buffer,
  29. struct async *parent );
  30. };
  31. /** Register a download protocol */
  32. #define __download_protocol __table ( struct download_protocol, \
  33. download_protocols, 01 )
  34. /** A download in progress */
  35. struct download {
  36. /** User buffer allocated for the download */
  37. userptr_t *data;
  38. /** Size of the download */
  39. size_t *len;
  40. /** URI being downloaded */
  41. struct uri *uri;
  42. /** Expandable buffer for this download */
  43. struct buffer buffer;
  44. /** Download protocol */
  45. struct download_protocol *protocol;
  46. /** Asynchronous operation for this download */
  47. struct async async;
  48. };
  49. extern int start_download ( const char *uri_string, struct async *parent,
  50. userptr_t *data, size_t *len );
  51. #endif /* _GPXE_DOWNLOAD_H */