2
0
mirror of https://github.com/xcat2/xNBA.git synced 2024-12-14 07:11:32 +00:00

Add utility function to parse port from URI

This commit is contained in:
Michael Brown 2007-01-18 03:28:55 +00:00
parent 8ffbbebf11
commit 5a807994d8
2 changed files with 12 additions and 0 deletions

View File

@ -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 );
}

View File

@ -112,5 +112,6 @@ static inline void free_uri ( struct uri *uri ) {
}
extern struct uri * parse_uri ( const char *uri_string );
unsigned int uri_port ( struct uri *uri, unsigned int default_port );
#endif /* _GPXE_URI_H */