Browse Source

Add utility function to parse port from URI

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
5a807994d8
2 changed files with 12 additions and 0 deletions
  1. 11
    0
      src/core/uri.c
  2. 1
    0
      src/include/gpxe/uri.h

+ 11
- 0
src/core/uri.c View File

159
 
159
 
160
 	return uri;
160
 	return uri;
161
 }
161
 }
162
+
163
+/**
164
+ * Get port from URI
165
+ *
166
+ * @v uri		URI
167
+ * @v default_port	Default port to use if none specified in URI
168
+ * @ret port		Port
169
+ */
170
+unsigned int uri_port ( struct uri *uri, unsigned int default_port ) {
171
+	return ( uri->port ? strtoul ( uri->port, NULL, 0 ) : default_port );
172
+}

+ 1
- 0
src/include/gpxe/uri.h View File

112
 }
112
 }
113
 
113
 
114
 extern struct uri * parse_uri ( const char *uri_string );
114
 extern struct uri * parse_uri ( const char *uri_string );
115
+unsigned int uri_port ( struct uri *uri, unsigned int default_port );
115
 
116
 
116
 #endif /* _GPXE_URI_H */
117
 #endif /* _GPXE_URI_H */

Loading…
Cancel
Save