Bladeren bron

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

current working URI.
tags/v0.9.3
Michael Brown 17 jaren geleden
bovenliggende
commit
4f309ff0c7
1 gewijzigde bestanden met toevoegingen van 23 en 5 verwijderingen
  1. 23
    5
      src/core/open.c

+ 23
- 5
src/core/open.c Bestand weergeven

@@ -48,18 +48,33 @@ static struct socket_opener socket_openers_end[0]
48 48
  * @v xfer		Data transfer interface
49 49
  * @v uri		URI
50 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 55
 int xfer_open_uri ( struct xfer_interface *xfer, struct uri *uri ) {
53 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 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 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,6 +83,9 @@ int xfer_open_uri ( struct xfer_interface *xfer, struct uri *uri ) {
68 83
  * @v xfer		Data transfer interface
69 84
  * @v uri_string	URI string (e.g. "http://etherboot.org/kernel")
70 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 90
 int xfer_open_uri_string ( struct xfer_interface *xfer,
73 91
 			   const char *uri_string ) {

Laden…
Annuleren
Opslaan