5 #include <gpxe/refcnt.h>
11 * "Hello World" data source
17 struct xfer_interface xfer;
20 static const char hw_msg[] = "Hello world!\n";
22 static void hw_finished ( struct hw *hw, int rc ) {
23 xfer_nullify ( &hw->xfer );
24 xfer_close ( &hw->xfer, rc );
27 static void hw_xfer_close ( struct xfer_interface *xfer, int rc ) {
28 struct hw *hw = container_of ( xfer, struct hw, xfer );
30 hw_finished ( hw, rc );
33 static void hw_xfer_request ( struct xfer_interface *xfer,
34 off_t start __unused, int whence __unused,
35 size_t len __unused ) {
36 struct hw *hw = container_of ( xfer, struct hw, xfer );
39 rc = xfer_deliver_raw ( xfer, hw_msg, sizeof ( hw_msg ) );
40 hw_finished ( hw, rc );
43 static struct xfer_interface_operations hw_xfer_operations = {
44 .close = hw_xfer_close,
45 .vredirect = ignore_xfer_vredirect,
46 .request = hw_xfer_request,
47 .seek = ignore_xfer_seek,
48 .deliver_iob = xfer_deliver_as_raw,
49 .deliver_raw = ignore_xfer_deliver_raw,
52 static int hw_open ( struct xfer_interface *xfer, struct uri *uri __unused ) {
55 /* Allocate and initialise structure */
56 hw = malloc ( sizeof ( *hw ) );
59 memset ( hw, 0, sizeof ( *hw ) );
60 xfer_init ( &hw->xfer, &hw_xfer_operations, &hw->refcnt );
62 /* Attach parent interface, mortalise self, and return */
63 xfer_plug_plug ( &hw->xfer, xfer );
64 ref_put ( &hw->refcnt );
68 struct uri_opener hw_uri_opener __uri_opener = {