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:
parent
8ffbbebf11
commit
5a807994d8
@ -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 );
|
||||
}
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user