summaryrefslogtreecommitdiffstats
path: root/src/core/open.c
diff options
context:
space:
mode:
authorMichael Brown2007-06-09 19:20:08 +0200
committerMichael Brown2007-06-09 19:20:08 +0200
commit2c569fb240513b229384bf425f4708888b7880cf (patch)
treec5ad810525a1f89b79b3615183f2768cd52d1b11 /src/core/open.c
parentAdd our own trivial version of stdarg.h. This makes our build (diff)
downloadipxe-2c569fb240513b229384bf425f4708888b7880cf.tar.gz
ipxe-2c569fb240513b229384bf425f4708888b7880cf.tar.xz
ipxe-2c569fb240513b229384bf425f4708888b7880cf.zip
Allow xfer_open() to take a struct uri as well as a URI string.
Diffstat (limited to 'src/core/open.c')
-rw-r--r--src/core/open.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/src/core/open.c b/src/core/open.c
index 6c184e65..ea485347 100644
--- a/src/core/open.c
+++ b/src/core/open.c
@@ -46,13 +46,33 @@ static struct socket_opener socket_openers_end[0]
* Open URI
*
* @v xfer Data transfer interface
+ * @v uri URI
+ * @ret rc Return status code
+ */
+int xfer_open_uri ( struct xfer_interface *xfer, struct uri *uri ) {
+ struct uri_opener *opener;
+
+ for ( opener = uri_openers ; opener < uri_openers_end ; opener++ ) {
+ if ( strcmp ( uri->scheme, opener->scheme ) == 0 )
+ return opener->open ( xfer, uri );
+ }
+
+ DBGC ( xfer, "XFER %p attempted to open unsupported URI scheme "
+ "\"%s\"\n", xfer, uri->scheme );
+ return -ENOTSUP;
+}
+
+/**
+ * Open URI string
+ *
+ * @v xfer Data transfer interface
* @v uri_string URI string (e.g. "http://etherboot.org/kernel")
* @ret rc Return status code
*/
-int xfer_open_uri ( struct xfer_interface *xfer, const char *uri_string ) {
+int xfer_open_uri_string ( struct xfer_interface *xfer,
+ const char *uri_string ) {
struct uri *uri;
- struct uri_opener *opener;
- int rc = -ENOTSUP;
+ int rc;
DBGC ( xfer, "XFER %p opening URI %s\n", xfer, uri_string );
@@ -60,16 +80,8 @@ int xfer_open_uri ( struct xfer_interface *xfer, const char *uri_string ) {
if ( ! uri )
return -ENOMEM;
- for ( opener = uri_openers ; opener < uri_openers_end ; opener++ ) {
- if ( strcmp ( uri->scheme, opener->scheme ) == 0 ) {
- rc = opener->open ( xfer, uri );
- goto done;
- }
- }
+ rc = xfer_open_uri ( xfer, uri );
- DBGC ( xfer, "XFER %p attempted to open unsupported URI scheme "
- "\"%s\"\n", xfer, uri->scheme );
- done:
uri_put ( uri );
return rc;
}
@@ -114,10 +126,12 @@ int xfer_open_socket ( struct xfer_interface *xfer, int semantics,
*/
int xfer_vopen ( struct xfer_interface *xfer, int type, va_list args ) {
switch ( type ) {
- case LOCATION_URI: {
+ case LOCATION_URI_STRING: {
const char *uri_string = va_arg ( args, const char * );
- return xfer_open_uri ( xfer, uri_string ); }
+ return xfer_open_uri_string ( xfer, uri_string ); }
+ case LOCATION_URI:
+
case LOCATION_SOCKET: {
int semantics = va_arg ( args, int );
struct sockaddr *peer = va_arg ( args, struct sockaddr * );