Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
#include "asterisk.h"
#include "asterisk/astobj2.h"
#include "asterisk/strings.h"
#include "asterisk/uri.h"
Go to the source code of this file.
Data Structures | |
struct | ast_uri |
Stores parsed uri information. More... | |
Macros | |
#define | SET_VALUE(param, field, size) |
#define | SET_VALUES(value) |
Functions | |
struct ast_uri * | ast_uri_copy_replace (const struct ast_uri *uri, const char *scheme, const char *user_info, const char *host, const char *port, const char *path, const char *query) |
Copy the given uri replacing any value in the new uri with any given. More... | |
struct ast_uri * | ast_uri_create (const char *scheme, const char *user_info, const char *host, const char *port, const char *path, const char *query) |
Create a uri with the given parameters. More... | |
static struct ast_uri * | ast_uri_create_ (const char *scheme, unsigned int scheme_size, const char *user_info, unsigned int user_info_size, const char *host, unsigned int host_size, const char *port, unsigned int port_size, const char *path, unsigned int path_size, const char *query, unsigned int query_size) |
Construct a uri object with the given values. More... | |
const char * | ast_uri_host (const struct ast_uri *uri) |
Retrieve the uri host. More... | |
int | ast_uri_is_secure (const struct ast_uri *uri) |
Retrieve if the uri is of a secure type. More... | |
char * | ast_uri_make_host_with_port (const struct ast_uri *uri) |
Retrieve a string of the host and port. More... | |
struct ast_uri * | ast_uri_parse (const char *uri) |
Parse the given uri into a structure. More... | |
struct ast_uri * | ast_uri_parse_http (const char *uri) |
Parse the given http uri into a structure. More... | |
struct ast_uri * | ast_uri_parse_websocket (const char *uri) |
Parse the given websocket uri into a structure. More... | |
const char * | ast_uri_path (const struct ast_uri *uri) |
Retrieve the uri path. More... | |
const char * | ast_uri_port (const struct ast_uri *uri) |
Retrieve the uri port. More... | |
const char * | ast_uri_query (const struct ast_uri *uri) |
Retrieve the uri query parameters. More... | |
const char * | ast_uri_scheme (const struct ast_uri *uri) |
Retrieve the uri scheme. More... | |
const char * | ast_uri_user_info (const struct ast_uri *uri) |
Retrieve the uri user information. More... | |
static struct ast_uri * | uri_parse_and_default (const char *uri, const char *scheme, const char *port, const char *secure_port) |
#define SET_VALUE | ( | param, | |
field, | |||
size | |||
) |
#define SET_VALUES | ( | value | ) |
struct ast_uri * ast_uri_copy_replace | ( | const struct ast_uri * | uri, |
const char * | scheme, | ||
const char * | user_info, | ||
const char * | host, | ||
const char * | port, | ||
const char * | path, | ||
const char * | query | ||
) |
Copy the given uri replacing any value in the new uri with any given.
uri | the uri object to copy |
scheme | the uri scheme (ex: http) |
user_info | user credentials (ex: <name>@<pass>) |
host | host name or ip address |
port | the port |
path | the path |
query | query parameters |
NULL | on error |
Definition at line 101 of file uri.c.
References ast_uri_create(), ast_uri::host, ast_uri::path, ast_uri::port, ast_uri::query, ast_uri::scheme, ast_uri::uri, and ast_uri::user_info.
Referenced by uri_parse_and_default().
struct ast_uri * ast_uri_create | ( | const char * | scheme, |
const char * | user_info, | ||
const char * | host, | ||
const char * | port, | ||
const char * | path, | ||
const char * | query | ||
) |
Create a uri with the given parameters.
scheme | the uri scheme (ex: http) |
user_info | user credentials (ex: <name>@<pass>) |
host | host name or ip address |
port | the port |
path | the path |
query | query parameters |
NULL | on error |
Definition at line 88 of file uri.c.
References ast_uri_create_(), ast_uri::host, ast_uri::path, ast_uri::port, ast_uri::query, ast_uri::scheme, and ast_uri::user_info.
Referenced by ast_uri_copy_replace().
|
static |
Construct a uri object with the given values.
Definition at line 54 of file uri.c.
References ao2_alloc, ast_log, ast_uri::host, LOG_ERROR, NULL, ast_uri::path, ast_uri::port, ast_uri::query, ast_uri::scheme, SET_VALUE, ast_uri::uri, and ast_uri::user_info.
Referenced by ast_uri_create(), and ast_uri_parse().
const char * ast_uri_host | ( | const struct ast_uri * | uri | ) |
Retrieve the uri host.
Definition at line 125 of file uri.c.
References ast_uri::uri.
Referenced by AST_TEST_DEFINE(), and ast_uri_make_host_with_port().
int ast_uri_is_secure | ( | const struct ast_uri * | uri | ) |
Retrieve if the uri is of a secure type.
True | if secure. |
False | otherwise. |
Definition at line 145 of file uri.c.
References ast_strlen_zero(), and ast_uri::uri.
Referenced by AST_TEST_DEFINE(), and uri_parse_and_default().
char * ast_uri_make_host_with_port | ( | const struct ast_uri * | uri | ) |
Retrieve a string of the host and port.
Combine the host and port (<host>:<port>) if the port is available, otherwise just return the host.
uri | the uri object |
Definition at line 300 of file uri.c.
References ast_asprintf, ast_uri_host(), ast_uri_port(), NULL, and ast_uri::uri.
Referenced by websocket_client_parse_uri().
struct ast_uri * ast_uri_parse | ( | const char * | uri | ) |
Parse the given uri into a structure.
<scheme>://[user:pass@]<host>[:port][/<path>]
uri | a string uri to parse |
NULL | on error |
Definition at line 195 of file uri.c.
References ast_uri_create_(), ast_uri::host, NULL, ast_uri::path, ast_uri::port, ast_uri::query, ast_uri::scheme, SET_VALUES, ast_uri::uri, and ast_uri::user_info.
Referenced by AST_TEST_DEFINE(), file_extension_from_url_path(), and uri_parse_and_default().
struct ast_uri * ast_uri_parse_http | ( | const char * | uri | ) |
Parse the given http uri into a structure.
[http[s]://][user:pass@]<host>[:port][/<path>]
uri | an http string uri to parse |
NULL | on error |
Definition at line 290 of file uri.c.
References ast_uri::uri, and uri_parse_and_default().
Referenced by AST_TEST_DEFINE().
struct ast_uri * ast_uri_parse_websocket | ( | const char * | uri | ) |
Parse the given websocket uri into a structure.
uri | a websocket string uri to parse |
NULL | on error |
Definition at line 295 of file uri.c.
References ast_uri::uri, and uri_parse_and_default().
Referenced by websocket_client_parse_uri().
const char * ast_uri_path | ( | const struct ast_uri * | uri | ) |
Retrieve the uri path.
Definition at line 135 of file uri.c.
References ast_uri::uri.
Referenced by AST_TEST_DEFINE(), file_extension_from_url_path(), and websocket_client_parse_uri().
const char * ast_uri_port | ( | const struct ast_uri * | uri | ) |
Retrieve the uri port.
Definition at line 130 of file uri.c.
References ast_uri::uri.
Referenced by AST_TEST_DEFINE(), ast_uri_make_host_with_port(), and uri_parse_and_default().
const char * ast_uri_query | ( | const struct ast_uri * | uri | ) |
Retrieve the uri query parameters.
Definition at line 140 of file uri.c.
References ast_uri::uri.
Referenced by AST_TEST_DEFINE(), and websocket_client_parse_uri().
const char * ast_uri_scheme | ( | const struct ast_uri * | uri | ) |
Retrieve the uri scheme.
Definition at line 115 of file uri.c.
References ast_uri::uri.
Referenced by AST_TEST_DEFINE().
const char * ast_uri_user_info | ( | const struct ast_uri * | uri | ) |
Retrieve the uri user information.
Definition at line 120 of file uri.c.
References ast_uri::uri.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 253 of file uri.c.
References ao2_ref, ast_free, ast_log, ast_malloc, ast_strlen_zero(), ast_uri_copy_replace(), ast_uri_is_secure(), ast_uri_parse(), ast_uri_port(), len(), LOG_ERROR, NULL, ast_uri::port, ast_uri::scheme, tmp(), and ast_uri::uri.
Referenced by ast_uri_parse_http(), and ast_uri_parse_websocket().