|
@@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
31
|
31
|
#include <libgen.h>
|
32
|
32
|
#include <ctype.h>
|
33
|
33
|
#include <ipxe/vsprintf.h>
|
|
34
|
+#include <ipxe/params.h>
|
34
|
35
|
#include <ipxe/uri.h>
|
35
|
36
|
|
36
|
37
|
/**
|
|
@@ -59,6 +60,21 @@ static void dump_uri ( struct uri *uri ) {
|
59
|
60
|
DBG ( " query \"%s\"", uri->query );
|
60
|
61
|
if ( uri->fragment )
|
61
|
62
|
DBG ( " fragment \"%s\"", uri->fragment );
|
|
63
|
+ if ( uri->params )
|
|
64
|
+ DBG ( " params \"%s\"", uri->params->name );
|
|
65
|
+}
|
|
66
|
+
|
|
67
|
+/**
|
|
68
|
+ * Free URI
|
|
69
|
+ *
|
|
70
|
+ * @v refcnt Reference count
|
|
71
|
+ */
|
|
72
|
+static void free_uri ( struct refcnt *refcnt ) {
|
|
73
|
+ struct uri *uri = container_of ( refcnt, struct uri, refcnt );
|
|
74
|
+
|
|
75
|
+ if ( uri->params )
|
|
76
|
+ destroy_parameters ( uri->params );
|
|
77
|
+ free ( uri );
|
62
|
78
|
}
|
63
|
79
|
|
64
|
80
|
/**
|
|
@@ -85,12 +101,25 @@ struct uri * parse_uri ( const char *uri_string ) {
|
85
|
101
|
uri = zalloc ( sizeof ( *uri ) + raw_len );
|
86
|
102
|
if ( ! uri )
|
87
|
103
|
return NULL;
|
|
104
|
+ ref_init ( &uri->refcnt, free_uri );
|
88
|
105
|
raw = ( ( ( char * ) uri ) + sizeof ( *uri ) );
|
89
|
106
|
|
90
|
107
|
/* Copy in the raw string */
|
91
|
108
|
memcpy ( raw, uri_string, raw_len );
|
92
|
109
|
|
93
|
|
- /* Start by chopping off the fragment, if it exists */
|
|
110
|
+ /* Identify the parameter list, if present */
|
|
111
|
+ if ( ( tmp = strstr ( raw, "##params" ) ) ) {
|
|
112
|
+ *tmp = '\0';
|
|
113
|
+ tmp += 8 /* "##params" */;
|
|
114
|
+ uri->params = find_parameters ( *tmp ? ( tmp + 1 ) : NULL );
|
|
115
|
+ if ( uri->params ) {
|
|
116
|
+ claim_parameters ( uri->params );
|
|
117
|
+ } else {
|
|
118
|
+ /* Ignore non-existent submission blocks */
|
|
119
|
+ }
|
|
120
|
+ }
|
|
121
|
+
|
|
122
|
+ /* Chop off the fragment, if it exists */
|
94
|
123
|
if ( ( tmp = strchr ( raw, '#' ) ) ) {
|
95
|
124
|
*(tmp++) = '\0';
|
96
|
125
|
uri->fragment = tmp;
|