diff options
author | Michael Brown | 2007-01-18 04:28:55 +0100 |
---|---|---|
committer | Michael Brown | 2007-01-18 04:28:55 +0100 |
commit | 5a807994d84bd494bae38f48d6b71d3cdae22aff (patch) | |
tree | 57f2e2bc497bd763f5ccedb99bd00b669260c7a4 /src/core/uri.c | |
parent | Ensure that struct sockaddr is long enough... (diff) | |
download | ipxe-5a807994d84bd494bae38f48d6b71d3cdae22aff.tar.gz ipxe-5a807994d84bd494bae38f48d6b71d3cdae22aff.tar.xz ipxe-5a807994d84bd494bae38f48d6b71d3cdae22aff.zip |
Add utility function to parse port from URI
Diffstat (limited to 'src/core/uri.c')
-rw-r--r-- | src/core/uri.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/uri.c b/src/core/uri.c index 42367170..cb1ac3bc 100644 --- a/src/core/uri.c +++ b/src/core/uri.c @@ -159,3 +159,14 @@ struct uri * parse_uri ( const char *uri_string ) { return uri; } + +/** + * Get port from URI + * + * @v uri URI + * @v default_port Default port to use if none specified in URI + * @ret port Port + */ +unsigned int uri_port ( struct uri *uri, unsigned int default_port ) { + return ( uri->port ? strtoul ( uri->port, NULL, 0 ) : default_port ); +} |