Browse Source

Treat URIs opened via xfer_open() and friends as relative to the

current working URI.
tags/v0.9.3
Michael Brown 17 years ago
parent
commit
4f309ff0c7
1 changed files with 23 additions and 5 deletions
  1. 23
    5
      src/core/open.c

+ 23
- 5
src/core/open.c View File

48
  * @v xfer		Data transfer interface
48
  * @v xfer		Data transfer interface
49
  * @v uri		URI
49
  * @v uri		URI
50
  * @ret rc		Return status code
50
  * @ret rc		Return status code
51
+ *
52
+ * The URI will be regarded as being relative to the current working
53
+ * URI (see churi()).
51
  */
54
  */
52
 int xfer_open_uri ( struct xfer_interface *xfer, struct uri *uri ) {
55
 int xfer_open_uri ( struct xfer_interface *xfer, struct uri *uri ) {
53
 	struct uri_opener *opener;
56
 	struct uri_opener *opener;
57
+	struct uri *resolved_uri;
58
+	int rc = -ENOTSUP;
59
+
60
+	/* Resolve URI */
61
+	resolved_uri = resolve_uri ( cwuri, uri );
62
+	if ( ! resolved_uri )
63
+		return -ENOMEM;
54
 
64
 
65
+	/* Find opener which supports this URI scheme */
55
 	for ( opener = uri_openers ; opener < uri_openers_end ; opener++ ) {
66
 	for ( opener = uri_openers ; opener < uri_openers_end ; opener++ ) {
56
-		if ( strcmp ( uri->scheme, opener->scheme ) == 0 )
57
-			return opener->open ( xfer, uri );
67
+		if ( strcmp ( resolved_uri->scheme, opener->scheme ) == 0 ) {
68
+			rc = opener->open ( xfer, resolved_uri );
69
+			goto done;
70
+		}
58
 	}
71
 	}
59
-
60
 	DBGC ( xfer, "XFER %p attempted to open unsupported URI scheme "
72
 	DBGC ( xfer, "XFER %p attempted to open unsupported URI scheme "
61
-	       "\"%s\"\n", xfer, uri->scheme );
62
-	return -ENOTSUP;
73
+	       "\"%s\"\n", xfer, resolved_uri->scheme );
74
+
75
+ done:
76
+	uri_put ( resolved_uri );
77
+	return rc;
63
 }
78
 }
64
 
79
 
65
 /**
80
 /**
68
  * @v xfer		Data transfer interface
83
  * @v xfer		Data transfer interface
69
  * @v uri_string	URI string (e.g. "http://etherboot.org/kernel")
84
  * @v uri_string	URI string (e.g. "http://etherboot.org/kernel")
70
  * @ret rc		Return status code
85
  * @ret rc		Return status code
86
+ *
87
+ * The URI will be regarded as being relative to the current working
88
+ * URI (see churi()).
71
  */
89
  */
72
 int xfer_open_uri_string ( struct xfer_interface *xfer,
90
 int xfer_open_uri_string ( struct xfer_interface *xfer,
73
 			   const char *uri_string ) {
91
 			   const char *uri_string ) {

Loading…
Cancel
Save