1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 06:23:53 +01:00

sys/net/sock_util: add sock_urlpath()

This commit is contained in:
Benjamin Valentin 2022-04-18 01:31:15 +02:00 committed by Benjamin Valentin
parent 0e5900d597
commit f6be7d6ffe
2 changed files with 21 additions and 0 deletions

View File

@ -102,6 +102,16 @@ static inline int sock_udp_ep_fmt(const sock_udp_ep_t *endpoint,
*/
int sock_urlsplit(const char *url, char *hostport, char *urlpath);
/**
* @brief Returns a pointer to the path component in @p url
*
* @param[in] url URL to examine. Must not be NULL.
*
* @returns pointer to the start of the path component in @p url
* @returns NULL if @p url is invalid
*/
const char *sock_urlpath(const char *url);
/**
* @brief Convert string to common IP-based transport layer endpoint
*

View File

@ -149,6 +149,17 @@ int sock_urlsplit(const char *url, char *hostport, char *urlpath)
return 0;
}
const char *sock_urlpath(const char *url)
{
assert(url);
char *hoststart = _find_hoststart(url);
if (!hoststart) {
return NULL;
}
return _find_pathstart(hoststart);
}
int _parse_port(sock_udp_ep_t *ep_out, const char *portstart)
{
int port_len = strlen(portstart);